Beispiel #1
0
        /// <summary>
        /// 原始查询  查询30天
        /// </summary>
        /// <param name="warehouseId"></param>
        /// <param name="hostingFilialeId"></param>
        /// <param name="days"> </param>
        /// <param name="goodsInfo"> </param>
        /// <param name="childGoods"></param>
        /// <returns></returns>
        public IList <StockWarningInfo> GetStockWarningList(Guid warehouseId, Guid hostingFilialeId, int days, GoodsInfo goodsInfo, Dictionary <Guid, ChildGoodsInfo> childGoods)
        {
            IList <StockWarningInfo> stockWarningList = new List <StockWarningInfo>();

            if (goodsInfo != null && goodsInfo.GoodsId != Guid.Empty)
            {
                var realgoodsIds = childGoods.Count > 0 ? childGoods.Keys.ToList() : new List <Guid> {
                    goodsInfo.GoodsId
                };
                stockWarningList = _stockWarningDao.GetStockWarningList(warehouseId, hostingFilialeId, realgoodsIds, days);
                if (stockWarningList.Count > 0)
                {
                    var quantityList = WMSSao.GetStockStatisticsDtos(realgoodsIds.ToDictionary(k => k, v => goodsInfo.GoodsType), warehouseId, hostingFilialeId);

                    foreach (var info in stockWarningList)
                    {
                        info.GoodsName = goodsInfo.GoodsName;
                        info.GoodsCode = goodsInfo.GoodsCode;
                        info.IsOnShelf = goodsInfo.IsOnShelf;
                        if (childGoods.ContainsKey(info.GoodsId))
                        {
                            var childGoodsInfo = childGoods[info.GoodsId] ?? new ChildGoodsInfo();
                            info.Specification = childGoodsInfo.Specification;
                            info.IsScarcity    = childGoodsInfo.IsScarcity;
                        }
                        var statisInfo = !quantityList.ContainsKey(hostingFilialeId) ? null : quantityList[hostingFilialeId].FirstOrDefault(act => act.RealGoodsId == info.GoodsId);
                        if (statisInfo != null)
                        {
                            info.NonceWarehouseGoodsStock = statisInfo.CurrentStock;
                            info.UppingQuantity           = statisInfo.UppingQuantity;
                            info.RequireQuantity          = statisInfo.RequireQuantity;
                            info.SubtotalQuantity         = statisInfo.SubtotalQuantity;
                            info.NonceRequest             = statisInfo.RequireQuantity;
                        }
                    }
                }
            }
            return(stockWarningList.OrderBy(ent => ent.Specification).ToList());
        }
Beispiel #2
0
            /// <summary>
            /// 开始常规报备
            /// </summary>
            public static void DoPurchasing(PurchasingGoods p, GoodsInfo goodsInfo, int avgStockDays, DateTime nextStockDate, TaskType taskType, int step, DateTime nextPurchasingDate, Dictionary <Guid, string> warehouseDics)
            {
#if debug
                Console.WriteLine("");
                Console.WriteLine("商品ID:{0}", p.GoodsId);
                Console.WriteLine("商品名称:{0}", p.GoodsName);
                if (p.WarehouseId != Guid.Empty)
                {
                    Console.WriteLine("对应仓库:{0}", p.WarehouseName);
                }
                else
                {
                    Console.WriteLine("对应仓库:全部仓库");
                }
#endif
                List <Guid> goodsIdList = _goodsCenterSao.GetRealGoodsIdsByGoodsId(p.GoodsId).ToList();
                if (goodsIdList.Count == 0)
                {
                    goodsIdList.Add(p.GoodsId);
                }
                //指定仓库报备
                if (p.WarehouseId != Guid.Empty)
                {
                    //获取销售总统计
                    var childGoodsSaleAll = GetChildGoodsSaleTotalByDays(goodsIdList, p.WarehouseId, p.StockingDays);
                    //逐个算出计划采购
                    if (childGoodsSaleAll.Count > 0)
                    {
                        var stocks = WMSSao.GetStockStatisticsDtos(goodsIdList.ToDictionary(k => k, v => goodsInfo.GoodsType), p.WarehouseId, Guid.Empty);
                        foreach (var childGoodsSalePurchasing in childGoodsSaleAll.GroupBy(act => act.HostingFilialeId))
                        {
                            var key = childGoodsSalePurchasing.Key;
                            //循环遍历子商品的销售和采购信息
                            OperationSaleAndPurchasing(p, childGoodsSalePurchasing, p.WarehouseId, key, avgStockDays, nextStockDate, taskType, step, nextPurchasingDate, stocks.ContainsKey(key)
                                ? stocks[key] : new List <ERP.SAL.WMS.StockStatisticsDTO>());
                        }
                    }
                    else
                    {
                        Console.WriteLine("近期都没有销售记录!");
                    }

#if debug
#endif
                }
                else
                {
                    //全仓库报备
                    foreach (var info in warehouseDics)
                    {
                        var stocks = WMSSao.GetStockStatisticsDtos(goodsIdList.ToDictionary(k => k, v => goodsInfo.GoodsType), p.WarehouseId, Guid.Empty);
                        //获取销售总统计
                        var childGoodsSaleAll = GetChildGoodsSaleTotalByDays(goodsIdList, info.Key, p.StockingDays);
                        foreach (var childGoodsSalePurchasing in childGoodsSaleAll.GroupBy(act => act.HostingFilialeId))
                        {
                            var key = childGoodsSalePurchasing.Key;
                            //循环遍历子商品的销售和采购信息
                            OperationSaleAndPurchasing(p, childGoodsSalePurchasing, info.Key, key, avgStockDays, nextStockDate, taskType, step, nextPurchasingDate, stocks.ContainsKey(key)
                                ? stocks[key] : new List <ERP.SAL.WMS.StockStatisticsDTO>());
                        }
                    }
                }


#if debug
                {
                    Console.WriteLine("");
                    Console.WriteLine("========================================================================");
                    Console.WriteLine("");
                }
#endif
            }
Beispiel #3
0
        /// <summary>
        /// 原始查询  查询10天
        /// </summary>
        /// <param name="warehouseId"></param>
        /// <param name="goodsId"></param>
        /// <param name="days"> </param>
        /// <param name="goodsInfo"> </param>
        /// <param name="filialeId"></param>
        /// <returns></returns>
        public IList <StockWarningInfo> GetStockWarningListNew(Guid warehouseId, Guid filialeId, Guid goodsId, int days, GoodsInfo goodsInfo)
        {
            IList <StockWarningInfo> stockWarnings = new List <StockWarningInfo>();

            if (goodsId == Guid.Empty)
            {
                return(new List <StockWarningInfo>());
            }
            List <Guid> realGoodsIds = new List <Guid>();

            if (goodsInfo != null && goodsInfo.GoodsId != Guid.Empty)
            {
                var list = _goodsInfoSao.GetRealGoodsListByGoodsId(new List <Guid> {
                    goodsId
                });
                var realGoodsInfoList = list.ToDictionary(k => k.RealGoodsId, v => v);
                realGoodsIds.AddRange(realGoodsInfoList.Keys);
                if (realGoodsIds.Count == 0)
                {
                    throw new Exception(goodsInfo.GoodsName + ": 无子商品");
                }
                var stockWarningList = _stockWarningDao.GetStockWarningList(warehouseId, filialeId, realGoodsIds, days);
                var now        = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                var totalSales = _stockWarningDao.GetGoodsDaySalesInfos(realGoodsIds, warehouseId, now.AddDays(-110), now, filialeId);
                //计算前第一个备货周期的销售额
                var childSaleList1 = totalSales.Where(act => act.DayTime >= now.AddDays(-30) && act.DayTime < now);

                //计算前第二个备货周期的销售额
                var childSaleList2 = totalSales.Where(act => act.DayTime >= now.AddDays(-60) && act.DayTime < now.AddDays(-30));

                //计算前第三个备货周期的销售额
                var childSaleList3 = totalSales.Where(act => act.DayTime >= now.AddDays(-90) && act.DayTime < now.AddDays(-60));
                //获取子商品对应库存(按托管公司分组)
                var quantityList = WMSSao.GetStockStatisticsDtos(realGoodsIds.ToDictionary(k => k, v => goodsInfo.GoodsType), warehouseId, filialeId);

                //获取商品的销售天数
                var salesDays = _stockWarningDao.GetSaleDays(realGoodsIds, warehouseId, now, filialeId);
                foreach (var guid in realGoodsIds)
                {
                    double count1       = childSaleList1.Where(act => act.RealGoodsID == guid).Sum(act => act.GoodsSales);
                    double count2       = childSaleList2.Where(act => act.RealGoodsID == guid).Sum(act => act.GoodsSales);
                    double count3       = childSaleList3.Where(act => act.RealGoodsID == guid).Sum(act => act.GoodsSales);
                    var    preStepSales = GetPreStepSales(totalSales, guid, now, salesDays.ContainsKey(guid) ? salesDays[guid] : 0);
                    var    warningInfo  = stockWarningList.FirstOrDefault(act => act.GoodsId == guid) ?? new StockWarningInfo();
                    warningInfo.SetStepSales(preStepSales.OrderBy(act => act.Key).ToDictionary(k => k.Key, v => v.Value));
                    warningInfo.GoodsId  = guid;
                    warningInfo.StockDay = days;
                    warningInfo.FirstNumberOneStockUpSale   = count1;
                    warningInfo.FirstNumberTwoStockUpSale   = count2;
                    warningInfo.FirstNumberThreeStockUpSale = count3;
                    warningInfo.GoodsName = goodsInfo.GoodsName;
                    warningInfo.GoodsCode = goodsInfo.GoodsCode;
                    warningInfo.IsOnShelf = goodsInfo.IsOnShelf;

                    if (realGoodsInfoList.ContainsKey(guid))
                    {
                        var childGoodsInfo = realGoodsInfoList[guid] ?? new ChildGoodsInfo();
                        warningInfo.IsScarcity    = childGoodsInfo.IsScarcity;
                        warningInfo.Specification = childGoodsInfo.Specification;
                    }

                    var statisInfo = quantityList.ContainsKey(filialeId) && quantityList[filialeId] != null ? quantityList[filialeId].FirstOrDefault(act => act.RealGoodsId == guid) : null;
                    if (statisInfo != null)
                    {
                        warningInfo.NonceWarehouseGoodsStock = statisInfo.CurrentStock;
                        warningInfo.UppingQuantity           = statisInfo.UppingQuantity;
                        warningInfo.RequireQuantity          = statisInfo.RequireQuantity;
                        warningInfo.SubtotalQuantity         = statisInfo.SubtotalQuantity;
                        warningInfo.NonceRequest             = statisInfo.RequireQuantity;
                    }
                    stockWarnings.Add(warningInfo);
                }
            }
            return(stockWarnings.OrderBy(ent => ent.Specification).ToList());
        }