Ejemplo n.º 1
0
        public List <T_StockInfo> GetNewListStock(string strBarCode, T_StockInfo newModel) //, T_StockInfo stockModel
        {
            List <T_StockInfo>      lstStock    = new List <T_StockInfo>();
            T_OutBarcode_DB         odb         = new T_OutBarcode_DB();
            List <T_OutBarCodeInfo> lstHbarCode = odb.GetBarCodeOutAll(strBarCode);

            foreach (var item in lstHbarCode)
            {
                T_StockInfo model = new T_StockInfo();

                model.Barcode        = item.BarCode;
                model.SerialNo       = item.SerialNo;
                model.BarCodeType    = item.BarcodeType;
                model.MaterialNo     = item.MaterialNo;
                model.MaterialDesc   = item.MaterialDesc;
                model.Qty            = item.Qty.ToDecimal();
                model.CompanyCode    = item.CompanyCode;
                model.StrongHoldCode = item.StrongHoldCode;
                model.StrongHoldName = item.StrongHoldName;
                model.fserialno      = item.fserialno;
                model.BatchNo        = item.BatchNo;
                model.WarehouseNo    = newModel.WarehouseNo;
                model.ErpVoucherNo   = newModel.ErpVoucherNo;
                model.IsPalletOrBox  = newModel.IsPalletOrBox;
                model.PalletNo       = newModel.PalletNo;
                //model.AreaID = stockModel.AreaID;
                lstStock.Add(model);
            }
            return(lstStock);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据托盘条码获取托盘明细
        /// </summary>
        /// <returns></returns>
        private bool GetPalletInfoByPalletSerialNo(string SerialNo, ref List <T_OutBarCodeInfo> modelList, ref string strError)
        {
            bool bSucc = false;
            T_PalletDetail_Func palletFunc = new T_PalletDetail_Func();
            string  strFilter    = string.Empty;
            decimal SumPalletQty = 0;
            List <T_OutBarCodeInfo> HModelList = new List <T_OutBarCodeInfo>();
            T_OutBarcode_DB         odb        = new T_OutBarcode_DB();

            //根据托盘号获取托盘明细
            strFilter = "palletno =  '" + SerialNo + "'";

            if (outBarCodeFunc.GetOutBarCodeByPalletNo(SerialNo, ref modelList, ref strError) == false)
            {
                bSucc = false;
            }
            else
            {
                HModelList = modelList.Where(t => t.BarcodeType == 5).ToList();

                if (HModelList != null && HModelList.Count > 0)
                {
                    foreach (var item in HModelList)
                    {
                        modelList.Find(t => t.ID == item.ID).lstBarCode = odb.GetBarCodeOutAll(item.BarCode);
                    }
                }
                modelList.ForEach(t => t.PalletNo = SerialNo);
                SumPalletQty = modelList.Sum(t1 => t1.Qty).ToDecimal();
                modelList.ForEach(t => t.PalletQty = SumPalletQty);
                bSucc = true;
            }

            return(bSucc);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 验证条码是否有相同数据
        /// </summary>
        /// <param name="modelList"></param>
        /// <param name="strErrMsg"></param>
        /// <returns></returns>
        private bool CheckBarCodeIsSame(List <T_InStockDetailInfo> modelList, ref string strErrMsg)
        {
            bool bSucc = false;

            List <T_OutBarCodeInfo> lstBarCode = new List <T_OutBarCodeInfo>();

            foreach (var item in modelList)
            {
                lstBarCode.AddRange(item.lstBarCode);
            }

            var groupByList = from t in lstBarCode
                              group t by new { t1 = t.SerialNo } into m
                select new
            {
                SerialNo = m.Key.t1
            };

            if (groupByList.Count() != modelList.Count)
            {
                strErrMsg = "收货条码存在相同数据,不能提交!";
                bSucc     = false;
            }
            else
            {
                bSucc = true;
            }

            T_OutBarcode_DB _db = new T_OutBarcode_DB();

            bSucc = _db.CheckBarCodeIsExists(XmlUtil.Serializer(typeof(List <T_OutBarCodeInfo>), lstBarCode), ref strErrMsg);

            return(bSucc);
        }
Ejemplo n.º 4
0
        protected override bool CheckGuid(string Guid, ref string strError)
        {
            T_OutBarcode_DB db = new T_OutBarcode_DB();

            if (db.GetGuid(Guid) > 0)
            {
                return(false);
            }
            db.InsertGuid(Guid, ref strError);
            return(true);
        }
Ejemplo n.º 5
0
        ///// <summary>
        ///// 获取序列号
        ///// </summary>
        ///// <param name="count"></param>
        ///// <returns></returns>
        //public List<string> GetSerialnos(int count)
        //{
        //    List<string> serialnos = new List<string>();
        //    for (int i = 0; i < count; i++)
        //    {
        //        string code = "1" + DateTime.Now.ToString("MMdd") + getSqu(Guid.NewGuid().ToString("N"));
        //        if (serialnos.Find(x => x == code) != null)
        //        {
        //            i--;
        //            continue;
        //        }
        //        serialnos.Add(code);
        //    }
        //    return serialnos;
        //}

        //public string getSqu(string ss)
        //{
        //    if (ss.Length >= 8)
        //    {
        //        ss = ss.Substring(ss.Length - 8, 8);
        //    }
        //    else
        //    {
        //        ss = "00000000" + ss;
        //        ss = ss.Substring(ss.Length - 8, 8);
        //    }
        //    return ss;
        //}

        //public JsonResult Print(string IDs, string Path)
        //{
        //    try
        //    {
        //        List<Barcode_Model> barcodelist = new List<Barcode_Model>();
        //        var Isxls = System.IO.Path.GetExtension(Path).ToString().ToLower();
        //        DataTable dt = new DataTable();
        //        if (Isxls == ".xls")
        //        {
        //            dt = ImportExcelFile(Path);
        //        }
        //        if (Isxls == ".xlsx")
        //        {
        //            dt = ImportExcelFilexlsx(Path);
        //        }
        //        barcodelist = Print_DB.ConvertToModel<Barcode_Model>(dt);
        //        List<Barcode_Model> barcodelistnew = new List<Barcode_Model>();
        //        List<Barcode_Model> barcodelistnewsub = new List<Barcode_Model>();
        //        List<Barcode_Model> barcodelistnewAll = new List<Barcode_Model>();
        //        string[] ids = IDs.Split(',');
        //        for (int i = 0; i < ids.Length; i++)
        //        {
        //            if (ids[i] != "")
        //            {
        //                List<Barcode_Model> barcodes = new List<Barcode_Model>();
        //                barcodes.AddRange(barcodelist.Where(P => P.RowNo == ids[i]));
        //                //单张条码
        //                //Barcode_Model model = (Barcode_Model)DeepCopy(barcodes[0]);
        //                //barcodelistnew.Add(model);
        //                //多张条码
        //                if (barcodes.Count == 1 && barcodes[0].BoxCount >= 1)
        //                {
        //                    for (int j = 0; j < barcodes[0].BoxCount; j++)
        //                    {
        //                        Barcode_Model model = (Barcode_Model)DeepCopy(barcodes[0]);
        //                        barcodelistnew.Add(model);
        //                    }
        //                }

        //            }
        //        }

        //        if (barcodelistnew != null && barcodelistnew.Count > 0)
        //        {
        //            string strMsg = "";
        //            PrintInController printIn = new PrintInController();
        //            List<string> squence = printIn.GetSerialnos(barcodelistnew.Count.ToString(), "外", ref strMsg);
        //            int k = 0;
        //            DateTime time = DateTime.Now;
        //            for (int i = 0; i < barcodelistnew.Count; i++)
        //            {
        //                barcodelistnew[i].CompanyCode = "SHJC";
        //                barcodelistnew[i].BarcodeType = 1;
        //                barcodelistnew[i].SerialNo = squence[k++];
        //                barcodelistnew[i].Creater = currentUser.UserNo;
        //                barcodelistnew[i].ReceiveTime = time;
        //                barcodelistnew[i].BarCode = "1@" + barcodelistnew[i].StrongHoldCode + "@" + barcodelistnew[i].MaterialNo + "@" + barcodelistnew[i].BatchNo + "@" + barcodelistnew[i].Qty + "@" + barcodelistnew[i].SerialNo;

        //                //查物料
        //                T_Material_Func funM = new T_Material_Func();
        //                string strErrMsg = "";
        //                List<T_MaterialInfo> modelList = funM.GetMaterialModelBySql(barcodelistnew[i].MaterialNo, ref strErrMsg);
        //                if (modelList == null || modelList.Count == 0)
        //                {
        //                    //失败
        //                    return Json(new { state = false, obj = "没有该物料号" + barcodelistnew[i].MaterialNo }, JsonRequestBehavior.AllowGet);
        //                }
        //                if (modelList[0].sku == "是")
        //                {
        //                    for (int kk = 0; kk < barcodelistnew[i].Qty; kk++)
        //                    {
        //                        Barcode_Model modelsub = (Barcode_Model)DeepCopy(barcodelistnew[i]);
        //                        modelsub.fserialno = barcodelistnew[i].SerialNo;
        //                        barcodelistnewsub.Add(modelsub);
        //                    }
        //                }
        //            }

        //            //本体打印
        //            DateTime timesub = DateTime.Now.AddSeconds(5);
        //            if (barcodelistnewsub != null && barcodelistnewsub.Count > 0)
        //            {
        //                List<string> squencesub = printIn.GetSerialnos(barcodelistnewsub.Count.ToString(), "内", ref strMsg);
        //                int ksub = 0;

        //                for (int isub = 0; isub < barcodelistnewsub.Count; isub++)
        //                {
        //                    barcodelistnewsub[isub].CompanyCode = "SHJC";
        //                    barcodelistnewsub[isub].BarcodeType = 2;
        //                    barcodelistnewsub[isub].SerialNo = squencesub[ksub++];
        //                    barcodelistnewsub[isub].Creater = currentUser.UserNo;
        //                    barcodelistnewsub[isub].ReceiveTime = timesub;
        //                    barcodelistnewsub[isub].Qty = 1;

        //                    barcodelistnewsub[isub].BarCode = "2@" + barcodelistnewsub[isub].StrongHoldCode + "@" + barcodelistnewsub[isub].MaterialNo + "@" + barcodelistnewsub[isub].BatchNo + "@1@" + barcodelistnewsub[isub].SerialNo;

        //                }
        //            }
        //            barcodelistnewAll.AddRange(barcodelistnew);
        //            barcodelistnewAll.AddRange(barcodelistnewsub);
        //            Print_DB func = new Print_DB();
        //            if (func.SubBarcodesNoPrint(barcodelistnewAll, ref strMsg))
        //            {
        //                if (barcodelistnewsub != null && barcodelistnewsub.Count > 0)
        //                {
        //                    return Json(new { state = true, obj = time.ToString("yyyy/MM/dd HH:mm:ss"), obj1 = timesub.ToString("yyyy/MM/dd HH:mm:ss") }, JsonRequestBehavior.AllowGet);
        //                }
        //                else
        //                {
        //                    return Json(new { state = true, obj = time.ToString("yyyy/MM/dd HH:mm:ss"), obj1 = "" }, JsonRequestBehavior.AllowGet);
        //                }
        //            }
        //            else
        //            {
        //                //失败
        //                return Json(new { state = false, obj = strMsg }, JsonRequestBehavior.AllowGet);
        //            }
        //        }
        //        else
        //        {
        //            //失败
        //            return Json(new { state = false, obj = "数据为空" }, JsonRequestBehavior.AllowGet);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return Json(new { state = false, obj = ex.ToString() }, JsonRequestBehavior.AllowGet);
        //    }

        //}

        public JsonResult CheckSKU(string serialno)
        {
            try
            {
                T_OutBarcode_DB funb = new T_OutBarcode_DB();
                string          sku  = funb.GetMaterialno(serialno);
                if (sku == "是")
                {
                    return(Json(new { state = true }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { state = false }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json(new { state = false }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 6
0
        public List <T_OutStockTaskDetailsInfo> CreateNewListByPickRuleAreaNo(List <T_OutStockTaskDetailsInfo> modelList, List <T_StockInfo> stockList)
        {
            List <T_OutStockTaskDetailsInfo> NewModelList = new List <T_OutStockTaskDetailsInfo>();
            List <T_StockInfo> stockModelList             = new List <T_StockInfo>();
            List <T_StockInfo> stockModelListSum          = new List <T_StockInfo>();
            string             strAreaNo = string.Empty;

            //单据客编码
            T_OutBarcode_DB OutBarcodeDB = new T_OutBarcode_DB();
            string          CUSTOMERCODE = OutBarcodeDB.GetTaskCusCode(modelList[0].HeaderID.ToString());

            //库存里面客户加上
            stockList.ForEach(item => {
                item.CusCode = OutBarcodeDB.GetCusCode(item.SerialNo);
            });

            foreach (var item in modelList)
            {
                //查找物料可分配库存
                List <T_StockInfo> stockModelListForCusCode = stockList.FindAll(t => t.CusCode == CUSTOMERCODE && t.MaterialNoID == item.MaterialNoID && t.WarehouseNo == item.FromErpWarehouse && t.Qty > 0).OrderBy(t => t.BatchNo).OrderBy(t => t.SortArea).ToList();
                //stockModelList = stockList.FindAll(t => t.MaterialNoID == item.MaterialNoID && t.StrongHoldCode==item.StrongHoldCode && t.WarehouseNo==item.FromErpWarehouse && t.HouseProp==item.HouseProp && t.Qty>0 && t.BatchNo==item.FromBatchNo ).OrderBy(t=>t.EDate).OrderBy(t=>t.SortArea).ToList();
                //if (stockModelList.Count==0|| stockModelList==null)
                //{
                stockModelList = stockList.FindAll(t => t.MaterialNoID == item.MaterialNoID && t.WarehouseNo == item.FromErpWarehouse && t.Qty > 0).OrderBy(t => t.BatchNo).OrderBy(t => t.SortArea).ToList();
                //}
                List <T_StockInfo> stockModelListSumForCusCode = CreateNewStockInfoSum(stockModelListForCusCode);
                stockModelListSum = CreateNewStockInfoSum(stockModelList);

                //优先匹配客户
                if (stockModelListSumForCusCode != null && stockModelListSumForCusCode.Count > 0)
                {
                    strAreaNo = string.Empty;
                    foreach (var itemArea in stockModelListSumForCusCode)
                    {
                        strAreaNo += itemArea.AreaNo + "|";
                    }
                    item.AreaNo = strAreaNo;
                }

                if (stockModelListSum != null && stockModelListSum.Count > 0)
                {
                    strAreaNo = string.Empty;
                    foreach (var itemArea in stockModelListSum)
                    {
                        if (stockModelListSumForCusCode.FindAll(t => t.AreaNo == itemArea.AreaNo).ToList().Count == 0)
                        {
                            strAreaNo += itemArea.AreaNo + "|";
                        }
                    }
                    item.AreaNo += strAreaNo;
                }
                item.AreaNo = item.AreaNo == null?"": item.AreaNo.TrimEnd('|');
                //暂时屏蔽,拆分推荐库位
                //foreach (var stockModel in stockModelListSum)
                //{
                //    if (item.RemainQty < stockModel.Qty)
                //    {
                //        item.RePickQty = item.RemainQty;
                //        stockModel.Qty = stockModel.Qty - item.RemainQty.ToDecimal();
                //        NewModelList.Add(CreateNewOutStockModelToADF(stockModel, item));
                //        break;
                //    }
                //    else if (item.RemainQty == stockModel.Qty)
                //    {
                //        item.RePickQty = stockModel.Qty;
                //        stockModel.Qty = 0;
                //        NewModelList.Add(CreateNewOutStockModelToADF(stockModel, item));
                //        break;
                //    }
                //    else if (item.RemainQty > stockModel.Qty)
                //    {
                //        item.RePickQty = stockModel.Qty;
                //        item.RemainQty = item.RemainQty - stockModel.Qty;
                //        stockModel.Qty = 0;
                //        NewModelList.Add(CreateNewOutStockModelToADF(stockModel, item));
                //    }
                //}
            }

            ///暂时屏蔽,代码有用,拆分推荐库位有用
            //if (NewModelList == null || NewModelList.Count == 0)
            //{
            //    modelList.ForEach(t => t.RePickQty=0);
            //    return modelList;
            //}
            //else
            //{
            //    return NewModelList.OrderBy(t => t.FloorType).OrderBy(t => t.SortArea).ToList();
            //}
            modelList.ForEach(t => t.ToBatchNo = t.FromBatchNo);
            modelList.ForEach(t => t.BatchNo   = t.FromBatchNo);
            return(modelList);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 外箱条码没有收货,需要查询是否已经拼托,如果拼托要返回整托信息,如果没有拼托则返回单个条码,用条码类封装
        /// </summary>
        /// <param name="SerialNo"></param>
        /// <param name="?"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        private bool GetPalletInfoBySerialNo(string SerialNo, ref List <T_OutBarCodeInfo> modelList, ref string strError)
        {
            bool                      bSucc           = false;
            string                    strFilter       = string.Empty;
            T_OutBarCodeInfo          model           = new T_OutBarCodeInfo();
            T_OutBarCode_Func         toc             = new T_OutBarCode_Func();
            T_PalletDetail_Func       palletFunc      = new T_PalletDetail_Func();
            List <T_PalletDetailInfo> lstPallet       = new List <T_PalletDetailInfo>();
            T_OutBarCodeInfo          outBarCodeModel = new T_OutBarCodeInfo();
            List <T_OutBarCodeInfo>   HModelList      = new List <T_OutBarCodeInfo>();
            T_OutBarcode_DB           odb             = new T_OutBarcode_DB();
            decimal                   SumPalletQty    = 0;

            //外箱条码不存在
            if (outBarCodeFunc.GetOutBarCodeInfoBySerialNo(SerialNo, ref model, ref strError) == false)
            {
                return(false);
            }


            strFilter = "palletno = (select palletno from t_Palletdetail where barcode = '" + model.BarCode + "')";

            //外箱条码存在,但是没有组托,需要生成新的托盘类,返回客户端
            if (palletFunc.GetPalletByPalletNo(strFilter, ref lstPallet, ref strError) == false)
            {
                if (toc.GetOutBarCodeInfoBySerialNo(SerialNo, ref outBarCodeModel, ref strError) == false)
                {
                    return(false);
                }

                if (outBarCodeModel.BarcodeType == 5) //混箱
                {
                    model.BarcodeType = 5;

                    model.lstBarCode = odb.GetBarCodeOutAll(model.BarCode);
                }

                modelList.Add(model);
                bSucc = true;
            }
            else //已经组托,根据组托条码获取条码类
            {
                if (outBarCodeFunc.GetOutBarCodeByPalletNo(lstPallet[0].PalletNo, ref modelList, ref strError) == false)
                {
                    bSucc = false;
                }
                else
                {
                    HModelList = modelList.Where(t => t.BarcodeType == 5).ToList();

                    if (HModelList != null && HModelList.Count > 0)
                    {
                        foreach (var item in HModelList)
                        {
                            modelList.Find(t => t.ID == item.ID).lstBarCode = odb.GetBarCodeOutAll(item.BarCode);
                        }
                    }

                    modelList.ForEach(t => t.PalletNo = lstPallet[0].PalletNo);
                    SumPalletQty = modelList.Sum(t1 => t1.Qty).ToDecimal();
                    modelList.ForEach(t => t.PalletQty = SumPalletQty);
                    bSucc = true;
                }
            }

            return(bSucc);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据条码或者托盘号获取托盘明细,不需要需要获取库存数据的,收货用
        /// 条码有组托返回托盘明细,没有组托返回单个条码托盘明细
        /// 托盘条码返回托盘明细
        /// 该接口判断了条码或者托盘是否已经入库
        /// </summary>
        /// <param name="BarCode"></param>
        /// <returns></returns>
        public string GetPalletDetailByBarCode(string UserJson, string BarCode, string VoucherType)
        {
            BaseMessage_Model <List <T_OutBarCodeInfo> > model = new BaseMessage_Model <List <T_OutBarCodeInfo> >();
            List <T_OutBarCodeInfo> modelList = new List <T_OutBarCodeInfo>();
            string strPalletNo = string.Empty;
            string SerialNo    = string.Empty;
            string strError    = string.Empty;
            string BarCodeType = string.Empty;


            try
            {
                if (string.IsNullOrEmpty(BarCode))
                {
                    model.HeaderStatus = "E";
                    model.Message      = "客户端传来的托盘号或者条码为空!";
                    return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                }

                if (string.IsNullOrEmpty(UserJson))
                {
                    model.HeaderStatus = "E";
                    model.Message      = "客户端传来的用户JSON为空!";
                    return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                }

                UserModel userModel = JSONHelper.JsonToObject <UserModel>(UserJson);
                if (userModel == null || string.IsNullOrEmpty(userModel.UserNo))
                {
                    model.HeaderStatus = "E";
                    model.Message      = "解析用户JSON为空!";
                    return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                }

                //调拨单单独处理
                if (BarCode.Substring(0, 2) == "DC")
                {
                    T_OutBarcode_DB _db = new T_OutBarcode_DB();
                    modelList = _db.GetOutBarCodeByDimension(BarCode);
                    if (modelList == null || modelList.Count == 0)
                    {
                        model.HeaderStatus = "E";
                        model.Message      = "获取调拨单条码为空";
                        return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                    }
                    else
                    {
                        model.HeaderStatus = "S";
                        model.ModelJson    = modelList;
                        return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                    }
                }
                else
                {
                    //验证条码正确性
                    if (outBarCodeFunc.GetSerialNoByBarCode(BarCode, ref SerialNo, ref BarCodeType, ref strError) == false)
                    {
                        model.HeaderStatus = "E";
                        model.Message      = strError;
                        return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                    }

                    //验证外箱条码或者托盘条码是否已经收货
                    if (outBarCodeFunc.CheckBaeCodeIsReciveForTB(userModel, SerialNo, ref strError, VoucherType) == false)
                    {
                        model.HeaderStatus = "E";
                        model.Message      = strError;
                        return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                    }

                    if (GetPalletDetailBySerialNo(ref modelList, SerialNo, ref strError, BarCodeType) == false)
                    {
                        model.HeaderStatus = "E";
                        model.Message      = strError;
                        return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                    }



                    ///如果物料,批次在DJ存在已经判定的质量状态。必须先移走
                    //T_Stock_DB _db = new T_Stock_DB();
                    //string strStatus = _db.GetMaterialBatchStatus(modelList[0].MaterialNo, modelList[0].BatchNo, userModel.ReceiveAreaID.ToString());
                    //if (strStatus == "3")
                    //{
                    //    model.HeaderStatus = "E";
                    //    model.ModelJson = null;
                    //    model.Message = "物料:" + modelList[0].MaterialNo + "批次:" + modelList[0].BatchNo + "在收货库位检验合格,请先移至其他库位后再进行收货!";
                    //    return JSONHelper.ObjectToJson<BaseMessage_Model<List<T_OutBarCodeInfo>>>(model);
                    //}

                    //if (strStatus == "4")
                    //{
                    //    model.HeaderStatus = "E";
                    //    model.ModelJson = null;
                    //    model.Message = "物料:" + modelList[0].MaterialNo + "批次:" + modelList[0].BatchNo + "在收货库位检验不合格,请先移至其他库位后再进行收货!";
                    //    return JSONHelper.ObjectToJson<BaseMessage_Model<List<T_OutBarCodeInfo>>>(model);
                    //}

                    //截取物料第一位
                    //string IsKeGong = modelList[0].MaterialNo.Substring(0, 1);
                    //string UserWareHouse = userModel.ReceiveWareHouseNo;

                    //if (IsKeGong.ToUpper().Equals("K")) //是客供料
                    //{
                    //    if (!"AD05,AD09,AD08,AD10,AD11".Contains(UserWareHouse))
                    //    {
                    //        model.HeaderStatus = "E";
                    //        model.ModelJson = null;
                    //        model.Message = "客供料收货仓库错误!应录入客供品仓库!当前登录仓库为:" + UserWareHouse;
                    //        return JSONHelper.ObjectToJson<BaseMessage_Model<List<T_OutBarCodeInfo>>>(model);
                    //    }
                    //}
                    //else
                    //{
                    //    if ("AD05".Contains(UserWareHouse))
                    //    {
                    //        model.HeaderStatus = "E";
                    //        model.ModelJson = null;
                    //        model.Message = "非客供料不能录入客供品仓库!当前登录仓库为:" + UserWareHouse;
                    //        return JSONHelper.ObjectToJson<BaseMessage_Model<List<T_OutBarCodeInfo>>>(model);
                    //    }
                    //}

                    model.HeaderStatus = "S";
                    model.ModelJson    = modelList;
                    return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
                }
            }
            catch (Exception ex)
            {
                model.HeaderStatus = "E";
                model.Message      = ex.Message;
                return(JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(model));
            }
        }
Ejemplo n.º 9
0
        public string Post(string ErpVoucherNo, string Remark, string Guid, string Creater)
        {
            LogNet.LogInfo("-------------------------------------------直发公司ErpVoucherNo:【" + ErpVoucherNo + "】,  Remark:【" + Remark + "】, Guid:【" + Guid + "】, Creater::【" + Creater + "】");
            BaseMessage_Model <string> messageModel = new BaseMessage_Model <string>();

            try
            {
                T_Material_Batch_DB _db = new T_Material_Batch_DB();
                //成品需要检验库存
                string Msg  = "";
                bool   isOK = _db.isChengpin(ErpVoucherNo, ref Msg);
                if (isOK)
                {
                    if (!string.IsNullOrEmpty(Msg))
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = Msg;
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }

                    T_OutBarcode_DB         OutBarcodeDB    = new T_OutBarcode_DB();
                    List <T_OutBarCodeInfo> OutBarCodeInfos = OutBarcodeDB.GetModelListByFilter("", " dimension='" + ErpVoucherNo + "'", " * ");
                    if (OutBarCodeInfos == null || OutBarCodeInfos.Count == 0)
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "WMS不存在属于该成品入库单【" + ErpVoucherNo + "】的条码!";
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }
                }

                string strERP = _db.Post(ErpVoucherNo, Remark, Guid, Creater);
                if (strERP.Substring(0, 1) == "0")
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = strERP;
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                }

                if (isOK)
                {
                    string strError = "";
                    T_OutTaskDetails_DB _dbOutTaskDetails = new T_OutTaskDetails_DB();
                    LogNet.LogInfo("-------------------------------------------直发公司ERP成功凭证号:" + strERP.Substring(1, strERP.Length - 1));
                    if (_dbOutTaskDetails.DelStockForU9(ErpVoucherNo, strERP.Substring(1, strERP.Length - 1), ref strError) == false)
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "ERP操作成功,ERP凭证号:" + strERP.Substring(1, strERP.Length - 1) + "WMS失败:" + strError;
                        LogNet.LogInfo("-------------------------------------------直发公司ERP成功凭证号:" + messageModel.Message);
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }
                    else
                    {
                        messageModel.HeaderStatus = "S";
                        messageModel.Message      = "操作成功!ERP凭证号:" + strERP.Substring(1, strERP.Length - 1);
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }
                }
                else
                {
                    messageModel.HeaderStatus = "S";
                    messageModel.Message      = "操作成功!ERP凭证号:" + strERP.Substring(1, strERP.Length - 1);
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                }
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
            }
        }
Ejemplo n.º 10
0
        //启用序列号管理
        public override bool GetStockByBarCode(T_StockInfo model, ref List <T_StockInfo> modelList, ref string strError)
        {
            string             strSerialNo     = string.Empty;
            string             BarCodeType     = string.Empty;
            int                iWareHouseID    = 0;
            T_Stock_Func       sfunc           = new T_Stock_Func();
            T_StockInfo        newModel        = new T_StockInfo();
            List <T_StockInfo> newModelList    = new List <T_StockInfo>();
            T_Stock_DB         db              = new T_Stock_DB();
            T_OutBarCode_Func  toc             = new T_OutBarCode_Func();
            T_OutBarCodeInfo   outBarCodeModel = new T_OutBarCodeInfo();
            T_OutBarCodeInfo   JBarCodeModel   = new T_OutBarCodeInfo();
            T_OutBarcode_DB    odb             = new T_OutBarcode_DB();

            //if (model.Barcode.Contains("@") == true)
            //{
            //    strSerialNo = OutBarCode_DeCode.GetEndSerialNo(model.Barcode);
            //    //根据序列号查库存
            //    if (sfunc.GetStockByBarCode(strSerialNo, ref newModel, ref strError) == false)
            //    {
            //        return false;
            //    }

            //}
            //else
            //{
            //    iWareHouseID = model.WareHouseID;

            //    newModelList = db.GetStockByWHBarCode(model);
            //    if (newModelList == null || newModelList.Count==0)
            //    {
            //        strError = Language_CHS.StockIsEmpty;
            //        return false;
            //    }
            //    if (string.IsNullOrEmpty(model.ErpVoucherNo))
            //    {
            //        newModelList = newModelList.Where(t => t.TaskDetailesID == 0).ToList();
            //    }
            //    else
            //    {
            //        newModelList = newModelList.Where(t => t.TaskDetailesID > 0).ToList();
            //    }

            //}

            if ((model.Barcode.Length == 13 || model.Barcode.Length == 14) && model.ScanType != 2) //69码,复核的时候用
            {
                iWareHouseID = model.WareHouseID;

                newModelList = db.GetStockByWHBarCode(model);
                if (newModelList == null || newModelList.Count == 0)
                {
                    strError = Language_CHS.StockIsEmpty;
                    return(false);
                }
                if (string.IsNullOrEmpty(model.ErpVoucherNo))
                {
                    newModelList = newModelList.Where(t => t.TaskDetailesID == 0).ToList();
                }
                else
                {
                    newModelList = newModelList.Where(t => t.TaskDetailesID > 0).ToList();
                }

                modelList = newModelList;
            }
            else
            {
                if (outBarCodeFunc.GetSerialNoByBarCode(model.Barcode, ref strSerialNo, ref BarCodeType, ref strError) == false)
                {
                    return(false);
                }

                if (BarCodeType == "1")
                {
                    //根据序列号查库存
                    if (sfunc.GetStockByBarCode(strSerialNo, ref newModel, ref strError) == false)
                    {
                        return(false);
                    }
                    //扫描到的是外箱
                    newModel.IsPalletOrBox = 1;
                }
                else if (BarCodeType == "2")
                {
                    if (sfunc.GetStockInfoByPalletNo(strSerialNo, ref modelList, ref strError) == false)
                    {
                        return(false);
                    }



                    //扫描到的是托盘
                    modelList.ForEach(t => t.IsPalletOrBox = 2);
                    List <T_StockInfo> HStockList = modelList.Where(t => t.BarCodeType == 5).ToList();

                    if (HStockList != null && HStockList.Count > 0)
                    {
                        foreach (var item in HStockList)
                        {
                            item.lstHBarCode = GetNewListStock(item.Barcode, item);//odb.GetBarCodeOutAll(model.Barcode);
                            item.lstHBarCode.ForEach(t => t.WareHouseID = item.WareHouseID);
                            item.lstHBarCode.ForEach(t => t.HouseID     = item.HouseID);
                            item.lstHBarCode.ForEach(t => t.AreaID      = item.AreaID);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(model.JBarCode))
                {
                    string strJSerialNo = string.Empty;
                    if (OutBarCode_DeCode.GetSubBarcodeType(model.JBarCode) != "1")
                    {
                        strError = "您扫描的不是J箱条码!";
                        return(false);
                    }
                    strJSerialNo = OutBarCode_DeCode.GetSubBarcodeSerialNo(model.JBarCode);
                    if (toc.GetOutBarCodeInfoBySerialNo(strJSerialNo, ref JBarCodeModel, ref strError) == false)
                    {
                        return(false);
                    }

                    if (odb.GetJBarCodeIsScan(strJSerialNo) > 0)
                    {
                        strError = "J箱条码已经扫描,不能重复扫描!";
                        return(false);
                    }

                    if (JBarCodeModel.fserialno.Substring(0, 1) == "2") //J箱对应中盒
                    {
                        //根据中盒找外箱
                        if (toc.GetOutBarCodeInfoBySerialNo(JBarCodeModel.fserialno, ref JBarCodeModel, ref strError) == false)
                        {
                            return(false);
                        }
                    }

                    if (model.Barcode.CompareTo(JBarCodeModel.fserialno) != 0)
                    {
                        strError = "外箱条码不包含J箱码!";
                        return(false);
                    }
                    else
                    {
                        //J箱码转换库存类
                        modelList.Add(GetAmoutInnerStock(newModel, JBarCodeModel));
                    }
                }

                //外箱条码需要查看条码是否是混箱
                if (BarCodeType == "1" && string.IsNullOrEmpty(model.JBarCode))
                {
                    if (toc.GetOutBarCodeInfoBySerialNo(strSerialNo, ref outBarCodeModel, ref strError) == false)
                    {
                        return(false);
                    }

                    if (outBarCodeModel.BarcodeType == 5) //混箱
                    {
                        newModel.BarCodeType = 5;

                        newModel.lstHBarCode = GetNewListStock(model.Barcode, newModel);//odb.GetBarCodeOutAll(model.Barcode);
                        newModel.lstHBarCode.ForEach(t => t.WareHouseID = newModel.WareHouseID);
                        newModel.lstHBarCode.ForEach(t => t.HouseID     = newModel.HouseID);
                        newModel.lstHBarCode.ForEach(t => t.AreaID      = newModel.AreaID);
                    }
                    else//不是混箱
                    {
                        newModel.BarCodeType = outBarCodeModel.BarcodeType;
                        //查看是否J箱
                        newModel.lstBarCode = odb.GetBarCodeOutAll(model.Barcode);
                        //newModel.lstBarCode.ForEach(t => t.WareHouseID = newModel.WareHouseID);
                        //newModel.lstBarCode.ForEach(t => t.HouseID = newModel.HouseID);
                        //newModel.lstBarCode.ForEach(t => t.AreaID = newModel.AreaID);

                        if (newModel.lstBarCode == null || newModel.lstBarCode.Count == 0)
                        {
                            newModel.ISJ = "2";//不是J箱
                        }
                        else if (newModel.lstBarCode[0].BarcodeType == 1)
                        {
                            newModel.ISJ = "1";                           //是J想
                        }
                        else if (newModel.lstBarCode[0].BarcodeType == 2) //找到中盒
                        {
                            //根据中盒找J箱
                            newModel.lstBarCode = odb.GetBarCodeOutAll(newModel.lstBarCode[0].BarCode);
                            //newModel.lstBarCode.ForEach(t => t.WareHouseID = newModel.WareHouseID);
                            //newModel.lstBarCode.ForEach(t => t.HouseID = newModel.HouseID);
                            //newModel.lstBarCode.ForEach(t => t.AreaID = newModel.AreaID);

                            if (newModel.lstBarCode == null || newModel.lstBarCode.Count == 0)
                            {
                                newModel.ISJ = "2";//不是J箱
                            }
                            else if (newModel.lstBarCode[0].BarcodeType == 1)
                            {
                                newModel.ISJ = "1";//是J箱
                            }
                        }
                        newModel.lstBarCode = null;
                    }
                    modelList.Add(newModel);
                }
            }



            ////整箱或者零数发货
            //if (model.ScanType == 2 || model.ScanType == 3)
            //{
            //    if (model.Barcode.Contains("@") == true)
            //    {
            //        modelList.Add(newModel);
            //    }
            //    else
            //    {
            //        modelList.AddRange(newModelList);
            //    }
            //}

            ////整托发货
            //if (model.ScanType == 1 && model.Barcode.Contains("@") == true)
            //{
            //    if (string.IsNullOrEmpty(newModel.PalletNo))
            //    {
            //        strError = Language_CHS.StockPEmpty;
            //        return false;
            //    }

            //    if (sfunc.GetStockInfoByPalletNo(newModel.PalletNo, ref modelList, ref strError) == false)
            //    {
            //        return false;
            //    }
            //}

            decimal SumQty = modelList.Sum(t1 => t1.Qty).ToDecimal();

            modelList.ForEach(t => t.PalletQty = SumQty);

            return(true);
        }