yxj
2022-10-25 e453524ea42b61b057df2faabf19828495b37bbb
新增扫描托条码调用方法,卓力专用
1个文件已修改
712 ■■■■■ 已修改文件
CLOUDWEB/WebService1.asmx.cs 712 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CLOUDWEB/WebService1.asmx.cs
@@ -37364,13 +37364,30 @@
                    //判断是否启用一键扫码模式,Y为启用,未启用时只扫描物料条码
                    if (oSystemParameter.omodel.WMS_OneKeyMode.ToUpper() == "N")
                    {
                        if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见" || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦") //系统参数  客户定制化名称     空白为通用
                        if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见"
                            || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦"
                            || oSystemParameter.omodel.WMS_CampanyName == "卓力") //系统参数  客户定制化名称     空白为通用
                        {
                            DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
                            if (dal.GetInfoByNumber_View(sBarCode))
                            {
                                //托盘条码  卓力
                                if (dal.omodel_View.HBarCodeType == "托盘条码" && oSystemParameter.omodel.WMS_CampanyName == "卓力")
                                {
                                    //将物料条码信息写入条码出入库临时表
                                    oBar = get_SavePonderationBillMain_Temp_BarCode_Pack_ZhuoLi(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, SourceFlag, HSourceBillType, HOWNERID, HExpressNumber, oSystemParameter.omodel, ref sErrMsg);
                                    if (oBar == null)
                                    {
                                        sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sErrMsg;
                                        return null;
                                    }
                                    else
                                    {
                                        return oBar;
                                    }
                                }
                                //如果是托盘条码分解并模拟扫码
                                if (dal.omodel_View.HBarCodeType == "托盘条码")
                                else if (dal.omodel_View.HBarCodeType == "托盘条码")
                                {
                                    //分解托条码得到明细条码信息写入出入库条码临时表
                                    DataSet dsTBarCode;
@@ -37498,13 +37515,30 @@
                        //无返回数据则为物料条码
                        if (Dss == null || Dss.Tables[0].Rows.Count == 0)
                        {
                            if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见" || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦") //系统参数  客户定制化名称     空白为通用
                            if (oSystemParameter.omodel.WMS_CampanyName == "博日科技" || oSystemParameter.omodel.WMS_CampanyName == "杭州智见"
                                || oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔" || oSystemParameter.omodel.WMS_CampanyName == "奥邦"
                            || oSystemParameter.omodel.WMS_CampanyName == "卓力") //系统参数  客户定制化名称     空白为通用
                            {
                                DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
                                if (dal.GetInfoByNumber_View(sBarCode))
                                {
                                    //托盘条码  卓力
                                    if (dal.omodel_View.HBarCodeType == "托盘条码" && oSystemParameter.omodel.WMS_CampanyName == "卓力")
                                    {
                                        //将物料条码信息写入条码出入库临时表
                                        oBar = get_SavePonderationBillMain_Temp_BarCode_Pack_ZhuoLi(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, SourceFlag, HSourceBillType, HOWNERID, HExpressNumber, oSystemParameter.omodel, ref sErrMsg);
                                        if (oBar == null)
                                        {
                                            sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描失败!" + sErrMsg;
                                            return null;
                                        }
                                        else
                                        {
                                            return oBar;
                                        }
                                    }
                                    //如果是托盘条码分解并模拟扫码
                                    if (dal.omodel_View.HBarCodeType == "托盘条码")
                                    else if (dal.omodel_View.HBarCodeType == "托盘条码")
                                    {
                                        //分解托条码得到明细条码信息写入出入库条码临时表
                                        DataSet dsTBarCode;
@@ -39190,6 +39224,383 @@
            {
                sErrMsg = "无效条码";
                return false;
            }
        }
        #endregion
        #region 扫描物料条码(托盘条码)    存入出入库条码临时表  卓力专用
        //扫描物料条码  存入条码出入库临时表
        [WebMethod]
        public Model.ClsKf_ICStockBill_WMS get_SavePonderationBillMain_Temp_BarCode_Pack_ZhuoLi(string sHBarCode_Pack, Int64 HInterID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, bool SourceFlag, string HSourceBillType, Int64 HStockOrgID, string HCustom1, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DAL.ClsKF_PonderationBillMain_Temp_Ctl tem = new DAL.ClsKF_PonderationBillMain_Temp_Ctl();
            Model.ClsKF_PonderationBillMain_Temp oMain = new Model.ClsKF_PonderationBillMain_Temp();
            Model.ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
            DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
            string HMaterNumber;            //物料代码
            string sSourceBillCtl = "N";    //是否进行源单信息核对('Y'为核对源单信息)
            string sBatchNoCtl = "N";       //是否进行批号核对('Y'为核对批号)
            string sMultilineCtl = "N";     //是否存在多行相同物料时自动拆分换行('Y'为自动拆分)
            string sMustQtyCtl = "不控制";  //扫码数量能否可超单据数量控制(小于等于应收、完全等于应收、不控制)
            string sMaterWHSPCtl = "N";     //是否取物料默认仓库仓位('Y'为是)
            string sSourceWHSPCtl = "N";    //是否取源单中仓库仓位('Y'为是)
            string sOneScanCtl = "N";       //一次扫码控制('Y'为控制)
            string sFIFOCtl = "N";          //先进先出控制('Y'为控制)
            string sMulSourceCtl = "N";     //是否启用多源单扫码模式('Y'为启用)
            int sWHSPCtl = 0;               //界面仓库为空时,值变为1
            string sBarCode = sHBarCode_Pack.Substring(0, sHBarCode_Pack.Length-2);//截掉条码后两位字符串
            double sRelQty = 0;
            //根据单据类型,获取对应单据系统参数值
            if (get_SystemParameter_BarCode(HBillType, oSystemParameterMain, ref sSourceBillCtl, ref sBatchNoCtl, ref sMultilineCtl, ref sMustQtyCtl, ref sMaterWHSPCtl, ref sSourceWHSPCtl, ref sOneScanCtl, ref sFIFOCtl, ref sMulSourceCtl, ref sErrMsg))
            {
            }
            if (dal.GetInfoByBarCode_View(sBarCode))
            {
                if (dal.omodel_View.HStopflag)
                {
                    sErrMsg = "托条码对应条码: " + sBarCode + " 已被禁用,不允许扫描!";
                    return null;
                }
                else
                {
                    //蓝字入库、汇报模块,非无源单扫码、条码类型为 唯一条码 且为有源单生成的物料条码,扫描条码时自动带出源单信息,第一次扫码或启用多源单扫码模式
                    //采购入库(1201)、生产入库(1202)、其他入库(1203)、委外入库(1210)、生产汇报(3711)
                    if (HSourceBillType != "-1" && dal.omodel_View.HBarCodeType == "唯一条码" && dal.omodel_View.HSourceBillNo != "" && (SourceFlag == false || sMulSourceCtl == "Y")
                        && (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1210" || HBillType == "3711"))
                    {
                        Int64 HAccessFlag = 1;   //是否物料条码带出源单信息标志(0为直接扫源单条码,1为物料条码带出源单信息)
                        oBar = get_SourceBill_MaterBarCode(HInterID, HBillNo, HBillType, dal.omodel_View.HSourceBillNo, dal.omodel_View.HSourceBillType, HMaker, HStockOrgID, HAccessFlag, oSystemParameterMain, ref sErrMsg);
                        if (oBar == null)
                        {
                            return null;
                        }
                        else
                        {
                            SourceFlag = true;
                        }
                    }
                    else
                    {
                        //无源单状态,设置源单类型为-1
                        if (SourceFlag == false)
                        {
                            //销售出库不允许无源单出库
                            if (HBillType == "1205")
                            {
                                sErrMsg = "不允许无源单出库,请先扫描源单!";
                                return null;
                            }
                            HSourceBillType = "-1";
                        }
                    }
                    //1、首次扫码防串单判断; 2、源单类型是否在源单列表里判断; 3、唯一条码是否存在相同条码判断; 4、有源单,物料是否在源单中判断
                    DataSet dsSource = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_SourceInterID_Pack_ZhuoLi " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + sHBarCode_Pack + "','" + HSourceBillType + "'," + HStockOrgID.ToString() + "," + DBUtility.ClsPub.BoolToString(SourceFlag) + "," + sSourceBillCtl + ",'" + sBatchNoCtl + "','" + sMultilineCtl + "','" + sMaterWHSPCtl + "','" + sSourceWHSPCtl + "'", "h_p_WMS_AddBarCode_SourceInterID_Pack_ZhuoLi");
                    if (dsSource == null || dsSource.Tables[0].Rows.Count == 0)
                    {
                        sErrMsg = "判断所扫条码是否在单据中发生错误!";
                        return null;
                    }
                    else
                    {
                        if (DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0][0]) == 0)
                        {
                            dal.omodel_View.HMaterID = DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0]["HMaterID"]);
                            dal.omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0]["HSourceInterID"]);
                            dal.omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(dsSource.Tables[0].Rows[0]["HSumQtyMust"]);   //HSumQtyMust为源单相同物料剩余可扫数量
                            sRelQty = DBUtility.ClsPub.isDoule(dsSource.Tables[0].Rows[0]["HBarCodeQty_Sum"]);   //托条码总数量
                            //获取仓库仓位信息
                            if (HWhID == 0)
                            {
                                HWhID = DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0]["HWhID"]);
                                HSPID = DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0]["HSPID"]);
                                sWHSPCtl = 1;
                            }
                            HMaterNumber = DBUtility.ClsPub.isStrNull(dsSource.Tables[0].Rows[0]["HMaterNumber"]);
                        }
                        else
                        {
                            sErrMsg = DBUtility.ClsPub.isStrNull(dsSource.Tables[0].Rows[0]["HRemark"]);
                            return null;
                        }
                    }
                    //有源单扫码,根据系统参数 控制扫码数量能否可超单据数量(小于等于应收、完全等于应收、不控制)
                    if (dal.omodel_View.HSourceInterID != 0 && (sMustQtyCtl == "小于等于应收" || sMustQtyCtl == "完全等于应收"))
                    {
                        if (dal.omodel_View.HSourceQty == 0)
                        {
                            sErrMsg = "启用条码扫描数量不能超源单可扫数量,所扫物料在列表中剩余可扫数量为0,不允许扫码!";
                            return null;
                        }
                        else if (sRelQty > dal.omodel_View.HSourceQty)
                        {
                            sErrMsg = "启用条码扫描数量不能超源单可扫数量,所扫描托条码总数量为 " + sRelQty.ToString() + " 大于列表中剩余可扫描数量" + dal.omodel_View.HSourceQty.ToString() + ",不允许扫码!";
                            return null;
                        }
                    }
                    //生产领料(1204)、销售出库(1205)、其他出库蓝字(1206)、委外出库(1211)、生产补料(1254)
                    //外购退料(1239)、产品退库(1245)、其他入库红字(1248)、委外退库(1246)
                    //出库、红字入库,判断条码库存、ERP库存
                    if (HBillType == "1204" || HBillType == "1205" || HBillType == "1206" || HBillType == "1211" || HBillType == "1254"
                        || HBillType == "1239" || HBillType == "1245" || HBillType == "1248" || HBillType == "1246")
                    {
                        double sERPQty = 0;     //ERP库存数量
                        string sWhName = "";    //仓库名称
                        string sSPName = "";    //仓位名称
                        //库存控制-WMS负库存控制     唯一条码、启用条码库存,仓库仓位获取顺序:界面上仓库仓位 > 条码库存仓库仓位
                        if (dal.omodel_View.HBarCodeType == "唯一条码" && oSystemParameterMain.WMS_WMSStockCtl == "Y")
                        {
                            //判断条码库存   返回条码库存数量
                            DataSet DsWMS = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_GetWMSICInventory_Pack_ZhuoLi " + HInterID.ToString() + ",'" + HBillType + "','" + sHBarCode_Pack + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + HStockOrgID.ToString(), "h_p_WMS_AddBarCode_GetWMSICInventory_Pack_ZhuoLi");
                            if (DsWMS == null || DsWMS.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "判断条码库存发生错误!";
                                return null;
                            }
                            else
                            {
                                if (DBUtility.ClsPub.isLong(DsWMS.Tables[0].Rows[0][0]) == 1)
                                {
                                    sErrMsg = DBUtility.ClsPub.isStrNull(DsWMS.Tables[0].Rows[0]["HRemark"]);
                                    return null;
                                }
                            }
                        }
                        //判断仓库、仓位是否有效
                        if (HWhID == 0)
                        {
                            sErrMsg = "仓库不允许为空,请先选择仓库!";
                            return null;
                        }
                        else
                        {
                            //根据仓库ID,判断是否启用仓位
                            DataSet dsWH = oCn.RunProcReturn(" select HSPFlag from Gy_Warehouse with(nolock) where HItemID= " + HWhID.ToString() + " and HUSEORGID= " + HStockOrgID.ToString(), "Gy_Warehouse");
                            if (dsWH == null || dsWH.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "所选仓库不属于当前登入组织!";
                                return null;
                            }
                            else if (HSPID == 0 && DBUtility.ClsPub.isBool(dsWH.Tables[0].Rows[0]["HSPFlag"]) == true)
                            {
                                sErrMsg = "所选仓库启用了仓位,仓位不允许为空,请选择对应仓位!";
                                return null;
                            }
                        }
                        //库存控制-ERP负库存控制
                        if (oSystemParameterMain.WMS_ERPStockCtl == "Y")
                        {
                            //判断ERP库存   返回ERP库存数量
                            DataSet DsERP = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_GetERPICInventory " + HInterID.ToString() + ",'" + HBillType + "','" + HMaterNumber + "'," + dal.omodel_View.HAuxPropID.ToString() + ",'" + dal.omodel_View.HBatchNo + "'," + HWhID.ToString() + "," + HSPID.ToString() + "," + HStockOrgID.ToString(), "h_p_WMS_AddBarCode_GetERPICInventory");
                            if (DsERP == null || DsERP.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "所扫描托条码对应物料代码: " + HMaterNumber + " ,无金蝶库存!";
                                return null;
                            }
                            else
                            {
                                sERPQty = DBUtility.ClsPub.isDoule(DsERP.Tables[0].Rows[0]["HQty"]);
                                sWhName = DBUtility.ClsPub.isStrNull(DsERP.Tables[0].Rows[0]["HWhName"]);
                                sSPName = DBUtility.ClsPub.isStrNull(DsERP.Tables[0].Rows[0]["HSPName"]);
                                if (sERPQty <= 0)
                                {
                                    sErrMsg = "所扫描托条码对应物料代码:" + HMaterNumber + " ,在仓库[ " + sWhName + " ]、仓位[ " + sSPName + " ]中,无金蝶库存!";
                                    return null;
                                }
                                //判断扫描数量与金蝶库存数量
                                else if (sRelQty > sERPQty)
                                {
                                    sErrMsg = "所扫描托条码对应物料代码:" + HMaterNumber + " ,在仓库[ " + sWhName + " ]、仓位[ " + sSPName + " ]中,金蝶云库存数量为 " + sERPQty.ToString() + " 小于托条码总数量" + sRelQty.ToString() + " !";
                                    return null;
                                }
                            }
                        }
                        //先进先出控制
                        if (sFIFOCtl == "Y")
                        {
                            DataSet dsFIFO = oCn.RunProcReturn("exec h_p_Kf_ICInventory_FIFO_Tmp_BarCode " + HInterID.ToString() + ",'" + HBillType + "','" + dal.omodel_View.HBatchNo + "','" + dal.omodel_View.HBarCode + "'," + dal.omodel_View.HQty.ToString(), "h_p_Kf_ICInventory_FIFO_Tmp_BarCode");
                            if (dsFIFO == null || dsFIFO.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "启用先进先出控制,所扫条码不在先进先出列表清单中!";
                                return null;
                            }
                        }
                    }
                    //采购入库(1201)、产品入库(1202)、其他入库蓝字(1203)、委外入库(1210)、生产汇报(3711)
                    //生产退料(1244)、销售退库(1247)、其他出库红字(1249)、委外退料(1238)
                    //生产汇报、蓝字入库、红字出库,获取唯一条码剩余可扫描数量
                    else
                    {
                        //判断仓库、仓位是否有效
                        if (HWhID == 0)
                        {
                            sErrMsg = "仓库不允许为空,请先选择仓库!";
                            return null;
                        }
                        else
                        {
                            //根据仓库ID,判断是否启用仓位
                            DataSet dsInWH = oCn.RunProcReturn(" select HSPFlag from Gy_Warehouse with(nolock) where HItemID= " + HWhID.ToString() + " and HUSEORGID= " + HStockOrgID.ToString(), "Gy_Warehouse");
                            if (sWHSPCtl == 1)
                            {
                                if (dsInWH == null || dsInWH.Tables[0].Rows.Count == 0)
                                {
                                    sErrMsg = "源单或物料默认仓库维护信息错误,请重新维护正确仓库信息!";
                                    return null;
                                }
                                else if (HSPID == 0 && DBUtility.ClsPub.isBool(dsInWH.Tables[0].Rows[0]["HSPFlag"]) == true)
                                {
                                    sErrMsg = "源单或物料中所维护的仓库启用了仓位,但没有维护仓位信息,请先维护好仓位信息!";
                                    return null;
                                }
                            }
                            else
                            {
                                if (dsInWH == null || dsInWH.Tables[0].Rows.Count == 0)
                                {
                                    sErrMsg = "所选仓库不属于当前登入组织!";
                                    return null;
                                }
                                else if (HSPID == 0 && DBUtility.ClsPub.isBool(dsInWH.Tables[0].Rows[0]["HSPFlag"]) == true)
                                {
                                    sErrMsg = "所选仓库启用了仓位,仓位不允许为空,请选择对应仓位!";
                                    return null;
                                }
                            }
                        }
                        //获取唯一条码剩余可扫描数量
                        if (dal.omodel_View.HBarCodeType == "唯一条码")
                        {
                            DataSet DsInQty = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_GetInBill_Pack_ZhuoLi '" + sHBarCode_Pack + "','" + HBillType + "'", "h_p_WMS_AddBarCode_GetInBill_Pack_ZhuoLi");
                            if (DsInQty == null || DsInQty.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "判断条码剩余可扫描数量发生错误!";
                                return null;
                            }
                            else
                            {
                                if (DBUtility.ClsPub.isLong(DsInQty.Tables[0].Rows[0][0]) == 1)
                                {
                                    sErrMsg = DBUtility.ClsPub.isStrNull(DsInQty.Tables[0].Rows[0]["HRemark"]);
                                    return null;
                                }
                            }
                        }
                    }
                    //唯一条码,是否启用一次扫码控制('Y'为启用)
                    if (dal.omodel_View.HBarCodeType == "唯一条码" && sOneScanCtl == "Y")
                    {
                        //一次扫码控制,同一条码、同一单据类型,在WMS表和TEMP表里,只允许进行一次扫码
                        DataSet dsOneScan = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_OneScan_Pack_ZhuoLi '" + sHBarCode_Pack + "'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + ",0,0,'" + HMaker + "'", "h_p_WMS_AddBarCode_OneScan_Pack_ZhuoLi");
                        if (dsOneScan == null || dsOneScan.Tables[0].Rows.Count == 0)
                        {
                        }
                        else
                        {
                            if (DBUtility.ClsPub.isLong(dsOneScan.Tables[0].Rows[0][0]) == 1)
                            {
                                sErrMsg = DBUtility.ClsPub.isStrNull(dsOneScan.Tables[0].Rows[0]["HRemark"]);
                                return null;
                            }
                        }
                    }
                    //赋值,写入出入库临时表
                    //红蓝单标志
                    //生产退料(1244)、销售退库(1247)、其他出库红字(1249)、委外退料(1238)
                    //外购退料(1239)、产品退库(1245)、其他入库红字(1248)、委外退库(1246)
                    if (HBillType == "1244" || HBillType == "1247" || HBillType == "1249" || HBillType == "1238"
                        || HBillType == "1239" || HBillType == "1245" || HBillType == "1248" || HBillType == "1246")
                    {
                        oMain.HRedBlueFlag = true;
                    }
                    else
                    {
                        oMain.HRedBlueFlag = false;
                    }
                    //是否多源单标志(0为非多源单模式,1为多源单模式)
                    if (sMulSourceCtl == "Y")
                    {
                        oMain.HMulSourceBill = 1;
                    }
                    else
                    {
                        oMain.HMulSourceBill = 0;
                    }
                    if (HCustom1 == "工序汇报转移单")
                    {
                        oMain.HSubBillType = "1270";
                        HCustom1 = "";
                    }
                    //条码类型为唯一条码,扫码存入时 HRelationEntryID=1,用于判断刷新列表时区分是否重复扫入
                    if (dal.omodel_View.HBarCodeType == "唯一条码")
                    {
                        oMain.HRelationEntryID = 1;
                    }
                    oMain.HInterID = HInterID;
                    oMain.HBillNo = HBillNo;
                    oMain.HBillType = HBillType;
                    oMain.HMaker = HMaker;
                    oMain.HMaterID = dal.omodel_View.HMaterID;
                    oMain.HQtyMust = 0;
                    oMain.HMTONo = dal.omodel_View.HMTONo;
                    oMain.HWhID = HWhID;
                    oMain.HStockPlaceID = HSPID;
                    oMain.HSCWHID = 0;
                    oMain.HOutStockPlaceID = 0;
                    oMain.HPieceQty = 1;
                    oMain.HSourceInterID = DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0]["HSourceInterID"]);
                    oMain.HSourceEntryID = DBUtility.ClsPub.isLong(dsSource.Tables[0].Rows[0]["HSourceEntryID"]);
                    oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(dsSource.Tables[0].Rows[0]["HSourceBillNo"]);
                    oMain.HSourceBillType = DBUtility.ClsPub.isStrNull(dsSource.Tables[0].Rows[0]["HSourceBillType"]);
                    oMain.HSTOCKORGID = HStockOrgID;
                    oMain.HOWNERID = HStockOrgID;
                    oMain.HCusBarCode = HCustom1;
                    oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
                    "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
                    ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
                    ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
                    ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                    ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
                    ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
                    ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
                    " select " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + ",HAuxPropID," + oMain.HProcID.ToString() +
                    "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
                    "," + oMain.HQtyMust.ToString() + ",HQty," + oMain.HPieceQty.ToString() + ",HBatchNo,HBarCode,''" +
                    ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() +"," + oMain.HSourceEntryID.ToString() +",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
                    "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
                    "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + "," + oMain.HSTOCKORGID.ToString() + ",'','','" + oMain.HSubBillType + "'" +
                    ",0,0,'" + oMain.HCusBarCode + "'," + oMain.HMulSourceBill.ToString() +
                    "from  Gy_BarCodeBill with(nolock) where HBarCode_Pack= '" + sHBarCode_Pack + "' and HBarCodeType='唯一条码' order by HItemID"
                    );
                    oBar.HBarType = "物料条码";
                    return oBar;
                }
            }
            else
            {
                sErrMsg = "条码档案中不存在该托条码所对应条码: " + sBarCode + " ,请确认该条码是否已被删除!";
                return null;
            }
        }
@@ -42826,8 +43237,19 @@
                            }
                            else
                            {
                                //托盘条码  卓力
                                if (dal.omodel_View.HBarCodeType == "托盘条码" && oSystemParameter.omodel.WMS_CampanyName == "卓力")
                                {
                                    //将物料条码信息写入条码出入库临时表
                                    if (!set_SavePonderationBillMain_Temp_BarCode_Pack_MoveStock_ZhuoLi(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HSCWHID, HSCSPID, SourceFlag, HSourceBillType, HStockInOrgID, HStockOutOrgID, oSystemParameter.omodel, ref sErrMsg))
                                    {
                                        sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HBillID + ";扫描物料托条码失败!" + sErrMsg;
                                        return null;
                                    }
                                    return oBar;
                                }
                                //判断条码类型是否为托盘条码,如果是托盘条码则分解并模拟扫码
                                if (dal.omodel_View.HBarCodeType == "托盘条码")
                                else if (dal.omodel_View.HBarCodeType == "托盘条码")
                                {
                                    //分解托盘条码得到明细条码信息写入条码出入库临时表
                                    DataSet dsTBarCode = oCn.RunProcReturn("exec h_p_WMS_BeforeCheckToTPBarCode '" + sBarCode + "'", "h_p_WMS_BeforeCheckToTPBarCode");
@@ -43385,6 +43807,286 @@
            return true;
        }
        //扫描物料条码(托盘条码)  存入条码出入库临时表      调拨    卓力专用
        [WebMethod]
        public bool set_SavePonderationBillMain_Temp_BarCode_Pack_MoveStock_ZhuoLi(string sHBarCode_Pack, Int64 HBillID, string HBillType, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Int64 HSCWHID, Int64 HSCSPID, bool SourceFlag, string HSourceBillType, Int64 HStockInOrgID, Int64 HStockOutOrgID, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DAL.ClsKF_PonderationBillMain_Temp_Ctl tem = new DAL.ClsKF_PonderationBillMain_Temp_Ctl();
            Model.ClsKF_PonderationBillMain_Temp oMain = new Model.ClsKF_PonderationBillMain_Temp();
            DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
            string HMaterNumber;            //物料代码
            string sSourceBillCtl = "N";    //是否进行源单信息核对('Y'为核对源单信息)
            string sBatchNoCtl = "N";       //是否进行批号核对('Y'为核对批号)
            string sMultilineCtl = "N";     //是否存在多行相同物料时自动拆分换行('Y'为自动拆分)
            string sMustQtyCtl = "不控制";  //扫码数量能否可超单据数量控制(小于等于应收、完全等于应收、不控制)
            string sMaterWHSPCtl = "N";     //是否取物料默认仓库仓位('Y'为是)
            string sSourceWHSPCtl = "N";    //是否取源单中仓库仓位('Y'为是)
            string sOneScanCtl = "N";       //一次扫码控制('Y'为控制)
            string sFIFOCtl = "N";          //先进先出控制('Y'为控制)
            string sMulSourceCtl = "N";     //是否启用多源单扫码模式('Y'为启用)
            string sBarCode = sHBarCode_Pack.Substring(0, sHBarCode_Pack.Length - 2);//截掉条码后两位字符串
            double sRelQty = 0;
            //根据单据类型,获取对应单据系统参数值
            if (get_SystemParameter_BarCode(HBillType, oSystemParameterMain, ref sSourceBillCtl, ref sBatchNoCtl, ref sMultilineCtl, ref sMustQtyCtl, ref sMaterWHSPCtl, ref sSourceWHSPCtl, ref sOneScanCtl, ref sFIFOCtl, ref sMulSourceCtl, ref sErrMsg))
            {
            }
            //判断调入仓库、仓位是否有效
            if (HWhID == 0)
            {
                sErrMsg = "调入仓库没有选择!";
                return false;
            }
            else
            {
                //根据仓库ID,判断是否启用仓位
                DataSet dsWh = oCn.RunProcReturn(" select HSPFlag from Gy_Warehouse with(nolock) where HItemID= " + HWhID.ToString() + " and HUSEORGID= " + HStockInOrgID.ToString(), "Gy_Warehouse");
                if (dsWh == null || dsWh.Tables[0].Rows.Count == 0)
                {
                    sErrMsg = "所选调入仓库不属于该调入组织!";
                    return false;
                }
                else if (HSPID == 0 && DBUtility.ClsPub.isBool(dsWh.Tables[0].Rows[0]["HSPFlag"]) == true)
                {
                    sErrMsg = "调入仓位没有选择!";
                    return false;
                }
            }
            //无源单状态,设置源单类型为-1
            if (SourceFlag == false)
            {
                HSourceBillType = "-1";
            }
            if (dal.GetInfoByBarCode_View(sBarCode))
            {
                if (dal.omodel_View.HStopflag)
                {
                    sErrMsg = "托条码对应条码: " + sBarCode + " 已被禁用,不允许扫描!";
                    return false;
                }
                else
                {
                    //1、首次扫码防串单判断; 2、源单类型是否在源单列表里判断;3、唯一条码是否存在相同条码判断; 4、有源单,物料是否在源单中判断
                    DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_MoveStock_Pack_ZhuoLi '" + sHBarCode_Pack + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + HSourceBillType + "'," + DBUtility.ClsPub.BoolToString(SourceFlag), "h_p_WMS_AddBarCode_MoveStock_Pack_ZhuoLi");
                    if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
                    {
                        sErrMsg = "判断所扫条码是否在单据中发生错误!";
                        return false;
                    }
                    else
                    {
                        if (DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0][0]) == 0)
                        {
                            dal.omodel_View.HMaterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HMaterID"]);
                            dal.omodel_View.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSourceBillNo"]);
                            dal.omodel_View.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceEntryID"]);
                            dal.omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceInterID"]);
                            dal.omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HQtyMust"]);     //源单可扫数量
                            sRelQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HBarCodeQty_Sum"]);   //托条码总数量
                            HMaterNumber = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HMaterNumber"]);
                        }
                        else
                        {
                            sErrMsg = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HRemark"]);
                            return false;
                        }
                    }
                    //有源单扫码,根据系统参数 控制扫码数量能否可超单据数量(小于等于应收、完全等于应收、不控制)
                    if (dal.omodel_View.HSourceInterID != 0 && (sMustQtyCtl == "小于等于应收" || sMustQtyCtl == "完全等于应收"))
                    {
                        if (dal.omodel_View.HSourceQty == 0)
                        {
                            sErrMsg = "启用条码扫描数量不能超源单可扫数量,所扫物料在列表中剩余可扫数量为0,不允许扫码!";
                            return false;
                        }
                        else if (sRelQty > dal.omodel_View.HSourceQty)
                        {
                            sErrMsg = "启用条码扫描数量不能超源单可扫数量,所扫描条码数量为 " + sRelQty.ToString() + " 大于列表中剩余可扫描数量" + dal.omodel_View.HSourceQty.ToString() + ",不允许扫码!";
                            return false;
                        }
                    }
                    double sERPQty = 0;     //ERP库存数量
                    string sWhName = "";    //仓库名称
                    string sSPName = "";    //仓位名称
                    if (dal.omodel_View.HBarCodeType == "唯一条码")
                    {
                        //判断条码库存    库存控制-WMS负库存控制
                        if (oSystemParameterMain.WMS_WMSStockCtl == "Y" && HBillType != "1251")
                        {
                            //判断条码库存   返回条码库存数量
                            DataSet DsWMS = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_GetWMSICInventory_Pack_ZhuoLi " + HBillID.ToString() + ",'" + HBillType + "','" + sHBarCode_Pack + "'," + HSCWHID.ToString() + "," + HSCSPID.ToString() + "," + HStockOutOrgID.ToString(), "h_p_WMS_AddBarCode_GetWMSICInventory_Pack_ZhuoLi");
                            if (DsWMS == null || DsWMS.Tables[0].Rows.Count == 0)
                            {
                                sErrMsg = "判断条码库存发生错误!";
                                return false;
                            }
                            else
                            {
                                if (DBUtility.ClsPub.isLong(DsWMS.Tables[0].Rows[0][0]) == 1)
                                {
                                    sErrMsg = DBUtility.ClsPub.isStrNull(DsWMS.Tables[0].Rows[0]["HRemark"]);
                                    return false;
                                }
                            }
                        }
                    }
                    //判断调出仓库、仓位是否有效
                    if (HSCWHID == 0)
                    {
                        sErrMsg = "调出仓库没有选择!";
                        return false;
                    }
                    else
                    {
                        //根据仓库ID,判断是否启用仓位
                        DataSet dsSCWH = oCn.RunProcReturn(" select HSPFlag from Gy_Warehouse with(nolock) where HItemID= " + HSCWHID.ToString() + " and HUSEORGID= " + HStockOutOrgID.ToString(), "Gy_Warehouse");
                        if (dsSCWH == null || dsSCWH.Tables[0].Rows.Count == 0)
                        {
                            sErrMsg = "所选调出仓库不属于该调出组织!";
                            return false;
                        }
                        else if (HSCSPID == 0 && DBUtility.ClsPub.isBool(dsSCWH.Tables[0].Rows[0]["HSPFlag"]) == true)
                        {
                            sErrMsg = "调出仓位没有选择!";
                            return false;
                        }
                    }
                    //判断ERP库存   库存控制-ERP负库存控制
                    if (oSystemParameterMain.WMS_ERPStockCtl == "Y" && HBillType != "1251")
                    {
                        //判断ERP库存   返回ERP库存数量
                        DataSet DsERP = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_GetERPICInventory " + HBillID.ToString() + ",'" + HBillType + "','" + HMaterNumber + "'," + dal.omodel_View.HAuxPropID.ToString() + ",'" + dal.omodel_View.HBatchNo + "'," + HSCWHID.ToString() + "," + HSCSPID.ToString() + "," + HStockOutOrgID.ToString(), "h_p_WMS_AddBarCode_GetERPICInventory");
                        if (DsERP == null || DsERP.Tables[0].Rows.Count == 0)
                        {
                            sErrMsg = "所扫描托条码对应物料代码: " + HMaterNumber + " ,无金蝶库存!";
                            return false;
                        }
                        else
                        {
                            sERPQty = DBUtility.ClsPub.isDoule(DsERP.Tables[0].Rows[0]["HQty"]);
                            sWhName = DBUtility.ClsPub.isStrNull(DsERP.Tables[0].Rows[0]["HWhName"]);
                            sSPName = DBUtility.ClsPub.isStrNull(DsERP.Tables[0].Rows[0]["HSPName"]);
                            if (sERPQty <= 0)
                            {
                                sErrMsg = "所扫描托条码对应物料代码:" + HMaterNumber + " ,在仓库[ " + sWhName + " ]、仓位[ " + sSPName + " ]中,无金蝶库存!";
                                return false;
                            }
                            //判断扫描数量与金蝶库存数量
                            else if (sRelQty > sERPQty)
                            {
                                sErrMsg = "所扫描托条码对应物料代码:" + HMaterNumber + " ,在仓库[ " + sWhName + " ]、仓位[ " + sSPName + " ]中,金蝶云库存数量为 " + sERPQty.ToString() + " 小于托条码总数量" + sRelQty.ToString() + " !";
                                return false;
                            }
                        }
                    }
                    if (HWhID == HSCWHID && HSPID == HSCSPID)
                    {
                        sErrMsg = "调入仓库、仓位不能与调出仓库、仓位相同!";
                        return false;
                    }
                    //唯一条码,是否启用一次扫码控制('Y'为启用)
                    if (dal.omodel_View.HBarCodeType == "唯一条码" && sOneScanCtl == "Y")
                    {
                        //一次扫码控制,同一条码、同一单据类型,在WMS表和TEMP表里,只允许进行一次扫码
                        DataSet dsOneScan = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_OneScan_Pack_ZhuoLi '" + sHBarCode_Pack + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + "," + HSCWHID.ToString() + "," + HSCSPID.ToString() + ",'" + HMaker + "'", "h_p_WMS_AddBarCode_OneScan_Pack_ZhuoLi");
                        if (dsOneScan == null || dsOneScan.Tables[0].Rows.Count == 0)
                        {
                        }
                        else
                        {
                            if (DBUtility.ClsPub.isLong(dsOneScan.Tables[0].Rows[0][0]) == 1)
                            {
                                sErrMsg = DBUtility.ClsPub.isStrNull(dsOneScan.Tables[0].Rows[0]["HRemark"]);
                                return false;
                            }
                        }
                    }
                    //是否多源单标志(0为非多源单模式,1为多源单模式)
                    if (sMulSourceCtl == "Y")
                    {
                        oMain.HMulSourceBill = 1;
                    }
                    else
                    {
                        oMain.HMulSourceBill = 0;
                    }
                    //条码类型为唯一条码,扫码存入时 HRelationEntryID=1,用于判断刷新列表时区分是否重复扫入
                    if (dal.omodel_View.HBarCodeType == "唯一条码")
                    {
                        oMain.HRelationEntryID = 1;
                    }
                    oMain.HInterID = HBillID;
                    oMain.HBillNo = HBillNo;
                    oMain.HBillType = HBillType;
                    oMain.HMaker = HMaker;
                    oMain.HMaterID = dal.omodel_View.HMaterID;
                    oMain.HQtyMust = 0;
                    oMain.HMTONo = dal.omodel_View.HMTONo;
                    oMain.HWhID = HWhID;
                    oMain.HStockPlaceID = HSPID;
                    oMain.HSCWHID = HSCWHID;
                    oMain.HOutStockPlaceID = HSCSPID;
                    oMain.HSourceInterID = dal.omodel_View.HSourceInterID;
                    oMain.HSourceEntryID = dal.omodel_View.HSourceEntryID;
                    oMain.HSourceBillNo = dal.omodel_View.HSourceBillNo;
                    oMain.HSourceBillType = HSourceBillType;
                    oMain.HRedBlueFlag = false;
                    oMain.HPieceQty = 1;
                    oMain.HSTOCKORGID = HStockOutOrgID;
                    oMain.HOWNERID = HStockInOrgID;
                    //先进先出控制
                    if ((HBillType == "1207" && oSystemParameterMain.Kf_MoveStockBill_FIFOCtl == "Y")      //系统参数  直接调拨单-先进先出控制
                        )
                    {
                        DataSet FIFO = oCn.RunProcReturn("exec h_p_Kf_ICInventory_FIFO_Tmp_BarCode " + HBillID.ToString() + ",'" + HBillType + "','" + oMain.HBatchNo + "','" + oMain.HBarCode + "'," + oMain.HQty.ToString(), "h_p_Kf_ICInventory_FIFO_Tmp_BarCode");
                        if (FIFO == null || FIFO.Tables[0].Rows.Count == 0)
                        {
                            sErrMsg = "启用先进先出控制,所扫条码不在先进先出列表清单中!";
                            return false;
                        }
                    }
                    oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
                        "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
                        ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
                        ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
                        ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                        ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
                        ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
                        ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
                        " select " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + ",HAuxPropID," + oMain.HProcID.ToString() +
                        "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
                        "," + oMain.HQtyMust.ToString() + ",HQty," + oMain.HPieceQty.ToString() + ",HBatchNo,HBarCode,''" +
                        ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
                        "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
                        "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + "," + oMain.HSTOCKORGID.ToString() + ",'','','" + oMain.HSubBillType + "'" +
                        ",0,0,'" + oMain.HCusBarCode + "'," + oMain.HMulSourceBill.ToString() +
                        "from  Gy_BarCodeBill with(nolock) where HBarCode_Pack= '" + sHBarCode_Pack + "' and HBarCodeType='唯一条码' order by HItemID"
                    );
                    return true;
                }
            }
            else
            {
                sErrMsg = "条码档案中不存在该托条码所对应条码: " + sBarCode + " ,请确认该条码是否已被删除!";
                return false;
            }
        }
        #endregion