CommonQueryService.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Muchinfo.MTPClient.Adapter.Abstract;
  6. using Muchinfo.MTPClient.Data;
  7. using Muchinfo.MTPClient.Data.Enums;
  8. using Muchinfo.MTPClient.Data.Model.Account;
  9. using Muchinfo.MTPClient.Data.Model.Report;
  10. using Muchinfo.MTPClient.Infrastructure.LinkProxy;
  11. using Muchinfo.MTPClient.Infrastructure.Utilities;
  12. using Muchinfo.MTPClient.IService;
  13. using Muchinfo.MTPClient.Resources;
  14. using Muchinfo.MTPClient.Service.Utilities;
  15. using Muchinfo.MTPClient.Data.Model;
  16. using Muchinfo.MTPClient.Infrastructure.Cache;
  17. namespace Muchinfo.MTPClient.Service
  18. {
  19. /// <summary>
  20. /// 通用查询服务
  21. /// </summary>
  22. public class CommonQueryService : ICommonQueryService
  23. {
  24. #region Public Methods
  25. /// <summary>
  26. /// 查询市场运行状态
  27. /// </summary>
  28. /// <param name="marketId">The market identifier.</param>
  29. /// <param name="successAction">The success action.</param>
  30. /// <param name="errorAction">The error action.</param>
  31. public void QueryMarketRun(int marketId, Action<List<MarketRunModelNew>> successAction, Action<ErrorEntity> errorAction)
  32. {
  33. var statement = QueryStatement.ClientSearchMarketRun;
  34. var queryParams = new List<QueryCommonParam>()
  35. {
  36. new QueryCommonParam() { ParamKey = "marketId", ParamValue = marketId.ToString()},
  37. };
  38. QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询市场运行状态");
  39. }
  40. /// <summary>
  41. /// 查询结算单-资金账户信息
  42. /// </summary>
  43. /// <param name="cycleType">Type of the cycle.</param>
  44. /// <param name="cycleTime">The cycle time.</param>
  45. /// <param name="successAction">The success action.</param>
  46. /// <param name="errorAction">The error action.</param>
  47. /// <exception cref="System.NotImplementedException"></exception>
  48. public void QueryTaAccount(ReckonReportQueryType cycleType, string cycleTime, Action<List<ReckonAccountModel>> successAction, Action<ErrorEntity> errorAction)
  49. {
  50. var statement = QueryStatement.ClientDayRetortTaaccount;
  51. var queryParams = new List<QueryCommonParam>()
  52. {
  53. new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()},
  54. new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime },
  55. };
  56. if (cycleType != ReckonReportQueryType.DayReckon)
  57. {
  58. //周期报表
  59. statement = QueryStatement.ClientRetortTaaccount;
  60. queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() });
  61. }
  62. QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询结算单-账号资金信息");
  63. }
  64. /// <summary>
  65. /// 查询结算单-资金账户币种信息
  66. /// </summary>
  67. /// <param name="cycleType">Type of the cycle.</param>
  68. /// <param name="cycleTime">The cycle time.</param>
  69. /// <param name="successAction">The success action.</param>
  70. /// <param name="errorAction">The error action.</param>
  71. public void QueryTaAccountCur(ReckonReportQueryType cycleType, string cycleTime, Action<List<ReckonReportModel>> successAction, Action<ErrorEntity> errorAction)
  72. {
  73. var statement = QueryStatement.ClientReportDayTaAccountCur;
  74. var queryParams = new List<QueryCommonParam>()
  75. {
  76. new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()},
  77. new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime },
  78. };
  79. if (cycleType != ReckonReportQueryType.DayReckon)
  80. {
  81. //周期报表
  82. statement = QueryStatement.ClientReportTaAccountCur;
  83. queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() });
  84. }
  85. QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询结算单-资金账户币种信息");
  86. }
  87. /// <summary>
  88. /// 查询账户止盈止损单
  89. /// </summary>
  90. /// <param name="accountId">The account identifier.</param>
  91. /// <param name="successAction">The success action.</param>
  92. /// <param name="errorAction">The error action.</param>
  93. /// <exception cref="System.NotImplementedException"></exception>
  94. public void QuerySPSLOrder(ulong accountId, Action<List<SPSLOrderModel>> successAction, Action<ErrorEntity> errorAction)
  95. {
  96. var queryParams = new List<QueryCommonParam>()
  97. {
  98. new QueryCommonParam() { ParamKey = "accountid", ParamValue = accountId.ToString()},
  99. };
  100. QueryCommonHelper.QueryCommon(QueryStatement.ClientQuerySpslOrderdetail, queryParams, successAction, errorAction, "查询账户止盈止损单");
  101. }
  102. /// <summary>
  103. /// 查询资管内部委托单
  104. /// </summary>
  105. /// <param name="queryParams">The query parameters.</param>
  106. /// <param name="successAction">The success action.</param>
  107. /// <param name="errorAction">The error action.</param>
  108. public void QueryInnerHisOrderDetails(List<QueryCommonParam> queryParams, Action<List<Data.Model.Account.OrderDetail>> successAction, Action<ErrorEntity> errorAction)
  109. {
  110. QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerOrderDetail, queryParams, successAction, errorAction, "查询资管内部委托单");
  111. }
  112. /// <summary>
  113. /// 查询资管内部成交单
  114. /// </summary>
  115. /// <param name="queryParams">The query parameters.</param>
  116. /// <param name="successAction">The success action.</param>
  117. /// <param name="errorAction">The error action.</param>
  118. public void QueryInnerHisTradeDetails(List<QueryCommonParam> queryParams, Action<List<CompleteOrder>> successAction, Action<ErrorEntity> errorAction)
  119. {
  120. QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerTradeDetail, queryParams, successAction, errorAction, "查询资管内部成交单");
  121. }
  122. /// <summary>
  123. /// 查询资管内部平仓明细
  124. /// </summary>
  125. /// <param name="queryParams">The query parameters.</param>
  126. /// <param name="successAction">The success action.</param>
  127. /// <param name="errorAction">The error action.</param>
  128. /// <exception cref="System.NotImplementedException"></exception>
  129. public void QueryInnerHisCloseDetails(List<QueryCommonParam> queryParams, Action<List<Data.Model.Account.CloseDetail>> successAction, Action<ErrorEntity> errorAction)
  130. {
  131. QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerCloseDetail, queryParams, successAction, errorAction, "查询资管内部平仓明细");
  132. }
  133. /// <summary>
  134. /// 查询资管内部持仓单
  135. /// </summary>
  136. /// <param name="queryParams">The query parameters.</param>
  137. /// <param name="successAction">The success action.</param>
  138. /// <param name="errorAction">The error action.</param>
  139. public void QueryInnerHisHoldDetails(List<QueryCommonParam> queryParams, Action<List<HoldDetail>> successAction, Action<ErrorEntity> errorAction)
  140. {
  141. QueryCommonHelper.QueryCommon(QueryStatement.ClientInforHisInnerHolderDetail, queryParams, successAction, errorAction, "查询资管内部持仓单");
  142. }
  143. /// <summary>
  144. /// 查询账户持仓汇总
  145. /// </summary>
  146. /// <param name="cycleType">Type of the cycle.</param>
  147. /// <param name="cycleTime">The cycle time.</param>
  148. /// <param name="successAction">The success action.</param>
  149. /// <param name="errorAction">The error action.</param>
  150. /// <exception cref="System.NotImplementedException"></exception>
  151. public void QueryTradePostion(ReckonReportQueryType cycleType, string cycleTime, Action<List<TradePosition>> successAction, Action<ErrorEntity> errorAction)
  152. {
  153. var statement = QueryStatement.ClientDayRetortTradePosition;
  154. var queryParams = new List<QueryCommonParam>()
  155. {
  156. new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.FundsAccountId.ToString()},
  157. new QueryCommonParam() { ParamKey = "cycleTime", ParamValue = cycleTime },
  158. };
  159. if (cycleType != ReckonReportQueryType.DayReckon)
  160. {
  161. //周期报表
  162. statement = QueryStatement.ClientRetortTradePosition;
  163. queryParams.Add(new QueryCommonParam() { ParamKey = "cycleType", ParamValue = ((int)cycleType).ToString() });
  164. }
  165. QueryCommonHelper.QueryCommon(statement, queryParams, successAction, errorAction, "查询账户持仓汇总");
  166. }
  167. #endregion
  168. /// <summary>
  169. /// 查询账户汇率模板
  170. /// </summary>
  171. /// <param name="taAccountIdList">The ta account identifier list.</param>
  172. /// <param name="successAction">The success action.</param>
  173. /// <param name="errorAction">The error action.</param>
  174. public void QueryTradeRateTmpConfig(string taAccountIdList, Action<List<TradeRateTmpConfig>> successAction, Action<ErrorEntity> errorAction)
  175. {
  176. var statement = QueryStatement.ClientInforTradeRateTmpConfig;
  177. var queryParams = new List<QueryCommonParam>()
  178. {
  179. new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList},
  180. };
  181. QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<TradeRateTmpConfig>>((configs) =>
  182. {
  183. UserManager.TradeRateTmpConfigs = configs;
  184. if (successAction != null ) successAction(configs);
  185. }), errorAction, "查询账户汇率模板");
  186. }
  187. /// <summary>
  188. /// 查询外部汇率模版配置表
  189. /// </summary>
  190. /// <param name="taAccountIdList">The ta account identifier list.</param>
  191. /// <param name="tradeDate">交易日</param>
  192. /// <param name="successAction">The success action.</param>
  193. /// <param name="errorAction">The error action.</param>
  194. public void QueryExtenalTradeRateTmpConfig(string taAccountIdList, string tradeDate, Action<List<TradeRateTmpConfig>> successAction, Action<ErrorEntity> errorAction)
  195. {
  196. var statement = QueryStatement.ClientExtenalExchangeRate;
  197. var queryParams = new List<QueryCommonParam>()
  198. {
  199. new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList},
  200. new QueryCommonParam() { ParamKey = "tradeDate", ParamValue = tradeDate},
  201. };
  202. QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<TradeRateTmpConfig>>((configs) =>
  203. {
  204. UserManager.ExtenalTradeRateTmpConfigs = configs;
  205. if (successAction != null) successAction(configs);
  206. }), errorAction, "查询外部汇率模版配置表");
  207. }
  208. /// <summary>
  209. /// 查询资金账户汇率
  210. /// </summary>
  211. /// <param name="taAccountIdList">The ta account identifier list.</param>
  212. /// <param name="successAction">The success action.</param>
  213. /// <param name="errorAction">The error action.</param>
  214. public void QueryTaAccountExchangeRate(string taAccountIdList, Action<List<TradeRateTmpConfig>> successAction, Action<ErrorEntity> errorAction)
  215. {
  216. var statement = QueryStatement.TaAccountExchangeRate;
  217. var queryParams = new List<QueryCommonParam>()
  218. {
  219. new QueryCommonParam() { ParamKey = "taAccountIdList", ParamValue = taAccountIdList},
  220. };
  221. QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<TradeRateTmpConfig>>((configs) =>
  222. {
  223. UserManager.TaAccountExchangeRateConfigs = configs;
  224. if (successAction != null) successAction(configs);
  225. }), errorAction, "查询资金账户汇率");
  226. }
  227. /// <summary>
  228. /// 获取行情交易日
  229. /// </summary>
  230. /// <param name="successAction"></param>
  231. /// <param name="errorAction"></param>
  232. public void QuoteSourceGroupMarketDate(Action<List<QuoteSourceGroupMarketData>> successAction, Action<ErrorEntity> errorAction)
  233. {
  234. var statement = QueryStatement.QuoteSourceGroupMarketDate;
  235. var queryParams = new List<QueryCommonParam>()
  236. {
  237. };
  238. QueryCommonHelper.QueryCommon(statement, queryParams, new Action<List<QuoteSourceGroupMarketData>>((configs) =>
  239. {
  240. CacheManager.QuoteSourceGroupMarketDatas = configs;
  241. if (successAction != null) successAction(configs);
  242. }), errorAction, "获取行情交易日失败");
  243. }
  244. }
  245. }