예제 #1
0
        private bool checkTimes(DateTime aimTime, string fileBasePath, string fileName, out int gCount, out List <stock_alarm_GSA> goodsList)
        {
            gCount = 0;
            using (ksoaContext db = new ksoaContext())
            {
                var query = from q in db.stock_alarm_GSA  where q.stock_5DLatter < q.threshold_value && q.alarm_state == 0 && DbFunctions.DiffMinutes(q.last_alarmDate, DateTime.Now) >= q.alarmSpan select q;

                var query1 = from q in query
                             where q.stock_5DLatter < q.threshold_value && q.alarm_state == 0 && DbFunctions.DiffMinutes(q.last_alarmDate, DateTime.Now) >= q.alarmSpan
                             from p in db.spkfks
                             from r in db.huoweizls
                                                                    //from s in db.hwsps
                             where q.spid == p.spid && r.hw == q.hw //&&q.spid==s.spid&&q.hw==s.hw
                             select new
                {                                                   //18335768012    462045
                    ID   = q.ID,
                    商品编号 = q.spbh,
                    商品名称 = q.spmch,
                    货位   = r.huowname,
                    一级分类 = p.yjfl,
                    二级分类 = p.ejfl,
                    级分类  = p.sjfl,
                    预警阈值 = (int)(q.threshold_value),
                    //实时库存= (int)s.hwshl,
                    计算时库存   = (int)q.amount_static,
                    近1月总销量  = q.saledIn1Month,
                    近7天销量   = q.saledIn7Days,
                    预计五天后库存 = q.stock_5DLatter,
                    在途数量    = q.stock_transit,
                    预计补货量   = q.restock_count,
                    最大库存量   = (int)(q.amount_static + q.restock_count + q.stock_transit - q.delivery_cycle * (q.saledIn7Days / 7.0)),
                    安全库存量   = (int)(q.safty_days * (0.85 * (q.saledIn7Days / 7.0) + 0.15 * (q.saledIn1Month / 30.0))),
                    次预警时间   = q.last_alarmDate,
                    最后统计时间  = q.lastCalcuDate
                };

                goodsList = query.ToList();
                gCount    = goodsList.Count();
                if (gCount > 0)
                {
                    OpenXmlExcelOper.CreateSpreadSheet(fileBasePath + fileName, "data");
                    OpenXmlExcelOper.FillAlarmData(fileBasePath + fileName, "data", ListToDataTable(query1.ToList()));
                }
            }
            return(true);
        }
예제 #2
0
        private bool checkTimes(DateTime aimTime, string fileBasePath, string fileName, out int gCount, out List <stock_alarm_GSA> goodsList)
        {
            gCount = 0;
            using (ksoaContext db = new ksoaContext())
            {
                var query = from q in db.stock_alarm_GSA where q.stock_5DLatter < q.threshold_value && q.alarm_state == 0 && DbFunctions.DiffMinutes(q.last_alarmDate, DateTime.Now) >= q.alarmSpan select q;

                var query1 = from q in query
                             where q.stock_5DLatter < q.threshold_value && q.alarm_state == 0 && DbFunctions.DiffMinutes(q.last_alarmDate, DateTime.Now) >= q.alarmSpan
                             from p in db.spkfks
                             from r in db.huoweizls
                             where q.spid == p.spid && r.hw == q.hw
                             select new
                {
                    ID     = q.ID,
                    商品编号   = q.spbh,
                    商品名称   = q.spmch,
                    货位     = r.huowname,
                    一级分类   = p.yjfl,
                    二级分类   = p.ejfl,
                    级分类    = p.sjfl,
                    预警阈值   = q.threshold_value,
                    五日后库存  = q.stock_5DLatter,
                    最后统计时间 = q.lastCalcuDate,
                    次预警时间  = q.last_alarmDate,
                    近两个月销量 = q.saledIn2Month,
                    近一月销量  = q.saledIn1Month,
                };

                goodsList = query.ToList();
                gCount    = goodsList.Count();
                if (gCount > 0)
                {
                    OpenXmlExcelOper.CreateSpreadSheet(fileBasePath + fileName, "data");
                    OpenXmlExcelOper.FillAlarmData(fileBasePath + fileName, "data", ListToDataTable(query1.ToList()));
                }
            }
            return(true);
        }