From 5bee62e95d6cd1d5306e99c0e4b6349b663ca0ce Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期四, 09 一月 2025 09:15:49 +0800
Subject: [PATCH] 工艺路线孙表新增;排产锁定工单(添康反写排产完成日期到金蝶);批改小时产能;批改上班工时;不良原因添加班组过滤

---
 WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs |  226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 223 insertions(+), 3 deletions(-)

diff --git a/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs b/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
index f655bd7..1d97270 100644
--- a/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
+++ b/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
@@ -569,6 +569,107 @@
             return objJsonResult;
         }
 
+        //宸ヨ壓璺嚎瀛欒〃 鏂板
+        [Route("Gy_RoutingBillSub/AddWorkQty")]
+        [HttpPost]
+        public object AddWorkQty([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                var _value = sMainSub["sMainSub"].ToString();
+                string msg1 = _value.ToString();
+
+                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+                string msg2 = sArray[0].ToString();
+                string user = sArray[1].ToString();
+
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "宸ヨ壓璺嚎鏃犳潈闄愮紪杈�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<Gy_RoutingBillSub_WorkQty> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_RoutingBillSub_WorkQty>>(msg2);
+                int i = 0;
+
+                oCN.BeginTran();//寮�濮嬩簨鐗�
+
+                foreach (Gy_RoutingBillSub_WorkQty oSub in DetailColl)
+                {
+                    i++;
+
+                    if (i == 1)
+                    {
+                        //鍏堝垹闄ゅ巻鍙茬粦瀹氭暟鎹悗鍦ㄩ噸鏂颁繚瀛�
+                        oCN.RunProc("delete from Gy_RoutingBillSub_WorkQty where HInterID = " + oSub.HInterID + " and HEntryID = " + oSub.HEntryID);
+                    };
+
+                    oCN.RunProc($"insert into Gy_RoutingBillSub_WorkQty" +
+                        $"(HInterID,HEntryID,HEntrySubID,HSourceID,HWorkQty_Source,HEntryStdEmpQty,HEntryStdEmpAvg,HSortNum,HRemark)" +
+                        $"values({oSub.HInterID},{oSub.HEntryID},{i},{oSub.HSourceID},{oSub.HWorkQty_Source},{oSub.HEntryStdEmpQty}" +
+                        $",{oSub.HEntryStdEmpAvg},{oSub.HSortNum},'{oSub.HRemark}')");
+                }
+
+                oCN.Commit();//鎻愪氦浜嬬墿
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();//鍥炴粴浜嬬墿
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }           
+        }
+        #endregion
+
+        #region 宸ヨ壓璺嚎瀛欒〃缂栬緫鑾峰彇鏁版嵁
+        [Route("Gy_RoutingBill/EditWorkQty")]
+        [HttpGet]
+        public object EditWorkQty(long HInterID,long HEntryID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn($"select * from h_v_Gy_RoutingBillSub_WorkQtyEdit where hmainid={HInterID} and hsubid={HEntryID} order by HEntrySubID asc", "h_v_Gy_RoutingBillSub_WorkQtyEdit");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "false锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    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 涓存椂瀹氶鎶ヨ〃
@@ -1350,6 +1451,16 @@
                 var ds = oCN.RunProcReturn("select * from Gy_RoutingBillMain where HInterID=" + HInterID, "Gy_RoutingBillMain");
                 if (ds.Tables[0].Rows.Count > 0)
                 {
+                    string HBillStatus = Convert.ToString(ds.Tables[0].Rows[0]["HBillStatus"]);
+                    //string hdeleteman = Convert.ToString(ds.Tables[0].Rows[0]["hdeleteman"]);
+                    if (HBillStatus == "6")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鍦ㄥ鏍镐腑,涓嶈兘鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     if (IsAudit == 0)  //鍏抽棴鍒ゆ柇
                     {
                         if (ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
@@ -1625,10 +1736,11 @@
                     return objJsonResult;
                 }
                 //鎼滅储闇�瑕佸鏍哥殑
-                string sql = "  select DISTINCT a.*,c.HItemID as HCheckFlowStatusID,m.HName as 瀹℃壒娴�,c.HCheckFlowID,i.HName as 瀹℃壒椤圭洰鍚嶇О,c.HCheckItemID,c.HChecker as 椤圭洰瀹℃牳浜�,c.HCheckNote as 瀹℃壒娴佸鏍稿缓璁�,c.HCheckDate 瀹℃壒娴佸鏍告棩鏈�   from h_v_Gy_RoutingBillList AS a LEFT JOIN Xt_BillCheckFlowStatus AS c ON a.hmainid = c.HBillInterID and a.鍗曟嵁绫诲瀷 = c.HBillTypeID" +
+                string sql = "select TOP 1000 a.*,c.HItemID as HCheckFlowStatusID,m.HName as 瀹℃壒娴�,c.HCheckFlowID,i.HName as 瀹℃壒椤圭洰鍚嶇О,c.HCheckItemID,c.HChecker as 椤圭洰瀹℃牳浜�,c.HCheckNote as 瀹℃壒娴佸鏍稿缓璁�,c.HCheckDate 瀹℃壒娴佸鏍告棩鏈�   from h_v_Gy_RoutingBillList AS a LEFT JOIN Xt_BillCheckFlowStatus AS c ON a.hmainid = c.HBillInterID and a.鍗曟嵁绫诲瀷 = c.HBillTypeID" +
                     " LEFT JOIN Xt_CheckFlowMain as m ON m.HInterID = c.HCheckFlowID" +
                     " LEFT JOIN Xt_CheckItem as i ON i.HItemID = c.HCheckItemID" +
-                    " where 宸ュ簭浠g爜 != '9999' and a.HBillSubType<>'SUB' and c.HCheckDate is  not NUll and c.HChecker = '" + user + "'";
+                    " where 宸ュ簭浠g爜 != '9999' and a.HBillSubType<>'SUB' and c.HCheckDate is  not NUll and c.HChecker = '" + user + "'"+ 
+                    " ORDER BY a.hmainid DESC;";
                 ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList");
                 foreach (DataColumn col in ds.Tables[0].Columns)
                 {
@@ -2314,7 +2426,7 @@
                     return objJsonResult;
                 }
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList  where 瀹氶绫诲瀷 = '涓存椂瀹氶' and 澶辨晥鏃堕棿 BETWEEN DATEADD(DAY, -15, GETDATE()) AND GETDATE() " + sWhere + " order by hmainid desc", "h_v_Gy_RoutingBillList");
+                ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList  where 瀹氶绫诲瀷 = '涓存椂瀹氶' and 鐘舵��!= '鍏抽棴' and 澶辨晥鏃堕棿 BETWEEN  CAST(GETDATE() AS DATE) AND DATEADD(DAY, 15, GETDATE()) " + sWhere + " order by hmainid desc", "h_v_Gy_RoutingBillList");
                 foreach (DataColumn col in ds.Tables[0].Columns)
                 {
                     Type dataType = col.DataType;
@@ -2440,5 +2552,113 @@
         }
         #endregion
 
+        #region 宸ヨ壓璺嚎鎾ゅ洖
+        [Route("Gy_Routing/WithdrawCheckFlow")]
+        [HttpGet]
+        public object WithdrawCheckFlow(string HInterID, string user)
+        {
+            try
+            {
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);      //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsGy_RoutingBill oBill = new DAL.ClsGy_RoutingBill();                              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+                //鑾峰彇绯荤粺鍙傛暟鍒ゆ柇宸ヨ壓璺嚎鏄惁鍚敤澶氱骇瀹℃壒绂佺敤
+                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+                string sReturn = "";
+                if (oSystemParameter.ShowBill(ref sReturn) == true)
+                {
+                    if (oSystemParameter.omodel.Gy_RoutingBill_EnableMultiLevel.ToUpper() == "N") //绯荤粺鍙傛暟  鏈惎鐢ㄨ嚜鍔ㄥ鏍� 
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "宸ヨ壓璺嚎鏈惎鐢ㄥ绾у鎵圭鐢�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HBillStatus != 6)
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "鍗曟嵁鏈湪瀹℃牳涓笉鑳芥挙鍥�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                    if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Edit", 1, false, user))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "宸ヨ壓璺嚎鏃犳潈闄愭挙鍥�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = CodeConstant.FAIL;
+                    objJsonResult.count = CountConstant.FAIL;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁瀛樺湪瀹℃牳杩囩殑椤圭洰
+                string sql0 = "select * from Xt_BillCheckFlowStatus where HBillInterID = " + lngBillKey + " and HBillTypeID = '" + oBill.BillType + "' and ISNULL(HChecker,'') <> ''";
+                DataSet ds0 = oCN.RunProcReturn(sql0, "Xt_BillCheckFlowStatus");
+                if (ds0 != null && ds0.Tables[0].Rows.Count == 0)
+                {
+                    oCN.BeginTran();
+                    //鑾峰彇闇�瑕侀┏鍥炵殑瀹℃牳椤圭洰
+                    string sql1 = "select c.* from Xt_CheckFlowMain as a " +
+                                  "inner join Xt_CheckFlowSub as b on a.HInterID = b.HInterID " +
+                                  "inner join Xt_BillCheckFlowStatus as c on a.HBillTypeID = c.HBillTypeID and b.HCheckItemID = c.HCheckItemID " +
+                                  "where c.HBillTypeID = '" + this.BillType + "' and c.HBillInterID = " + lngBillKey + " " +
+                                  "order by b.HFlowNo asc";
+                    DataSet ds1= oCN.RunProcReturn(sql1, "Xt_BillCheckFlowStatus");
+                    if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
+                    {
+                        sReturn = "鎾ゅ洖澶辫触!鍘熷洜:鏈彂璧峰鎵癸紒锛�";
+                        return false;
+                    }
+                    //鑾峰彇褰撳墠瀹℃牳椤圭洰
+                    string HCheckFlowID = ds1.Tables[0].Rows[0]["HCheckFlowID"].ToString();             //瀹℃壒娴佸唴鐮�
+                    sql0 = "select * from Gy_RoutingBillMain " + " where HInterID = " + lngBillKey;
+                    ds0 = oCN.RunProcReturn(sql0, "Gy_RoutingBillMain");
+                    string HCheckItemNowID = ds0.Tables[0].Rows[0]["HCheckItemNowID"].ToString();       //褰撳墠瀹℃壒椤圭洰鍐呯爜
+                    //鏇存柊 椹冲洖鍒犻櫎瀹℃牳娴佺姸鎬佽〃
+                    string sql02 = "Delete Xt_BillCheckFlowStatus where HBillTypeID = '" + this.BillType + "' and HBillInterID=" + lngBillKey + " and HCheckFlowID=" + HCheckFlowID;
+                    oCN.RunProc(sql02);
+                    oCN.RunProc(" Update Gy_RoutingBillMain" + " set HChecker='',HCheckDate=null,HBillStatus=1,HCheckItemNowID = 0,HCheckItemNextID = 0 Where HInterID=" + lngBillKey.ToString());
+                    oCN.Commit();
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鎾ゅ洖鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                else
+                {
+                    objJsonResult.code = CodeConstant.FAIL;
+                    objJsonResult.count = CountConstant.FAIL;
+                    objJsonResult.Message = "鎾ゅ洖澶辫触!鍘熷洜:鍗曟嵁瀛樺湪宸茬粡瀹℃牳鐨勯」鐩紒锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1