From 5e26af3b206b1ffee23c011c01b9e4af066d5b59 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 03 一月 2023 16:55:41 +0800
Subject: [PATCH] 点检规程

---
 WebAPI/Controllers/POStockInBillController.cs |  918 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 864 insertions(+), 54 deletions(-)

diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs
index 57446e2..b0bbedd 100644
--- a/WebAPI/Controllers/POStockInBillController.cs
+++ b/WebAPI/Controllers/POStockInBillController.cs
@@ -82,8 +82,7 @@
         {
             try
             {
-
-                var sJXCode = POStockInBillController.JX_Json(sCode, HOWNERID);
+                var sJXCode = POStockInBillController.JX_Json(sCode, sInterID, HBillType, HOWNERID, HBillNo, sMaker);
                 //if (sRedBlue == true)
                 //{
                 //    HBillType = "1239";
@@ -175,68 +174,681 @@
 
         [Route("kf_PoStockInBill/JX_Json")]
         [HttpGet]
-        public static string JX_Json(string sBarCodeNew, Int64 HOrgID)
+        public static string JX_Json(string sBarCodeNew, Int64 hinterid, string HBillType,Int64 HOrgID,string HBillNo,string HMaker)
         {
             try
             {
+                //1.鍒ゆ柇绯荤粺鍙傛暟鏄惁瀹夌憺  涓嶆槸瀹夌憺 鐩存帴璺虫帀
+                //濡傛灉鏄畨鐟�  璧颁笅闈�
+
+                //瑙f瀽鏉$爜
+                //濡傛灉鍦ㄦ潯鐮佹。妗堥噷闈�   涓嶅鐞�  娌℃湁鐨勮瘽 瀛樺叆鏉$爜妗f
+
+                //鏍规嵁瑙f瀽鐨勭墿鏂� +  鎵规  鍒ゆ柇 鏉$爜涓存椂琛�  璁板綍鏄惁瀛樺湪  娌℃湁鐨勮瘽  杩涜鎵簮鍗曠殑鍔ㄤ綔
+
+
                 //鍔犱簡  鐢熶骇鏃ユ湡  鏈夋晥鏈熻嚦   淇濊川鏈熸爣蹇�
 
-                string[] sArray = sBarCodeNew.Split('@');
-                string HMaterNumber = "";
-                HMaterNumber = sArray[0];
-                Int64 HQty = 0;
-                HQty = ClsPub.isInt(sArray[4]);
-                string HBarchNo = "";
-                HBarchNo = sArray[6];
-
-                DateTime HSCRQ = ClsPub.isDate(sArray[3]);
-                DateTime HYXQZ = ClsPub.isDate(sArray[5]);
-
-
-                Int64 HMaterID = 0;
-
-                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
-                DataSet Dss;
-                Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
-                string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
-
-                DataSet Dss1;
-                Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
-                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
-                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
-                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
-                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
-
+                Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+                //if (oSystemParameter.omodel.WMS_CampanyName == "瀹夌憺")
+                //{
                 string HTM = "";
-                HTM = HOrgNumber + HMaterID + HBarchNo;
-                string ModName = "85";
-                var  HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
-                Int64 HSupID = 0;
-                oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
-                                   ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
-                                   ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
-                                   ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
-                                   ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
-                                   ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
-                                   ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
-                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
-                                   ") values ("
-                                   + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
-                                   + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
-                                   + ", 0,0,'','',0"
-                                   + ", 0,'',0,0,0,''"
-                                   + ",0,'',''," + HSCRQ.ToShortDateString() + "," + HYXQZ.ToShortDateString() + ",'',getdate()"
-                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
-                                   + ",0,0,0"
-                                   + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                //閲囪喘鍏ュ簱
+                if (HBillType == "1201")
+                {
+                    string[] sArray = sBarCodeNew.Split('@');
+                    string HMaterNumber = "";
+                    HMaterNumber = sArray[0];
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sArray[4]);
+                    string HBarchNo = "";
+                    HBarchNo = sArray[6];
+
+                    DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                    DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                    //閲囪喘璁㈠崟鍙�
+                    string HPOOrderBillNo = "";
+                    HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
 
 
-                string sExpressNumber = "";
+
+                    Int64 HMaterID = 0;
+
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet Dss;
+                    Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                    DataSet Dss1;
+                    Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+                    
+                    HTM = HOrgNumber + HMaterID + HBarchNo;
+
+                    //濡傛灉鏉$爜妗f涓嶅瓨鍦�  杩涜瀛樺叆鏉$爜妗f鐨勫姩浣�
+                    //鏍规嵁鐗╂枡 + 鎵规  +   閲囪喘璁㈠崟鍙� 鎵惧埌瀵瑰簲鐨勬敹鏂欓�氱煡鍗曞彿
+                    DataSet Dss2;
+                    Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
+                    Int64 HSourceInterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["fid"]);
+                    Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FENTRYID"]);
+                    string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
+                    //鍒ゆ柇鏉$爜妗f鏄惁瀛樺湪璇ユ潯鐮�
+                    //濡傛灉瀛樺湪 鍐嶅垽鏂壂鐮佷复鏃惰〃鏄惁瀛樺湪璇ユ潯鐮�
+                    //濡傛灉涓嶅瓨鍦�  杩涜鎵簮鍗曠殑鏂规硶
+                    DataSet Dss5;
+                    Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                        DataSet Dss6;
+                        Dss6 = oCn.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss6.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            POStockInBillController POStockInBill = new POStockInBillController();
+                            POStockInBill.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", HSourceBillNo, hinterid, HBillNo);
+
+                        }
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','1103',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                        DataSet Dss7;
+                        Dss7 = oCn.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss7.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            POStockInBillController POStockInBill = new POStockInBillController();
+                            POStockInBill.set_SavePonderationBillMain_Temp_Source_Fast_Json("1103", HSourceBillNo, hinterid, HBillNo);
+
+                        }
+
+                    }
+                }
+                //浜у搧鍏ュ簱
+                if(HBillType == "1202")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year =  ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                    DataSet ds;
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    ds = oCN.RunProcReturn("select * from h_v_SCStockInCheckBill_Json where  HYear =" + Year + " and HMonth = " + Month + " and HDay = " + Day + " and HMaterID = " + HMaterID.ToString() + "and 鎵规 = '" + HBatchNo.ToString() + "'", "h_v_SCStockInCheckBill_Json");
+                    Int64 HSourceInterID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceInterID"]);
+                    Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(ds.Tables[0].Rows[0]["HSourceEntryID"]);
+                    string HSourceBillNo = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBillNo"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string  HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33,3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                        DataSet Dss6;
+                        Dss6 = oCN.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss6.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+
+                            WEBSController WEBS = new WEBSController();
+                            WEBS.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, HSourceBillNo, "3714", HMaker,HOrgID);
+
+                        }
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','3714',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                        DataSet Dss7;
+                        Dss7 = oCN.RunProcReturn(" select * from KF_PonderationBillMain_Temp where HBarCode= '" + HTM + "' and HInterID = " + hinterid.ToString() + " and HBillType = '" + HBillType + "' and hsourcebillno = '" + HSourceBillNo + "' ", "KF_PonderationBillMain_Temp");
+                        if (Dss7.Tables[0].Rows.Count > 0)
+                        {
+
+                        }
+                        else
+                        {
+                            WEBSController WEBS = new WEBSController();
+                            WEBS.get_SourceBarCode_ProductIn_Json(hinterid, HBillNo, HBillType, HSourceBillNo, "3714", HMaker, HOrgID);
+
+                        }
+
+                    }
+
+                }
+                //鐢熶骇閫�鏂�
+                if (HBillType == "1244")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                    
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                       
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //璋冩嫧鍗�
+                if (HBillType == "1207")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //鍏朵粬鍑哄簱鍗�
+                if (HBillType == "1206")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //棰嗘枡鍑哄簱鏍¢獙
+                if (HBillType == "1204")
+                {
+                    string[] sArray = sBarCodeNew.Split('@');
+                    string HMaterNumber = "";
+                    HMaterNumber = sArray[0];
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sArray[4]);
+                    string HBarchNo = "";
+                    HBarchNo = sArray[6];
+
+                    DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                    DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                    //閲囪喘璁㈠崟鍙�
+                    string HPOOrderBillNo = "";
+                    HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                    Int64 HMaterID = 0;
+
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet Dss;
+                    Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                    DataSet Dss1;
+                    Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                    HTM = HOrgNumber + HMaterID + HBarchNo;
+
+                   
+                    DataSet Dss5;
+                    Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+                      
+                    }
+                    else
+                    {
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + 0 + "," + 0 + ",'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                       
+                    }
+
+                }
+                //鐢熶骇琛ユ枡鏍¢獙
+                if (HBillType == "1254")
+                {
+                    string[] sArray = sBarCodeNew.Split('@');
+                    string HMaterNumber = "";
+                    HMaterNumber = sArray[0];
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sArray[4]);
+                    string HBarchNo = "";
+                    HBarchNo = sArray[6];
+
+                    DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                    DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                    //閲囪喘璁㈠崟鍙�
+                    string HPOOrderBillNo = "";
+                    HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                    Int64 HMaterID = 0;
+
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet Dss;
+                    Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                    DataSet Dss1;
+                    Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                    HTM = HOrgNumber + HMaterID + HBarchNo;
+
+
+                    DataSet Dss5;
+                    Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+
+                    }
+                    else
+                    {
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", " + 0 + "," + 0 + ",'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
+                //閿�鍞嚭搴撴牎楠�
+                if (HBillType == "1205")
+                {
+                    string HMaterNumber = "";
+                    HMaterNumber = sBarCodeNew.Substring(0, 10);
+                    string HSCRQ = "";
+                    HSCRQ = "20" + sBarCodeNew.Substring(10, 6);
+                    Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                    Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                    Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                    string HBatchNo = "";
+                    HBatchNo = sBarCodeNew.Substring(16, 11);
+                    SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+                    Int64 HMaterID = 0;
+                    DataSet Dss1;
+                    Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                    HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                    string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                    string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                    Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+                    DataSet Dss;
+                    Dss = oCN.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                    string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+                    HTM = HOrgNumber + HMaterID + HBatchNo;
+
+
+                    DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+                    string HYXQZ = "20" + sBarCodeNew.Substring(27, 6);
+                    Int64 Year1 = ClsPub.isInt(HYXQZ.Substring(0, 4));
+                    Int64 Month1 = ClsPub.isInt(HYXQZ.Substring(4, 2));
+                    Int64 Day1 = ClsPub.isInt(HYXQZ.Substring(6, 2));
+                    DateTime HYXQZ1 = ClsPub.isDate(Year1 + "-" + Month1 + "-" + Day1);
+
+                    Int64 HQty = 0;
+                    HQty = ClsPub.isInt(sBarCodeNew.Substring(33, 3));
+
+                    DataSet Dss5;
+                    Dss5 = oCN.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                    if (Dss5.Tables[0].Rows.Count > 0)
+                    {
+
+                    }
+                    else
+                    {
+
+
+
+                        string ModName = "85";
+                        var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                        Int64 HSupID = 0;
+                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                           ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                           ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                           ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                           ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                           ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                           ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                           ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                           ") values ("
+                                           + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                           + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                           + ", 0,0,'','',0"
+                                           + ", 0,'',0,0,0,''"
+                                           + ",0,'','','" + HSCRQ1.ToShortDateString() + "','" + HYXQZ1.ToShortDateString() + "','',getdate()"
+                                           + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                           + ",0,0,0"
+                                           + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+
+                    }
+
+                }
                 //objJsonResult.code = "0";
                 //objJsonResult.count = 1;
                 //objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
                 //objJsonResult.data = ;
                 return HTM;
+               
             }
             catch (Exception e)
             {
@@ -248,6 +860,10 @@
             }
 
         }
+
+
+
+     
 
 
 
@@ -498,12 +1114,206 @@
 
         [Route("Kf_QCStockInCheckBill_Fast/BarCode_Json")]
         [HttpGet]
-        public object BarCode_Json(string HBarCode)
+        public object BarCode_Json(string HBarCode,Int64 HOrgID)
         {
             try
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  鏉$爜缂栧彿 ='" + HBarCode.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                //string[] sArray = HBarCode.Split('@');
+                //string HMaterNumber = "";
+                //HMaterNumber = sArray[0];
+
+                ////閲囪喘璁㈠崟鍙�
+                //string HPOOrderBillNo = "";
+                //HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                //Int64 HMaterID = 0;
+
+
+                //DataSet Dss1;
+                //Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                //HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+
+
+                ////鏍规嵁鐗╂枡 + 鎵规  +   閲囪喘璁㈠崟鍙� 鎵惧埌瀵瑰簲鐨勬敹鏂欓�氱煡鍗曞彿
+                //DataSet Dss2;
+                //Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
+                //HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
+                //string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
+
+
+                string HTM = "";
+                string[] sArray = HBarCode.Split('@');
+                string HMaterNumber = "";
+                HMaterNumber = sArray[0];
+                Int64 HQty = 0;
+                HQty = ClsPub.isInt(sArray[4]);
+                string HBarchNo = "";
+                HBarchNo = sArray[6];
+
+                DateTime HSCRQ = ClsPub.isDate(sArray[3]);
+                DateTime HYXQZ = ClsPub.isDate(sArray[5]);
+
+                //閲囪喘璁㈠崟鍙�
+                string HPOOrderBillNo = "";
+                HPOOrderBillNo = ClsPub.isStrNull(sArray[8]);
+
+
+
+                Int64 HMaterID = 0;
+
+                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                DataSet Dss;
+                Dss = oCn.RunProcReturn(" select HNumber from h_v_CLD_ORGANIZATIONSList where HItemID= " + HOrgID, "h_v_CLD_ORGANIZATIONSList");
+                string HOrgNumber = Pub_Class.ClsPub.isStrNull(Dss.Tables[0].Rows[0]["HNumber"]);
+
+                DataSet Dss1;
+                Dss1 = oCn.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                HTM = HOrgNumber + HMaterID + HBarchNo;
+
+                //濡傛灉鏉$爜妗f涓嶅瓨鍦�  杩涜瀛樺叆鏉$爜妗f鐨勫姩浣�
+                //鏍规嵁鐗╂枡 + 鎵规  +   閲囪喘璁㈠崟鍙� 鎵惧埌瀵瑰簲鐨勬敹鏂欓�氱煡鍗曞彿
+                DataSet Dss2;
+                Dss2 = oCn.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + HPOOrderBillNo + "' and  FMATERIALID = " + HMaterID, "h_v_RECEIVEQuery");
+                HMaterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FMATERIALID"]);
+                Int64 HSourceInterID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["fid"]);
+                Int64 HSourceEntryID = Pub_Class.ClsPub.isLong(Dss2.Tables[0].Rows[0]["FENTRYID"]);
+                string HSourceBillNo = Pub_Class.ClsPub.isStrNull(Dss2.Tables[0].Rows[0]["FBILLNO"]);
+                //鍒ゆ柇鏉$爜妗f鏄惁瀛樺湪璇ユ潯鐮�
+                //濡傛灉瀛樺湪 鍐嶅垽鏂壂鐮佷复鏃惰〃鏄惁瀛樺湪璇ユ潯鐮�
+                //濡傛灉涓嶅瓨鍦�  杩涜鎵簮鍗曠殑鏂规硶
+                DataSet Dss5;
+                Dss5 = oCn.RunProcReturn(" select * from Gy_BarCodeBill where HBarCode= '" + HTM + "'", "Gy_BarCodeBill");
+                if (Dss5.Tables[0].Rows.Count > 0)
+                {
+                    DataSet ds;
+                    ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  HSourceBillNo ='" + HSourceBillNo.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                    {
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                        //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+
+
+
+                    string ModName = "85";
+                    var HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+                    Int64 HSupID = 0;
+                    oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                                       ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
+                                       ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
+                                       ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
+                                       ",HCusID,HCusType,HEndDate,HProduceDate,HExpiryDate,HWorkLineName,HBarCodeDate " +
+                                       ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
+                                       ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
+                                       ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HExpirationDateFlag " +
+                                       ") values ("
+                                       + "'" + HTM + "','鎵规鏉$爜'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
+                                       + ",'" + HBarchNo + "'," + HSupID.ToString() + ",0,'" + ClsPub.CurUserName + "',getdate(),0," + HQty.ToString()
+                                       + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo.ToString() + "','1103',0"
+                                       + ", 0,'',0,0,0,''"
+                                       + ",0,'','','" + HSCRQ.ToShortDateString() + "','" + HYXQZ.ToShortDateString() + "','',getdate()"
+                                       + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",''," + HInterID.ToString() + ",1"
+                                       + ",0,0,0"
+                                       + ",'" + HMaterName + "','" + HMaterModel + "','',0,'','',1)");
+                    DataSet ds;
+                    ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  HSourceBillNo ='" + HSourceBillNo.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                    if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                    {
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                        //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                        objJsonResult.data = ds.Tables[0];
+                        return objJsonResult;
+                    }
+                }
+                //ds = oCN.RunProcReturn("select * from h_v_QCStockInCheckBill_Json where  鏉$爜缂栧彿 ='" + HBarCode.ToString() + "'", "h_v_QCStockInCheckBill_Json");
+                
+            }
+            catch (Exception e)
+            {
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        [Route("Kf_SCStockInCheckBill_Fast/BarCode_Json1")]
+        [HttpGet]
+        public object BarCode_Json1(string HBarCode,Int64 HOrgID)
+        {
+            try
+            {
+
+                //鏍规嵁鎷嗗垎鐨勭墿鏂橧D +  鎵规 +  鐢熶骇鏃ユ湡 鑳芥壘鍒板敮涓�鐨勫伐搴忔眹鎶ュ崟
+                string HMaterNumber = "";
+                HMaterNumber = HBarCode.Substring(0, 10);
+                string HSCRQ = "";
+                HSCRQ = "20" + HBarCode.Substring(10, 6);
+                Int64 Year = ClsPub.isInt(HSCRQ.Substring(0, 4));
+                Int64 Month = ClsPub.isInt(HSCRQ.Substring(4, 2));
+                Int64 Day = ClsPub.isInt(HSCRQ.Substring(6, 2));
+
+                string HBatchNo = "";
+                HBatchNo = HBarCode.Substring(16, 11);
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                DataSet ds;
+                Int64 HMaterID = 0;
+                DataSet Dss1;
+                Dss1 = oCN.RunProcReturn(" select HItemID,HName,HModel,HUnitID from Gy_Material where HNumber= '" + HMaterNumber + "' and  huseorgid = " + HOrgID, "Gy_Material");
+                HMaterID = Pub_Class.ClsPub.isLong(Dss1.Tables[0].Rows[0]["HItemID"]);
+                string HMaterName = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HName"]);
+                string HMaterModel = Pub_Class.ClsPub.isStrNull(Dss1.Tables[0].Rows[0]["HModel"]);
+                Int64 HUnitID = Pub_Class.ClsPub.isInt(Dss1.Tables[0].Rows[0]["HUnitID"]);
+
+
+                DateTime HSCRQ1 = ClsPub.isDate(Year + "-" + Month + "-" + Day);
+
+
+
+                Int64 HQty = 0;
+                HQty = ClsPub.isInt(HBarCode.Substring(33, 3));
+
+              
+                ds = oCN.RunProcReturn("select * from h_v_SCStockInCheckBill_Json where  HYear =" + Year.ToString() + "and HMonth = " + Month.ToString() + "and HDay = " + Day.ToString() + " and HMaterID = " + HMaterID.ToString() + "and 鎵规 = '" + HBatchNo.ToString() + "'", "h_v_SCStockInCheckBill_Json");
                 if (ds == null || ds.Tables[0].Rows.Count <= 0)
                 {
 
@@ -1535,7 +2345,7 @@
                 string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);//瀹㈡埛鍚嶇О
                 string sql = string.Empty;
                 if (FCusName.Contains("瀹夌憺"))
-                    sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode}' and HBarCodeType ='绠卞彿鍐呮潯鐮�'";
+                    sql = $"select top 1 HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID =(select distinct HSourceInterID from Cg_POInStockBillSub where HInterID ={HInterID}) and HBarCode = '{HBarcode}' and HBarCodeType ='绠卞彿鍐呮潯鐮�'";
                 else
                     sql = $"select HItemID,HSourceBillNo,HQty,HSourceInterID,HSourceEntryID from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
                 DataSet ds = oCn.RunProcReturn(sql, "H_v_SRM_POOrderBillList");

--
Gitblit v1.9.1