From 9ff424751d75ebba92f8317bd2d6aa57094baca4 Mon Sep 17 00:00:00 2001
From: chenhaozhe <gaozhechen26@gmail.com>
Date: 星期日, 08 三月 2026 19:04:38 +0800
Subject: [PATCH] 新增 投料防错 增删改查 API

---
 WebAPI/Controllers/Sc_MouldRepairInBillListController.cs |   60 ++++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
index 00b3256..b801c1c 100644
--- a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
+++ b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -768,15 +768,13 @@
         {
             try
             {
-
                 Dictionary<object, object> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<object, object>>(sWhere);
-
                 string HBeginDate = dic["HBeginDate"].ToString();//寮�濮嬫棩鏈�
                 string HEndDate = dic["HEndDate"].ToString();//缁撴潫鏃ユ湡
                 string HMouldNo = dic["HMouldNo"].ToString();//妯″叿缂栫爜
                 string HName = dic["HName"].ToString();//妯″叿鍚嶇О
 
-                ds = oCN.RunProcReturn("exec h_P_Sc_MouldLifeUsePicReport '" + HBeginDate + "'," + HEndDate + ",'" + HMouldNo + "','" + HName + "'", "h_P_Sc_MouldLifeUsePicReport");
+                ds = oCN.RunProcReturn("exec h_P_Sc_MouldLifeUsePicReport '" + HBeginDate + "','" + HEndDate + "','" + HMouldNo + "','" + HName + "'", "h_P_Sc_MouldLifeUsePicReport");
                 List<object> columnNameList = new List<object>();
                 //娣诲姞鍒楀悕
                 foreach (DataColumn col in ds.Tables[0].Columns)
@@ -791,7 +789,6 @@
                 objJsonResult.data = ds.Tables[0];
                 objJsonResult.list = columnNameList;
                 return objJsonResult;
-                //}
             }
             catch (Exception e)
             {
@@ -6058,6 +6055,7 @@
             ListModels oListModels = new ListModels();
             try
             {
+                string sErrMsg = "";
                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBill_Edit", 1, false, msg4))
                 {
                     objJsonResult.code = "0";
@@ -6083,6 +6081,17 @@
                     //oItem.HInnerBillNo = "";  //  --鍐呴儴鍗曟嵁鍙�
                     oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                     oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                   if(oSystemParameter.ShowBill(ref sErrMsg) == true)
+                   {
+                        // if(oSystemParameter.omodel.WMS_CampanyName == "鍗庤垷")
+                        // {
+                        //     oItem.HRepairManID = oItem.HEmpID;
+                        // }else
+                        // {
+                            oItem.HRepairManID = 0;
+                        // }
+                   }
+                    
                     if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                     {
                         objJsonResult.code = "0";
@@ -6290,19 +6299,20 @@
                 //==================================================================================  
 
                 bool IsDete = oBill.DeleteBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Sc_MouldConkBookBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
-                if (IsDete)
+
+                var oDelDs = oCn.RunProcReturn($"exec h_p_Sc_MouldConkBookBill_AfterDelCtrl {lngBillKey},{oBill.omodel.HBillNo}, {user}, {oBill.omodel.HMouldID}", "h_p_Sc_MouldConkBookBill_AfterDelCtrl");
+                if (!IsDete || oDelDs == null)
                 {
                     objJsonResult.code = "0";
-                    objJsonResult.count = 1;
+                    objJsonResult.count = 0;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
                 else
                 {
-
                     objJsonResult.code = "0";
-                    objJsonResult.count = 0;
+                    objJsonResult.count = 1;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
                     return objJsonResult;
@@ -9463,6 +9473,7 @@
         public object CheckSc_MouldDotCheckPlanBill(string HInterID, int Type, string user)
         {
             DAL.ClsSc_MouldDotCheckPlanBill BillOld = new DAL.ClsSc_MouldDotCheckPlanBill();
+            oCN.BeginTran();//寮�濮嬩簨鍔�
             try
             {
                 //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
@@ -9472,6 +9483,7 @@
                     objJsonResult.count = 0;
                     objJsonResult.Message = "鏃犳潈闄愬鏍�!";
                     objJsonResult.data = null;
+                    oCN.RollBack();
                     return objJsonResult;
                 }
 
@@ -9481,11 +9493,11 @@
                     objJsonResult.count = 0;
                     objJsonResult.Message = "HInterID涓虹┖锛�";
                     objJsonResult.data = null;
+                    oCN.RollBack();
                     return objJsonResult;
                 }
 
                 ClsPub.CurUserName = user;
-                oCN.BeginTran();//寮�濮嬩簨鍔�
 
                 //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
                 if (BillOld.ShowBill(Convert.ToInt32(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))
@@ -9496,6 +9508,7 @@
                         objJsonResult.count = 0;
                         objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }
                     if (BillOld.omodel.HDeleteMan.Trim() != "")
@@ -9504,6 +9517,7 @@
                         objJsonResult.count = 0;
                         objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }
                     if (Type == 1)  //瀹℃牳鍒ゆ柇
@@ -9514,6 +9528,7 @@
                             objJsonResult.count = 0;
                             objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
                             objJsonResult.data = null;
+                            oCN.RollBack();
                             return objJsonResult;
                         }
                     }
@@ -9525,6 +9540,7 @@
                             objJsonResult.count = 0;
                             objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
                             objJsonResult.data = null;
+                            oCN.RollBack();
                             return objJsonResult;
                         }
                     }
@@ -9535,6 +9551,7 @@
                     objJsonResult.count = 0;
                     objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
+                    oCN.RollBack();
                     return objJsonResult;
                 }
 
@@ -9547,7 +9564,7 @@
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 1;
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
                         objJsonResult.data = null;
                         oCN.RollBack();
@@ -9557,7 +9574,7 @@
                     if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 1;
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                         objJsonResult.data = null;
                         oCN.RollBack();
@@ -9568,14 +9585,12 @@
                     if (!BillOld.CheckBill(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Sc_MouldDotCheckPlanBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 1;
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }
-
-                    //鑷姩鐢熸垚鐐规璁″垝鍗�
-                    oCN.RunProc("exec h_p_Sc_MouldDotCheckPlan_Auto " + HInterID);
                 }
                 else
                 {
@@ -9585,18 +9600,20 @@
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 1;
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
 
                     }
                     if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 1;
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }
                     //===========================================================         
@@ -9604,14 +9621,20 @@
                     if (!BillOld.AbandonCheck(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Sc_MouldDotCheckPlanBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
-                        objJsonResult.count = 1;
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }                    
                 }
 
                 oCN.Commit();//鎻愪氦浜嬪姟
+                if (Type == 1)
+                {
+                    // 鍦ㄦ彁浜や簨鍔″悗鍐嶅皾璇曠敓鎴愬櫒鍏风偣妫�璁″垝鍗� 棰勯槻姝婚攣
+                    oCN.RunProc("exec h_p_Sc_MouldDotCheckPlan_Auto " + HInterID);
+                }
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -9622,6 +9645,7 @@
             }
             catch (Exception e)
             {
+                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();

--
Gitblit v1.9.1