From da84e4e72c9d9cc7e2bd40dc4bb7b3222ca3519a Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 28 四月 2026 17:07:52 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Cg_ContractTransportBillListController.cs |  213 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 190 insertions(+), 23 deletions(-)

diff --git a/WebAPI/Controllers/Cg_ContractTransportBillListController.cs b/WebAPI/Controllers/Cg_ContractTransportBillListController.cs
index 90f972d..f456c04 100644
--- a/WebAPI/Controllers/Cg_ContractTransportBillListController.cs
+++ b/WebAPI/Controllers/Cg_ContractTransportBillListController.cs
@@ -35,7 +35,7 @@
                 List<object> columnNameList = new List<object>();
 
                 //鏌ョ湅鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Cg_ContractTransportBill_Check", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("Cg_ContractTransportBill_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -47,13 +47,13 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Cg_ContractTransportBillList order by 鍗曟嵁鍙� desc", "锘縣_v_Cg_ContractTransportBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_Cg_ContractTransportBillList_Query order by 鍗曟嵁鍙� desc", "h_v_Cg_ContractTransportBillList_Query");
                 }
                 else
                 {
-                    string sql1 = "select * from  h_v_Cg_ContractTransportBillList  where 1 = 1 ";
+                    string sql1 = "select * from  h_v_Cg_ContractTransportBillList_Query  where 1 = 1 ";
                     string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
-                    ds = oCN.RunProcReturn(sql, "锘縣_v_Cg_ContractTransportBillList");
+                    ds = oCN.RunProcReturn(sql, "锘縣_v_Cg_ContractTransportBillList_Query");
                 }
 
                 //娣诲姞鍒楀悕
@@ -83,6 +83,62 @@
 
         #endregion
 
+        #region 鎵胯繍鍟嗗悎鍚屽垎椤靛垪琛�
+        [Route("Cg_ContractTransportBillListController/page")]
+        [HttpGet]
+        public json Sc_MouldProdOutBillPage(string sWhere, string user, int page, int size, string Type)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒楄〃杩涘叆鏃跺垽鏂潈闄愶紝閫夋簮鍗曡繘鍏ヤ笉鍒ゆ柇鏉冮檺
+             
+                    if (!DBUtility.ClsPub.Security_Log("Cg_ContractTransportBill_Query", 3, 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_Cg_ContractTransportBillList " + page + "," + size + ",'','" + Type + "'", "h_p_Cg_ContractTransportBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Cg_ContractTransportBillList " + page + "," + size + ",'" + sWhere + "','" + Type + "'", "h_p_Cg_ContractTransportBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                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 = "0";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "鎴愬姛锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏌ヨ鍒楄〃淇℃伅澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鍒犻櫎     
         [Route("Cg_ContractTransportBillListController/Delete锘緽ill")]
         [HttpGet]
@@ -90,6 +146,7 @@
         {
             try
             {
+                string s = "";
                 //鏌ョ湅鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log("Cg_ContractTransportBill_Delete", 1, false, user))
                 {
@@ -115,7 +172,7 @@
                 if (BillOld.ShowBill(Int64.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))
                 {
                     //鍒犻櫎鍓嶆帶鍒�=========================================      
-                    string sql1 = "exec h_p_Cg_ContractTransportBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    string sql1 = "exec h_p_Cg_ContractTransportBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + user + "'";
                     ds = oCN.RunProcReturn(sql1, "h_p_Cg_ContractTransportBill_BeforeDelCtrl");
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
@@ -135,38 +192,51 @@
                         return objJsonResult;
                     }
                     //==================================================================================  
-
+                    oCN.RunProc("delete from Cg_ContractTransportBillMain where HInterID = " + HInterID);
+                    oCN.RunProc("delete from Cg_ContractTransportBillSub where HInterID= " + HInterID);
                     //鍒犻櫎鍗曟嵁锛堝寘鍚垹闄ゅ悗鎺у埗銆佸啓鍏ユ棩蹇楋級
-                    if (!BillOld.DeleteBill(BillOld.omodel.HInterID, BillOld.omodel.HBillNo, "h_p_Cg_ContractTransportBill_AfterDelCtrl", user, ref ClsPub.sExeReturnInfo))
+                    //鍒犻櫎鍚庢帶鍒�==================================================================================      
+                    string sql2 = "exec h_p_Cg_ContractTransportBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Cg_ContractTransportBill_AfterDelCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
-                        objJsonResult.code = "0";
-                        objJsonResult.count = 0;
-                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                        objJsonResult.data = null;
-                        return objJsonResult;
-                    }
-                    else
-                    {
+                        s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
                         objJsonResult.code = "0";
                         objJsonResult.count = 1;
-                        objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        s = ds.Tables[0].Rows[0]["HRemark"].ToString();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==============================================================================================
 
+                    oCN.Commit();
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎鎴愬姛";
+                    objJsonResult.data = null;
+                    return objJsonResult;
                 }
-
-                oCN.Commit();
-
-
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.Message = "鍒犻櫎鎴愬姛";
                 objJsonResult.data = null;
                 return objJsonResult;
             }
             catch (Exception e)
             {
+                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.ToString();
@@ -342,12 +412,12 @@
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
-                if (refSav == "Add")
+                if (refSav == "Add"|| refSav=="1")
                 {
 
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
-                else if (refSav == "Update")
+                else if (refSav == "Update" || refSav == "3")
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
@@ -382,5 +452,102 @@
             }
         }
         #endregion
+
+
+        #region 瀹℃牳銆佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Cg_ContractTransportBillEdit/AuditCg_ContractTransportBillEdit")]
+        [HttpGet]
+        public object AuditCg_ContractTransportBillEdit(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Cg_ContractTransportBillMain where HInterID=" + HInterID, "Cg_ContractTransportBillMain");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                {
+                    oCN.RunProc("update Cg_ContractTransportBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() ,HBillStatus=2 where HInterID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    oCN.RunProc("update Cg_ContractTransportBillMain set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1