王 垚
2022-12-07 ee9f4215d0750a15031bfb89f0f347dadc8c1b70
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.判断系统参数是否安瑞  不是安瑞 直接跳掉
                //如果是安瑞  走下面
                //解析条码
                //如果在条码档案里面   不处理  没有的话 存入条码档案
                //根据解析的物料 +  批次  判断 条码临时表  记录是否存在  没有的话  进行扫源单的动作
                //加了  生产日期  有效期至   保质期标志
                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;
                    //如果条码档案不存在  进行存入条码档案的动作
                    //根据物料 + 批次  +   采购订单号 找到对应的收料通知单号
                    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"]);
                    //判断条码档案是否存在该条码
                    //如果存在 再判断扫码临时表是否存在该条码
                    //如果不存在  进行扫源单的方法
                    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;
                //如果条码档案不存在  进行存入条码档案的动作
                //根据物料 + 批次  +   采购订单号 找到对应的收料通知单号
                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"]);
                //判断条码档案是否存在该条码
                //如果存在 再判断扫码临时表是否存在该条码
                //如果不存在  进行扫源单的方法
                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
            {
                //根据拆分的物料ID +  批次 +  生产日期 能找到唯一的工序汇报单
                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");