From 5f3963706bf5e87556aa467834d2ca49b274e638 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期四, 31 十月 2024 12:18:55 +0800
Subject: [PATCH] 采购订单更新

---
 MES.Service/service/BasicData/MesRohInManager.cs |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/MES.Service/service/BasicData/MesRohInManager.cs b/MES.Service/service/BasicData/MesRohInManager.cs
index 6509483..b8853e7 100644
--- a/MES.Service/service/BasicData/MesRohInManager.cs
+++ b/MES.Service/service/BasicData/MesRohInManager.cs
@@ -37,15 +37,15 @@
     private bool UpdateData(SqlSugarScope db, MesRohIn mesRohIn,
         List<MesRohInData> mesRohInDatas)
     {
-        var decimals = mesRohInDatas.Select(s => s.Id).ToArray();
+        var decimals = mesRohInDatas.Select(s => s.Guid).ToArray();
 
         var update = db.Deleteable<MesRohIn>()
-            .Where(a => a.Id == mesRohIn.Id)
+            .Where(a => a.Guid == mesRohIn.Guid)
             .ExecuteCommand() > 0;
 
         var insertOrUpdate = db
             .Deleteable<MesRohInData>()
-            .Where(s => decimals.Contains(s.Id))
+            .Where(s => decimals.Contains(s.Guid))
             .ExecuteCommand() > 0;
 
         if (update && insertOrUpdate) return true;
@@ -56,16 +56,22 @@
     private bool SaveOrUpdateData(SqlSugarScope db, MesRohIn mesRohIn,
         List<MesRohInData> mesRohInDatas)
     {
-        if (mesRohIn.Id != null)
-            db.Deleteable<MesRohIn>().Where(s => s.Id == mesRohIn.Id)
+        if (mesRohIn.Guid != null)
+            db.Deleteable<MesRohIn>().Where(s => s.Guid == mesRohIn.Guid)
                 .ExecuteCommand();
 
         if (mesRohInDatas.Count > 0)
             db.Deleteable<MesRohInData>()
                 .Where(s => s.ErpId == mesRohIn.EbelnK3id).ExecuteCommand();
 
-        var orUpdate = base.Insert(mesRohIn);
-        var baOrUpdate = rohInDataManager.InsertRange(mesRohInDatas);
+        var orUpdate = db.Insertable(mesRohIn)
+            .IgnoreColumns(true).ExecuteCommand() > 0;
+
+
+        var baOrUpdate = db.Insertable(mesRohInDatas).PageSize(1)
+            .IgnoreColumnsNull()
+            .ExecuteCommand() > 0;
+        
         if (orUpdate && baOrUpdate) return true;
         throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�");
     }
@@ -83,8 +89,9 @@
         var eid = long.Parse(rohIn.id);
         var mesRohIn = new MesRohIn();
 
+
         var single = base.GetSingle(it => it.EbelnK3id == eid);
-        if (single != null) mesRohIn.Id = single.Id;
+        if (single != null) mesRohIn.Guid = single.Guid;
 
         mesRohIn.EbelnK3id = eid;
         mesRohIn.BillNo = rohIn.FBillNo;
@@ -155,7 +162,7 @@
         {
             var entity = new MesRohInData
             {
-                 EbelnK3id = Convert.ToDecimal(s.id),
+                EbelnK3id = Convert.ToDecimal(s.id),
                 ErpId = Convert.ToDecimal(s.Eid),
                 BillNo = s.FBillNo,
                 ItemId = s.FMaterialId,
@@ -201,7 +208,8 @@
                 TotalStoredQty = Convert.ToDecimal(s.FStockInQty), //绱鍏ュ簱鏁�
                 RemainingStoredQty = Convert.ToDecimal(s.FRemainStockINQty),
                 TotalReturnedQty = Convert.ToDecimal(s.FMrbQty),
-                ReturnableReceivedQty = Convert.ToDecimal(s.FCHECKRETQTY), //鏀舵枡鍙��鏁�
+                ReturnableReceivedQty =
+                    Convert.ToDecimal(s.FCHECKRETQTY), //鏀舵枡鍙��鏁�
                 ReturnableStoredQty = Convert.ToDecimal(s.FSTOCKRETQTY), //搴撳瓨鍙��鏁�
                 SourceDocumentType = s.FSrcBillTypeId,
                 SourceDocumentId = s.FSrcBillNo,
@@ -224,7 +232,7 @@
 
             var single = rohInDataManager.GetSingle(it =>
                 it.EbelnK3id == entity.EbelnK3id);
-            if (single != null) entity.Id = single.Id;
+            if (single != null) entity.Guid = single.Guid;
 
             return entity;
         }).ToList();

--
Gitblit v1.9.3