From 9382e8326714a25e04661150d0f11ad47ca0fcac Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 15 四月 2025 14:10:36 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs |  543 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 515 insertions(+), 28 deletions(-)

diff --git a/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs b/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
index 08d95d3..b38467f 100644
--- a/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
+++ b/WebAPI/Controllers/JHGL/Gy_RoutingBillController.cs
@@ -1,19 +1,16 @@
 锘縰sing Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Pub_Class;
-using SQLHelper;
+using SyntacticSugar.constant;
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Data;
-using System.Data.SqlClient;
 using System.IO;
 using System.Web;
 using System.Web.Http;
 using System.Windows.Forms;
 using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
 using WebAPI.Models;
-using SyntacticSugar.constant;
 namespace WebAPI.Controllers
 {
     //宸ヨ壓璺嚎Controller
@@ -244,6 +241,21 @@
                         return objJsonResult;
                     }
                 }
+                else if (oSystemParameter.omodel.WMS_CampanyName == "娣诲悍绉戞妧")
+                {
+                    DataSet dss;
+                    dss = oCN.RunProcReturn("select COUNT(*) as number from Sc_ProcessExchangeBillMain where HRoutingBillID = " + HInterID, "Gy_RoutingBillMain");
+                    //鍒ゆ柇鏄惁鍙紪杈�
+                    if (dss.Tables[0].Rows[0]["number"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "姝ゅ崟鎹凡缁忚寮曠敤锛屼笉鍏佽淇敼锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                }
+
                 if (OperationType == 2)
                 {
                     ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList where  鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Gy_RoutingBillList");
@@ -255,12 +267,34 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-                }
+                }             
 
                 ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_Gy_RoutingBillList");
 
                 if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
+
+                    //淇濆瓨鍓嶆帶鍒�=========================================
+                    string HBillNote = "";
+                    ds = oCN.RunProcReturn("Exec  h_p_Gy_RoutingBill_BeforeSaveCtrl  " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", " h_p_Gy_RoutingBill_BeforeSaveCtrl ");
+                    if (ds == null)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
                     //涓昏〃
                     oCN.RunProc("Insert Into Gy_RoutingBillMain   " +
                     "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
@@ -275,6 +309,30 @@
                     "," + HMainGroupID + "," + HMainProcID + "," + HMainCenterID + ",'" + HMainTimeUnit + "'," + HMainUnitTime + "," + HMainWorkQty +
                     "," + HMainPrice + "," + HStdSourceQty + "," + HAddSourceRate + "," + HPRDORGID + "," + HDelSourceRate +
                     ",'" + HPicNumVer + "','" + HPicNumAssemble + "','" + HMaterTexture + "','" + HProductNum + "','" + HVerNum + "'," + HOrgID + ",'"+ HProcPriceType + "','" + HBeginDate + "','" + HEndDate + "') ");
+
+
+                    //=========================淇濆瓨鍚庢帶鍒�   娣诲姞瀹℃壒娴�
+                    //DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "',1 ", "h_p_Gy_RoutingBill_AfterSaveCtrl");
+                    //if (ds2 == null)
+                    //{
+                    //    oCN.RollBack();
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "淇濆瓨鍚庢帶鍒跺垽鏂け璐ワ紒";
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+
+                    //}
+                    //if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    //{
+                    //    oCN.RollBack();
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "淇濆瓨澶辫触2锛�" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
+                    //============================
 
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板宸ヨ壓璺嚎鍗曟嵁:" + HBillNo);
                     oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板宸ヨ壓璺嚎鍗曟嵁锛�" + HBillNo + "','LMES-宸ヨ壓璺嚎妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
@@ -300,20 +358,30 @@
                             objJsonResult.data = 1;
                             return objJsonResult;
                         }
-
-                        dss = oCN.RunProcReturn("select COUNT(*) as number from Sc_ProcessExchangeBillMain where HRoutingBillID = " + HInterID, "Gy_RoutingBillMain");
-                        //鍒ゆ柇鏄惁鍙紪杈�
-                        if (dss.Tables[0].Rows[0]["number"].ToString() != "0")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚寮曠敤锛屼笉鍏佽淇敼锛�";
-                            objJsonResult.data = 1;
-                            return objJsonResult;
-                        }
                     }
-                    
-                    
+
+                    //淇濆瓨鍓嶆帶鍒�=========================================
+                    string HBillNote = "";
+                    ds = oCN.RunProcReturn("Exec  h_p_Gy_RoutingBill_BeforeSaveCtrl  " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',2 ", " h_p_Gy_RoutingBill_BeforeSaveCtrl ");
+                    if (ds == null)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+
                     oCN.RunProc("update Gy_RoutingBillMain  set " +
                        "HDate='" + HDate +
                        "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker +
@@ -328,11 +396,38 @@
                     //鍒犻櫎瀛愯〃
                     oCN.RunProc("delete from Gy_RoutingBillSub where HInterID='" + HInterID + "'");
 
+                    //=========================淇濆瓨鍚庢帶鍒�   娣诲姞瀹℃壒娴�
+                    //DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "',2 ", "h_p_Gy_RoutingBill_AfterSaveCtrl");
+                    //if (ds2 == null)
+                    //{
+                    //    oCN.RollBack();
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "淇濆瓨鍚庢帶鍒跺垽鏂け璐ワ紒";
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+
+                    //}
+                    //if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    //{
+                    //    oCN.RollBack();
+                    //    objJsonResult.code = "0";
+                    //    objJsonResult.count = 0;
+                    //    objJsonResult.Message = "淇濆瓨澶辫触2锛�" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
+                    //    objJsonResult.data = null;
+                    //    return objJsonResult;
+                    //}
+                    //============================
+
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼宸ヨ壓璺嚎鍗曟嵁:" + HBillNo);
                     oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼宸ヨ壓璺嚎鍗曟嵁锛�" + HBillNo + "','LMES-宸ヨ壓璺嚎妯″潡','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 //淇濆瓨瀛愯〃
                 objJsonResult = AddBillSub(msg3, HInterID, OperationType);
+
+
+             
+
                 if (objJsonResult.code == "0")
                 {
                     objJsonResult.code = "0";
@@ -440,7 +535,7 @@
             foreach (Gy_RoutingBillSub oSub in DetailColl)
             {
                 i++;
-                if (oSystemParameter.omodel.WMS_CampanyName != "榫欏北姹介厤" && oSystemParameter.omodel.WMS_CampanyName != "娣诲悍绉戞妧")
+                if (oSystemParameter.omodel.WMS_CampanyName != "榫欏北姹介厤" && oSystemParameter.omodel.WMS_CampanyName != "娣诲悍绉戞妧" && oSystemParameter.omodel.WMS_CampanyName != "瀹濆伐")
                 {
                     if (oSub.HWorkQty <= 0)
                     {
@@ -467,7 +562,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() +
@@ -480,7 +575,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)
@@ -510,7 +605,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() +
@@ -524,7 +619,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)
@@ -540,8 +635,8 @@
                     }
                 }
 
-                //淇濆瓨鍚庢帶鍒�=========================================           娣诲姞瀹℃壒娴�
-                ds = oCN.RunProcReturn("exec h_p_Gy_RoutingBill_AfterSaveCtrl " + HInterID, "h_p_Gy_RoutingBill_AfterSaveCtrl");
+                ////淇濆瓨鍚庢帶鍒�=========================================           娣诲姞瀹℃壒娴�
+                ds = oCN.RunProcReturn("exec h_p_Gy_RoutingBill_AfterSaveCtrl " + HInterID + ",'',"+ OperationType, "h_p_Gy_RoutingBill_AfterSaveCtrl");
 
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
@@ -559,7 +654,7 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                //=========================================================
+                ////=========================================================
             }
 
             objJsonResult.code = "1";
@@ -569,6 +664,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 涓存椂瀹氶鎶ヨ〃
@@ -661,7 +857,7 @@
             try
             {
 
-                ds = oCN.RunProcReturn("select a.*,m.HProcPriceType,m.HBeginDate,m.HEndDate,s.HQCProc,s.HQCFst,s.HQCPatrol,s.HMaterToSourceCtrl from h_v_Gy_RoutingBillList as a,Gy_RoutingBillMain as m,Gy_RoutingBillSub as s where m.HInterID = hmainid and s.HInterID = hmainid and s.HEntryID = hsubid and hmainid =" + HInterID, "h_v_Gy_RoutingBillList");
+                ds = oCN.RunProcReturn("select a.*,m.HProcPriceType,m.HBeginDate,m.HEndDate,s.HQCProc,s.HQCFst,s.HQCPatrol,s.HMaterToSourceCtrl from h_v_Gy_RoutingBill_Edit as a,Gy_RoutingBillMain as m,Gy_RoutingBillSub as s where m.HInterID = hmainid and s.HInterID = hmainid and s.HEntryID = hsubid and hmainid =" + HInterID, "h_v_Gy_RoutingBillList");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -1223,7 +1419,7 @@
         /// <param name="HInterID">鍗曟嵁ID</param>
         /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
         /// <param name="CurUserName">瀹℃牳浜�</param>
-        /// <returns></returns>
+        /// <returns></returns>Gy_RoutingBill/CheckGy_RoutingBill
         [Route("Gy_RoutingBill/AuditGy_RoutingBill")]
         [HttpGet]
         public object AuditGy_RoutingBill(string HInterID, int IsAudit, string CurUserName)
@@ -1279,7 +1475,60 @@
 
                 if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
                 {
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_RoutingBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + CurUserName + "'";
+                    var ds2 = oCN.RunProcReturn(sql1, "h_p_Gy_RoutingBill_BeforeCheckCtrl");
+                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳宸ヨ壓璺嚎
                     oCN.RunProc("update Gy_RoutingBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate(),HBillStatus=2 where HInterID=" + HInterID);
+
+
+                    //瀹℃牳鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_RoutingBill_AfterCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_RoutingBill_AfterCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                  
 
                     //鑾峰彇绯荤粺鍙傛暟
                     string Ret = "";
@@ -1300,8 +1549,58 @@
                 }
                 if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
                 {
+                    //鍙嶅鏍稿墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Gy_Routing_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + CurUserName + "'";
+                    var ds2 = oCN.RunProcReturn(sql1, "h_p_Gy_Routing_BeforeUnCheckCtrl");
+                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //鍙嶅鏍稿伐鑹鸿矾绾�
                     oCN.RunProc("update Gy_RoutingBillMain set HChecker='',HCheckDate=null where HInterID=" + HInterID);
 
+                    //鍙嶅鏍稿悗鎺у埗=========================================      
+                    string sql2 = "exec h_p_Gy_RoutingBill_AfterUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_RoutingBill_AfterUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:鍙嶅鏍稿悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                  
                     objJsonResult.code = "1";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鍙嶅鏍告垚鍔�";
@@ -1428,6 +1727,194 @@
         }
         #endregion
 
+        #region 宸ヨ壓璺嚎  浣滃簾/鍙嶄綔搴�
+        /// <summary>
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param>
+        /// <param name="CurUserName">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Gy_RoutingBill/DeleteGy_RoutingBill")]
+        [HttpGet]
+        public object DeleteOA_AndengFlowRuleBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Gy_RoutingBill_Delete";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsGy_RoutingBill oBill = new DAL.ClsGy_RoutingBill();              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+                {
+                    if (oBill.omodel.HChecker.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (IsAudit == 1)  //浣滃簾鍒ゆ柇
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 2) //鍙嶄綔搴熷垽鏂�
+                    {
+                        if (oBill.omodel.HDeleteMan.Trim() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣�
+                if (IsAudit == 1) //浣滃簾鎻愪氦
+                {
+                    //浣滃簾鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_RoutingBill_BeforeDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_RoutingBill_BeforeDropCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+
+                    //浣滃簾鎻愪氦
+                    if (oBill.Cancelltion(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_RoutingBill_AfterDropCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 2) //鍙嶄綔搴熸彁浜�
+                {
+                    //鍙嶄綔搴熷墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Gy_RoutingBill_BeforeUnDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_RoutingBill_BeforeUnDropCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:鍙嶄綔搴熷墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    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;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.AbandonCancelltion(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_RoutingBill_AfterUnDropCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶄綔搴熸垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
         #region 宸ヨ壓璺嚎鍒楄〃 涓昏〃
         /// <summary>
         /// 杩斿洖宸ヨ壓璺嚎鍒楄〃

--
Gitblit v1.9.1