HotlineWebController.cs 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621
  1. using DataSharing.FwDataExchange;
  2. using DataSharing.HotlineWeb;
  3. using DataSharing.Province;
  4. using DataSharing.Province.SendTask;
  5. using DataSharing.Province.SendTask.ProvinceOther;
  6. using DataSharing.Province.SendTask.SubmitCaseInfo;
  7. using DataSharing.Province.SendTask.SubmitCaseProcess;
  8. using DataSharing.Province.SendTask.SubmitCaseRecord;
  9. using DataSharing.Province.SendTask.SubmitCaseResult;
  10. using DataSharing.RawData;
  11. using DataSharing.Repository.Extensions;
  12. using DataSharing.SendTask;
  13. using DataSharing.SendTask.OtherPlatforms;
  14. using DataSharing.Share.Consts;
  15. using DataSharing.Share.Dtos;
  16. using DataSharing.Share.Dtos.Common;
  17. using DataSharing.Share.Dtos.FwDataExchange;
  18. using DataSharing.Share.Dtos.HotlineSetting;
  19. using DataSharing.Share.Dtos.HotlineWeb;
  20. using DataSharing.Share.Dtos.Statistics;
  21. using DataSharing.Share.Enums;
  22. using DataSharing.Share.Requests;
  23. using DotNetCore.CAP;
  24. using Hotline.Share.Dtos;
  25. using Hotline.Share.Dtos.Order;
  26. using MapsterMapper;
  27. using MediatR;
  28. using Microsoft.AspNetCore.Authorization;
  29. using Microsoft.AspNetCore.Mvc;
  30. using SqlSugar;
  31. using System.Security.Cryptography;
  32. using System.Text;
  33. using XC.RSAUtil;
  34. using XF.Domain.Cache;
  35. using XF.Domain.Exceptions;
  36. using XF.Domain.Repository;
  37. using XF.Utility.EnumExtensions;
  38. namespace DataSharing.Host.Controllers
  39. {
  40. /// <summary>
  41. ///
  42. /// </summary>
  43. public class HotlineWebController : BaseController
  44. {
  45. #region 注入
  46. private const string PublicKey = @"-----BEGIN PUBLIC KEY-----
  47. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgw+/x6IQPkH0A4eoF63j
  48. kLThsOXWyNBdcL9LATGy/G1yTHOr1RyKJB//iNug+V8DIoIHuFTlhgLHDbSqxvRW
  49. MONxIIF289riS6bDI4Ox/pFmOfmElFRk0lKGihaTE2Aefd6g/N+RfLLaHWztY+/v
  50. oVeDTiOIw9y3tokIxjKwuJ/mQ66MkKh78AqQjjSD/3jcBP8ZhMyCJOK9XQcqvhD6
  51. WBFWkxlAqKOWggDU7YohfrbNkg3bd0oGE6zCE2EHhkcQbzGCh3lu1zf4TfKMXD+P
  52. Prr5JWDNYQTXFQklqgae+Puge7xxZGYRoi5YpIUnkQGm6zpPxhIOdxlz+Yb5geSJ
  53. UQIDAQAB
  54. -----END PUBLIC KEY-----";
  55. private const string PrivateKey = @"-----BEGIN RSA PRIVATE KEY-----
  56. MIIEowIBAAKCAQEAgw+/x6IQPkH0A4eoF63jkLThsOXWyNBdcL9LATGy/G1yTHOr
  57. 1RyKJB//iNug+V8DIoIHuFTlhgLHDbSqxvRWMONxIIF289riS6bDI4Ox/pFmOfmE
  58. lFRk0lKGihaTE2Aefd6g/N+RfLLaHWztY+/voVeDTiOIw9y3tokIxjKwuJ/mQ66M
  59. kKh78AqQjjSD/3jcBP8ZhMyCJOK9XQcqvhD6WBFWkxlAqKOWggDU7YohfrbNkg3b
  60. d0oGE6zCE2EHhkcQbzGCh3lu1zf4TfKMXD+PPrr5JWDNYQTXFQklqgae+Puge7xx
  61. ZGYRoi5YpIUnkQGm6zpPxhIOdxlz+Yb5geSJUQIDAQABAoIBAAe+312BKUbsp0BV
  62. fOyCqoTLqTJHBcBneWY86pte9bjaZQYPU1PsdF452o8a38gXwpErBcwcjwCyWv48
  63. iQKUv8qdiSWGe+Jh3hGM1lKGfsyl3i3wnlJqgcI2U1zc2a4BoREHnmm4yBnfs2lI
  64. HegpRCG7u3cGPZfJtxJyxdHPfsc3wk8sXt+Byqkuym87l0a8wEF7b33f2hP2R7m/
  65. 37qYvTaGX3yN4s1rssQ3wBEfHEsesQmrQrEkRIUnWfgpkH3FdR5T1V4USC6GhM6x
  66. sIxqwBBYLL2LhVcNEifegqHtLZOw0VfUfpvoKnH5omSjUP5X+c8dmY9KPoKGpYFT
  67. l09fiRMCgYEAwSAmJr8G/xOCPtkRZ9qpxOwAeqA9iEhB3ViIydESrYMZGUaIKAWV
  68. ofOuDIdaMgW/2hyQtJasAnlX87Za7iODcBAMMAPSNiLEXk9nHWO+Xw/oMakgS5Dg
  69. uE2J02Bn4KFTCGALtfo70A40kkikkR2UdD4RG6j+DgI2JxxrCgaKiIMCgYEArbrv
  70. cvJs62LlvOFdVCY3mWEJkoBbStHGq2GdtZ5Rx9oNqiy3j/xT7Wav061OPCaC2rcd
  71. ALEH7AA3JJtAMr6QRv3HYyd2NIrlqS6pn4tInIpqlarrnVkkOk0WhsWVkScQJyx6
  72. eLKQ24zEF3wHslrRpHcclCWjtQ52TmWOuUvy9psCgYAWw6BbntbHSFho6hNIJ5kt
  73. Uhg4XB0ErGe/HIl7KH7IHxTdStgPx6C8p0mTxnyWOuFDZ2yTLNN3sy/v1UXgniUH
  74. F40oN7sWkICPEVL5PuGYuPpIqEPbRGeIsfMWDF4SN1HfQdr/h1B3lMUTnSZwyIjQ
  75. LuS7Wu8fXZlegNYJJ3462wKBgE5TSF9vktGw/djhVj15GXoKONGXExGxcDuWQA9A
  76. +Kf81EpT7NJ6tbADquPpb6tIxZgsFGRabDLnifT0FcaLCesnwXwfr3hS4uYaxpjK
  77. qAsDkLg3nhCLvvyWAsDyVdNiZDL1J6ZBA3Qoi8P2xFWSApB+ryDPs3YOtiH0QZui
  78. 9UBfAoGBAIQ2uv4J7ql++EpNNtLzOhTEpyjWS+qRSZRRXfKN2lm7e7czOsSpKIJx
  79. Q9PP8NTEmKqdI3WVFYqW/OlOFC6sjiscTOOn9Tc5Mrcn8ocCjAPjkhkCCVRMiJnv
  80. jxrWXHbT1FB6DqkdOnBbQqS1Azqz5HxLlSyEK3F60e3SgB5iZsDZ
  81. -----END RSA PRIVATE KEY-----";
  82. private readonly IMapper _mapper;
  83. private readonly IMediator _mediator;
  84. private readonly ICapPublisher _capPublisher;
  85. private readonly IRepository<DsOrderSend> _dsOrderSendRepository;
  86. private readonly IRepository<DsTelCall> _dsTelCallRepository;
  87. private readonly IRepository<ConfigurationInformation> _configurationInformationRepository;
  88. private readonly ITypedCache<ConfigurationInformationDto> _configurationInformationCache;
  89. private readonly IRepository<DsOrderVisitSend> _dsOrderVisitSendRepository;
  90. private readonly IRepository<DsKnowledgeRawData> _knowledgeRawDataRepository;
  91. private readonly IRepository<DsUserTokenInfo> _dsUserTokenInfoRepository;
  92. private readonly IRepository<DsWaitSendTaskProvinceOther> _waitSendTaskProvinceOtherRepository;
  93. private readonly IRepository<DsSendTaskProvinceOther> _sendTaskProvinceOtherRepository;
  94. private readonly IRepository<DsWaitSendTaskSubmitCaseInfo> _waitSendTaskSubmitCaseInfoRepository;
  95. private readonly IRepository<DsSendTaskSubmitCaseInfo> _sendTaskSubmitCaseInfoRepository;
  96. private readonly IRepository<DsWaitSendTaskSubmitCaseProcess> _waitSendTaskSubmitCaseProcessRepository;
  97. private readonly IRepository<DsSendTaskSubmitCaseProcess> _sendTaskSubmitCaseProcessRepository;
  98. private readonly IRepository<DsWaitSendTaskSubmitCaseRecord> _waitSendTaskSubmitCaseRecordRepository;
  99. private readonly IRepository<DsSendTaskSubmitCaseRecord> _sendTaskSubmitCaseRecordRepository;
  100. private readonly IRepository<DsWaitSendTaskSubmitCaseResult> _waitSendTaskSubmitCaseResultRepository;
  101. private readonly IRepository<DsSendTaskSubmitCaseResult> _sendTaskSubmitCaseResultRepository;
  102. private readonly IWaitSendTaskRepository _waitSendTaskRepository;
  103. private readonly IRepository<DsSendTaskDetailInfo> _sendTaskDetailInfoRepository;
  104. private readonly IRepository<DsWaitSendTaskOtherPlatforms> _waitSendTaskOtherPlatformsRepository;
  105. private readonly IRepository<DsSendTaskOtherPlatforms> _sendTaskOtherPlatformsRepository;
  106. private readonly IInitPushDataService _initPushDataService;
  107. private readonly IRepository<SendHotlineErrorData> _sendHotlineErrorDataRepository;
  108. private readonly FwClient _fwClient;
  109. private readonly ISharingConfigurationManager _sharingConfigurationManager;
  110. private readonly IRepository<UserOperationLog> _userOperationLogRepository;
  111. private readonly IRepository<SendFwErrorData> _sendFwErrorDataRepository;
  112. private readonly IRepository<DsGetCaseMaterialInfo> _getCaseMaterialInfoRepository;
  113. private readonly IRepository<DsReceiveHandleData> _dsReceiveHandleDataRepository;
  114. private readonly IRepository<DsGetCaseDistrecordSend> _getCaseDistrecordSendRepository;
  115. /// <summary>
  116. ///
  117. /// </summary>
  118. /// <param name="mapper"></param>
  119. /// <param name="mediator"></param>
  120. /// <param name="capPublisher"></param>
  121. /// <param name="dsOrderSendRepository"></param>
  122. /// <param name="dsTelCallRepository"></param>
  123. /// <param name="configurationInformationRepository"></param>
  124. /// <param name="configurationInformationCache"></param>
  125. /// <param name="dsOrderVisitSendRepository"></param>
  126. /// <param name="knowledgeRawDataRepository"></param>
  127. /// <param name="dsUserTokenInfoRepository"></param>
  128. /// <param name="waitSendTaskProvinceOtherRepository"></param>
  129. /// <param name="sendTaskProvinceOtherRepository"></param>
  130. /// <param name="waitSendTaskSubmitCaseInfoRepository"></param>
  131. /// <param name="sendTaskSubmitCaseInfoRepository"></param>
  132. /// <param name="waitSendTaskSubmitCaseProcessRepository"></param>
  133. /// <param name="sendTaskSubmitCaseProcessRepository"></param>
  134. /// <param name="waitSendTaskSubmitCaseRecordRepository"></param>
  135. /// <param name="sendTaskSubmitCaseRecordRepository"></param>
  136. /// <param name="waitSendTaskSubmitCaseResultRepository"></param>
  137. /// <param name="sendTaskSubmitCaseResultRepository"></param>
  138. /// <param name="waitSendTaskRepository"></param>
  139. /// <param name="sendTaskDetailInfoRepository"></param>
  140. /// <param name="waitSendTaskOtherPlatformsRepository"></param>
  141. /// <param name="sendTaskOtherPlatformsRepository"></param>
  142. /// <param name="initPushDataService"></param>
  143. /// <param name="sendHotlineErrorDataRepository"></param>
  144. /// <param name="fwClient"></param>
  145. /// <param name="sharingConfigurationManager"></param>
  146. /// <param name="userOperationLogRepository"></param>
  147. /// <param name="sendFwErrorDataRepository"></param>
  148. /// <param name="getCaseMaterialInfoRepository"></param>
  149. /// <param name="dsReceiveHandleDataRepository"></param>
  150. /// <param name="getCaseDistrecordSendRepository"></param>
  151. public HotlineWebController(IMapper mapper,
  152. IMediator mediator,
  153. ICapPublisher capPublisher,
  154. IRepository<DsOrderSend> dsOrderSendRepository,
  155. IRepository<DsTelCall> dsTelCallRepository,
  156. IRepository<ConfigurationInformation> configurationInformationRepository,
  157. ITypedCache<ConfigurationInformationDto> configurationInformationCache,
  158. IRepository<DsOrderVisitSend> dsOrderVisitSendRepository,
  159. IRepository<DsKnowledgeRawData> knowledgeRawDataRepository,
  160. IRepository<DsUserTokenInfo> dsUserTokenInfoRepository,
  161. IRepository<DsWaitSendTaskProvinceOther> waitSendTaskProvinceOtherRepository,
  162. IRepository<DsSendTaskProvinceOther> sendTaskProvinceOtherRepository,
  163. IRepository<DsWaitSendTaskSubmitCaseInfo> waitSendTaskSubmitCaseInfoRepository,
  164. IRepository<DsSendTaskSubmitCaseInfo> sendTaskSubmitCaseInfoRepository,
  165. IRepository<DsWaitSendTaskSubmitCaseProcess> waitSendTaskSubmitCaseProcessRepository,
  166. IRepository<DsSendTaskSubmitCaseProcess> sendTaskSubmitCaseProcessRepository,
  167. IRepository<DsWaitSendTaskSubmitCaseRecord> waitSendTaskSubmitCaseRecordRepository,
  168. IRepository<DsSendTaskSubmitCaseRecord> sendTaskSubmitCaseRecordRepository,
  169. IRepository<DsWaitSendTaskSubmitCaseResult> waitSendTaskSubmitCaseResultRepository,
  170. IRepository<DsSendTaskSubmitCaseResult> sendTaskSubmitCaseResultRepository,
  171. IWaitSendTaskRepository waitSendTaskRepository,
  172. IRepository<DsSendTaskDetailInfo> sendTaskDetailInfoRepository,
  173. IRepository<DsWaitSendTaskOtherPlatforms> waitSendTaskOtherPlatformsRepository,
  174. IRepository<DsSendTaskOtherPlatforms> sendTaskOtherPlatformsRepository,
  175. IInitPushDataService initPushDataService,
  176. IRepository<SendHotlineErrorData> sendHotlineErrorDataRepository,
  177. FwClient fwClient,
  178. ISharingConfigurationManager sharingConfigurationManager,
  179. IRepository<UserOperationLog> userOperationLogRepository,
  180. IRepository<SendFwErrorData> sendFwErrorDataRepository,
  181. IRepository<DsGetCaseMaterialInfo> getCaseMaterialInfoRepository,
  182. IRepository<DsReceiveHandleData> dsReceiveHandleDataRepository,
  183. IRepository<DsGetCaseDistrecordSend> getCaseDistrecordSendRepository
  184. )
  185. {
  186. _mapper = mapper;
  187. _mediator = mediator;
  188. _capPublisher = capPublisher;
  189. _dsOrderSendRepository = dsOrderSendRepository;
  190. _dsTelCallRepository = dsTelCallRepository;
  191. _configurationInformationRepository = configurationInformationRepository;
  192. _configurationInformationCache = configurationInformationCache;
  193. _dsOrderVisitSendRepository = dsOrderVisitSendRepository;
  194. _knowledgeRawDataRepository = knowledgeRawDataRepository;
  195. _dsUserTokenInfoRepository = dsUserTokenInfoRepository;
  196. _waitSendTaskProvinceOtherRepository = waitSendTaskProvinceOtherRepository;
  197. _sendTaskProvinceOtherRepository = sendTaskProvinceOtherRepository;
  198. _waitSendTaskSubmitCaseInfoRepository = waitSendTaskSubmitCaseInfoRepository;
  199. _sendTaskSubmitCaseInfoRepository = sendTaskSubmitCaseInfoRepository;
  200. _waitSendTaskSubmitCaseProcessRepository = waitSendTaskSubmitCaseProcessRepository;
  201. _sendTaskSubmitCaseProcessRepository = sendTaskSubmitCaseProcessRepository;
  202. _waitSendTaskSubmitCaseRecordRepository = waitSendTaskSubmitCaseRecordRepository;
  203. _sendTaskSubmitCaseRecordRepository = sendTaskSubmitCaseRecordRepository;
  204. _waitSendTaskSubmitCaseResultRepository = waitSendTaskSubmitCaseResultRepository;
  205. _sendTaskSubmitCaseResultRepository = sendTaskSubmitCaseResultRepository;
  206. _waitSendTaskRepository = waitSendTaskRepository;
  207. _sendTaskDetailInfoRepository = sendTaskDetailInfoRepository;
  208. _waitSendTaskOtherPlatformsRepository = waitSendTaskOtherPlatformsRepository;
  209. _sendTaskOtherPlatformsRepository = sendTaskOtherPlatformsRepository;
  210. _initPushDataService = initPushDataService;
  211. _sendHotlineErrorDataRepository = sendHotlineErrorDataRepository;
  212. _fwClient = fwClient;
  213. _sharingConfigurationManager = sharingConfigurationManager;
  214. _userOperationLogRepository = userOperationLogRepository;
  215. _sendFwErrorDataRepository = sendFwErrorDataRepository;
  216. _getCaseMaterialInfoRepository = getCaseMaterialInfoRepository;
  217. _dsReceiveHandleDataRepository = dsReceiveHandleDataRepository;
  218. _getCaseDistrecordSendRepository = getCaseDistrecordSendRepository;
  219. }
  220. #endregion
  221. #region 数据推送查询统计---最新
  222. #region 推送任务
  223. /// <summary>
  224. /// 省平台待推送数据
  225. /// </summary>
  226. /// <param name="dto"></param>
  227. /// <returns></returns>
  228. [HttpGet("getprovincewaitsendtasklist")]
  229. [AllowAnonymous]
  230. public async Task<PagedDto<DsWaitSendTaskDto>> GetProvinceWaitSendTaskList([FromQuery] QuerySendTaskDto dto)
  231. {
  232. if (!dto.StartTime.HasValue)
  233. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  234. if (!dto.EndTime.HasValue)
  235. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  236. #region 其他接口
  237. //其他接口
  238. var waitSendTaskProvinceOther = _waitSendTaskProvinceOtherRepository.Queryable()
  239. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  240. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  241. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  242. .Select(p => new DsWaitSendTaskDto
  243. {
  244. Id = p.Id,
  245. ProvinceNo = p.ProvinceNo,
  246. FirstTime = p.FirstTime,
  247. LastTime = p.LastTime,
  248. SendTimes = p.SendTimes,
  249. PlatformSource = EPlatformSource.Province,
  250. TaskType = p.TaskType,
  251. HttpMethod = p.HttpMethod,
  252. Path = p.Path,
  253. Request = p.Request,
  254. PathType = p.PathType,
  255. GenerationTime = p.GenerationTime,
  256. CreationTime = p.CreationTime,
  257. State = p.State
  258. })
  259. .MergeTable();
  260. #endregion
  261. #region 服务工单受理
  262. //服务工单受理
  263. var waitSendTaskSubmitCaseInfo = _waitSendTaskSubmitCaseInfoRepository.Queryable()
  264. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  265. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  266. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  267. .Select(p => new DsWaitSendTaskDto
  268. {
  269. Id = p.Id,
  270. ProvinceNo = p.ProvinceNo,
  271. FirstTime = p.FirstTime,
  272. LastTime = p.LastTime,
  273. SendTimes = p.SendTimes,
  274. PlatformSource = EPlatformSource.Province,
  275. TaskType = p.TaskType,
  276. HttpMethod = p.HttpMethod,
  277. Path = p.Path,
  278. Request = p.Request,
  279. PathType = p.PathType,
  280. GenerationTime = p.GenerationTime,
  281. CreationTime = p.CreationTime,
  282. State = p.State
  283. })
  284. .MergeTable();
  285. #endregion
  286. #region 服务工单处理过程
  287. //服务工单处理过程
  288. var waitSendTaskSubmitCaseProcess = _waitSendTaskSubmitCaseProcessRepository.Queryable()
  289. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  290. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  291. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  292. .Select(p => new DsWaitSendTaskDto
  293. {
  294. Id = p.Id,
  295. ProvinceNo = p.ProvinceNo,
  296. FirstTime = p.FirstTime,
  297. LastTime = p.LastTime,
  298. SendTimes = p.SendTimes,
  299. PlatformSource = EPlatformSource.Province,
  300. TaskType = p.TaskType,
  301. HttpMethod = p.HttpMethod,
  302. Path = p.Path,
  303. Request = p.Request,
  304. PathType = p.PathType,
  305. GenerationTime = p.GenerationTime,
  306. CreationTime = p.CreationTime,
  307. State = p.State
  308. })
  309. .MergeTable();
  310. #endregion
  311. #region 电话记录
  312. //电话记录
  313. var waitSendTaskSubmitCaseRecord = _waitSendTaskSubmitCaseRecordRepository.Queryable()
  314. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  315. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  316. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  317. .Select(p => new DsWaitSendTaskDto
  318. {
  319. Id = p.Id,
  320. ProvinceNo = p.ProvinceNo,
  321. FirstTime = p.FirstTime,
  322. LastTime = p.LastTime,
  323. SendTimes = p.SendTimes,
  324. PlatformSource = EPlatformSource.Province,
  325. TaskType = p.TaskType,
  326. HttpMethod = p.HttpMethod,
  327. Path = p.Path,
  328. Request = p.Request,
  329. PathType = p.PathType,
  330. GenerationTime = p.GenerationTime,
  331. CreationTime = p.CreationTime,
  332. State = p.State
  333. })
  334. .MergeTable();
  335. #endregion
  336. #region 服务工单处理结果
  337. //服务工单处理结果
  338. var waitSendTaskSubmitCaseResult = _waitSendTaskSubmitCaseResultRepository.Queryable()
  339. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  340. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  341. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  342. .Select(p => new DsWaitSendTaskDto
  343. {
  344. Id = p.Id,
  345. ProvinceNo = p.ProvinceNo,
  346. FirstTime = p.FirstTime,
  347. LastTime = p.LastTime,
  348. SendTimes = p.SendTimes,
  349. PlatformSource = EPlatformSource.Province,
  350. TaskType = p.TaskType,
  351. HttpMethod = p.HttpMethod,
  352. Path = p.Path,
  353. Request = p.Request,
  354. PathType = p.PathType,
  355. GenerationTime = p.GenerationTime,
  356. CreationTime = p.CreationTime,
  357. State = p.State
  358. })
  359. .MergeTable();
  360. #endregion
  361. //连表查询数据
  362. RefAsync<int> total = 0;
  363. var items = await _waitSendTaskRepository.UnionAll(waitSendTaskProvinceOther, waitSendTaskSubmitCaseInfo, waitSendTaskSubmitCaseProcess,
  364. waitSendTaskSubmitCaseRecord, waitSendTaskSubmitCaseResult).MergeTable()
  365. .OrderBy(p => p.CreationTime)
  366. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  367. return new PagedDto<DsWaitSendTaskDto>(total, _mapper.Map<List<DsWaitSendTaskDto>>(items));
  368. }
  369. /// <summary>
  370. /// 其他平台待推送数据
  371. /// </summary>
  372. /// <param name="dto"></param>
  373. /// <returns></returns>
  374. [HttpGet("getotherplatformswaitsendtasklist")]
  375. [AllowAnonymous]
  376. public async Task<PagedDto<DsWaitSendTaskDto>> GetOtherPlatformsWaitSendTaskList([FromQuery] QuerySendTaskDto dto)
  377. {
  378. if (!dto.StartTime.HasValue)
  379. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  380. if (!dto.EndTime.HasValue)
  381. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  382. RefAsync<int> total = 0;
  383. //其他平台
  384. var items = await _waitSendTaskOtherPlatformsRepository.Queryable()
  385. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  386. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  387. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  388. .WhereIF(dto.PlatformSource.HasValue, p => p.PlatformSource == dto.PlatformSource)
  389. .Select(p => new DsWaitSendTaskDto
  390. {
  391. Id = p.Id,
  392. ProvinceNo = p.ProvinceNo,
  393. FirstTime = p.FirstTime,
  394. LastTime = p.LastTime,
  395. SendTimes = p.SendTimes,
  396. PlatformSource = p.PlatformSource,
  397. TaskType = p.TaskType,
  398. HttpMethod = p.HttpMethod,
  399. Path = p.Path,
  400. Request = p.Request,
  401. PathType = p.PathType,
  402. GenerationTime = p.GenerationTime,
  403. CreationTime = p.CreationTime
  404. })
  405. .MergeTable()
  406. .OrderBy(p => p.CreationTime)
  407. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  408. return new PagedDto<DsWaitSendTaskDto>(total, _mapper.Map<List<DsWaitSendTaskDto>>(items));
  409. }
  410. /// <summary>
  411. /// 查询任务推送明细
  412. /// </summary>
  413. /// <param name="dto"></param>
  414. /// <returns></returns>
  415. [HttpGet("getdssenddetailtaskinfo")]
  416. [AllowAnonymous]
  417. public async Task<PagedDto<DsSendTaskDetailInfo>> GetDsSendDetailTaskInfo([FromQuery] QuerySendTaskDto dto)
  418. {
  419. //数据查询
  420. RefAsync<int> total = 0;
  421. var items = await _sendTaskDetailInfoRepository.Queryable()
  422. .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime)
  423. .WhereIF(dto.EndTime.HasValue, p => p.CreationTime <= dto.EndTime)
  424. .WhereIF(!string.IsNullOrEmpty(dto.Id), p => p.TaskId == dto.Id)
  425. .WhereIF(dto.IsSuccess.HasValue, p => p.IsSuccess == dto.IsSuccess)
  426. .OrderByDescending(p => p.CreationTime)
  427. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  428. return new PagedDto<DsSendTaskDetailInfo>(total, items);
  429. }
  430. /// <summary>
  431. ///
  432. /// </summary>
  433. /// <returns></returns>
  434. [HttpGet("getbaseinfo")]
  435. [AllowAnonymous]
  436. public async Task<object> GetBaseInfo()
  437. {
  438. var rsp = new
  439. {
  440. EPlatformSource = EnumExts.GetDescriptions<EPlatformSource>(),
  441. };
  442. return rsp;
  443. }
  444. /// <summary>
  445. /// 查询已推送任务 查询类型 1:服务工单受理,2、电话记录,3、服务工单处理过程,4、服务工单处理结果,5、省平台其他推送,6、其他平台
  446. /// </summary>
  447. /// <param name="dto"></param>
  448. /// <returns></returns>
  449. [HttpGet("getdssendendtask")]
  450. [AllowAnonymous]
  451. public async Task<PagedDto<DsEndSendTaskDto>> GetDsSendEndTask([FromQuery] QuerySendTaskDto dto)
  452. {
  453. if (!dto.StartTime.HasValue)
  454. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  455. if (!dto.EndTime.HasValue)
  456. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  457. //数据查询
  458. RefAsync<int> total = 0;
  459. //服务工单受理
  460. if (dto.SelectType == "1")
  461. {
  462. //服务工单受理
  463. var items = await _sendTaskSubmitCaseInfoRepository.Queryable()
  464. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  465. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  466. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  467. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.IsSuccess == ESendTaskState.PushSuccess)
  468. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.IsSuccess == ESendTaskState.PushFail)
  469. .Select(p => new DsEndSendTaskDto
  470. {
  471. Id = p.Id,
  472. ProvinceNo = p.ProvinceNo,
  473. FirstTime = p.FirstTime,
  474. LastTime = p.LastTime,
  475. SendTimes = p.SendTimes,
  476. PlatformSource = EPlatformSource.Province,
  477. TaskType = p.TaskType,
  478. HttpMethod = p.HttpMethod,
  479. Path = p.Path,
  480. Request = p.Request,
  481. PathType = p.PathType,
  482. GenerationTime = p.GenerationTime,
  483. CreationTime = p.CreationTime,
  484. IsSuccess = p.IsSuccess,
  485. ExpiredTime = p.ExpiredTime
  486. })
  487. .MergeTable()
  488. .OrderByDescending(p => p.CreationTime)
  489. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  490. return new PagedDto<DsEndSendTaskDto>(total, _mapper.Map<List<DsEndSendTaskDto>>(items));
  491. }
  492. //电话记录
  493. if (dto.SelectType == "2")
  494. {
  495. //电话记录
  496. var items = await _sendTaskSubmitCaseRecordRepository.Queryable()
  497. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  498. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  499. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  500. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.IsSuccess == ESendTaskState.PushSuccess)
  501. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.IsSuccess == ESendTaskState.PushFail)
  502. .Select(p => new DsEndSendTaskDto
  503. {
  504. Id = p.Id,
  505. ProvinceNo = p.ProvinceNo,
  506. FirstTime = p.FirstTime,
  507. LastTime = p.LastTime,
  508. SendTimes = p.SendTimes,
  509. PlatformSource = EPlatformSource.Province,
  510. TaskType = p.TaskType,
  511. HttpMethod = p.HttpMethod,
  512. Path = p.Path,
  513. Request = p.Request,
  514. PathType = p.PathType,
  515. GenerationTime = p.GenerationTime,
  516. CreationTime = p.CreationTime,
  517. IsSuccess = p.IsSuccess
  518. })
  519. .MergeTable()
  520. .OrderByDescending(p => p.CreationTime)
  521. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  522. return new PagedDto<DsEndSendTaskDto>(total, _mapper.Map<List<DsEndSendTaskDto>>(items));
  523. }
  524. //服务工单处理过程
  525. if (dto.SelectType == "3")
  526. {
  527. //服务工单处理过程
  528. var items = await _sendTaskSubmitCaseProcessRepository.Queryable()
  529. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  530. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  531. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  532. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.IsSuccess == ESendTaskState.PushSuccess)
  533. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.IsSuccess == ESendTaskState.PushFail)
  534. .Select(p => new DsEndSendTaskDto
  535. {
  536. Id = p.Id,
  537. ProvinceNo = p.ProvinceNo,
  538. FirstTime = p.FirstTime,
  539. LastTime = p.LastTime,
  540. SendTimes = p.SendTimes,
  541. PlatformSource = EPlatformSource.Province,
  542. TaskType = p.TaskType,
  543. HttpMethod = p.HttpMethod,
  544. Path = p.Path,
  545. Request = p.Request,
  546. PathType = p.PathType,
  547. GenerationTime = p.GenerationTime,
  548. CreationTime = p.CreationTime,
  549. IsSuccess = p.IsSuccess
  550. })
  551. .OrderByDescending(p => p.CreationTime)
  552. .MergeTable().ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  553. return new PagedDto<DsEndSendTaskDto>(total, _mapper.Map<List<DsEndSendTaskDto>>(items));
  554. }
  555. //服务工单处理结果
  556. if (dto.SelectType == "4")
  557. {
  558. //服务工单处理结果
  559. var items = await _sendTaskSubmitCaseResultRepository.Queryable()
  560. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  561. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  562. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  563. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.IsSuccess == ESendTaskState.PushSuccess)
  564. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.IsSuccess == ESendTaskState.PushFail)
  565. .Select(p => new DsEndSendTaskDto
  566. {
  567. Id = p.Id,
  568. ProvinceNo = p.ProvinceNo,
  569. FirstTime = p.FirstTime,
  570. LastTime = p.LastTime,
  571. SendTimes = p.SendTimes,
  572. PlatformSource = EPlatformSource.Province,
  573. TaskType = p.TaskType,
  574. HttpMethod = p.HttpMethod,
  575. Path = p.Path,
  576. Request = p.Request,
  577. PathType = p.PathType,
  578. GenerationTime = p.GenerationTime,
  579. CreationTime = p.CreationTime,
  580. IsSuccess = p.IsSuccess,
  581. FiledTime = p.FiledTime,
  582. ExpiredTime = SqlFunc.Subqueryable<DsSendTaskSubmitCaseInfo>().Where(s => s.ProvinceNo == p.ProvinceNo).OrderByDesc(s => s.LastTime).Select(s => s.ExpiredTime)
  583. })
  584. .OrderByDescending(p => p.CreationTime)
  585. .MergeTable().ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  586. return new PagedDto<DsEndSendTaskDto>(total, _mapper.Map<List<DsEndSendTaskDto>>(items));
  587. }
  588. //其他接口
  589. if (dto.SelectType == "5")
  590. {
  591. //其他接口
  592. var items = await _sendTaskProvinceOtherRepository.Queryable()
  593. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  594. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  595. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  596. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.IsSuccess == ESendTaskState.PushSuccess)
  597. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.IsSuccess == ESendTaskState.PushFail)
  598. .Select(p => new DsEndSendTaskDto
  599. {
  600. Id = p.Id,
  601. ProvinceNo = p.ProvinceNo,
  602. FirstTime = p.FirstTime,
  603. LastTime = p.LastTime,
  604. SendTimes = p.SendTimes,
  605. PlatformSource = EPlatformSource.Province,
  606. TaskType = p.TaskType,
  607. HttpMethod = p.HttpMethod,
  608. Path = p.Path,
  609. Request = p.Request,
  610. PathType = p.PathType,
  611. GenerationTime = p.GenerationTime,
  612. CreationTime = p.CreationTime,
  613. IsSuccess = p.IsSuccess
  614. })
  615. .OrderByDescending(p => p.CreationTime)
  616. .MergeTable().ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  617. return new PagedDto<DsEndSendTaskDto>(total, _mapper.Map<List<DsEndSendTaskDto>>(items));
  618. }
  619. //其他平台
  620. if (dto.SelectType == "6")
  621. {
  622. //其他平台
  623. var items = await _sendTaskOtherPlatformsRepository.Queryable()
  624. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  625. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  626. .WhereIF(!string.IsNullOrEmpty(dto.Path), p => p.Path == dto.Path)
  627. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.IsSuccess == ESendTaskState.PushSuccess)
  628. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.IsSuccess == ESendTaskState.PushFail)
  629. .WhereIF(dto.PlatformSource.HasValue, p => p.PlatformSource == dto.PlatformSource)
  630. .Select(p => new DsEndSendTaskDto
  631. {
  632. Id = p.Id,
  633. ProvinceNo = p.ProvinceNo,
  634. FirstTime = p.FirstTime,
  635. LastTime = p.LastTime,
  636. SendTimes = p.SendTimes,
  637. PlatformSource = p.PlatformSource,
  638. TaskType = p.TaskType,
  639. HttpMethod = p.HttpMethod,
  640. Path = p.Path,
  641. Request = p.Request,
  642. PathType = p.PathType,
  643. GenerationTime = p.GenerationTime,
  644. CreationTime = p.CreationTime,
  645. IsSuccess = p.IsSuccess
  646. })
  647. .MergeTable()
  648. .OrderBy(p => p.CreationTime)
  649. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  650. return new PagedDto<DsEndSendTaskDto>(total, _mapper.Map<List<DsEndSendTaskDto>>(items));
  651. }
  652. return new PagedDto<DsEndSendTaskDto>(total, null);
  653. }
  654. /// <summary>
  655. /// 根据ID从新推送
  656. /// </summary>
  657. /// <param name="Id">推送任务Id</param>
  658. /// <param name="Type">类型 1:服务工单受理,2、电话记录,3、服务工单处理过程,4、服务工单处理结果,5、省平台其他推送,6、其他平台</param>
  659. /// <returns></returns>
  660. [HttpGet("addnewtasksendbyid")]
  661. [AllowAnonymous]
  662. public async Task AddNewTaskSendById(string Id, string Type)
  663. {
  664. if (string.IsNullOrEmpty(Id) || string.IsNullOrEmpty(Type))
  665. throw UserFriendlyException.SameMessage("参数无效");
  666. var userInfo = Request.Headers["userinfo"].ToString();
  667. if (string.IsNullOrEmpty(userInfo))
  668. throw UserFriendlyException.SameMessage("用户信息获取失败");
  669. var pkcs1 = new RsaPkcs1Util(Encoding.UTF8, PublicKey, PrivateKey);
  670. var info = pkcs1.Decrypt(userInfo, RSAEncryptionPadding.Pkcs1);
  671. if (info == null)
  672. throw UserFriendlyException.SameMessage("用户信息获取失败");
  673. var user = System.Text.Json.JsonSerializer.Deserialize<UserInfo>(info);
  674. if (user == null)
  675. throw UserFriendlyException.SameMessage("用户信息获取失败");
  676. //写入操作记录
  677. UserOperationLog operationLog = new()
  678. {
  679. DataId = Id,
  680. PlatformSource = EPlatformSource.Province,
  681. UserId = user.UserId,
  682. UserName = user.UserName,
  683. OrgCode = user.OrgCode,
  684. OrgName = user.OrgName
  685. };
  686. string resultId = "";
  687. //服务工单受理
  688. if (Type == "1")
  689. {
  690. var data = await _sendTaskSubmitCaseInfoRepository.GetAsync(Id, HttpContext.RequestAborted);
  691. if (data != null)
  692. {
  693. operationLog.ReceiveServiceInterface = data.TaskType;
  694. operationLog.Path = data.Path;
  695. operationLog.RequestData = data.Request;
  696. resultId = await _initPushDataService.InitDsSendTaskSubmitCaseInfo(data.OrderId, data.ProvinceNo, data.Request, data.RequestData, data.GenerationTime, HttpContext.RequestAborted);
  697. }
  698. }
  699. //电话记录
  700. if (Type == "2")
  701. {
  702. var data = await _sendTaskSubmitCaseRecordRepository.GetAsync(Id, HttpContext.RequestAborted);
  703. if (data != null)
  704. {
  705. operationLog.ReceiveServiceInterface = data.TaskType;
  706. operationLog.Path = data.Path;
  707. operationLog.RequestData = data.Request;
  708. resultId = await _initPushDataService.InitDsSendTaskSubmitCaseRecord(data.ProvinceNo, data.CallId, data.CallLogId, data.Request, data.RequestData, data.GenerationTime, HttpContext.RequestAborted);
  709. }
  710. }
  711. //服务工单处理过程
  712. if (Type == "3")
  713. {
  714. var data = await _sendTaskSubmitCaseProcessRepository.GetAsync(Id, HttpContext.RequestAborted);
  715. if (data != null)
  716. {
  717. operationLog.ReceiveServiceInterface = data.TaskType;
  718. operationLog.Path = data.Path;
  719. operationLog.RequestData = data.Request;
  720. resultId = await _initPushDataService.InitDsSendTaskSubmitCaseProcess(data.ProvinceNo, data.Request, data.RequestData, data.GenerationTime, HttpContext.RequestAborted);
  721. }
  722. }
  723. //服务工单处理结果
  724. if (Type == "4")
  725. {
  726. var data = await _sendTaskSubmitCaseResultRepository.GetAsync(Id, HttpContext.RequestAborted);
  727. if (data != null)
  728. {
  729. operationLog.ReceiveServiceInterface = data.TaskType;
  730. operationLog.Path = data.Path;
  731. operationLog.RequestData = data.Request;
  732. resultId = await _initPushDataService.InitDsSendTaskSubmitCaseResult(data.ProvinceNo, data.Request, data.RequestData, data.GenerationTime, HttpContext.RequestAborted);
  733. }
  734. }
  735. //其他接口
  736. if (Type == "5")
  737. {
  738. var data = await _sendTaskProvinceOtherRepository.GetAsync(Id, HttpContext.RequestAborted);
  739. if (data != null)
  740. {
  741. operationLog.ReceiveServiceInterface = data.TaskType;
  742. operationLog.Path = data.Path;
  743. operationLog.RequestData = data.Request;
  744. resultId = await _initPushDataService.InitDsSendTaskProvinceOther(data.TaskType, data.Path, data.ProvinceNo, data.Request, data.RequestData, data.HttpMethod, data.PathType.Value, data.FileJson, data.GenerationTime, cancellationToken: HttpContext.RequestAborted);
  745. }
  746. }
  747. //其他平台
  748. if (Type == "6")
  749. {
  750. var data = await _sendTaskOtherPlatformsRepository.GetAsync(Id, HttpContext.RequestAborted);
  751. if (data != null)
  752. {
  753. operationLog.ReceiveServiceInterface = data.TaskType;
  754. operationLog.Path = data.Path;
  755. operationLog.RequestData = data.Request;
  756. resultId = await _initPushDataService.InitDsSendTaskOtherPlatforms(data.TaskType, data.Path, data.ProvinceNo, data.Request, data.RequestData, data.PlatformSource, data.HttpMethod, data.PathType.Value, data.FileJson, data.GenerationTime, HttpContext.RequestAborted);
  757. }
  758. }
  759. operationLog.NewDataId = resultId;
  760. await _userOperationLogRepository.AddAsync(operationLog, HttpContext.RequestAborted);
  761. if (string.IsNullOrEmpty(resultId))
  762. throw UserFriendlyException.SameMessage("重新推送失败");
  763. }
  764. #endregion
  765. #region 及时性
  766. /// <summary>
  767. /// 查询工单及时上传列表
  768. /// </summary>
  769. /// <param name="dto"></param>
  770. /// <returns></returns>
  771. [HttpGet("getordertimelylist")]
  772. [AllowAnonymous]
  773. public async Task<PagedDto<object>> GetOrderTimelyList([FromQuery] QuerySendTaskDto dto)
  774. {
  775. if (!dto.StartTime.HasValue)
  776. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  777. if (!dto.EndTime.HasValue)
  778. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  779. //数据查询
  780. RefAsync<int> total = 0;
  781. var items = await _sendTaskSubmitCaseInfoRepository.Queryable()
  782. .Where(p => p.GenerationTime >= dto.StartTime && p.GenerationTime <= dto.EndTime)
  783. .Where(p => p.LastTime >= dto.StartTime && p.LastTime <= dto.EndTime && p.IsSuccess == ESendTaskState.PushSuccess)
  784. .Select(p => new
  785. {
  786. index = SqlFunc.RowNumber($"{p.LastTime} asc ", $"{p.ProvinceNo}"),
  787. ProvinceNo = p.ProvinceNo,
  788. FirstTime = p.FirstTime,
  789. LastTime = p.LastTime,
  790. SendTimes = p.SendTimes,
  791. StartTime = p.GenerationTime,
  792. CreationTime = p.CreationTime,
  793. IntervalTime = SqlFunc.DateDiff(DateType.Second, p.GenerationTime.Value, p.LastTime.Value),
  794. CaseSource = p.CaseSource,
  795. p.RequestData,
  796. p.OrderId
  797. })
  798. .MergeTable()
  799. .Where(d => d.index == 1)
  800. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, d => SqlFunc.DateDiff(DateType.Second, d.StartTime.Value, d.LastTime.Value) <= 180)//及时上传
  801. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, d => SqlFunc.DateDiff(DateType.Second, d.StartTime.Value, d.LastTime.Value) > 180)//不及时上传
  802. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  803. .OrderByDescending(d => d.CreationTime)
  804. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  805. return new PagedDto<object>(total, items);
  806. }
  807. /// <summary>
  808. /// 查询通话记录及时上传列表
  809. /// </summary>
  810. /// <param name="dto"></param>
  811. /// <returns></returns>
  812. [HttpGet("getcalllist")]
  813. [AllowAnonymous]
  814. public async Task<PagedDto<object>> GetCalllist([FromQuery] QuerySendTaskDto dto)
  815. {
  816. if (!dto.StartTime.HasValue)
  817. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  818. if (!dto.EndTime.HasValue)
  819. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  820. RefAsync<int> total = 0;
  821. var items = await _sendTaskSubmitCaseRecordRepository.Queryable()
  822. .Where(p => p.GenerationTime >= dto.StartTime && p.GenerationTime <= dto.EndTime)
  823. .Where(p => p.LastTime >= dto.StartTime && p.LastTime <= dto.EndTime && p.IsSuccess == ESendTaskState.PushSuccess)
  824. .Select(p => new
  825. {
  826. index = SqlFunc.RowNumber($"{p.LastTime} asc ", $"{p.CallId}"),
  827. ProvinceNo = p.ProvinceNo,
  828. FirstTime = p.FirstTime,
  829. LastTime = p.LastTime,
  830. SendTimes = p.SendTimes,
  831. StartTime = p.GenerationTime,
  832. CreationTime = p.CreationTime,
  833. IntervalTime = SqlFunc.DateDiff(DateType.Second, p.GenerationTime.Value, p.LastTime.Value),
  834. CallId = p.CallId,
  835. CallLogId = p.CallLogId,
  836. CallDirection = p.CallDirection,
  837. OnState = p.OnState,
  838. p.RequestData
  839. })
  840. .MergeTable()
  841. .Where(d => d.index == 1)
  842. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, d => SqlFunc.DateDiff(DateType.Second, d.StartTime.Value, d.LastTime.Value) <= 180)//及时上传
  843. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, d => SqlFunc.DateDiff(DateType.Second, d.StartTime.Value, d.LastTime.Value) > 180)//不及时上传
  844. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  845. .OrderByDescending(d => d.CreationTime)
  846. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  847. return new PagedDto<object>(total, items);
  848. }
  849. /// <summary>
  850. /// 查询没匹配到通话记录的电话来源工单
  851. /// </summary>
  852. /// <param name="dto"></param>
  853. /// <returns></returns>
  854. [HttpGet("getordermatchingcalllist")]
  855. [AllowAnonymous]
  856. public async Task<PagedDto<OrderMatchingCallDto>> GetOrderMatchingCallList([FromQuery] QuerySendTaskDto dto)
  857. {
  858. if (!dto.StartTime.HasValue)
  859. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  860. if (!dto.EndTime.HasValue)
  861. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  862. RefAsync<int> total = 0;
  863. string strSql = @"SELECT * FROM( SELECT ""SCO"".""ProvinceNo"",""FirstTime"", ""LastTime"",""SendTimes"", ""GenerationTime"",""CreationTime"",""RequestData"",""ExpiredTime"", ""CaseSource"",""OrderId""
  864. FROM(
  865. SELECT * FROM
  866. (
  867. SELECT ROW_NUMBER() OVER(PARTITION BY ""ProvinceNo"" ORDER BY ""CreationTime"" DESC) AS ""newIndex"",""ProvinceNo"",""FirstTime"",""OrderId"",
  868. ""LastTime"",""SendTimes"",""GenerationTime""AS ""GenerationTime"",""CreationTime"",""RequestData"",""ExpiredTime"",""CaseSource"" AS ""CaseSource""
  869. FROM ""ds_send_task_submit_case_info""
  870. where ""GenerationTime"" >= '{0}' AND ""GenerationTime"" <= '{1}' AND ""LastTime"" >= '{0}' AND ""LastTime"" <= '{1}' AND ""IsSuccess"" = 1
  871. ) ""SCI"" WHERE ""newIndex""=1 AND ""CaseSource"" = 'RGDH'
  872. ) ""SCO""
  873. LEFT JOIN
  874. (
  875. SELECT * FROM (
  876. SELECT ROW_NUMBER() OVER(PARTITION BY ""CallId"" ORDER BY ""CreationTime"" DESC) as ""newIndex"",""ProvinceNo"",""CallId"",""CallLogId""
  877. FROM ""ds_send_task_submit_case_record""
  878. WHERE ""GenerationTime"" >= '{0}' AND ""LastTime"" >= '{0}' AND ""IsSuccess"" = 1 AND ""CallDirection""='0'
  879. ) ""SCR"" WHERE ""newIndex""=1 and (""ProvinceNo"" IS NOT NULL or ""ProvinceNo"" !='')
  880. )""SCRC""
  881. ON ""SCO"".""ProvinceNo""=""SCRC"".""ProvinceNo"" WHERE ""SCRC"".""ProvinceNo"" IS NULL {2}
  882. )""te"" ";
  883. string strWhere = "";
  884. if (!string.IsNullOrEmpty(dto.CaseSerial))
  885. {
  886. strWhere = " AND \"SCO\".\"ProvinceNo\"= '" + dto.CaseSerial + "'";
  887. }
  888. strSql = string.Format(strSql, dto.StartTime, dto.EndTime, strWhere);
  889. var items = await _waitSendTaskRepository.GetDataBySql(strSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  890. return new PagedDto<OrderMatchingCallDto>(total, _mapper.Map<List<OrderMatchingCallDto>>(items));
  891. //if (!dto.StartTime.HasValue)
  892. // dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  893. //if (!dto.EndTime.HasValue)
  894. // dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  895. //var itemsWSSS = _sendTaskSubmitCaseInfoRepository.Queryable()
  896. // .Where(p => p.GenerationTime >= dto.StartTime && p.GenerationTime <= dto.EndTime)
  897. // .Where(p => p.LastTime >= dto.StartTime && p.LastTime <= dto.EndTime && p.IsSuccess == ESendTaskState.PushSuccess)
  898. // .Select(p => new
  899. // {
  900. // index = SqlFunc.RowNumber($"{p.CreationTime} DESC ", $"{p.ProvinceNo}"),
  901. // p.ProvinceNo,
  902. // p.FirstTime,
  903. // p.LastTime,
  904. // p.SendTimes,
  905. // p.GenerationTime,
  906. // p.CreationTime,
  907. // p.RequestData,
  908. // p.CaseSource,
  909. // p.ExpiredTime,
  910. // p.OrderId
  911. // })
  912. // .MergeTable()
  913. // .Where(d => d.index == 1 && d.CaseSource == "RGDH")
  914. // .Where(p => SqlFunc.Subqueryable<DsSendTaskSubmitCaseRecord>().Where(s => s.ProvinceNo == p.ProvinceNo).OrderByDesc(s => s.LastTime).NotAny())
  915. // .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  916. // .OrderByDescending(d => d.CreationTime).ToSqlString();
  917. //RefAsync<int> total = 0;
  918. //var items = await _sendTaskSubmitCaseInfoRepository.Queryable()
  919. // .Where(p => p.GenerationTime >= dto.StartTime && p.GenerationTime <= dto.EndTime)
  920. // .Where(p => p.LastTime >= dto.StartTime && p.LastTime <= dto.EndTime && p.IsSuccess == ESendTaskState.PushSuccess)
  921. // .Select(p => new
  922. // {
  923. // index = SqlFunc.RowNumber($"{p.CreationTime} DESC ", $"{p.ProvinceNo}"),
  924. // p.ProvinceNo,
  925. // p.FirstTime,
  926. // p.LastTime,
  927. // p.SendTimes,
  928. // p.GenerationTime,
  929. // p.CreationTime,
  930. // p.RequestData,
  931. // p.CaseSource,
  932. // p.ExpiredTime,
  933. // p.OrderId
  934. // })
  935. // .MergeTable()
  936. // .Where(d => d.index == 1 && d.CaseSource == "RGDH")
  937. // .Where(p => SqlFunc.Subqueryable<DsSendTaskSubmitCaseRecord>().Where(s => s.ProvinceNo == p.ProvinceNo).OrderByDesc(s => s.LastTime).NotAny())
  938. // .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  939. // .OrderByDescending(d => d.CreationTime)
  940. // .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  941. //return new PagedDto<OrderMatchingCallDto>(total, _mapper.Map<List<OrderMatchingCallDto>>(items));
  942. }
  943. /// <summary>
  944. /// 查询没匹配到通话记录的电话来源工单
  945. /// </summary>
  946. /// <param name="dto"></param>
  947. /// <returns></returns>
  948. [HttpGet("getordermatchingcalllistfixed")]
  949. [AllowAnonymous]
  950. public async Task<IReadOnlyList<OrderMatchingCallDto>> GetOrderMatchingCallListFixed([FromQuery] QuerySendTaskFixedDto dto)
  951. {
  952. var items = await queryFixed(dto).ToFixedListAsync(dto.QueryIndex, 100, HttpContext.RequestAborted);
  953. return _mapper.Map<IReadOnlyList<OrderMatchingCallDto>>(items);
  954. }
  955. /// <summary>
  956. ///
  957. /// </summary>
  958. /// <param name="dto"></param>
  959. /// <returns></returns>
  960. [HttpGet("getordermatchingcalllistcount")]
  961. [AllowAnonymous]
  962. public async Task<int> GetOrderMatchingCallListCount([FromQuery] QuerySendTaskDto dto)
  963. {
  964. return await queryFixed(dto).CountAsync(HttpContext.RequestAborted);
  965. }
  966. /// <summary>
  967. ///
  968. /// </summary>
  969. /// <param name="dto"></param>
  970. /// <returns></returns>
  971. private ISugarQueryable<DsSendTaskSubmitCaseInfo> queryFixed(QuerySendTaskDto dto)
  972. {
  973. if (!dto.StartTime.HasValue)
  974. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  975. if (!dto.EndTime.HasValue)
  976. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  977. string strSql = @"select provinceno ""ProvinceNo"",firsttime""FirstTime"", lasttime""LastTime"",generationtime""GenerationTime"",
  978. creationtime""CreationTime"",requestdata""RequestData"",
  979. casesource""CaseSource"",orderid""OrderId"" FROM
  980. get_order_matching_call_list('{0}','{1}')";
  981. string strWhere = "";
  982. if (!string.IsNullOrEmpty(dto.CaseSerial))
  983. {
  984. strWhere = " WHERE provinceno = '" + dto.CaseSerial + "'";
  985. }
  986. strSql = string.Format(strSql, dto.StartTime, dto.EndTime, strWhere);
  987. return _waitSendTaskRepository.GetDataBySql(strSql);
  988. }
  989. /// <summary>
  990. /// 及时率查询
  991. /// </summary>
  992. /// <param name="dto"></param>
  993. /// <returns></returns>
  994. [HttpGet("getcalculateuploadrate")]
  995. [AllowAnonymous]
  996. public async Task<CalculateUploadRateDto> GetCalculateUploadRate([FromQuery] QuerySendTaskDto dto)
  997. {
  998. if (!dto.StartTime.HasValue)
  999. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  1000. if (!dto.EndTime.HasValue)
  1001. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  1002. CalculateUploadRateDto calculateUploadRateDto = new();
  1003. //工单
  1004. var orderRate = await _dsOrderSendRepository.Queryable()
  1005. .LeftJoin<DsTelCall>((p, o) => p.CallId == o.CallId)
  1006. .Where((p, o) => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime && p.FirstSendProvinceTime >= dto.StartTime && p.FirstSendProvinceTime <= dto.EndTime)
  1007. .Where((p, o) => p.FirstSendProvinceTime.HasValue && p.StartTime.HasValue)
  1008. .Select((p, o) => new
  1009. {
  1010. p.OrderId,
  1011. p.StartTime,
  1012. p.FirstSendProvinceTime,
  1013. p.CaseSourceCode,
  1014. o.CallId,
  1015. p.HandleState,
  1016. p.ExpiredTime,
  1017. p.ActualHandleTime
  1018. }).MergeTable()
  1019. .Select(p => new CalculateUploadRateDto
  1020. {
  1021. OrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.OrderId != null, 1, 0)),//总工单数
  1022. OrderTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.StartTime.Value, p.FirstSendProvinceTime.Value) <= 180, 1, 0)),//及时
  1023. OrderNotTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.StartTime.Value, p.FirstSendProvinceTime.Value) > 180, 1, 0)),//为及时
  1024. RGDHOrderCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CaseSourceCode == "RGDH", 1, 0)),
  1025. ContainTel = SqlFunc.AggregateSum(SqlFunc.IIF(p.CaseSourceCode == "RGDH" && p.CallId != null, 1, 0)),//匹配数
  1026. NotContainTel = SqlFunc.AggregateSum(SqlFunc.IIF(p.CaseSourceCode == "RGDH" && p.CallId == null, 1, 0)),//未匹配数
  1027. HandleEndOrderNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.HandleState == "办理完成", 1, 0)),//办结件数
  1028. HandleEndOrderOnTime = SqlFunc.AggregateSum(SqlFunc.IIF(p.HandleState == "办理完成" && p.ExpiredTime > p.ActualHandleTime, 1, 0)),//按时办结件数
  1029. })
  1030. .FirstAsync();
  1031. //电话
  1032. var callRate = await _dsTelCallRepository.Queryable()
  1033. .Where(p => p.OverTime >= dto.StartTime && p.OverTime <= dto.EndTime && p.FirstSendProvinceTime >= dto.StartTime && p.FirstSendProvinceTime <= dto.EndTime)
  1034. .Where(p => p.FirstSendProvinceTime.HasValue && p.OverTime.HasValue)
  1035. .Select(p => new
  1036. {
  1037. p.CallId,
  1038. p.OverTime,
  1039. p.FirstSendProvinceTime,
  1040. p.OnState
  1041. })
  1042. .MergeTable()
  1043. .Select(p => new CalculateUploadRateDto
  1044. {
  1045. TelCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.CallId != null, 1, 0)),//总电话数
  1046. TelTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.OverTime.Value, p.FirstSendProvinceTime.Value) <= 180, 1, 0)),//及时
  1047. TelNotTimely = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.DateDiff(DateType.Second, p.OverTime.Value, p.FirstSendProvinceTime.Value) > 180, 1, 0)),//为及时
  1048. TelConnectCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.OnState == "On", 1, 0)),//接通数量
  1049. TelNotConnectCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.OnState != "On", 1, 0)),//未接通数量
  1050. })
  1051. .FirstAsync();
  1052. //回访
  1053. var visitList = await _dsOrderVisitSendRepository.Queryable()
  1054. .Where(p => p.VisitTime >= dto.StartTime && p.VisitTime <= dto.EndTime && p.IsProvince == false && p.FirstSendProvinceTime >= dto.StartTime && p.FirstSendProvinceTime <= dto.EndTime)
  1055. .Select(p => new
  1056. {
  1057. p.SubjectResultSatifyCode,
  1058. p.VisitTime,
  1059. p.IsProvince,
  1060. p.Source,
  1061. p.ProvinceNo
  1062. })
  1063. .MergeTable()
  1064. .Select(p => new CalculateUploadRateDto
  1065. {
  1066. VisitCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.SubjectResultSatifyCode != null, 1, 0)),//回访总量
  1067. SatisfactionCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.SubjectResultSatifyCode != null && p.SubjectResultSatifyCode != "2", 1, 0)),//满意数量
  1068. NotSatisfiedCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.SubjectResultSatifyCode != null && p.SubjectResultSatifyCode == "2", 1, 0)),//不满意数量
  1069. })
  1070. .FirstAsync();
  1071. //查询知识总量
  1072. calculateUploadRateDto.KnowledgeCount = await _knowledgeRawDataRepository.Queryable()
  1073. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  1074. .CountAsync();
  1075. //修改知识库量-以第一次上传成功的记录为准
  1076. calculateUploadRateDto.UpdateKnowledgeCount = await _waitSendTaskProvinceOtherRepository.Queryable()
  1077. .Where(p => p.FirstTime >= dto.StartTime && p.FirstTime <= dto.EndTime && p.TaskType == "GetKnowledgeInfoUpdate")
  1078. .Select(p => new
  1079. {
  1080. p.Id,
  1081. RowID = SqlFunc.RowNumber($"{p.CreationTime} asc ")
  1082. })
  1083. .MergeTable()
  1084. .Where(p => p.RowID == 1)
  1085. .CountAsync();
  1086. //工单
  1087. if (orderRate != null)
  1088. {
  1089. calculateUploadRateDto.OrderCountNum = orderRate.OrderCountNum;
  1090. calculateUploadRateDto.OrderTimely = orderRate.OrderTimely;
  1091. calculateUploadRateDto.OrderNotTimely = orderRate.OrderNotTimely;
  1092. calculateUploadRateDto.RGDHOrderCount = orderRate.RGDHOrderCount;
  1093. calculateUploadRateDto.ContainTel = orderRate.ContainTel;
  1094. calculateUploadRateDto.NotContainTel = orderRate.NotContainTel;
  1095. calculateUploadRateDto.HandleEndOrderNum = orderRate.HandleEndOrderNum;
  1096. calculateUploadRateDto.HandleEndOrderOnTime = orderRate.HandleEndOrderOnTime;
  1097. }
  1098. //电话
  1099. if (callRate != null)
  1100. {
  1101. calculateUploadRateDto.TelCountNum = callRate.TelCountNum;
  1102. calculateUploadRateDto.TelTimely = callRate.TelTimely;
  1103. calculateUploadRateDto.TelNotTimely = callRate.TelNotTimely;
  1104. calculateUploadRateDto.TelConnectCountNum = callRate.TelConnectCountNum;
  1105. calculateUploadRateDto.TelNotConnectCountNum = callRate.TelNotConnectCountNum;
  1106. }
  1107. //回访
  1108. if (visitList != null)
  1109. {
  1110. calculateUploadRateDto.VisitCountNum = visitList.VisitCountNum;
  1111. calculateUploadRateDto.SatisfactionCountNum = visitList.SatisfactionCountNum;
  1112. calculateUploadRateDto.NotSatisfiedCountNum = visitList.NotSatisfiedCountNum;
  1113. }
  1114. return calculateUploadRateDto;
  1115. }
  1116. #endregion
  1117. #endregion
  1118. #region 系统配置
  1119. /// <summary>
  1120. /// 上传数据系统配置-查询详情
  1121. /// </summary>
  1122. /// <returns></returns>
  1123. [AllowAnonymous]
  1124. [HttpGet("info-configurationinformation")]
  1125. public async Task<ConfigurationInformation> GetStandard()
  1126. {
  1127. var sandard = await _configurationInformationRepository.Queryable().FirstAsync();
  1128. if (sandard == null)
  1129. {
  1130. ConfigurationInformation configuration = new()
  1131. {
  1132. CrntSeatNum = 0,
  1133. CrntTelNum = 0,
  1134. SeatNum = 0,
  1135. SeatHwyNum = 0,
  1136. MissedCallCount = 0
  1137. };
  1138. var Id = await _configurationInformationRepository.AddAsync(configuration, HttpContext.RequestAborted);
  1139. return await _configurationInformationRepository.GetAsync(Id, HttpContext.RequestAborted);
  1140. }
  1141. return sandard;
  1142. }
  1143. /// <summary>
  1144. /// 上传数据系统配置-修改
  1145. /// </summary>
  1146. /// <param name="dto"></param>
  1147. /// <returns></returns>
  1148. [AllowAnonymous]
  1149. [HttpPut("update-configurationinformation")]
  1150. public async Task UpdateStandard([FromBody] ConfigurationInformationDto dto)
  1151. {
  1152. var standard = await _configurationInformationRepository.GetAsync(dto.Id);
  1153. if (standard != null)
  1154. {
  1155. _mapper.Map(dto, standard);
  1156. await _configurationInformationRepository.UpdateAsync(standard, HttpContext.RequestAborted);
  1157. await _configurationInformationCache.GetOrSetAsync(ConstantSettings.ConfigurationInformationCacheKey, dto, cancellationToken: HttpContext.RequestAborted);
  1158. }
  1159. }
  1160. #endregion
  1161. #region 对接平台用户管理
  1162. /// <summary>
  1163. /// 对接平台用户管理
  1164. /// </summary>
  1165. /// <param name="dto"></param>
  1166. /// <returns></returns>
  1167. [HttpPost("adduserinfo")]
  1168. [AllowAnonymous]
  1169. public async Task AddUserInfo([FromBody] AddUserInfoDto dto)
  1170. {
  1171. var tokenInfo = _mapper.Map<DsUserTokenInfo>(dto);
  1172. if (string.IsNullOrEmpty(tokenInfo.AuthIP))
  1173. tokenInfo.AuthIP = "*";
  1174. await _dsUserTokenInfoRepository.AddAsync(tokenInfo, HttpContext.RequestAborted);
  1175. }
  1176. /// <summary>
  1177. /// 查询对接平台用户信息
  1178. /// </summary>
  1179. /// <param name="dto"></param>
  1180. /// <returns></returns>
  1181. [HttpGet("get-user-info-list")]
  1182. [AllowAnonymous]
  1183. public async Task<PagedDto<DsUserTokenInfo>> GetUserInfoList([FromQuery] PagedKeywordRequest dto)
  1184. {
  1185. RefAsync<int> total = 0;
  1186. var items = await _dsUserTokenInfoRepository.Queryable()
  1187. .WhereIF(!string.IsNullOrEmpty(dto.Keyword), p => p.PlatformSourceName.Contains(dto.Keyword))
  1188. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  1189. return new PagedDto<DsUserTokenInfo>(total, items);
  1190. }
  1191. #endregion
  1192. #region 推送业务系统失败
  1193. /// <summary>
  1194. /// 查询推送业务系统失败数据
  1195. /// </summary>
  1196. /// <param name="dto"></param>
  1197. /// <returns></returns>
  1198. [HttpGet("getsendhotlineerrordata")]
  1199. [AllowAnonymous]
  1200. public async Task<PagedDto<SendHotlineErrorData>> GetSendHotlineErrorData([FromQuery] QuerySendTaskDto dto)
  1201. {
  1202. if (!dto.StartTime.HasValue)
  1203. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  1204. if (!dto.EndTime.HasValue)
  1205. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  1206. //数据查询
  1207. RefAsync<int> total = 0;
  1208. var items = await _sendHotlineErrorDataRepository.Queryable()
  1209. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  1210. .OrderBy(p => p.CreationTime)
  1211. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  1212. return new PagedDto<SendHotlineErrorData>(total, items);
  1213. }
  1214. /// <summary>
  1215. /// 从新推送
  1216. /// </summary>
  1217. /// <param name="Id"></param>
  1218. /// <returns></returns>
  1219. [HttpGet("pushfromhotlinedata")]
  1220. [AllowAnonymous]
  1221. public async Task PushFromHotlineData(string Id)
  1222. {
  1223. var data = await _sendHotlineErrorDataRepository.GetAsync(p => p.Id == Id, HttpContext.RequestAborted);
  1224. if (data == null)
  1225. throw UserFriendlyException.SameMessage("重新推送失败");
  1226. var userInfo = Request.Headers["userinfo"].ToString();
  1227. if (string.IsNullOrEmpty(userInfo))
  1228. throw UserFriendlyException.SameMessage("用户信息获取失败");
  1229. var pkcs1 = new RsaPkcs1Util(Encoding.UTF8, PublicKey, PrivateKey);
  1230. var info = pkcs1.Decrypt(userInfo, RSAEncryptionPadding.Pkcs1);
  1231. if (info == null)
  1232. throw UserFriendlyException.SameMessage("用户信息获取失败");
  1233. var user = System.Text.Json.JsonSerializer.Deserialize<UserInfo>(info);
  1234. if (user == null)
  1235. throw UserFriendlyException.SameMessage("用户信息获取失败");
  1236. bool isSuccess = true;
  1237. string error = "";
  1238. //调用工单创建接口
  1239. try
  1240. {
  1241. //推业务系统
  1242. if (data.ReceiveServiceInterface == "rest/receive_case_info")
  1243. {
  1244. var result = await _fwClient.RequestNoTokenAsync<HotlineClientResponse>(data.Path, data.HttpMethod, data.RequestData);
  1245. if (result == null || result.code != 0)
  1246. {
  1247. isSuccess = false;
  1248. error = result?.message;
  1249. }
  1250. }
  1251. //推旧系统
  1252. if (data.ReceiveServiceInterface == "SendOldHotlineData")
  1253. {
  1254. ConfigurationSendDataOld configSendDataOld = new();
  1255. if (_sharingConfigurationManager.IsCity(ConfigurationConsts.YiBin))
  1256. configSendDataOld = _sharingConfigurationManager.GetYiBinConfig().SendDataOld;
  1257. else if (_sharingConfigurationManager.IsCity(ConfigurationConsts.ZiGong))
  1258. configSendDataOld = _sharingConfigurationManager.GetZiGongConfig().SendDataOld;
  1259. else if (_sharingConfigurationManager.IsCity(ConfigurationConsts.LuZhou))
  1260. configSendDataOld = _sharingConfigurationManager.GetLuZhouConfig().SendDataOld;
  1261. //var configSendDataOld = _sharingConfigurationManager.GetYiBinConfig().SendDataOld;
  1262. //先验证是否开启推送
  1263. if (configSendDataOld == null || !configSendDataOld.IsSend)
  1264. return;
  1265. var url = configSendDataOld.AddressUrl + data.Path;
  1266. var response = await _fwClient.RequestAsync<FwResponse>(url, data.HttpMethod, data.RequestData, HttpContext.RequestAborted);
  1267. if (response == null && response.code != 1)
  1268. {
  1269. isSuccess = false;
  1270. error = response?.msg;
  1271. }
  1272. }
  1273. }
  1274. catch (Exception ex)
  1275. {
  1276. isSuccess = false;
  1277. error = ex.Message;
  1278. }
  1279. //写入操作记录
  1280. UserOperationLog operationLog = new()
  1281. {
  1282. DataId = data.Id,
  1283. NewDataId = data.Id,
  1284. PlatformSource = EPlatformSource.Hotline,
  1285. ReceiveServiceInterface = data.ReceiveServiceInterface,
  1286. Path = data.Path,
  1287. RequestData = data.RequestData,
  1288. UserId = user.UserId,
  1289. UserName = user.UserName,
  1290. OrgCode = user.OrgCode,
  1291. OrgName = user.OrgName
  1292. };
  1293. await _userOperationLogRepository.AddAsync(operationLog, HttpContext.RequestAborted);
  1294. //推送失败添加
  1295. if (!isSuccess)
  1296. {
  1297. data.SendTimes = data.SendTimes + 1;
  1298. data.ErrorMessage = error;
  1299. await _sendHotlineErrorDataRepository.UpdateAsync(data, HttpContext.RequestAborted);
  1300. }
  1301. else
  1302. {
  1303. await _sendHotlineErrorDataRepository.RemoveAsync(data, cancellationToken: HttpContext.RequestAborted);
  1304. await _sendFwErrorDataRepository.RemoveAsync(p => p.Id == data.DataId, cancellationToken: HttpContext.RequestAborted);
  1305. }
  1306. }
  1307. #endregion
  1308. #region 省查询
  1309. /// <summary>
  1310. /// 查询附件信息
  1311. /// </summary>
  1312. /// <param name="dto"></param>
  1313. /// <returns></returns>
  1314. [HttpGet("getcasematerialinfolist")]
  1315. [AllowAnonymous]
  1316. public async Task<PagedDto<DsGetCaseMaterialInfo>> GetCaseMaterialInfoList([FromQuery] QueryCaseMaterialInfoDto dto)
  1317. {
  1318. RefAsync<int> total = 0;
  1319. var items = await _getCaseMaterialInfoRepository.Queryable()
  1320. .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime.Value)
  1321. .WhereIF(dto.EndTime.HasValue, p => p.CreationTime >= dto.EndTime.Value)
  1322. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.CaseSerial == dto.CaseSerial)
  1323. .OrderByDescending(p => p.CreationTime)
  1324. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  1325. return new PagedDto<DsGetCaseMaterialInfo>(total, items);
  1326. }
  1327. /// <summary>
  1328. /// 修改工单来源推送省平台
  1329. /// </summary>
  1330. /// <returns></returns>
  1331. [HttpGet("updateordersource")]
  1332. [AllowAnonymous]
  1333. public async Task UpdateOrderSourceAsync()
  1334. {
  1335. //查询数据
  1336. var items = await _dsOrderSendRepository.Queryable()
  1337. .LeftJoin<DsTelCall>((p, o) => p.CallId == o.CallId)
  1338. .Where((p, o) => p.FirstSendProvinceTime >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"))
  1339. && p.FirstSendProvinceTime <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")) && p.CaseSourceCode == "RGDH")
  1340. .Where((p, o) => p.FirstSendProvinceTime.HasValue && p.HandleState == "办理完成")
  1341. .Where((p, o) => o.CallId == null || o.CallId == "")
  1342. .OrderByDescending((p, o) => p.CreationTime)
  1343. .ToListAsync();
  1344. //处理数据
  1345. if (items != null && items.Any())
  1346. {
  1347. // _logger.LogInformation("读取到条数:" + "--------------" + items.Count);
  1348. List<string> Ids = [];
  1349. foreach (var item in items)
  1350. {
  1351. Ids.Add(item.OrderId);
  1352. }
  1353. //推送数据
  1354. if (Ids != null && Ids.Count > 0)
  1355. {
  1356. UpdateOrderSourceChannelDto data = new()
  1357. {
  1358. Ids = Ids,
  1359. IsPush = true
  1360. };
  1361. await _fwClient.RequestNoTokenAsync<HotlineClientResponse>("api/v1/Order/update-order-sourcechannel", "Post", System.Text.Json.JsonSerializer.Serialize(data));
  1362. }
  1363. }
  1364. }
  1365. #endregion
  1366. /// <summary>
  1367. /// 查询接收到的原始数据
  1368. /// </summary>
  1369. /// <param name="dto"></param>
  1370. /// <returns></returns>
  1371. [HttpGet("get_receive_raw_data")]
  1372. [AllowAnonymous]
  1373. public async Task<PagedDto<DsReceiveHandleData>> GetReceiveRawData([FromQuery] ReportPagedRequest dto)
  1374. {
  1375. RefAsync<int> total = 0;
  1376. var items = await _dsReceiveHandleDataRepository.Queryable()
  1377. .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
  1378. .WhereIF(!string.IsNullOrEmpty(dto.Keyword), p => p.OrderNo.Contains(dto.Keyword))
  1379. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  1380. if (items != null)
  1381. {
  1382. foreach (var item in items)
  1383. {
  1384. item.ReceiveData = System.Text.RegularExpressions.Regex.Unescape(item.ReceiveData);
  1385. }
  1386. }
  1387. return new PagedDto<DsReceiveHandleData>(total, items);
  1388. }
  1389. /// <summary>
  1390. /// 数据汇聚情况
  1391. /// </summary>
  1392. /// <param name="dto"></param>
  1393. /// <returns></returns>
  1394. [HttpGet("get_data_aggregation_situation")]
  1395. [AllowAnonymous]
  1396. public List<DataAggregationSituationDto> GetDataAggregationSituation([FromQuery] ReportPagedRequest dto)
  1397. {
  1398. string strsql = @"select CalConnectionRate ""CalConnectionRate"",
  1399. MatchingRateOfCallData ""MatchingRateOfCallData"",
  1400. TimelyUploadRateOfCallData ""TimelyUploadRateOfCallData"",
  1401. TimelyUploadRateOfOrderData ""TimelyUploadRateOfOrderData"",
  1402. AcceptanceQuantity ""AcceptanceQuantity"",
  1403. NumbeOfCompletedCases ""NumbeOfCompletedCases"",
  1404. OnTimeCompletionRate ""OnTimeCompletionRate"",
  1405. FollowUpVolume ""FollowUpVolume"",
  1406. DissatisfiedItems ""DissatisfiedItems"",
  1407. DissatisfactionRate ""DissatisfactionRate"",
  1408. KnowledgeTotalNum ""KnowledgeTotalNum"",
  1409. KnowledgeUpdateTotalNum ""KnowledgeUpdateTotalNum""
  1410. FROM
  1411. get_aggregate_data_tatistics('{0}','{1}')";
  1412. strsql = string.Format(strsql, dto.StartTime, dto.EndTime);
  1413. return _waitSendTaskRepository.GetDataAggregationSituation(strsql);
  1414. }
  1415. /// <summary>
  1416. /// 查询推送了受理为推送办理结果的工单数据
  1417. /// </summary>
  1418. /// <param name="dto"></param>
  1419. /// <returns></returns>
  1420. [HttpGet("get_republish_filed_orders")]
  1421. [AllowAnonymous]
  1422. public async Task<PagedDto<object>> GetRepublishFiledOrders([FromQuery] QuerySendTaskDto dto)
  1423. {
  1424. RefAsync<int> total = 0;
  1425. var items = await _sendTaskSubmitCaseInfoRepository.Queryable()
  1426. .Where(p => p.GenerationTime >= dto.StartTime && p.GenerationTime <= dto.EndTime && p.IsSuccess == ESendTaskState.PushSuccess)
  1427. .Select(p => new
  1428. {
  1429. index = SqlFunc.RowNumber($"{p.CreationTime} desc ", $"{p.ProvinceNo}"),
  1430. ProvinceNo = p.ProvinceNo,
  1431. FirstTime = p.FirstTime,
  1432. LastTime = p.LastTime,
  1433. SendTimes = p.SendTimes,
  1434. StartTime = p.GenerationTime,
  1435. CreationTime = p.CreationTime,
  1436. CaseSource = SqlFunc.JsonField(p.RequestData, "CaseSource"),
  1437. p.RequestData,
  1438. p.OrderId,
  1439. TfdBackTimeBf = Convert.ToDateTime(SqlFunc.JsonField(p.RequestData, "TfdBackTimeBf"))
  1440. })
  1441. .MergeTable()
  1442. .Where(d => d.index == 1)
  1443. .Where(p => SqlFunc.Subqueryable<DsSendTaskSubmitCaseResult>().Where(s => s.ProvinceNo == p.ProvinceNo).NotAny())
  1444. .MergeTable()
  1445. .Select(p => new
  1446. {
  1447. p.ProvinceNo,
  1448. p.FirstTime,
  1449. p.LastTime,
  1450. p.SendTimes,
  1451. p.StartTime,
  1452. p.CreationTime,
  1453. p.CaseSource,
  1454. p.RequestData,
  1455. p.OrderId,
  1456. p.TfdBackTimeBf,
  1457. isOverText = p.TfdBackTimeBf > DateTime.Now ? "否" : "是"
  1458. })
  1459. .WhereIF(!string.IsNullOrEmpty(dto.CaseSerial), p => p.ProvinceNo == dto.CaseSerial)
  1460. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == true, p => p.TfdBackTimeBf < DateTime.Now)
  1461. .WhereIF(dto.IsSuccess.HasValue && dto.IsSuccess == false, p => p.TfdBackTimeBf > DateTime.Now)
  1462. .OrderBy(d => d.TfdBackTimeBf)
  1463. .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
  1464. return new PagedDto<object>(total, items);
  1465. }
  1466. /// <summary>
  1467. /// 查询12315办理过程
  1468. /// </summary>
  1469. /// <param name="caseSerial"></param>
  1470. /// <returns></returns>
  1471. [HttpGet("get_case_distrecord_send")]
  1472. [AllowAnonymous]
  1473. public async Task<List<CaseDistrecordSendDto>> GetCaseDistrecordSend([FromQuery] string? caseSerial)
  1474. {
  1475. var items = await _getCaseDistrecordSendRepository.Queryable()
  1476. .Where(p => p.CaseSerial == caseSerial)
  1477. .OrderBy(p => p.HandleTime)
  1478. .ToListAsync();
  1479. return _mapper.Map<List<CaseDistrecordSendDto>>(items);
  1480. }
  1481. /// <summary>
  1482. /// 查询超期明细
  1483. /// </summary>
  1484. /// <param name="dto"></param>
  1485. /// <returns></returns>
  1486. [HttpGet("get_overdue_details")]
  1487. [AllowAnonymous]
  1488. public async Task<List<GetOverdueDetailsDto>> GetOverdueDetails([FromQuery] QuerySendTaskDto dto)
  1489. {
  1490. if (!dto.StartTime.HasValue)
  1491. dto.StartTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01 00:00:00"));
  1492. if (!dto.EndTime.HasValue)
  1493. dto.EndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  1494. string strSql = @"select provinceno ""ProvinceNo"",overduetype""Overduetype"" FROM
  1495. get_overdue_details('{0}','{1}')";
  1496. string strWhere = "";
  1497. if (!string.IsNullOrEmpty(dto.CaseSerial))
  1498. {
  1499. strWhere = " WHERE provinceno = '" + dto.CaseSerial + "'";
  1500. }
  1501. strSql = string.Format(strSql, dto.StartTime, dto.EndTime, strWhere);
  1502. var data = await _waitSendTaskRepository.GetDataBySql(strSql).ToListAsync();
  1503. return _mapper.Map<List<GetOverdueDetailsDto>>(data);
  1504. }
  1505. }
  1506. }