From 7ce2de3024356ebb38f6f939d473fac1307c8c2b Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期二, 27 一月 2026 19:05:00 +0800
Subject: [PATCH] 1

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs |  129 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 122 insertions(+), 7 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/OutboundService.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/OutboundService.cs"
index 13dbfe3..9ec56f5 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/OutboundService.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/OutboundService.cs"
@@ -22,12 +22,14 @@
 using WIDESEA_DTO.Base;
 using WIDESEA_DTO.Basic;
 using WIDESEA_DTO.CalcOut;
+using WIDESEA_DTO.Outbound;
 using WIDESEA_DTO.ReturnMES;
 using WIDESEA_IBasicService;
 using WIDESEA_IOutboundService;
 using WIDESEA_IRecordService;
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Check;
 using static HslCommunication.Profinet.Knx.KnxCode;
 
 namespace WIDESEA_OutboundService
@@ -61,6 +63,8 @@
         private readonly IESSApiService _eSSApiService;
         private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
         private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository;
+        public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
+        public readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
 
         private Dictionary<string, string> stations = new Dictionary<string, string>
         {
@@ -74,7 +78,7 @@
             {"3-1","3-5" },
         };
 
-        public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository)
+        public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository)
         {
             _mapper = mapper;
             _unitOfWorkManage = unitOfWorkManage;
@@ -97,6 +101,35 @@
             _eSSApiService = eSSApiService;
             _allocateOrderRepository = allocateOrderRepository;
             _allocateMaterialInfoRepository = allocateMaterialInfoRepository;
+            _inboundOrderDetailRepository = inboundOrderDetailRepository;
+            _inboundOrderRepository = inboundOrderRepository;
+        }
+
+        public WebResponseContent PrintFromData (string barcode)
+        {
+            var detail = _inboundOrderDetailRepository.QueryFirst(x => x.Barcode == barcode);
+            if(detail == null)
+            {
+                return WebResponseContent.Instance.Error();
+            }
+
+            var inbound = _inboundOrderRepository.QueryFirst(x=>x.Id ==  detail.OrderId);
+            if(inbound == null)
+            {
+                return WebResponseContent.Instance.Error();
+            }
+            var printFormData = new PrintFromDataDTO { 
+                materialCode = detail.Barcode,
+                materialName = detail.MaterielName,
+                materialSpec = detail.Unit,
+                batchNo = detail.BatchNo,
+                pruchaseOrderNo = inbound.UpperOrderNo,
+                factoryArea = inbound.FactoryArea,
+                suplierCode = inbound.SupplierId,
+                quantity = detail.BarcodeQty
+            };
+
+            return WebResponseContent.Instance.OK(data:printFormData);
         }
 
         #region 鍑哄簱鍒嗛厤
@@ -176,7 +209,7 @@
                     foreach (var detail in materielCalc.Details)
                     {
                         if (remainingToLock <= 0) break;
-                        decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity - detail.LockQuantity;
+                        decimal maxLockableQty = detail.OrderQuantity - detail.OverOutQuantity;
                         if (maxLockableQty <= 0) continue;
                         decimal currentLockQty = Math.Min(remainingToLock, maxLockableQty);
                         detail.LockQuantity += currentLockQty;
@@ -208,6 +241,11 @@
                 string responseMsg = totalActualAllocate == totalNeedAllocate
                     ? "鍒嗘嫞浠诲姟鍒嗛厤鎴愬姛"
                     : $"鍒嗘嫞浠诲姟鍒嗛厤瀹屾垚锛堝疄闄呭垎閰峽totalActualAllocate}锛岄渶姹倇totalNeedAllocate}锛屽簱瀛樹笉瓒抽儴鍒嗘湭鍒嗛厤锛�";
+                if(totalActualAllocate == 0)
+                {
+                    UpdateOutboundOrderStatus(request.OrderNo, (int)OutOrderStatusEnum.鏈紑濮�);
+                    return WebResponseContent.Instance.Error("鍒嗛厤搴撳瓨鏁伴噺涓�0锛屾棤娉曞嚭搴�");
+                }
                 response.Success = true;
                 response.Message = responseMsg;
                 response.Tasks = tasks;
@@ -490,7 +528,7 @@
                 x => request.StockDetailIds.Contains(x.Id)
                 && x.MaterielCode == materielCalc.MaterielCode
                 && x.StockQuantity > 0
-                && (x.Status == (int)StockStatusEmun.鍏ュ簱瀹屾垚 || x.Status == (int)StockStatusEmun.鎵嬪姩鍐荤粨)|| x.Status == (int)StockStatusEmun.鎵嬪姩瑙i攣);
+                && (x.Status == (int)StockStatusEmun.鍏ュ簱瀹屾垚 || x.Status == (int)StockStatusEmun.鎵嬪姩鍐荤粨 || x.Status == (int)StockStatusEmun.鎵嬪姩瑙i攣 || x.Status == (int)StockStatusEmun.杩囨湡));
 
             if (!specifiedStockDetails.Any())
             {
@@ -599,7 +637,7 @@
 
             List<int> stockIds = stockDetailList.GroupBy(x => x.StockId).Select(x => x.Key).ToList();
             List<Dt_StockInfo> stockInfos = _stockInfoRepository.QueryData(x =>
-                stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() || x.StockStatus == StockStatusEmun.鍑哄簱閿佸畾.ObjToInt())
+                stockIds.Contains(x.Id) && (x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
                 && !string.IsNullOrEmpty(x.LocationCode) && locationCodes.Contains(x.LocationCode));
 
             foreach (var stockInfo in stockInfos)
@@ -767,6 +805,10 @@
                 Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo);
                 if (outboundOrder == null) return false;
                 outboundOrder.OrderStatus = status;
+                if(outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt())
+                {
+                    outboundOrder.ReturnToMESStatus = 5;
+                }
                 _outboundRepository.UpdateData(outboundOrder);
                 return true;
             }
@@ -1108,8 +1150,15 @@
                         {
                             barcodeQuantity = item.LockQuantity - item.OverOutQuantity;
                             allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity);
+                            if(item.ReturnToMESStatus == 0)
+                            {
+                                item.CurrentDeliveryQty = item.LockQuantity;
+                            }
+                            else
+                            {
+                                item.CurrentDeliveryQty = item.LockQuantity - item.OverOutQuantity;
+                            }
                             item.OverOutQuantity = item.LockQuantity;
-                            item.CurrentDeliveryQty = item.LockQuantity;
                         }
 
                         updateDetails.Add(item);
@@ -1571,12 +1620,11 @@
                     {
                         UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
 
-                        if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+                        if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt() && outboundOrder.CreateType!=OrderCreateTypeEnum.CreateInSystem.ObjToInt())
                         {
                             _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
                         }
                     }
-
                 }
                 catch (Exception ex)
                 {
@@ -1926,6 +1974,12 @@
             {
                 var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
 
+                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == palletCode);
+                if (task != null)
+                {
+                    return WebResponseContent.Instance.Error("浠诲姟淇℃伅鍒楄〃瀛樺湪璇ユ墭鐩樼殑浠诲姟淇℃伅锛屼笉鍙彇璧扮┖绠憋紝璇锋鏌ヤ换鍔℃槸鍚﹀畬鎴�");
+                }
+
                 if (stock == null)
                 {
                     return content.Error($"鏈壘鍒版墭鐩榹palletCode}搴撳瓨淇℃伅");
@@ -2032,6 +2086,67 @@
             }
         }
 
+        public WebResponseContent RecheckPicking(RecheckPickingDTO pickingDTO)
+        {
+            try
+            {
+                Dt_ReCheckOrder reCheckOrder = _outboundRepository.Db.Queryable<Dt_ReCheckOrder>().Where(x => x.OrderNo == pickingDTO.orderNo && x.Result == 0).First();
+                if(reCheckOrder == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒拌寰呴噸鎷g殑鍗曟嵁{pickingDTO.orderNo}");
+                }
+                Dt_StockInfoDetail stockInfoDetail = _stockDetailRepository.QueryFirst(x=>x.Barcode == pickingDTO.barCode && x.Status == StockStatusEmun.鎵嬪姩鍐荤粨.ObjToInt() );
+                if(stockInfoDetail == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈湪搴撳瓨涓壘鍒拌鍐荤粨/闅旂鏉$爜 {pickingDTO.barCode}");
+                }
+                if (stockInfoDetail.MaterielCode != reCheckOrder.MaterielCode || stockInfoDetail.BatchNo != reCheckOrder.BatchNo)
+                {
+                    return WebResponseContent.Instance.Error("璇ユ潯鐮佺殑鐗╂枡缂栫爜鍜屾壒娆″拰璇ラ噸妫�鍗曚笉绗�");
+                }
+                stockInfoDetail.OrderNo = pickingDTO.orderNo;
+                stockInfoDetail.Status = StockStatusEmun.閲嶆涓�.ObjToInt();
+                var currentRemark = _outboundRepository.Db.Queryable<Dt_OutboundOrder>()
+                .Where(x => x.OrderNo == pickingDTO.orderNo)
+                .Select(x => x.Remark)
+                .First();
+
+                string newRemark;
+                if (string.IsNullOrWhiteSpace(currentRemark))
+                {
+                    newRemark = pickingDTO.barCode;
+                }
+                else
+                {
+                    var existingCodes = currentRemark.Split(',', StringSplitOptions.RemoveEmptyEntries)
+                        .Select(s => s.Trim())
+                        .ToList();
+
+                    if (!existingCodes.Contains(pickingDTO.barCode))
+                    {
+                        existingCodes.Add(pickingDTO.barCode);
+                        newRemark = string.Join(",", existingCodes);
+                    }
+                    else
+                    {
+                        newRemark = currentRemark;
+                    }
+                }
+                _outboundRepository.Db.Updateable<Dt_OutboundOrder>()
+                    .SetColumns(x => x.Remark == newRemark)
+                    .SetColumns(x=>x.OrderStatus == (int)OutOrderStatusEnum.鍑哄簱瀹屾垚)
+                    .Where(x => x.OrderNo == pickingDTO.orderNo)
+                    .ExecuteCommand();
+                _stockDetailRepository.UpdateData(stockInfoDetail);
+
+                return WebResponseContent.Instance.OK();
+            }
+            catch(Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+
         #endregion
     }
 }

--
Gitblit v1.9.3