From a5d691a24ef8fdb7155ecc9f6dd1bef843020f03 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期二, 20 二月 2024 13:28:10 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs |  214 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 193 insertions(+), 21 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index 1c93f60..75722a2 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -322,6 +322,28 @@
                 var num = 0;
                 //LogService.Write($"3.浜嬪姟寮�濮嬶紝鐢ㄦ椂" + sw.Elapsed);
 
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                string HBillNote = "";
+                ds = oCN.RunProcReturn("Exec  h_p_Sc_StationOutBill_BeforeSaveCtrl  " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", " h_p_Sc_StationOutBill_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;
+                }
+                //=========================================================
+
+
                 //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
                 oCN.BeginTran();
                 if ("Add".Equals(eventType))
@@ -502,6 +524,29 @@
                     }
                 }
 
+                //=========================淇濆瓨鍚庢帶鍒�  
+                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_StationOutBill_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "',1 ", "h_p_Sc_StationOutBill_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($"10.浜嬪姟缁撴潫锛岀敤鏃�" + sw.Elapsed);
                 oCN.Commit();
@@ -598,7 +643,7 @@
                     long HMaterID = listSub[i].HMaterID;//浜у搧ID
                     long HProcID = listSub[i].HProcID;//褰撳墠宸ュ簭ID
                     double HICMOQty = listSub[i].HICMOQty;//浠诲姟鍗曟暟閲�
-                    double HPlanQty = list[0].HPlanQty;//绉讳氦PNL鏁�
+                    double HPlanQty = listSub[i].HPlanQty;//绉讳氦PNL鏁�
                     DateTime HStationOutTime = list[0].HStationOutTime;//姹囨姤鏃堕棿
                     long HSourceID = listSub[i].HSourceID;//鐢熶骇璧勬簮ID
                     long HPayProcID = list[0].HPayProcID;//鏍哥畻宸ュ簭ID
@@ -621,10 +666,11 @@
                     string HProcNo = listSub[i].HProcNo;//娴佹按鍙�
                     string HOrderProcNO = list[0].HOrderProcNO;//璁㈠崟璺熻釜鍙�
                     string HSourceNameList = list[0].HSourceNameList;//璁惧娓呭崟
-                    long HMainSourceInterID = list[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
-                    string HMainSourceBillNo = list[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+                    long HMainSourceInterID = listSub[0].HMainSourceInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+                    long HMainSourceEntryID = listSub[0].HMainSourceEntryID;//閫掑叆type寰楀埌鐨勫崟鎹瓙ID
+                    string HMainSourceBillNo = listSub[0].HMainSourceBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
                     string HMainSourceBillType = "3790";
-                    bool HLastSubProc = list[0].HLastSubProc;//杞笅宸ュ簭
+                    bool HLastSubProc = listSub[0].HLastSubProc;//杞笅宸ュ簭
                     long HEmpID2 = list[0].HEmpID2;//鎿嶄綔鍛�2ID
                     long HEmpID3 = list[0].HEmpID3;//鎿嶄綔鍛�3ID
                     long HEmpID4 = list[0].HEmpID4;//鎿嶄綔鍛�4ID
@@ -659,7 +705,7 @@
                         ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" +
                         ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" +
                         ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" +
-                        ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" +
+                        ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID,HMainSourceEntryID" +
                         ") " +
                         " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" +
                         "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
@@ -668,7 +714,7 @@
                         "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 +
                         "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" +
                         "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) +
-                        "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID +
+                        "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID + "," + HMainSourceEntryID +
                         ") ");
                     }
                     else
@@ -2117,8 +2163,52 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
+                    //鍒犻櫎鍓嶅垽鏂湁娌℃湁鐢熸垚閲戣澏鍗曟嵁锛堢敓浜ф眹鎶ュ崟锛岀敓浜у叆搴撳崟锛�
+                    ds = oCn.RunProcReturn($"exec h_p_Cj_StationOutBill_BeforeDelCtrl {HInterID}", "h_p_Cj_StationOutBill_BeforeDelCtrl");
+                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎鍑虹珯姹囨姤鍗曞彂鐢熷紓甯革紝娌℃湁浠讳綍杩斿洖璁板綍锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        if (ds.Tables[0].Rows[0]["HBackCount"].ToString() == "1")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = ds.Tables[0].Rows[0]["HRemarkBack"].ToString();
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
 
-                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
+                    //鍒犻櫎鍓嶆帶鍒�=========================================      
+                    string HBillNo = oBill.omodel.HBillNo;
+                    string sql1 = "exec h_p_Sc_StationOutBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + HDeleteMan + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Sc_StationOutBill_BeforeDelCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, HBillNo, "h_p_Sc_StationOutBill_AfterDelCtrl", HDeleteMan, ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
@@ -2429,12 +2519,13 @@
                 }
               
             
-                var HBillNo = HInterID.Split(',');
+                var HInterIDs = HInterID.Split(',');
+                string[] HBillNo = new string[HInterIDs.Length];
                 DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill();
 
-                for (int i = 0; i < HBillNo.Length; i++)
+                for (int i = 0; i < HInterIDs.Length; i++)
                 {
-                    if (HBillNo[i] == "0")
+                    if (HInterIDs[i] == "0")
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
@@ -2443,7 +2534,7 @@
                         return objJsonResult;
                     }
                     //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
-                    if (oBill.ShowBill(long.Parse(HBillNo[i]), ref DBUtility.ClsPub.sExeReturnInfo))
+                    if (oBill.ShowBill(long.Parse(HInterIDs[i]), ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         if (oBill.omodel.HChecker.Trim() != "")
                         {
@@ -2453,6 +2544,7 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+                        HBillNo[i] = oBill.omodel.HBillNo;
                     }
                     else
                     {
@@ -2465,10 +2557,32 @@
                 }
 
                 int j = 0;
-                for (int i = 0; i < HBillNo.Length; i++)
+                for (int i = 0; i < HInterIDs.Length; i++)
                 {
+                    //瀹℃牳鍓嶆帶鍒�
+                    string sql = "exec h_p_Sc_StationOutBill_BeforeCheckCtrl " + HInterIDs[i] + ",'" + HBillNo[i] + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_BeforeCheckCtrl");
+                    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;
+                    }
+
+                    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;
+                    }
+
+
                     //瀹℃牳
-                    if (Cj_StationOutBillCheckBill(long.Parse(HBillNo[i]), CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo))
+                    if (Cj_StationOutBillCheckBill(long.Parse(HInterIDs[i]), HBillNo[i], CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         j += 1;
                     }
@@ -2499,7 +2613,7 @@
         }
 
         //瀹℃牳
-        public bool Cj_StationOutBillCheckBill(Int64 lngBillKey, string CurUserName,bool HLastSubProc, ref string sReturn)
+        public bool Cj_StationOutBillCheckBill(Int64 lngBillKey, string HBillNo, string CurUserName,bool HLastSubProc, ref string sReturn)
         {
             try
             {
@@ -2527,6 +2641,23 @@
                 else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "鏄�")
                 {
                 }
+
+                //瀹℃牳鍚庢帶鍒�
+                string sql = "exec h_p_Sc_StationOutBill_AfterCheckCtrl " + lngBillKey + ",'" + HBillNo + "','" + CurUserName + "'";
+                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_AfterCheckCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "瀹℃牳杩囩▼涓嚭閿欙紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    oCN.RollBack();
+                    return false;
+                }
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
+                    oCN.RollBack();
+                    return false;
+                }
+
                 sReturn = sReturn + " 瀹℃牳鍔熻兘锛�";
                 oCN.Commit();
                 return true;
@@ -2573,16 +2704,17 @@
                 }
               
 
-                var HBillNo = HInterID.Split(',');
+                var HInterIDs = HInterID.Split(',');
+                string[] HBillNo = new string[HInterIDs.Length];
                 DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill();
 
                 //鑾峰彇绯荤粺鍙傛暟
                 string Ret = "";
                 oSystemParameter.ShowBill(ref Ret);
 
-                    for (int i = 0; i < HBillNo.Length; i++)
+                    for (int i = 0; i < HInterIDs.Length; i++)
                 {
-                    if (long.Parse(HBillNo[i]) == 0)
+                    if (long.Parse(HInterIDs[i]) == 0)
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
@@ -2592,7 +2724,7 @@
                     }
 
                     //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
-                    if (oBill.ShowBill(long.Parse(HBillNo[i]), ref DBUtility.ClsPub.sExeReturnInfo))
+                    if (oBill.ShowBill(long.Parse(HInterIDs[i]), ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         if (oBill.omodel.HChecker.Trim() == "")
                         {
@@ -2615,6 +2747,8 @@
                                 return objJsonResult;
                             }
                         }
+
+                        HBillNo[i] = oBill.omodel.HBillNo;
                     }
                     else
                     {
@@ -2627,10 +2761,31 @@
                 }
 
                 int j = 0;
-                for (int i = 0; i < HBillNo.Length; i++)
+                for (int i = 0; i < HInterIDs.Length; i++)
                 {
+                    //鍙嶅鏍稿墠鎺у埗
+                    string sql = "exec h_p_Sc_StationOutBill_BeforeUnCheckCtrl " + HInterIDs[i] + ",'" + HBillNo[i] + "','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_BeforeUnCheckCtrl");
+                    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;
+
+                    }
+                    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;
+                    }
+
                     //鍙嶅鏍�
-                    if (Cj_StationOutBillAbandonCheckBill(long.Parse(HBillNo[i]), CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo))
+                    if (Cj_StationOutBillAbandonCheckBill(long.Parse(HInterIDs[i]),HBillNo[i], CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         j += 1;
                     }
@@ -2661,7 +2816,7 @@
         }
 
         //鍙嶅鏍�
-        public bool Cj_StationOutBillAbandonCheckBill(Int64 lngBillKey, string CurUserName, bool HLastSubProc, ref string sReturn)
+        public bool Cj_StationOutBillAbandonCheckBill(Int64 lngBillKey,string HBillNo, string CurUserName, bool HLastSubProc, ref string sReturn)
         {
             if (Cj_StationInBillisUse(lngBillKey, ref sReturn))
             {
@@ -2694,6 +2849,23 @@
                 else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "鏄�")
                 {
                 }
+
+                //鍙嶅鏍稿悗鎺у埗
+                string sql = "exec h_p_Sc_StationOutBill_AfterUnCheckCtrl " + lngBillKey + ",'" + HBillNo + "','" + CurUserName + "'";
+                ds = oCN.RunProcReturn(sql, "h_p_Sc_StationOutBill_AfterUnCheckCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍙嶅鏍歌繃绋嬩腑鍑洪敊锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    oCN.RollBack();
+                    return false;
+                }
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
+                    oCN.RollBack();
+                    return false;
+                }
+
                 sReturn = sReturn + "鍙嶅鏍稿姛鑳斤紒";
                 oCN.Commit();
                 return true;

--
Gitblit v1.9.1