From 5898d7f62ec4b29f313a018c7526ce100e9d30a6 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期三, 09 四月 2025 15:02:05 +0800
Subject: [PATCH] 加日志

---
 WebAPI/Controllers/SBGL/Sb_EquipBeginBillController.cs |  276 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 250 insertions(+), 26 deletions(-)

diff --git a/WebAPI/Controllers/SBGL/Sb_EquipBeginBillController.cs b/WebAPI/Controllers/SBGL/Sb_EquipBeginBillController.cs
index 1e3c9a8..34f1128 100644
--- a/WebAPI/Controllers/SBGL/Sb_EquipBeginBillController.cs
+++ b/WebAPI/Controllers/SBGL/Sb_EquipBeginBillController.cs
@@ -21,7 +21,7 @@
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         public DAL.ClsSb_EquipBeginBillMain OBill = new DAL.ClsSb_EquipBeginBillMain();
         public DAL.ClsSb_EquipBeginBillMain BillOld = new DAL.ClsSb_EquipBeginBillMain();
-
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); //鑾峰彇绯荤粺鍙傛暟
 
         #region 璁惧寮�鏈哄崟鍒楄〃 鏌ヨ       
         [Route("Sb_EquipBeginBill/get锘縎b_EquipBeginBillMainList")]
@@ -33,7 +33,7 @@
                 List<object> columnNameList = new List<object>();
 
                 //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipBeginBillMain_Check", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipBeginBillMain_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -80,6 +80,59 @@
         }
         #endregion
 
+        #region 璁惧寮�鏈哄崟鍒嗛〉鏌ヨ
+        [Route("Sb_EquipBeginBill/get锘縎b_EquipBeginBillListPage")]
+        [HttpGet]
+        public object Sb_EquipBeginBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipBeginBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipBeginBillMainListPage " + page + "," + size + ",''", "h_p_Sb_EquipBeginBillMainListPage");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipBeginBillMainListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipBeginBillMainListPage");
+                }
+
+                //娣诲姞鍒楀悕
+                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 = "1";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 璁惧寮�鏈哄崟鍒楄〃 鑾峰彇缂栬緫鍒楄〃鏁版嵁
         [Route("Sb_EquipBeginBill/锘縎b_EquipBeginBillMainEditList")]
         [HttpGet]
@@ -108,7 +161,7 @@
                     return objJsonResult;
                 }
 
-                ds = oCN.RunProcReturn("select * from h_v_Sb_EquipBeginBillMainList where HInterID = " + HInterID, " h_v_Sb_EquipBeginBillMainList");
+                ds = oCN.RunProcReturn("select * from h_v_Sb_EquipBeginBillMain_Edit where HInterID = " + HInterID, " h_v_Sb_EquipBeginBillMain_Edit");
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -240,6 +293,31 @@
                 }
                 if (bResult)
                 {
+                    //鑷姩瀹℃牳璁剧疆
+                    if (refSav == "Add")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        //绯荤粺鍙傛暟  鑷姩瀹℃牳
+                        string sReturn = "";
+                        if (oSystemParameter.ShowBill(ref sReturn) == true)
+                        {
+                            if (oSystemParameter.omodel.Sb_EquipBeginBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+                            {
+                                objJsonResult.Verify = "Y";
+                            }
+                            else
+                            {
+                                objJsonResult.Verify = "N";
+                            }
+                        }
+                    }
+                    else
+                    if (refSav == "Update")
+                    {
+                        objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //杩斿洖涓籌D
+                        objJsonResult.Verify = "N";
+                    }
+
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -294,15 +372,49 @@
 
                 oCN.BeginTran();
 
-                oCN.RunProc("delete from Sb_EquipBeginBillMain where HInterID = " + HInterID);
+                BillOld.MvarItemKey = "Sb_EquipBeginBillMain";
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Sb_EquipBeginBill_BeforeDelCtrl " + HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipBeginBill_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //==================================================================================  
+
+                bool IsDete = BillOld.DeleteBill(Convert.ToInt32(HInterID), BillOld.omodel.HBillNo, "h_p_Sb_EquipBeginBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
+                //oCN.RunProc("delete from Sb_EquipBeginBillMain where HInterID = " + HInterID);
 
                 oCN.Commit();
-
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
-                objJsonResult.data = null;
-                return objJsonResult;
+                if (IsDete)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
             }
             catch (Exception e)
             {
@@ -386,8 +498,32 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //瀹℃牳鍗曟嵁
-                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+
+                        //瀹℃牳鍓嶆帶鍒�=========================================      
+                        string sql1 = "exec h_p_Sb_EquipBeginBill_BeforeCheckCtrl " + HInterID + ",'','" + user + "'";
+                        ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipBeginBill_BeforeCheckCtrl");
+                        if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            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.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+                        //==================================================================================  
+
+                        if (!BillOld.CheckBill(int.Parse(HInterID), "", "h_p_Sb_EquipBeginBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -429,12 +565,34 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //鍙嶅鏍稿崟鎹�
-                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+
+                        //鍙嶅鏍稿墠鎺у埗=========================================        
+                        string sql1 = "exec h_p_Sb_EquipBeginBill_BeforeUnCheckCtrl " + HInterID + ",'','" + user + "'";
+                        ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipBeginBill_BeforeUnCheckCtrl");
+                        if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
-                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                        }
+                        if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //===========================================================         
+
+                        if (!BillOld.AbandonCheck(int.Parse(HInterID), "", "h_p_Sb_EquipBeginBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
@@ -445,7 +603,7 @@
 
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.Message = "瀹℃牳鎴愬姛锛�";
                 objJsonResult.data = null;
                 return objJsonResult; ;
 
@@ -454,7 +612,7 @@
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.Message = "瀹℃牳澶辫触锛�" + e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
             }
@@ -533,15 +691,47 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //鍏抽棴鍗曟嵁
-                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+
+                        string sql2 = "";
+                        //鍏抽棴鍓嶆帶鍒�===============================================Begin===================================================================
+                        sql2 = "exec h_p_Sb_EquipBeginBill_BeforeCloseCtrl " + HInterID + ",'','" + user + "'";
+                        ds = oCN.RunProcReturn(sql2, "h_p_Sb_EquipBeginBill_BeforeCloseCtrl");
+                        if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                         {
                             objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                        }
+                        if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        //鍏抽棴鍓嶆帶鍒�===============================================End===================================================================
+
+                        //鍏抽棴鎻愪氦
+                        if (BillOld.CloseBill(Convert.ToInt32(HInterID),"", "h_p_Sb_EquipBeginBill_AfterCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                        {
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍏抽棴鎴愬姛";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }                        
                     }
                 }
                 else
@@ -576,15 +766,48 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //鍙嶅叧闂崟鎹�
-                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+
+
+                        string sql2 = "";
+                        //鍙嶅叧闂墠鎺у埗===============================================Begin===================================================================
+                        sql2 = "exec h_p_Sb_EquipBeginBill_BeforeUnCloseCtrl " + HInterID + ",'','" + user + "'";
+                        ds = oCN.RunProcReturn(sql2, "h_p_Sb_EquipBeginBill_BeforeUnCloseCtrl");
+                        if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                         {
                             objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                        }
+                        if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        //鍙嶅叧闂墠鎺у埗===============================================End===================================================================
+
+                        //鍙嶅叧闂彁浜�
+                        if (BillOld.CancelClose(Convert.ToInt32(HInterID), "", "h_p_Sb_EquipBeginBill_AfterUnCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                        {
+                            objJsonResult.code = "1";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }                       
                     }
                 }
 
@@ -748,7 +971,7 @@
                 List<object> columnNameList = new List<object>();
 
                 //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipBeginBillMain_Check", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipBeginBillMain_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -795,5 +1018,6 @@
         }
         #endregion
 
+        
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1