From 28161a2db7a593c30ca53e5c1e59103cd7591fe7 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期一, 27 四月 2026 09:47:32 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/CJGL/Cj_SingleStationController.cs |  188 ++++++++++++++++++++++++++++++----------------
 1 files changed, 123 insertions(+), 65 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
index f181774..c2b50e0 100644
--- a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -376,30 +376,33 @@
                 {
                     if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
                     {
-                       
-                        //鍒ゆ柇褰撳墠娴佽浆鍗� 褰撳墠宸ュ簭鏄惁鏄紑宸�
-                        ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0' and HProcID='"+ HProcID + "'", "Sc_ICMOBillStatus_Tmp");
-                        //鏌ヤ笉鍒拌瘉鏄庢病鏈夊紑宸ヨ繘鍏ヤ笅涓�鍙ユ煡璇�
-                        if (ds.Tables[0].Rows.Count == 0)
+                        if (HProcID == "90")  //娓呮磥宸ュ簭杩涘叆鑷姩寮�宸ユā寮�
                         {
-                            //鍒ゆ柇褰撳墠娴佽浆鍗℃槸鍚﹀ⅷ瑗垮摜鐨�
-                            ds2 = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain");
-                            if (ds2.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152")
+                            //鍒ゆ柇褰撳墠娴佽浆鍗� 褰撳墠宸ュ簭鏄惁鏄紑宸�
+                            ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0' and HProcID='" + HProcID + "'", "Sc_ICMOBillStatus_Tmp");
+                            //鏌ヤ笉鍒拌瘉鏄庢病鏈夊紑宸ヨ繘鍏ヤ笅涓�鍙ユ煡璇�
+                            if (ds.Tables[0].Rows.Count == 0)
                             {
-                                //鑾峰彇鐢熶骇鐘舵�佷复鏃惰〃鏁版嵁
-                                ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HProcID='" + HProcID + "'", "Sc_ICMOBillStatus_Tmp");
-                                //浼犲叆 鐢熶骇鐘舵�佷复鏃惰ˉ 鍗曟嵁绫诲瀷銆佷富id銆佹簮鍗曞瓙ID銆佹簮鍗曞崟鍙枫�佸綋鍓嶇櫥褰曚汉銆佹簮鍗曞崟鎹被鍨�
-                                objJsonResult = SaveMESBeginWorkFrom_ZD(ds.Tables[0].Rows[0]["HBillType"].ToString(),ds.Tables[0].Rows[0]["HInterID"].ToString(), ds.Tables[0].Rows[0]["HSourceEntryID"].ToString(), ds.Tables[0].Rows[0]["HSourceBillNo"].ToString(),user, ds.Tables[0].Rows[0]["HSourceBillType"].ToString());
-                                if (objJsonResult.code == "0")
+                                //鍒ゆ柇褰撳墠娴佽浆鍗℃槸鍚﹀ⅷ瑗垮摜鐨�
+                                ds2 = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain");
+                                if (ds2.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152")
                                 {
-                                    objJsonResult.code = "0";
-                                    objJsonResult.count = 0;
-                                    objJsonResult.Message = objJsonResult.Message;
-                                    objJsonResult.data = null;
-                                    return objJsonResult;
+                                    //鑾峰彇鐢熶骇鐘舵�佷复鏃惰〃鏁版嵁
+                                    ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HProcID='" + HProcID + "'", "Sc_ICMOBillStatus_Tmp");
+                                    //浼犲叆 鐢熶骇鐘舵�佷复鏃惰ˉ 鍗曟嵁绫诲瀷銆佷富id銆佹簮鍗曞瓙ID銆佹簮鍗曞崟鍙枫�佸綋鍓嶇櫥褰曚汉銆佹簮鍗曞崟鎹被鍨�
+                                    objJsonResult = SaveMESBeginWorkFrom_ZD(ds.Tables[0].Rows[0]["HBillType"].ToString(), ds.Tables[0].Rows[0]["HInterID"].ToString(), ds.Tables[0].Rows[0]["HSourceEntryID"].ToString(), ds.Tables[0].Rows[0]["HSourceBillNo"].ToString(), user, ds.Tables[0].Rows[0]["HSourceBillType"].ToString());
+                                    if (objJsonResult.code == "0")
+                                    {
+                                        objJsonResult.code = "0";
+                                        objJsonResult.count = 0;
+                                        objJsonResult.Message = objJsonResult.Message;
+                                        objJsonResult.data = null;
+                                        return objJsonResult;
+                                    }
                                 }
-                            }                                                 
-                        }   
+                            }
+                        }
+                        
                     }
                 }
 
@@ -432,10 +435,26 @@
                 }
                 else
                 {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "[0000-1-037]";
-                    objJsonResult.data = ds.Tables[0];
+                    if (HProcID == "90" || HProcID== "102")
+                    {
+                        DataSet dataSet = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList2 '" + HBarCode + "'," + HProcID, "h_p_Sc_ProcessExchangeBillList2");
+                        if (dataSet.Tables[0].Rows.Count > 0)
+                        {
+                            objJsonResult.code = "2";
+                            objJsonResult.count = 2;
+                            objJsonResult.Message = "[0000-1-037]";
+                            objJsonResult.data = dataSet.Tables[0];
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "[0000-1-037]";
+                        objJsonResult.data = ds.Tables[0];
+                    }
+                    
                 }
 
                 return objJsonResult;
@@ -512,7 +531,7 @@
                     "(HInterID,HEntryID,HBillNo_bak,HSourceBillNo,HSourceInterID,HSourceEntryID,HMaterID" +
                     ",HProdOrgID,HSourceBillType,HAuxPropID,HProcID,HQty,HBatchNo,HBarCode,HMTONo,HPlanMode) " +
                     " values(" + HInterID + "," + (i + 1) + ",'" + HBillNo + "','" + tempList[i].HProcExchBillNo + "'," + tempList[i].HProcExchInterID + "," + tempList[i].HProcExchEntryID + "," + tempList[i].HMaterID +
-                    ",'" + HOrgID + "','',0," + HProcID + "," + tempList[i].HQty + ",'"+ tempList[i].HBatchNo + "','" + tempList[i].HBarCode + "','','') ");
+                    ",'" + HOrgID + "','',0," + tempList[i].HProcID + "," + tempList[i].HQty + ",'"+ tempList[i].HBatchNo + "','" + tempList[i].HBarCode + "','','') ");
                 }
 
                 oCN.Commit();
@@ -600,72 +619,76 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-
-                //澧炲姞浜х嚎缁勮杩芥函鍗�
-                DataSet ds1 = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + omodel.HProcExchBillNo + "'," + omodel.HProcID, "h_p_Gy_BarCodeBillBomList");
-                if (ds1.Tables[0].Rows.Count > 0)
+                if (omodel.HProcID!=90)//鏂帿灏旀媿鐓ф竻娲佸伐搴忚繃婊�
                 {
-                    //鍒ら厤浠舵暟閲忔槸鍚︾瓑浜�0
-                    for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
+                    //澧炲姞浜х嚎缁勮杩芥函鍗�
+                    DataSet ds1 = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + omodel.HProcExchBillNo + "'," + omodel.HProcID, "h_p_Gy_BarCodeBillBomList");
+                    if (ds1.Tables[0].Rows.Count > 0)
                     {
-                        double SYHQty = double.Parse(ds1.Tables[0].Rows[i]["閰嶄欢鏁伴噺"].ToString());
-                        string HMaterNamePJ = ds1.Tables[0].Rows[i]["閰嶄欢浠g爜"].ToString();
-                        if (SYHQty == 0)
+                        //鍒ら厤浠舵暟閲忔槸鍚︾瓑浜�0
+                        for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                         {
-                            oCN.RollBack();
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "[3791-2-020]閰嶄欢浠g爜:" + HMaterNamePJ + ",鏁伴噺涓�0!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            double SYHQty = double.Parse(ds1.Tables[0].Rows[i]["閰嶄欢鏁伴噺"].ToString());
+                            string HMaterNamePJ = ds1.Tables[0].Rows[i]["閰嶄欢浠g爜"].ToString();
+                            if (SYHQty == 0)
+                            {
+                                oCN.RollBack();
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[3791-2-020]閰嶄欢浠g爜:" + HMaterNamePJ + ",鏁伴噺涓�0!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
                         }
-                    }
 
 
-                    ds1 = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID =" + omodel.HProcExchInterID + " and HMainSourceEntryID =" + omodel.HProcExchEntryID + " and HBarCode_P = '" + omodel.HBarCode_P + "'", "Sc_AssemblyBillMain");
+                        ds1 = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID =" + omodel.HProcExchInterID + " and HMainSourceEntryID =" + omodel.HProcExchEntryID + " and HBarCode_P = '" + omodel.HBarCode_P + "'", "Sc_AssemblyBillMain");
 
-                    if (ds1.Tables[0].Rows.Count == 0)
-                    {
-                        Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
-                        string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
-                        string prefix = omodel.HBarCode_P.Substring(0, 10); // 浠庣储寮�0寮�濮嬶紝鎴彇10涓瓧绗� 鍒ゆ柇姣忎釜椤圭洰鐨凮鏄熷湀閰嶄欢鏁伴噺
-                        
+                        if (ds1.Tables[0].Rows.Count == 0)
+                        {
+                            Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
+                            string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
+                            string prefix = omodel.HBarCode_P.Substring(0, 10); // 浠庣储寮�0寮�濮嬶紝鎴彇10涓瓧绗� 鍒ゆ柇姣忎釜椤圭洰鐨凮鏄熷湀閰嶄欢鏁伴噺
+
                             //淇濆瓨鐢熶骇缁勮鍗曚富琛�
-                         string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate
+                            string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate
                         ,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo
                         ,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID)
                         values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{HInterID1},getdate()
                         ,'{HBillNo1}','1','{user}',getdate(),{omodel.HProcExchInterID.ToString()},{omodel.HProcExchEntryID.ToString()},'{omodel.HProcExchBillNo.ToString()}'
                         ,{omodel.HICMOInterID.ToString()},'{omodel.HICMOBillNo.ToString()}','{omodel.HBarCode_P.ToString()}',{omodel.HMaterID},0,'姹囨姤',{omodel.HProdOrgID})";
-                        oCN.RunProc(sql);
-                        if (prefix == "#0TE911124") {
-                            for (int i = 0; i < sub.Count; i++)
+                            oCN.RunProc(sql);
+                            if (prefix == "#0TE911124")
                             {
-                                //瀛愯〃瀛樺偍
-                             string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
+                                for (int i = 0; i < sub.Count; i++)
+                                {
+                                    //瀛愯〃瀛樺偍
+                                    string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
                             ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty
                             ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber)
                             values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,''
                             ,'',{sub[i].HMaterID},0,0,0,3
                             ,0,0,getdate(),'{sub[i].HBarCode}','{omodel.HBarCode_P}','') ";
-                                oCN.RunProc(sq2);
+                                    oCN.RunProc(sq2);
+                                }
                             }
-                        }
-                        else
-                        {
-                            for (int i = 0; i < sub.Count; i++)
+                            else
                             {
-                                //瀛愯〃瀛樺偍
-                                string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
+                                for (int i = 0; i < sub.Count; i++)
+                                {
+                                    //瀛愯〃瀛樺偍
+                                    string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo
                             ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty
                             ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber)
                             values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,''
                             ,'',{sub[i].HMaterID},0,0,0,1
                             ,0,0,getdate(),'{sub[i].HBarCode}','{omodel.HBarCode_P}','') ";
-                                oCN.RunProc(sq2);
+                                    oCN.RunProc(sq2);
+                                }
                             }
+
                         }
-                        
+
                     }
 
                 }
@@ -1354,6 +1377,41 @@
                 }
 
                 ds = oCN.RunProcReturn(@"exec h_p_Gy_BadRecordsList " + HProcExchInterID + "," + HProcExchEntryID, "h_p_Gy_BadRecordsList");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-037]";
+                objJsonResult.data = ds;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "[0000-1-010]娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        //鏍规嵁涓籭d+宸ュ簭鏌�
+        [Route("Cj_SingleStation/BadRecordsList2")]
+        [HttpGet]
+        public object BadRecordsList2(string HProcExchInterID, string HProcID, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                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;
+                }
+
+                ds = oCN.RunProcReturn(@"exec h_p_Gy_BadRecordsList2 " + HProcExchInterID + "," + HProcID, "h_p_Gy_BadRecordsList2");
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -3949,7 +4007,7 @@
         #region 瑙i櫎鍖呰鍏崇郴銆佹媶闄ょ墿鏂�(1:瑙i櫎鍖呰鍏崇郴锛�2.鎷嗛櫎鐗╂枡)
         [Route("Cj_SingleStation/DelRelation")]
         [HttpGet]
-        public object DelRelation(string HBarCodeIDs, Int64 HICMOInterID, Int64 HICMOEntryID, Int64 HProcID, Int64 HType, string user)
+        public object DelRelation(string HBarCodeIDs, Int64 HICMOInterID, Int64 HICMOEntryID, Int64 HProcID, Int64 HType, string user, string HUnBindMaterArr)
         {
             try
             {
@@ -3963,7 +4021,7 @@
                 }
                 else
                 {
-                    string sql = "exec h_p_Sc_DelbindBarRelation '" + HBarCodeIDs + "'," + HICMOInterID + "," + HICMOEntryID + "," + HProcID + "," + HType;
+                    string sql = "exec h_p_Sc_DelbindBarRelation '" + HBarCodeIDs + "'," + HICMOInterID + "," + HICMOEntryID + "," + HProcID + "," + HType + ",'" + HUnBindMaterArr + "'";
                     ds = oCN.RunProcReturn(sql, "h_p_Sc_DelbindBarRelation");
                 }
 

--
Gitblit v1.9.1