From 6624c278786b9d8c63fefb3d95e91efd1e61f9d9 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 26 三月 2025 15:03:11 +0800
Subject: [PATCH] 单据模块优化(器具保养记录单、器具点检计划单、器具点检记录单、上模单、下模单、模具投产验收单、器具故障登记单、器具维修派工单、器具维修记录单、器具维修验收单)

---
 WebAPI/Controllers/MJGL/Sc_MouldBatchWorkCheckBillController.cs |  234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 222 insertions(+), 12 deletions(-)

diff --git a/WebAPI/Controllers/MJGL/Sc_MouldBatchWorkCheckBillController.cs b/WebAPI/Controllers/MJGL/Sc_MouldBatchWorkCheckBillController.cs
index 568ae50..dafcedc 100644
--- a/WebAPI/Controllers/MJGL/Sc_MouldBatchWorkCheckBillController.cs
+++ b/WebAPI/Controllers/MJGL/Sc_MouldBatchWorkCheckBillController.cs
@@ -9,6 +9,7 @@
 using Newtonsoft.Json;
 using Model;
 using DBUtility;
+using SyntacticSugar.constant;
 
 namespace WebAPI.Controllers.MJGL
 {
@@ -131,6 +132,63 @@
             }
         }
         #endregion
+
+        /// <summary>
+        /// 妯″叿鎶曚骇楠屾敹鍗曞垎椤靛垪琛�
+        /// </summary>
+        /// <returns></returns>
+        [Route("Sc_MouldBatchWorkCheckBill/GetMouldBatchWorkCheckBillListPage")]
+        [HttpGet]
+        public object GetMouldBatchWorkCheckBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldBatchWorkCheckBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldBatchWorkCheckBillList " + page + "," + size + ",''", "h_p_Sc_MouldBatchWorkCheckBillList");
+                }
+                else
+                {
+                    sWhere = sWhere.Replace("'", "''");
+                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldBatchWorkCheckBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldBatchWorkCheckBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = CodeConstant.SUCCEED;
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
 
         #region 妯″叿鎶曚骇楠屾敹鍗� 鏂板
         /// <summary>
@@ -429,9 +487,57 @@
                     oCN.RollBack();
                     return objJsonResult;
                 }
+               
+                BillOld.MvarItemKey = "Sc_MouldBatchWorkCheckBillMain";
+                //鍒犻櫎鍓嶆帶鍒�=========================================
+                DataSet ds2;
+                string sql1 = "exec h_p_Sc_MouldBatchWorkCheckBill_BeforeDelCtrl " + Convert.ToInt32(HInterID) + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'";
+                ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldBatchWorkCheckBill_BeforeDelCtrl");
+                if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //==================================================================================                   
 
                 oCN.RunProc("delete from Sc_MouldBatchWorkCheckBillMain where HInterID=" + HInterID);
-                oCN.RunProc("delete from Sc_MouldBatchWorkCheckBillSub where HInterID=" + HInterID) ;
+                oCN.RunProc("delete from Sc_MouldBatchWorkCheckBillSub where HInterID=" + HInterID);
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Sc_MouldBatchWorkCheckBill_AfterDelCtrl " + Convert.ToInt32(HInterID) + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'";
+                ds2 = oCN.RunProcReturn(sql2, "h_p_Sc_MouldBatchWorkCheckBill_AfterDelCtrl");
+                if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //==================================================================================                     
 
                 oCN.Commit();
             }
@@ -488,6 +594,7 @@
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
                     DataSet ds;
+                    DataSet ds2;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -501,8 +608,31 @@
                             return objJsonResult;
                         }
 
-                        //瀹℃牳鍗曟嵁
-                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        //瀹℃牳鍓嶆帶鍒�=========================================      
+                        string sql1 = "exec h_p_Sc_MouldBatchWorkCheckBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'";
+                        ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldBatchWorkCheckBill_BeforeCheckCtrl");
+                        if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+
+                        if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+                        //==================================================================================  
+
+                        if (!BillOld.CheckBill(int.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldBatchWorkCheckBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -526,6 +656,7 @@
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
                     DataSet ds;
+                    DataSet ds2;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -539,12 +670,29 @@
                             return objJsonResult;
                         }
 
-                        //鍙嶅鏍稿崟鎹�
-                        if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        //鍙嶅鏍稿墠鎺у埗=========================================        
+                        string sql1 = "exec h_p_Sc_MouldBatchWorkCheckBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'";
+                        ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldBatchWorkCheckBill_BeforeUnCheckCtrl");
+                        if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                         {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
 
                         }
-                        else
+                        if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //===========================================================         
+
+                        if (!BillOld.AbandonCheck(int.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldBatchWorkCheckBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -619,6 +767,7 @@
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
                     DataSet ds;
+                    DataSet ds2;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
@@ -649,12 +798,42 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //鍏抽棴鍗曟嵁
-                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        //鍏抽棴鍓嶆帶鍒�===============================================Begin===================================================================
+                        sql = "exec h_p_Sc_MouldBatchWorkCheckBill_BeforeCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'";
+                        ds2 = oCN.RunProcReturn(sql, "h_p_Sc_MouldBatchWorkCheckBill_BeforeCloseCtrl");
+                        if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                         {
                             objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                        }
+                        if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍏抽棴鍓嶆帶鍒�===============================================End===================================================================
+
+                        //鍏抽棴鎻愪氦
+                        if (BillOld.CloseBill(Convert.ToInt32(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldBatchWorkCheckBill_AfterCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                        {
+                            objJsonResult.code = "1";
                             objJsonResult.count = 1;
-                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.Message = "鍏抽棴鎴愬姛";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
@@ -664,6 +843,7 @@
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
                     DataSet ds;
+                    DataSet ds2;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
@@ -685,12 +865,42 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //鍙嶅叧闂崟鎹�
-                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        //鍙嶅叧闂墠鎺у埗===============================================Begin===================================================================
+                        sql = "exec h_p_Sc_MouldBatchWorkCheckBill_BeforeUnCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'";
+                        ds2 = oCN.RunProcReturn(sql, "h_p_Sc_MouldBatchWorkCheckBill_BeforeUnCloseCtrl");
+                        if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
                         {
                             objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                        }
+                        if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //鍙嶅叧闂墠鎺у埗===============================================End===================================================================
+
+                        //鍙嶅叧闂彁浜�
+                        if (BillOld.CancelClose(Convert.ToInt32(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldBatchWorkCheckBill_AfterUnCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                        {
+                            objJsonResult.code = "1";
                             objJsonResult.count = 1;
-                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                             objJsonResult.data = null;
                             return objJsonResult;
                         }

--
Gitblit v1.9.1