From 42429ae61571ff9563c9e987cd52be2132e77775 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期四, 06 十一月 2025 17:13:29 +0800
Subject: [PATCH] 提交出库

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 55 insertions(+), 1 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 358c522..e1afe73 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"
@@ -20,6 +20,7 @@
 using Microsoft.Extensions.Logging;
 using Newtonsoft.Json;
 using Org.BouncyCastle.Asn1.Ocsp;
+using Org.BouncyCastle.Asn1.Pkcs;
 using SqlSugar;
 using System.Reflection;
 using System.Reflection.Emit;
@@ -37,6 +38,7 @@
 using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO.Basic;
+using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Task;
 using WIDESEA_IBasicService;
 using WIDESEA_IInboundService;
@@ -58,10 +60,16 @@
         private readonly ILocationInfoService _locationInfoService;
         private readonly IInboundOrderService _inboundOrderService;
         private readonly IInboundOrderDetailService _inboundOrderDetailService;
+
+        private readonly IOutboundOrderService _outboundOrderService;
+        private readonly IOutboundOrderDetailService _outboundOrderDetailService;
+
         private readonly ILocationStatusChangeRecordService _locationStatusChangeRecordService;
         private readonly IESSApiService _eSSApiService;
         private readonly IStockService _stockService;
         private readonly IRecordService _recordService;
+
+        private readonly IInvokeMESService _invokeMESService;
         public IRepository<Dt_Task> Repository => BaseDal;
 
         private Dictionary<string, SqlSugar.OrderByType> _taskOrderBy = new()
@@ -81,7 +89,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) : 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) : base(BaseDal)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -94,6 +102,9 @@
             _stockService = stockService;
             _recordService = recordService;
             _inboundOrderDetailService = inboundOrderDetailService;
+            _outboundOrderService = outboundOrderService;
+            _outboundOrderDetailService = outboundOrderDetailService;
+            _invokeMESService = invokeMESService;
         }
 
         /// <summary>
@@ -227,7 +238,50 @@
             _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum);
 
             _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, WIDESEA_Common.StockEnum.StockChangeType.MaterielGroup);
+            try
+            {
+                foreach (var inboundOrder in inboundOrders)
+                {
+                    if (inboundOrder != null && inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+                    {
+                        var feedmodel = new FeedbackInboundRequestModel
+                        {
+                            reqCode = Guid.NewGuid().ToString(),
+                            reqTime = DateTime.Now.ToString(),
+                            business_type = inboundOrder.BusinessType,
+                            factoryArea = inboundOrder.FactoryArea,
+                            operationType = 1,
+                            orderNo = inboundOrder.UpperOrderNo,
+                            status = inboundOrder.OrderStatus,
+                            details = new List<FeedbackInboundDetailsModel>()
 
+                        };
+
+                        var groupedData = inboundOrder.Details.GroupBy(item => new { item.MaterielCode, item.SupplyCode, item.BatchNo, item.lineNo, item.BarcodeUnit, item.WarehouseCode})
+                           .Select(group => new FeedbackInboundDetailsModel
+                           {
+                               materialCode = group.Key.MaterielCode,
+                               supplyCode = group.Key.SupplyCode,
+                               batchNo = group.Key.BatchNo,
+                               lineNo = group.Key.lineNo,
+                               warehouseCode = group.Key.WarehouseCode,
+                               unit= group.Key.BarcodeUnit,
+                               barcodes = group.Select(row => new FeedbackBarcodesModel
+                               {
+                                   barcode = row.Barcode,
+                                   qty = row.BarcodeQty
+                               }).ToList()
+                           }).ToList();
+                        feedmodel.details = groupedData;
+
+                        _invokeMESService.FeedbackInbound(feedmodel);
+                    }
+
+                }
+            }
+            catch (Exception ex) {
+                _logger.LogInformation("InboundTaskCompleted 鍥炲啓MES澶辫触:  " + ex.Message);
+            }
 
             return WebResponseContent.Instance.OK();
         }

--
Gitblit v1.9.3