From 87bdc068d2135c27fa23732bab14ac297787e6e5 Mon Sep 17 00:00:00 2001
From: 如洲 陈 <1278080563@qq.com>
Date: 星期四, 30 十月 2025 08:35:11 +0800
Subject: [PATCH] 单位转换接口和委外工单变更修改

---
 MES.Service/service/BasicData/ProductionOrderManager.cs |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/MES.Service/service/BasicData/ProductionOrderManager.cs b/MES.Service/service/BasicData/ProductionOrderManager.cs
index f78da56..03d8359 100644
--- a/MES.Service/service/BasicData/ProductionOrderManager.cs
+++ b/MES.Service/service/BasicData/ProductionOrderManager.cs
@@ -53,6 +53,31 @@
 
         womcaaWW.Caa001 = mesRohInDatas[0].Cab001;
         womcaaWW.Erpid = womcaaWW.FSUBENTRYID.ToInt32();
+
+        //瀹氫箟杈撳叆鍙傛暟
+        var inputParam1 = new SugarParameter("P_WORK_NO", womcaaWW.Caa001);
+        // 瀹氫箟杈撳嚭鍙傛暟
+        var outParam1 = new SugarParameter("c_Result", null, true);
+        var outParam2 = new SugarParameter("C_MSG", null, true);
+        // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+        db.Ado.ExecuteCommand(
+            "BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;",
+            inputParam1, outParam1, outParam2);
+        // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+        var result = int.Parse((string)outParam1.Value);
+        var message = outParam2.Value == DBNull.Value
+            ? string.Empty
+            : (string)outParam2.Value;
+        if (result == 1)
+        {
+            //瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊�
+            db.Ado.RollbackTran();
+            throw new Exception(message);
+        }
+
+        // 鎻愪氦浜嬪姟
+        db.Ado.CommitTran();
+
         var decimals = mesRohInDatas.Select(s => s.Id).ToArray();
         var update = base.DeleteById(womcaaWW.Id);
         var insertOrUpdate = db
@@ -91,7 +116,34 @@
             .IgnoreColumnsNull()
             .ExecuteCommand() > 0;
 
-        if (orUpdate && baOrUpdate) return true;
+        if (orUpdate && baOrUpdate)
+        {
+            //瀹氫箟杈撳叆鍙傛暟
+            var inputParam1 = new SugarParameter("P_WORK_NO", mesWomcaa.Caa001);
+            // 瀹氫箟杈撳嚭鍙傛暟
+            var outParam1 = new SugarParameter("c_Result", null, true);
+            var outParam2 = new SugarParameter("C_MSG", null, true);
+            // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+            Db.Ado.ExecuteCommand(
+                "BEGIN PRC_UPDATE_DAA(:P_WORK_NO,:c_Result,:C_MSG); END;",
+                inputParam1, outParam1, outParam2);
+            // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+            var result = int.Parse((string)outParam1.Value);
+            var message = outParam2.Value == DBNull.Value
+                ? string.Empty
+                : (string)outParam2.Value;
+            if (result == 1)
+            {
+                //瀛樺偍杩囩▼澶辫触鍒欎簨鍔¤繘琛屽洖婊�
+                db.Ado.RollbackTran();
+                throw new Exception(message);
+            }
+
+            // 鎻愪氦浜嬪姟
+            db.Ado.CommitTran();
+            return true;
+        }
+
 
         throw new NotImplementedException("鎻掑叆鎴栨洿鏂板け璐�");
     }

--
Gitblit v1.9.3