From 001aa51e3a7f669594bc958424be9b74b44cd7a9 Mon Sep 17 00:00:00 2001
From: zgq <519541279@qq.com>
Date: 星期六, 29 五月 2021 15:29:16 +0800
Subject: [PATCH] 工序模块优化

---
 WebAPI/Controllers/QC_ManagementController.cs |  794 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 774 insertions(+), 20 deletions(-)

diff --git a/WebAPI/Controllers/QC_ManagementController.cs b/WebAPI/Controllers/QC_ManagementController.cs
index a3e6fd1..fdde39f 100644
--- a/WebAPI/Controllers/QC_ManagementController.cs
+++ b/WebAPI/Controllers/QC_ManagementController.cs
@@ -147,11 +147,11 @@
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_POStockInCheckBillList ", "h_v_QC_POStockInCheckBillList");
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_POStockInCheckBillList where 鍏抽棴浜�='' ", "h_v_QC_POStockInCheckBillList");
                 }
                 else
                 {
-                    string sql1 = "select * from h_v_QC_POStockInCheckBillList where 1 = 1 ";
+                    string sql1 = "select * from h_v_QC_POStockInCheckBillList where 鍏抽棴浜�='' ";
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_QC_POStockInCheckBillList");
                 }
@@ -182,11 +182,11 @@
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_FirstPieceCheckBillList ", "h_v_QC_FirstPieceCheckBillList");
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_FirstPieceCheckBillList  where  鍏抽棴浜�='' ", "h_v_QC_FirstPieceCheckBillList");
                 }
                 else
                 {
-                    string sql1 = "select * from h_v_QC_FirstPieceCheckBillList where 1 = 1 ";
+                    string sql1 = "select * from h_v_QC_FirstPieceCheckBillList where 鍏抽棴浜�='' ";
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBillList");
                 }
@@ -217,11 +217,11 @@
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (sqlWhere == null || sqlWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_PatrolProcCheckBillList ", "h_v_QC_PatrolProcCheckBillList");
+                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_PatrolProcCheckBillList where  鍏抽棴浜�=''", "h_v_QC_PatrolProcCheckBillList");
                 }
                 else
                 {
-                    string sql1 = "select * from h_v_QC_PatrolProcCheckBillList where 1 = 1 ";
+                    string sql1 = "select * from h_v_QC_PatrolProcCheckBillList where 鍏抽棴浜�='' ";
                     string sql = sql1 + sqlWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_QC_PatrolProcCheckBillList");
                 }
@@ -236,6 +236,57 @@
             }
             return GetObjectJson(ds);
         }
+
+
+        /// <summary>
+        /// 妫�楠屾柟妗堣幏鍙栦俊鎭�
+        /// </summary>
+        /// <returns></returns>
+        [Route("GetQCCheckProjectDetail")]
+        [HttpGet]
+        public ApiResult<DataSet> GetQCCheckProjectDetail(string HID)
+        {
+            var model = LuBaoSevice.GetCheckProjectDetail(HID);
+            return model;
+        }
+
+        /// <summary>
+        /// 鏉ユ枡妫�楠屽崟鑾峰彇淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("GetPOStockInCheckDetail")]
+        [HttpGet]
+        public ApiResult<DataSet> GetPOStockInCheckDetail(string HID)
+        {
+            var model = LuBaoSevice.GetPOStockInCheckBillDetail(HID);
+            return model;
+        }
+
+        /// <summary>
+        /// 棣栦欢妫�楠屽崟鑾峰彇淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("GetQC_FirstPieceCheckDetail")]
+        [HttpGet]
+        public ApiResult<DataSet> GetQC_FirstPieceCheckDetail(string HID)
+        {
+            var model = LuBaoSevice.GetQC_FirstPieceCheckBillDetail(HID);
+            return model;
+        }
+
+
+        /// <summary>
+        /// 宸℃鍗曡幏鍙栦俊鎭�
+        /// </summary>
+        /// <returns></returns>
+        [Route("GetQC_PatrolProcCheckDetail")]
+        [HttpGet]
+        public ApiResult<DataSet> GetQC_PatrolProcCheckDetail(string HID)
+        {
+            var model = LuBaoSevice.GetQC_PatrolProcCheckBillDetail(HID);
+            return model;
+        }
+
 
         /// <summary>
         /// 杩斿洖妫�楠屾柟妗堝崟瀛愯〃璇︽儏
@@ -272,10 +323,119 @@
             return GetObjectJson(ds);
         }
 
+
+        /// <summary>
+        /// 杩斿洖鏉ユ枡妫�楠屽崟瀛愯〃璇︽儏
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("MES_QC_POStockInCheckDetail_Json")]
+        [HttpGet]
+        public object MES_QC_POStockInCheckDetail_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_QC_Edit_POStockInCheckBillList", "h_v_QC_Edit_POStockInCheckBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_QC_Edit_POStockInCheckBillList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_QC_Edit_POStockInCheckBillList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+        /// <summary>
+        /// 杩斿洖棣栦欢妫�楠屽崟瀛愯〃璇︽儏
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("MES_QC_FirstPieceCheckDetail_Json")]
+        [HttpGet]
+        public object MES_QC_FirstPieceCheckDetail_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_QC_Edit_FirstPieceCheckBillList", "h_v_QC_Edit_FirstPieceCheckBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_QC_Edit_FirstPieceCheckBillList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_QC_Edit_FirstPieceCheckBillList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+
+        /// <summary>
+        /// 杩斿洖宸℃鍗曞瓙琛ㄨ鎯�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("MES_QC_PatrolProcCheckDetail_Json")]
+        [HttpGet]
+        public object MES_QC_PatrolProcCheckDetail_Json(string sqlWhere)
+        {
+            DataSet ds;
+            try
+            {
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (sqlWhere == null || sqlWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_QC_Edit_PatrolProcCheckBillList", "h_v_QC_Edit_PatrolProcCheckBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_QC_Edit_PatrolProcCheckBillList where 1 = 1 ";
+                    string sql = sql1 + sqlWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_QC_Edit_PatrolProcCheckBillList");
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+
         #endregion
 
         #region 淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
 
+        #region 妫�楠屾柟妗�
         /// <summary>
         /// 淇濆瓨妫�楠屾柟妗�
         /// </summary>
@@ -402,20 +562,6 @@
             }
         }
 
-
-        /// <summary>
-        /// 妫�楠屾柟妗堣幏鍙栦俊鎭�
-        /// </summary>
-        /// <returns></returns>
-        [Route("GetQCCheckProjectDetail")]
-        [HttpGet]
-        public ApiResult<DataSet> GetQCCheckProjectDetail(string HID)
-        {
-            var model = LuBaoSevice.GetCheckProjectDetail(HID);
-            return model;
-        }
-
-
         /// <summary>
         /// 妫�楠屾柟妗堥�昏緫鍒犻櫎鍔熻兘
         /// </summary>
@@ -489,7 +635,615 @@
                 return objJsonResult;
             }
         }
+        #endregion
 
+        #region 鏉ユ枡妫�楠�
+        /// <summary>
+        /// 淇濆瓨鏉ユ枡妫�楠屽崟
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("SaveQC_POStockInCheckList")]
+        [HttpPost]
+        public object SaveQC_POStockInCheckList([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+
+            string UserName = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DAL.ClsQC_POStockInCheckBill oBill = new DAL.ClsQC_POStockInCheckBill();
+                List<Model.ClsQC_POStockInCheckBillMain> lsmain = new List<Model.ClsQC_POStockInCheckBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_QC_POStockInCheckBillMain(msg2);
+                foreach (Model.ClsQC_POStockInCheckBillMain oItem in lsmain)
+                {
+                    //oItem.HMaker = "";
+                    UserName = oItem.HMaker;
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HBillType = "7503";
+                    oItem.HBillSubType = "7503";
+                    oItem.HBillStatus = 0;
+                    oItem.HPeriod = 0;
+                    oItem.HMaker = "";
+                    oItem.HMainSourceInterID = oItem.HInterID;
+
+                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsQC_POStockInCheckBillSub> ls = new List<Model.ClsQC_POStockInCheckBillSub>();
+                ls = oListModels.getObjectByJson_QC_POStockInCheckBillSub(msg3);
+                int i = 0;
+                foreach (Model.ClsQC_POStockInCheckBillSub oItemSub in ls)
+                {
+                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//鍗曟嵁鍙凤紙澶囦唤锛屼互鍏嶅唴鐮佷涪澶憋紝鎵句笉鍒板搴斾富琛級
+                    i++;
+                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病澶囦唤鍗曟嵁鍙凤紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oItemSub.HSourceEntryID = 0;
+                    oItemSub.HSourceInterID = 0;
+                    oItemSub.HEntryID = i;
+                    // DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;
+                    oItemSub.HSourceBillNo = "";
+                    oItemSub.HSourceBillType = "";
+                    oItemSub.HRelationQty = 0;
+                    oItemSub.HRelationMoney = 0;
+                    oItemSub.HCloseMan = "";
+                    oItemSub.HRemark = "";
+                    oItemSub.HProcCheckEmp = oBill.omodel.HFirstCheckEmp;//妫�娴嬪憳
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏉ユ枡妫�楠岄�昏緫鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("DeltetQC_POStockInCheck")]
+        [HttpGet]
+        public object DeltetQC_POStockInCheck(string HInterID)
+        {
+            DataSet ds;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
+                //{
+                //    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_POStockInCheckBillMain where HInterID=" + HInterID, "QC_POStockInCheckBillMain");
+                DataSet ds2 = oCN.RunProcReturn("select * from QC_POStockInCheckBillSub where HInterID=" + HInterID, "QC_POStockInCheckBillSub");
+                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_POStockInCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID);
+                oCN.RunProc("update QC_POStockInCheckBillSub 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
+
+        #region 棣栦欢妫�楠�
+        /// <summary>
+        /// 淇濆瓨棣栦欢妫�楠屽崟
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("SaveQC_FirstPieceCheckList")]
+        [HttpPost]
+        public object SaveQC_FirstPieceCheckList([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+
+            string UserName = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+
+                DAL.ClsQC_FirstPieceCheckBill oBill = new DAL.ClsQC_FirstPieceCheckBill();
+                List<Model.ClsQC_FirstPieceCheckBillMain> lsmain = new List<Model.ClsQC_FirstPieceCheckBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_QC_FirstPieceCheckBillMain(msg2);
+                foreach (Model.ClsQC_FirstPieceCheckBillMain oItem in lsmain)
+                {
+                    //oItem.HMaker = "";
+                    UserName = oItem.HMaker;
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HBillType = "7505";
+                    oItem.HBillSubType = "7505";
+                    oItem.HBillStatus = 0;
+                    oItem.HPeriod = 0;
+                    oItem.HMaker = "";
+                    oItem.HMainSourceInterID = oItem.HInterID;
+
+                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsQC_FirstPieceCheckBillSub> ls = new List<Model.ClsQC_FirstPieceCheckBillSub>();
+                ls = oListModels.getObjectByJson_QC_FirstPieceCheckBillSub(msg3);
+                int i = 0;
+                foreach (Model.ClsQC_FirstPieceCheckBillSub oItemSub in ls)
+                {
+                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//鍗曟嵁鍙凤紙澶囦唤锛屼互鍏嶅唴鐮佷涪澶憋紝鎵句笉鍒板搴斾富琛級
+                    i++;
+                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病澶囦唤鍗曟嵁鍙凤紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oItemSub.HSourceEntryID = 0;
+                    oItemSub.HSourceInterID = 0;
+                    oItemSub.HEntryID = i;
+                    // DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;
+                    oItemSub.HSourceBillNo = "";
+                    oItemSub.HSourceBillType = "";
+                    oItemSub.HRelationQty = 0;
+                    oItemSub.HRelationMoney = 0;
+                    oItemSub.HCloseMan = "";
+                    oItemSub.HRemark = "";
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 棣栦欢妫�楠岄�昏緫鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("DeltetQC_FirstPieceCheck")]
+        [HttpGet]
+        public object DeltetQC_FirstPieceCheck(string HInterID)
+        {
+            DataSet ds;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
+                //{
+                //    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
+
+        #region 宸℃
+        /// <summary>
+        /// 淇濆瓨宸℃鍗�
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("SaveQC_PatrolProcCheckList")]
+        [HttpPost]
+        public object SaveQC_PatrolProcCheckList([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+
+            string UserName = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                WebAPI.DLL.ClsQC_PatrolProcCheckBill oBill = new WebAPI.DLL.ClsQC_PatrolProcCheckBill();
+                List<Model.ClsQC_PatrolProcCheckBillMain> lsmain = new List<Model.ClsQC_PatrolProcCheckBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_QC_PatrolProcCheckBillMain(msg2);
+                foreach (Model.ClsQC_PatrolProcCheckBillMain oItem in lsmain)
+                {
+                    //oItem.HMaker = "";
+                    UserName = oItem.HMaker;
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
+                    oItem.HBillType = "7506";
+                    oItem.HBillSubType = "7506";
+                    oItem.HBillStatus = 0;
+                    oItem.HPeriod = 0;
+                    oItem.HMaker = "";
+                    oItem.HMainSourceInterID = oItem.HInterID;
+
+                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Model.ClsQC_PatrolProcCheckBillSub> ls = new List<Model.ClsQC_PatrolProcCheckBillSub>();
+                ls = oListModels.getObjectByJson_QC_PatrolProcCheckBillSub(msg3);
+                int i = 0;
+                foreach (Model.ClsQC_PatrolProcCheckBillSub oItemSub in ls)
+                {
+                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//鍗曟嵁鍙凤紙澶囦唤锛屼互鍏嶅唴鐮佷涪澶憋紝鎵句笉鍒板搴斾富琛級
+                    i++;
+                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病澶囦唤鍗曟嵁鍙凤紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oItemSub.HSourceEntryID = 0;
+                    oItemSub.HSourceInterID = 0;
+                    oItemSub.HEntryID = i;
+                    // DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;
+                    oItemSub.HSourceBillNo = "";
+                    oItemSub.HSourceBillType = "";
+                    oItemSub.HRelationQty = 0;
+                    oItemSub.HRelationMoney = 0;
+                    oItemSub.HCloseMan = "";
+                    oItemSub.HRemark = "";
+                    oBill.DetailColl.Add(oItemSub);
+
+                }
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 宸℃閫昏緫鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("DeltetQC_PatrolProcCheck")]
+        [HttpGet]
+        public object DeltetQC_PatrolProcCheck(string HInterID)
+        {
+            DataSet ds;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
+                //{
+                //    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_PatrolProcCheckBillMain where HInterID=" + HInterID, "QC_PatrolProcCheckBillMain");
+                DataSet ds2 = oCN.RunProcReturn("select * from QC_PatrolProcCheckBillSub where HInterID=" + HInterID, "QC_PatrolProcCheckBillSub");
+                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_PatrolProcCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID);
+                oCN.RunProc("update QC_PatrolProcCheckBillSub 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
 
         #endregion
 

--
Gitblit v1.9.1