From e354b5938f49ac90b237289923dcde923d22daf5 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 20 十一月 2025 09:08:27 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs |   84 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 73 insertions(+), 11 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_OutboundService/OutboundPickingService.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_OutboundService/OutboundPickingService.cs"
index 93f7d84..653f016 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_OutboundService/OutboundPickingService.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_OutboundService/OutboundPickingService.cs"
@@ -17,6 +17,7 @@
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO.Basic;
+using WIDESEA_DTO.Inbound;
 using WIDESEA_DTO.Outbound;
 using WIDESEA_IBasicService;
 using WIDESEA_IOutboundService;
@@ -43,7 +44,7 @@
         private readonly ISplitPackageService _splitPackageService;
         private readonly IRepository<Dt_Task> _taskRepository;
         private readonly IESSApiService _eSSApiService;
-
+        private readonly IInvokeMESService _invokeMESService;
 
         private readonly ILogger<OutboundPickingService> _logger;
 
@@ -61,7 +62,7 @@
 
         };
 
-        public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger) : base(BaseDal)
+        public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger, IInvokeMESService invokeMESService) : base(BaseDal)
         {
             _unitOfWorkManage = unitOfWorkManage;
             _stockInfoService = stockInfoService;
@@ -75,6 +76,7 @@
             _taskRepository = taskRepository;
             _eSSApiService = eSSApiService;
             _logger = logger;
+            _invokeMESService = invokeMESService;
         }
 
 
@@ -276,12 +278,72 @@
 
             if (allCompleted)
             {
-                await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
-                    .SetColumns(x => x.OrderStatus == 2) // 宸插畬鎴�
-                    .Where(x => x.OrderNo == orderNo)
-                    .ExecuteCommandAsync();
+                try
+                {
+                    await _outboundOrderService.Db.Updateable<Dt_OutboundOrder>()
+                        .SetColumns(x => x.OrderStatus == 2) // 宸插畬鎴�
+                        .Where(x => x.OrderNo == orderNo)
+                        .ExecuteCommandAsync();
 
-                //鍥炰紶MES
+                    var outboundOrder = _stockInfoService.Db.Queryable<Dt_OutboundOrder>().First(x => x.OrderNo == orderNo);
+
+
+                    if (outboundOrder != null && outboundOrder.OrderStatus == OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt())
+                    {
+
+                        if (outboundOrder.OrderType == OutOrderTypeEnum.Allocate.ObjToInt().ObjToInt())//璋冩嫧鍑哄簱
+                        {
+
+                        }
+                        else if (outboundOrder.OrderType == OutOrderTypeEnum.ReCheck.ObjToInt()) //閲嶆鍑哄簱
+                        {
+
+                        }
+                        else
+                        {
+                            var feedmodel = new FeedbackOutboundRequestModel
+                            {
+                                reqCode = Guid.NewGuid().ToString(),
+                                reqTime = DateTime.Now.ToString(),
+                                business_type = outboundOrder.BusinessType,
+                                factoryArea = outboundOrder.FactoryArea,
+                                operationType = 1,
+                                Operator = outboundOrder.Operator,
+                                orderNo = outboundOrder.UpperOrderNo,
+                                status = outboundOrder.OrderStatus,
+                                details = new List<FeedbackOutboundDetailsModel>()
+
+                            };
+                            var lists = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>().Where(x => x.OrderNo == orderNo).ToList();
+
+                            var groupedData = lists.GroupBy(item => new { item.MaterielCode, item.lineNo, item.Unit, item.WarehouseCode })
+                               .Select(group => new FeedbackOutboundDetailsModel
+                               {
+                                   materialCode = group.Key.MaterielCode,
+                                   lineNo = group.Key.lineNo,
+                                   warehouseCode = group.Key.WarehouseCode,
+                                   currentDeliveryQty = group.Sum(x => x.OrderQuantity),
+                                   // warehouseCode= "1072",
+                                   unit = group.Key.Unit,
+                                   barcodes = group.Select(row => new WIDESEA_DTO.Outbound.BarcodesModel
+                                   {
+                                       barcode = row.CurrentBarcode,
+                                       supplyCode = row.SupplyCode,
+                                       batchNo = row.BatchNo,
+                                       unit = row.Unit,
+                                       qty = row.AssignQuantity
+                                   }).ToList()
+                               }).ToList();
+                            feedmodel.details = groupedData;
+
+                            _invokeMESService.FeedbackOutbound(feedmodel);
+                        }
+                    }
+                }
+                catch (Exception ex) {
+                    _logger.LogError(" OutboundPickingService  FeedbackOutbound : " + ex.Message);
+                }
+                 
             }
         }
 
@@ -289,7 +351,7 @@
         /// <summary>
         /// 鍥炲簱鎿嶄綔  
         /// </summary>
-       
+
         public async Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason)
         {
             try
@@ -316,7 +378,7 @@
 
                 //  妫�鏌ユ墭鐩樹笂鏄惁鏈夊叾浠栭潪鍑哄簱璐х墿锛堝簱瀛樿揣鐗╋級
                 var palletStockGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
-                    .Where(it => it.StockId == stockinfo.Id &&( it.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt()  || it.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()))
+                    .Where(it => it.StockId == stockinfo.Id && (it.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt() || it.Status == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() || it.Status == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt()))
                     .Where(it => it.OutboundQuantity == 0 || it.OutboundQuantity < it.StockQuantity) // 鏈畬鍏ㄥ嚭搴撶殑
                     .ToListAsync();
 
@@ -327,7 +389,7 @@
                     return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖搴撶殑鍓╀綑璐х墿");
                 }
 
-           
+
                 var firstlocation = _locationInfoService.Db.Queryable<Dt_LocationInfo>().First(x => x.LocationCode == task.SourceAddress);
                 decimal totalReturnQty = 0;
                 var hasRemainingLocks = remainingLocks.Any(x => x.PalletCode == palletCode);
@@ -419,7 +481,7 @@
                     totalReturnQty = palletStockGoods.Sum(x => x.StockQuantity - x.OutboundQuantity);
                 }
 
-                // 淇濆瓨浠诲姟
+                // 淇濆瓨浠诲姟 缁橢SS涓嬪彂浠诲姟
                 if (tasks.Any())
                 {
                     try

--
Gitblit v1.9.3