From 7a9041cfac9be9f0c094a00470ffdb4b46025345 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期日, 28 九月 2025 17:01:56 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/CJGL/Cj_SingleStationController.cs |  288 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 205 insertions(+), 83 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
index f92698d..e4ae986 100644
--- a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -171,6 +171,7 @@
                 long HMainSourceEntryID = mainList[0].HICMOEntryID;
                 string HMainSourceBillNo = mainList[0].HICMOBillNo;
 
+                //鍒ゆ柇鐢熶骇璐ㄩ噺姹囨姤鍗曟槸鍚﹀瓨鍦�
                 ds = oCN.RunProcReturn("select * from Sc_QualityReportBillMain WITH(NOLOCK) where HInterID=" + HInterID + " and HBillNo='" + HBillNo + "'", "Sc_QualityReportBillMain");
                 if (ds.Tables[0].Rows.Count != 0) {
                     objJsonResult.code = "0";
@@ -370,15 +371,21 @@
                 {
                     if (oSystemParameter.omodel.WMS_CampanyName == "鏉窞鏂帿灏�")
                     {
+                       
                         //鍒ゆ柇褰撳墠娴佽浆鍗℃槸鍚︽槸寮�宸�
                         ds = oCN.RunProcReturn("select  * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0'", "Sc_ICMOBillStatus_Tmp");
                         if (ds.Tables[0].Rows.Count == 0)
                         {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "[3791-2-018]鍗″彿:" + HBarCode + ",娴佽浆鍗℃湭寮�宸�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            //鍒ゆ柇褰撳墠娴佽浆鍗℃槸鍚﹀ⅷ瑗垮摜鐨�
+                            ds = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain");
+                            if (ds.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[3791-2-018]鍗″彿:" + HBarCode + ",娴佽浆鍗℃湭寮�宸�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }                                                 
                         }
                     }
                 }
@@ -460,7 +467,8 @@
                 List<Model.Sc_AssemblyBill_BindSourceTemp> tempList = new List<Model.Sc_AssemblyBill_BindSourceTemp>();
                 tempList = JsonConvert.DeserializeObject<List<Model.Sc_AssemblyBill_BindSourceTemp>>(msg1);
 
-                if (tempList.Count == 0) {
+                if (msg1 != "[]" && tempList.Count == 0)
+                {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "[3791-2-026]鏃犻厤浠舵暟鎹�!";
@@ -544,8 +552,8 @@
                 List<Model.ClsSc_AssemblyBillSub> sub = new List<Model.ClsSc_AssemblyBillSub>();
                 sub = JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillSub>>(sSubStr);
 
-
-                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + omodel.HBarCode_P + "'," + omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
+                //鏉$爜涓婇亾宸ュ簭鏄惁杩囩珯
+                ds = oCN.RunProcReturn("exec h_p_Sc_SNBarcodeProcCtrl_S '" + omodel.HBarCode_P + "'," + omodel.HProcID, "h_p_Sc_SNBarcodeProcCtrl_S");
                 if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
                 {
                     objJsonResult.code = "0";
@@ -563,6 +571,7 @@
                     return objJsonResult;
                 }
 
+                //鍒ゆ柇鏉$爜鏄惁宸茬粡鍑虹珯
                 ds = oCN.RunProcReturn("select  * from h_v_Gy_QualifiedRecordsList WITH(NOLOCK) where 浜у搧鏉$爜='" + omodel.HBarCode_P + "' and HProcExchInterID="+ omodel .HProcExchInterID+ " and HProcExchEntryID="+ omodel.HProcExchEntryID + " and HProcID="+ omodel.HProcID, "h_v_Gy_QualifiedRecordsList");
 
                 if (ds.Tables[0].Rows.Count > 0)
@@ -602,26 +611,44 @@
                     {
                         Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo);
                         string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true);
-                        //淇濆瓨鐢熶骇缁勮鍗曚富琛�
-                        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})";
+                        string prefix = omodel.HBarCode_P.Substring(0, 10); // 浠庣储寮�0寮�濮嬶紝鎴彇10涓瓧绗� 鍒ゆ柇姣忎釜椤圭洰鐨凮鏄熷湀閰嶄欢鏁伴噺
+                        
+                            //淇濆瓨鐢熶骇缁勮鍗曚富琛�
+                         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);
-
-                        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);
+                        if (prefix == "#0TE911124") {
+                            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);
+                            }
                         }
+                        else
+                        {
+                            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);
+                            }
+                        }
+                        
                     }
 
                 }
@@ -705,11 +732,13 @@
                 int HTemporaryAreaID = 0;//鏆傛斁鍖�
                 int HShiftsID = 0;
 
+                //鑾峰彇褰撳墠鐝
                 DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + HDeptID + "," + HCenterID, "h_p_Gy_GetWorkShiftInfo");
                 if (set.Tables[0].Rows.Count > 0)
                 {
                     HShiftsID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString());
                 }
+                //鍒ゆ柇褰撳ぉ褰撳墠鐨勬祦杞崱鏄惁鏈夊嚭绔欏崟
                 ds = oCN.RunProcReturn("select  * from Sc_StationOutBillMain a WITH(NOLOCK) left join  Sc_StationOutBillSub_SN sn WITH(NOLOCK) on a.HInterID=sn.HInterID where a.HInterID=" + HInterID + " and HBillNo='" + HBillNo + "' and CONVERT(varchar(10),HDate,20) ='" + DateTime.Now.ToString("yyyy-MM-dd") + "' ", "Sc_StationOutBillMain");
 
                 if (ds.Tables[0].Rows.Count == 0)
@@ -744,7 +773,7 @@
                 ds = oCN.RunProcReturn("select  * from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + omodel.HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
 
                 oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
-values({HInterID}, '{HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{omodel.HBarCode_P}', 1, GETDATE(), '', " + HProcExchInterID + ","+ HProcExchEntryID + ", '"+ HProcExchBillNo + "', '', 0, 0)");
+                    values({HInterID}, '{HBillNo}', {(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)}, '{omodel.HBarCode_P}', 1, GETDATE(), '', " + HProcExchInterID + ","+ HProcExchEntryID + ", '"+ HProcExchBillNo + "', '', 0, 0)");
 
                 //鎶婃潯鐮佸啓鍏ユ棩蹇楅噷闈�
                 LogService.CustomWriteLog("鏉$爜:" + omodel.HBarCode_P + ",宸ュ簭:"+ HProcID + ",鍑虹珯鏃堕棿:" + DateTime.Now, "TM" + DateTime.Now.ToString("yyyy-MM-dd"));
@@ -754,9 +783,9 @@
 
 
                 ds = oCN.RunProcReturn($@"select (b.HQty -sum(isnull(ou.HQty,0))-sum(isnull(ou.HBadCount,0))) HQty from Sc_ProcessExchangeBillSub b WITH(NOLOCK)
-left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
-where b.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
-group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
+                            left join Sc_StationOutBillMain ou WITH(NOLOCK) on b.HInterID=ou.HProcExchInterID and b.HEntryID=ou.HProcExchEntryID
+                            where b.HInterID={HProcExchInterID} and b.HEntryID={HProcExchEntryID}
+                            group by b.HInterID,b.HEntryID,b.HQty", "Sc_ProcessExchangeBill_Out");
 
                 if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) < 0) {
                     oCN.RollBack();
@@ -795,6 +824,7 @@
         {
             try
             {
+                string str1 = "";
                 ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "h_v_Gy_BarCodeBill");
 
                 //鍒ゆ柇鏉$爜鏄惁瀛樺湪鏉$爜妗f
@@ -818,21 +848,21 @@
                     //鍒ゆ柇闀垮害鏄惁涓�29浣� 鏃犲皹杞﹂棿
                     if (HBarCode.Length == 29)
                     {
-                        string str1 = HBarCode.Substring(18, 8);
+                        str1 = HBarCode.Substring(18, 8);
 
                         DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
-where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+                        left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                        left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                        where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
 
                         if (dataSet.Tables[0].Rows.Count == 0)
                         {
                             str1 = HBarCode.Substring(23, 3);
 
                             dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
-where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
 
                             if (dataSet.Tables[0].Rows.Count == 0)
                             {
@@ -856,30 +886,61 @@
                             return get_HBardBillSave(HProcExchBillNo, HBarCode);
                         }
                     }
-                    //鍒ゆ柇闀垮害鏄惁涓�50浣�  15杞﹂棿
+                    //鍒ゆ柇闀垮害鏄惁涓�50浣�  15杞﹂棿 鍜� O6椤圭洰
                     else if (HBarCode.Length == 50)
                     {
-                        string str1 = HBarCode.Substring(42, 8);
-
-                        DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
-where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
-
-                        if (dataSet.Tables[0].Rows.Count == 0)
+                        string prefix = HBarCode.Substring(0, 10); // 浠庣储寮�0寮�濮嬶紝鎴彇10涓瓧绗�
+                        if (prefix == "#0TE911124")
                         {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "[3791-2-016]鏉$爜涓庢祦杞崱涓嶅瓨鍦ㄥ搴斿叧绯�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            str1 = HBarCode.Substring(41, 3);
+                            LogService.Write($"鏉$爜鍓嶇紑" + str1);
+
+                            DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+
+                            if (dataSet.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[3791-2-016]鏉$爜涓庢祦杞崱涓嶅瓨鍦ㄥ搴斿叧绯�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                ClsPub.CurUserName = user;
+                                //鏉$爜鐢熸垚
+                                return get_HBardBillSave(HProcExchBillNo, HBarCode);
+                            }
                         }
                         else
                         {
-                            ClsPub.CurUserName = user;
-                            //鏉$爜鐢熸垚
-                            return get_HBardBillSave(HProcExchBillNo, HBarCode);
+                          
+                            str1 = HBarCode.Substring(42, 8);
+                            LogService.Write($"鏉$爜鍓嶇紑1.1" + str1);
+                            DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+
+                            if (dataSet.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[3791-2-016]鏉$爜涓庢祦杞崱涓嶅瓨鍦ㄥ搴斿叧绯�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                            else
+                            {
+                                ClsPub.CurUserName = user;
+                                //鏉$爜鐢熸垚
+                                return get_HBardBillSave(HProcExchBillNo, HBarCode);
+                            }
                         }
+
                     }
                     else
                     {
@@ -890,25 +951,26 @@
                         return objJsonResult;
                     }
                 }
-                else {
+                else 
+                {
                     //鍒ゆ柇闀垮害鏄惁涓�29浣� 鏃犲皹杞﹂棿
                     if (HBarCode.Length == 29)
                     {
-                        string str1 = HBarCode.Substring(18, 8);
+                        str1 = HBarCode.Substring(18, 8);
 
                         DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
-where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+                        left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                        left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                        where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
 
                         if (dataSet.Tables[0].Rows.Count == 0)
                         {
                             str1 = HBarCode.Substring(23, 3);
 
                             dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
-where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
 
                             if (dataSet.Tables[0].Rows.Count == 0)
                             {
@@ -920,24 +982,47 @@
                             }
                         }
                     }
-                    //鍒ゆ柇闀垮害鏄惁涓�50浣�  15杞﹂棿
+                    //鍒ゆ柇闀垮害鏄惁涓�50浣�  15杞﹂棿  鍜� O6椤圭洰
                     else if (HBarCode.Length == 50)
                     {
-                        string str1 = HBarCode.Substring(42, 8);
-
-                        DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
-where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
-
-                        if (dataSet.Tables[0].Rows.Count == 0)
+                        string prefix = HBarCode.Substring(0, 10); // 浠庣储寮�0寮�濮嬶紝鎴彇10涓瓧绗�
+                        if (prefix == "#0TE911124")
                         {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "[3791-2-016]鏉$爜涓庢祦杞崱涓嶅瓨鍦ㄥ搴斿叧绯�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
+                            str1 = HBarCode.Substring(41, 3);
+                            LogService.Write($"鏉$爜鍓嶇紑" + str1);
+                            DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+
+                            if (dataSet.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[3791-2-016]鏉$爜涓庢祦杞崱涓嶅瓨鍦ㄥ搴斿叧绯�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
                         }
+                        else
+                        {
+                            str1 = HBarCode.Substring(42, 8);
+
+                            DataSet dataSet = oCN.RunProcReturn(@"select  m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
+                            left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                            left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID 
+                            where HBillNo='" + HProcExchBillNo + "' and HProjectNum like'" + str1 + "%' and HPRDORGID=" + HOrgID, "Sc_ProcessExchangeBillMain");
+
+                            if (dataSet.Tables[0].Rows.Count == 0)
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "[3791-2-016]鏉$爜涓庢祦杞崱涓嶅瓨鍦ㄥ搴斿叧绯�!";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
+
                     }
 
                     if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "")
@@ -972,10 +1057,10 @@
             {
                 //鏌ヨ娴佽浆鍗℃暟鎹�
                 DataSet dataSet = oCN.RunProcReturn(@"select  a.HPRDORGID, m.HModel 鐗╂枡瑙勬牸,m.HName 鍚嶇墿鏂欑О,a.HBillNo,a.HInterID,a.HMaterID,m.HNumber 鐗╂枡浠g爜,o.HNumber 缁勭粐浠g爜,a.HUnitID,u.HNumber 鍗曚綅浠g爜 from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
-left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
-left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
-left join Gy_Unit u WITH(NOLOCK) on a.HUnitID=u.HItemID 
-where HBillNo='" + HProcExchBillNo + "'", "Sc_ProcessExchangeBillMain");
+                left join Gy_Material m WITH(NOLOCK) on a.HMaterID=m.HItemID
+                left join Xt_ORGANIZATIONS o WITH(NOLOCK) on a.HPRDORGID=o.HItemID
+                left join Gy_Unit u WITH(NOLOCK) on a.HUnitID=u.HItemID 
+                where HBillNo='" + HProcExchBillNo + "'", "Sc_ProcessExchangeBillMain");
 
                 string HMaterNumber = dataSet.Tables[0].Rows[0]["鐗╂枡浠g爜"].ToString();
                 string HOrgNumber = dataSet.Tables[0].Rows[0]["缁勭粐浠g爜"].ToString();
@@ -1164,6 +1249,7 @@
                 ds = oCN.RunProcReturn("select * from gy_czygl WITH(NOLOCK) where czymc='" + user + "'", "gy_czygl");
                 string HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString();
 
+                //鏌ヨ娴佽浆鍗℃墍鏈夊伐搴忎俊鎭�
                 ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBillHICOMProcessExchange WITH(NOLOCK) where 鏉$爜='" + HBarCode + "' ", "h_v_Gy_BarCodeBillHICOMProcessExchange");
 
                 if (ds.Tables[0].Rows.Count == 0)
@@ -1638,7 +1724,7 @@
 
                     Model.Sc_AssemblyBill_BindSourceTemp temp = new Model.Sc_AssemblyBill_BindSourceTemp();
                     temp = JsonConvert.DeserializeObject<Model.Sc_AssemblyBill_BindSourceTemp>(sSubStr);
-
+                    //宸ュ簭杩斾慨璁板綍鍗� 閰嶄欢琛�
                     ds = oCN.RunProcReturn("select * from Sc_SourceLineRepairBillSub_Mater where HInterID=" + model.HInterID+ " order by HEntryID  desc", "Sc_SourceLineRepairBillSub_Mater");
 
                     oCN.RunProc($@"insert into Sc_SourceLineRepairBillSub_Mater
@@ -1652,7 +1738,7 @@
                     oCN.RunProc("update Sc_AssemblyBillSub set HBarCode='" + temp.HBarCode + "' where HInterID=" + temp.HInterID + " and HEntryID=" + temp.HEntryID);
                     //oCN.RunProc("exec h_p_AssemblyBill_Temp '" + temp.HProcExchBillNo + "'," + model.HProcess + "," + temp.HMaterID + ",'" + temp.HBatchNo + "'");
                 }
-                else if (HResult == "NG"|| HResult == "OK") {
+                else if (HResult == "NG"|| HResult == "OK") { 
                     Model.ClsSc_SourceLineRepairBillMain model = new Model.ClsSc_SourceLineRepairBillMain();
                     model = JsonConvert.DeserializeObject<Model.ClsSc_SourceLineRepairBillMain>(sMainStr);
 
@@ -1701,7 +1787,7 @@
                         if (dataSet.Tables[0].Rows.Count > 0)
                         {
                             string HOutInterID = dataSet.Tables[0].Rows[0][0].ToString();
-                            //鏂帿灏旂殑鎯呭喌 鍒� 宸ュ簾鏂欏簾 杩斿伐
+                            //鏂帿灏旂殑鎯呭喌 鍒� 宸ュ簾 鏂欏簾 杩斿伐
                             //宸ュ簾
                             if (subLsit[0].HBadTypeID == 3)
                             {
@@ -2164,6 +2250,7 @@
 
                 List<object> columnNameList = new List<object>();
 
+                //鏌ヨ閰嶄欢娓呭崟淇℃伅
                 string sql = @"exec h_p_GZ_BarCodeBillList '" + HMaterNumber + "','" + HBatchNo + "','" + sWhere + "'";
                 ds = oCN.RunProcReturn(sql, "h_p_GZ_BarCodeBillList");
 
@@ -2314,5 +2401,40 @@
         }
         #endregion
 
+        #region 宸ュ簭鍗曞搧杩囩珯 鏌ヨ褰撳墠娴佽浆鍗℃槸鍚︽湁宸叉湁鍑虹珯鍗� 鑾峰彇id 鍗曟嵁鍙�
+        [Route("Cj_SingleStation/SingleItemTransit_CZD")]
+        [HttpGet]
+        public object SingleItemTransit_CZD(string sWhere)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                ds = oCN.RunProcReturn(sWhere, "WindowPrint");               
+                
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-037]Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                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
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1