1
zrg
2026-01-15 4f77dfadbfe7eaf39f172fa21260d41ebca002b1
WebAPI/Controllers/²Ö´æ¹ÜÀí/ÌõÂëÉú³É/Sc_BarCodeController.cs
@@ -207,11 +207,11 @@
                        if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺")
                        {
                            count = new SQLHelper.ClsCN().RunProcReturn("select top 1000 * from h_v_IF_POInStockBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                            sql = string.Format(@"select * from(select  top 1000 row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_POInStockBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                            sql = string.Format(@"select * from(select top 1000 row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_POInStockBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        }
                        else
                        {
                            count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_POInStockBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                            count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_POInStockBillList_Source " + sWhere + " order by å•据号 desc,hsubid ", tabname).Tables[0].Rows.Count;
                            sql = string.Format(@"select * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_POInStockBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        }
                        break;
@@ -303,6 +303,148 @@
            return objJsonResult;
        }
        #endregion
        #region [通过源单类型查找不同单据信息] ä½¿ç”¨æ–°çš„分页方式
        [Route("Sc_BarCode/ReportFromBillList_New")]
        [HttpGet]
        public object ReportFromBillList_New(int page, int limit, string sWhere, string HSouceBillType, string HOrgID)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            List<object> columnNameList = new List<object>();
            try
            {
                int count = 0;
                int pageNum = page;
                int pageSize = limit;
                string sql = "";
                string tabname = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " where 1=1 and HOrgID='" + HOrgID + "' ";
                }
                else
                {
                    sWhere = " where 1=1 and HOrgID='" + HOrgID + "' " + sWhere;
                }
                switch (HSouceBillType)
                {
                    case "生产订单":
                        tabname = "h_v_IFCLD_ICMOBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IFCLD_ICMOBillList_Source " + sWhere + " and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案' order by å•据号", tabname).Tables[0].Rows.Count;
                        sql = string.Format($@"select * from h_v_IFCLD_ICMOBillList_Source {sWhere} and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案' order by å•据号 offset {(pageNum - 1)*pageSize} rows fetch next {pageSize} rows only;");
                        break;
                    case "生产汇报单":
                        tabname = "h_v_IF_ICMOReportBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_ICMOReportBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_ICMOReportBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "采购订单":
                        tabname = "h_v_IF_POOrderBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_POOrderBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format($@"select * from h_v_IF_POOrderBillList_Source {sWhere} order by å•据号 offset {(pageNum - 1)*pageSize} rows fetch next {pageSize} rows only;");
                        break;
                    case "收料通知单":
                        tabname = "h_v_IF_POInStockBillList_Source";
                        if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺")
                        {
                            count = new SQLHelper.ClsCN().RunProcReturn("select top 1000 * from h_v_IF_POInStockBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                            sql = string.Format(@"select * from(select top 1000 row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_POInStockBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        }
                        else
                        {
                            count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_POInStockBillList_Source " + sWhere + " order by å•据号 desc,hsubid ", tabname).Tables[0].Rows.Count;
                            sql = string.Format($@"select * from h_v_IF_POInStockBillList_Source {sWhere} order by å•据号 offset {(pageNum - 1) * pageSize} rows fetch next {pageSize} rows only; ");
                        }
                        break;
                    case "委外订单":
                        tabname = "h_v_IF_EntrustOrderBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_EntrustOrderBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_EntrustOrderBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "生产入库单":
                        tabname = "h_v_IF_ProductInBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_ProductInBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_ProductInBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "采购入库单":
                        tabname = "h_v_IF_POStockInBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_POStockInBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_POStockInBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "销售退货单":
                        tabname = "h_v_IF_SellOutBackBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBackBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_SellOutBackBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "生产退料单":
                        tabname = "h_v_IF_MateOutBackBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_MateOutBackBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_MateOutBackBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "工序流转卡":
                        tabname = "h_v_IF_ProcessExchangeBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_ProcessExchangeBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_ProcessExchangeBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "销售出库单":
                        tabname = "h_v_IF_SellOutBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_SellOutBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "领料出库单":
                        tabname = "h_v_IF_MateOutBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_MateOutBillList_Source " + sWhere + " order by å•据号 desc,hsubid", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select top " + pageSize + " * from(select row_number() over (order by å•据号 desc,hsubid) as HRowNumber,* from h_v_IF_MateOutBillList_Source " + sWhere + ")   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    default:
                        break;
                }
                ds = new SQLHelper.ClsCN().RunProcReturn(sql, tabname);
                string aa = ds.Tables[0].Columns[0].ToString();
                //ds.Tables[0].Columns["hmainid"].ColumnName.ToUpper();
                //ds.Tables[0].Columns["hsubid"].ColumnName.ToUpper();
                ds.Tables[0].Columns["hmainid"].ColumnName = "HMainID";
                ds.Tables[0].Columns["hsubid"].ColumnName = "HSubID";
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = count;
                    objJsonResult.Message = "获取资源绑定数据成功!";
                    objJsonResult.data = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(ds.Tables[0], new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }));  //序列化DataSet中的时间格式,然后再反序列化回来
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "暂无资源绑定!";
                    objJsonResult.data = null;
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
                objJsonResult.list = columnNameList;
            }
            return objJsonResult;
        }
        #endregion
        #region [通过条码编号获取HItemId]
        [Route("Sc_BarCode/Get_HItemId")]
@@ -926,7 +1068,6 @@
            string HPOInStockBillNo = ""; // æ”¶æ–™é€šçŸ¥å•号
            string HPOOrderBillNo = ""; // é‡‡è´­è®¢å•号
            DataSet Ds;
            msg2 = msg2.Replace("\\", "");
            msg2 = msg2.Replace("\n", "");  //\n
@@ -937,6 +1078,7 @@
                if (ClsPub.isLong(ordrlist[j].HMaterID) != 0)
                {
                    HNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HMaterID);
                    HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber);//供应商
                    HMaterNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HMaterNumber);
                    HBatchNo = ClsPub.isStrNull(ordrlist[j].HBatchNo);
@@ -1092,11 +1234,24 @@
                        }
                        else if (CampanyName.Contains("小卫"))
                        {
                            // å°å«ç”µå™¨
                            // æ¡ç å‰ç¼€ = å•据号 + ç‰©æ–™ç¼–码 + æ‰¹æ¬¡å·
                            sTMNumber = HPOOrderBillNo + "@" + HMaterNumber + "@" + HBatchNo;
                            Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            if(HSourceBillTypeName== "采购订单")
                            {
                                //条码规则为:物料编码-供应商编码-来料批号-来料数量-采购订单编码
                                sTMNumber = HMaterNumber + "-" + HSupNumber + "-" + HBatchNo + "-" + HBQty + "-" + HPOInStockBillNo;
                                Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            }
                            else
                            {
                                // å°å«ç”µå™¨
                                // æ¡ç å‰ç¼€ = å•据号 + ç‰©æ–™ç¼–码 + æ‰¹æ¬¡å·
                                sTMNumber = HPOOrderBillNo + "@" + HMaterNumber + "@" + HBatchNo;
                                Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            }
                        }
                        else  //通用方法
                        {
@@ -1295,7 +1450,7 @@
                                TM = HNumber + "@" + sHMTONo.Replace(" ","") + "@" + HBatchNo.Replace(" ","") + "@" + sHQty;
                            }
                        }
                        barcode.HBarCode2 = TM;
                        barcode.HEntryID2 = ClsPub.isStrNull(j + 1);
                        barcode.HMaterID2 = ordrlist[j].HMaterID;
@@ -1436,6 +1591,7 @@
                        {
                            HBarCode = HBarCode + ClsPub.isStrNull(ListRows[i].HMTONo2);
                        }
                        //
                        HMaterID = ClsPub.isLong(ListRows[i].HMaterID2);
                        HEntryID = ClsPub.isLong(ListRows[i].HEntryID2);
@@ -2669,7 +2825,7 @@
                            string HMaterNumber_BarCode = DBUtility.ClsPub.isStrNull(ordrlist[i].HMaterNumber);
                            string HInspectionDate_BarCode = DBUtility.ClsPub.isStrNull(ordrlist[i].HInspectionDate).Replace("-", "/");
                            string HQty_BarCode = ClsPub.isStrNull(HMinQty);
                            HBarCode_Temp = HPOOrderBillMTO_TMN + HMaterNumber_BarCode + HInspectionDate_BarCode + HQty_BarCode + LSH;
                            HBarCode_Temp = HPOOrderBillMTO_TMN + "|" + HMaterNumber_BarCode + "|" + HInspectionDate_BarCode + "|" + HQty_BarCode + "|" + LSH;
                            HBarCodeList barcode = new HBarCodeList();
                            barcode.HBarCode2 = HBarCode_Temp;
@@ -2737,9 +2893,12 @@
                            barcode.HCusMaterName2 = ordrlist[i].HCusMaterName;
                            barcode.HCheckEmpName2 = ordrlist[i].HCheckEmpName;
                            barcode.HReInspectionFlag = ordrlist[i].HReInspectionFlag ? 1 : 0;
                            barcode.HInspectionDate = ordrlist[i].HReInspectionFlag? ordrlist[i].HInspectionDate:null;
                            barcode.HInspectionDate = ordrlist[i].HInspectionDate;
                            barcode.HInspectionCycle = ordrlist[i].HReInspectionFlag ? ordrlist[i].HInspectionCycle : 0;
                            barcode.HReInspectionDate = ordrlist[i].HReInspectionFlag ? ordrlist[i].HReInspectionDate : null;
                            barcode.HPOOrderBillMTO = DBUtility.ClsPub.isStrNull(ordrlist[i].HPOOrderBillMTO);
                            barcode.HSeOrderBillNo2 = DBUtility.ClsPub.isStrNull(ordrlist[i].HSeOrderBillNo);
                            barcode.HCusModel2 = DBUtility.ClsPub.isStrNull(ordrlist[i].HCusModel);
                            ListRows.Add(barcode);
                            n += 1;                                                             //更新同批生成的条码数
@@ -2816,6 +2975,7 @@
                        string HReInspectionDate = ListRows[i].HInspectionDate;
                        string HCustomBatchNo = ClsPub.isStrNull(ListRows[i].HInspectionDate).Replace("-","");
                        string HBarCodeStatus = "正常";
                        string HPOOrderBillNoMTO = ClsPub.isStrNull(ListRows[i].HPOOrderBillMTO);
                        string sql_produceBarCode = "insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HBarCodeSubType,HMaterID,HUnitID,HQty" +
                                    ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
@@ -2825,7 +2985,7 @@
                                    ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                    ",HGiveAwayFlag " +
                                    ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo" +
                                    ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName,HCustomBatchNo,HBarCodeStatus" +
                                    ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName,HCustomBatchNo,HBarCodeStatus,HOrderBillNo" +
                                    ",HReInspectionFlag,HInspectionDate,HInspectionCycle,HReInspectionDate " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "','" + HBarCodeSubType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
@@ -2836,7 +2996,7 @@
                                    + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString() + "," + HEntryID.ToString() + ""
                                    + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)
                                    + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "'"
                                    + ",'" + HCoilNO2 + "','" + HFurnaceNO2 + "','" + HFactory2 + "'," + HAuxQty2 + ",'" + HheatNO2 + "','" + HProduceDate + "','" + HExpiryDate + "'," + HEmpID2.ToString() + ",'" + HCusModel2 + "','" + HCusMaterName2 + "','" + HCheckEmpName2 + "','" + HCustomBatchNo + "','" + HBarCodeStatus + "'" +
                                    + ",'" + HCoilNO2 + "','" + HFurnaceNO2 + "','" + HFactory2 + "'," + HAuxQty2 + ",'" + HheatNO2 + "','" + HProduceDate + "','" + HExpiryDate + "'," + HEmpID2.ToString() + ",'" + HCusModel2 + "','" + HCusMaterName2 + "','" + HCheckEmpName2 + "','" + HCustomBatchNo + "','" + HBarCodeStatus + "','" + HPOOrderBillNoMTO + "'" +
                                    "," + HReInspectionFlag + "," + (HInspectionDate == null ? "null" : "'" + HInspectionDate + "'") + "," + HInspectionCycle + "," + (HReInspectionDate == null ? "null" : "'" + HReInspectionDate + "'") +
                                    ")";
@@ -3162,35 +3322,35 @@
        {
            try
            {
                if(oWebs.GetWebAPIToLocal_ICMO(HBillNo, "3710", "admin", ref DBUtility.ClsPub.sErrInfo)==false)
                //if(oWebs.GetWebAPIToLocal_ICMO(HBillNo, "3710", "admin", ref DBUtility.ClsPub.sErrInfo)==false)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "[0000-2-020]单据同步失败请联系管理员,"+ DBUtility.ClsPub.sErrInfo;
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //else
                //{
                ds = oCN.RunProcReturn("exec h_p_WMS_SaveSNByICMO_XW '" + @HBillNo + "','" + HSN +"',"+HBeginNo+","+HEndNo+","+HCount+",'"+HMachineCode+"'", "h_p_WMS_SaveSNByICMO_XW");
                if (ds == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-020]单据同步失败请联系管理员,"+ DBUtility.ClsPub.sErrInfo;
                    objJsonResult.Message = "[0000-2-020]没有返回任何结果,条码保存失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    ds = oCN.RunProcReturn("exec h_p_WMS_SaveSNByICMO_XW '" + @HBillNo + "', " + HSN +","+HBeginNo+","+HEndNo+","+HCount+",'"+HMachineCode+"'", "h_p_WMS_SaveSNByICMO_XW");
                    if (ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "[0000-2-020]没有返回任何结果,条码保存失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "[0000-2-020]条码绑定失败!"+ ds.Tables[0].Rows[0]["HRemark"].ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-020]条码绑定失败!"+ ds.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //}
@@ -3229,6 +3389,7 @@
                string HSelectBarCodeType = "托盘条码";
                string CampanyName = "小卫";
                string UserName = sArray[2].ToString();//用户
                string barCode_middle = sArray[3].ToString();//中箱码
                ClsPub.CurUserName = UserName;
                //获取内码
@@ -3258,7 +3419,7 @@
                else
                {
                    //生成条码
                    SaveBarCode_xiaowei(msg2, HSelectBarCodeType, CampanyName, HSourceBillTypeName);
                    SaveBarCode_xiaowei(msg2, HSelectBarCodeType, CampanyName, HSourceBillTypeName, barCode_middle);
                }
            }
            catch (Exception e)
@@ -3273,7 +3434,7 @@
        #endregion        
        #region[条码生成方法_xiaowei]
        private object SaveBarCode_xiaowei(string msg2, string HSelectBarCodeType, string CampanyName, string HSourceBillTypeName)
        private object SaveBarCode_xiaowei(string msg2, string HSelectBarCodeType, string CampanyName, string HSourceBillTypeName,string barCode_middle)
        {
            DateTime sDate = DateTime.Now;                      //日期
            string HSourceBillType_Temp = "";                   //源单类型
@@ -3288,6 +3449,7 @@
            List<HBarCodeList> ListRows = new List<HBarCodeList>();
            DataSet Ds;
            DataSet Ds2;
            for (int i = 0; i < 1; i++)
            {
                HSourceBillType_Temp = ordrlist.HBillType;
@@ -3309,32 +3471,31 @@
                            string sTMNumber = "";                                                      //条码前缀
                            string LSH = "";                                                            //最大流水号
                            int HLen = 6;                                                            //流水号长度
                            //条码拼接所需字段
                            string HMaterialName = DBUtility.ClsPub.isStrNull(ordrlist.HMaterName);
                            string HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist.HSupNumber).Replace(".", "");             //供应商代码(去掉分隔符)
                            int lastDigit = int.Parse(DateTime.Today.Year.ToString().Last().ToString());
                            char productionMonth = DateTime.Today.Month <= 9
                            ? (char)(DateTime.Today.Month + '0')
                            : (char)('A' + DateTime.Today.Month - 10);
                            if (HMaterialName.Trim() == "")
                            DataSet dds= oCN.RunProcReturn("exec h_p_rule_BarCodePack_xiaowei "+ ordrlist.HMaterID+",'"+ barCode_middle+"'", "h_p_rule_BarCodePack_xiaowei");
                            //todo
                            if (dds.Tables[0].Rows[0]["HBack"]=="1")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "物料不能为空,不能生成条码!";
                                objJsonResult.Message = "生成条码失败!" + dds.Tables[0].Rows[0]["HRemark"].ToString();
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            //todo
                            else if(dds == null || dds.Tables[0].Rows.Count <= 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "生成条码失败,未找到条码!" ;
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            //条码前缀 = p+商品SKU+生产年份+生产月份+6位流水号+生产工厂代码
                            sTMNumber = "P" + HMaterialName + lastDigit+ productionMonth;
                            //根据条码前缀获取最大流水号
                            Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");
                            LSH = String.Format("{0:D" + HLen + "}", ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1);
                            //拼接条码
                            HBarCode_Temp = sTMNumber + LSH+"XXX";
                            HBarCode_Temp = dds.Tables[0].Rows[0]["HRemark"].ToString();
                            if (HSumQty - HMinQty > 0)
                            {