Exemple #1
0
        private static void SetProduceDate(SpareEntities db, TS_STOCK_DETAIL detail)
        {
            IFormatProvider ifp   = new CultureInfo("zh-CN", true);
            DateTime        pDate = DateTime.Now;

            try
            {
                pDate = DateTime.ParseExact(detail.Batch.Substring(0, 6), "yyMMdd", ifp);
            }
            catch (Exception ex)
            {
//                throw ex;
            }
            var part = db.TA_PART.SingleOrDefault(p => p.PartCode == detail.PartCode);

            if (part == null)
            {
                detail.ProduceDate = pDate;
                return;
            }
            detail.ProduceDate = pDate;
            if (detail.ProduceDate != null)
            {
                detail.OverdueDate = detail.ProduceDate.AddDays(part.ValidityDays);
            }
        }
Exemple #2
0
        private static void In(SpareEntities db, TB_BILL bill, TS_STOCK_DETAIL detailIn)
        {
            CheckStockDetailLoc(db, detailIn.LocCode);

            if (detailIn.UpdateQty <= 0)
            {
                throw new WmsException(ResultCode.StockNotEnough, GetDetailInfo(detailIn), "入库数量错误");
            }
            var stockDetail = Get(db, detailIn.LocCode, detailIn.PartCode, detailIn.Batch) ?? detailIn.Clone();

            stockDetail.Qty       += detailIn.UpdateQty;
            stockDetail.UpdateQty  = detailIn.UpdateQty;
            stockDetail.UpdateTime = DateTime.Now;
            db.TS_STOCK_DETAIL.AddOrUpdate(stockDetail);
            SetProduceDate(db, stockDetail);

            TransactionLogController.Add(db, bill, detailIn); //添加库存事务日志
        }
Exemple #3
0
 /// <summary>
 ///     执行【领用还回单】
 /// </summary>
 /// <param name="db"></param>
 /// <param name="billList">领用还回单列表</param>
 /// <param name="detailList">领用还回明细列表</param>
 /// <returns></returns>
 public static void ExecuteSpareReturn(SpareEntities db, TB_BILL bill,
                                       List <TB_RETURN> detailList)
 {
     {
         foreach (var detail in detailList)
         {
             var stockDetail = new TS_STOCK_DETAIL()
             {
                 LocCode   = detail.ToLocCode,
                 PartCode  = detail.PartCode,
                 Batch     = detail.Batch,
                 Qty       = (decimal)detail.InQty,
                 UnitPrice = detail.UnitPrice,
                 UpdateQty = (decimal)detail.InQty
             };
             var stockDetails = new List <TS_STOCK_DETAIL>();
             stockDetails.Add(stockDetail);
             StockDetailController.ListIn(db, bill, stockDetails); //更新【库存主表】【库存明细】
             NotifyController.AddNotify(db, bill.OperName, NotifyType.SpareReturnApprove, bill.BillNum, "");
         }
         EntitiesFactory.SaveDb(db);
     }
 }
Exemple #4
0
        public static void ListMove(SpareEntities db, TB_BILL bill, List <TB_STOCK_MOVE> details)
        {
            foreach (var detail in details)
            {
                if (detail.FromLocCode != detail.ToLocCode)
                {
                    var detailOut = detail.ToStockDetailOut();
                    Out(db, bill, detailOut);
                }
                var detailIn = new TS_STOCK_DETAIL();
                if (bill.BillType == (int)BillType.InventoryPlan)
                {
                    detailIn = detail.ToStockDetailInventory(db);
                }
                else
                {
                    detailIn = detail.ToStockDetailIn(db);
                }
                In(db, bill, detailIn);
//                //创建ERP接口
//                ErpInterfaceController.CreateTR(db, detail.PartCode, detail.Qty, detail.FromLocCode, detail.ToLocCode,detail.Batch,detail.Batch, bill.BillNum, (BillType)(bill.BillType), bill.BillTime);
            }
        }
Exemple #5
0
        public static void Out(SpareEntities db, TB_BILL bill, TS_STOCK_DETAIL detailOut)
        {
            CheckStockDetailLoc(db, detailOut.LocCode);

            var loc = StoreLocationController.Get(db, detailOut.LocCode);

//            if (detailOut.UpdateQty >= 0)
//            {
//                throw new WmsException(ResultCode.StockNotEnough,
//                   GetDetailInfo(detailOut), "出库数量错误,无法移出");
//            }
            if (detailOut.Qty + detailOut.UpdateQty < 0)
            {
                throw new WmsException(ResultCode.StockNotEnough,
                                       GetDetailInfo(detailOut), "出库库存明细不足,无法移出");
            }
            var stockDetail = Get(db, detailOut.LocCode, detailOut.PartCode, detailOut.Batch);

            if (stockDetail == null) //库存明细不存在,报错
            {
                if (bill.BillType == (int)BillType.InventoryPlan)
                {
                    return;
                }
                throw new WmsException(ResultCode.DataNotFound,
                                       GetDetailInfo(detailOut), "出库库存明细不存在");
            }
            else //库存明细存在,更新数量(出库时更新数量为负值)
            {
                stockDetail.Qty       += detailOut.UpdateQty;
                stockDetail.UpdateQty  = detailOut.UpdateQty;
                stockDetail.UpdateTime = DateTime.Now;
            }
            db.TS_STOCK_DETAIL.AddOrUpdate(stockDetail);
            TransactionLogController.Add(db, bill, detailOut); //添加库存事务日志
        }
Exemple #6
0
 public static void Add(SpareEntities db, TB_BILL bill, TS_STOCK_DETAIL detail)
 {
     Add(db, bill.BillNum, bill.BillType, bill.OperName, detail);
 }
Exemple #7
0
        public static void Add(SpareEntities db, string billNum, int billType, string operName, TS_STOCK_DETAIL detail)
        {
            var log = new TL_TRANSACTION()
            {
                OperName  = operName,
                LogTime   = DateTime.Now,
                BillNum   = billNum,
                BillType  = billType,
                PartCode  = detail.PartCode,
                Batch     = detail.Batch,
                Qty       = detail.UpdateQty,
                LocCode   = detail.LocCode,
                UnitPrice = detail.UnitPrice,
                Remark    = detail.UpdateQty > 0?"In":"Out",
            };

            db.TL_TRANSACTION.Add(log);
        }
Exemple #8
0
 private static string GetDetailInfo(TS_STOCK_DETAIL detailIn)
 {
     return(detailIn.PartCode + "." + detailIn.Batch + "@" + detailIn.LocCode);
 }