TANG JIANG 2 years ago
parent
commit
73dae2ee3f

+ 25 - 3
src/Sharing.Api/Controllers/HotlineMessageReceiveController.cs

@@ -23,6 +23,7 @@ namespace Sharing.Api.Controllers
         private readonly ILogger<HotlineMsgReceiver> _logger;
         private readonly IMapper _mapper;
         private readonly IGetCaseResultReceiveRepository _getCaseResultReceiveRepository;
+        private readonly IGetCaseProcessReceiveRepository _getCaseProcessReceiveRepository;
 
         /// <summary>
         /// 
@@ -33,13 +34,14 @@ namespace Sharing.Api.Controllers
         /// <param name="mapper"></param>
         /// <param name="getCaseResultReceiveRepository"></param>
         public HotlineMessageReceiveController(IDataOrderRepository dataOrderRepository, IMediator mediator, ILogger<HotlineMsgReceiver> logger, IMapper mapper
-            , IGetCaseResultReceiveRepository getCaseResultReceiveRepository)
+            , IGetCaseResultReceiveRepository getCaseResultReceiveRepository, IGetCaseProcessReceiveRepository getCaseProcessReceiveRepository)
         {
             _dataOrderRepository = dataOrderRepository;
             _mediator = mediator;
             _logger = logger;
             _mapper = mapper;
             _getCaseResultReceiveRepository = getCaseResultReceiveRepository;
+            _getCaseProcessReceiveRepository = getCaseProcessReceiveRepository;
         }
 
         [NonAction]
@@ -61,17 +63,37 @@ namespace Sharing.Api.Controllers
         /// <returns></returns>
         [NonAction]
         //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderCreated)]
-        [CapSubscribe("GetCaseResultReceive")]
         public async Task GetCaseResultReceive(GetCaseResultReceiveInfo dto)
         {
             var data = _mapper.Map<GetCaseResultReceive>(dto);
 
             //将上报信息写入本地库
-             await _getCaseResultReceiveRepository.AddAsync(data);
+            var id= await _getCaseResultReceiveRepository.AddAsync(data);
 
+            data.Id = id;
             //信息上报
             await _mediator.Publish(new GetCaseResultReceiveNotification(data));
 
         }
+
+        /// <summary>
+        /// 服务工单交办处理过程
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [NonAction]
+        //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderCreated)]
+        public async Task GetCaseProcessReceive(GetCaseProcessReceiveInfo dto)
+        {
+            var data = _mapper.Map<GetCaseProcessReceive>(dto);
+
+            //将上报信息写入本地库
+            var id = await _getCaseProcessReceiveRepository.AddAsync(data);
+
+            data.Id = id;
+            //信息上报
+            await _mediator.Publish(new GetCaseProcessReceiveNotification(data));
+
+        }
     }
 }

+ 1 - 1
src/Sharing.Province/Controllers/ProvinceController.cs

@@ -67,7 +67,7 @@ namespace Sharing.Province.Controllers
 
             var response = await pusher.PushGetCaseResultReceiveAsync(request, cancellationToken: default);
 
-            return response.ReturnInfo.Description;
+            return response.Description;
 
             //将上报信息写入本地库
             // await _getCaseResultReceiveRepository.AddAsync(data);

+ 15 - 2
src/Sharing.Province/DefaultPusher.cs

@@ -35,8 +35,21 @@ public class DefaultPusher : IProvincePusher
     /// <param name="request"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    public async Task<ProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
+    public async Task<BaseProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
     {
-        return await _xieTongClient.RequestAsync<GetCaseResultReceiveRequest, ProvinceResponse>(request, cancellationToken);
+        var response = await _xieTongClient.RequestAsync<GetCaseResultReceiveRequest, ProvinceResponse>(request, cancellationToken);
+        return response.ReturnInfo;
+    }
+
+    /// <summary>
+    /// 服务工单交办处理过程
+    /// </summary>
+    /// <param name="request"></param>
+    /// <param name="cancellationToken"></param>
+    /// <returns></returns>
+    public async Task<BaseProvinceResponse> PushGetCaseProcessReceiveAsync(GetCaseProcessReceiveRequest request, CancellationToken cancellationToken)
+    {
+        var response = await _xieTongClient.RequestAsync<GetCaseProcessReceiveRequest, ProvinceResponse>(request, cancellationToken);
+        return response.ReturnInfo;
     }
 }

+ 90 - 0
src/Sharing.Province/Dtos/XieTong/Send/GetCaseProcessReceiveRequest.cs

@@ -0,0 +1,90 @@
+using Microsoft.AspNetCore.Http;
+using Sharing.Province.XieTong.Send;
+using System.Text.Json.Serialization;
+
+namespace Sharing.Province.Dtos.XieTong.Send
+{
+    /// <summary>
+    /// 服务工单交办处理过程  
+    /// </summary>
+    public class GetCaseProcessReceiveRequest : ProvinceRequest<GetCaseProcessReceiveData>
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public override string GetRequestUrl() => "get_case_process_receive";
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public override string GetHttpMethod() => HttpMethods.Post;
+    }
+
+    /// <summary>
+    /// 服务工单交办处理过程
+    /// </summary>
+    public class GetCaseProcessReceiveData
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        [JsonPropertyName("jsonList")]
+        public IReadOnlyList<GetCaseProcessReceiveInfo> GetCaseProcessReceiveInfos { get; set; }
+    }
+
+    /// <summary>
+    /// 
+    /// </summary>
+    public class GetCaseProcessReceiveInfo : BaseModel
+    {
+        /// <summary>
+        /// 处理部门
+        /// </summary>
+        [JsonPropertyName("DEPT_NAME")]
+        public string DeptName { get; set; }
+
+        /// <summary>
+        /// 环节名称
+        /// </summary>
+        [JsonPropertyName("TACHE_NAME")]
+        public string TacheName { get; set; }
+
+        /// <summary>
+        /// 处理时间
+        /// </summary>
+        [JsonPropertyName("PROCESS_TIME")]
+        public DateTime? ProcessTime { get; set; }
+
+        /// <summary>
+        /// 处理人员
+        /// </summary>
+        [JsonPropertyName("PROCESS_NAME")]
+        public string ProcessName { get; set; }
+
+        /// <summary>
+        /// 处理意见
+        /// </summary>
+        [JsonPropertyName("PROCESS_NOTE")]
+        public string ProcessNote { get; set; }
+
+        /// <summary>
+        /// 办理部门所在区、市、县行政区划代码
+        /// </summary>
+        [JsonPropertyName("END_AREACODE")]
+        public string EndAreacode { get; set; }
+
+        /// <summary>
+        /// 办理部门所在区、市、县行政区划名称
+        /// </summary>
+        [JsonPropertyName("END_AREANAME")]
+        public string EndAreaname { get; set; }
+
+        /// <summary>
+        /// 任务关联单 guid
+        /// </summary>
+        [JsonPropertyName("TROWGUID")]
+        public string TrowGuid { get; set; }
+    }
+}

+ 74 - 0
src/Sharing.Province/Handlers/GetCaseProcessReceiveHandler.cs

@@ -0,0 +1,74 @@
+using MapsterMapper;
+using MediatR;
+using Sharing.Notifications;
+using Sharing.Province.Dtos.XieTong.Send;
+using Sharing.Province.XieTong.Send;
+using Sharing.Repository.Province.XieTong.Send;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Sharing.Province.Handlers
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class GetCaseProcessReceiveHandler : INotificationHandler<GetCaseProcessReceiveNotification>
+    {
+        private readonly IChannelConfigurationManager _channelConfigurationManager;
+        private readonly PusherProvider _pusherProvider;
+        private readonly IMapper _mapper;
+        private readonly IGetCaseProcessReceiveRepository _getCaseProcessReceiveRepository;
+
+      /// <summary>
+      /// 
+      /// </summary>
+      /// <param name="channelConfigurationManager"></param>
+      /// <param name="pusherProvider"></param>
+      /// <param name="mapper"></param>
+      /// <param name="getCaseProcessReceiveRepository"></param>
+        public GetCaseProcessReceiveHandler(IChannelConfigurationManager channelConfigurationManager, PusherProvider pusherProvider, IMapper mapper
+            , IGetCaseProcessReceiveRepository getCaseProcessReceiveRepository)
+        {
+            _channelConfigurationManager = channelConfigurationManager;
+            _pusherProvider = pusherProvider;
+            _mapper = mapper;
+            _getCaseProcessReceiveRepository = getCaseProcessReceiveRepository;
+        }
+
+        /// <summary>
+        /// 服务工单交办处理过程
+        /// </summary>
+        /// <param name="notification"></param>
+        /// <param name="cancellationToken"></param>
+        /// <returns></returns>
+        public async Task Handle(GetCaseProcessReceiveNotification notification, CancellationToken cancellationToken = default)
+        {
+            var pusher = _pusherProvider.CreatePusher(_channelConfigurationManager);
+
+            var dataReceive = _mapper.Map<GetCaseProcessReceiveInfo>(notification.Data);
+            var data = new GetCaseProcessReceiveData
+            {
+                GetCaseProcessReceiveInfos = new List<GetCaseProcessReceiveInfo>
+                {
+                    dataReceive
+                }
+            };
+
+            var request = new GetCaseProcessReceiveRequest();
+            request.SetData(data);
+
+            var response = await pusher.PushGetCaseProcessReceiveAsync(request, cancellationToken);
+
+            //如果推送成功修改数据状态
+            if (response != null && response.Code == "1")
+            {
+                notification.Data.SyncState = "1";
+                notification.Data.ReturnResult = Newtonsoft.Json.JsonConvert.SerializeObject(response);
+                await _getCaseProcessReceiveRepository.UpdateAsync(notification.Data);
+            }
+        }
+    }
+}

+ 13 - 3
src/Sharing.Province/Handlers/GetCaseResultReceiveHandler.cs

@@ -16,6 +16,7 @@ namespace Sharing.Province.Handlers
         private readonly IChannelConfigurationManager _channelConfigurationManager;
         private readonly PusherProvider _pusherProvider;
         private readonly IMapper _mapper;
+        private readonly IGetCaseResultReceiveRepository _getCaseResultReceiveRepository;
 
         /// <summary>
         /// 
@@ -23,11 +24,12 @@ namespace Sharing.Province.Handlers
         /// <param name="channelConfigurationManager"></param>
         /// <param name="pusherProvider"></param>
         /// <param name="mapper"></param>
-        public GetCaseResultReceiveHandler(IChannelConfigurationManager channelConfigurationManager, PusherProvider pusherProvider, IMapper mapper)
+        public GetCaseResultReceiveHandler(IChannelConfigurationManager channelConfigurationManager, PusherProvider pusherProvider, IMapper mapper, IGetCaseResultReceiveRepository getCaseResultReceiveRepository)
         {
             _channelConfigurationManager = channelConfigurationManager;
             _pusherProvider = pusherProvider;
             _mapper = mapper;
+            _getCaseResultReceiveRepository = getCaseResultReceiveRepository;
         }
 
         /// <summary>
@@ -36,7 +38,7 @@ namespace Sharing.Province.Handlers
         /// <param name="notification"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public async Task Handle(GetCaseResultReceiveNotification notification, CancellationToken cancellationToken=default)
+        public async Task Handle(GetCaseResultReceiveNotification notification, CancellationToken cancellationToken = default)
         {
             var pusher = _pusherProvider.CreatePusher(_channelConfigurationManager);
 
@@ -52,7 +54,15 @@ namespace Sharing.Province.Handlers
             var request = new GetCaseResultReceiveRequest();
             request.SetData(data);
 
-            await pusher.PushGetCaseResultReceiveAsync(request, cancellationToken);
+            var response = await pusher.PushGetCaseResultReceiveAsync(request, cancellationToken);
+
+            //如果推送成功修改数据状态
+            if (response != null && response.Code == "1")
+            {
+                notification.Data.SyncState = "1";
+                notification.Data.ReturnResult = Newtonsoft.Json.JsonConvert.SerializeObject(response);
+                await _getCaseResultReceiveRepository.UpdateAsync(notification.Data);
+            }
         }
     }
 }

+ 9 - 1
src/Sharing.Province/IProvincePusher.cs

@@ -22,5 +22,13 @@ public interface IProvincePusher
     /// <param name="request"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    Task<ProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken);
+    Task<BaseProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken);
+
+    /// <summary>
+    /// 服务工单交办处理过程
+    /// </summary>
+    /// <param name="request"></param>
+    /// <param name="cancellationToken"></param>
+    /// <returns></returns>
+    Task<BaseProvinceResponse> PushGetCaseProcessReceiveAsync(GetCaseProcessReceiveRequest request, CancellationToken cancellationToken);
 }

+ 12 - 1
src/Sharing.Province/SmartPusher.cs

@@ -18,7 +18,18 @@ public class SmartPusher : IProvincePusher
     /// <param name="request"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    public async Task<ProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
+    public async Task<BaseProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
+    {
+        throw new NotImplementedException();
+    }
+
+    /// <summary>
+    /// 服务工单交办处理过程
+    /// </summary>
+    /// <param name="request"></param>
+    /// <param name="cancellationToken"></param>
+    /// <returns></returns>
+    public async Task<BaseProvinceResponse> PushGetCaseProcessReceiveAsync(GetCaseProcessReceiveRequest request, CancellationToken cancellationToken)
     {
         throw new NotImplementedException();
     }

+ 14 - 0
src/Sharing.Repository/Province/XieTong/Send/GetCaseProcessReceiveRepository.cs

@@ -0,0 +1,14 @@
+using Sharing.Province.XieTong.Send;
+using SqlSugar;
+using XF.Domain.Dependency;
+
+namespace Sharing.Repository.Province.XieTong.Send
+{
+    public class GetCaseProcessReceiveRepository : BaseRepository<GetCaseProcessReceive>, IGetCaseProcessReceiveRepository, IScopeDependency
+    {
+        public GetCaseProcessReceiveRepository(ISugarUnitOfWork<SharingDbContext> uow) : base(uow)
+        {
+
+        }
+    }
+}

+ 11 - 0
src/Sharing/Notifications/GetCaseProcessReceiveNotification.cs

@@ -0,0 +1,11 @@
+using MediatR;
+using Sharing.Province.XieTong.Send;
+
+namespace Sharing.Notifications
+{
+    /// <summary>
+    /// 服务工单交办处理  
+    /// </summary>
+    /// <param name="Data"></param>
+    public record GetCaseProcessReceiveNotification(GetCaseProcessReceive Data) : INotification;
+}

+ 6 - 0
src/Sharing/Province/HuiJu/Send/BaseSendResult.cs

@@ -25,6 +25,12 @@ namespace Sharing.Province.HuiJu.Send
         /// </summary>
         [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
         public string ReturnResult { get; set; }
+
+        /// <summary>
+        /// 同步状态 0:待同步;	  1:同步成功;	 2:同步失败;
+        /// </summary>
+        [SugarColumn(ColumnDescription = "同步状态", ColumnDataType = "varchar(1)", IsNullable = true)]
+        public string SyncState { get; set; } = "0";
     }
 
     /// <summary>

+ 61 - 0
src/Sharing/Province/XieTong/Send/GetCaseProcessReceive.cs

@@ -0,0 +1,61 @@
+using Sharing.Province.HuiJu.Send;
+using SqlSugar;
+using System.ComponentModel;
+
+namespace Sharing.Province.XieTong.Send
+{
+    /// <summary>
+    /// 服务工单交办处理过程 
+    /// </summary>
+    [Description("服务工单交办处理过程")]
+    public class GetCaseProcessReceive : BaseSendResult
+    {
+        /// <summary>
+        /// 处理部门
+        /// </summary>
+        [SugarColumn(ColumnDescription = "处理部门", ColumnDataType = "varchar(200)")]
+        public string DeptName { get; set; }
+
+        /// <summary>
+        /// 环节名称
+        /// </summary>
+        [SugarColumn(ColumnDescription = "环节名称", ColumnDataType = "varchar(50)")]
+        public string TacheName { get; set; }
+
+        /// <summary>
+        /// 处理时间
+        /// </summary>
+        [SugarColumn(ColumnDescription = "处理时间")]
+        public DateTime? ProcessTime { get; set; }
+
+        /// <summary>
+        /// 处理人员
+        /// </summary>
+        [SugarColumn(ColumnDescription = "处理人员", ColumnDataType = "varchar(100)")]
+        public string ProcessName { get; set; }
+
+        /// <summary>
+        /// 处理意见
+        /// </summary>
+        [SugarColumn(ColumnDescription = "处理意见", ColumnDataType = "text")]
+        public string ProcessNote { get; set; }
+
+        /// <summary>
+        /// 办理部门所在区、市、县行政区划代码
+        /// </summary>
+        [SugarColumn(ColumnDescription = "办理部门所在区、市、县行政区划代码", ColumnDataType = "varchar(24)")]
+        public string EndAreacode { get; set; }
+
+        /// <summary>
+        /// 办理部门所在区、市、县行政区划名称
+        /// </summary>
+        [SugarColumn(ColumnDescription = "办理部门所在区、市、县行政区划名称", ColumnDataType = "varchar(24)")]
+        public string EndAreaname { get; set; }
+
+        /// <summary>
+        /// 任务关联单 guid
+        /// </summary>
+        [SugarColumn(ColumnDescription = "任务关联单 guid", ColumnDataType = "varchar(50)")]
+        public string TrowGuid { get; set; }
+    }
+}

+ 8 - 0
src/Sharing/Province/XieTong/Send/IGetCaseProcessReceiveRepository.cs

@@ -0,0 +1,8 @@
+using XF.Domain.Repository;
+
+namespace Sharing.Province.XieTong.Send
+{
+    public interface IGetCaseProcessReceiveRepository : IRepository<GetCaseProcessReceive>
+    {
+    }
+}