From 6471c590d3119303bc4b71380c73427231aa35c2 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 18 十二月 2025 17:59:01 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 73308c9..d82af0d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -41,10 +41,12 @@
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
+using WIDESEA_Core.Util;
 using WIDESEA_DTO.Allocate;
 using WIDESEA_DTO.Basic;
 using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Outbound;
+using WIDESEA_DTO.ReturnMES;
 using WIDESEA_DTO.Task;
 using WIDESEA_IAllocateService;
 using WIDESEA_IBasicService;
@@ -56,6 +58,7 @@
 using WIDESEA_Model.Models;
 using WIDESEA_Model.Models.Check;
 using WIDESEA_Model.Models.Outbound;
+using static HslCommunication.Profinet.Knx.KnxCode;
 
 namespace WIDESEA_TaskInfoService
 {
@@ -85,6 +88,7 @@
         private readonly IAllocateService _allocateService;
         private readonly IInvokeMESService _invokeMESService;
         private readonly ITask_HtyService _task_HtyService;
+        private readonly HttpClientHelper _httpClientHelper;
         public IRepository<Dt_Task> Repository => BaseDal;
 
         private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new()
@@ -104,7 +108,7 @@
 
         public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList();
 
-        public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService) : base(BaseDal)
+        public TaskService(IRepository<Dt_Task> BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_StockInfo> stockRepository, ILocationInfoService locationInfoService, IInboundOrderService inboundOrderService, ILocationStatusChangeRecordService locationStatusChangeRecordService, IESSApiService eSSApiService, ILogger<TaskService> logger, IStockService stockService, IRecordService recordService, IInboundOrderDetailService inboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutboundOrderDetailService outboundOrderDetailService, IInvokeMESService invokeMESService, IOutStockLockInfoService outStockLockInfoService, IAllocateService allocateService, IRepository<Dt_OutboundBatch> outboundBatchRepository, IRepository<Dt_ReCheckOrder> reCheckOrderRepository, IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository, IRepository<Dt_AllocateOrder> allocateOrderRepository, IMaterialUnitService materialUnitService, ITask_HtyService task_HtyService, HttpClientHelper httpClientHelper) : base(BaseDal)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -128,6 +132,7 @@
             _allocateOrderRepository = allocateOrderRepository;
             _materialUnitService = materialUnitService;
             _task_HtyService = task_HtyService;
+            _httpClientHelper = httpClientHelper;
         }
 
         public async Task TaskStatusChange(string taskNum, TaskStatusEnum taskStatusEnum)
@@ -455,8 +460,11 @@
                                }).ToList();
                             feedmodel.details = groupedData;
 
-                            var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel);
-                            if (feedbackresult != null && feedbackresult.code == 200)
+                            //var feedbackresult = await _invokeMESService.FeedbackInbound(feedmodel);
+
+                            var response= responseModel(feedmodel, inboundOrder);
+
+                            if (response != null && response.IsSuccess)
                             {
                                 _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 1, Remark = "" })
                                 .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
@@ -465,7 +473,7 @@
                             }
                             else
                             {
-                                _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2, Remark = feedbackresult.message })
+                                _inboundOrderService.Db.Updateable<Dt_InboundOrder>().SetColumns(it => new Dt_InboundOrder { ReturnToMESStatus = 2, Remark = response.ErrorMessage })
                                 .Where(it => it.Id == inboundOrder.Id).ExecuteCommand();
                                 _inboundOrderDetailService.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 2 })
                                .Where(it => it.OrderId == inboundOrder.Id).ExecuteCommand();
@@ -483,6 +491,51 @@
             return WebResponseContent.Instance.OK();
         }
 
+        public HttpResponseResult<MesResponseDTO> responseModel(FeedbackInboundRequestModel model,Dt_InboundOrder order)
+        {
+            HttpResponseResult<MesResponseDTO> httpResponseResult = new HttpResponseResult<MesResponseDTO>();
+            string reqCode = Guid.NewGuid().ToString();
+            string reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            string requestData = string.Empty;
+            //string apiUrl = AppSettings.GetValue("AllocationFeedbackUrl");
+            string apiUrl = "http://127.0.0.1:450/api/AldMaterialWarehousing/MaterialWarehousing";
+            httpResponseResult = _httpClientHelper.Post<MesResponseDTO>(apiUrl, model.Serialize());
+            httpResponseResult.ApiUrl = apiUrl;
+            bool isSuccess = httpResponseResult.IsSuccess && httpResponseResult.Data.Code == "200";
+            string message = "鎴愬姛";
+            if (!isSuccess)
+            {
+                if (!httpResponseResult.IsSuccess)
+                {
+                    message = $"MES鎺ュ彛杩斿洖閿欒锛孒TTP浠g爜锛歿httpResponseResult.StatusCode}锛屼俊鎭細{httpResponseResult.ErrorMessage}";
+                }
+                else if (httpResponseResult?.Data?.Code != "200")
+                {
+                    message = $"璋冪敤MES鎺ュ彛澶辫触锛屼唬鐮侊細{httpResponseResult?.Data?.Code}锛屼俊鎭細{httpResponseResult?.Data?.Message}";
+                }
+            }
+            Dt_MesReturnRecord mesReturnRecord = new Dt_MesReturnRecord()
+            {
+                ApiUrl = httpResponseResult.ApiUrl,
+                InterfaceType = 2,
+                OrderId = order.Id,
+                OrderNo = order.InboundOrderNo,
+                RequestCode = reqCode,
+                RequestData = requestData,
+                FailureReason = message,
+                LastReturnTime = DateTime.Now,
+                HttpStatusCode = httpResponseResult.StatusCode.ObjToInt(),
+                ResponseData = httpResponseResult.Content,
+                ReturnType = 0,
+                ReturnCount = 1,
+                ReturnStatus = httpResponseResult.IsSuccess ? 1 : 2,
+                SuccessTime = httpResponseResult.IsSuccess ? DateTime.Now : null
+            };
+            _unitOfWorkManage.Db.Insertable(mesReturnRecord).ExecuteCommand();
+            
+            return httpResponseResult;
+        }
+
 
         public async Task<WebResponseContent> OutAllocateTaskCompleted(Dt_Task task)
         {

--
Gitblit v1.9.3