Ejemplo n.º 1
0
        public _SumModel GetSum(ListModel model)
        {
            _SumModel sumModel = new _SumModel
            {
                Types = new Dictionary<string, int> 
                { 
                    { "虚", 2 }, 
                    { "实", 12 }
                },
                Priorities = new Dictionary<string, int>
                { 
                    { "高", 2 },
                    { "中", 12 }, 
                    { "低", 3 } 
                },
                Difficulties = new Dictionary<string, int> 
                { 
                    { "困难", 2 }, 
                    { "普通", 11 } 
                },
                ConsumeTime = new Dictionary<string, int> 
                { 
                    { "预计", 235 }, 
                    { "实际", 386 } 
                },
                Status = new Dictionary<string, int> 
                {
                    { "发布", 1 }, 
                    { "承接", 2 }, 
                    { "质疑", 1 },
                    { "完成", 3 },
                    { "合格", 8 }, 
                    { "不合格", 1 }
                },
                OverDue = new Dictionary<string, int>
                { 
                    { "条数", 3 }, 
                    { "次数", 7 }
                },
                Qualities = new Dictionary<string, int>
                { 
                    { "良好", 2 }, 
                    { "合格", 8 }, 
                    { "不合格", 1 } 
                },
                Doubt = new Dictionary<string, int>
                { 
                    { "条数", 3 }, 
                    { "次数", 9 },
                },
                RefuseAccept = new Dictionary<string, int>
                { 
                    { "良好", 2 }, 
                    { "合格", 8 }, 
                    { "不合格", 1 } 
                },
            };

            return sumModel;
        }
Ejemplo n.º 2
0
        public _SumModel GetSum(ListModel model)
        {
            _SumModel sumModel = new _SumModel();

            Project current = session.Load<Project>(model.CurrentProject.TailSelectedProject.Id);
            IList<int> allProjectIds = current.GetDescendantIds();
            var allTasks = _querySource
                .Get(model, allProjectIds);

            sumModel.Types = new Dictionary<string, int>();
            sumModel.Types.Add("虚", allTasks.Count(t => t.IsVirtual));
            sumModel.Types.Add("实", allTasks.Count(t => !t.IsVirtual));

            sumModel.Publish = allTasks.GroupBy(t => t.Publisher).ToDictionary(t => t.Key.Name, t => t.Count());
            sumModel.Own = allTasks.GroupBy(t => t.Owner).ToDictionary(t => getName(t.Key), t => t.Count());
            sumModel.Accept = allTasks.GroupBy(t => t.Accepter).ToDictionary(t => t.Key.Name, t => t.Count());

            sumModel.Priorities = allTasks.GroupBy(t => t.Priority).ToDictionary(t => getDescription(t.Key), t => t.Count());
            sumModel.Difficulties = allTasks.GroupBy(t => t.Difficulty).ToDictionary(t => getDescription(t.Key), t => t.Count());

            sumModel.ConsumeTime = new Dictionary<string, int>();
            sumModel.ConsumeTime.Add("预计", allTasks.Sum(t => t.ExpectWorkPeriod) ?? 0);
            sumModel.ConsumeTime.Add("实际", allTasks.Sum(t => t.ActualWorkPeriod) ?? 0);

            sumModel.Status = allTasks.GroupBy(t => t.CurrentStatus).ToDictionary(t => t.Key.GetEnumDescription(), t => t.Count());

            sumModel.OverDue = new Dictionary<string, int>();
            sumModel.OverDue.Add("条数", allTasks.Where(t => t.OverDue > 0).Count());
            sumModel.OverDue.Add("时间", allTasks.Sum(t => t.OverDue) ?? 0);

            sumModel.Qualities = allTasks.GroupBy(t => t.Quality).ToDictionary(t => getDescription(t.Key), t => t.Count());

            sumModel.Doubt = new Dictionary<string, int>();
            sumModel.Doubt.Add("条数", allTasks.Count(t => t.Histroy.Count(h => h.Status == Status.Doubt) > 0));
            sumModel.Doubt.Add("次数", _historyItemQuery.Get(allTasks, Status.Doubt).Count());

            sumModel.RefuseAccept = new Dictionary<string, int>();
            sumModel.RefuseAccept.Add("条数", allTasks.Count(t => t.Histroy.Count(h => h.Status == Status.RefuseAccept) > 0));
            sumModel.RefuseAccept.Add("次数", _historyItemQuery.Get(allTasks, Status.RefuseAccept).Count());

            return sumModel;
        }