From b9ac90e91d4de079acf33f379674e4e448e6baf3 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 26 八月 2025 11:07:50 +0800
Subject: [PATCH] 修改  生产领料单 递入 HMainSourceBillType 为 HBillSubType

---
 WebAPI/Controllers/品质管理/基础资料/Gy_BaseInformationController.cs |  296 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 284 insertions(+), 12 deletions(-)

diff --git "a/WebAPI/Controllers/\345\223\201\350\264\250\347\256\241\347\220\206/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_BaseInformationController.cs" "b/WebAPI/Controllers/\345\223\201\350\264\250\347\256\241\347\220\206/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_BaseInformationController.cs"
index 7b1c65c..fa35e16 100644
--- "a/WebAPI/Controllers/\345\223\201\350\264\250\347\256\241\347\220\206/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_BaseInformationController.cs"
+++ "b/WebAPI/Controllers/\345\223\201\350\264\250\347\256\241\347\220\206/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_BaseInformationController.cs"
@@ -20,9 +20,10 @@
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
         private json objJsonResult = new json();
         public DataSet ds = new DataSet();
+        public DataSet ds1 = new DataSet();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-        public DAL.ClsGy_EnvironmentTestSchemeBillMain OBill = new DAL.ClsGy_EnvironmentTestSchemeBillMain();
-        public DAL.ClsGy_EnvironmentTestSchemeBillMain BillOld = new DAL.ClsGy_EnvironmentTestSchemeBillMain();
+        public DAL.ClsGy_EnvironmentTestSchemeBillMain OBill = new DAL.ClsGy_EnvironmentTestSchemeBillMain();       //鐜妫�娴嬫柟妗�
+        public DAL.ClsGy_EnvironmentTestSchemeBillMain BillOld = new DAL.ClsGy_EnvironmentTestSchemeBillMain();  //鐜妫�娴嬫柟妗�
 
         #region 鐜妫�娴嬮」鐩� 鏌ヨ       
         [Route("Gy_BaseInformation/get锘縂y_EnvironmentTestSchemeBillMainList")]
@@ -312,12 +313,64 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+                DAL.ClsGy_EnvironmentTestSchemeBillMain BillOld = new DAL.ClsGy_EnvironmentTestSchemeBillMain();
+                //鍒ゆ柇瀛樺湪鎬�
+                if (BillOld.ShowBill(Int64.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    //鍒ゆ柇鏄惁鍙紪杈�
+                    if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    //鍒犻櫎鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_EnvironmentTestSchemeBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestSchemeBill_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;
+                    }
 
-                oCN.BeginTran();
+                    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;
+                    }
+                    //==================================================================================  
 
-                oCN.RunProc("delete from Gy_EnvironmentTestSchemeBillMain where HInterID = " + HInterID);
+                    //鍒犻櫎鍗曟嵁锛堝寘鍚垹闄ゅ悗鎺у埗銆佸啓鍏ユ棩蹇楋級
+                    if (!BillOld.DeleteBill(BillOld.omodel.HInterID, BillOld.omodel.HBillNo, "h_p_Gy_EnvironmentTestSchemeBill_AfterDelCtrl", user, ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                }
 
                 oCN.Commit();
+
+
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -364,13 +417,13 @@
 
                 ClsPub.CurUserName = user;
                 BillOld.MvarItemKey = "Gy_EnvironmentTestSchemeBillMain";
+
                 oCN.BeginTran();//寮�濮嬩簨鍔�
 
                 //Type 1 瀹℃牳  2  鍙嶅鏍�
                 if (Type == 1)
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
-                    DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
@@ -407,8 +460,32 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        //瀹℃牳鍓嶆帶鍒�=========================================      
+                        string sql1 = "exec h_p_Gy_EnvironmentTestSchemeBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
+                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestSchemeBill_BeforeCheckCtrl");
+                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+
+                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+                        //==================================================================================      
+
                         //瀹℃牳鍗曟嵁
-                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_EnvironmentTestSchemeBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -421,7 +498,6 @@
                 else
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
-                    DataSet ds;
                     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)
@@ -450,8 +526,29 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        //鍙嶅鏍稿墠鎺у埗=========================================        
+                        string sql1 = "exec h_p_Gy_EnvironmentTestSchemeBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
+                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestSchemeBill_BeforeUnCheckCtrl");
+                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                        }
+                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        //===========================================================  
                         //鍙嶅鏍稿崟鎹�
-                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_EnvironmentTestSchemeBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -663,7 +760,6 @@
                 if (Type == 1)
                 {
                     //鍒ゆ柇鍗曟嵁鏄惁宸茬粡浣滃簾
-                    DataSet ds;
                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                     if (ds == null || ds.Tables[0].Rows.Count == 0)
@@ -692,8 +788,31 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        //浣滃簾鍓嶆帶鍒�=========================================      
+                        string sql1 = "exec h_p_Gy_EnvironmentTestSchemeBill_BeforeDropCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
+                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestSchemeBill_BeforeDropCtrl");
+                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+
+                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+                        //==================================================================================  
                         //浣滃簾鍗曟嵁
-                        if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        if (!BillOld.Cancelltion(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_EnvironmentTestSchemeBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -727,8 +846,31 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        //鍙嶄綔搴熷墠鎺у埗=========================================      
+                        string sql1 = "exec h_p_Gy_EnvironmentTestSchemeBill_BeforeUnDropCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + user + "'";
+                        ds1 = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestSchemeBill_BeforeUnDropCtrl");
+                        if (ds1 == null || ds1.Tables.Count == 0 || ds1.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:鍙嶄綔搴熷墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+
+                        if (ds1.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 1;
+                            objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ds1.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                            objJsonResult.data = null;
+                            oCN.RollBack();
+                            return objJsonResult;
+                        }
+                        //==================================================================================  
                         //鍙嶄綔搴熷崟鎹�
-                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Gy_EnvironmentTestSchemeBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo))
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 1;
@@ -757,7 +899,137 @@
                 return objJsonResult;
             }
         }
-        #endregion     
+        #endregion
+
+        #region SPC涓績绾垮垪琛� 鏌ヨ       
+        [Route("QC_SpcCenterlineList/List")]
+        [HttpGet]
+        public object List(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+               
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_QC_SpcCenterlineList order by HInterID desc", "锘縣_v_QC_SpcCenterlineList");
+                }
+                else
+                {
+                    string sql1 = "select * from  h_v_QC_SpcCenterlineList  where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by HInterID desc";
+                    ds = oCN.RunProcReturn(sql, "锘縣_v_QC_SpcCenterlineList");
+                }
+
+                //娣诲姞鍒楀悕
+                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 = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region SPC涓績绾垮垪琛� 寮傚父鏁版嵁 鏇存柊       
+        [Route("QC_SpcCenterlineList/UpdateData")]
+        [HttpGet]
+        public object UpdateData(string HInterID, string HBeginDate, string HEndDate, string user)
+        {
+            try
+            {
+                LogService.Write("杈撳叆鍊�:" + "exec h_p_QC_SPC_EightJudge_Abnormal " + HInterID + ",'" + HBeginDate + "','" + HEndDate + "'");
+                ds = oCN.RunProcReturn("exec h_p_QC_SPC_EightJudge_Abnormal "+ HInterID + ",'"+ HBeginDate + "','"+ HEndDate + "'", "锘縣_p_QC_SPC_EightJudge_Abnormal");
+                LogService.Write("杈撳叆鍊�:" + ds.Tables[0].Rows.Count);
+                if (int.Parse(ds.Tables[0].Rows[0]["绫诲瀷"].ToString()) <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = ds.Tables[0].Rows[0][1].ToString();
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                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 SPC涓績绾垮垪琛� 寮傚父鏁版嵁 鏂板
+        [Route("QC_SpcCenterlineList/QC_SpcCenterlineAdd")]
+        [HttpGet]
+        public object UpdateData(string HInterID, string AvgData, string HControlUpperLimit_X, string HControlLowerLimit_X, string user)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select * from QC_SpcCenterline where HInterID="+ HInterID, "锘縌C_SpcCenterline");
+
+                if (ds.Tables[0].Rows.Count==0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message ="鏌ユ棤鏁版嵁!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var HMaterID = int.Parse( ds.Tables[0].Rows[0]["HMaterID"].ToString());
+                var HQCCheckItemID = int.Parse(ds.Tables[0].Rows[0]["HQCCheckItemID"].ToString());
+                var HMouldNum = ds.Tables[0].Rows[0]["HMouldNum"].ToString();
+
+                oCN.RunProc("update QC_SpcCenterline set HStart=0 where HMaterID=" + HMaterID + " and HQCCheckItemID=" + HQCCheckItemID + " and HMouldNum='" + HMouldNum + "'");
+                oCN.RunProc("insert into QC_SpcCenterline(HMaterID,HQCCheckItemID,HMouldNum,HCenterline_X,HControlUpperLimit_X,HControlLowerLimit_X,HMaker, HMakeDate, HStart)" +
+                    "values(" + HMaterID + "," + HQCCheckItemID + "," + HMouldNum + "," + AvgData + "," + HControlUpperLimit_X + "," + HControlLowerLimit_X + "," + user + ",getdate(),1) ");
+
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏂板鎴愬姛锛�";
+                objJsonResult.data = null;
+                objJsonResult.list = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
 
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1