From 1acd793656c629f5b90190dc656cd1b269fa36b6 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 17 三月 2026 11:43:17 +0800
Subject: [PATCH] 合并分支

---
 WebAPI/Controllers/LMESController.cs |  134 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 116 insertions(+), 18 deletions(-)

diff --git a/WebAPI/Controllers/LMESController.cs b/WebAPI/Controllers/LMESController.cs
index 287eaf4..87c44d2 100644
--- a/WebAPI/Controllers/LMESController.cs
+++ b/WebAPI/Controllers/LMESController.cs
@@ -12,6 +12,8 @@
 using WebAPI.Models;
 using System.Web;
 using System.IO;
+using WebAPI.Controllers.SCGL;
+
 namespace WebAPI.Controllers
 {
     public class LMESController : ApiController
@@ -25,7 +27,6 @@
         //鑷畾涔�34杩涘埗鏁扮粍
         private static char[] lNCode = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
         string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
-
 
         #region 杩斿洖杩涚珯鎵弿鍒楄〃|宸ュ簭杩涚珯鎺ユ敹鍗曞垪琛� 
         [Route("LEMS/MES_StationInBillList_Json")]
@@ -856,11 +857,11 @@
                 // 鍙嶅簭鍒楀寲瀛愯〃鏁版嵁
                 var detailList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(msg3);
 
-                // 3. 寮�濮嬩簨鍔�
-                oCN.BeginTran();
-
                 foreach (var row in detailList)
                 {
+                    // 3. 寮�濮嬩簨鍔�
+                    oCN.BeginTran();
+                    DataSet ds2 = null;
                     // 鑾峰彇瀛愯〃瀛楁鍊�
                     string hSourceID = row.ContainsKey("HSourceID") ? row["HSourceID"] : "0";
                     string hMoldID = row.ContainsKey("HMoldID") ? row["HMoldID"] : "0";
@@ -870,8 +871,9 @@
                     if (hSourceID == "0" || hMoldID == "0")
                     {
                         continue;
-                    }
-
+                    }        
+                    //鏇存柊娴佽浆鍗″瓙琛ㄧ敓浜ц祫婧�
+                    oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=" + hSourceID + " where HInterID=" + hSourceInterID + " and HEntryID=" + hSourceEntryID);
                     // 鎻掑叆鐢熶骇鐘舵�佷复鏃惰〃
                     string SQL = $"exec h_p_Sc_ICMOBillStatus_Tmp_PGPL {hSourceInterID},{hSourceEntryID},{hSourceID},{hMoldID}";
                     oCN.RunProc(SQL);
@@ -884,16 +886,27 @@
                         if (oSystemParameter.omodel.WMS_CampanyName == "鍗庤垷")
                         {
                             oCN.RunProc("update Sc_ProcessExchangeBillMain set HMakeDate = GETDATE(),HRemark3='宸叉淳宸�',HMaker='" + msg4 + "' where HInterID = " + hSourceInterID);
+                            LogService.Write("鑷姩鐢熸垚宸ヤ綔鑱旂郴鍗�...");
 
                             //鑷姩鐢熸垚宸ヤ綔鑱旂郴鍗�
-                            oCN.RunProc("exec h_p_OA_WorkLinkBill_Create " + hSourceInterID + "," + 3772);
+                            ds2 = oCN.RunProcReturn("exec h_p_OA_WorkLinkBill_Create " + hSourceInterID + "," + 3772, "h_p_OA_WorkLinkBill_Create");
                         }
                     }
-                    
+                  
+
+                    // 7. 鎻愪氦浜嬪姟
+                    oCN.Commit();
+                    if (ds2 != null && ds2.Tables[0].Rows.Count > 0)
+                    {
+                        int HInterID = int.Parse(ds2.Tables[0].Rows[0]["NewHInterID"].ToString());
+                        LogService.Write("鎵ц娑堟伅鎺ㄩ��..." + HInterID);
+
+                        // 瑙﹀彂娑堟伅鎺ㄩ��
+                        Service.GeTuiService.PubishSingle(HInterID);
+                    }
                 }
 
-                // 7. 鎻愪氦浜嬪姟
-                oCN.Commit();
+
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -915,7 +928,7 @@
         #region 鍙栨秷娲惧伐鍔熻兘(鍗庤垷)
         [Route("LEMS/ProcessExchangeArrangementDel_PGHZ")]
         [HttpGet]
-        public object ProcessExchangeArrangementDel_PGHZ(string HInterID_S, int HSourceID, int HMouldID, string user)
+        public object ProcessExchangeArrangementDel_PGHZ(string HInterID_S, string user)
         {
             DataSet ds;
             DataSet ds1;
@@ -939,8 +952,9 @@
 
                     long HInterID = long.Parse(HNum[j].Split('|')[0]);
                     long HEntryID = long.Parse(HNum[j].Split('|')[1]);
-                    ds = oCN.RunProcReturn(@"select a.HMaterID,b.HProcID,a.HBillNo from Sc_ProcessExchangeBillMain a inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID 
-where a.HInterID=" + HInterID + " and b.HEntryID=" + HEntryID, "Sc_ProcessExchangeBillMain");
+                    long HSourceID = long.Parse(HNum[j].Split('|')[2]);
+                    ds = oCN.RunProcReturn(@"select a.HMaterID,b.HProcID,a.HBillNo from Sc_ProcessExchangeBillMain a inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID  where a.HInterID=" + HInterID + " and b.HEntryID=" + HEntryID, "Sc_ProcessExchangeBillMain");
+                    LogService.Write(1);
                     if (ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -949,9 +963,9 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-                    //鏍规嵁涓诲瓙ID+浜х嚎+妯″叿鏌ヨ鏄惁娲惧伐
-                    ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + "  and HSourceID=" + HSourceID + " and HMouldID=" + HMouldID, "Sc_ICMOBillStatus_Tmp");
-
+                    //鏍规嵁涓诲瓙ID+浜х嚎鏌ヨ鏄惁娲惧伐
+                    ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + "  and HSourceID=" + HSourceID , "Sc_ICMOBillStatus_Tmp");
+                    LogService.Write(2);
                     if (ds.Tables[0].Rows.Count == 0)
                     {
                         objJsonResult.code = "0";
@@ -960,9 +974,25 @@
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-
+                    LogService.Write(3);
                     oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=0 where HInterID=" + HInterID + " and HEntryID=" + HEntryID);
-                    oCN.RunProc("delete from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + " and HMouldID="+ HMouldID);
+                    LogService.Write(4);
+                    //鏇存柊鎺夊凡娲惧伐瀛楁
+                    oCN.RunProc("update Sc_ProcessExchangeBillMain set HRemark3='' where HInterID=" + HInterID);
+                    LogService.Write(5);
+                    oCN.RunProc("delete from Sc_ICMOBillStatus_Tmp where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + " and HSourceID=" + HSourceID);
+                    LogService.Write(6);
+                    //鏌ヨ鏄惁鏈夊嚭绔欏崟杩欎釜宸ュ崟杩欎釜浜х嚎
+                    ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HProcExchInterID=" + HInterID + " and HProcExchEntryID=" + HEntryID + " and HSourceID=" + HSourceID + "", "Sc_StationOutBillMain");
+                    LogService.Write(7);
+                    if (ds!=null && ds.Tables[0].Rows.Count == 0)
+                    {
+                        //娌℃湁鍑虹珯鍗曠殑杩涜鍒犻櫎宸ュ簭娴佽浆鍗℃淳宸ュ崟
+                        oCN.RunProc("delete from Sc_ProcExchSendWorkBillMain where HInterID=(select HInterID from Sc_ProcExchSendWorkBillSub where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + "  and HSourceID=" + HSourceID + " )");
+                        LogService.Write(8);
+                        oCN.RunProc("delete from Sc_ProcExchSendWorkBillSub where HSourceInterID=" + HInterID + " and HSourceEntryID=" + HEntryID + "  and HSourceID=" + HSourceID);
+                        LogService.Write(9);
+                    }
                 }
 
                 oCN.Commit();
@@ -2220,6 +2250,74 @@
             return GetObjectJson(ds);
         }
 
+        /// <summary>
+        /// 杩斿洖宸ュ簭娴佽浆鍗″垪琛�
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("LEMS/MES_Sc_ProcessExchangeBillList_Json")]
+        [HttpGet]
+        public object MES_Sc_ProcessExchangeBillList_Json(string sWhere, string user)
+        {
+            DataSet ds;
+            try
+            {
+                List<object> columnNameList = new List<object>()
+;                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBillQuery", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鑾峰彇绯荤粺鍙傛暟
+                string Ret = "";
+                if (oSystemParameter.ShowBill(ref Ret))
+                {
+                    //鍒ゆ柇瀹㈡埛涓洪緳灞辨苯閰�
+                    if (oSystemParameter.omodel.WMS_CampanyName == "榫欏北姹介厤")
+                    {
+                        //鑾峰彇闇�瑕佹嫾鎺ョ殑瀛楃涓�
+                        string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "鐢熶骇璁㈠崟鍒楄〃");
+
+                        sWhere += sql_splice;
+                    }
+                }
+
+                ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery where 1 = 1 " + sWhere + " order by 鍒跺崟鏃ユ湡 desc,鍗曟嵁鍙� desc", "h_v_Sc_ProcessExchangeBillQuery");
+                //娣诲姞鍒楀悕
+                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 = "Sucess锛�";
+                //objJsonResult.data = ds.Tables[0];
+                //objJsonResult.list = a;
+                //return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            return GetObjectJson(ds);
+        }
+
+
+
 
         #region 鐢熶骇璁㈠崟鍒楄〃-鍒嗛〉
         [Route("LEMS/MES_IF_ICMOBillList_Json_byPage")]

--
Gitblit v1.9.1