wtt
5 天以前 9b6cd6ba2508314b3a4967b3764153170d40e66c
WebAPI/Controllers/²Ö´æ¹ÜÀí/ÌõÂëÉú³É/Sc_BarCodeController.cs
@@ -127,6 +127,15 @@
                    list.Add("仪器成品条码规则");
                    list.Add("试剂成品条码规则");
                }
                else if (sCapName == "添康科技")
                {
                    list.Add("唯一条码");
                    list.Add("批次条码");
                }
                else if (sCapName == "海诚")
                {
                    list.Add("品种条码");
                }
                else
                {
                    list.Add("唯一条码");
@@ -232,6 +241,16 @@
                        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;
@@ -349,6 +368,12 @@
                            //写入信息
                            ListRows.Add(HSourceOrderList1(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
                            break;
                        case "1205": //销售出库单
                            //得到信息
                            ds = oCN.RunProcReturn("select * from h_v_IF_SellOutBillList_BarCode where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_SellOutBillList_BarCode");
                            //写入信息
                            ListRows.Add(HSourceOrderList1(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
                            break;
                        case "1102": //采购订单
                            //得到信息
                            ds = oCN.RunProcReturn("select * from h_v_IF_POOrderList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POOrderList");
@@ -407,6 +432,12 @@
                            //写入信息
                            ListRows.Add(HSourceOrderList1(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
                            break;
                        case "1204": //领料出库单
                            //得到信息
                            ds = oCN.RunProcReturn("exec h_p_Gy_BarCodeBill_MateOutBillList " + oSelectRow.BillMainID.ToString() + "," + oSelectRow.BillSubID.ToString(), "h_p_Gy_BarCodeBill_MateOutBillList");
                            //写入信息
                            ListRows.Add(HSourceOrderList1(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
                            break;
                        default:
                            break;
                    }
@@ -431,6 +462,7 @@
        public object HSourceOrderList(DataTable dt, HSouceOrderList ordrlist,string HBarCodeType) 
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ordrlist.HQty = dt.Rows[i]["未生成条码数量"].ToString();
@@ -467,6 +499,17 @@
                ordrlist.HSourceName = dt.Rows[i]["生产线"].ToString();
                ordrlist.HEndDate = dt.Rows[i]["计划完工日期"].ToString();//博日 ç”Ÿäº§è®¢å• å¤±æ•ˆæ—¥æœŸ
                ordrlist.HMinQty = dt.Rows[i]["最小包装数"].ToString();
                if (oSystemParameter.omodel.WMS_CampanyName == "九菱") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                {
                    ordrlist.HGroupID = Convert.ToInt32(dt.Rows[i]["HBeginWorkGroupID"]);
                    ordrlist.HGroupNumber = dt.Rows[i]["开工班组代码"].ToString();
                    ordrlist.HGroupName = dt.Rows[i]["开工班组名称"].ToString();
                    ordrlist.HEmpID = Convert.ToInt32(dt.Rows[i]["HBeginWorkEmpID"]);
                    ordrlist.HEmpNumber = dt.Rows[i]["开工人代码"].ToString();
                    ordrlist.HEmpName = dt.Rows[i]["开工人名称"].ToString();
                }
                if (HBarCodeType == "仪器外购件条码容器规则")
                {
                    ordrlist.HMinQty = dt.Rows[i]["未生成条码数量"].ToString();
@@ -550,6 +593,16 @@
                            ordrlist.HGiveAwayFlag = 0;
                        }
                    }
                    if (HSourceBillType == "收料通知单" || HSourceBillType == "采购订单")
                    {
                        if (oSystemParameter.omodel.WMS_CampanyName == "海诚")   //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                        {
                            ordrlist.HSourceBillSEQ = dt.Rows[i]["HSEQ"].ToString();
                            ordrlist.HFactory = dt.Rows[i]["客户编号"].ToString();
                            ordrlist.HCoilNO = dt.Rows[i]["款号"].ToString();
                            ordrlist.HFurnaceNO = dt.Rows[i]["分组"].ToString();
                        }
                    }
                }
                if (HSourceBillType == "退货通知单")
                {
@@ -557,7 +610,7 @@
                    ordrlist.HCusNumber = dt.Rows[i]["客户代码"].ToString();
                    ordrlist.HCusName= dt.Rows[i]["客户"].ToString();
                }
                if (HSourceBillType == "其他入库单")
                if (HSourceBillType == "其他入库单" || HSourceBillType == "领料出库单")
                {
                    ordrlist.HWhID = dt.Rows[i]["HWhID"].ToString();
                    ordrlist.HWhNumber = dt.Rows[i]["仓库代码"].ToString();
@@ -566,6 +619,15 @@
                    ordrlist.HSPNumber = dt.Rows[i]["仓位代码"].ToString();
                    ordrlist.HSPName = dt.Rows[i]["仓位"].ToString();
                }
                if(HSourceBillType == "销售出库单")
                {
                    ordrlist.HWhID = dt.Rows[i]["HWhID"].ToString();
                    ordrlist.HWhNumber = dt.Rows[i]["仓库代码"].ToString();
                    ordrlist.HWhName = dt.Rows[i]["仓库"].ToString();
                    //ordrlist.HSPID = dt.Rows[i]["HSPID"].ToString();
                    //ordrlist.HSPNumber = dt.Rows[i]["仓位代码"].ToString();
                    //ordrlist.HSPName = dt.Rows[i]["仓位"].ToString();
                }
            }
            return ordrlist;
        }
@@ -573,7 +635,7 @@
        //根据TABLE写入界面(出入库单据) 
        private object Sub_WriteInForm_InOut(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType, string HSourceBillType)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ordrlist.HQty = dt.Rows[i]["可生成条码数量"].ToString();
@@ -606,6 +668,20 @@
                ordrlist.HMTONo = dt.Rows[i]["计划跟踪号"].ToString();
                ordrlist.HDate = dt.Rows[i]["日期"].ToString(); 
                ordrlist.HShowDate = DateTime.Now.ToString();
                if(HSourceBillType=="采购入库单")
                {
                    if(oSystemParameter.omodel.WMS_CampanyName=="海诚")   //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                    {
                        ordrlist.HInnerBillNo = dt.Rows[i]["采购订单号"].ToString();
                        ordrlist.HSupID = dt.Rows[i]["HSupID"].ToString();
                        ordrlist.HSupNumber = dt.Rows[i]["供应商代码"].ToString();
                        ordrlist.HSupName = dt.Rows[i]["供应商"].ToString();
                        ordrlist.HFactory = dt.Rows[i]["客户编号"].ToString();
                        ordrlist.HCoilNO = dt.Rows[i]["款号"].ToString();
                        ordrlist.HFurnaceNO = dt.Rows[i]["分组"].ToString();
                    }
                }
            }
            return ordrlist;
        }
@@ -651,13 +727,13 @@
                if (oDs == null && oDs.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.Message="生成批次失败!";
                    objJsonResult.Message= "[0000-2-053]生成批次失败!";
                    return objJsonResult;
                }
                else if (DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][0]) == "1")
                {
                    objJsonResult.code = "1";
                    objJsonResult.Message = "生成批次成功!";
                    objJsonResult.Message = "[0000-2-054]生成批次成功!";
                    objJsonResult.data = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HBatchNo"]);
                    HBatchNo = DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0]["HBatchNo"]);
                    b = true;
@@ -668,7 +744,7 @@
            if (b == false)
            {
                objJsonResult.code = "1";
                objJsonResult.Message="没有需要生成批次的明细行!";
                objJsonResult.Message= "[3899-2-003]没有需要生成批次的明细行!";
                return objJsonResult;
            }
            else //完全封闭
@@ -709,7 +785,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "选择组织有错误!";
                    objJsonResult.Message = "[0000-2-055]选择组织有错误!";
                    return objJsonResult;
                }
                if (!Sub_AllowSave(msg2, HSelectBarCodeType))//单据完整性判断
@@ -730,7 +806,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "条码生成失败!"+e.Message;
                objJsonResult.Message = "[3899-2-006]条码生成失败!" + e.Message;
                return objJsonResult;
            }
            return objJsonResult;
@@ -753,17 +829,18 @@
                long HMaterID = DBUtility.ClsPub.isLong(ordrlist[i].HMaterID);              // ç‰©æ–™å†…码
                string HBatchNo = DBUtility.ClsPub.isStrNull(ordrlist[i].HBatchNo);         // æ‰¹å·
                long HAuxPropID = DBUtility.ClsPub.isLong(ordrlist[i].HAuxPropID);          // è¾…助属性ID
                string HMTONo = DBUtility.ClsPub.isStrNull(ordrlist[i].HMTONo);             //计划跟踪号
                double HSourceQty = DBUtility.ClsPub.isDoule(ordrlist[i].HMinQty);          // æºå•数量
                double HQty = DBUtility.ClsPub.isDoule(ordrlist[i].HQty);                   // æ•°é‡
                double HMinQty = DBUtility.ClsPub.isDoule(ordrlist[i].HMinQty);             // æœ€å°åŒ…装数
                if (HMaterID != 0)
                {
                    DataSet oDsCheck = oCN.RunProcReturn("exec h_p_Gy_BarCodeBill_AddCheck " + HSno.ToString() + ",'" + HBarCodeType + "','" + HSourceBillNo + "'," + HMaterID.ToString() + ",'" + HBatchNo + "'," + HAuxPropID.ToString() + "," + HSourceQty.ToString() + "," + HQty.ToString() + "," + HMinQty.ToString() + "," + HOrgID.ToString() + ",'" + SourceQtyCtl + "'", "h_p_Gy_BarCodeBill_AddCheck");
                    DataSet oDsCheck = oCN.RunProcReturn("exec h_p_Gy_BarCodeBill_AddCheck_New " + HSno.ToString() + ",'" + HBarCodeType + "','" + HSourceBillNo + "'," + HMaterID.ToString() + ",'" + HBatchNo + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "'," + HSourceQty.ToString() + "," + HQty.ToString() + "," + HMinQty.ToString() + "," + HOrgID.ToString() + ",'" + SourceQtyCtl + "'", "h_p_Gy_BarCodeBill_AddCheck_New");
                    if (oDsCheck == null && oDsCheck.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "条码生成完整性判断错误";
                        objJsonResult.Message = "[3899-2-007]条码生成完整性判断错误";
                        return false;
                    }
                    else if (DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0][0]) == "1")
@@ -797,7 +874,7 @@
            int HBQty = 0;              //箱数
            double HQty = 0;            //数量
            string WeiShu = "";         //尾数
            int LSH = 0;                //流水号
            Int64 LSH = 0;              //流水号
            string LSH2 = "";           //流水号转换成字符
            string sDate = "";          //日期
            string sYear = "";          //å¹´
@@ -819,6 +896,12 @@
            decimal HAuxQty = 0;
            string HheatNO = "";
            Int64 HGroupID = 0;
            long HEmpID = 0;
            string HCusModel = ""; //客户物料规格
            string HCusMaterName = ""; //客户物料名称
            string HCheckEmpName = ""; //检验员名称
            DataSet Ds;
            msg2 = msg2.Replace("\\", "");
            msg2 = msg2.Replace("\n", "");  //\n
@@ -837,6 +920,11 @@
                    HFactory = ClsPub.isStrNull(ordrlist[j].HFactory);
                    HAuxQty = ClsPub.isLong(ordrlist[j].HAuxQty);
                    HheatNO = ClsPub.isStrNull(ordrlist[j].HheatNO);
                    HGroupID = ClsPub.isInt(ordrlist[j].HGroupID);
                    HEmpID = ClsPub.isLong(ordrlist[j].HEmpID);
                    HCusModel = ClsPub.isStrNull(ordrlist[j].HCusModel);
                    HCusMaterName = ClsPub.isStrNull(ordrlist[j].HCusMaterName);
                    HCheckEmpName = ClsPub.isStrNull(ordrlist[j].HCheckEmpName);
                    //日期获取方式
                    sDate = DateTime.Now.ToString();
                    //
@@ -849,6 +937,10 @@
                        sDate = DBUtility.ClsPub.isStrNull(ordrlist[j].HEndDate);
                    }
                    else if (CampanyName == "夏宝电器")// æ—¥æœŸï¼šç”Ÿäº§è®¢å• æ¡ç æ—¥æœŸ
                    {
                        sDate = DBUtility.ClsPub.isStrNull(ordrlist[j].HDate);
                    }
                    else if (CampanyName == "九菱")// æ—¥æœŸï¼šç”Ÿäº§è®¢å• æ¡ç æ—¥æœŸ
                    {
                        sDate = DBUtility.ClsPub.isStrNull(ordrlist[j].HDate);
                    }
@@ -872,7 +964,7 @@
                            sTMNumber = HNumber + sYear + sPeriod + sDay;
                            Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (CampanyName == "飞龙")
                        {
@@ -889,7 +981,7 @@
                            sTMNumber = HWorksNumber + HNumber + sYear + sPeriod + sDay;
                            Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (CampanyName == "瑞与祺") {
                            var date = DateTime.Now.ToString("yyMMdd");//日期
@@ -914,7 +1006,7 @@
                                //sTMNumber = ordrlist[j].HMaterNumber + "-包装标识-" + date + "-" + ordrlist[j].HSupNumber + "-";
                                Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                                LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            }
                            else if (HSourceBillTypeName == "生产入库单")
                            {
@@ -948,13 +1040,13 @@
                                //sTMNumber = ordrlist[j].HMaterNumber + "-包装标识-"+ date + "-组织代码-";
                                Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                                LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            }
                            else
                            {
                                sTMNumber = HOrgNumber + HNumber + sYear + sPeriod + sDay;
                                Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                                LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            }
                        }
                        else  //通用方法
@@ -963,7 +1055,7 @@
                            sTMNumber = HOrgNumber + HNumber + sYear + sPeriod + sDay;
                            Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                    }
                    else if (HSelectBarCodeType == "品种条码")
@@ -987,7 +1079,7 @@
                        sTMNumber = HMaterNumber + sYear + sPeriod + sDay;
                        Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 4;
                    }
                    else if (HSelectBarCodeType == "仪器成品条码规则") //另外处理了
@@ -1004,7 +1096,7 @@
                        sTMNumber = HMaterNumber + HBatchNo;
                        Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 6;
                    }
                    else if (HSelectBarCodeType == "内销机条码")
@@ -1014,7 +1106,7 @@
                        sTMNumber = "1" + HModelName + HBarCodeDate + HBarCodeBatchNo + HYasuoji + "00";
                        Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                        if (sTMNumber.Length != 16)
                        {
@@ -1031,7 +1123,7 @@
                        sTMNumber = HMaterNumber.Replace(".", "") + HBarCodeDate + HBarCodeBatchNo;
                        Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                        if (sTMNumber.Length != 18)
                        {
@@ -1047,7 +1139,7 @@
                        sTMNumber = HICMOBillNo;
                        Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                    }
                    else if (HSelectBarCodeType == "托盘条码")
@@ -1056,7 +1148,7 @@
                        //条码前缀 = ç‰©æ–™å†…码 + å¹´ + æœˆ + æ—¥
                        sTMNumber = HNumber + sYear + sPeriod + sDay;
                        Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                    }
                    else
                    {
@@ -1121,6 +1213,40 @@
                            return objJsonResult;
                        }
                        HBarCodeList barcode = new HBarCodeList();
                        if (CampanyName == "海诚") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称
                        {
                            string sHMTONo = "";            //计划跟踪号
                            string sHSourceBillNo = "";     //源单单号
                            string sHSourceBillSEQ = "";    //源单行号
                            string sHSourceEntryID = "";    //源单子ID
                            string sSupNumber = "";         //供应商代码
                            string sHQty = "";              //数量
                            sHMTONo = DBUtility.ClsPub.isStrNull(ordrlist[j].HMTONo);
                            sHSourceBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo);
                            sHSourceBillSEQ = DBUtility.ClsPub.isStrNull(ordrlist[j].HSourceBillSEQ);
                            sHSourceEntryID = DBUtility.ClsPub.isStrNull(ordrlist[j].HSubID);
                            sSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber);
                            sHQty = DBUtility.ClsPub.isStrNull(HMinQty);
                            if (DBUtility.ClsPub.isStrNull(ordrlist[j].HBillType) == "1102") //源单:采购订单
                            {
                                //条码规则:采购订单单号@行号@物料代码@MTO@数量@供应商代码
                                TM = sHSourceBillNo + "@" + sHSourceBillSEQ + "@" + HMaterNumber + "@" + sHMTONo + "@" + sHQty + "@" + sSupNumber;
                            }
                            else if (DBUtility.ClsPub.isStrNull(ordrlist[j].HBillType) == "1103") //源单:收料通知单
                            {
                                //条码规则:收料通知单号@单据子内码@物料代码@MTO@数量@供应商代码
                                TM = sHSourceBillNo + "@" + sHSourceEntryID + "@" + HMaterNumber + "@" + sHMTONo + "@" + sHQty + "@" + sSupNumber;
                            }
                            else
                            {
                                //条码规则:物料内码@MTO@批次号@数量
                                TM = HNumber + "@" + sHMTONo + "@" + HBatchNo + "@" + sHQty;
                            }
                        }
                        barcode.HBarCode2 = TM;
                        barcode.HEntryID2 = ClsPub.isStrNull(j + 1);
                        barcode.HMaterID2 = ordrlist[j].HMaterID;
@@ -1183,6 +1309,12 @@
                        barcode.HFactory = ordrlist[j].HFactory;
                        barcode.HAuxQty = ordrlist[j].HAuxQty;
                        barcode.HheatNO = ordrlist[j].HheatNO;
                        barcode.HGroupID2 = ordrlist[j].HGroupID;
                        barcode.HEmpID2 = ordrlist[j].HEmpID;
                        barcode.HCusModel2 = ordrlist[j].HCusModel;
                        barcode.HCusMaterName2 = ordrlist[j].HCusMaterName;
                        barcode.HCheckEmpName2 = ordrlist[j].HCheckEmpName;
                        ListRows.Add(barcode);
                        k = k + 1;
                        n = n + 1;
@@ -1199,7 +1331,7 @@
            double HQty2 = 0;
            string HBatchNo2 = "";
            Int64 HSupID = 0;
            Int64 HGroupID = 0;
            Int64 HGroupID2 = 0;
            int HPrintQty = 0;
            Int64 HSourceInterID = 0;
            Int64 HSourceEntryID = 0;
@@ -1231,6 +1363,11 @@
            string HheatNO2 = "";
            DateTime HProduceDate;
            DateTime HExpiryDate;
            long HEmpID2 = 0;
            string HCusModel2 = "";
            string HCusMaterName2 = "";
            string HCheckEmpName2 = "";
            try
            {
                oCN.BeginTran();
@@ -1245,6 +1382,10 @@
                        if (CampanyName == "博日科技" || CampanyName == "夏宝电器")
                        {
                            HBarCodeType = "唯一条码";
                        }
                        if (CampanyName == "九菱")
                        {
                            HBarCode = HBarCode + ClsPub.isStrNull(ListRows[i].HMTONo2);
                        }
                        //
                        HMaterID = ClsPub.isLong(ListRows[i].HMaterID2);
@@ -1283,6 +1424,11 @@
                        HheatNO2 = ClsPub.isStrNull(ListRows[i].HheatNO);
                        HProduceDate = ClsPub.isDate(ListRows[i].HProduceDate);
                        HExpiryDate = ClsPub.isDate(ListRows[i].HExpiryDate);
                        HGroupID2 = ClsPub.isInt(ListRows[i].HGroupID2);
                        HEmpID2 = ClsPub.isLong(ListRows[i].HEmpID2);
                        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 " +
@@ -1291,16 +1437,17 @@
                                    ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                    ",HGiveAwayFlag " +
                                    ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo" +
                                    ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate " +
                                    ",HCoilNO,HFurnaceNO,HFactory,HAuxQty,HheatNO,HProduceDate,HExpiryDate,HEmpID,HCusModel,HCusMaterName,HCheckEmpName " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                    + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.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 + "'" + ")");
                                    + ",'" + 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);
@@ -1362,7 +1509,7 @@
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取资源绑定数据成功!";
                    objJsonResult.Message = "[0000-1-037]获取资源绑定数据成功!";
                    objJsonResult.data = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(ds.Tables[0], new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }));  //序列化DataSet中的时间格式,然后再反序列化回来
                    objJsonResult.list = listobj;
                    return objJsonResult;
@@ -1371,7 +1518,7 @@
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何结果,条码不存在!";
                    objJsonResult.Message = "[0000-2-020]没有返回任何结果,条码不存在!";
                    objJsonResult.data = null;
                    objJsonResult.list = listobj;
                    return objJsonResult;
@@ -1382,7 +1529,7 @@
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "条码生成失败!" + e.Message;
                objJsonResult.Message = "[3899-2-006]条码生成失败!" + e.Message;
                return objJsonResult;
            }
        }
@@ -1417,6 +1564,654 @@
        }
        #endregion
        #region æ¡ç è½¬å­˜æ¡ç ä¸»æ¡£
        /// <summary>
        /// æ¡ç è½¬å­˜æ¡ç ä¸»æ¡£
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("Sc_BarCode/SaveBarCode_NoGenerate")]
        [HttpPost]
        public object SaveBarCode_NoGenerate([FromBody] JObject msg)
        {
            try
            {
                var _value = msg["msg"].ToString();
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.None);
                string msg2 = sArray[0].ToString();
                string HOrgType = sArray[1].ToString();
                string HSourceBillTypeName = sArray[2].ToString();
                string HSelectBarCodeType = sArray[3].ToString();
                string CampanyName = sArray[4].ToString() == "xxx" ? "" : sArray[4].ToString();
                string UserName = sArray[5].ToString();
                string barCodeNo = sArray[6].ToString();
                string HFactory = sArray[7].ToString();
                string HCoilNO = sArray[8].ToString();
                string HFurnaceNO = sArray[9].ToString();
                ClsPub.CurUserName = UserName;
                //获取内码
                HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
                DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
                HOrgNumber = "";
                if (oClsGy_ORGANIZATIONS_View.GetInfoByName(HOrgType))
                {
                    HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
                    HOrgNumber = DBUtility.ClsPub.isStrNull(oClsGy_ORGANIZATIONS_View.omodel.HNumber);
                }
                if (HOrgID == -1)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-055]选择组织有错误!";
                    return objJsonResult;
                }
                if (!Sub_AllowSave(msg2, HSelectBarCodeType))//单据完整性判断
                {
                    return objJsonResult;
                }
                if (HSelectBarCodeType == "仪器成品条码规则")
                {
                    //客户定制
                }
                else
                {
                    string HBarCodeType = ClsPub.isStrNull(HSelectBarCodeType);
                    // æ¡ç è½¬å­˜
                    msg2 = msg2.Replace("\\", "");
                    msg2 = msg2.Replace("\n", "");  //\n
                    List<HSouceOrderList> ordrlist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HSouceOrderList>>(msg2);
                    // LogService.Write(ordrlist[0]);
                    long HSourceInterID = string.IsNullOrEmpty(ordrlist[0].HMainID) == true ? 0 : ClsPub.isLong(ordrlist[0].HMainID);
                    long HSourceEntryID = string.IsNullOrEmpty(ordrlist[0].HSubID) == true ? 0 : ClsPub.isLong(ordrlist[0].HSubID);
                    DataSet ds1 = oCN.RunProcReturn("exec h_p_SC_BarCode_Transfer " +
                        "@HBarCodeNo = N'" + barCodeNo + "'" +
                        ",@HSubID = " + ordrlist[0].HSubID +
                        ",@HMaterID = " + ordrlist[0].HMaterID +
                        ",@HGiveAwayFlag = " + ordrlist[0].HGiveAwayFlag +
                        ",@HQty = " + ordrlist[0].HQty +
                        ",@HUnitID = " + ordrlist[0].HUnitID +
                        ",@HMinQty = " + ordrlist[0].HMinQty +
                        ",@HSupID = " + ordrlist[0].HSupID +
                        ",@HBatchNo = N'" + ordrlist[0].HBatchNo  + "'" +
                        ",@HMTONO = N'" + ordrlist[0].HMTONo + "'" +
                        ",@HBarCodeDate = N'" + ordrlist[0].HDate + "'" +
                        ",@HEmpID = " + ordrlist[0].HEmpID  +
                        ",@HSourceInterID = " + HSourceInterID +
                        ",@HSourceEntryID = " + HSourceEntryID +
                        ",@HBarCodeType = N'" + HBarCodeType + "'" +
                        ",@HSourceBillNo = N'" + ordrlist[0].HSourceBillNo + "'" +
                        ",@HMaker = N'" + ordrlist[0].HMaker + "'" +
                        ",@HFactory = N'" + HFactory + "'" +
                        ",@HCoilNO = N'" + HCoilNO + "'" +
                        ",@HFurnaceNO = N'" + HFurnaceNO + "'" +
                        ",@HInnerBillNo = N'" + ordrlist[0].HSourceBillNo + "'"
                        , "h_p_SC_BarCode_Transfer");
                    if((bool)ds1.Tables[0].Rows[0]["returntype"] == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = ds1.Tables[0].Rows[0]["mesg"].ToString();
                    }
                    else
                    {
                        throw new Exception(ds1.Tables[0].Rows[0]["mesg"].ToString());
                    }
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[3899-2-006]条码生成失败!" + e.Message;
                return objJsonResult;
            }
            return objJsonResult;
        }
        #endregion
        #region [条码生成接口-迦南]
        [Route("Sc_BarCode/Sub_SaveBill_JiaNan")]
        [HttpPost]
        public object Sub_SaveBill_JiaNan([FromBody] JObject msg)
        {
            try
            {
                var _value = msg["msg"].ToString();
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = sArray[0].ToString();                                             //物料记录
                string HOrgType = sArray[1].ToString();                                         //组织名称
                string HSourceBillTypeName = sArray[2].ToString();                              //源单类型名称
                string HSelectBarCodeType = sArray[3].ToString();                               //条码类型
                string CampanyName = sArray[4].ToString() == "xxx" ? "" : sArray[4].ToString(); //加工工厂名称
                string UserName = sArray[5].ToString();                                         //登录账号
                ClsPub.CurUserName = UserName;
                //获取内码
                HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
                DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
                HOrgNumber = "";
                if (oClsGy_ORGANIZATIONS_View.GetInfoByName(HOrgType))
                {
                    HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
                    HOrgNumber = DBUtility.ClsPub.isStrNull(oClsGy_ORGANIZATIONS_View.omodel.HNumber);
                }
                if (HOrgID == -1)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-055]选择组织有错误!";
                    return objJsonResult;
                }
                if (!Sub_AllowSave(msg2, HSelectBarCodeType))//单据完整性判断
                {
                    return objJsonResult;
                }
                //生成条码
                SaveBarCode_JiaNan(msg2, HSelectBarCodeType, CampanyName, HSourceBillTypeName);
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[3899-2-006]条码生成失败!" + e.Message;
                return objJsonResult;
            }
            return objJsonResult;
        }
        #endregion
        #region[条码生成方法_迦南]
        private object SaveBarCode_JiaNan(string msg2, string HSelectBarCodeType, string CampanyName, string HSourceBillTypeName)
        {
            DateTime sDate = DateTime.Now;                      //日期
            string HSourceBillType_Temp = "";                   //源单类型
            int n = 0;                                          //同批生成的条码索引
            //获取明细信息
            msg2 = msg2.Replace("\\", "");
            msg2 = msg2.Replace("\n", "");  //\n
            List<HSouceOrderList> ordrlist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HSouceOrderList>>(msg2);
            List<HBarCodeList> ListRows = new List<HBarCodeList>();
            DataSet Ds;
            for (int i = 0; i < ordrlist.Count; i++)
            {
                HSourceBillType_Temp = ordrlist[i].HBillType;
                if (ClsPub.isLong(ordrlist[i].HMaterID) != 0)
                {
                    if (HSelectBarCodeType == "BarCode")
                    {
                        //拆分每条物料记录为多条条码记录
                        double HSumQty = ClsPub.isDoule(ordrlist[i].HQty);                      //产品数量
                        double HQty = ClsPub.isDoule(ordrlist[i].HQty);                         //数量
                        double HMinQty = ClsPub.isDoule(ordrlist[i].HMinQty);                   //最小包装数
                        int HBQty = ClsPub.isInt(ordrlist[i].HBQty);                            //箱数
                        string WeiShu = "";                                                     //尾数
                        for (int j = 0; j < HBQty; j++)
                        {
                            string HBarCode_Temp = "";                                                  //条码
                            string sTMNumber = "";                                                      //条码前缀
                            string LSH = "";                                                            //最大流水号
                            int HLen = 4;                                                            //流水号长度
                            //条码拼接所需字段
                            string HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[i].HSupNumber).Replace(".", "");             //供应商代码(去掉分隔符)
                            string sDateStr = sDate.ToString("yyMMdd");                                                         //启动日期(YYMMDD)
                            if (HSupNumber.Trim() == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "供应商代码不能为空,不能生成条码!";
                                return objJsonResult;
                            }
                            //条码前缀 = R+供应商代码(去掉分隔符)+启动日期(YYMMDD)+四位流水号
                            sTMNumber = "R" + HSupNumber + sDateStr;
                            //根据条码前缀获取最大流水号
                            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;
                            if (HSumQty - HMinQty > 0)
                            {
                                WeiShu = "";
                                HSumQty = HSumQty - HMinQty;
                            }
                            else
                            {
                                if (HSumQty == HMinQty)
                                {
                                    WeiShu = "";
                                }
                                else
                                {
                                    WeiShu = "尾数";
                                }
                                HMinQty = HSumQty;
                            }
                            HBarCodeList barcode = new HBarCodeList();
                            barcode.HBarCode2 = HBarCode_Temp;
                            barcode.HBarCodeType2 = "唯一条码";
                            barcode.HBarCodeSubType2 = "包条码";
                            barcode.HEntryID2 = ClsPub.isStrNull(i + 1);
                            barcode.HMaterID2 = ordrlist[i].HMaterID;
                            barcode.HMaterNumber2 = ordrlist[i].HMaterNumber;
                            barcode.HMaterName2 = ordrlist[i].HMaterName;
                            barcode.HMaterModel2 = ordrlist[i].HMaterModel;
                            barcode.HPinfan2 = ordrlist[i].HPinfan;
                            barcode.HPinfanBarCode2 = ordrlist[i].HPinfanBarCode;
                            barcode.HAuxPropID2 = ordrlist[i].HAuxPropID;
                            barcode.HAuxPropNumber2 = ordrlist[i].HAuxPropNumber;
                            barcode.HAuxPropName2 = ordrlist[i].HAuxPropName;
                            barcode.HUnitID2 = ordrlist[i].HUnitID;
                            barcode.HUnitNumber2 = ordrlist[i].HUnitNumber;
                            barcode.HUnitName2 = ordrlist[i].HUnitName;
                            barcode.HQty2 = ClsPub.isStrNull(HMinQty);
                            barcode.HBatchNo2 = ordrlist[i].HBatchNo;
                            barcode.HSourceInterID2 = ordrlist[i].HMainID;
                            barcode.HSourceEntryID2 = ordrlist[i].HSubID;
                            barcode.HSourceBillNo2 = ordrlist[i].HBillNo;
                            barcode.HSourceBillType2 = ordrlist[i].HBillType;
                            barcode.HPrint = "0";
                            barcode.HWei = WeiShu;
                            barcode.HBarcodeNo = ClsPub.isStrNull(n + 1);
                            barcode.HBarcodeQtys = ordrlist[i].HBQty;
                            barcode.HSupID2 = ordrlist[i].HSupID;
                            barcode.HSupNumber2 = ordrlist[i].HSupNumber;
                            barcode.HSupName2 = ordrlist[i].HSupName;
                            barcode.HDeptID2 = ordrlist[i].HDeptID;
                            barcode.HDeptNumber2 = ordrlist[i].HDeptNumber;
                            barcode.HDeptName2 = ordrlist[i].HDeptName;
                            barcode.HRemark2 = ordrlist[i].HRemark;
                            barcode.HDate2 = ordrlist[i].HDate;
                            barcode.HShowDate2 = ordrlist[i].HShowDate;
                            barcode.HWhID2 = ordrlist[i].HWhID;
                            barcode.HWhNumber2 = ordrlist[i].HWhNumber;
                            barcode.HWhName2 = ordrlist[i].HWhName;
                            barcode.HSPID2 = ordrlist[i].HSPID;
                            barcode.HSPNumber2 = ordrlist[i].HSPNumber;
                            barcode.HSPName2 = ordrlist[i].HSPName;
                            barcode.HMTONo2 = ordrlist[i].HMTONo;
                            barcode.HCusID2 = ordrlist[i].HCusID;
                            barcode.HCusNumber2 = ordrlist[i].HCusNumber;
                            barcode.HCusName2 = ordrlist[i].HCusName;
                            barcode.HCusType2 = ordrlist[i].HCusType;
                            barcode.HSourceID2 = ordrlist[i].HSourceID;
                            barcode.HSourceNumber2 = ordrlist[i].HSourceNumber;
                            barcode.HSourceName2 = ordrlist[i].HSourceName;
                            barcode.HEndDate2 = ordrlist[i].HEndDate;
                            barcode.HSeOrderBillNo2 = ordrlist[i].HSeOrderBillNo;
                            barcode.HInnerBillNo2 = ordrlist[i].HInnerBillNo;
                            barcode.HMaker2 = ordrlist[i].HMaker;
                            barcode.HGiveAwayFlag2 = ordrlist[i].HGiveAwayFlag;
                            barcode.HCoilNO = ordrlist[i].HCoilNO;
                            barcode.HFurnaceNO = ordrlist[i].HFurnaceNO;
                            barcode.HFactory = ordrlist[i].HFactory;
                            barcode.HAuxQty = ordrlist[i].HAuxQty;
                            barcode.HheatNO = ordrlist[i].HheatNO;
                            barcode.HGroupID2 = ordrlist[i].HGroupID;
                            barcode.HEmpID2 = ordrlist[i].HEmpID;
                            barcode.HCusModel2 = ordrlist[i].HCusModel;
                            barcode.HCusMaterName2 = ordrlist[i].HCusMaterName;
                            barcode.HCheckEmpName2 = ordrlist[i].HCheckEmpName;
                            barcode.HZZRQ = ordrlist[i].HZZRQ;
                            ListRows.Add(barcode);
                            n += 1;                                                             //更新同批生成的条码数
                            oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");           //更新最大流水号
                        }
                    }
                    else if(HSelectBarCodeType == "BarCode_Box")
                    {
                        int HBQty = ClsPub.isInt(ordrlist[i].HBQty);                            //箱数
                        for (int j = 0; j < HBQty; j++)
                        {
                            string HBarCode_Temp = "";                                                  //条码
                            string sTMNumber = "";                                                      //条码前缀
                            string LSH = "";                                                            //最大流水号
                            int HLen = 4;                                                               //流水号长度
                            //条码拼接所需字段
                            string HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[i].HSupNumber).Replace(".", "");             //供应商代码(去掉分隔符)
                            string sDateStr = sDate.ToString("yyMMdd");                                                         //启动日期(YYMMDD)
                            if (HSupNumber.Trim() == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "供应商代码不能为空,不能生成条码!";
                                return objJsonResult;
                            }
                            //条码前缀 = R+供应商代码(去掉分隔符)+启动日期(YYMMDD)+四位流水号
                            sTMNumber = "B" + HSupNumber + sDateStr;
                            //根据条码前缀获取最大流水号
                            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;
                            HBarCodeList barcode = new HBarCodeList();
                            barcode.HBarCode2 = HBarCode_Temp;
                            barcode.HBarCodeType2 = "托盘条码";
                            barcode.HBarCodeSubType2 = "箱条码";
                            barcode.HEntryID2 = ClsPub.isStrNull(i + 1);
                            barcode.HMaterID2 = ordrlist[i].HMaterID;
                            barcode.HMaterNumber2 = ordrlist[i].HMaterNumber;
                            barcode.HMaterName2 = ordrlist[i].HMaterName;
                            barcode.HMaterModel2 = ordrlist[i].HMaterModel;
                            barcode.HPinfan2 = ordrlist[i].HPinfan;
                            barcode.HPinfanBarCode2 = ordrlist[i].HPinfanBarCode;
                            barcode.HAuxPropID2 = ordrlist[i].HAuxPropID;
                            barcode.HAuxPropNumber2 = ordrlist[i].HAuxPropNumber;
                            barcode.HAuxPropName2 = ordrlist[i].HAuxPropName;
                            barcode.HUnitID2 = ordrlist[i].HUnitID;
                            barcode.HUnitNumber2 = ordrlist[i].HUnitNumber;
                            barcode.HUnitName2 = ordrlist[i].HUnitName;
                            barcode.HQty2 = ClsPub.isStrNull(0);
                            barcode.HBatchNo2 = ordrlist[i].HBatchNo;
                            barcode.HSourceInterID2 = ordrlist[i].HMainID;
                            barcode.HSourceEntryID2 = ordrlist[i].HSubID;
                            barcode.HSourceBillNo2 = ordrlist[i].HBillNo;
                            barcode.HSourceBillType2 = ordrlist[i].HBillType;
                            barcode.HPrint = "0";
                            barcode.HWei = "";
                            barcode.HBarcodeNo = ClsPub.isStrNull(n + 1);
                            barcode.HBarcodeQtys = ordrlist[i].HBQty;
                            barcode.HSupID2 = ordrlist[i].HSupID;
                            barcode.HSupNumber2 = ordrlist[i].HSupNumber;
                            barcode.HSupName2 = ordrlist[i].HSupName;
                            barcode.HDeptID2 = ordrlist[i].HDeptID;
                            barcode.HDeptNumber2 = ordrlist[i].HDeptNumber;
                            barcode.HDeptName2 = ordrlist[i].HDeptName;
                            barcode.HRemark2 = ordrlist[i].HRemark;
                            barcode.HDate2 = ordrlist[i].HDate;
                            barcode.HShowDate2 = ordrlist[i].HShowDate;
                            barcode.HWhID2 = ordrlist[i].HWhID;
                            barcode.HWhNumber2 = ordrlist[i].HWhNumber;
                            barcode.HWhName2 = ordrlist[i].HWhName;
                            barcode.HSPID2 = ordrlist[i].HSPID;
                            barcode.HSPNumber2 = ordrlist[i].HSPNumber;
                            barcode.HSPName2 = ordrlist[i].HSPName;
                            barcode.HMTONo2 = ordrlist[i].HMTONo;
                            barcode.HCusID2 = ordrlist[i].HCusID;
                            barcode.HCusNumber2 = ordrlist[i].HCusNumber;
                            barcode.HCusName2 = ordrlist[i].HCusName;
                            barcode.HCusType2 = ordrlist[i].HCusType;
                            barcode.HSourceID2 = ordrlist[i].HSourceID;
                            barcode.HSourceNumber2 = ordrlist[i].HSourceNumber;
                            barcode.HSourceName2 = ordrlist[i].HSourceName;
                            barcode.HEndDate2 = ordrlist[i].HEndDate;
                            barcode.HSeOrderBillNo2 = ordrlist[i].HSeOrderBillNo;
                            barcode.HInnerBillNo2 = ordrlist[i].HInnerBillNo;
                            barcode.HMaker2 = ordrlist[i].HMaker;
                            barcode.HGiveAwayFlag2 = ordrlist[i].HGiveAwayFlag;
                            barcode.HCoilNO = ordrlist[i].HCoilNO;
                            barcode.HFurnaceNO = ordrlist[i].HFurnaceNO;
                            barcode.HFactory = ordrlist[i].HFactory;
                            barcode.HAuxQty = ordrlist[i].HAuxQty;
                            barcode.HheatNO = ordrlist[i].HheatNO;
                            barcode.HGroupID2 = ordrlist[i].HGroupID;
                            barcode.HEmpID2 = ordrlist[i].HEmpID;
                            barcode.HCusModel2 = ordrlist[i].HCusModel;
                            barcode.HCusMaterName2 = ordrlist[i].HCusMaterName;
                            barcode.HCheckEmpName2 = ordrlist[i].HCheckEmpName;
                            barcode.HZZRQ = ordrlist[i].HZZRQ;
                            ListRows.Add(barcode);
                            n += 1;                                                             //更新同批生成的条码数
                            oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");           //更新最大流水号
                        }
                    }
                    else if (HSelectBarCodeType == "BarCode_Pack")
                    {
                        int HBQty = ClsPub.isInt(ordrlist[i].HBQty);                            //箱数
                        for (int j = 0; j < HBQty; j++)
                        {
                            string HBarCode_Temp = "";                                                  //条码
                            string sTMNumber = "";                                                      //条码前缀
                            string LSH = "";                                                            //最大流水号
                            int HLen = 4;                                                               //流水号长度
                            //条码拼接所需字段
                            string HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[i].HSupNumber).Replace(".", "");             //供应商代码(去掉分隔符)
                            string sDateStr = sDate.ToString("yyMMdd");                                                         //启动日期(YYMMDD)
                            if (HSupNumber.Trim() == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "供应商代码不能为空,不能生成条码!";
                                return objJsonResult;
                            }
                            //条码前缀 = R+供应商代码(去掉分隔符)+启动日期(YYMMDD)+四位流水号
                            sTMNumber = "P" + HSupNumber + sDateStr;
                            //根据条码前缀获取最大流水号
                            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;
                            HBarCodeList barcode = new HBarCodeList();
                            barcode.HBarCode2 = HBarCode_Temp;
                            barcode.HBarCodeType2 = "托盘条码";
                            barcode.HBarCodeSubType2 = "托条码";
                            barcode.HEntryID2 = ClsPub.isStrNull(i + 1);
                            barcode.HMaterID2 = ordrlist[i].HMaterID;
                            barcode.HMaterNumber2 = ordrlist[i].HMaterNumber;
                            barcode.HMaterName2 = ordrlist[i].HMaterName;
                            barcode.HMaterModel2 = ordrlist[i].HMaterModel;
                            barcode.HPinfan2 = ordrlist[i].HPinfan;
                            barcode.HPinfanBarCode2 = ordrlist[i].HPinfanBarCode;
                            barcode.HAuxPropID2 = ordrlist[i].HAuxPropID;
                            barcode.HAuxPropNumber2 = ordrlist[i].HAuxPropNumber;
                            barcode.HAuxPropName2 = ordrlist[i].HAuxPropName;
                            barcode.HUnitID2 = ordrlist[i].HUnitID;
                            barcode.HUnitNumber2 = ordrlist[i].HUnitNumber;
                            barcode.HUnitName2 = ordrlist[i].HUnitName;
                            barcode.HQty2 = ClsPub.isStrNull(0);
                            barcode.HBatchNo2 = ordrlist[i].HBatchNo;
                            barcode.HSourceInterID2 = ordrlist[i].HMainID;
                            barcode.HSourceEntryID2 = ordrlist[i].HSubID;
                            barcode.HSourceBillNo2 = ordrlist[i].HBillNo;
                            barcode.HSourceBillType2 = ordrlist[i].HBillType;
                            barcode.HPrint = "0";
                            barcode.HWei = "";
                            barcode.HBarcodeNo = ClsPub.isStrNull(n + 1);
                            barcode.HBarcodeQtys = ordrlist[i].HBQty;
                            barcode.HSupID2 = ordrlist[i].HSupID;
                            barcode.HSupNumber2 = ordrlist[i].HSupNumber;
                            barcode.HSupName2 = ordrlist[i].HSupName;
                            barcode.HDeptID2 = ordrlist[i].HDeptID;
                            barcode.HDeptNumber2 = ordrlist[i].HDeptNumber;
                            barcode.HDeptName2 = ordrlist[i].HDeptName;
                            barcode.HRemark2 = ordrlist[i].HRemark;
                            barcode.HDate2 = ordrlist[i].HDate;
                            barcode.HShowDate2 = ordrlist[i].HShowDate;
                            barcode.HWhID2 = ordrlist[i].HWhID;
                            barcode.HWhNumber2 = ordrlist[i].HWhNumber;
                            barcode.HWhName2 = ordrlist[i].HWhName;
                            barcode.HSPID2 = ordrlist[i].HSPID;
                            barcode.HSPNumber2 = ordrlist[i].HSPNumber;
                            barcode.HSPName2 = ordrlist[i].HSPName;
                            barcode.HMTONo2 = ordrlist[i].HMTONo;
                            barcode.HCusID2 = ordrlist[i].HCusID;
                            barcode.HCusNumber2 = ordrlist[i].HCusNumber;
                            barcode.HCusName2 = ordrlist[i].HCusName;
                            barcode.HCusType2 = ordrlist[i].HCusType;
                            barcode.HSourceID2 = ordrlist[i].HSourceID;
                            barcode.HSourceNumber2 = ordrlist[i].HSourceNumber;
                            barcode.HSourceName2 = ordrlist[i].HSourceName;
                            barcode.HEndDate2 = ordrlist[i].HEndDate;
                            barcode.HSeOrderBillNo2 = ordrlist[i].HSeOrderBillNo;
                            barcode.HInnerBillNo2 = ordrlist[i].HInnerBillNo;
                            barcode.HMaker2 = ordrlist[i].HMaker;
                            barcode.HGiveAwayFlag2 = ordrlist[i].HGiveAwayFlag;
                            barcode.HCoilNO = ordrlist[i].HCoilNO;
                            barcode.HFurnaceNO = ordrlist[i].HFurnaceNO;
                            barcode.HFactory = ordrlist[i].HFactory;
                            barcode.HAuxQty = ordrlist[i].HAuxQty;
                            barcode.HheatNO = ordrlist[i].HheatNO;
                            barcode.HGroupID2 = ordrlist[i].HGroupID;
                            barcode.HEmpID2 = ordrlist[i].HEmpID;
                            barcode.HCusModel2 = ordrlist[i].HCusModel;
                            barcode.HCusMaterName2 = ordrlist[i].HCusMaterName;
                            barcode.HCheckEmpName2 = ordrlist[i].HCheckEmpName;
                            barcode.HZZRQ = ordrlist[i].HZZRQ;
                            ListRows.Add(barcode);
                            n += 1;                                                             //更新同批生成的条码数
                            oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");           //更新最大流水号
                        }
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "错误的条码类型,不能生成条码!";
                        return objJsonResult;
                    }
                }
            }
            try
            {
                oCN.BeginTran();
                for (int i = 0; i < ListRows.Count; i++)
                {
                    if (ClsPub.isLong(ListRows[i].HMaterID2) != 0)
                    {
                        string HBarCode = ClsPub.isStrNull(ListRows[i].HBarCode2);
                        string HBarCodeType = ClsPub.isStrNull(ListRows[i].HBarCodeType2);
                        string HBarCodeSubType = ClsPub.isStrNull(ListRows[i].HBarCodeSubType2);
                        Int64 HMaterID = ClsPub.isLong(ListRows[i].HMaterID2);
                        Int64 HEntryID = ClsPub.isLong(ListRows[i].HEntryID2);
                        Int64 HAuxPropID = ClsPub.isLong(ListRows[i].HAuxPropID2);
                        Int64 HUnitID = ClsPub.isLong(ListRows[i].HUnitID2);
                        double HQty2 = ClsPub.isDoule(ListRows[i].HQty2);
                        string HWei = ClsPub.isStrNull(ListRows[i].HWei);
                        string HBatchNo2 = ClsPub.isStrNull(ListRows[i].HBatchNo2);
                        Int64 HSourceInterID = ClsPub.isLong(ListRows[i].HSourceInterID2);
                        Int64 HSourceEntryID = ClsPub.isLong(ListRows[i].HSourceEntryID2);
                        string HSourceBillNo = ClsPub.isStrNull(ListRows[i].HSourceBillNo2);
                        string HSourceBillType = ClsPub.isStrNull(ListRows[i].HSourceBillType2);
                        Int64 HBarcodeQtys = ClsPub.isLong(ListRows[i].HBarcodeQtys);
                        Int64 HBarcodeNo = ClsPub.isLong(ListRows[i].HBarcodeNo);
                        Int64 HSupID = ClsPub.isLong(ListRows[i].HSupID2);
                        Int64 HDeptID = ClsPub.isLong(ListRows[i].HDeptID2);
                        Int64 HWhID = ClsPub.isLong(ListRows[i].HWhID2);
                        Int64 HSPID = ClsPub.isLong(ListRows[i].HSPID2);
                        string HRemark = ClsPub.isStrNull(ListRows[i].HRemark2);
                        string HMaterName = ClsPub.isStrNull(ListRows[i].HMaterName2);
                        string HMaterModel = ClsPub.isStrNull(ListRows[i].HMaterModel2);
                        string HPinfan = ClsPub.isStrNull(ListRows[i].HPinfan2);
                        string HMTONo = ClsPub.isStrNull(ListRows[i].HMTONo2);
                        Int64 HCusID = ClsPub.isLong(ListRows[i].HCusID2);
                        string HCusType = ClsPub.isStrNull(ListRows[i].HCusType2);
                        DateTime HEndDate = ClsPub.isDate(ListRows[i].HEndDate2);
                        string HWorkLineName = ClsPub.isStrNull(ListRows[i].HSourceName2);
                        string HSeOrderBillNo = ClsPub.isStrNull(ListRows[i].HSeOrderBillNo2);
                        string HInnerBillNo = ClsPub.isStrNull(ListRows[i].HInnerBillNo2);
                        bool HGiveAwayFlag = ClsPub.isBool(ListRows[i].HGiveAwayFlag2);
                        int HPrintQty = ClsPub.isInt(ListRows[i].HPrint);
                        string HCoilNO2 = ClsPub.isStrNull(ListRows[i].HCoilNO);
                        string HFurnaceNO2 = ClsPub.isStrNull(ListRows[i].HFurnaceNO);
                        string HFactory2 = ClsPub.isStrNull(ListRows[i].HFactory);
                        Int64 HAuxQty2 = ClsPub.isLong(ListRows[i].HAuxQty);
                        string HheatNO2 = ClsPub.isStrNull(ListRows[i].HheatNO);
                        DateTime HProduceDate = ClsPub.isDate(ListRows[i].HProduceDate);
                        DateTime HExpiryDate = ClsPub.isDate(ListRows[i].HExpiryDate);
                        int HGroupID2 = ClsPub.isInt(ListRows[i].HGroupID2);
                        Int64 HEmpID2 = ClsPub.isLong(ListRows[i].HEmpID2);
                        string HCusModel2 = ClsPub.isStrNull(ListRows[i].HCusModel2);
                        string HCusMaterName2 = ClsPub.isStrNull(ListRows[i].HCusMaterName2);
                        string HCheckEmpName2 = ClsPub.isStrNull(ListRows[i].HCheckEmpName2);
                        string HZZRQ = ClsPub.isStrNull(ListRows[i].HZZRQ);
                        oCN.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HBarCodeSubType,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,HZZRQ " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "','" + HBarCodeSubType + "'," + 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 + "','" + HZZRQ + "'" + ")");
                    }
                }
                //增加 æ¡ç è¶…过未生成功能控制
                //
                oCN.Commit();
                List<Object> listobj = ListRows.ConvertAll(s => (object)s);//List实体类转换为object
                //获取生成的条码信息
                string sql = string.Format(@"select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID");
                ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_IF_ICMOBillList_Table");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "[0000-1-037]获取资源绑定数据成功!";
                    objJsonResult.data = JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(ds.Tables[0], new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }));  //序列化DataSet中的时间格式,然后再反序列化回来
                    objJsonResult.list = listobj;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-020]没有返回任何结果,条码不存在!";
                    objJsonResult.data = null;
                    objJsonResult.list = listobj;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[3899-2-006]条码生成失败!" + e.Message;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
    }
}