Esempio n. 1
0
 //分配条烟
 private void AllotBar(InBillMaster billMaster, InBillDetail billDetail, IEnumerable <Cell> cs, CancellationToken cancellationToken, ProgressState ps)
 {
     foreach (var c in cs)
     {
         lock (c)
         {
             if (!cancellationToken.IsCancellationRequested && (billDetail.BillQuantity - billDetail.AllotQuantity) > 0)
             {
                 decimal billQuantity = (billDetail.BillQuantity - billDetail.AllotQuantity) % billDetail.Product.Unit.Count;
                 if (billQuantity > 0)
                 {
                     var targetStorage = Locker.LockStorage(c);
                     if (targetStorage != null &&
                         (string.IsNullOrEmpty(targetStorage.ProductCode) ||
                          targetStorage.ProductCode == billDetail.ProductCode ||
                          (targetStorage.Quantity == 0 &&
                           targetStorage.InFrozenQuantity == 0)))
                     {
                         Allot(billMaster, billDetail, c, targetStorage, billQuantity, ps);
                         Locker.UnLockStorage(targetStorage);
                     }
                 }
                 else
                 {
                     break;
                 }
             }
             else
             {
                 break;
             }
         }
     }
 }
Esempio n. 2
0
 //分配整盘
 private void AllotPallet(InBillMaster billMaster, InBillDetail billDetail, IEnumerable <Cell> cs, CancellationToken cancellationToken, ProgressState ps)
 {
     foreach (var c in cs)
     {
         lock (c)
         {
             if (!cancellationToken.IsCancellationRequested && (billDetail.BillQuantity - billDetail.AllotQuantity) > 0)
             {
                 decimal allotQuantity = c.MaxQuantity * billDetail.Product.Unit.Count;
                 decimal billQuantity  = Math.Floor((billDetail.BillQuantity - billDetail.AllotQuantity)
                                                    / billDetail.Product.Unit.Count)
                                         * billDetail.Product.Unit.Count;
                 if (billQuantity >= allotQuantity)
                 {
                     var targetStorage = Locker.LockStorage(c);
                     if (targetStorage != null &&
                         targetStorage.Quantity == 0 &&
                         targetStorage.InFrozenQuantity == 0)
                     {
                         Allot(billMaster, billDetail, c, targetStorage, allotQuantity, ps);
                         Locker.UnLockStorage(targetStorage);
                     }
                 }
                 else
                 {
                     break;
                 }
             }
             else
             {
                 break;
             }
         }
     }
 }
Esempio n. 3
0
        public ActionResult InBillDetailEdit(InBillDetail inBillDetail)
        {
            bool   bResult = InBillDetailService.Save(inBillDetail);
            string msg     = bResult ? "修改成功" : "修改失败";

            return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, null), "text", JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public ActionResult InBillDetailCreate(InBillDetail inBillDetail)
        {
            bool   bResult = InBillDetailService.Add(inBillDetail);
            string msg     = bResult ? "新增成功" : "新增失败";

            return(Json(JsonMessageHelper.getJsonMessage(bResult, msg, null), "text", JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
 //分配件烟
 private void AllotPiece(InBillMaster billMaster, InBillDetail billDetail, IEnumerable <Cell> cs, CancellationToken cancellationToken, ProgressState ps)
 {
     foreach (var c in cs)
     {
         lock (c)
         {
             if (!cancellationToken.IsCancellationRequested && (billDetail.BillQuantity - billDetail.AllotQuantity) > 0)
             {
                 var targetStorage = Locker.LockStorage(c);
                 if (targetStorage != null &&
                     (string.IsNullOrEmpty(targetStorage.ProductCode) ||
                      targetStorage.ProductCode == billDetail.ProductCode ||
                      (targetStorage.Quantity == 0 &&
                       targetStorage.InFrozenQuantity == 0)))
                 {
                     decimal allotQuantity = (c.MaxQuantity >= billDetail.Product.CellMaxProductQuantity ? billDetail.Product.CellMaxProductQuantity : c.MaxQuantity) * billDetail.Product.Unit.Count
                                             - targetStorage.Quantity
                                             - targetStorage.InFrozenQuantity;
                     decimal billQuantity = Math.Floor((billDetail.BillQuantity - billDetail.AllotQuantity)
                                                       / billDetail.Product.Unit.Count)
                                            * billDetail.Product.Unit.Count;
                     allotQuantity = allotQuantity < billQuantity ? allotQuantity : billQuantity;
                     Allot(billMaster, billDetail, c, targetStorage, allotQuantity, ps);
                     Locker.UnLockStorage(targetStorage);
                 }
             }
             else
             {
                 break;
             }
         }
     }
 }
Esempio n. 6
0
        public bool DownInBillMaster(string BeginDate, string EndDate, out string errorInfo)
        {
            errorInfo = string.Empty;
            bool   result          = false;
            string inBillStr       = "";
            string inBillMasterStr = "";

            try
            {
                var inBillNos = InBillMasterRepository.GetQueryable().Where(i => i.BillNo == i.BillNo).Select(i => new { i.BillNo }).ToArray();

                for (int i = 0; i < inBillNos.Length; i++)
                {
                    inBillStr += inBillNos[i].BillNo + ",";
                }
                InBillMaster[] inBillMasterList = InBillMasterDownService.GetInBillMaster(inBillStr);
                foreach (var master in inBillMasterList)
                {
                    var inBillMaster = new InBillMaster();
                    inBillMaster.BillNo        = master.BillNo;
                    inBillMaster.BillDate      = master.BillDate;
                    inBillMaster.BillTypeCode  = master.BillTypeCode;
                    inBillMaster.WarehouseCode = master.WarehouseCode;
                    inBillMaster.Status        = "1";
                    inBillMaster.IsActive      = master.IsActive;
                    inBillMaster.UpdateTime    = DateTime.Now;
                    InBillMasterRepository.Add(inBillMaster);
                    inBillMasterStr += master.BillNo + ",";
                }
                if (inBillMasterStr != string.Empty)
                {
                    InBillDetail[] inBillDetailList = InBillMasterDownService.GetInBillDetail(inBillMasterStr);
                    foreach (var detail in inBillDetailList)
                    {
                        var inBillDetail = new InBillDetail();
                        inBillDetail.BillNo        = detail.BillNo;
                        inBillDetail.ProductCode   = detail.ProductCode;
                        inBillDetail.UnitCode      = detail.UnitCode;
                        inBillDetail.Price         = detail.Price;
                        inBillDetail.BillQuantity  = detail.BillQuantity;
                        inBillDetail.AllotQuantity = detail.AllotQuantity;
                        inBillDetail.RealQuantity  = detail.RealQuantity;
                        inBillDetail.Description   = detail.Description;
                        InBillDetailRepository.Add(inBillDetail);
                    }
                }
                InBillMasterRepository.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                errorInfo = "出错,原因:" + e.Message;
            }
            return(result);
        }
Esempio n. 7
0
        private void Allot(InBillMaster billMaster, InBillDetail billDetail, Cell cell, Storage storage, decimal allotQuantity, ProgressState ps)
        {
            if (storage != null && allotQuantity > 0)
            {
                InBillAllot billAllot = null;
                billDetail.AllotQuantity += allotQuantity;
                storage.ProductCode       = billDetail.ProductCode;
                storage.LockTag           = billDetail.BillNo;
                storage.InFrozenQuantity += allotQuantity;

                billAllot = new InBillAllot()
                {
                    BillNo         = billMaster.BillNo,
                    InBillDetailId = billDetail.ID,
                    ProductCode    = billDetail.ProductCode,
                    CellCode       = cell.CellCode,
                    StorageCode    = storage.StorageCode,
                    UnitCode       = billDetail.UnitCode,
                    AllotQuantity  = allotQuantity,
                    RealQuantity   = 0,
                    Status         = "0"
                };
                billMaster.InBillAllots.Add(billAllot);

                decimal sumBillQuantity  = billMaster.InBillDetails.Sum(d => d.BillQuantity);
                decimal sumAllotQuantity = billMaster.InBillDetails.Sum(d => d.AllotQuantity);

                decimal sumBillProductQuantity = billMaster.InBillDetails.Where(d => d.ProductCode == billDetail.ProductCode)
                                                 .Sum(d => d.BillQuantity);
                decimal sumAllotProductQuantity = billMaster.InBillDetails.Where(d => d.ProductCode == billDetail.ProductCode)
                                                  .Sum(d => d.AllotQuantity);

                ps.State                = StateType.Processing;
                ps.TotalProgressName    = "分配入库单:" + billMaster.BillNo;
                ps.TotalProgressValue   = (int)(sumAllotQuantity / sumBillQuantity * 100);
                ps.CurrentProgressName  = "分配卷烟:" + billDetail.Product.ProductName;
                ps.CurrentProgressValue = (int)(sumAllotProductQuantity / sumBillProductQuantity * 100);
                NotifyConnection(ps.Clone());
            }
        }