yxj
2025-10-31 141421117a797dbd5f2c64918046ec1b7ec6f39f
出入库模块扫描物料条码方法,增加小卫客户条码解析
1个文件已修改
332 ■■■■ 已修改文件
CLOUDWEB/WebService1.asmx.cs 332 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CLOUDWEB/WebService1.asmx.cs
@@ -59593,12 +59593,12 @@
                            else if (oSystemParameter.omodel.WMS_CampanyName == "小卫")
                            {
                                //解析条码
                                if (!GetJXBarCode_XiaoWei(sBarCode, HQty, HStockOrgID, ref sErrMsg))
                                if (!GetJXBarCode_XiaoWei(sBarCode, HStockOrgID, ref sErrMsg))
                                {
                                    return null;
                                }
                                if (dal.GetInfoByBarCode_View(sBarCode))
                                if (dal.GetInfoByBarCode(sBarCode, HBillType, HStockOrgID))
                                {
                                    if (dal.omodel_View.HStopflag)
                                    {
@@ -59607,71 +59607,22 @@
                                    }
                                    else
                                    {
                                        //判断条码类型是否为托盘条码,如果是托盘条码则分解并模拟扫码
                                        if (dal.omodel_View.HBarCodeType == "托盘条码")
                                        //将物料条码信息写入条码出入库临时表
                                        oBar = get_SavePonderationBillMain_Temp_BarCode(dal.omodel_View, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, SourceFlag, HSourceBillType, HStockOrgID, HCustom1, HCustom2, oSystemParameter.omodel, ref sErrMsg);
                                        if (oBar == null)
                                        {
                                            //分解托盘条码得到明细条码信息写入条码出入库临时表
                                            DataSet dsTBarCode = oCn.RunProcReturn("exec h_p_WMS_BeforeCheckToTPBarCode '" + sBarCode + "'", "h_p_WMS_BeforeCheckToTPBarCode");
                                            if (dsTBarCode == null || dsTBarCode.Tables[0].Rows.Count == 0)
                                            {
                                                sErrMsg = "分解托盘条码发生错误!";
                                                return null;
                                            }
                                            else
                                            {
                                                if (DBUtility.ClsPub.isLong(dsTBarCode.Tables[0].Rows[0][0]) == 1)
                                                {
                                                    sErrMsg = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[0]["HRemark"]);
                                                    return null;
                                                }
                                                else
                                                {
                                                    for (int i = 0; i < dsTBarCode.Tables[0].Rows.Count; i++)
                                                    {
                                                        dal.omodel_View.HBarCode = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HBarCode"]);
                                                        dal.omodel_View.HBarCodeType = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HBarCodeType"]);
                                                        dal.omodel_View.HMaterID = DBUtility.ClsPub.isLong(dsTBarCode.Tables[0].Rows[i]["HMaterID"]);
                                                        dal.omodel_View.HAuxPropID = DBUtility.ClsPub.isLong(dsTBarCode.Tables[0].Rows[i]["HAuxPropID"]);
                                                        dal.omodel_View.HBatchNo = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HBatchNo"]);
                                                        dal.omodel_View.HQty = DBUtility.ClsPub.isDoule(dsTBarCode.Tables[0].Rows[i]["HQty"]);
                                                        dal.omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(dsTBarCode.Tables[0].Rows[i]["HSourceInterID"]);
                                                        dal.omodel_View.HSourceEntryID = DBUtility.ClsPub.isLong(dsTBarCode.Tables[0].Rows[i]["HSourceEntryID"]);
                                                        dal.omodel_View.HSourceBillNo = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HSourceBillNo"]);
                                                        dal.omodel_View.HMTONo = DBUtility.ClsPub.isStrNull(dsTBarCode.Tables[0].Rows[i]["HMTONo"]);
                                                        //将物料条码信息写入条码出入库临时表
                                                        oBar = get_SavePonderationBillMain_Temp_BarCode(dal.omodel_View, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, SourceFlag, HSourceBillType, HStockOrgID, HCustom1, HCustom2, oSystemParameter.omodel, ref sErrMsg);
                                                        if (oBar == null)
                                                        {
                                                            sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";扫描失败!" + dal.omodel_View.HBarCode + sErrMsg;
                                                            return null;
                                                        }
                                                        SourceFlag = true;
                                                    }
                                                }
                                                return oBar;
                                            }
                                            sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";扫描失败!" + sErrMsg;
                                            return null;
                                        }
                                        else
                                        //条码类型不为托盘条码
                                        {
                                            //将物料条码信息写入条码出入库临时表
                                            oBar = get_SavePonderationBillMain_Temp_BarCode(dal.omodel_View, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, SourceFlag, HSourceBillType, HStockOrgID, HCustom1, HCustom2, oSystemParameter.omodel, ref sErrMsg);
                                            if (oBar == null)
                                            {
                                                sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";扫描失败!" + sErrMsg;
                                                return null;
                                            }
                                            else
                                            {
                                                return oBar;
                                            }
                                            return oBar;
                                        }
                                    }
                                }
                                else
                                {
                                    sErrMsg = "条码档案中不存在该条码,请确认条码是否正确或是否已被删除!";
                                    sErrMsg = "条码档案中不存在该条码,条码解析失败!";
                                    return null;
                                }
                            }
@@ -59893,6 +59844,42 @@
                                    else
                                    {
                                        sErrMsg = "条码档案中不存在该条码,请确认条码是否正确或是否已被删除!";
                                        return null;
                                    }
                                }
                                else if (oSystemParameter.omodel.WMS_CampanyName == "小卫")
                                {
                                    //解析条码
                                    if (!GetJXBarCode_XiaoWei(sBarCode, HStockOrgID, ref sErrMsg))
                                    {
                                        return null;
                                    }
                                    if (dal.GetInfoByBarCode(sBarCode, HBillType, HStockOrgID))
                                    {
                                        if (dal.omodel_View.HStopflag)
                                        {
                                            sErrMsg = "条码已被禁用,不允许扫描!";
                                            return null;
                                        }
                                        else
                                        {
                                            //将物料条码信息写入条码出入库临时表
                                            oBar = get_SavePonderationBillMain_Temp_BarCode(dal.omodel_View, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, SourceFlag, HSourceBillType, HStockOrgID, HCustom1, HCustom2, oSystemParameter.omodel, ref sErrMsg);
                                            if (oBar == null)
                                            {
                                                sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";扫描失败!" + sErrMsg;
                                                return null;
                                            }
                                            else
                                            {
                                                return oBar;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        sErrMsg = "条码档案中不存在该条码,条码解析失败!";
                                        return null;
                                    }
                                }
@@ -62996,142 +62983,127 @@
        #region 小卫条码解析
        [WebMethod]
        public bool GetJXBarCode_XiaoWei(string sBarCode, Double HQty,long HStockOrgID, ref string sErrMsg)
        public bool GetJXBarCode_XiaoWei(string sBarCode,long HStockOrgID, ref string sErrMsg)
        {
            try
            {
                //条码解析
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                //获取对应条码解析数据
                string[] str = sBarCode.Split('@');
                //通过条码字段数量进入不同的解析方式,因为有同一个数组位置,填写的是不同字段的内容,比如有的第三位显示的是批号信息,有的第三位显示的是物料名称信息
                if (str.Length == 4)
                if (str.Length < 6)
                {
                    DataSet ds;
                    string HMaterNumber = str[0];
                    string HSupNumber = str[1];
                    string HBatchNo = str[2];
                    string HBarQty = str[3];
                    string HSupIDs = "0";
                    //查询供应商
                    ds = oCn.RunProcReturn("select * from Gy_Supplier with(nolock) where HNumber ='" + HSupNumber + "' and HUSEORGID=" + HStockOrgID, "Gy_Supplier");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        sErrMsg = "条码解析失败,请确认条码供应商是否正确!";
                        return false;
                    }
                    else
                    {
                        HSupIDs = ds.Tables[0].Rows[0]["HItemID"].ToString();
                    }
                    string HMaterNames = "";
                    string HMaterModels = "";
                    string HMaterIDs = "0";
                    string HISKFPERIOD = "0";// 保质期启用标记
                    string HUnitIDs = "0";
                    //查询物料
                    ds = oCn.RunProcReturn("select  HUnitID,HItemID,HName,HModel,case HISKFPERIOD when 1 then '1' else '0' end HISKFPERIOD from Gy_Material a with(nolock) where HNumber='" + HMaterNumber + "' and HUSEORGID=" + HStockOrgID + " order by a.HISKFPERIOD desc", "Gy_Material");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        sErrMsg = "条码解析失败,请确认条码物料是否正确!";
                        return false;
                    }
                    else
                    {
                        HMaterIDs = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        HMaterNames = ds.Tables[0].Rows[0]["HName"].ToString();
                        HMaterModels = ds.Tables[0].Rows[0]["HModel"].ToString();
                        HISKFPERIOD = ds.Tables[0].Rows[0]["HISKFPERIOD"].ToString();
                        HUnitIDs = ds.Tables[0].Rows[0]["HUnitID"].ToString();
                    }
                    DateTime HDate = DateTime.Now;//日期
                    string HProduceDate = "";//生产日期
                    string HExpiryDate = "";//保质期至
                    string HSourceInterIDs = "0";
                    string HSourceEntryIDs = "0";
                    string HSourceBillNos = "";
                    string HInnerBillNos = "";
                    //日期获取方式
                    string HBarCodeType = "批次条码";
                    Int64 HMaterID = int.Parse(HMaterIDs);
                    Int64 HUnitID = int.Parse(HUnitIDs);
                    Int64 HSupID = int.Parse(HSupIDs);
                    Int64 HGroupID = 0;
                    int HPrintQty = 1;
                    Int64 HSourceInterID = int.Parse(HSourceInterIDs);
                    Int64 HSourceEntryID = int.Parse(HSourceEntryIDs);
                    string HSourceBillNo = HSourceBillNos;
                    string HSourceBillType = "";
                    string HWei = "0";      //尾数
                    Int64 HBarcodeQtys = 0;     //总托数
                    Int64 HBarcodeNo = 0;       //托号
                    Int64 HDeptID = 0;
                    string HRemark = "条码解析";
                    Int64 HCusID = 0;
                    string HCusType = "";
                    DateTime HEndDate = DateTime.Now;
                    string HWorkLineName = "";
                    long HOrgID = HStockOrgID;
                    string HSeOrderBillNo = "";
                    Int64 HInterIDs = DBUtility.ClsPub.CreateBillID_Prod("85", ref DBUtility.ClsPub.sExeReturnInfo);
                    Int64 HEntryID = 1;
                    bool HGiveAwayFlag = false;
                    string HMaterName = HMaterNames;
                    string HMaterModel = HMaterModels;
                    string HPinfan = "";
                    string HMTONo = "";
                    Int64 HAuxPropID = 0;
                    string HInnerBillNo = HInnerBillNos;
                    //Int64 HWhID = 0;
                    //Int64 HSPID = 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,HWorkLineName,HBarCodeDate " +
                                ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                ",HGiveAwayFlag " +
                                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo" +
                                ",HProduceDate,HExpiryDate,HISKFPERIOD " +
                                ") values ("
                                + "'" + sBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HBarQty.ToString()
                                + ",'" + HBatchNo + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'admin',getdate()," + HPrintQty.ToString() + "," + HBarQty.ToString()
                                + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + ",0,0,'" + HRemark + "'"
                                + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "',getdate()"
                                + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterIDs.ToString() + "," + HEntryID.ToString() + ""
                                + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)
                                + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "','" + HProduceDate + "','" + HExpiryDate + "'," + HISKFPERIOD + ")");
                    return true;
                    sErrMsg = "条码解析失败,条码格式错误,必须包含最少5个 @ 分隔符!";
                    return false;
                }
                else if (str.Length == 5)
                {
                    //另外一种解析方法
                string sHMaterNumber = str[0];      //物料编码
                string sHSupNumber = str[1];        //供应商编码
                string sHBatchNo = str[2];          //来料批号/物料名称
                string sHBarQty = str[3];           //来料数量
                string sHPOOrderBillNo = str[4];    //采购订单编码
                    return true;
                //定义并赋值条码表所需写入字段数据
                Int64 HInterID = 0;             //主ID
                Int64 HEntryID = 0;             //子ID
                string HBarCodeType = "唯一条码";       //条码类型
                Int64 HMaterID = 0;             //物料ID
                Int64 HUnitID = 0;              //计量单位ID
                Int64 HAuxPropID = 0;           //辅助属性ID
                string HBatchNo = "";           //批次号
                string HMTONo = "";             //MTO号
                double HQty = DBUtility.ClsPub.isDoule(sHBarQty);   //数量
                double HinitQty = 0;            //初始化数量(生成条码时数量)
                double HSourceBillQty = 0;      //源单可生成条码数量
                bool HGiveAwayFlag = false;     //是否赠品
                string HProduceDate = "";       //生产日期(保质期用)
                string HExpiryDate = "";        //保质期至(保质期用)
                bool HISKFPERIOD = false;       //是否启用保质期
                string HEXPUNIT = "";           //保质期单位
                double HEXPPERIOD = 0;          //保质期
                Int64 HWhID = 0;                //仓库ID
                Int64 HSPID = 0;                //仓位ID
                Int64 HBarcodeQtys = 0;         //总托数
                Int64 HBarcodeNo = 0;           //当前托号
                string HEndQty = "";            //尾数
                Int64 HSourceInterID = 0;       //源单ID
                Int64 HSourceEntryID = 0;       //源单子ID
                string HSourceBillNo = sHPOOrderBillNo; //源单单号
                string HSourceBillType = "1102";        //源单类型(采购订单1102)
                Int64 HInitSourceEntryID = 0;           //初始化源单子ID(生成条码时源单子ID)
                string HRemark = "解析生成";            //备注
                Int64 HPrintQty = 0;            //打印次数
                Int64 HDeptID = 0;              //部门ID
                Int64 HSupID = 0;               //往来单位ID
                Int64 HGroupID = 0;             //生产班组ID
                Int64 HCusID = 0;               //客户ID
                string HCusType = "";           //客户型号
                string HSeOrderBillNo = "";     //销售订单号
                Int64 HSeOrderSEQ = 0;          //销售订单行号
                string HInnerBillNo = "";       //内部采购订单号
                string HWorkLineName = "";      //生产线
                string HMaterName = "";         //产品名称
                string HMaterModel = "";        //产品规格型号
                string HPinfan = "";            //品番
                DateTime HEndDate = DateTime.Now; ;     //计划完工日期
                //获取物料相关数据
                DataSet Mds = oCn.RunProcReturn("select top 1 HItemID,HNumber,HName,HModel,HUnitID,HISKFPERIOD,HEXPUNIT,HEXPPERIOD from Gy_Material with(nolock) where HNumber='" + sHMaterNumber + "' and HUSEORGID=" + HStockOrgID.ToString() + " order by HISKFPERIOD desc", "Gy_Material");
                if (Mds.Tables[0].Rows.Count == 0)
                {
                    sErrMsg = "条码解析失败,请确认条码中物料编码:" + sHMaterNumber + " 是否正确!";
                    return false;
                }
                else
                {
                    sErrMsg = "条码解析失败,请确认条码是否正确!";
                    return false;
                    HMaterID = DBUtility.ClsPub.isLong(Mds.Tables[0].Rows[0]["HItemID"]);
                    HMaterName = DBUtility.ClsPub.isStrNull(Mds.Tables[0].Rows[0]["HName"]);
                    HUnitID = DBUtility.ClsPub.isLong(Mds.Tables[0].Rows[0]["HUnitID"]);
                    HISKFPERIOD = DBUtility.ClsPub.isBool(Mds.Tables[0].Rows[0]["HISKFPERIOD"]);
                    HEXPUNIT = DBUtility.ClsPub.isStrNull(Mds.Tables[0].Rows[0]["HEXPUNIT"]);
                    HEXPPERIOD = DBUtility.ClsPub.isDoule(Mds.Tables[0].Rows[0]["HEXPPERIOD"]);
                }
                //获取批号
                if (str.Length == 6)
                {
                    HBatchNo = sHBatchNo;
                }
                //获取供应商相关数据
                DataSet Sds = oCn.RunProcReturn("select top 1 HItemID from Gy_Supplier with(nolock) where HNumber='" + sHSupNumber + "' and HUSEORGID=" + HStockOrgID.ToString(), "Gy_Supplier");
                if (Sds.Tables[0].Rows.Count == 0)
                {
                    sErrMsg = "条码解析失败,请确认条码中供应商编码:" + sHSupNumber + " 是否正确!";
                    return false;
                }
                else
                {
                    HSupID = DBUtility.ClsPub.isLong(Sds.Tables[0].Rows[0]["HItemID"]);
                }
                //写入条码档案表
                oCn.RunProc("insert into Gy_BarCodeBill" +
                        "(HInterID,HEntryID,HBarCode,HBarCodeType,HMaterID,HUnitID" +
                        ",HAuxPropID,HBatchNo,HMTONo,HQty,HinitQty,HSourceBillQty" +
                        ",HProduceDate,HExpiryDate" +
                        ",HISKFPERIOD,HEXPUNIT,HEXPPERIOD,HBarCodeDate,HGiveAwayFlag" +
                        ",HWhID,HSPID,HBarcodeQtys,HBarcodeNo,HEndQty" +
                        ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HInitSourceEntryID,HRemark" +
                        ",HPrintQty,HSTOCKORGID,HOWNERID,HDeptID,HSupID,HGroupID" +
                        ",HCusID,HCusType,HSeOrderBillNo,HSeOrderSEQ,HInnerBillNo,HWorkLineName" +
                        ",HMaterName,HMaterModel,HPinfan,HEndDate,HMaker,HMakeDate" +
                        ") values ("
                        + " " + HInterID.ToString() + "," + HEntryID.ToString() + ",'" + sBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString()
                        + ", " + HAuxPropID.ToString() + ",'" + HBatchNo + "','" + HMTONo + "'," + HQty.ToString() + "," + HinitQty.ToString() + "," + HSourceBillQty.ToString()
                        + ", " + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'")
                        + ", " + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",'" + HEXPUNIT + "'," + HEXPPERIOD.ToString() + ",getdate()," + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)
                        + ", " + HWhID.ToString() + "," + HSPID.ToString() + "," + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + ",'" + HEndQty + "'"
                        + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'," + HInitSourceEntryID.ToString() + ",'" + HRemark + "'"
                        + ", " + HPrintQty.ToString() + "," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + "," + HDeptID.ToString() + "," + HSupID.ToString() + "," + HGroupID.ToString()
                        + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HSeOrderBillNo + "'," + HSeOrderSEQ.ToString() + ",'" + HInnerBillNo + "','" + HWorkLineName + "'"
                        + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "','" + HEndDate.ToShortDateString() + "','Admin',getdate()" +
                        ")");
                return true;
            }
            catch (Exception e)
            {