HotlineMessageReceiveController.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. using DotNetCore.CAP;
  2. using Hotline.Share.Dtos.Knowledge;
  3. using Hotline.Share.Dtos.Order;
  4. using Hotline.Share.Enums.Order;
  5. using MapsterMapper;
  6. using MediatR;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Sharing.Application;
  9. using Sharing.Notifications.HuiJu;
  10. using Sharing.Notifications.Knowledge;
  11. using Sharing.Notifications.XieTong;
  12. using Sharing.Orders;
  13. using Sharing.Province.Dtos.HuiJu.Send;
  14. using Sharing.Province.Dtos.XieTong.Send;
  15. using Sharing.Province.HuiJu.Send;
  16. using Sharing.Province.XieTong.Knowledge;
  17. using Sharing.Province.XieTong.Receive;
  18. using Sharing.Province.XieTong.Send;
  19. using XF.Domain.Repository;
  20. namespace Sharing.Api.Controllers
  21. {
  22. /// <summary>
  23. ///
  24. /// </summary>
  25. public class HotlineMessageReceiveController : Controller
  26. {
  27. #region 注入
  28. private readonly IMediator _mediator;
  29. private readonly ILogger<HotlineMsgReceiver> _logger;
  30. private readonly IMapper _mapper;
  31. private readonly IRepository<GetCaseResultReceive> _getCaseResultReceiveRepository;
  32. private readonly IRepository<GetCaseProcessReceive> _getCaseProcessReceiveRepository;
  33. private readonly IRepository<GetVisitInfoReceive> _getVisitInfoReceiveRepository;
  34. private readonly IRepository<GetCaseBackApply> _getCaseBackApplyRepository;
  35. private readonly IRepository<DelayCaseInfoSend> _delayCaseInfoSendRepository;
  36. private readonly IRepository<SendSuperviseProcessInfo> _sendSuperviseProcessInfoRepository;
  37. private readonly IRepository<SendSuperviseResultInfo> _sendSuperviseResultInfoRepository;
  38. private readonly IRepository<SubmitCaseRecord> _submitCaseRecordRepository;
  39. private readonly IRepository<SubmitCaseTotal> _submitCaseTotalRepository;
  40. private readonly IRepository<SendCaseInfo> _sendCaseInfoRepository;
  41. private readonly IRepository<SupplyCaseInfoSend> _supplyCaseInfoSendRepository;
  42. private readonly IRepository<RevokeCaseInfo> _revokeCaseInfoRepository;
  43. private readonly IRepository<RemindCaseInfo> _remindCaseInfoRepository;
  44. private readonly IRepository<GetKnowledgeInfoSend> _getKnowledgeInfoSendRepository;
  45. private readonly IRepository<GetKnowledgeInfoUpdate> _getKnowledgeInfoUpdateRepository;
  46. private readonly IRepository<GetKnowledgeInfoAbandon> _getKnowledgeInfoAbandonRepository;
  47. private readonly IRepository<SendRealTimeStatus> _sendRealTimeStatusRepository;
  48. private readonly IRepository<ScreenCaseInfoSend> _screenCaseInfoSendRepository;
  49. private readonly IRepository<ZMHDCaseInfoPublic> _zMHDCaseInfoPublicRepository;
  50. private readonly IProvinceService _provinceService;
  51. private readonly IRepository<KnowledgeRawData> _knowledgeRawDataRepository;
  52. private readonly IChannelConfigurationManager _channelConfigurationManager;
  53. private readonly IDataOrderRepository _dataOrderRepository;
  54. /// <summary>
  55. ///
  56. /// </summary>
  57. /// <param name="mediator"></param>
  58. /// <param name="logger"></param>
  59. /// <param name="mapper"></param>
  60. /// <param name="getCaseResultReceiveRepository"></param>
  61. /// <param name="getCaseProcessReceiveRepository"></param>
  62. /// <param name="getVisitInfoReceiveRepository"></param>
  63. /// <param name="getCaseBackApplyRepository"></param>
  64. /// <param name="delayCaseInfoSendRepository"></param>
  65. /// <param name="sendSuperviseProcessInfoRepository"></param>
  66. /// <param name="sendSuperviseResultInfoRepository"></param>
  67. /// <param name="submitCaseRecordRepository"></param>
  68. /// <param name="submitCaseTotalRepository"></param>
  69. /// <param name="sendCaseInfoRepository"></param>
  70. /// <param name="supplyCaseInfoSendRepository"></param>
  71. /// <param name="revokeCaseInfoRepository"></param>
  72. /// <param name="remindCaseInfoRepository"></param>
  73. /// <param name="getKnowledgeInfoSendRepository"></param>
  74. /// <param name="getKnowledgeInfoUpdateRepository"></param>
  75. /// <param name="getKnowledgeInfoAbandonRepository"></param>
  76. /// <param name="sendRealTimeStatusRepository"></param>
  77. /// <param name="screenCaseInfoSendRepository"></param>
  78. /// <param name="zMHDCaseInfoPublicRepository"></param>
  79. /// <param name="provinceService"></param>
  80. /// <param name="knowledgeRawDataRepository"></param>
  81. /// <param name="channelConfigurationManager"></param>
  82. /// <param name="dataOrderRepository"></param>
  83. public HotlineMessageReceiveController(IMediator mediator,
  84. ILogger<HotlineMsgReceiver> logger,
  85. IMapper mapper,
  86. IRepository<GetCaseResultReceive> getCaseResultReceiveRepository,
  87. IRepository<GetCaseProcessReceive> getCaseProcessReceiveRepository,
  88. IRepository<GetVisitInfoReceive> getVisitInfoReceiveRepository,
  89. IRepository<GetCaseBackApply> getCaseBackApplyRepository,
  90. IRepository<DelayCaseInfoSend> delayCaseInfoSendRepository,
  91. IRepository<SendSuperviseProcessInfo> sendSuperviseProcessInfoRepository,
  92. IRepository<SendSuperviseResultInfo> sendSuperviseResultInfoRepository,
  93. IRepository<SubmitCaseRecord> submitCaseRecordRepository,
  94. IRepository<SubmitCaseTotal> submitCaseTotalRepository,
  95. IRepository<SendCaseInfo> sendCaseInfoRepository,
  96. IRepository<SupplyCaseInfoSend> supplyCaseInfoSendRepository,
  97. IRepository<RevokeCaseInfo> revokeCaseInfoRepository,
  98. IRepository<RemindCaseInfo> remindCaseInfoRepository,
  99. IRepository<GetKnowledgeInfoSend> getKnowledgeInfoSendRepository,
  100. IRepository<GetKnowledgeInfoUpdate> getKnowledgeInfoUpdateRepository,
  101. IRepository<GetKnowledgeInfoAbandon> getKnowledgeInfoAbandonRepository,
  102. IRepository<SendRealTimeStatus> sendRealTimeStatusRepository,
  103. IRepository<ScreenCaseInfoSend> screenCaseInfoSendRepository,
  104. IRepository<ZMHDCaseInfoPublic> zMHDCaseInfoPublicRepository,
  105. IProvinceService provinceService,
  106. IRepository<KnowledgeRawData> knowledgeRawDataRepository,
  107. IChannelConfigurationManager channelConfigurationManager,
  108. IDataOrderRepository dataOrderRepository)
  109. {
  110. _mediator = mediator;
  111. _logger = logger;
  112. _mapper = mapper;
  113. _getCaseResultReceiveRepository = getCaseResultReceiveRepository;
  114. _getCaseProcessReceiveRepository = getCaseProcessReceiveRepository;
  115. _getVisitInfoReceiveRepository = getVisitInfoReceiveRepository;
  116. _getCaseBackApplyRepository = getCaseBackApplyRepository;
  117. _delayCaseInfoSendRepository = delayCaseInfoSendRepository;
  118. _sendSuperviseProcessInfoRepository = sendSuperviseProcessInfoRepository;
  119. _sendSuperviseResultInfoRepository = sendSuperviseResultInfoRepository;
  120. _submitCaseRecordRepository = submitCaseRecordRepository;
  121. _submitCaseTotalRepository = submitCaseTotalRepository;
  122. _sendCaseInfoRepository = sendCaseInfoRepository;
  123. _supplyCaseInfoSendRepository = supplyCaseInfoSendRepository;
  124. _revokeCaseInfoRepository = revokeCaseInfoRepository;
  125. _remindCaseInfoRepository = remindCaseInfoRepository;
  126. _getKnowledgeInfoSendRepository = getKnowledgeInfoSendRepository;
  127. _getKnowledgeInfoUpdateRepository = getKnowledgeInfoUpdateRepository;
  128. _getKnowledgeInfoAbandonRepository = getKnowledgeInfoAbandonRepository;
  129. _sendRealTimeStatusRepository = sendRealTimeStatusRepository;
  130. _screenCaseInfoSendRepository = screenCaseInfoSendRepository;
  131. _zMHDCaseInfoPublicRepository = zMHDCaseInfoPublicRepository;
  132. _provinceService = provinceService;
  133. _knowledgeRawDataRepository = knowledgeRawDataRepository;
  134. _channelConfigurationManager = channelConfigurationManager;
  135. _dataOrderRepository = dataOrderRepository;
  136. }
  137. #endregion
  138. #region 协同-第一批次
  139. /// <summary>
  140. /// 服务工单交办处理结果 ---已在汇聚中完成
  141. /// </summary>
  142. /// <param name="dto"></param>
  143. /// <returns></returns>
  144. [NonAction]
  145. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetCaseResultReceive)]
  146. public async Task GetCaseResultReceive(GetCaseResultReceiveInfo dto)
  147. {
  148. var data = _mapper.Map<GetCaseResultReceive>(dto);
  149. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  150. //将上报信息写入本地库
  151. var id = await _getCaseResultReceiveRepository.AddAsync(data);
  152. data.Id = id;
  153. //信息上报
  154. await _mediator.Publish(new GetCaseResultReceiveNotification(data));
  155. }
  156. /// <summary>
  157. /// 服务工单交办处理过程 ---已在汇聚中完成
  158. /// </summary>
  159. /// <param name="dto"></param>
  160. /// <returns></returns>
  161. [NonAction]
  162. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetCaseProcessReceive)]
  163. public async Task GetCaseProcessReceive(GetCaseProcessReceiveInfo dto)
  164. {
  165. var data = _mapper.Map<GetCaseProcessReceive>(dto);
  166. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  167. //将上报信息写入本地库
  168. var id = await _getCaseProcessReceiveRepository.AddAsync(data);
  169. data.Id = id;
  170. //信息上报
  171. await _mediator.Publish(new GetCaseProcessReceiveNotification(data));
  172. }
  173. /// <summary>
  174. /// 服务工单交办评价 ---已在汇聚中完成
  175. /// </summary>
  176. /// <param name="dto"></param>
  177. /// <returns></returns>
  178. [NonAction]
  179. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetVisitInfoReceive)]
  180. public async Task GetVisitInfoReceive(GetVisitInfoReceiveInfo dto)
  181. {
  182. var data = _mapper.Map<GetVisitInfoReceive>(dto);
  183. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  184. //将上报信息写入本地库
  185. var id = await _getVisitInfoReceiveRepository.AddAsync(data);
  186. data.Id = id;
  187. //信息上报
  188. await _mediator.Publish(new GetVisitInfoReceiveNotification(data));
  189. }
  190. /// <summary>
  191. /// 退回申请
  192. /// </summary>
  193. /// <param name="dto"></param>
  194. /// <returns></returns>
  195. [NonAction]
  196. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderGetCaseBackApply)]
  197. public async Task GetCaseBackApply(GetCaseBackApplyInfo dto)
  198. {
  199. var data = _mapper.Map<GetCaseBackApply>(dto);
  200. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  201. //将上报信息写入本地库
  202. var id = await _getCaseBackApplyRepository.AddAsync(data);
  203. data.Id = id;
  204. //信息上报
  205. await _mediator.Publish(new GetCaseBackApplyNotification(data));
  206. //处理附件
  207. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.CaseSerial, dto.CliengGuid, dto.AreaCode);
  208. }
  209. /// <summary>
  210. /// 服务工单申请延时
  211. /// </summary>
  212. /// <param name="dto"></param>
  213. /// <returns></returns>
  214. [NonAction]
  215. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderDelayCaseInfoSend)]
  216. public async Task DelayCaseInfoSend(DelayCaseInfoSendInfo dto)
  217. {
  218. var data = _mapper.Map<DelayCaseInfoSend>(dto);
  219. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  220. //将上报信息写入本地库
  221. var id = await _delayCaseInfoSendRepository.AddAsync(data);
  222. data.Id = id;
  223. //信息上报
  224. await _mediator.Publish(new DelayCaseInfoSendNotification(data));
  225. //处理附件
  226. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.CaseSerial, dto.CliengGuid, dto.AreaCode);
  227. }
  228. /// <summary>
  229. /// 服务工单督办过程 --已对接
  230. /// </summary>
  231. /// <param name="dto"></param>
  232. /// <returns></returns>
  233. [NonAction]
  234. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSuperviseCourse)]
  235. public async Task SendSuperviseProcessInfo(PublishSuperviseDto dto)
  236. {
  237. //工单是省上派下来的,才能进行督办回复
  238. if (dto.Order.Source == ESource.ProvinceStraight)
  239. {
  240. var data = _mapper.Map<SendSuperviseProcessInfo>(dto);
  241. //将上报信息写入本地库
  242. data.Id = await _sendSuperviseProcessInfoRepository.AddAsync(data);
  243. //信息上报
  244. await _mediator.Publish(new SendSuperviseProcessInfoNotification(data));
  245. }
  246. }
  247. /// <summary>
  248. /// 服务工单督办结果 --已对接
  249. /// </summary>
  250. /// <param name="dto"></param>
  251. /// <returns></returns>
  252. [NonAction]
  253. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSuperviseResult)]
  254. public async Task SendSuperviseResultInfo(PublishSuperviseDto dto)
  255. {
  256. //工单是省上派下来的,才能进行督办回复
  257. if (dto.Order.Source == ESource.ProvinceStraight)
  258. {
  259. var data = _mapper.Map<SendSuperviseResultInfo>(dto);
  260. //将上报信息写入本地库
  261. data.Id = await _sendSuperviseResultInfoRepository.AddAsync(data);
  262. //信息上报
  263. await _mediator.Publish(new SendSuperviseResultInfoNotification(data));
  264. }
  265. }
  266. /// <summary>
  267. /// 工单发起甄别 --已对接
  268. /// </summary>
  269. /// <param name="dto"></param>
  270. /// <returns></returns>
  271. [NonAction]
  272. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderScreenApply)]
  273. public async Task ScreenCaseInfoSend(PublishScreenDto dto)
  274. {
  275. //如果是省上派下来的工单,才能调发起甄别的接口
  276. if (dto.Order.Source == ESource.ProvinceStraight)
  277. {
  278. var data = _mapper.Map<ScreenCaseInfoSend>(dto);
  279. data.ApplyType = dto.Screen.TypeDicName switch
  280. {
  281. "违反法律法规" => "10",
  282. "按正常流程处理" => "20",
  283. _ => "30",
  284. };
  285. //将上报信息写入本地库
  286. data.Id = await _screenCaseInfoSendRepository.AddAsync(data);
  287. //信息上报
  288. await _mediator.Publish(new ScreenCaseInfoSendNotification(data));
  289. }
  290. }
  291. /// <summary>
  292. /// 政民互动提交公开
  293. /// </summary>
  294. /// <param name="dto"></param>
  295. /// <returns></returns>
  296. [NonAction]
  297. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderZMHDCaseInfoPublic)]
  298. public async Task ZMHDCaseInfoPublic(ZMHDCaseInfoPublicInfo dto)
  299. {
  300. var data = _mapper.Map<ZMHDCaseInfoPublic>(dto);
  301. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  302. //将上报信息写入本地库
  303. var id = await _zMHDCaseInfoPublicRepository.AddAsync(data);
  304. data.Id = id;
  305. //信息上报
  306. await _mediator.Publish(new ZMHDCaseInfoPublicNotification(data));
  307. }
  308. #endregion
  309. #region 汇聚-第二批次
  310. #region 已对接
  311. /// <summary>
  312. /// 热线工单流程开启 --服务工单受理
  313. /// </summary>
  314. /// <param name="dto"></param>
  315. /// <returns></returns>
  316. [NonAction]
  317. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderFlowStarted)]
  318. public async Task OrderFlowStarted(OrderDto dto)
  319. {
  320. //如果不是省上派下来的工单,需要汇聚到省上
  321. if (dto.Source != ESource.ProvinceStraight)
  322. {
  323. var submitCaseInfo = await _provinceService.InitData(dto);
  324. await _mediator.Publish(new OrderCreatedNotification(submitCaseInfo));
  325. //处理数据
  326. var dataOrder = await _dataOrderRepository.GetAsync(p => p.OrderId == submitCaseInfo.OrderID);
  327. if (dataOrder == null)
  328. {
  329. dataOrder = new()
  330. {
  331. OrderId = submitCaseInfo.OrderID,
  332. OrderNo = submitCaseInfo.No,
  333. ProvinceNo = submitCaseInfo.CaseSerial,
  334. CaseDate = submitCaseInfo.CaseDate,
  335. FirstSyncProvinceTime = DateTime.Now,
  336. SyncInterval = 0,
  337. IsTimelyUpload = true,
  338. CaseSource = dto.SourceChannel,
  339. CaseSourceCode=dto.SourceChannelCode,
  340. ExpiredTime = submitCaseInfo.TfdBackTimeBf,
  341. CaseType = submitCaseInfo.CaseType,
  342. CaseTypeCode = dto.AcceptTypeCode,
  343. AllDuration = 0,
  344. IsProvince = false,
  345. HandleState = "办理中",
  346. Title= dto.Title,
  347. FromName=dto.FromName,
  348. Contact=dto.Contact,
  349. Content=dto.Content,
  350. HotspotId=dto.HotspotId,
  351. HotspotName=dto.HotspotName,
  352. HotspotSpliceName=dto.HotspotSpliceName,
  353. Source=dto.Source.ToString()
  354. };
  355. await _dataOrderRepository.AddAsync(dataOrder);
  356. }
  357. else
  358. {
  359. //修改
  360. dataOrder.NewSyncProvinceTime = DateTime.Now;
  361. dataOrder.SyncInterval = new TimeSpan(DateTime.Now.Ticks - dataOrder.FirstSyncProvinceTime.Value.Ticks).TotalSeconds;
  362. dataOrder.IsTimelyUpload = false;
  363. await _dataOrderRepository.UpdateAsync(dataOrder);
  364. }
  365. //处理附件
  366. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), submitCaseInfo.CaseSerial, submitCaseInfo.CliengGuid, submitCaseInfo.AreaCode);
  367. }
  368. }
  369. ///派单的时候,需要确定往哪里推,需要一个事件
  370. /// <summary>
  371. /// 热线工单期满时间变更--服务工单受理
  372. /// </summary>
  373. /// <param name="dto"></param>
  374. /// <returns></returns>
  375. [NonAction]
  376. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderExpiredTimeUpdate)]
  377. public async Task OrderExpiredTimeUpdate(OrderDto dto)
  378. {
  379. //如果不是省上派下来的工单,需要汇聚到省上
  380. if (dto.Source != ESource.ProvinceStraight)
  381. {
  382. var submitCaseInfo = await _provinceService.InitData(dto);
  383. await _mediator.Publish(new OrderCreatedNotification(submitCaseInfo));
  384. }
  385. }
  386. /// <summary>
  387. /// 派单是判断是否需要往第三方推送数据
  388. /// </summary>
  389. /// <param name="dto"></param>
  390. /// <returns></returns>
  391. [NonAction]
  392. // [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderExpiredTimeUpdate)]
  393. public async Task OrderDispatch(OrderFlowDto dto)
  394. {
  395. await _provinceService.OrderDispatch(dto);
  396. }
  397. /// <summary>
  398. /// 热线工单一级部门办理完---服务工单处理--缺少附件
  399. /// </summary>
  400. /// <param name="dto"></param>
  401. /// <returns></returns>
  402. [NonAction]
  403. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderLevelOneOrgHandled)]
  404. public async Task SubmitCaseProcess(OrderFlowDto dto)
  405. {
  406. //判断是否是热线中心
  407. if (!string.IsNullOrEmpty(dto.Order.ActualHandleOrgCode))
  408. {
  409. if (dto.Order.ActualHandleOrgCode.Substring(0, 3) == "001")
  410. {
  411. dto.Order.ActualHandleOrgName = "热线中心";
  412. }
  413. }
  414. //如果不是省上派下来的工单
  415. if (dto.Order.Source != ESource.ProvinceStraight)
  416. await _provinceService.SubmitCaseProcess(dto);//本地工单走市州接口
  417. else
  418. {
  419. //省上下来的工单走协同的接口
  420. var data = _mapper.Map<GetCaseProcessReceive>(dto);
  421. data.TacheName = "70:" + data.DeptName;
  422. //将上报信息写入本地库
  423. data.Id = await _getCaseProcessReceiveRepository.AddAsync(data);
  424. //信息上报
  425. await _mediator.Publish(new GetCaseProcessReceiveNotification(data));
  426. }
  427. }
  428. /// <summary>
  429. /// 回访完成---服务工单回访评价
  430. /// </summary>
  431. /// <param name="dto"></param>
  432. /// <returns></returns>
  433. [NonAction]
  434. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderVisited)]
  435. public async Task SubmitVisitInfo(PublishVisitDto dto)
  436. {
  437. // dto.Order.ProvinceNo = dto.Order.No;
  438. //如果不是省上派下来的工单,走服务工单评价接口,是省上下来的工单走服务工单交办评价接口
  439. if (dto.Order.Source != ESource.ProvinceStraight && dto.Order.IsProvince == false)
  440. await _provinceService.SubmitVisitInfo(dto);
  441. else
  442. {
  443. var data = _mapper.Map<GetVisitInfoReceive>(dto);
  444. switch (dto.VisitType)
  445. {
  446. case EVisitType.ArtificialVisit:
  447. data.VisitType = "DH";
  448. break;
  449. case EVisitType.SmsVisit:
  450. data.VisitType = "DX";
  451. break;
  452. case EVisitType.WebVisit:
  453. data.VisitType = "WZ";
  454. break;
  455. case EVisitType.WeChatVisit:
  456. data.VisitType = "WX";
  457. break;
  458. case EVisitType.AppVisit:
  459. data.VisitType = "AP";
  460. break;
  461. default:
  462. break;
  463. }
  464. data.CliengGuid = Guid.NewGuid().ToString();
  465. //将上报信息写入本地库
  466. data.Id = await _getVisitInfoReceiveRepository.AddAsync(data);
  467. //信息上报
  468. await _mediator.Publish(new GetVisitInfoReceiveNotification(data));
  469. //处理附件
  470. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), data.CaseSerial, data.CliengGuid, data.AreaCode);
  471. }
  472. }
  473. /// <summary>
  474. /// 甄别通过---服务工单回访评价
  475. /// </summary>
  476. /// <param name="dto"></param>
  477. /// <returns></returns>
  478. [NonAction]
  479. // [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderScreenSuccess)]
  480. public async Task SubmitOrderScreenSuccess(PublishVisitDto dto)
  481. {
  482. //如果不是省上派下来的工单,走服务工单评价接口,是省上下来的工单走服务工单交办评价接口(除开政民互动直派)
  483. if (dto.Order.Source != ESource.ProvinceStraight && dto.Order.IsProvince == false)
  484. await _provinceService.SubmitVisitInfo(dto);
  485. else
  486. {
  487. var data = _mapper.Map<GetVisitInfoReceive>(dto);
  488. switch (dto.VisitType)
  489. {
  490. case EVisitType.ArtificialVisit:
  491. data.VisitType = "DH";
  492. break;
  493. case EVisitType.SmsVisit:
  494. data.VisitType = "DX";
  495. break;
  496. case EVisitType.WebVisit:
  497. data.VisitType = "WZ";
  498. break;
  499. case EVisitType.WeChatVisit:
  500. data.VisitType = "WX";
  501. break;
  502. case EVisitType.AppVisit:
  503. data.VisitType = "AP";
  504. break;
  505. default:
  506. break;
  507. }
  508. data.CliengGuid = Guid.NewGuid().ToString();
  509. //将上报信息写入本地库
  510. data.Id = await _getVisitInfoReceiveRepository.AddAsync(data);
  511. //信息上报
  512. await _mediator.Publish(new GetVisitInfoReceiveNotification(data));
  513. //处理附件
  514. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), data.CaseSerial, data.CliengGuid, data.AreaCode);
  515. }
  516. }
  517. /// <summary>
  518. ///热线工单归档---服务工单结果--缺少附件
  519. /// </summary>
  520. /// <param name="dto"></param>
  521. /// <returns></returns>
  522. [NonAction]
  523. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderFiled)]
  524. public async Task OrderFiled(OrderFlowDto dto)
  525. {
  526. //判断是否是热线中心
  527. if (!string.IsNullOrEmpty(dto.Order.ActualHandleOrgCode))
  528. {
  529. if (dto.Order.ActualHandleOrgCode.Substring(0, 3) == "001")
  530. {
  531. dto.Order.ActualHandleOrgName = "热线中心";
  532. }
  533. }
  534. //IsProvince 如果是false 则推送服务工单受理
  535. if (dto != null && dto.Order != null && !dto.Order.IsProvince)
  536. {
  537. //推送工单信息
  538. var submitCaseInfo = await _provinceService.InitData(dto.Order);
  539. await _mediator.Publish(new OrderCreatedNotification(submitCaseInfo));
  540. }
  541. //推送服务工单处理信息
  542. await _provinceService.SubmitCaseProcess(dto);
  543. //推送服务工单结果信息-组装110数据
  544. await _provinceService.SubmitCaseResult(dto);
  545. var data = await _dataOrderRepository.GetAsync(p => p.OrderId == dto.Order.Id);
  546. if (data != null)
  547. {
  548. data.HandleState = "办理完成";
  549. data.ActualHandleOrgName = dto.Order.ActualHandleOrgName;
  550. data.ActualHandleOrgCode= dto.Order.ActualHandleOrgCode;
  551. data.ActualOpinion = dto.Order.ActualOpinion;
  552. await _dataOrderRepository.UpdateAsync(data);
  553. }
  554. }
  555. /// <summary>
  556. /// 挂电话推送----电话记录
  557. /// </summary>
  558. /// <param name="dtos"></param>
  559. /// <returns></returns>
  560. [NonAction]
  561. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineCallBye)]
  562. public async Task SubmitCaseRecord(List<CallConnectOrderDto> dtos)
  563. {
  564. List<SubmitCaseRecord> recordList = new();
  565. foreach (var item in dtos)
  566. {
  567. var record = _mapper.Map<SubmitCaseRecord>(item);
  568. record.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  569. if (item.Order != null && !string.IsNullOrEmpty(item.Order.ProvinceNo))
  570. record.CaseSerial = item.Order.ProvinceNo;
  571. //将上报信息写入本地库
  572. record.Id = await _submitCaseRecordRepository.AddAsync(record);
  573. if (!string.IsNullOrEmpty(record.Id))
  574. recordList.Add(record);
  575. }
  576. if (recordList != null && recordList.Count > 0)
  577. //信息上报
  578. await _mediator.Publish(new SubmitCaseRecordNotification(recordList));
  579. }
  580. /// <summary>
  581. /// 关联工单了推送----电话记录
  582. /// </summary>
  583. /// <param name="dto"></param>
  584. /// <returns></returns>
  585. [NonAction]
  586. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineCallConnectWithOrder)]
  587. public async Task SubmitCaseRecordOrder(CallConnectOrderDto dto)
  588. {
  589. var data = _mapper.Map<SubmitCaseRecord>(dto);
  590. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  591. data.CaseSerial = dto.Order.ProvinceNo;
  592. //将上报信息写入本地库
  593. data.Id = await _submitCaseRecordRepository.AddAsync(data);
  594. //信息上报
  595. await _mediator.Publish(new SubmitCaseRecordNotification(new List<SubmitCaseRecord> { data }));
  596. }
  597. #endregion
  598. /// <summary>
  599. /// 统计数据
  600. /// </summary>
  601. /// <param name="dto"></param>
  602. /// <returns></returns>
  603. [NonAction]
  604. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderSubmitCaseTotal)]
  605. public async Task SubmitCaseTotal(CaseTotal dto)
  606. {
  607. var data = _mapper.Map<SubmitCaseTotal>(dto);
  608. //将上报信息写入本地库
  609. var id = await _submitCaseTotalRepository.AddAsync(data);
  610. data.Id = id;
  611. //信息上报
  612. await _mediator.Publish(new SubmitCaseTotalNotification(data));
  613. }
  614. #endregion
  615. #region 协同-第三批次
  616. /// <summary>
  617. /// 服务工单上报 --- 在派单的时候,确定需不需要往各个平台推送数据--已在派单的推送事件中处理
  618. /// </summary>
  619. /// <param name="dto"></param>
  620. /// <returns></returns>
  621. [NonAction]
  622. //[CapSubscribe(Hotline.Share.Mq.EventNames.SendCaseInfo)]
  623. public async Task SendCaseInfo(OrderDto dto)
  624. {
  625. var sendCaseInfo = _mapper.Map<SendCaseInfo>(dto);
  626. //处理性别
  627. switch (dto.FromGender)
  628. {
  629. case EGender.Female:
  630. sendCaseInfo.AppLicantSex = "0";
  631. break;
  632. case EGender.Male:
  633. sendCaseInfo.AppLicantSex = "1";
  634. break;
  635. case EGender.Unknown:
  636. sendCaseInfo.AppLicantSex = "2";
  637. break;
  638. default:
  639. sendCaseInfo.AppLicantSex = "2";
  640. break;
  641. }
  642. //处理证件类型
  643. sendCaseInfo.CertifiCateType = dto.LicenceTypeCode switch
  644. {
  645. "10" => "10",
  646. "40" => "20",
  647. "55" => "30",
  648. "57" => "40",
  649. _ => "50",
  650. };
  651. //处理紧急程度
  652. sendCaseInfo.CaseIsUrgent = dto.EmergencyLevel switch
  653. {
  654. EEmergencyLevel.QuiteEmergency => "10",
  655. EEmergencyLevel.Emergency => "20",
  656. _ => "30",
  657. };
  658. //处理诉求类型
  659. switch (sendCaseInfo.CaseType)
  660. {
  661. case "10":
  662. case "15":
  663. case "20":
  664. case "25":
  665. case "30":
  666. case "35":
  667. break;
  668. default:
  669. sendCaseInfo.CaseType = "40";
  670. break;
  671. }
  672. sendCaseInfo.Id = await _sendCaseInfoRepository.AddAsync(sendCaseInfo, HttpContext.RequestAborted);
  673. await _mediator.Publish(new SendCaseInfoNotification(sendCaseInfo));
  674. }
  675. /// <summary>
  676. /// 上报补充诉求
  677. /// </summary>
  678. /// <param name="dto"></param>
  679. /// <returns></returns>
  680. [NonAction]
  681. //[CapSubscribe(Hotline.Share.Mq.EventNames.SupplyCaseInfoSend)]
  682. public async Task SupplyCaseInfoSend(SupplyCaseInfoSendInfo dto)
  683. {
  684. var data = _mapper.Map<SupplyCaseInfoSend>(dto);
  685. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  686. //将上报信息写入本地库
  687. var id = await _supplyCaseInfoSendRepository.AddAsync(data);
  688. data.Id = id;
  689. //信息上报
  690. await _mediator.Publish(new SupplyCaseInfoSendNotification(data));
  691. //处理附件
  692. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.CaseSerial, dto.CliengGuid, dto.AreaCode);
  693. }
  694. /// <summary>
  695. /// 服务工单撤单
  696. /// </summary>
  697. /// <param name="dto"></param>
  698. /// <returns></returns>
  699. [NonAction]
  700. //[CapSubscribe(Hotline.Share.Mq.EventNames.SendRevokeCaseInfo)]
  701. public async Task SendRevokeCaseInfo(RevokeCaseInfoInfo dto)
  702. {
  703. var data = _mapper.Map<RevokeCaseInfo>(dto);
  704. data.Direction = "1";
  705. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  706. //将上报信息写入本地库
  707. var id = await _revokeCaseInfoRepository.AddAsync(data);
  708. data.Id = id;
  709. //信息上报
  710. await _mediator.Publish(new SendRevokeCaseInfoNotification(data));
  711. //处理附件
  712. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.CaseSerial, dto.CliengGuid, dto.AreaCode);
  713. }
  714. /// <summary>
  715. /// 服务工单催单--已对接
  716. /// </summary>
  717. /// <param name="dto"></param>
  718. /// <returns></returns>
  719. [NonAction]
  720. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderUrgeInform)]
  721. public async Task SendRemindCaseInfo(PublishUrgeDto dto)
  722. {
  723. //被催办部门为省上,才能调用接口
  724. if (dto.Urge.OrgName == "")
  725. {
  726. var data = _mapper.Map<RemindCaseInfo>(dto);
  727. data.Direction = "1";
  728. //将上报信息写入本地库
  729. data.Id = await _remindCaseInfoRepository.AddAsync(data);
  730. //信息上报
  731. await _mediator.Publish(new SendRemindCaseInfoNotification(data));
  732. //处理附件
  733. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.Order.ProvinceNo, dto.ClientGuid, dto.Order.AreaCode);
  734. }
  735. }
  736. #endregion
  737. #region 协同-第四批次
  738. #region 知识库--已对接附件
  739. /// <summary>
  740. /// 知识库上报
  741. /// </summary>
  742. /// <param name="dto"></param>
  743. /// <returns></returns>
  744. [NonAction]
  745. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineKnowledgeAdd)]
  746. public async Task GetKnowledgeInfoSend(KnowledgeSendDto dto)
  747. {
  748. var data = _mapper.Map<GetKnowledgeInfoSend>(dto);
  749. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  750. dto.CliengGuid = Guid.NewGuid().ToString();
  751. if (data.DisableDate == null)//如果没得有失效时间,默认在生效日期上面加10年
  752. data.DisableDate = data.BeginDate.Value.AddYears(10);
  753. //将上报信息写入本地库
  754. data.Id = await _getKnowledgeInfoSendRepository.AddAsync(data);
  755. //保存原始数据
  756. var dataRaw = _mapper.Map<KnowledgeRawData>(data);
  757. await _knowledgeRawDataRepository.AddAsync(dataRaw);
  758. //信息上报
  759. await _mediator.Publish(new GetKnowledgeInfoSendNotification(data));
  760. //知识附件处理
  761. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.UID, dto.CliengGuid, data.AreaCode);
  762. }
  763. /// <summary>
  764. /// 知识库变更
  765. /// </summary>
  766. /// <param name="dto"></param>
  767. /// <returns></returns>
  768. [NonAction]
  769. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineKnowledgeUpdate)]
  770. public async Task GetKnowledgeInfoUpdate(KnowledgeSendDto dto)
  771. {
  772. var data = _mapper.Map<GetKnowledgeInfoUpdate>(dto);
  773. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  774. dto.CliengGuid = Guid.NewGuid().ToString();
  775. if (data.DisableDate == null)//如果没得有失效时间,默认在生效日期上面加10年
  776. data.DisableDate = data.BeginDate.Value.AddYears(10);
  777. //将上报信息写入本地库
  778. data.Id = await _getKnowledgeInfoUpdateRepository.AddAsync(data);
  779. //查询原有数据,如果有修改原始数据,没有直接新增
  780. var dataRaw = await _knowledgeRawDataRepository.GetAsync(p => p.UID == data.UID);
  781. var raw = _mapper.Map<KnowledgeRawData>(data);
  782. if (dataRaw != null)
  783. {
  784. raw.Id = dataRaw.Id;
  785. await _knowledgeRawDataRepository.UpdateAsync(raw);
  786. }
  787. else
  788. await _knowledgeRawDataRepository.AddAsync(raw);
  789. //信息上报
  790. await _mediator.Publish(new GetKnowledgeInfoUpdateNotification(data));
  791. //知识附件处理
  792. await _provinceService.FileData(new List<Hotline.Share.Dtos.File.FileDto>(), dto.UID, dto.CliengGuid, data.AreaCode);
  793. }
  794. /// <summary>
  795. /// 知识库下架
  796. /// </summary>
  797. /// <param name="dto"></param>
  798. /// <returns></returns>
  799. [NonAction]
  800. [CapSubscribe(Hotline.Share.Mq.EventNames.HotlineKnowledgeRemove)]
  801. public async Task GetKnowledgeInfoAbandon(KnowledgeSendDto dto)
  802. {
  803. var data = _mapper.Map<GetKnowledgeInfoAbandon>(dto);
  804. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  805. //将上报信息写入本地库
  806. data.Id = await _getKnowledgeInfoAbandonRepository.AddAsync(data);
  807. //知识下架删除原有原始数据
  808. await _knowledgeRawDataRepository.RemoveAsync(p => p.UID == data.UID, false);
  809. //信息上报
  810. await _mediator.Publish(new GetKnowledgeInfoAbandonNotification(data));
  811. }
  812. #endregion
  813. /// <summary>
  814. /// 实时服务上报
  815. /// </summary>
  816. /// <param name="dto"></param>
  817. /// <returns></returns>
  818. [NonAction]
  819. //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineSendRealTimeStatus)]
  820. public async Task SendRealTimeStatus(SendRealTimeStatusInfo dto)
  821. {
  822. var data = _mapper.Map<SendRealTimeStatus>(dto);
  823. data.AreaCode = _channelConfigurationManager.GetConfigurationCityCode().AreaCode;
  824. //将上报信息写入本地库
  825. data.Id = await _sendRealTimeStatusRepository.AddAsync(data);
  826. //信息上报
  827. await _mediator.Publish(new SendRealTimeStatusNotification(data));
  828. }
  829. #endregion
  830. }
  831. }