Exemplo n.º 1
0
        /// <summary>
        /// 商品结算价存档 历史数据
        /// </summary>
        public static void RunHistorySettlePriceTask()
        {
            //结算价的起点是2014年12月份,2014年12月份的结算价数据由老龚初始化,故程序从2015年1月开始计算
            int year = 0, month = 2;

            while (!(DateTime.Now.Year.Equals(2015 + year) && DateTime.Now.Month.Equals(month - 1)))
            {
                if (month == 13)
                {
                    year++;
                    month = 1;
                }

                try
                {
                    var result = _goodsStockSettleRecordBll.AddSettlePriceAndStockRecord(2015 + year, month);
                    if (result)
                    {
                        month++;
                    }
                }
                catch (Exception ex)
                {
                    ERP.SAL.LogCenter.LogService.LogError("商品库存、结算价报表存档(历史数据)", "RunGoodsStockRecordTask.Error", ex);
                }
            }
        }
Exemplo n.º 2
0
        public void TestAddSettlePriceAndStockRecord()
        {
            _stubIGoodsStockRecord.IsExistsSettlePriceRecordDateTime = time => true;
            _goodsStockSettleRecordBll = new GoodsStockSettleRecordBll(_stubIGoodsStockRecord, _stubIStorageRecordDao, _stubIGoodsInfoSao);
            var result = _goodsStockSettleRecordBll.AddSettlePriceAndStockRecord(DateTime.Now.Year, DateTime.Now.Month);

            Assert.IsTrue(result);


            _stubIGoodsStockRecord.IsExistsSettlePriceRecordDateTime = time => false;


            _stubIStorageRecordDao.SelectMonthGoodsStockRecordInfosDateTime = (i) => new List <MonthGoodsStockRecordInfo>();
            _goodsStockSettleRecordBll = new GoodsStockSettleRecordBll(_stubIGoodsStockRecord, _stubIStorageRecordDao, _stubIGoodsInfoSao);
            var result1 = _goodsStockSettleRecordBll.AddSettlePriceAndStockRecord(DateTime.Now.Year, DateTime.Now.Month);

            Assert.IsTrue(result1);



            _stubIStorageRecordDao.SelectMonthGoodsStockRecordInfosDateTime = time => new List <MonthGoodsStockRecordInfo>
            {
                new MonthGoodsStockRecordInfo
                {
                    GoodsId = new Guid("1137DD20-7C7E-4107-BE19-4EE40866F274")
                }
            };

            _stubIStorageRecordDao.SelectGoodsStockInfosListOfInt32DateTimeDateTime = (ints, time, arg3) => new List <MonthGoodsStockInfo>
            {
                new MonthGoodsStockInfo
                {
                    GoodsId     = new Guid("1137DD20-7C7E-4107-BE19-4EE40866F274"),
                    Quantity    = 10,
                    RealGoodsId = new Guid("C531E492-CA5C-44E1-9862-2CC031B5DCCD"),
                    TotalPrice  = 1000
                }
            };

            _stubIGoodsStockRecord.GetGoodsSettlePriceDictsDateTime = (time) => new Dictionary <Guid, decimal>
            {
                { new Guid("057C679C-7ED1-4FB0-98BA-22F4D466755C"), decimal.Parse("9.00") },
                { new Guid("D6445A88-AB5C-404A-A7AD-23151238A51D"), decimal.Parse("20.00") },
                { new Guid("6A4B292C-AAD9-42F2-889D-2333AEBD2F63"), decimal.Parse("6.00") },
                { new Guid("D9D599E3-D61C-4FD9-AE9F-237367B77528"), decimal.Parse("18.00") }
            };

            _goodsStockSettleRecordBll = new GoodsStockSettleRecordBll(_stubIGoodsStockRecord, _stubIStorageRecordDao, _stubIGoodsInfoSao);
            _stubIGoodsStockRecord.BatchInsertIListOfGoodsStockPriceRecordInfo = list => true;
            var result4 = _goodsStockSettleRecordBll.AddSettlePriceAndStockRecord(DateTime.Now.Year + 1, DateTime.Now.Month);

            Assert.IsTrue(result4);
        }
Exemplo n.º 3
0
        /// <summary>执行结算价与商品库存存档任务
        /// </summary>
        public static void RunGoodsStockRecordTask()
        {
            string title = "";

            try
            {
                var date            = DateTime.Now;
                var createStockHour = Configuration.AppSettings["CreateStockHour"];
                var hours           = createStockHour.Split(',');
                if (!hours.Contains(string.Format("{0}", date.Hour)))
                {
                    return;
                }
                var preDate = date.AddMonths(-1);
                //10月份算9月份存档
                var recordDate = new DateTime(preDate.Year, preDate.Month, 1);

                if (_day == DateTime.Now.Day)
                {
                    return;
                }

                if (date.Day == 1)
                {
                    title = "每月月末库存存档";
                    //备份月末库存
                    if (!_goodsStockSettleRecordBll.CopyMonthGoodsStockInfos(recordDate))
                    {
                        ERP.SAL.LogCenter.LogService.LogError("每月月末库存备份失败", "结算价报表存档", null);
                        return;
                    }


                    title = "商品结算价存档";
                    var result = _goodsStockSettleRecordBll.AddSettlePriceAndStockRecord(date.Year, date.Month);
                    if (!result)
                    {
                        ERP.SAL.LogCenter.LogService.LogError(string.Format("{0}年{1}月份商品结算价报表存档失败", preDate.Year, preDate.Month), "商品库存、结算价报表存档", null);
                        return;
                    }

                    //记录销售额存档
                    if (_goodsStockRecord.IsExistsSettlePriceRecord(recordDate))
                    {
                        title = "供应商月销售额存档";
                        if (!_supplierSaleRecordBll.InsertSaleRecord(recordDate))
                        {
                            ERP.SAL.LogCenter.LogService.LogError(string.Format("{0}年{1}月份供应商销售额报表存档失败", preDate.Year, preDate.Month), "供应商月销售额报表存档", null);
                            return;
                        }
                    }
                }
                else
                {
                    //如果是非每月1号先删除所有数据   当月数据的存储
                    var resultData = _supplierSaleRecordBll.SelectSupplierSaleRecordInfos(date);
                    if (!resultData)
                    {
                        ERP.SAL.LogCenter.LogService.LogError(string.Format("{0}年{1}月{2}日供应商每日销售额存档失败", date.Year, date.Month, date.Day), "供应商每日销售额", null);
                        return;
                    }
                }
                _day = DateTime.Now.Day;
            }
            catch (Exception exp)
            {
                ERP.SAL.LogCenter.LogService.LogError("执行结算价与商品库存存档任务", title, exp);
            }
        }