From 77198a2c5f246696198277b82821cdc69c588d1e Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期四, 16 一月 2025 10:16:02 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs |   79 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 76 insertions(+), 3 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
index 672b088..bcf23c8 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs"
@@ -513,7 +513,7 @@
                     return WebResponseContent.Instance.Error($"鏈壘鍒拌鐗╂枡鐨勪俊鎭�");
                 }
 
-                List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode).ToList();
+                List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCode && x.BatchNo==(models.FirstOrDefault()?.LotNo ?? "")).ToList();
 
                 if (inboundOrderDetails == null || inboundOrderDetails.Count <= 0)
                 {
@@ -766,9 +766,10 @@
             return content;
         }
         /// <summary>
-        /// 鍏ュ簱瀹屾垚涓婃姤ERP
+        /// 鍏ュ簱瀹屾垚涓婃姤ERP 寮冪敤
         /// </summary>
         /// <returns></returns>
+        #region 寮冪敤
         public WebResponseContent FeedbackInboundOrder(Dt_StockInfo stockInfo, Dt_InboundOrder inboundOrder, List<ERPInboundDetailModel> detailModels)
         {
             WebResponseContent content = new WebResponseContent();
@@ -812,7 +813,79 @@
             }
             return content;
         }
-
+        #endregion
+        /// <summary>
+        /// 鍏ュ簱瀹屾垚涓婃姤ERP
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent FeedbackInboundOrder(Dt_InboundOrder inboundOrder, List<Dt_StockInfoDetail> stockInfoDetails)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                if (inboundOrder.Details.Count == 0)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒板叆搴撳崟鏄庣粏淇℃伅");
+                }
+                if (stockInfoDetails.Count==0)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒板簱瀛樻槑缁嗕俊鎭�");
+                }
+                Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == inboundOrder.WarehouseId);
+                if (warehouse == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒颁粨搴撲俊鎭�");
+                }
+                List<ERPInboundDetailModel>? detailModels = null;
+                foreach (var item in stockInfoDetails)
+                {
+                    Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.Id == item.StockId);
+                    if (detailModels!=null && detailModels.FirstOrDefault(x=>x.Rack==stockInfo.LocationCode)!=null)
+                    {
+                        var detailModel = detailModels.FirstOrDefault(x => x.Rack == stockInfo.LocationCode);
+                        detailModel.Quantity = (Convert.ToDouble(detailModel.Quantity) + item.StockQuantity).ToString();
+                    }
+                    else
+                    {
+                        ERPInboundDetailModel detailModel = new ERPInboundDetailModel()
+                        {
+                            ExpiryDate = item.EffectiveDate ?? "",
+                            LocationCode = warehouse.WarehouseCode,
+                            MaterialsCode = item.MaterielCode,
+                            MfgDate = item.ProductionDate ?? "",
+                            QtyCustoms = "0",
+                            Quantity = item.StockQuantity.ToString(),
+                            Rack = stockInfo.LocationCode,
+                            ReceiptCode = inboundOrder.UpperOrderNo,
+                            ReceiptSerNo = item.InboundOrderRowNo.ToString()
+                        };
+                        detailModels.Add(detailModel);
+                    }
+                }
+                ERPInboundModel model = new ERPInboundModel()
+                {
+                    Code = CreateCodeByRule(nameof(RuleCodeEnum.RLCodeRule)),
+                    CreatorCode = inboundOrder.Creater,//娴嬭瘯
+                    EntDate = inboundOrder.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"),
+                    StockDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                    SuppliersId = inboundOrder.SupplierId,
+                    Type = "S",
+                    UniqueTag = inboundOrder.Id.ToString(),
+                    WarehouseCode = warehouse.WarehouseCode,
+                    Way = 1,
+                    Details = detailModels
+                };
+                //鎺ㄩ�丒RP 娴嬭瘯娉ㄩ噴
+                _invokeERPService.InvokeInboundOrderApi(model);
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                content.Error(ex.Message);
+            }
+            return content;
+        }
         static object lock_code = new object();
         public string CreateCodeByRule(string ruleCode)
         {

--
Gitblit v1.9.3