From a1c3a3d1b0b0b8c28a19e99177e4cee5a64949b7 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 25 二月 2025 11:20:17 +0800
Subject: [PATCH] 增加斯莫尔  性能检测散点图报表

---
 WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs |  253 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 237 insertions(+), 16 deletions(-)

diff --git a/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs b/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
index 4d9070e..cdb438b 100644
--- a/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
+++ b/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
@@ -379,14 +379,16 @@
                 }
 
 
+                if (oSystemParameter.omodel.WMS_CampanyName == "涔斾竴")
+                {
+                    //鏄惁鍕鹃�夐粯璁ゅ伐鑹鸿矾绾�
+                    if (HStandard)
+                    {
+                        //璁剧疆榛樿宸ヨ壓璺嚎
+                        oCN.RunProc("exec h_p_Gy_RoutingBillCheck " + HInterID + ",'" + user + "'");
+                    }
+                }
 
-                //鏄惁鍕鹃�夐粯璁ゅ伐鑹鸿矾绾�
-                //if (HStandard)
-                //{
-                //    //璁剧疆榛樿宸ヨ壓璺嚎
-                //    oCN.RunProc("exec h_p_Gy_RoutingBillCheck " + HInterID + ",'" + user + "'");
-                //}
-             
                 //鍒ゆ柇鏄惁閲嶅宸ュ簭鍙�
                 ds = oCN.RunProcReturn("exec h_p_Gy_RoutingCtrl " + HInterID, "h_p_Gy_RoutingCtrl");
 
@@ -465,7 +467,7 @@
                     ",HPackStd,HPack,HPutArea,HMyWorkDays,HMyFixWorkDays,HPassRate" +
                     ",HTechnologyParameter,HPicNum,HProcCheckNote" +
                     ",HOverRate,HProcWorkNum,HBadWHID,HWasterWHID, HWHID,HIsTime,HEstimate " +
-                    ",HWorkTimes_S,HSortProcFlag " +
+                    ",HWorkTimes_S,HSortProcFlag,HSubStdEmpAvg_S" +
                     ") values("
                     + HInterID + "," + i + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNo + "'," + oSub.HSupID.ToString() + "," + Convert.ToString(oSub.HSupFlag ? 1 : 0) + "" +
                     "," + oSub.HWorkQty.ToString() + "," + oSub.HCenterID.ToString() + ",'" + oSub.HTimeUnit.ToString() + "'," + oSub.HUnitTime.ToString() +
@@ -478,7 +480,7 @@
                    ",'" + oSub.HPackStd + "','" + oSub.HPack + "','" + oSub.HPutArea + "'," + oSub.HMyWorkDays.ToString() + "," + oSub.HMyFixWorkDays.ToString() + "," + oSub.HPassRate.ToString() +
                    ",'" + oSub.HTechnologyParameter.ToString() + "','" + oSub.HPicNum.ToString() + "','" + oSub.HProcCheckNote.ToString() +
                    "', " + oSub.HOverRate.ToString() + ",'" + oSub.HProcWorkNum.ToString() + "'," + oSub.HBadWHID.ToString() + "," + oSub.HWasterWHID.ToString() + "," + oSub.HWHID.ToString() + "," + Convert.ToString(oSub.HIsTime ? 1 : 0) + "," + oSub.HEstimate.ToString() +
-                   ", " + oSub.HWorkTimes_S.ToString() + "," + Convert.ToString(oSub.HSortProcFlag ? 1 : 0) +
+                   ", " + oSub.HWorkTimes_S.ToString() + "," + Convert.ToString(oSub.HSortProcFlag ? 1 : 0) + "," + oSub.HSubStdEmpAvg_S +
                     ") ");
                     //璁′环鏂瑰紡涓嶄负璁℃椂锛屽垯鎶婅鏃舵殏浼板瓧娈垫洿鏂颁负绌�
                     if (oSub.HIsTime == false)
@@ -508,7 +510,7 @@
                     ",HTechnologyParameter,HPicNum,HProcCheckNote" +
                     ",HOverRate,HProcWorkNum,HBadWHID,HWasterWHID, HWHID,HEstimate,HIsTime" +
                     ",HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol" +
-                    ",HWorkTimes_S,HSortProcFlag,HSNCtrl,HQCFst,HQCProc,HQCPatrol,HMaterToSourceCtrl " +
+                    ",HWorkTimes_S,HSortProcFlag,HSNCtrl,HQCFst,HQCProc,HQCPatrol,HMaterToSourceCtrl,HSubStdEmpAvg_S" +
                     ") values("
                     + HInterID + "," + i + "," + oSub.HProcID.ToString() + ",'" + oSub.HProcNo + "'," + oSub.HSupID.ToString() + "," + Convert.ToString(oSub.HSupFlag ? 1 : 0) + "" +
                     "," + oSub.HWorkQty.ToString() + "," + oSub.HCenterID.ToString() + ",'" + oSub.HTimeUnit.ToString() + "'," + oSub.HUnitTime.ToString() +
@@ -522,7 +524,7 @@
                    ",'" + oSub.HTechnologyParameter.ToString() + "','" + oSub.HPicNum.ToString() + "','" + oSub.HProcCheckNote.ToString() +
                    "', " + oSub.HOverRate.ToString() + ",'" + oSub.HProcWorkNum.ToString() + "'," + oSub.HBadWHID.ToString() + "," + oSub.HWasterWHID.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HEstimate.ToString() + "," + Convert.ToString(oSub.HIsTime ? 1 : 0) + "," + oSub.HQCSchemeID_Fst + "," +
                      oSub.HQCSchemeID_Proc + "," + oSub.HQCSchemeID_Patrol +
-                   ", " + oSub.HWorkTimes_S.ToString() + "," + Convert.ToString(oSub.HSortProcFlag ? 1 : 0) + "," + Convert.ToString(oSub.HSNCtrl ? 1 : 0) + "," + Convert.ToString(oSub.HQCFst ? 1 : 0) + "," + Convert.ToString(oSub.HQCProc ? 1 : 0) + "," + Convert.ToString(oSub.HQCPatrol ? 1 : 0) + "," + Convert.ToString(oSub.HMaterToSourceCtrl ? 1 : 0) +
+                   ", " + oSub.HWorkTimes_S.ToString() + "," + Convert.ToString(oSub.HSortProcFlag ? 1 : 0) + "," + Convert.ToString(oSub.HSNCtrl ? 1 : 0) + "," + Convert.ToString(oSub.HQCFst ? 1 : 0) + "," + Convert.ToString(oSub.HQCProc ? 1 : 0) + "," + Convert.ToString(oSub.HQCPatrol ? 1 : 0) + "," + Convert.ToString(oSub.HMaterToSourceCtrl ? 1 : 0) + "," + oSub.HSubStdEmpAvg_S +
                     ") ");
                     //璁′环鏂瑰紡涓嶄负璁℃椂锛屽垯鎶婅鏃舵殏浼板瓧娈垫洿鏂颁负绌�
                     if (oSub.HIsTime == false)
@@ -567,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 涓存椂瀹氶鎶ヨ〃
@@ -1348,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() != "")
@@ -1623,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)
                 {
@@ -2312,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;
@@ -2429,10 +2543,117 @@
             }
             catch (Exception e)
             {
-                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
-                objJsonResult.Message = "瀹℃牳鎴栧弽瀹℃牳宸ヨ壓璺嚎澶辫触锛�" + e.ToString();
+                objJsonResult.Message = "椹冲洖宸ヨ壓璺嚎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #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;
             }

--
Gitblit v1.9.1