From 4a8f16f0d07d67098e538c6a03bdc979b04af9bc Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期一, 15 九月 2025 16:16:10 +0800
Subject: [PATCH] 1111

---
 MES.Service/service/BasicData/MesRohInManager.cs |  105 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 83 insertions(+), 22 deletions(-)

diff --git a/MES.Service/service/BasicData/MesRohInManager.cs b/MES.Service/service/BasicData/MesRohInManager.cs
index c1be11a..043fab3 100644
--- a/MES.Service/service/BasicData/MesRohInManager.cs
+++ b/MES.Service/service/BasicData/MesRohInManager.cs
@@ -104,10 +104,12 @@
         // 1. 澶勭悊 fDate锛堥噰璐棩鏈燂級
         if (!rohIn.FDate.IsNullOrEmpty())
         {
-            if (!DateTime.TryParseExact(rohIn.FDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+            if (!DateTime.TryParseExact(rohIn.FDate, "yyyy-MM-d H:m:s",
+                    CultureInfo.InvariantCulture,
                     DateTimeStyles.None, out DateTime purchaseDate))
             {
-                throw new FormatException($"閲囪喘鏃ユ湡锛團Date锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
+                throw new FormatException(
+                    $"閲囪喘鏃ユ湡锛團Date锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
             }
 
             mesRohIn.PurchaseDate = purchaseDate;
@@ -118,13 +120,46 @@
         }
 
 
-        mesRohIn.Supplier = rohIn.FSupplierId;
+        var mesSupplier = Db.Queryable<MesSupplier>()
+            .Where(s => s.SuppNo == rohIn.FSupplierId)
+            .First();
+
+        if (mesSupplier != null)
+        {
+            mesRohIn.Supplier = mesSupplier.Id.ToString();
+        }
+
+        // SETTLEMENT_PARTY -> MesSupplier.id
+        if (!string.IsNullOrEmpty(rohIn.FSettleId))
+        {
+            var settlementSupplier = Db.Queryable<MesSupplier>()
+                .Where(s => s.SuppNo == rohIn.FSettleId)
+                .Select(s => s.Id)
+                .First();
+            if (settlementSupplier != null)
+            {
+                mesRohIn.SettlementParty = settlementSupplier.ToString();
+            }
+        }
+
+        // PURCHASE_DEPT -> SYS_DEPARTMENT.DEPARTMENTID
+        if (!string.IsNullOrEmpty(rohIn.FPurchaseDeptId))
+        {
+            var department = Db.Queryable<SysDepartment>()
+                .Where(d => d.Departmentcode == rohIn.FPurchaseDeptId)
+                .Select(d => d.Id)
+                .First();
+            if (department != null)
+            {
+                mesRohIn.PurchaseDept = department.ToString();
+            }
+        }
+
         mesRohIn.CloseStatus = rohIn.FCloseStatus;
-        mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId;
-        mesRohIn.PurchaseDept = rohIn.FPurchaseDeptId;
+        // mesRohIn.PurchaseOrg = rohIn.FPurchaseOrgId;
+        mesRohIn.PurchaseOrg = "1";
         mesRohIn.PurchaseGroup = rohIn.FPurchaserGroupId;
         mesRohIn.Purchaser = rohIn.FPurchaserId;
-        mesRohIn.SettlementParty = rohIn.FSettleId;
         mesRohIn.PaymentParty = rohIn.FChargeId;
         mesRohIn.Email = rohIn.FProviderEMail;
         mesRohIn.Remarks = rohIn.Remarks;
@@ -147,12 +182,15 @@
             ? DateTime.ParseExact(rohIn.Prearrivaldate,
                 "yyyy-MM-d H:m:s", null)
             : null;*/
-        if (!rohIn.FCancelDate.IsNullOrEmpty() && !mesRohIn.CancellationPerson.IsNullOrEmpty())
+        if (!rohIn.FCancelDate.IsNullOrEmpty() &&
+            !mesRohIn.CancellationPerson.IsNullOrEmpty())
         {
-            if (!DateTime.TryParseExact(rohIn.FCancelDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+            if (!DateTime.TryParseExact(rohIn.FCancelDate, "yyyy-MM-d H:m:s",
+                    CultureInfo.InvariantCulture,
                     DateTimeStyles.None, out DateTime cancelDate))
             {
-                throw new FormatException($"鍙栨秷鏃ユ湡锛團CancelDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCancelDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
+                throw new FormatException(
+                    $"鍙栨秷鏃ユ湡锛團CancelDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCancelDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
             }
 
             mesRohIn.CancellationDate = cancelDate;
@@ -165,10 +203,12 @@
         // 3. 澶勭悊 fCreateDate锛堝垱寤烘棩鏈燂級
         if (!rohIn.FCreateDate.IsNullOrEmpty())
         {
-            if (!DateTime.TryParseExact(rohIn.FCreateDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+            if (!DateTime.TryParseExact(rohIn.FCreateDate, "yyyy-MM-d H:m:s",
+                    CultureInfo.InvariantCulture,
                     DateTimeStyles.None, out DateTime createDate))
             {
-                throw new FormatException($"鍒涘缓鏃ユ湡锛團CreateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCreateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
+                throw new FormatException(
+                    $"鍒涘缓鏃ユ湡锛團CreateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FCreateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
             }
 
             mesRohIn.CreateDate = createDate;
@@ -181,10 +221,12 @@
         // 4. 澶勭悊 fModifyDate锛堜慨鏀规棩鏈燂級
         if (!rohIn.FModifyDate.IsNullOrEmpty())
         {
-            if (!DateTime.TryParseExact(rohIn.FModifyDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+            if (!DateTime.TryParseExact(rohIn.FModifyDate, "yyyy-MM-d H:m:s",
+                    CultureInfo.InvariantCulture,
                     DateTimeStyles.None, out DateTime modifyDate))
             {
-                throw new FormatException($"淇敼鏃ユ湡锛團ModifyDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FModifyDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
+                throw new FormatException(
+                    $"淇敼鏃ユ湡锛團ModifyDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵rohIn.FModifyDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
             }
 
             mesRohIn.LastupdateDate = modifyDate;
@@ -198,7 +240,8 @@
         // 6. 澶勭悊 prearrivaldate锛堥璁″埌璐ф棩鏈燂級
         if (!rohIn.Prearrivaldate.IsNullOrEmpty())
         {
-            if (!DateTime.TryParseExact(rohIn.Prearrivaldate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+            if (!DateTime.TryParseExact(rohIn.Prearrivaldate, "yyyy-MM-d H:m:s",
+                    CultureInfo.InvariantCulture,
                     DateTimeStyles.None, out DateTime preArrivalDate))
             {
                 throw new FormatException(
@@ -261,7 +304,8 @@
                     */
                 // 1. 澶勭悊 fDeliveryDate锛堜氦璐ф棩鏈燂級
                 DeliveryDate = !s.FDeliveryDate.IsNullOrEmpty()
-                    ? (DateTime.TryParseExact(s.FDeliveryDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+                    ? (DateTime.TryParseExact(s.FDeliveryDate,
+                        "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                         DateTimeStyles.None, out DateTime deliveryDate)
                         ? deliveryDate
                         : throw new FormatException(
@@ -270,7 +314,8 @@
 
                 // 2. 澶勭悊 fDeliveryEarlyDate锛堟渶鏃╀氦璐ф棩鏈燂級
                 EarliestDeliveryDate = !s.FDeliveryEarlyDate.IsNullOrEmpty()
-                    ? (DateTime.TryParseExact(s.FDeliveryEarlyDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+                    ? (DateTime.TryParseExact(s.FDeliveryEarlyDate,
+                        "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                         DateTimeStyles.None, out DateTime earlyDate)
                         ? earlyDate
                         : throw new FormatException(
@@ -279,7 +324,8 @@
 
                 // 3. 澶勭悊 fDeliveryLastDate锛堟渶鏅氫氦璐ф棩鏈燂級
                 LatestDeliveryDate = !s.FDeliveryLastDate.IsNullOrEmpty()
-                    ? (DateTime.TryParseExact(s.FDeliveryLastDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+                    ? (DateTime.TryParseExact(s.FDeliveryLastDate,
+                        "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
                         DateTimeStyles.None, out DateTime lastDate)
                         ? lastDate
                         : throw new FormatException(
@@ -341,10 +387,12 @@
 // 4. 澶勭悊 fFreezeDate锛堝喕缁撴棩鏈燂級
             if (!s.FFreezeDate.IsNullOrEmpty() && !s.FFreezerId.IsNullOrEmpty())
             {
-                if (!DateTime.TryParseExact(s.FFreezeDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+                if (!DateTime.TryParseExact(s.FFreezeDate, "yyyy-MM-d H:m:s",
+                        CultureInfo.InvariantCulture,
                         DateTimeStyles.None, out DateTime freezeTime))
                 {
-                    throw new FormatException($"鍐荤粨鏃ユ湡锛團FreezeDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FFreezeDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
+                    throw new FormatException(
+                        $"鍐荤粨鏃ユ湡锛團FreezeDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FFreezeDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
                 }
 
                 entity.FreezeTime = freezeTime;
@@ -355,12 +403,15 @@
             }
 
             // 5. 澶勭悊 fTerminateDate锛堢粓姝㈡棩鏈燂級
-            if (!s.FTerminateDate.IsNullOrEmpty() && !s.FTerminaterId.IsNullOrEmpty())
+            if (!s.FTerminateDate.IsNullOrEmpty() &&
+                !s.FTerminaterId.IsNullOrEmpty())
             {
-                if (!DateTime.TryParseExact(s.FTerminateDate, "yyyy-MM-d H:m:s", CultureInfo.InvariantCulture,
+                if (!DateTime.TryParseExact(s.FTerminateDate, "yyyy-MM-d H:m:s",
+                        CultureInfo.InvariantCulture,
                         DateTimeStyles.None, out DateTime terminateTime))
                 {
-                    throw new FormatException($"缁堟鏃ユ湡锛團TerminateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FTerminateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
+                    throw new FormatException(
+                        $"缁堟鏃ユ湡锛團TerminateDate锛夎В鏋愬け璐ワ紒鍊硷細銆恵s.FTerminateDate}銆戯紝鏀寔鏍煎紡锛歽yyy-MM-d H:m:s");
                 }
 
                 entity.TerminateTime = terminateTime;
@@ -370,6 +421,16 @@
                 entity.TerminateTime = null;
             }
 
+            //ItemId
+            var mesItems = Db.Queryable<MesItems>()
+                .Where(s => s.ItemNo == entity.ItemId)
+                .First();
+
+            if (mesItems != null)
+            {
+                entity.ItemId = mesItems.Id.ToString();
+            }
+
             var single = rohInDataManager.GetSingle(it =>
                 it.EbelnK3id == entity.EbelnK3id);
             if (single != null) entity.Guid = single.Guid;

--
Gitblit v1.9.3