|
@@ -0,0 +1,212 @@
|
|
|
+using DataSharing.RawData;
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Enums.DataSharing;
|
|
|
+using MapsterMapper;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
+using XF.Domain.Dependency;
|
|
|
+using XF.Domain.Repository;
|
|
|
+
|
|
|
+namespace DataSharing.Police110.DCJT110
|
|
|
+{
|
|
|
+ public class DcjtService : IDcjtService, IScopeDependency
|
|
|
+ {
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly ILogger<DcjtService> _logger;
|
|
|
+ private readonly IRepository<DsPoliceSendChainAlarmDcjt> _policeSendChainAlarmDcjtRepository;
|
|
|
+ private readonly IRepository<DsPoliceSendChainDealDcjt> _policeSendChainDealDcjtRepository;
|
|
|
+ private readonly IRepository<DsOrder> _dsOrderRepository;
|
|
|
+ private readonly ISharingConfigurationManager _sharingConfigurationManager;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mapper"></param>
|
|
|
+ /// <param name="logger"></param>
|
|
|
+ /// <param name="policeSendChainAlarmDcjtRepository"></param>
|
|
|
+ /// <param name="policeSendChainDealDcjtRepository"></param>
|
|
|
+ /// <param name="dsOrderRepository"></param>
|
|
|
+ /// <param name="sharingConfigurationManager"></param>
|
|
|
+ public DcjtService(IMapper mapper, ILogger<DcjtService> logger,
|
|
|
+ IRepository<DsPoliceSendChainAlarmDcjt> policeSendChainAlarmDcjtRepository,
|
|
|
+ IRepository<DsPoliceSendChainDealDcjt> policeSendChainDealDcjtRepository,
|
|
|
+ IRepository<DsOrder> dsOrderRepository,
|
|
|
+ ISharingConfigurationManager sharingConfigurationManager)
|
|
|
+ {
|
|
|
+ _mapper = mapper;
|
|
|
+ _logger = logger;
|
|
|
+ _policeSendChainAlarmDcjtRepository = policeSendChainAlarmDcjtRepository;
|
|
|
+ _policeSendChainDealDcjtRepository = policeSendChainDealDcjtRepository;
|
|
|
+ _dsOrderRepository = dsOrderRepository;
|
|
|
+ _sharingConfigurationManager = sharingConfigurationManager;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 组装110数据,12345警情工单推送到110
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="orderDto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task InitPoliceSendChainAlarmDsAsync(OrderDto orderDto, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var areaCodeDefu = _sharingConfigurationManager.GetCityCode();
|
|
|
+ var config = _sharingConfigurationManager.GetZiGongConfig().PoliceDCJT;
|
|
|
+ DsPoliceSendChainAlarmDcjt policeSend = new()
|
|
|
+ {
|
|
|
+ SerialNumber = orderDto.ExternalId,
|
|
|
+ AlarmReceiptNumber = orderDto.ExternalId,
|
|
|
+ RegisterNo = orderDto.AcceptorStaffNo,
|
|
|
+ RegisterName = orderDto.AcceptorName,
|
|
|
+ CallPoliceNumber = string.IsNullOrEmpty(orderDto.FromPhone) == true ? orderDto.Contact : orderDto.FromPhone,
|
|
|
+ CallPoliceName = orderDto.FromName,
|
|
|
+ PhoneNumber = orderDto.Contact,
|
|
|
+ CallPoliceContent = orderDto.Content,
|
|
|
+ PoliceTypeCode = "",
|
|
|
+ PoliceTypeName = "",
|
|
|
+ JurisdictionalUnitCode = config.GXDWDM,
|
|
|
+ JurisdictionalUnitName = config.GXDWMC,
|
|
|
+ JurisdictionalUnitNumber = config.GXDWDH,
|
|
|
+ AlarmReceivingUnitCode = "",
|
|
|
+ AlarmReceivingUnitName = "",
|
|
|
+ CallPoliceTime = Convert.ToDateTime(orderDto.CreationTime),
|
|
|
+ PushTime = DateTime.Now,
|
|
|
+ AlarmReceptionType = "0",
|
|
|
+ AreaCode = orderDto.AreaCode.Substring(0, 6),
|
|
|
+ CallPoliceAddress = orderDto.FullAddress,
|
|
|
+ OrderId = orderDto.Id
|
|
|
+ };
|
|
|
+
|
|
|
+ policeSend.FromGender = orderDto.FromGender switch
|
|
|
+ {
|
|
|
+ Hotline.Share.Enums.Order.EGender.Female => "0",
|
|
|
+ Hotline.Share.Enums.Order.EGender.Male => "1",
|
|
|
+ Hotline.Share.Enums.Order.EGender.Unknown => "2",
|
|
|
+ _ => "2",
|
|
|
+ };
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(policeSend.AlarmReceiptNumber))
|
|
|
+ {
|
|
|
+ policeSend.AlarmReceiptNumber = areaCodeDefu + "12345" + orderDto.No;
|
|
|
+ policeSend.SerialNumber = areaCodeDefu + "12345" + orderDto.No;
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改外部唯一ID
|
|
|
+ var orderData = await _dsOrderRepository.GetAsync(p => p.OrderId == orderDto.Id, cancellationToken);
|
|
|
+ if (orderData != null)
|
|
|
+ {
|
|
|
+ orderData.ExternalId = policeSend.AlarmReceiptNumber;
|
|
|
+ await _dsOrderRepository.UpdateAsync(orderData, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询是否有此工单,如果没有新增此工单
|
|
|
+ var data = await _policeSendChainAlarmDcjtRepository.GetAsync(p => p.OrderId == orderDto.Id, cancellationToken);
|
|
|
+ if (data == null)
|
|
|
+ await _policeSendChainAlarmDcjtRepository.AddAsync(policeSend, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 110的非警情工单获取办理信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task InitPoliceSendChainDealDsAsync(OrderFlowDto dto, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var data = await _policeSendChainDealDcjtRepository.GetAsync(p => p.OrderId == dto.Order.Id && p.DisposalType == (int)EDsDisposalType.OrderFiled, cancellationToken);
|
|
|
+ if (data == null)
|
|
|
+ {
|
|
|
+ data = new()
|
|
|
+ {
|
|
|
+ AlarmReceiptNumber = dto.Order.ExternalId,
|
|
|
+ FeedbackTime = dto.Order.ActualHandleTime,
|
|
|
+ DisposalSituation = dto.Order.ActualOpinion,
|
|
|
+ ResultDescription = dto.Order.ActualOpinion,
|
|
|
+ FeedbackPersonNumber = dto.Order.ActualHandlerId,
|
|
|
+ FeedbackPersonName = dto.Order.ActualHandlerName,
|
|
|
+ FeedbackUnitCode = dto.Order.ActualHandleOrgCode,
|
|
|
+ FeedbackUnitName = dto.Order.ActualHandleOrgName,
|
|
|
+ WarehousingTime = DateTime.Now,
|
|
|
+ DisposalType = 1,
|
|
|
+ OrderId = dto.Order.Id
|
|
|
+ };
|
|
|
+ await _policeSendChainDealDcjtRepository.AddAsync(data, cancellationToken);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.AlarmReceiptNumber = dto.Order.ExternalId;
|
|
|
+ data.FeedbackTime = dto.Order.ActualHandleTime;
|
|
|
+ data.DisposalSituation = dto.Order.ActualOpinion;
|
|
|
+ data.ResultDescription = dto.Order.ActualOpinion;
|
|
|
+ data.FeedbackPersonNumber = dto.Order.ActualHandlerId;
|
|
|
+ data.FeedbackPersonName = dto.Order.ActualHandlerName;
|
|
|
+ data.FeedbackUnitCode = dto.Order.ActualHandleOrgCode;
|
|
|
+ data.FeedbackUnitName = dto.Order.ActualHandleOrgName;
|
|
|
+ data.WarehousingTime = DateTime.Now;
|
|
|
+ await _policeSendChainDealDcjtRepository.UpdateAsync(data, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 110警情工单退回
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="orderDto"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task ReturnPoliceAsync(OrderDto orderDto, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var checkData = await _policeSendChainDealDcjtRepository.AnyAsync(p => p.AlarmReceiptNumber == orderDto.ExternalId && p.DisposalType == (int)EDsDisposalType.Return, cancellationToken);
|
|
|
+ if (!checkData)
|
|
|
+ {
|
|
|
+ var dataPolice = new DsPoliceSendChainDealDcjt()
|
|
|
+ {
|
|
|
+ OrderId = orderDto.Id,
|
|
|
+ AlarmReceiptNumber = orderDto.ExternalId,
|
|
|
+ ReturnName = orderDto.ActualHandlerName,
|
|
|
+ ReturnUnit = orderDto.ActualHandleOrgName,
|
|
|
+ ReturnOpinion = orderDto.ActualOpinion,
|
|
|
+ ReturnTime = orderDto.ActualHandleTime,
|
|
|
+ WarehousingTime = DateTime.Now,
|
|
|
+ DisposalType = 2
|
|
|
+ };
|
|
|
+ await _policeSendChainDealDcjtRepository.AddAsync(dataPolice, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 110回访数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task Visit(PublishVisitDto dto, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var VisitResult = dto.SubjectResultSatifyCode switch
|
|
|
+ {
|
|
|
+ "2" => "3",
|
|
|
+ "4" or "5" => "1",
|
|
|
+ _ => "2",
|
|
|
+ };
|
|
|
+ var checkData = await _policeSendChainDealDcjtRepository.GetAsync(p => p.AlarmReceiptNumber == dto.Order.ExternalId && p.DisposalType == (int)EDsDisposalType.Visit, cancellationToken);
|
|
|
+ if (checkData == null)
|
|
|
+ {
|
|
|
+ checkData = new()
|
|
|
+ {
|
|
|
+ AlarmReceiptNumber = dto?.Order?.ExternalId,
|
|
|
+ RevisitTime = dto.VisitTime,
|
|
|
+ CheckingContent = dto.VisitRemark,
|
|
|
+ VisitContent = dto.VisitRemark,
|
|
|
+ VisitResult = VisitResult,
|
|
|
+ DisposalType = 3
|
|
|
+ };
|
|
|
+ await _policeSendChainDealDcjtRepository.AddAsync(checkData, cancellationToken);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ checkData.AlarmReceiptNumber = dto?.Order?.ExternalId;
|
|
|
+ checkData.RevisitTime = dto.VisitTime;
|
|
|
+ checkData.CheckingContent = dto.VisitRemark;
|
|
|
+ checkData.VisitContent = dto.VisitRemark;
|
|
|
+ checkData.VisitResult = VisitResult;
|
|
|
+ await _policeSendChainDealDcjtRepository.UpdateAsync(checkData, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|