From 1cb5959adf96911101864488a67e8b31b8de658f Mon Sep 17 00:00:00 2001
From: zjh <2207896513@qq.com>
Date: 星期五, 08 八月 2025 15:31:38 +0800
Subject: [PATCH] 产测中箱码、栈板码绑定sn添加日志表记录

---
 StandardPda/MES.Service/service/BasicData/SalesDeliveryNoticeManager.cs |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/StandardPda/MES.Service/service/BasicData/SalesDeliveryNoticeManager.cs b/StandardPda/MES.Service/service/BasicData/SalesDeliveryNoticeManager.cs
index 4d3857e..34d57b6 100644
--- a/StandardPda/MES.Service/service/BasicData/SalesDeliveryNoticeManager.cs
+++ b/StandardPda/MES.Service/service/BasicData/SalesDeliveryNoticeManager.cs
@@ -45,7 +45,7 @@
                 }
             }) > 0;
         }
-    
+
         private bool UpdateData(SqlSugarScope db, SalesDeliveryNotice mesSalesDelivery,
             List<SalesDeliveryNoticeDetail> mesSalesDeliveryDatas)
         {
@@ -89,7 +89,7 @@
             var result = salesOrder.Select(Save).ToList();
             return result.All(b => b);
         }
- 
+
         private SalesDeliveryNotice ConvertErpToSalesDelivery(
             ErpSalesDeliveryDto erpDto)
         {
@@ -135,11 +135,11 @@
                 //PayerParty = erpDto.FPayerID,//浠樻鏂�
                 //CreatedBy = erpDto.FCreatorId, // 鍒涘缓浜�
                 CreatedDate = ParseDateTime(erpDto.FCreateDate) ?? null, // 鍒涘缓鏃堕棿
-                //ModifiedBy = erpDto.FModifierId, // 淇敼浜�
-                //ModifiedDate = ParseDateTime(erpDto.FModifyDate) ?? null, // 淇敼鏃堕棿
-                //ClosedBy = erpDto.FCloserId, // 鍏抽棴浜�
-                //CloseReason = erpDto.FCloseReason, // 鍏抽棴鍘熷洜
-               // CloseDate = ParseDateTime(erpDto.FCloseDate) ?? null, // 鍏抽棴鏃ユ湡
+                                                                         //ModifiedBy = erpDto.FModifierId, // 淇敼浜�
+                                                                         //ModifiedDate = ParseDateTime(erpDto.FModifyDate) ?? null, // 淇敼鏃堕棿
+                                                                         //ClosedBy = erpDto.FCloserId, // 鍏抽棴浜�
+                                                                         //CloseReason = erpDto.FCloseReason, // 鍏抽棴鍘熷洜
+                                                                         // CloseDate = ParseDateTime(erpDto.FCloseDate) ?? null, // 鍏抽棴鏃ユ湡
                 ApprovedBy = erpDto.FApproverId, // 瀹℃牳浜�
                 ApprovedDate = ParseDateTime(erpDto.FApproveDate) ?? null, // 瀹℃牳鏃ユ湡
                 //CancelStatus = erpDto.FCancelStatus, // 浣滃簾鐘舵��
@@ -149,8 +149,8 @@
                 BillStatus = erpDto.FDocumentStatus, //鍗曟嵁鐘舵��
                 DeliveryOrg = erpDto.FDeliveryOrgID, //鍙戣揣缁勭粐
                 //SalesOrg    = erpDto.FSaleOrgId //閿�鍞粍缁�
-                FSourceCategory= erpDto.FSourceCategory,
-                FSourceDocument= erpDto.FSourceDocument,
+                FSourceCategory = erpDto.FSourceCategory,
+                FSourceDocument = erpDto.FSourceDocument,
                 FDeliveryDate = erpDto.FDeliveryDate,
                 FProject = erpDto.FProject,
                 FCustomerPo = erpDto.FCustomerPo,
@@ -159,9 +159,9 @@
                 FDestinationPort = erpDto.FDestinationPort,
                 FReceiverContactID = erpDto.FReceiverContactID,
                 FEntryNote = erpDto.FEntryNote,
-                FVersionNo= erpDto.FVersionNo,
-                FBusinessType= erpDto.FBusinessType,
-                FHEADLOCID= erpDto.FHEADLOCID,
+                FVersionNo = erpDto.FVersionNo,
+                FBusinessType = erpDto.FBusinessType,
+                FHEADLOCID = erpDto.FHEADLOCID,
                 FCustId = erpDto.FCustId,
                 FNote = erpDto.FNote
             };
@@ -169,6 +169,11 @@
             var single = base.GetSingle(it => it.ErpId == erpDto.ErpID);
             if (single != null) salesOrder.Id = single.Id;
 
+            if (salesOrder.ErpId is null || salesOrder.ErpId=="")
+            {
+                throw new NotImplementedException(
+    $"琛ㄥごErpID涓嶈兘涓虹┖");
+            }
             return salesOrder;
         }
 
@@ -229,46 +234,68 @@
                     //SumOutQty = erpDto.FSumOutQty,//绱鍑哄簱鏁伴噺
                     //RemainOutQty = erpDto.FRemainOutQty,//鏈嚭搴撴暟閲�
                     //NOTE = erpDto.FEntrynote//澶囨敞
-                    FDeliveryDate= erpDto.FDeliveryDate,
-                    FMapId= erpDto.FMapId,
+                    FDeliveryDate = erpDto.FDeliveryDate,
+                    FMapId = erpDto.FMapId,
                     FMapName = erpDto.FMapName,
                     FMapId2 = erpDto.FMapId2,
-                    FProject= erpDto.FProject,
+                    FProject = erpDto.FProject,
                     FStorageLocation = erpDto.FStorageLocation,
                     FFreeItemType = erpDto.FFreeItemType,
                     FBodyNote = erpDto.FBodyNote,
                     FAvailableStock = erpDto.FAvailableStock,
                     FInventoryQueryTime = erpDto.FInventoryQueryTime,
-                    FLineStatus= erpDto.FLineStatus,
-                    FReceiveAddressFull= erpDto.FReceiveAddressFull,
-                    FReceiverContact= erpDto.FReceiverContact,
+                    FLineStatus = erpDto.FLineStatus,
+                    FReceiveAddressFull = erpDto.FReceiveAddressFull,
+                    FReceiverContact = erpDto.FReceiverContact,
                     FReturnExchangeAllowed = erpDto.FReturnExchangeAllowed,
                     FOutsourcedProcessQty = erpDto.FOutsourcedProcessQty,
                     FAvailableDate = erpDto.FAvailableDate,
-                    FCommitmentDate= erpDto.FCommitmentDate,
-                    FCustomerConfirmShipDate= erpDto.FCustomerConfirmShipDate,
-                    FPlannedOrg= erpDto.FPlannedOrg,
+                    FCommitmentDate = erpDto.FCommitmentDate,
+                    FCustomerConfirmShipDate = erpDto.FCustomerConfirmShipDate,
+                    FPlannedOrg = erpDto.FPlannedOrg,
                     FVendorDirectShip = erpDto.FVendorDirectShip,
                     FSupplySource = erpDto.FSupplySource,
                     FSupplyType = erpDto.FSupplyType,
-                    FSupplyOrg= erpDto.FSupplyOrg,
-                    FSupplier= erpDto.FSupplier,
-                    FShippingMethod= erpDto.FShippingMethod,
+                    FSupplyOrg = erpDto.FSupplyOrg,
+                    FSupplier = erpDto.FSupplier,
+                    FShippingMethod = erpDto.FShippingMethod,
                     FMRPDR = erpDto.FMRPDR,
                     FDemandCategory = erpDto.FDemandCategory,
                     FInventoryPlanning = erpDto.FInventoryPlanning,
-                    FLineRemark= erpDto.FLineRemark,
+                    FLineRemark = erpDto.FLineRemark,
                     FSourceDocCategory = erpDto.FSourceDocCategory,
-                    FSourceDocNo= erpDto.FSourceDocNo,
+                    FSourceDocNo = erpDto.FSourceDocNo,
                     FSourceDocLineNo = erpDto.FSourceDocLineNo,
                     FLINE_NO = erpDto.FLINE_NO
 
                 };
-
+                if (salesOrderSub.ErpLineId is null || salesOrderSub.ErpLineId=="")
+                {
+                    throw new NotImplementedException(
+    $"鏄庣粏琛孍rpID锛圗RP琛孖D锛変笉鑳戒负绌�");
+                }
+                if (salesOrderSub.ErpHeadId is null || salesOrderSub.ErpHeadId == "")
+                {
+                    throw new NotImplementedException(
+    $"鏄庣粏琛孍HID锛圗RP澶碔D锛変笉鑳戒负绌�");
+                }
                 var single = _SalesDeliveryDetailManager.GetSingle(it =>
                     it.ErpLineId == salesOrderSub.ErpLineId);
                 if (single != null) salesOrderSub.Id = single.Id;
+                var mesLinkU9 = Db.Queryable<MesLinkU9>()
+.Where(x => x.U9Id == erpDto.FMaterialId
+    && x.OrgId == erpDto.FSupplyOrg
+    && x.TableType == "MES_ITEMS").First();
 
+                if (mesLinkU9 != null) salesOrderSub.MaterialId = mesLinkU9.MesId;
+
+
+                var mesLinkU92 = Db.Queryable<MesLinkU9>()
+                    .Where(x => x.U9Id == erpDto.FProject
+                                && x.OrgId == erpDto.FSupplyOrg
+                                && x.TableType == "MES_PROJECT").First();
+
+                if (mesLinkU92 != null) salesOrderSub.FProject = mesLinkU92.MesId;
                 salesOrderSubList.Add(salesOrderSub);
             }
 

--
Gitblit v1.9.3