From 9ae6aa786445d49dc3e93ead5a8ee4b92006304e Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 07 八月 2023 08:08:15 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/QC_ManagementController.cs |  271 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 188 insertions(+), 83 deletions(-)

diff --git a/WebAPI/Controllers/QC_ManagementController.cs b/WebAPI/Controllers/QC_ManagementController.cs
index 0e51805..28e0467 100644
--- a/WebAPI/Controllers/QC_ManagementController.cs
+++ b/WebAPI/Controllers/QC_ManagementController.cs
@@ -13,6 +13,8 @@
 {
     public class QC_ManagementController : ApiController
     {
+        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        DataSet ds;
 
         #region 閿欒杩斿洖鏂规硶
         // GET: QC_Management
@@ -29,22 +31,22 @@
         {
             try
             {
-                if (ds == null || ds.Tables[0].Rows.Count <= 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                else
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -104,20 +106,30 @@
         /// <returns></returns>
         [Route("QC_Management/MES_QC_CheckProjectList_Json")]
         [HttpGet]
-        public object MES_QC_CheckProjectList_Json(string sWhere)
+        public object MES_QC_CheckProjectList_Json(string sWhere,string user)
         {
             DataSet ds;
             try
             {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select  * from h_v_Gy_QCCheckProjectList", "h_v_Gy_QCCheckProjectList");
+                    ds = oCN.RunProcReturn("select  * from h_v_Gy_QCCheckProjectList order by hmainid desc ", "h_v_Gy_QCCheckProjectList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_Gy_QCCheckProjectList where 1=1";
-                    string sql = sql1 + sWhere;
+                    string sql = sql1 + sWhere+ " order by hmainid desc ";
                     ds = oCN.RunProcReturn(sql, "h_v_Gy_QCCheckProjectList");
                 }
             }
@@ -174,20 +186,30 @@
         /// <returns></returns>
         [Route("QC_Management/MES_QC_FirstPieceCheckBillList_Json")]
         [HttpGet]
-        public object MES_QC_FirstPieceCheckBillList_Json(string sqlWhere)
+        public object MES_QC_FirstPieceCheckBillList_Json(string sqlWhere,string user)
         {
             DataSet ds;
             try
             {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("QC_FirstPieceCheckBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_FirstPieceCheckBillList  where  鍏抽棴浜�='' ", "h_v_QC_FirstPieceCheckBillList");
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_FirstPieceCheckBillList  where  鍏抽棴浜�='' order by hmainid desc ", "h_v_QC_FirstPieceCheckBillList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_QC_FirstPieceCheckBillList where 鍏抽棴浜�='' ";
-                    string sql = sql1 + sqlWhere;
+                    string sql = sql1 + sqlWhere+ " order by hmainid desc ";
                     ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBillList");
                 }
             }
@@ -209,20 +231,30 @@
         /// <returns></returns>
         [Route("QC_Management/MES_QC_PatrolProcCheckBillList_Json")]
         [HttpGet]
-        public object MES_QC_PatrolProcCheckBillList_Json(string sqlWhere)
+        public object MES_QC_PatrolProcCheckBillList_Json(string sqlWhere,string user)
         {
             DataSet ds;
             try
             {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("QC_PatrolProcCheckBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_PatrolProcCheckBillList where  鍏抽棴浜�=''", "h_v_QC_PatrolProcCheckBillList");
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_PatrolProcCheckBillList where  鍏抽棴浜�='' order by hmainid desc ", "h_v_QC_PatrolProcCheckBillList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_QC_PatrolProcCheckBillList where 鍏抽棴浜�='' ";
-                    string sql = sql1 + sqlWhere;
+                    string sql = sql1 + sqlWhere+ " order by hmainid desc ";
                     ds = oCN.RunProcReturn(sql, "h_v_QC_PatrolProcCheckBillList");
                 }
             }
@@ -496,7 +528,17 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string user = sArray[2].ToString();//鐢ㄦ埛鍚�
 
+            //鍒ゆ柇鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Edit", 1, false, user))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犵紪杈戞潈闄�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
             string UserName = "";
             ListModels oListModels = new ListModels();
@@ -620,7 +662,7 @@
 
             DBUtility.ClsPub.CurUserName = UserName;
             //缂栬緫鏉冮檺
-            if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Delete", 1, true, DBUtility.ClsPub.CurUserName))
+            if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Delete", 1, false, DBUtility.ClsPub.CurUserName))
             {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
@@ -695,7 +737,7 @@
             try
             {
                 //鍒犻櫎鏉冮檺
-                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
+                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName))
                 //{
                 //    objJsonResult.code = "0";
                 //    objJsonResult.count = 0;
@@ -756,10 +798,6 @@
             }
         }
         #endregion
-
-
-
-
 
         #region 鏉ユ枡妫�楠�
         /// <summary>
@@ -902,7 +940,7 @@
             try
             {
                 //鍒犻櫎鏉冮檺
-                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
+                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName))
                 //{
                 //    objJsonResult.code = "0";
                 //    objJsonResult.count = 0;
@@ -1091,6 +1129,81 @@
                 return objJsonResult;
             }
         }
+        #region [浼垹闄ゆā寮廬
+        ///// <summary>
+        ///// 棣栦欢妫�楠岄�昏緫鍒犻櫎鍔熻兘
+        ///// </summary>
+        ///// <returns></returns>
+        //[Route("DeltetQC_FirstPieceCheck")]
+        //[HttpGet]
+        //public object DeltetQC_FirstPieceCheck(string HInterID,string user)
+        //{
+        //    DataSet ds;
+        //    string ModRightNameCheck = "QC_FirstPieceCheckBill_Delete";
+        //    try
+        //    {
+        //        //鍒犻櫎鏉冮檺
+        //        if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
+        //        {
+        //            objJsonResult.code = "0";
+        //            objJsonResult.count = 0;
+        //            objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+        //            objJsonResult.data = null;
+        //            return objJsonResult;
+        //        }
+
+        //        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        //        if (string.IsNullOrWhiteSpace(HInterID))
+        //        {
+        //            objJsonResult.code = "0";
+        //            objJsonResult.count = 0;
+        //            objJsonResult.Message = "HInterID涓虹┖锛�";
+        //            objJsonResult.data = null;
+        //            return objJsonResult;
+        //        }
+        //        oCN.BeginTran();//寮�濮嬩簨鍔�
+        //        ds = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillMain where HInterID=" + HInterID, "QC_FirstPieceCheckBillMain");
+        //        DataSet ds2 = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillSub where HInterID=" + HInterID, "QC_FirstPieceCheckBillSub");
+        //        if (ds == null || ds.Tables[0].Rows.Count == 0 || ds2 == null || ds2.Tables[0].Rows.Count == 0)
+        //        {
+        //            objJsonResult.code = "0";
+        //            objJsonResult.count = 0;
+        //            objJsonResult.Message = "娌℃湁杩欎釜鍗曟嵁锛屾棤娉曞垹闄わ紒";
+        //            objJsonResult.data = null;
+        //            return objJsonResult; ;
+        //        }
+        //        var HCloseMan = Convert.ToString(ds.Tables[0].Rows[0]["HCloseMan"]);
+        //        var HCloseMan2 = Convert.ToString(ds2.Tables[0].Rows[0]["HCloseMan"]);
+        //        if (!string.IsNullOrWhiteSpace(HCloseMan) || !string.IsNullOrWhiteSpace(HCloseMan2))
+        //        {
+        //            oCN.RollBack();//鍥炴粴浜嬪姟
+        //            objJsonResult.code = "0";
+        //            objJsonResult.count = 0;
+        //            objJsonResult.Message = "鍗曟嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
+        //            objJsonResult.data = null;
+        //            return objJsonResult;
+        //        }
+
+        //        oCN.RunProc("update QC_FirstPieceCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID);
+        //        oCN.RunProc("update QC_FirstPieceCheckBillSub set HCloseMan='-1',HEntryCloseDate=GETDATE()  where HInterID=" + HInterID);
+        //        oCN.Commit();//鎻愪氦浜嬪姟
+        //        objJsonResult.code = "0";
+        //        objJsonResult.count = 1;
+        //        objJsonResult.Message = "* 鍗曟嵁鍒犻櫎鎴愬姛锛�";
+        //        objJsonResult.data = null;
+        //        return objJsonResult; ;
+
+        //    }
+        //    catch (Exception e)
+        //    {
+        //        objJsonResult.code = "0";
+        //        objJsonResult.count = 0;
+        //        objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+        //        objJsonResult.data = null;
+        //        return objJsonResult;
+        //    }
+        //}
+        #endregion
 
         /// <summary>
         /// 棣栦欢妫�楠岄�昏緫鍒犻櫎鍔熻兘
@@ -1098,23 +1211,21 @@
         /// <returns></returns>
         [Route("DeltetQC_FirstPieceCheck")]
         [HttpGet]
-        public object DeltetQC_FirstPieceCheck(string HInterID)
+        public object DeltetQC_FirstPieceCheck(string HInterID, string user)
         {
-            DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            string ModRightNameCheck = "QC_FirstPieceCheckBill_Delete";
             try
             {
                 //鍒犻櫎鏉冮檺
-                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
-                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (string.IsNullOrWhiteSpace(HInterID))
                 {
                     objJsonResult.code = "0";
@@ -1123,41 +1234,24 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                oCN.BeginTran();//寮�濮嬩簨鍔�
-                ds = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillMain where HInterID=" + HInterID, "QC_FirstPieceCheckBillMain");
-                DataSet ds2 = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillSub where HInterID=" + HInterID, "QC_FirstPieceCheckBillSub");
-                if (ds == null || ds.Tables[0].Rows.Count == 0 || ds2 == null || ds2.Tables[0].Rows.Count == 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁杩欎釜鍗曟嵁锛屾棤娉曞垹闄わ紒";
-                    objJsonResult.data = null;
-                    return objJsonResult; ;
-                }
-                var HCloseMan = Convert.ToString(ds.Tables[0].Rows[0]["HCloseMan"]);
-                var HCloseMan2 = Convert.ToString(ds2.Tables[0].Rows[0]["HCloseMan"]);
-                if (!string.IsNullOrWhiteSpace(HCloseMan) || !string.IsNullOrWhiteSpace(HCloseMan2))
-                {
-                    oCN.RollBack();//鍥炴粴浜嬪姟
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鍗曟嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                oCN.RunProc("update QC_FirstPieceCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID);
-                oCN.RunProc("update QC_FirstPieceCheckBillSub set HCloseMan='-1',HEntryCloseDate=GETDATE()  where HInterID=" + HInterID);
-                oCN.Commit();//鎻愪氦浜嬪姟
-                objJsonResult.code = "0";
+                //寮�濮嬩簨鐗�
+                oCN.BeginTran();
+                oCN.RunProc("Delete From QC_FirstPieceCheckBillMain where HInterID = " + HInterID);
+                oCN.RunProc("Delete From QC_FirstPieceCheckBillSub where HInterID = " + HInterID);
+                oCN.RunProc("Delete From QC_FirstPieceCheckBillSub_ValueGrid where HInterID = " + HInterID);
+                oCN.RunProc("Delete From QC_FirstPieceCheckBillSub_Result where HInterID = " + HInterID);
+                //鎻愪氦浜嬪姟
+                oCN.Commit();
+                objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "* 鍗曟嵁鍒犻櫎鎴愬姛锛�";
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
                 objJsonResult.data = null;
-                return objJsonResult; ;
+                return objJsonResult;
 
             }
             catch (Exception e)
             {
+                oCN.RollBack(); //鍥炴粴浜嬬墿
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
@@ -1182,12 +1276,23 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string user = sArray[2].ToString();
 
 
             string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("QC_PatrolProcCheckBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 WebAPI.DLL.ClsQC_PatrolProcCheckBill oBill = new WebAPI.DLL.ClsQC_PatrolProcCheckBill();
                 List<Model.ClsQC_PatrolProcCheckBillMain> lsmain = new List<Model.ClsQC_PatrolProcCheckBillMain>();
                 msg2 = msg2.Replace("\\", "");
@@ -1300,21 +1405,21 @@
         /// <returns></returns>
         [Route("DeltetQC_PatrolProcCheck")]
         [HttpGet]
-        public object DeltetQC_PatrolProcCheck(string HInterID)
+        public object DeltetQC_PatrolProcCheck(string HInterID,string user)
         {
             DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            string ModRightNameCheck = "QC_PatrolProcCheckBill_Delete";
             try
             {
                 //鍒犻櫎鏉冮檺
-                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (string.IsNullOrWhiteSpace(HInterID))

--
Gitblit v1.9.1