From aa51348d3501aa3a9bbda287929f3c8a05825063 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期三, 03 十二月 2025 18:14:31 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs |  292 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 273 insertions(+), 19 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index 36b375f..af1c550 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -292,7 +292,7 @@
                     //鍒ゆ柇褰撳墠宸ュ崟鏄惁寮�宸�
                     else if (oSystemParameter.omodel.MES_StationOutBill_MustBeginWorkCtl == "Y")
                     {
-                        ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceID = '" + HSourceID + "' and HICMOBillNo = '" + HICMOBillNo + "' and HInterID = '" + HICMOInterID + "' and hicmostatus =1", "Sc_ICMOBillStatus_Tmp");
+                        ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp with(nolock) where HSourceID = '" + HSourceID + "' and HICMOBillNo = '" + HICMOBillNo + "' and HInterID = '" + HICMOInterID + "' and hicmostatus =1", "Sc_ICMOBillStatus_Tmp");
                         if (ds.Tables[0].Rows[0]["HICMOStatus"].ToString() != "1")
                         {
                             objJsonResult.code = "0";
@@ -437,7 +437,7 @@
                 else if ("Modify".Equals(eventType))
                 {
                     num = 2;
-                    oCN.RunProc("UpDate Sc_StationOutBillMain set  " +
+                    oCN.RunProc("UpDate a set  " +
                     "HUpDater='" + HMaker + "'" +
                     ",HUpDateDate=getdate()" +
                     ",HSourceName='" + HSourceName + "'" +
@@ -479,6 +479,7 @@
                     //",HIsTimeFlag=" + HIsTimeFlag +
                     //",HRelBeginTime='" + HRelBeginTime + "'" +
                     //",HRelEndTime='" + HRelEndTime + "'" +
+                    " from Sc_StationOutBillMain a with(nolock)" +
                     " where HInterID=" + HInterID);
 
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼宸ュ簭鍑虹珯鍗曟嵁:" + HBillNo);
@@ -534,8 +535,8 @@
                 oCN.RunProc("exec h_p_Mes_StationOutBillBackBarCode  " + HInterID + " ");
                 LogService.Write($"7.瀛樺偍杩囩▼缁撴潫锛岀敤鏃�" + sw.Elapsed);
                 //鍒ゆ柇鏄惁鏄� 鏈亾宸ュ簭
-                ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a  " +
-                                    " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID  " +
+                ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a with(nolock) " +
+                                    " inner join Sc_ProcessExchangeBillSub b with(nolock) on a.HInterID=b.HInterID  " +
                                     " Where a.HInterID=" + HProcExchInterID + " and b.HEntryID=" + HProcExchEntryID + " ", "Sc_ProcessExchangeBillMain");
                 LogService.Write($"7.1.鏌ヨ锛岀敤鏃�" + sw.Elapsed);
                 //鍒ゆ柇鏄惁鏄柊澧�
@@ -632,6 +633,15 @@
                         objJsonResult.Verify = "N";
                     }
                 }
+                //鍒ゆ柇鏄惁鏄柊澧�
+                if ("Add".Equals(eventType))
+                {
+                    //鍒ゆ柇瀹㈡埛涓烘捣璇� 鍚屾閲戣澏宸ュ簭姹囨姤鍗�
+                    if (oSystemParameter.omodel.WMS_CampanyName == "娴疯瘹")
+                    {
+                        object objResult = set_SaveStationOutBill_CLD_Json(HInterID, HBillNo, user);
+                    }
+                }
                 sw.Stop();//缁撴潫璁℃椂
                 LogService.Write($"11.鍙傛暟鏌ヨ缁撴潫,鏂板缁撴潫锛岀敤鏃�" + sw.Elapsed);
                 LogService.Write("END--鍑虹珯鍗曟嵁淇濆瓨缁撴潫锛屽嚭绔欏崟鍙凤細" + HBillNo);
@@ -639,8 +649,8 @@
                 //娴嬭瘯璇彞===========================================================================================================
                 string msg_str = "";
                 string sql_str = "select a.HQty HQty_Main,b.HQty HQty_Sub " +
-                            "from Sc_ProcessExchangeBillMain as a " +
-                            "inner join Sc_ProcessExchangeBillSub as b on a.HInterID = b.HInterID " +
+                            "from Sc_ProcessExchangeBillMain as a with(nolock)" +
+                            "inner join Sc_ProcessExchangeBillSub as b with(nolock) on a.HInterID = b.HInterID " +
                             "where a.HInterID = " + HProcExchInterID;
                 DataSet ds_str = oCN.RunProcReturn(sql_str, "Sc_ProcessExchangeBillMain");
                 if (ds_str.Tables[0].Rows.Count > 0)
@@ -942,7 +952,7 @@
                 Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo);
                 string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true);
                 //鑾峰彇缁勭粐浠g爜
-                string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString();
+                string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS with(nolock) where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString();
                 //鏍规嵁宸ュ簭姹囨姤鍗曚富ID鑾峰彇宸ュ簭姹囨姤鍏ュ簱鍗曠殑鏁版嵁
                 DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc");
                 if (ds.Tables[0].Rows.Count <= 0)
@@ -957,7 +967,7 @@
 
                 //淇濆瓨
                 //oCN.BeginTran();
-                DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain where HBillNo='{HBillNo}'", "Sc_ICMOReportBillMain");
+                DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain with(nolock) where HBillNo='{HBillNo}'", "Sc_ICMOReportBillMain");
                 if (DsTable.Tables[0].Rows.Count > 0)
                 {
                     objJsonResult.code = "0";
@@ -1119,7 +1129,7 @@
                     return objJsonResult;
                 }
 
-                oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo + "'");
+                oCN.RunProc("update a set HRelationQty=1 from Sc_StationOutBillMain a with(nolock) where  HBillNo='" + BillNo + "'");
 
                 //oCN.Commit();
                 objJsonResult.code = "0";
@@ -1335,7 +1345,7 @@
                     return objJsonResult;
                 }
 
-                oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo + "'");
+                oCN.RunProc("update a set HRelationQty=1 from Sc_StationOutBillMain a with(nolock) where  HBillNo='" + BillNo + "'");
 
                 //oCN.Commit();
                 objJsonResult.code = "0";
@@ -1718,6 +1728,113 @@
                     string sql1 = "select * from h_v_MES_StationOutBillList where 1 = 1 ";
                     string sql = sql1 + sWhere+ "  order by hmainid desc";
                     ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-037]Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-038]Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 杩斿洖宸ュ簭鍑虹珯姹囨姤鍗曞垪琛�
+        [Route("Cj_StationOutBill/get_Display_Eng")]
+        [HttpGet]
+        public object get_Display_Eng(string sWhere, string user, string HBillSubType)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (HBillSubType == "SUB")
+                {
+                    //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                    if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Query", 1, false, user))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-1-068]瀹屽伐鍗曟棤鏌ヨ鏉冮檺!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                    if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-1-068]鍑虹珯鍗曟棤鏌ヨ鏉冮檺!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+
+                //鑾峰彇绯荤粺鍙傛暟
+                string Ret = "";
+                if (oSystemParameter.ShowBill(ref Ret))
+                {
+                    //鍒ゆ柇瀹㈡埛涓洪緳灞辨苯閰�
+                    if (oSystemParameter.omodel.WMS_CampanyName == "榫欏北姹介厤")
+                    {
+                        //鑾峰彇闇�瑕佹嫾鎺ョ殑瀛楃涓�
+                        string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "宸ュ簭姹囨姤鍗曞垪琛�");
+
+                        if (sql_splice == "娌℃湁鏌ヨ鍒扮浉鍏崇敤鎴蜂俊鎭�")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "[0000-1-069]娌℃湁鏌ヨ鍒扮浉鍏崇敤鎴蜂俊鎭�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            sWhere += sql_splice;
+                        }
+                    }
+                }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_Eng where 1 = 1" + sWhere + "order by hmainid desc", "h_v_MES_StationOutBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_MES_StationOutBillList_Eng where 1 = 1 ";
+                    string sql = sql1 + sWhere + "  order by hmainid desc";
+                    ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList_Eng");
                 }
 
                 //娣诲姞鍒楀悕
@@ -2645,6 +2762,143 @@
         }
         #endregion
 
+        #region 鏍规嵁id鍒犻櫎鍑虹珯鍗曞拰鍏抽敭浠舵竻鍗曡〃
+        [Route("Cj_StationOutBill/del_StationOutBillandAssemblyBill")]
+        [HttpGet]
+        public object del_StationOutBillandAssemblyBill(long HInterID, string HBarCode_P, string HDeleteMan, string HBillSubType)
+        {
+            try
+            {
+                string HComputerName = SystemInformation.ComputerName; //璁惧鍚嶇О
+                if (HBillSubType == "SUB")
+                {
+                    //缂栬緫鏉冮檺
+                    if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Drop", 1, false, HDeleteMan))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[3791-1-001]瀹屽伐鍗曟棤鏉冮檺锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    //缂栬緫鏉冮檺
+                    if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Drop", 1, false, HDeleteMan))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[3791-1-001]鍑虹珯鍗曟棤鏉冮檺锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill();
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    string sReturn = "";
+                    if (oSystemParameter.ShowBill(ref sReturn))
+                    {
+                        if (oSystemParameter.omodel.MES_StationOutBill_DeleteCtl == "Y")
+                        {
+                            if (oBill.omodel.HMaker != HDeleteMan && (HDeleteMan != "admin" && HDeleteMan != "Admin"))
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[0000-1-011]鍙兘鍒犻櫎鏈汉鐨勫崟鎹紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+                    }
+
+
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet ds;
+                    //鍒ゆ柇鏄惁瀛樺湪 鐩稿悓鍗曟嵁鍙� 鐨勯鏂欏崟 鍒ゆ柇鐢熶骇璁㈠崟鏄惁宸茬粨妗堬紝瑕佹眰璁″垝鎵嬪伐鍙嶇粨妗�    
+                    ds = oCn.RunProcReturn("exec h_p_MES_StationOutBill_DelCtrl  '" + oBill.omodel.HBillNo + "'", "h_p_MES_StationOutBill_DelCtrl");
+                    if (ds == null)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-2-018]鍒ゆ柇鍏宠仈澶辫触锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (ds.Tables[0].Rows.Count > 0 && Pub_Class.ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 2)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-1-007]" + Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[0000-1-013]鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    ds = oCn.RunProcReturn($"exec h_p_DelOutInBill {HInterID},'MES_StationOutBill_DeleteRelationCtl'", "h_p_DelOutInBill");
+
+                    if (ds.Tables[0].Rows[0][0].ToString() == "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "[3791-1-002]绯荤粺鍙傛暟鎺у埗,宸叉湁涓嬮亾宸ュ簭,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    oCn.BeginTran();
+
+                    ds = oCn.RunProcReturn($"select * from Sc_AssemblyBillMain  where HMainSourceInterID={oBill.omodel.HProcExchInterID} and HMainSourceEntryID={oBill.omodel.HProcExchEntryID} and HBarCode_P='{HBarCode_P}'", "Sc_AssemblyBillMain");
+
+                    if (ds.Tables[0].Rows.Count > 0)
+                    {
+                        oCn.RunProc($"delete from Sc_AssemblyBillMain  where HMainSourceInterID={oBill.omodel.HProcExchInterID} and HMainSourceEntryID={oBill.omodel.HProcExchEntryID} and HBarCode_P='{HBarCode_P}'");
+                        oCn.RunProc($"delete from Sc_AssemblyBillSub  where HInterID={ds.Tables[0].Rows[0]["HInterID"].ToString()} and HBarCode_P='{HBarCode_P}'");
+                    }
+
+                    oCn.RunProc("delete from Sc_StationOutBillSub_SN where HInterID=" + HInterID + " and HBarCode='" + HBarCode_P + "'");
+                    oCn.RunProc($"delete from Sc_StationOutBillMain  where HInterID={HInterID}");
+
+
+                    oCn.Commit();
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "[0000-1-008]鍒犻櫎鎴愬姛锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-005]鍗曟嵁鏈壘鍒帮紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-007]寮傚父锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 缂栬緫鍓嶅垽鏂�
         [Route("Cj_StationOutBill/set_ShowBillJudge")]
         [HttpGet]
@@ -2816,7 +3070,7 @@
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "[0000-1-025]鎴愬姛:" + j + "琛�,绗�" + (i + 1) + "琛�:瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
@@ -2846,21 +3100,21 @@
                 string HChecker = CurUserName;
                 string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
                 oCN.BeginTran();
-                ds = oCN.RunProcReturn("Select * from Sc_StationOutBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_StationOutBillMain");
+                ds = oCN.RunProcReturn("Select * from Sc_StationOutBillMain with(nolock) Where HInterID=" + lngBillKey.ToString(), "Sc_StationOutBillMain");
                 if (ds.Tables[0].Rows.Count == 0)
                 {
                     sReturn = "鍗曟嵁鏈壘鍒帮紒";
                     return false;
                 }
-                oCN.RunProc(" Update Sc_StationOutBillMain set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
+                oCN.RunProc(" Update a set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' from Sc_StationOutBillMain with(nolock) Where HInterID=" + lngBillKey.ToString());
                 oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Check_In " + lngBillKey.ToString() + ",1");
                 //鍒ゆ柇鏄惁鏄� 鏈亾宸ュ簭
                 DataSet ds1;
                 ds1 = oCN.RunProcReturn("select HLastProc,HFstProc " +
-                    " from Sc_ProcessExchangeBillMain a " +
-                    " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID " +
-                    " Where a.HInterID=(Select HProcExchInterID from Sc_StationOutBillMain Where HInterID=" + lngBillKey + ") " +
-                    " and b.HEntryID=(Select HProcExchEntryID from Sc_StationOutBillMain Where HInterID=" + lngBillKey + ")", "Sc_ProcessExchangeBillMain");
+                    " from Sc_ProcessExchangeBillMain a with(nolock)" +
+                    " inner join Sc_ProcessExchangeBillSub b with(nolock) on a.HInterID=b.HInterID " +
+                    " Where a.HInterID=(Select HProcExchInterID from Sc_StationOutBillMain with(nolock) Where HInterID=" + lngBillKey + ") " +
+                    " and b.HEntryID=(Select HProcExchEntryID from Sc_StationOutBillMain with(nolock) Where HInterID=" + lngBillKey + ")", "Sc_ProcessExchangeBillMain");
                 if (ds1 == null || ds1.Tables[0].Rows.Count == 0 || HLastSubProc ==false)
                 {
                 }
@@ -2868,8 +3122,8 @@
                 {
                 }
 
-                DataSet dataSet = oCN.RunProcReturn(@"select a.HProcExchBillNo,a.HQty,b.HQty HProcExchQty  from Sc_StationOutBillMain a
-inner join Sc_ProcessExchangeBillMain b on a.HProcExchInterID = b.HInterID
+                DataSet dataSet = oCN.RunProcReturn(@"select a.HProcExchBillNo,a.HQty,b.HQty HProcExchQty  from Sc_StationOutBillMain a with(nolock) 
+inner join Sc_ProcessExchangeBillMain b with(nolock) on a.HProcExchInterID = b.HInterID
 where a.HInterID = " + lngBillKey, "Sc_ProcessExchangeBillMain");
 
                 if (dataSet.Tables[0].Rows.Count > 0)

--
Gitblit v1.9.1