From ef3870bb8d578457b310e58518ca814f3d4f932c Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 26 五月 2025 08:59:17 +0800
Subject: [PATCH] 更新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderService.cs |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 1 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderService.cs"
index 94e8e3b..c700679 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/ProOutOrderService.cs"
@@ -53,7 +53,7 @@
             _invokeERPService = invokeERPService;
         }
         /// <summary>
-        /// 鎺ユ敹ERP鎴愬搧鍑哄簱鍗�
+        /// 鎺ユ敹ERP鎴愬搧鍑哄簱鍗曚俊鎭�(璁㈠崟鍑哄簱/瀵勫敭鍑哄簱)
         /// </summary>
         /// <returns></returns>
         public async Task<WebResponseContent> ProductDeliveryOrder(ErpProOutOrderDTO outOrderDTO)
@@ -201,6 +201,69 @@
             return content;
         }
         /// <summary>
+        /// 閿�鍞寚娲�
+        /// </summary>
+        /// <returns></returns>
+        public async Task<WebResponseContent> ProductSpecifyVer(ErpProductSpecifyVerDTO erpProductSpecifyVerDTO)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==erpProductSpecifyVerDTO.WaType);
+                if (warehouse == null)
+                    return await Task.FromResult(content.Error($"鏈壘鍒皗erpProductSpecifyVerDTO.WaType}浠撳簱淇℃伅"));
+                //鏌ヨ鍙寚娲惧簱瀛�
+                List<Dt_ProStockInfo> proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => x.ProStockAttribute == ProStockAttributeEnum.鎴愬搧.ObjToInt())
+                .Includes(x => x.proStockInfoDetails)
+                .Where(x => x.proStockInfoDetails
+                .Any(v =>
+                     v.SaleOrder == erpProductSpecifyVerDTO.OrderNo
+                    && v.ProductCode == erpProductSpecifyVerDTO.PCode
+                    && v.ProductVersion == erpProductSpecifyVerDTO.PVer
+                    && v.LotNumber == erpProductSpecifyVerDTO.PLot
+                    && v.DateCode == erpProductSpecifyVerDTO.DateCode
+                    && (v.SpecifyVer==null||v.SpecifyVer=="")
+                ))
+                .ToList();
+                List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>();
+                List<Dt_ProStockInfoDetail> specifyVerDetails = new List<Dt_ProStockInfoDetail>();
+                if (proStockInfos==null)
+                    return await Task.FromResult(content.Error("鍙寚娲惧簱瀛樹笉瀛樺湪"));
+                proStockInfos = proStockInfos.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x => x.CreateDate).ThenBy(x => x.proStockInfoDetails.Sum(x => x.StockPcsQty)).ToList();
+                foreach (var item in proStockInfos)
+                {
+                    proStockInfoDetails.AddRange(item.proStockInfoDetails);
+                }
+                if (proStockInfoDetails.Sum(x=>x.StockPcsQty)< erpProductSpecifyVerDTO.QtyPcs)
+                    return await Task.FromResult(content.Error($"鍙寚娲惧簱瀛樻暟閲忎笉瓒�,鍙敤:{proStockInfoDetails.Sum(x => x.StockPcsQty)}"));
+                float overQty = 0;
+                foreach (var item in proStockInfoDetails)
+                {
+                    specifyVerDetails.Add(item);
+                    overQty += item.StockPcsQty;
+                    //宸叉弧瓒宠幏鍙栨暟閲忎笉鍐嶆洿鏀�
+                    if (overQty>= erpProductSpecifyVerDTO.QtyPcs)
+                    {
+                        break;
+                    }
+                }
+                specifyVerDetails.ForEach(x =>
+                {
+                    x.SpecifyVer = erpProductSpecifyVerDTO.Ver;
+                });
+                _unitOfWorkManage.BeginTran();
+                _stockRepository.ProStockInfoDetailRepository.UpdateData(specifyVerDetails);
+                _unitOfWorkManage.CommitTran();
+                content.OK("鎸囨淳鎴愬姛");
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                content.Error(ex.Message);
+            }
+            return await Task.FromResult(content);
+        }
+        /// <summary>
         /// 鎴愬搧鍑哄緟鍙戣揣鍖�(骞冲簱)+鍚屾ERP鍑哄簱(缁戝畾浜嗗嚭搴撳崟搴撳瓨)
         /// </summary>
         /// <returns></returns>

--
Gitblit v1.9.3