From 722ef8094b4357f01e08ff8984f679454aecf447 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期一, 25 三月 2024 13:12:19 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs |  240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 226 insertions(+), 14 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs b/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
index c59a0d6..18ab08f 100644
--- a/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
+++ b/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
@@ -838,9 +838,9 @@
         }
         #endregion
 
-        #region [妯″叿淇濆吇璁″垝鍗曞垹闄ゅ姛鑳絔
+        #region [宸ュ簭娴佽浆鍗″垹闄ゅ姛鑳絔
         /// <summary>
-        /// 妯″叿缁翠慨鍗曞垹闄ゅ姛鑳�
+        /// 宸ュ簭娴佽浆鍗″垹闄ゅ姛鑳�
         /// </summary>
         /// <returns></returns>
         [Route("Sc_ProcessExchangeBill/DeltetProcessExchangeBillByID")]
@@ -877,14 +877,15 @@
 
             DAL.ClsSc_ProcessExchangeBill oBill = new DAL.ClsSc_ProcessExchangeBill();
 
-            string[] HBillNo = HInterID.Split(',');
+            string[] HInterIDs = HInterID.Split(',');
+            string[] HBillNos = new string[HInterIDs.Length];
 
             string HBillNo_S = "";
 
-            foreach (var item in HBillNo)
+            for (int i = 0; i < HInterIDs.Length; i++)
             {
                 Int64 lngBillKey = 0;
-                lngBillKey = DBUtility.ClsPub.isLong(item);
+                lngBillKey = DBUtility.ClsPub.isLong(HInterIDs[i]);
 
                 DBUtility.ClsPub.HOrgID = HPRDORGID;
                 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
@@ -893,7 +894,7 @@
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "鍗曟嵁鍙�:"+ oBill .omodel.HBillNo+ "鍗曟嵁ID涓虹┖锛�";
+                        objJsonResult.Message = "鍗曟嵁鍙�:" + oBill.omodel.HBillNo + "鍗曟嵁ID涓虹┖锛�";
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
@@ -949,6 +950,7 @@
                         return objJsonResult;
                     }
                     HBillNo_S += oBill.omodel.HBillNo + ",";
+                    HBillNos[i] = oBill.omodel.HBillNo;
                 }
                 else
                 {
@@ -961,17 +963,18 @@
             }
 
             HBillNo_S = HBillNo_S.Substring(0, HBillNo_S.Length - 1);
-            LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鍒犻櫎宸ュ簭娴佽浆鍗″崟鎹�:" + HBillNo_S);
 
             oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鍒犻櫎宸ュ簭娴佽浆鍗″崟鎹細" + HBillNo_S + "','LMES-宸ュ簭娴佽浆鍗℃ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鍒犻櫎鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
 
-            foreach (var item in HBillNo)
+            for (int i = 0; i < HInterIDs.Length; i++)
             {
                 oCN.BeginTran();
-                if (HSouceBillType == "SUB") {
-                    ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HInterID=" + item, "Sc_ProcessExchangeBillMain");
+                if (HSouceBillType == "SUB")
+                {
+                    ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HInterID=" + HInterIDs[i], "Sc_ProcessExchangeBillMain");
 
-                    if (ds.Tables[0].Rows.Count == 0) {
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
                         oCN.RollBack();
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
@@ -983,7 +986,31 @@
                     oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=0 where HInterID=" + ds.Tables[0].Rows[0]["HMainSourceInterID"].ToString() + " and HEntryID=" + ds.Tables[0].Rows[0]["HMainSourceEntryID"].ToString());
                 }
 
-                bool IsDete = oBill.DeleteBill(long.Parse(item), ref DBUtility.ClsPub.sExeReturnInfo);
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Sc_ProcessExchangeBill_BeforeDelCtrl " + HInterIDs[i] + ",'" + HBillNos[i] + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Sc_ProcessExchangeBill_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;
+                    oCN.RollBack();
+                    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;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //==================================================================================      
+
+                bool IsDete = oBill.DeleteBill(long.Parse(HInterIDs[i]), HBillNos[i], "h_p_Sc_ProcessExchangeBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
 
                 if (!IsDete)
                 {
@@ -994,6 +1021,8 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+
                 oCN.Commit();
             }
 
@@ -1386,8 +1415,32 @@
                             return objJsonResult;
                         }
                     }
+
+                    //瀹℃牳鍓嶆帶鍒�
+                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                    sql = "exec h_p_Sc_ProcessExchangeBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcessExchangeBill_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 (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    if (!BillOld.CheckBill(Int64.Parse(HInterID), HBillNo, "h_p_Sc_ProcessExchangeBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 1;
@@ -1413,8 +1466,31 @@
                             return objJsonResult;
                         }
                     }
+
+                    //鍙嶅鏍稿墠鎺у埗
+                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                    sql = "exec h_p_Sc_ProcessExchangeBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcessExchangeBill_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 (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    if (BillOld.AbandonCheck(Int64.Parse(HInterID), HBillNo, "h_p_Sc_ProcessExchangeBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
                     {
                         //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                         //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl");
@@ -1579,6 +1655,142 @@
         }
         #endregion
 
+        #region 宸ュ簭娴佽浆鍗� 浣滃簾/鍙嶄綔搴�
+        /// <summary>
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param>
+        /// <param name="CurUserName">浣滃簾浜�</param>
+        /// <returns></returns>
+        [Route("Sc_ProcessExchangeBill/DeleteSc_ProcessExchangeBill")]
+        [HttpGet]
+        public object DeleteSc_ProcessExchangeBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Sc_ProcessExchangeBill_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.ClsSc_ProcessExchangeBill oBill = new DAL.ClsSc_ProcessExchangeBill();              //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                ////閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                //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 == 0)  //浣滃簾鍒ゆ柇
+                //    {
+                //        if (oBill.omodel.HDeleteMan.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;
+                //        }
+                //    }
+                //}
+                //else
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+
+                //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣�
+                if (IsAudit == 0) //浣滃簾鎻愪氦
+                {
+                    //浣滃簾鎻愪氦
+                    if (oBill.Cancelltion(lngBillKey, 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 == 1) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.AbandonCancelltion(lngBillKey, 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 鍗曟嵁鍙樻洿 椤甸潰鍒濆鍖�
         [Route("Sc_ProcessExchangeBill/GetProcessExchangeBillMain_Change_init")]

--
Gitblit v1.9.1