From 569bb53b544e2e178b64e229d45f047da032af36 Mon Sep 17 00:00:00 2001
From: hao <1836460075@qq.com>
Date: 星期五, 27 六月 2025 10:25:14 +0800
Subject: [PATCH] 销售退货,发货,采购退货申请反审核防呆

---
 StandardInterface/MES.Service/service/CgthSqManager.cs |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/StandardInterface/MES.Service/service/CgthSqManager.cs b/StandardInterface/MES.Service/service/CgthSqManager.cs
index 44b5ba0..59e979c 100644
--- a/StandardInterface/MES.Service/service/CgthSqManager.cs
+++ b/StandardInterface/MES.Service/service/CgthSqManager.cs
@@ -115,18 +115,48 @@
    private bool UpdateData(SqlSugarScope db, CgthSq mesWomCgth,
       List<CgthSqDetail> mesWomcabs)
         {
-            var decimals = mesWomcabs.Select(s => s.Id).ToArray();
+            //var decimals = mesWomcabs.Select(s => s.Id).ToArray();
 
             //鎵爜涓嶅厑璁稿垹闄�
-             
-            throw new NotImplementedException("鎵爜涓嶅厑璁稿垹闄�");
+            var hasMaterialOut = db.Queryable<MesInvItemOuts>()
+                               .Any(x => x.WorkNo == mesWomCgth.BillNo);
+
+            if (hasMaterialOut)
+            {
+                throw new Exception($"MES鏈夐鏂欒褰曪紝鍗曞彿锛歿mesWomCgth.BillNo}锛屼笉鑳藉垹闄わ紒");
+            }
+    /*    
             var update = base.DeleteById(mesWomCgth.Id);
             var insertOrUpdate = db
                 .Deleteable<CgthSqDetail>().In(decimals)
                 .ExecuteCommand() > 0;
 
 
-            if (update && insertOrUpdate) return true;
+            if (update && insertOrUpdate) return true;*/
+          // throw new NotImplementedException("鏇存柊澶辫触");
+
+            var decimals = mesWomcabs
+               ?.Where(x => x.Id.HasValue)
+               .Select(x => x.Id.Value)
+               .ToArray() ?? new decimal[0];
+            var update = true;
+            if (mesWomCgth != null)
+            {
+                if (mesWomCgth.Id != null)
+                {
+                    update = base.DeleteById(mesWomCgth.Id);
+                }
+            }
+            var insertOrUpdate = true;
+            if (decimals != null && decimals.Length > 0)
+            {
+                insertOrUpdate = db.Deleteable<CgthSqDetail>().In(decimals).ExecuteCommand() > 0;
+            }
+
+            if (update && insertOrUpdate)
+            {
+                return true;
+            }
             throw new NotImplementedException("鏇存柊澶辫触");
         }
    private bool SaveOrUpdateData(SqlSugarScope db, CgthSq mesWomcaa,

--
Gitblit v1.9.3