1
llj
8 小时以前 e3f218a023f0625f415a1526b278636c3e39aa4f
WebAPI/Controllers/²Ö´æ¹ÜÀí/ÌõÂëÉú³É/Sc_BarCodeController.cs
@@ -163,7 +163,7 @@
        #region [通过源单类型查找不通单据信息]
        [Route("Sc_BarCode/ReportFromBillList")]
        [HttpGet]
        public object ReportFromBillList(int page, int limit, string sWhere, string HSouceBillType, string HOrgID)
        public object ReportFromBillList(int page, int limit, string sWhere,string HSouceBillType,string HOrgID)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            List<object> columnNameList = new List<object>();
@@ -176,7 +176,7 @@
                string tabname = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " where 1=1 and HOrgID='" + HOrgID + "' ";
                    sWhere = " where 1=1 and HOrgID='"+HOrgID+"' ";
                }
                else
                {
@@ -185,8 +185,8 @@
                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;
                        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)");
                        break;
                    case "生产汇报单":
@@ -347,7 +347,7 @@
            List<object> ListRows = new List<object>();
            try
            {
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                List<DBUtility.BillSelect> oList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DBUtility.BillSelect>>(msg2);
@@ -360,7 +360,7 @@
                            //得到信息
                            ds = oCN.RunProcReturn("select * from h_v_IFCLD_ICMOList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IFCLD_ICMOList");
                            //写入信息
                            ListRows.Add(HSourceOrderList(ds.Tables[0], ordrlist, HBarCodeType));
                            ListRows.Add(HSourceOrderList(ds.Tables[0],ordrlist, HBarCodeType));
                            break;
                        case "3711": //生产汇报单
                            //得到信息
@@ -393,7 +393,7 @@
                            ListRows.Add(HSourceOrderList1(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
                            break;
                        case "1202": //生产入库
                                     //得到信息
                             //得到信息
                            ds = oWebs.getDataSetBySQL("select * from h_v_IF_ProductInBillList_Source where HMainID=" + oSelectRow.BillMainID + " and HSubID=" + oSelectRow.BillSubID, "h_v_IF_ProductInBillList_Source", ref DBUtility.ClsPub.sExeReturnInfo);
                            //写入信息
                            ListRows.Add(Sub_WriteInForm_InOut(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
@@ -460,7 +460,7 @@
            return objJsonResult;
        }
        public object HSourceOrderList(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType)
        public object HSourceOrderList(DataTable dt, HSouceOrderList ordrlist,string HBarCodeType)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
@@ -514,7 +514,7 @@
                {
                    ordrlist.HMinQty = dt.Rows[i]["未生成条码数量"].ToString();
                }
                else if (HBarCodeType == "仪器外购件条码普通规则" || HBarCodeType == "仪器成品条码规则" || HBarCodeType == "试剂成品条码规则")
                else if (HBarCodeType == "仪器外购件条码普通规则"|| HBarCodeType == "仪器成品条码规则"|| HBarCodeType == "试剂成品条码规则")
                {
                    ordrlist.HMinQty = "1";
                }
@@ -526,7 +526,7 @@
            return ordrlist;
        }
        public object HSourceOrderList1(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType, string HSourceBillType)
        public object HSourceOrderList1(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType,string HSourceBillType)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
@@ -553,7 +553,7 @@
                ordrlist.HRemark = dt.Rows[i]["备注"].ToString();
                ordrlist.HMTONo = dt.Rows[i]["计划跟踪号"].ToString();
                if (HSourceBillType == "收料通知单")
                if(HSourceBillType == "收料通知单")
                {
                    if (oSystemParameter.omodel.WMS_CampanyName != "瑞与祺")
                    {
@@ -576,10 +576,10 @@
                    ordrlist.HMinQty = dt.Rows[i]["最小包装数"].ToString();
                }
                ordrlist.HMaker = ClsPub.CurUserName;
                if (HSourceBillType == "收料通知单" || HSourceBillType == "采购订单" || HSourceBillType == "委外订单" || HSourceBillType == "采购入库单")
                if (HSourceBillType== "收料通知单"|| HSourceBillType== "采购订单"|| HSourceBillType=="委外订单"|| HSourceBillType== "采购入库单")
                {
                    ordrlist.HInnerBillNo = dt.Rows[i]["内部采购订单号"].ToString();
                    ordrlist.HSupID = dt.Rows[i]["hsupid"].ToString();
                    ordrlist.HSupID= dt.Rows[i]["hsupid"].ToString();
                    ordrlist.HSupNumber = dt.Rows[i]["供应商代码"].ToString();
                    ordrlist.HSupName = dt.Rows[i]["供应商"].ToString();
                    if (HSourceBillType == "收料通知单")
@@ -593,16 +593,22 @@
                            ordrlist.HGiveAwayFlag = 0;
                        }
                    }
                    if (HSourceBillType == "采购订单")
                    if (HSourceBillType == "收料通知单" || HSourceBillType == "采购订单")
                    {
                        ordrlist.HSourceBillSEQ = dt.Rows[i]["HSEQ"].ToString();
                        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 == "退货通知单")
                {
                    ordrlist.HCusID = dt.Rows[i]["HCusID"].ToString();
                    ordrlist.HCusNumber = dt.Rows[i]["客户代码"].ToString();
                    ordrlist.HCusName = dt.Rows[i]["客户"].ToString();
                    ordrlist.HCusName= dt.Rows[i]["客户"].ToString();
                }
                if (HSourceBillType == "其他入库单" || HSourceBillType == "领料出库单")
                {
@@ -613,7 +619,7 @@
                    ordrlist.HSPNumber = dt.Rows[i]["仓位代码"].ToString();
                    ordrlist.HSPName = dt.Rows[i]["仓位"].ToString();
                }
                if (HSourceBillType == "销售出库单")
                if(HSourceBillType == "销售出库单")
                {
                    ordrlist.HWhID = dt.Rows[i]["HWhID"].ToString();
                    ordrlist.HWhNumber = dt.Rows[i]["仓库代码"].ToString();
@@ -629,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();
@@ -660,8 +666,22 @@
                ordrlist.HSPNumber = dt.Rows[i]["仓位代码"].ToString();
                ordrlist.HSPName = dt.Rows[i]["仓位"].ToString();
                ordrlist.HMTONo = dt.Rows[i]["计划跟踪号"].ToString();
                ordrlist.HDate = 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;
        }
@@ -707,7 +727,7 @@
                if (oDs == null && oDs.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.Message = "[0000-2-053]生成批次失败!";
                    objJsonResult.Message= "[0000-2-053]生成批次失败!";
                    return objJsonResult;
                }
                else if (DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][0]) == "1")
@@ -724,7 +744,7 @@
            if (b == false)
            {
                objJsonResult.code = "1";
                objJsonResult.Message = "[3899-2-003]没有需要生成批次的明细行!";
                objJsonResult.Message= "[3899-2-003]没有需要生成批次的明细行!";
                return objJsonResult;
            }
            else //完全封闭
@@ -748,7 +768,7 @@
                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 CampanyName = sArray[4].ToString()=="xxx"?"": sArray[4].ToString();
                string UserName = sArray[5].ToString();
                ClsPub.CurUserName = UserName;
@@ -809,7 +829,7 @@
                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);             // è®¡åˆ’跟踪号
                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);             // æœ€å°åŒ…装数
@@ -842,7 +862,7 @@
        #endregion
        #region[条码生成方法]
        private object SaveBarCode(string msg2, string HSelectBarCodeType, string CampanyName, string HSourceBillTypeName)
        private object SaveBarCode(string msg2, string HSelectBarCodeType, string CampanyName,string HSourceBillTypeName)
        {
            int LSHlen = 6;             //流水号长度
            int SumLen = 10;            //总长度
@@ -963,8 +983,7 @@
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (CampanyName == "瑞与祺")
                        {
                        else if (CampanyName == "瑞与祺") {
                            var date = DateTime.Now.ToString("yyMMdd");//日期
                            if (HSourceBillTypeName == "收料通知单")
                            {
@@ -1143,7 +1162,7 @@
                    HMinQty = ClsPub.isDoule(ordrlist[j].HMinQty);
                    HSumQty = ClsPub.isDoule(ordrlist[j].HQty);
                    n = 0;
                    for (int i = k; i < HBQty; i++)
                    {
                        if (HSumQty - HMinQty > 0)
@@ -1193,19 +1212,21 @@
                            objJsonResult.Message = "条形码不能为空,不能生成条码!";
                            return objJsonResult;
                        }
                        HBarCodeList barcode = new HBarCodeList();
                        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);
@@ -1214,10 +1235,15 @@
                                //条码规则:采购订单单号@行号@物料代码@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 + "@" + sHQty;
                                //条码规则:物料内码@MTO@批次号@数量
                                TM = HNumber + "@" + sHMTONo + "@" + HBatchNo + "@" + sHQty;
                            }
                        }
@@ -1522,7 +1548,7 @@
        {
            try
            {
                oCN.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HitemID in(" + msg + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                oCN.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HitemID in("+msg+")", ref DBUtility.ClsPub.sExeReturnInfo);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "更新打印次数成功";
@@ -1538,7 +1564,7 @@
        }
        #endregion
        #region æ¡ç å­˜å…¥æ¡ç ä¸»æ¡£
        #region æ¡ç è½¬å­˜æ¡ç ä¸»æ¡£
        /// <summary>
        /// æ¡ç è½¬å­˜æ¡ç ä¸»æ¡£
        /// </summary>
@@ -1552,7 +1578,7 @@
            {
                var _value = msg["msg"].ToString();
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.None);
                string msg2 = sArray[0].ToString();
                string HOrgType = sArray[1].ToString();
                string HSourceBillTypeName = sArray[2].ToString();
@@ -1560,6 +1586,9 @@
                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;
                //获取内码
@@ -1588,37 +1617,40 @@
                }
                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]);
                    // 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 + "'" +
                    DataSet ds1 = oCN.RunProcReturn("exec h_p_SC_BarCode_Transfer " +
                        "@HBarCodeNo = N'" + barCodeNo + "'" +
                        ",@HSubID = " + ordrlist[0].HSubID +
                        ",@HMaterID = " + ordrlist[0].HMaterID +
                        ",@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 + "'" +
                        ",@HBatchNo = N'" + ordrlist[0].HBatchNo  + "'" +
                        ",@HMTONO = N'" + ordrlist[0].HMTONo + "'" +
                        ",@HBarCodeDate = N'" + ordrlist[0].HDate + "'" +
                        ",@HEmpID = " + ordrlist[0].HEmpID +
                        ",@HGroupID = " + ordrlist[0].HGroupID +
                        ",@HSourceInterID = " + HSourceInterID +
                        ",@HEmpID = " + ordrlist[0].HEmpID  +
                        ",@HSourceInterID = " + HSourceInterID +
                        ",@HSourceEntryID = " + HSourceEntryID +
                        ",@HBarCodeType = N'" + HSelectBarCodeType + "'"+
                        ",@HSourceBillNo = N'" + ordrlist[0].HBillNo + "'"+
                        ",@HMaker = N'" + UserName + "'"
                        ",@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)
                    if((bool)ds1.Tables[0].Rows[0]["returntype"] == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -1628,7 +1660,7 @@
                    {
                        throw new Exception(ds1.Tables[0].Rows[0]["mesg"].ToString());
                    }
                }
            }
            catch (Exception e)
@@ -1844,7 +1876,7 @@
                            oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");           //更新最大流水号
                        }
                    }
                    else if (HSelectBarCodeType == "BarCode_Box")
                    else if(HSelectBarCodeType == "BarCode_Box")
                    {
                        int HBQty = ClsPub.isInt(ordrlist[i].HBQty);                            //箱数