1
chenhaozhe
2026-04-13 debfb742b27f7a5e668e6cd3f52db2ee8ddfe815
WebAPI/Controllers/²Ö´æ¹ÜÀí/ÌõÂëÉú³É/Sc_BarCodeController.cs
@@ -188,9 +188,17 @@
                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(select row_number() over (order by å•据号) as HRowNumber,* from h_v_IFCLD_ICMOBillList_Source " + sWhere + " and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案')   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        tabname = "h_v_IFCLD_ICMOBillList_Source";
                        if (oSystemParameter.omodel.WMS_CampanyName == "华舟")
                        {
                            count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IFCLD_ICMOBillList_Source " + sWhere + "  order by å•据号", tabname).Tables[0].Rows.Count;
                            sql = string.Format(@"select * from(select row_number() over (order by å•据号) as HRowNumber,* from h_v_IFCLD_ICMOBillList_Source " + sWhere + " )   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        }
                        else
                        {
                            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(select row_number() over (order by å•据号) as HRowNumber,* from h_v_IFCLD_ICMOBillList_Source " + sWhere + " and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案')   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        }
                        break;
                    case "生产汇报单":
                        tabname = "h_v_IF_ICMOReportBillList_Source";
@@ -701,7 +709,8 @@
                ordrlist.HMTONo = dt.Rows[i]["计划跟踪号"].ToString();
                ordrlist.HProduceDate = DBUtility.ClsPub.isDate(dt.Rows[i]["生产日期"]);
                ordrlist.HExpiryDate = DBUtility.ClsPub.isDate(dt.Rows[i]["有效期至"]);
                ordrlist.HISKFPERIOD = int.Parse(dt.Rows[i]["HISKFPERIOD"].ToString());
                //ordrlist.HISKFPERIOD = int.Parse(dt.Rows[i]["HISKFPERIOD"].ToString());
                ordrlist.HISKFPERIOD = DBUtility.ClsPub.isInt(dt.Rows[i]["HISKFPERIOD"]);
                ordrlist.HEXPUNIT = dt.Rows[i]["HEXPUNIT"].ToString();                          //有效期单位(日、月、年)
                ordrlist.HEXPPERIOD = double.Parse(dt.Rows[i]["HEXPPERIOD"].ToString());        //有效期值
@@ -1450,7 +1459,15 @@
                                TM = HNumber + "@" + sHMTONo.Replace(" ","") + "@" + HBatchNo.Replace(" ","") + "@" + sHQty;
                            }
                        }
                        if (CampanyName == "华舟") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称
                        {
                            barcode.JMHSupID = ordrlist[j].JMHSupID;
                            barcode.JMHSupNumber = ordrlist[j].JMHSupNumber;
                            barcode.JMHSupName = ordrlist[j].JMHSupName;
                            barcode.HTH = ordrlist[j].HTH;
                            barcode.HZQty = ordrlist[j].HZQty;
                        }
                        barcode.HBarCode2 = TM;
                        barcode.HEntryID2 = ClsPub.isStrNull(j + 1);
                        barcode.HMaterID2 = ordrlist[j].HMaterID;
@@ -1572,6 +1589,13 @@
            string HCusMaterName2 = "";
            string HCheckEmpName2 = "";
            //华舟
            Int64 JMHSupID = 0;
            string JMHSupNumber = "";
            string JMHSupName = "";
            string HTH = "";
            double HZQty = 0;
            try
            {
                oCN.BeginTran();
@@ -1591,8 +1615,15 @@
                        {
                            HBarCode = HBarCode + ClsPub.isStrNull(ListRows[i].HMTONo2);
                        }
                        //
                        if (CampanyName == "华舟")
                        {
                            JMHSupID = ClsPub.isLong(ListRows[i].JMHSupID);
                            JMHSupNumber = ClsPub.isStrNull(ListRows[i].JMHSupNumber);
                            JMHSupName = ClsPub.isStrNull(ListRows[i].JMHSupName);
                            HTH = ClsPub.isStrNull(ListRows[i].HTH);
                            HZQty = ClsPub.isDoule(ListRows[i].HZQty);
                        }
                        HMaterID = ClsPub.isLong(ListRows[i].HMaterID2);
                        HEntryID = ClsPub.isLong(ListRows[i].HEntryID2);
                        HAuxPropID = ClsPub.isLong(ListRows[i].HAuxPropID2);
@@ -1634,25 +1665,51 @@
                        HCusModel2 = ClsPub.isStrNull(ListRows[i].HCusModel2);
                        HCusMaterName2 = ClsPub.isStrNull(ListRows[i].HCusMaterName2);
                        HCheckEmpName2 = ClsPub.isStrNull(ListRows[i].HCheckEmpName2);
                        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" +
                                    ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                    + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID2.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
                                    + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                    + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                                    + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + sDate + "'"
                                    + ", " + 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 + "'" + ")");
                        if (CampanyName == "华舟")
                        {
                            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,JMHSupID,JMHSupNumber,JMHSupName,HTH,HZQty" +
                                   ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo" +
                                   ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName,HBarCodeStatus " +
                                   ") values ("
                                   + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                   + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID2.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
                                   + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                   + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                                   + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + sDate + "'"
                                   + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString() + "," + HEntryID.ToString() + ""
                                   + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)+",'"+ JMHSupID.ToString()+"','"+ JMHSupNumber+"','"+ JMHSupName+"','"+ HTH + "','" + HZQty
                                   + "','" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "'"
                                   + ",'" + HCoilNO2 + "','" + HFurnaceNO2 + "','" + HFactory2 + "'," + HAuxQty2 + ",'" + HheatNO2 + "','" + HProduceDate + "','" + HExpiryDate + "'," + HEmpID2.ToString() + ",'" + HCusModel2 + "','" + HCusMaterName2 + "','" + HCheckEmpName2 + "','合格'" + ")");
                        }
                        else
                        {
                            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" +
                                   ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName " +
                                   ") values ("
                                   + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                   + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID2.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
                                   + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                   + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                                   + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + sDate + "'"
                                   + ", " + 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 + "'" + ")");
                        }
                        //HNumber = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterID2Col].Value);
@@ -2825,9 +2882,10 @@
                            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.HSourceBillSEQ = ordrlist[i].HSourceBillSEQ;  // æºå•行号
                            barcode.HBarCode2 = HBarCode_Temp;
                            barcode.HBarCodeType2 = "唯一条码";
                            barcode.HBarCodeSubType2 = "";
@@ -2893,9 +2951,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;                                                             //更新同批生成的条码数
@@ -2970,9 +3031,10 @@
                        string HInspectionDate = ListRows[i].HInspectionDate;
                        int HInspectionCycle = ClsPub.isInt(ListRows[i].HInspectionCycle);
                        string HReInspectionDate = ListRows[i].HInspectionDate;
                        int HSourceBillSEQ = ClsPub.isInt(ListRows[i].HSourceBillSEQ);
                        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" +
                                    ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
@@ -2981,8 +3043,8 @@
                                    ",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" +
                                    ",HReInspectionFlag,HInspectionDate,HInspectionCycle,HReInspectionDate " +
                                    ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName,HCustomBatchNo,HBarCodeStatus,HOrderBillNo" +
                                    ",HReInspectionFlag,HInspectionDate,HInspectionCycle,HReInspectionDate,HSourceBillSEQ " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "','" + HBarCodeSubType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                    + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID2.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
@@ -2992,8 +3054,9 @@
                                    + ", " + 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 + "'") +
                                    "," + HSourceBillSEQ +
                                    ")";
                        oCN.RunProc(sql_produceBarCode);
@@ -3194,7 +3257,7 @@
                  "'" + ds.Tables[0].Rows[0]["HCusType"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HEndDate"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HWorkLineName"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HBarCodeDate"].ToString() + "', " +
                  "getdate()," +
                  "'" + ds.Tables[0].Rows[0]["HSTOCKORGID"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HOWNERID"].ToString() + "', " +
                  "'" + ds.Tables[0].Rows[0]["HSeOrderBillNo"].ToString() + "', " +
@@ -3385,6 +3448,7 @@
                string HSelectBarCodeType = "托盘条码";
                string CampanyName = "小卫";
                string UserName = sArray[2].ToString();//用户
                string barCode_middle = sArray[3].ToString();//中箱码
                ClsPub.CurUserName = UserName;
                //获取内码
@@ -3414,7 +3478,7 @@
                else
                {
                    //生成条码
                    SaveBarCode_xiaowei(msg2, HSelectBarCodeType, CampanyName, HSourceBillTypeName);
                    SaveBarCode_xiaowei(msg2, HSelectBarCodeType, CampanyName, HSourceBillTypeName, barCode_middle);
                }
            }
            catch (Exception e)
@@ -3429,7 +3493,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 = "";                   //源单类型
@@ -3466,54 +3530,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());
                            int currentMonth = DateTime.Now.Month;
                            char[] monthToLetter = {
                            'N', 'P', 'Q', 'R', 'S', 'T',
                            'U', 'V', 'W', 'X', 'Y', 'Z'
                                                };
                            char productionMonth = monthToLetter[currentMonth - 1];
                            char productionDay = DateTime.Today.Month <= 9
                            ? (char)(DateTime.Today.Month + '0')
                            : (char)('A' + DateTime.Today.Month - 10);
                            if (HMaterialName.Trim() == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "物料不能为空,不能生成条码!";
                                return objJsonResult;
                            }
                            Ds2 = oCN.RunProcReturn("select top 1 HCusRelationNumber from Gy_Material m with(nolock) left join Gy_MateNumRelation_Sec b with(nolock) on m.HMASTERID = b.HMaterID where m.HItemID = " + ordrlist.HMaterID, "Gy_MateNumRelation_Sec");
                            string HSKU = "";//商品SKU
                            if (Ds2.Tables[0].Rows.Count > 0)
                            {
                                HSKU = Ds2.Tables[0].Rows[0]["HCusRelationNumber"].ToString();
                            }
                            else
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "没有匹配到对应的商品SKU!";
                                return objJsonResult;
                            }
                            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 = "生成条码失败!" + dds.Tables[0].Rows[0]["HRemark"].ToString();
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            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" + HSKU + 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 + "A" + LSH + "AHW";
                            HBarCode_Temp = dds.Tables[0].Rows[0]["HRemark"].ToString();
                            if (HSumQty - HMinQty > 0)
                            {