tangjiang 10 månader sedan
förälder
incheckning
5cf3a89140

+ 34 - 5
src/DataSharing.Host/Controllers/HotlineWebController.cs

@@ -11,20 +11,25 @@ using DataSharing.SendTask;
 using DataSharing.SendTask.OtherPlatforms;
 using DataSharing.Share.Consts;
 using DataSharing.Share.Dtos.Common;
+using DataSharing.Share.Dtos.FwDataExchange;
 using DataSharing.Share.Dtos.HotlineSetting;
 using DataSharing.Share.Dtos.HotlineWeb;
 using DataSharing.Share.Enums;
 using DataSharing.Share.Requests;
 using DotNetCore.CAP;
+using Google.Protobuf.WellKnownTypes;
 using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.Order;
 using MapsterMapper;
 using MediatR;
 using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http.HttpResults;
 using Microsoft.AspNetCore.Mvc;
 using Org.BouncyCastle.Utilities;
 using Polly.Caching;
 using SqlSugar;
+using System.Security.Policy;
 using XF.Domain.Cache;
 using XF.Domain.Exceptions;
 using XF.Domain.Repository;
@@ -67,6 +72,7 @@ namespace DataSharing.Host.Controllers
         private readonly IRepository<DsOrder> _dsOrderRepository;
         private readonly IRepository<SendHotlineErrorData> _sendHotlineErrorDataRepository;
         private readonly FwClient _fwClient;
+        private readonly ISharingConfigurationManager _sharingConfigurationManager;
 
         /// <summary>
         /// 
@@ -101,6 +107,7 @@ namespace DataSharing.Host.Controllers
         /// <param name="dsOrderRepository"></param>
         /// <param name="sendHotlineErrorDataRepository"></param>
         /// <param name="fwClient"></param>
+        /// <param name="sharingConfigurationManager"></param>
         public HotlineWebController(IMapper mapper,
             IMediator mediator,
             ICapPublisher capPublisher,
@@ -130,7 +137,8 @@ namespace DataSharing.Host.Controllers
            IRepository<DsSendTaskInfo> taskInfoRepository,
            IRepository<DsOrder> dsOrderRepository,
            IRepository<SendHotlineErrorData> sendHotlineErrorDataRepository,
-           FwClient fwClient)
+           FwClient fwClient,
+           ISharingConfigurationManager sharingConfigurationManager)
         {
             _mapper = mapper;
             _mediator = mediator;
@@ -162,6 +170,7 @@ namespace DataSharing.Host.Controllers
             _dsOrderRepository = dsOrderRepository;
             _sendHotlineErrorDataRepository = sendHotlineErrorDataRepository;
             _fwClient = fwClient;
+            _sharingConfigurationManager = sharingConfigurationManager;
         }
         #endregion
 
@@ -1345,11 +1354,31 @@ namespace DataSharing.Host.Controllers
             //调用工单创建接口
             try
             {
-                var result = await _fwClient.RequestNoTokenAsync<HotlineClientResponse>(data.Path, data.HttpMethod, data.RequestData);
-                if (result == null || result.code != 0)
+                //推业务系统
+                if (data.ReceiveServiceInterface == "rest/receive_case_info")
                 {
-                    isSuccess = false;
-                    error = result?.message;
+                    var result = await _fwClient.RequestNoTokenAsync<HotlineClientResponse>(data.Path, data.HttpMethod, data.RequestData);
+                    if (result == null || result.code != 0)
+                    {
+                        isSuccess = false;
+                        error = result?.message;
+                    }
+                }
+                //推旧系统
+                if (data.ReceiveServiceInterface == "SendOldHotlineData")
+                {
+                    var configSendDataOld = _sharingConfigurationManager.GetYiBinConfig().SendDataOld;
+                    //先验证是否开启推送
+                    if (configSendDataOld == null || !configSendDataOld.IsSend)
+                        return;
+
+                    var url = configSendDataOld.AddressUrl + data.Path;
+                    var response = await _fwClient.RequestAsync<FwResponse>(url, data.HttpMethod, data.RequestData, HttpContext.RequestAborted);
+                    if (response == null || response.code != 0)
+                    {
+                        isSuccess = false;
+                        error = response?.msg;
+                    }
                 }
             }
             catch (Exception ex)

+ 39 - 12
src/DataSharing.Host/Controllers/ProvinceController.cs

@@ -226,19 +226,19 @@ namespace DataSharing.Host.Controllers
                 }
 
                 //推送失败添加
-               if (!isSuccess)
+                if (!isSuccess)
                 {
                     SendHotlineErrorData errorData = new SendHotlineErrorData()
                     {
-                        DataId=id,
-                        PlatformSource= EPlatformSource.Province,
+                        DataId = id,
+                        PlatformSource = EPlatformSource.Province,
                         ReceiveServiceInterface = "rest/receive_case_info",
-                        RawData= System.Text.Json.JsonSerializer.Serialize(dto),
-                        RequestData= System.Text.Json.JsonSerializer.Serialize(data),
+                        RawData = System.Text.Json.JsonSerializer.Serialize(dto),
+                        RequestData = System.Text.Json.JsonSerializer.Serialize(data),
                         Path = "api/v1/Order/add-anonymous",
                         SendTimes = 0,
-                        HttpMethod= "Post",
-                        ErrorMessage=error
+                        HttpMethod = "Post",
+                        ErrorMessage = error
                     };
                     await _sendHotlineErrorDataRepository.AddAsync(errorData, HttpContext.RequestAborted);
                 }
@@ -1184,23 +1184,50 @@ namespace DataSharing.Host.Controllers
                 return false;
 
             //查询是否是本地工单,如果是本地工单不需要推送,如果是旧系统数据则推送
-
+            bool isResult = false;
+            string error = "";
             var isCheck = await _dsReceiveProvinceDataRepository.AnyAsync(p => p.CaseSerial == CaseSerial && p.ServiceInterface == "receive_case_info", HttpContext.RequestAborted);
             if (!isCheck)
             {
                 var url = configSendDataOld.AddressUrl + api;
-                var response = await _fwClient.RequestAsync<FwResponse>(url, httpMethod, jsonData, HttpContext.RequestAborted);
-                if (response != null && response.code != 1)
+                try
                 {
+                    var response = await _fwClient.RequestAsync<FwResponse>(url, httpMethod, jsonData, HttpContext.RequestAborted);
+                    if (response != null && response.code == 0)
+                    {
+                        isResult = true;
+                        return true;
+                    }
+                }
+                catch (Exception ex)
+                {
+                    error = ex.Message;
+                }
+                if (!isResult)
+                {
+                    //写入推送失败表
                     SendFwErrorData sendFwError = new()
                     {
                         HttpMethod = httpMethod,
                         ServiceInterface = url,
                         SendData = jsonData
                     };
-                    await _sendFwErrorDataRepository.AddAsync(sendFwError, HttpContext.RequestAborted);
+                    var id = await _sendFwErrorDataRepository.AddAsync(sendFwError, HttpContext.RequestAborted);
+
+                    SendHotlineErrorData errorData = new SendHotlineErrorData()
+                    {
+                        DataId = id,
+                        PlatformSource = EPlatformSource.Province,
+                        ReceiveServiceInterface = "SendOldHotlineData",
+                        RawData = jsonData,
+                        RequestData = jsonData,
+                        Path = api,
+                        SendTimes = 0,
+                        HttpMethod = "Post",
+                        ErrorMessage = error
+                    };
+                    await _sendHotlineErrorDataRepository.AddAsync(errorData, HttpContext.RequestAborted);
                 }
-                return true;
             }
             return false;
         }