TANG JIANG 2 년 전
부모
커밋
69e70c1d9c

+ 8 - 11
src/Sharing.Api/Controllers/HotlineMessageReceiveController.cs

@@ -7,7 +7,6 @@ using Sharing.Application;
 using Sharing.Notifications;
 using Sharing.Orders;
 using Sharing.Province.Dtos.XieTong.Send;
-using Sharing.Province.XieTong.Receive;
 using Sharing.Province.XieTong.Send;
 using Sharing.WebCore;
 using System.Threading;
@@ -24,7 +23,6 @@ namespace Sharing.Api.Controllers
         private readonly ILogger<HotlineMsgReceiver> _logger;
         private readonly IMapper _mapper;
         private readonly IGetCaseResultReceiveRepository _getCaseResultReceiveRepository;
-        private readonly ISendCaseEvlResultRepository _sendCaseEvlResultRepository;
 
         /// <summary>
         /// 
@@ -35,14 +33,13 @@ 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, ISendCaseEvlResultRepository sendCaseEvlResultRepository)
+            , IGetCaseResultReceiveRepository getCaseResultReceiveRepository)
         {
             _dataOrderRepository = dataOrderRepository;
             _mediator = mediator;
             _logger = logger;
             _mapper = mapper;
             _getCaseResultReceiveRepository = getCaseResultReceiveRepository;
-            _sendCaseEvlResultRepository = sendCaseEvlResultRepository;
         }
 
         [NonAction]
@@ -53,7 +50,7 @@ namespace Sharing.Api.Controllers
             // _logger.LogInformation("rec order");
             // await _dataOrderRepository.AddAsync(new DataOrder(), HttpContext.RequestAborted);
 
-           // await _mediator.Publish(new OrderCreatedNotification(new DataOrder()), HttpContext.RequestAborted);
+             await _mediator.Publish(new OrderCreatedNotification(new DataOrder()));
             // _logger.LogInformation("publish order success!");
         }
 
@@ -65,15 +62,15 @@ namespace Sharing.Api.Controllers
         [NonAction]
         //[CapSubscribe(Hotline.Share.Mq.EventNames.HotlineOrderCreated)]
         [CapSubscribe("GetCaseResultReceive")]
-        public async Task GetCaseResultReceive(SendCaseEvlResult dto)
+        public async Task GetCaseResultReceive(GetCaseResultReceiveInfo dto)
         {
-           // var data = _mapper.Map<GetCaseResultReceive>(dto);
+            var data = _mapper.Map<GetCaseResultReceive>(dto);
 
-            ////将上报信息写入本地库
-           await _sendCaseEvlResultRepository.AddAsync(dto, HttpContext.RequestAborted);
+            //将上报信息写入本地库
+             await _getCaseResultReceiveRepository.AddAsync(data);
 
-            ////信息上报
-           // await _mediator.Publish(new GetCaseResultReceiveNotification(dto), HttpContext.RequestAborted);
+            //信息上报
+            await _mediator.Publish(new GetCaseResultReceiveNotification(data));
 
         }
     }

+ 34 - 15
src/Sharing.Province/Controllers/ProvinceController.cs

@@ -1,15 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http.Headers;
-using System.Text;
-using System.Text.Json.Serialization;
-using System.Threading;
-using System.Threading.Tasks;
-using DotNetCore.CAP;
-using Hotline.Share.Dtos.Order;
-using Hotline.Share.Mq;
-using IdentityModel.Client;
+using DotNetCore.CAP;
+using MapsterMapper;
+using MediatR;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using Sharing.Province.Dtos;
@@ -24,12 +15,16 @@ namespace Sharing.Province.Controllers
         private readonly IChannelConfigurationManager _channelConfigurationManager;
         private readonly PusherProvider _pusherProvider;
         private readonly ICapPublisher _capPublisher;
+        private readonly IMapper _mapper;
+        private readonly IMediator _mediator;
 
-        public ProvinceController( IChannelConfigurationManager channelConfigurationManager, PusherProvider pusherProvider, ICapPublisher capPublisher)
+        public ProvinceController(IChannelConfigurationManager channelConfigurationManager, PusherProvider pusherProvider, ICapPublisher capPublisher, IMapper mapper, IMediator mediator)
         {
             _channelConfigurationManager = channelConfigurationManager;
             _pusherProvider = pusherProvider;
             _capPublisher = capPublisher;
+            _mapper = mapper;
+            _mediator = mediator;
         }
 
         [HttpGet("test")]
@@ -52,10 +47,34 @@ namespace Sharing.Province.Controllers
         /// <returns></returns>
         [HttpPost("getcaseresultreceive")]
         [AllowAnonymous]
-        public async Task GetCaseResultReceive([FromBody] GetCaseResultReceiveInfo dto)
+        public async Task<string> GetCaseResultReceive([FromBody] GetCaseResultReceiveInfo dto)
         {
+            //var data = _mapper.Map<GetCaseResultReceive>(dto);
 
-            await _capPublisher.PublishAsync("GetCaseResultReceive", dto, cancellationToken: HttpContext.RequestAborted);
+            var pusher = _pusherProvider.CreatePusher(_channelConfigurationManager);
+
+            //var dataReceive = _mapper.Map<GetCaseResultReceiveInfo>(data);
+            var datarequest = new GetCaseResultReceiveData
+            {
+                GetCaseResultReceiveInfos = new List<GetCaseResultReceiveInfo>
+                {
+                    dto
+                }
+            };
+
+            var request = new GetCaseResultReceiveRequest();
+            request.SetData(datarequest);
+
+            var response = await pusher.PushGetCaseResultReceiveAsync(request, cancellationToken: default);
+
+            return response.ReturnInfo.Description;
+
+            //将上报信息写入本地库
+            // await _getCaseResultReceiveRepository.AddAsync(data);
+            // await _mediator.Publish(new OrderCreatedNotification(new Orders.DataOrder()));
+            //信息上报
+            //await _mediator.Publish(new GetCaseResultReceiveNotification(data));
+            // await _capPublisher.PublishAsync("GetCaseResultReceive", dto, cancellationToken: HttpContext.RequestAborted);
         }
     }
 }

+ 0 - 2
src/Sharing.Province/Controllers/ReceiveController.cs

@@ -564,8 +564,6 @@ namespace Sharing.Province.Controllers
             //添加数据
             var id = await _sendCaseEvlResultRepository.AddAsync(dto, HttpContext.RequestAborted);
 
-            await _capPublisher.PublishAsync("GetCaseResultReceive", dto, cancellationToken: HttpContext.RequestAborted);
-
             //向业务系统推送消息
             // await _capPublisher.PublishAsync(EventNames.HotlineOrderSendCaseEvlResult, dto,cancellationToken: HttpContext.RequestAborted);
             if (!string.IsNullOrEmpty(id))

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

@@ -35,8 +35,8 @@ public class DefaultPusher : IProvincePusher
     /// <param name="request"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    public async Task PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
+    public async Task<ProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
     {
-        var response = await _xieTongClient.RequestAsync<GetCaseResultReceiveRequest, ProvinceResponse>(request, cancellationToken);
+        return await _xieTongClient.RequestAsync<GetCaseResultReceiveRequest, ProvinceResponse>(request, cancellationToken);
     }
 }

+ 15 - 9
src/Sharing.Province/Dtos/ProvinceResponse.cs

@@ -1,14 +1,10 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+namespace Sharing.Province.Dtos;
 
-namespace Sharing.Province.Dtos;
-
-public class ProvinceResponse : Reponse
+public class ProvinceResponse
 {
-    public bool Success => Code == 1;
+    //public bool Success => Code == 1;
+    public BaseProvinceResponse ReturnInfo { get; set; }
+
 
     ///// <summary>
     ///// 接收时间
@@ -16,6 +12,16 @@ public class ProvinceResponse : Reponse
     //public DateTime ReceiveTime { get; set; }
 }
 
+/// <summary>
+/// 省接口返回
+/// </summary>
+public class BaseProvinceResponse
+{
+    public string Code { get; set; }
+
+    public string Description { get; set; }
+}
+
 public class Reponse
 {
     public int Code { get; set; }

+ 4 - 1
src/Sharing.Province/Handlers/GetCaseResultReceiveHandler.cs

@@ -1,7 +1,10 @@
 using MapsterMapper;
 using MediatR;
 using Sharing.Notifications;
+using Sharing.Province.Dtos.HuiJu;
 using Sharing.Province.Dtos.XieTong.Send;
+using Sharing.Province.XieTong.Send;
+using XF.Domain.Exceptions;
 
 namespace Sharing.Province.Handlers
 {
@@ -33,7 +36,7 @@ namespace Sharing.Province.Handlers
         /// <param name="notification"></param>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public async Task Handle(GetCaseResultReceiveNotification notification, CancellationToken cancellationToken)
+        public async Task Handle(GetCaseResultReceiveNotification notification, CancellationToken cancellationToken=default)
         {
             var pusher = _pusherProvider.CreatePusher(_channelConfigurationManager);
 

+ 3 - 2
src/Sharing.Province/IProvincePusher.cs

@@ -1,4 +1,5 @@
-using Sharing.Province.Dtos.HuiJu;
+using Sharing.Province.Dtos;
+using Sharing.Province.Dtos.HuiJu;
 using Sharing.Province.Dtos.XieTong.Send;
 namespace Sharing.Province;
 
@@ -21,5 +22,5 @@ public interface IProvincePusher
     /// <param name="request"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    Task PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken);
+    Task<ProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken);
 }

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

@@ -18,7 +18,7 @@ public class SmartPusher : IProvincePusher
     /// <param name="request"></param>
     /// <param name="cancellationToken"></param>
     /// <returns></returns>
-    public async Task PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
+    public async Task<ProvinceResponse> PushGetCaseResultReceiveAsync(GetCaseResultReceiveRequest request, CancellationToken cancellationToken)
     {
         throw new NotImplementedException();
     }

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

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

+ 0 - 7
src/Sharing/Notifications/OrderCreatedNotification.cs

@@ -1,15 +1,8 @@
 using MediatR;
 using Sharing.Orders;
-using Sharing.Province.XieTong.Receive;
 using Sharing.Province.XieTong.Send;
 
 namespace Sharing.Notifications
 {
     public record OrderCreatedNotification(DataOrder DataOrder) : INotification;
-
-    /// <summary>
-    /// 服务工单交办处理
-    /// </summary>
-    /// <param name="Data"></param>
-    public record GetCaseResultReceiveNotification(SendCaseEvlResult Data) : INotification;
 }