Exemple #1
0
        /// <summary>
        /// 加工厂概况信息
        /// </summary>
        /// <param name="list"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private FactoryData CreatGuideData(List <TbDistributionPlanInfo> orderList, int type)
        {
            var production = new FactoryItmeData();
            var delivery   = new FactoryItmeData();
            var ps         = orderList;

            if (type == 1)//本月
            {
                var o = orderList.Where(p => p.InsertTime.Value.Month == DateTime.Now.Month).ToList();
                production.OrderCount = o.Count;
                //加急,滞后
                var zh = o.Where(p => (p.FinishProcessingDateTime.HasValue && p.DistributionTime < p.FinishProcessingDateTime) ||
                                 (p.FinishProcessingDateTime == null && p.DistributionTime < DateTime.Now.Date)).ToList();
                production.OrderRate = GetJJData(o);
                production.OtherRate = GetJJData(zh);
                ps = orderList.Where(p => p.DistributionTime.Value.Month == DateTime.Now.Month).ToList();
                //超期配送
                var cqps = ps.Where(p => p.DistributionStart == "配送完成" && p.DistributionTime < p.DeliveryCompleteTime).ToList();
                delivery.OrderCount = cqps.Count;
                delivery.OrderRate  = GetJJData(cqps);
                //超期未配送
                var cqwps = ps.Where(p => p.DistributionStart == "未配送" && p.DistributionTime < DateTime.Now.Date).ToList();
                delivery.OtherCount = cqwps.Count;
                delivery.OtherRate  = GetJJData(cqwps);
                //生产及时率=按时完成数/应加工完成数
                production.TotalRate = GetjslData(ps);
            }
            else
            {
                delivery.OrderCount   = orderList.Count(p => p.DistributionStart == "配送完成");
                production.OrderCount = orderList.Count(p => p.ProcessingState == "Finishing");
                production.OrderRate  = orderList.Where(p => p.ProcessingState == "Finishing").Sum(p => p.WeightTotal).Value;

                //生产及时率=按时完成数/应加工完成数
                var tps = orderList.Where(p => p.DistributionTime.Value < DateTime.Now.Date).ToList();
                production.TotalRate = GetjslData(tps);
            }

            //准时配送率=按期配送数 /(累计配送数+超期未配送数)
            decimal asps   = ps.Where(p => p.DistributionStart == "配送完成" && p.DistributionTime >= p.DeliveryCompleteTime).Count();
            decimal ljps   = ps.Where(p => p.DistributionStart == "配送完成").Count();
            decimal cqwpsc = ps.Where(p => p.DistributionStart == "未配送" && p.DistributionTime < DateTime.Now.Date).Count();

            if (delivery.OrderCount > 0)
            {
                delivery.TotalRate = decimal.Round((asps / (ljps + cqwpsc)) * 100, 2);//配送准时率
            }
            var retData = new FactoryData()
            {
                Production = production,
                Delivery   = delivery
            };

            return(retData);
        }
Exemple #2
0
        public GuideData GetFactoryInfo(HomeRequest request)
        {
            var where = new Where <TbDistributionPlanInfo>();
            where.And(p => p.Examinestatus == "审核完成");
            if (!string.IsNullOrWhiteSpace(request.ProcessFactoryCode))
            {
                where.And(p => p.ProcessFactoryCode == request.ProcessFactoryCode);
            }
            //订单信息
            var orderList = Db.Context.From <TbDistributionPlanInfo>()
                            .Select(TbDistributionPlanInfo._.All, TbCompany._.ParentCompanyCode, TbOrderProgress._.FinishProcessingDateTime)
                            .LeftJoin <TbCompany>((a, c) => a.SiteCode == c.CompanyCode)
                            .LeftJoin <TbOrderProgress>((a, c) => a.OrderCode == c.OrderCode)
                            .Where(where).ToList();
            //本月
            var orderMonth = orderList.Where(p => (p.InsertTime.Value.Year == DateTime.Now.Year && p.InsertTime.Value.Month == DateTime.Now.Month) ||
                                             (p.DistributionTime.Value.Year == DateTime.Now.Year && p.DistributionTime.Value.Month == DateTime.Now.Month)).ToList();
            var monthInfo = CreatGuideData(orderMonth, 1);

            monthInfo.Site     = orderMonth.GroupBy(p => p.SiteCode).Count();
            monthInfo.WorkArea = orderMonth.GroupBy(p => p.ParentCompanyCode).Count();
            //综合
            var TotalInfo = CreatGuideData(orderList, 2);

            //月均数,历史月份的总和
            if (orderList.Any())
            {
                var      tlist = orderList.OrderBy(p => p.InsertTime).ToList();
                DateTime dt1   = tlist[0].InsertTime.Value;
                DateTime dt2   = tlist[(orderList.Count - 1)].InsertTime.Value;
                int      Year  = dt2.Year - dt1.Year;
                int      Month = ((dt2.Year - dt1.Year) * 12 + (dt2.Month - dt1.Month)) + 1;
                TotalInfo.Site        = orderList.Count / Month;
                TotalInfo.TotalWeight = (orderList.Sum(p => p.WeightTotal) / Month).Value;
            }
            //报表
            var    reportInfo    = new FactoryItmeData();
            string CapacityMonth = DateTime.Now.Year + "-";
            int    month         = DateTime.Now.Month;

            if (month < 10)
            {
                CapacityMonth += "0" + DateTime.Now.Month;
            }
            else
            {
                CapacityMonth += DateTime.Now.Month;
            }
            var data = _WorkOrderLogic.GetCapacityNum(request.ProcessFactoryCode, CapacityMonth);

            if (data != null && data.Rows.Count > 0)
            {
                reportInfo.TotalRate = (decimal)data.Rows[0]["Capacity"];
                reportInfo.OrderRate = (decimal)data.Rows[0]["WeightSmallPlan"];
                reportInfo.OtherRate = (decimal)data.Rows[0]["ActualLoadNew"];
            }
            //联系人
            var storage = Db.Context.From <TbStorage>()
                          .Select(TbStorage._.StorageAdd, TbStorage._.Tel, TbUser._.UserName)
                          .LeftJoin <TbUser>((a, c) => a.UserCode == c.UserCode)
                          .Where(p => p.ProcessFactoryCode == request.ProcessFactoryCode).First();
            var retData = new GuideData()
            {
                MonthInfo  = monthInfo,
                TotalInfo  = TotalInfo,
                ReportInfo = reportInfo,
                Tel        = storage.Tel,
                Address    = storage.StorageAdd,
                Contacts   = storage.UserName
            };

            return(retData);
        }