コード例 #1
0
        public static HomeViewModel Create(string tabId, int parentId, HomeResult result)
        {
            var model = Create <HomeViewModel>(tabId, parentId);

            model.Sites         = result.Sites;
            model.CurrentUser   = result.CurrentUser;
            model.LockedCount   = result.LockedCount;
            model.ApprovalCount = result.ApprovalCount;
            return(model);
        }
コード例 #2
0
        public object HomeIndex(HomeIndexModel model)
        {
            HomeResult hr = new HomeResult();

            try
            {
                var Data = dbContext.v_Jusoft_PcMissionCenter.Where(p => true);
                if (!string.IsNullOrEmpty(model.StStortCode))
                {
                    Data = Data.Where(p => p.CusStoreCode == model.StStortCode);
                }
                //if (model.SubclassId!=null)
                //{
                //    Data = Data.Where(p=>p.SubclassId==model.SubclassId);
                //}
                if (model.StateTime != null && model.EndTime != null)
                {
                    Data = Data.Where(p => p.CreateTime >= model.StateTime && p.CreateTime <= model.EndTime);
                }
                hr.ProcessedCount    = Data.Where(p => p.State == HomeConfig.Processed).Count();
                hr.ProcessingCount   = Data.Where(p => p.State == HomeConfig.Processing).Count();
                hr.OverCount         = Data.Where(p => p.State == HomeConfig.Over && p.State == HomeConfig.Rejected && p.State == HomeConfig.Evaluated).Count();
                hr.MaterialCount     = Data.Where(p => p.SubclassId == HomeConfig.Material).Count();
                hr.RepairCount       = Data.Where(p => p.SubclassId == HomeConfig.Repair).Count();
                hr.LogisticsCount    = Data.Where(p => p.SubclassId == HomeConfig.Logistics).Count();
                hr.DecorationCount   = Data.Where(p => p.SubclassId == HomeConfig.Decoration).Count();
                hr.SupplyOtherCount  = Data.Where(p => p.SubclassId == HomeConfig.SupplyOther).Count();
                hr.OperaCount        = Data.Where(p => p.SubclassId == HomeConfig.Opera).Count();
                hr.PatrolCount       = Data.Where(p => p.SubclassId == HomeConfig.Patrol).Count();
                hr.OperateOtherCount = Data.Where(p => p.SubclassId == HomeConfig.OperateOther).Count();
                hr.ElemerceCount     = Data.Where(p => p.SubclassId == HomeConfig.Elemerce).Count();
                hr.OperationCount    = Data.Where(p => p.SubclassId == HomeConfig.Operation).Count();
                hr.MarketingCount    = Data.Where(p => p.SubclassId == HomeConfig.Marketing).Count();
                hr.AuxiliaryCount    = Data.Where(p => p.SubclassId == HomeConfig.Auxiliary).Count();
                hr.ResearchCount     = Data.Where(p => p.SubclassId == HomeConfig.Research).Count();
                hr.OtherCount        = Data.Where(p => p.SubclassId == HomeConfig.Other).Count();
                hr.Code   = 0;
                hr.Result = "ok";
                return(Json(hr));
            }
            catch (Exception ex)
            {
                hr.Code   = 1000;
                hr.Result = ex.Message;
                return(Json(hr));
            }
        }
コード例 #3
0
        public async Task <Result> Widgets()
        {
            var model = new HomeResult();

            model.WidgetInstances = await _widgetInstanceService.GetPublished()
                                    .OrderBy(x => x.DisplayOrder)
                                    .Select(x => new HomeWidgetInstanceResult
            {
                Id   = x.Id,
                Name = x.Name,
                ViewComponentName = x.Widget.ViewComponentName,
                WidgetId          = x.WidgetId,
                WidgetZoneId      = x.WidgetZoneId,
                Data         = x.Data,
                HtmlData     = x.HtmlData,
                DisplayOrder = x.DisplayOrder
            }).ToListAsync();

            return(Result.Ok(model));
        }
コード例 #4
0
        /// <summary>
        /// 获得首页数据
        /// </summary>
        /// <returns></returns>
        public static HomeResult GetHomeData(List <string> villages)
        {
            HomeResult homeresult = new HomeResult();

            try
            {
                IStatistics              factory           = StatisticsFactory.GetFactory();
                DateTime                 dtNow             = DateTime.Now;
                DateTime                 StartTime         = dtNow.Date.AddDays(-14);
                DateTime                 EndTime           = dtNow;
                List <BaseParkinfo>      parkinfos         = ParkingServices.QueryParkingByVillageIds(villages);
                List <Statistics_Gather> gatherlistdaily15 = null;
                if (parkinfos != null && parkinfos.Count > 0)
                {
                    gatherlistdaily15 = factory.GetStatisticsGroupByDay(parkinfos.Select(u => u.PKID).ToList(), StartTime, EndTime);
                }
                //如果少于15天,则补足15天
                if (gatherlistdaily15 != null)
                {
                    if (gatherlistdaily15.Count <= 15)
                    {
                        for (int i = 0; i < 15; i++)
                        {
                            var v = gatherlistdaily15.Find(u => u.KeyName == dtNow.AddDays(-i).ToString("yyyy-MM-dd"));
                            if (v == null)
                            {
                                gatherlistdaily15.Add(new Statistics_Gather {
                                    KeyName = dtNow.AddDays(-i).ToString("MM-dd"), GatherTime = dtNow.AddDays(-i)
                                });
                            }
                            else
                            {
                                v.KeyName = dtNow.AddDays(-i).ToString("MM-dd");
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < 15; i++)
                    {
                        gatherlistdaily15.Add(new Statistics_Gather {
                            KeyName = dtNow.AddDays(-i).ToString("MM-dd"), GatherTime = dtNow.AddDays(-i)
                        });
                    }
                }
                gatherlistdaily15 = gatherlistdaily15.OrderBy(u => u.KeyName).ToList();

                homeresult.GatherDaily30 = gatherlistdaily15;
                int vipcard   = gatherlistdaily15.Select(u => u.VIPCard).Sum();
                int stordcard = gatherlistdaily15.Select(u => u.StordCard).Sum();
                int monthcard = gatherlistdaily15.Select(u => u.MonthCard).Sum();
                int jobcard   = gatherlistdaily15.Select(u => u.JobCard).Sum();
                int tempcard  = gatherlistdaily15.Select(u => u.TempCard).Sum();

                int sumnormal = gatherlistdaily15.Select(u => u.ReleaseType_Normal).Sum();
                int sumcatch  = gatherlistdaily15.Select(u => u.ReleaseType_Catch).Sum();
                int sumfree   = gatherlistdaily15.Select(u => u.ReleaseType_Free).Sum();
                int sumcharge = gatherlistdaily15.Select(u => u.ReleaseType_Charge).Sum();
                //进场类型
                homeresult.EntranceCardType.Add(new KeyValue {
                    KeyName = "贵宾卡", Key_Value = vipcard, KeyValue2 = vipcard
                });
                homeresult.EntranceCardType.Add(new KeyValue {
                    KeyName = "储值卡", Key_Value = stordcard, KeyValue2 = stordcard
                });
                homeresult.EntranceCardType.Add(new KeyValue {
                    KeyName = "月卡", Key_Value = monthcard, KeyValue2 = monthcard
                });
                homeresult.EntranceCardType.Add(new KeyValue {
                    KeyName = "临时卡", Key_Value = tempcard, KeyValue2 = tempcard
                });
                homeresult.EntranceCardType.Add(new KeyValue {
                    KeyName = "工作卡", Key_Value = jobcard, KeyValue2 = jobcard
                });
                //放行类型
                homeresult.ReleaseType.Add(new KeyValue {
                    KeyName = "正常放行", Key_Value = sumnormal, KeyValue2 = sumnormal
                });
                homeresult.ReleaseType.Add(new KeyValue {
                    KeyName = "免费放行", Key_Value = sumfree, KeyValue2 = sumfree
                });
                homeresult.ReleaseType.Add(new KeyValue {
                    KeyName = "收费放行", Key_Value = sumcharge, KeyValue2 = sumcharge
                });
                homeresult.ReleaseType.Add(new KeyValue {
                    KeyName = "异常放行", Key_Value = sumcatch, KeyValue2 = sumcatch
                });

                List <Statistics_Gather> gathertop5 = null;
                if (parkinfos != null && parkinfos.Count > 0)
                {
                    gathertop5 = factory.GetParkingTempTop5(parkinfos.Select(u => u.PKID).ToList(), StartTime, EndTime);
                }
                List <KeyValue> parkingtop5 = new List <KeyValue> ();

                if (gathertop5 != null)
                {
                    foreach (var v in gathertop5)
                    {
                        parkingtop5.Add(new KeyValue
                        {
                            Key_Value = v.TempCard,
                            KeyName   = v.ParkingName
                        });
                    }

                    int num = gathertop5.Count;
                    if (num < 5)
                    {
                        for (int i = 0; i < 5 - num; i++)
                        {
                            parkingtop5.Add(new KeyValue
                            {
                                KeyName   = "",
                                Key_Value = 0
                            });
                        }
                    }
                }
                else
                {
                    if (gathertop5.Count < 5)
                    {
                        int n = gathertop5.Count;
                        for (int i = 0; i < 5 - n; i++)
                        {
                            parkingtop5.Add(new KeyValue
                            {
                                KeyName   = "",
                                Key_Value = 0
                            });
                        }
                    }
                }
                homeresult.ParkTempTop5 = parkingtop5.OrderBy(u => u.Key_Value).ToList();
                StartTime = DateTime.Parse(dtNow.ToString("yyyy-MM-01")).AddMonths(-5);
                List <Statistics_Gather> gatherlistmonth12 = null;
                if (parkinfos != null && parkinfos.Count > 0)
                {
                    gatherlistmonth12 = factory.GetStatisticsGroupByMonth(parkinfos.Select(u => u.PKID).ToList(), StartTime, EndTime);
                }

                if (gatherlistmonth12 != null)
                {
                    if (gatherlistmonth12.Count < 6)
                    {
                        for (int i = 0; i < 6; i++)
                        {
                            var v = gatherlistmonth12.Find(u => u.KeyName == dtNow.AddMonths(-i).ToString("yyyy-MM"));
                            if (v == null)
                            {
                                gatherlistmonth12.Add(new Statistics_Gather {
                                    KeyName = DateTime.Parse(dtNow.ToString("yyyy-MM")).AddMonths(-i).ToString("yyyy-MM"), GatherTime = DateTime.Parse(dtNow.ToString("yyyy-MM-01")).AddMonths(-i)
                                });
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < 6; i++)
                    {
                        gatherlistmonth12.Add(new Statistics_Gather {
                            KeyName = DateTime.Parse(dtNow.ToString("yyyy-MM")).AddMonths(-i).ToString("yyyy-MM"), GatherTime = DateTime.Parse(dtNow.ToString("yyyy-MM-01")).AddMonths(-i)
                        });
                    }
                }
                homeresult.GatherMonth12 = gatherlistmonth12.OrderBy(u => u.KeyName).ToList();
            }
            catch (Exception ex)
            {
                Common.Services.TxtLogServices.WriteTxtLog("打开首页异常 异常信息:", ex.Message);
            }
            return(homeresult);
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: jjzhou/MyTeam
        //
        // GET: /Home/
        public ActionResult Index()
        {
            // 首页显示 未出池的需求,未入池的需求,未完成的项目,未完成的下发
            User user = this.GetSessionCurrentUser();

            if (user == null)
            {
                return(RedirectToAction("Login", "User", new { ReturnUrl = "/Home/Index" }));
            }

            // 根据用户UID,
            // (1)找到负责的系统,统计未出池的需求(未出池需求,超过三个月未出池需求,未入池需求,超过8天未入池需求)
            // (2)根据项目计划判断有无超期
            // 若为管理员,则显示全部

            HomeResult hr = new HomeResult();

            if (user.IsAdmin)
            {
                hr.ReqLs = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, 0 as ReqAcptPerson from Reqs t where t.ReqStat = N'入池' group by t.SysId").ToList();
            }
            else
            {
                hr.ReqLs = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, @p0 as ReqAcptPerson from Reqs t where t.ReqStat = N'入池' and t.SysId in (select rs.SysId from RetailSystems rs where rs.ReqPersonID = @p0) group by t.SysId", user.UID).ToList();
            }

            // 统计计算未出池的需求总数
            int reqLsSum = 0;

            foreach (HomeReq q in hr.ReqLs)
            {
                reqLsSum += q.ReqNum;
            }

            ViewBag.ReqLsSum = reqLsSum;

            //////////////////////////////////////////////////////////////////////

            // 判断入池已超过三个月,但是没有出池的需求记录
            if (user.IsAdmin)
            {
                hr.ReqDelayLS = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, 0 as ReqAcptPerson from Reqs t where t.ReqStat = N'入池' and t.AcptDate <= DATEADD(month,-3,GETDATE()) group by t.SysId").ToList();
            }
            else
            {
                hr.ReqDelayLS = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, @p0 as ReqAcptPerson from Reqs t where t.ReqStat = N'入池' and t.AcptDate <= DATEADD(month,-3,GETDATE()) and t.SysId in (select rs.SysId from RetailSystems rs where rs.ReqPersonID = @p0) group by t.SysId", user.UID).ToList();
            }

            // 统计计算三个月未出池的需求总数
            int reqDelayLsSum = 0;

            foreach (HomeReq q in hr.ReqDelayLS)
            {
                reqDelayLsSum += q.ReqNum;
            }

            ViewBag.ReqDelayLsSum = reqDelayLsSum;

            //////////////////////////////////////////////////////////////////////

            // 统计所有还没入池的记录(状态为「待评估」)
            if (user.IsAdmin)
            {
                hr.ReqInpoolLS = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, 0 as ReqAcptPerson from Reqs t where t.ReqStat = N'待评估' group by t.SysId").ToList();
            }
            else
            {
                hr.ReqInpoolLS = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, @p0 as ReqAcptPerson from Reqs t where t.ReqStat = N'待评估' and t.SysId in (select rs.SysId from RetailSystems rs where rs.ReqPersonID = @p0) group by t.SysId", user.UID).ToList();
            }

            // 统计计算所有未入池的需求总数
            int reqInpoolLsSum = 0;

            foreach (HomeReq q in hr.ReqInpoolLS)
            {
                reqInpoolLsSum += q.ReqNum;
            }

            ViewBag.ReqInpoolLsSum = reqInpoolLsSum;

            //////////////////////////////////////////////////////////////////////

            // 判断超过8天还没入池的记录(状态为「待评估」)
            if (user.IsAdmin)
            {
                hr.ReqInpoolDelayLS = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, 0 as ReqAcptPerson from Reqs t where t.ReqStat = N'待评估' and t.AcptDate <= DATEADD(day,-8,GETDATE()) group by t.SysId").ToList();
            }
            else
            {
                hr.ReqInpoolDelayLS = dbContext.Database.SqlQuery <HomeReq>("select t.SysId, count(1) as ReqNum, @p0 as ReqAcptPerson from Reqs t where t.ReqStat = N'待评估' and t.AcptDate <= DATEADD(day,-8,GETDATE()) and t.SysId in (select rs.SysId from RetailSystems rs where rs.ReqPersonID = @p0) group by t.SysId", user.UID).ToList();
            }

            // 统计计算超过8天未入池的需求总数
            int reqInpoolDelayLsSum = 0;

            foreach (HomeReq q in hr.ReqInpoolDelayLS)
            {
                reqInpoolDelayLsSum += q.ReqNum;
            }

            ViewBag.ReqInpoolDelayLsSum = reqInpoolDelayLsSum;

            //////////////////////////////////////////////////////////////////////

            // 筛选出各个阶段延期的项目(只统计项目状态为:进行中)
            // 首先获得所有有时间计划的项目列表,对没有时间计划的项目将不统计其延期的情况
            List <ProjPlan>      plans  = dbContext.ProjPlans.ToList();
            List <Proj>          projs  = dbContext.Projs.Where(p => p.ProjStat == "进行中").ToList();
            List <HomeProjDelay> delays = new List <HomeProjDelay>();

            foreach (ProjPlan plan in plans)
            {
                Proj p = new Proj();
                if (user.IsAdmin)
                {
                    p = projs.Find(a => a.ProjID == plan.ProjID);
                }
                // 如果是非管理员登陆,显示自己的延期项目
                else
                {
                    p = projs.Find(a => a.ProjID == plan.ProjID && a.ReqAnalysisID == user.UID);
                }

                // 如果筛选出项目在项目计划列表中,那么判断时间是否延期
                if (p != null)
                {
                    // 判断各个阶段的时间是否延期
                    if (p.OutlineEndDate == null && plan.OutlineFinishDate <= DateTime.Now)
                    {
                        HomeProjDelay projDelay = new HomeProjDelay();
                        projDelay.ProjId      = p.ProjID;
                        projDelay.DelayDetail = "需求大纲结束编写";
                        delays.Add(projDelay);
                        continue;
                    }
                    else if (p.ReviewAcptDate == null && plan.ReviewStartDate <= DateTime.Now)
                    {
                        HomeProjDelay projDelay = new HomeProjDelay();
                        projDelay.ProjId      = p.ProjID;
                        projDelay.DelayDetail = "业需开始评审";
                        delays.Add(projDelay);
                        continue;
                    }
                    else if (p.ReqPublishDate == null && plan.ReviewFinishDate <= DateTime.Now)
                    {
                        HomeProjDelay projDelay = new HomeProjDelay();
                        projDelay.ProjId      = p.ProjID;
                        projDelay.DelayDetail = "业需结束评审";
                        delays.Add(projDelay);
                        continue;
                    }
                    else if (p.TechFeasiReviewFinishDate == null && plan.TechFeasiReviewFinishDate <= DateTime.Now)
                    {
                        HomeProjDelay projDelay = new HomeProjDelay();
                        projDelay.ProjId      = p.ProjID;
                        projDelay.DelayDetail = "技术可行性分析报告评审结束";
                        delays.Add(projDelay);
                        continue;
                    }
                    else if (p.SoftBudgetFinishDate == null && plan.SoftBudgetFinishDate <= DateTime.Now)
                    {
                        HomeProjDelay projDelay = new HomeProjDelay();
                        projDelay.ProjId      = p.ProjID;
                        projDelay.DelayDetail = "软件实施投入预算结束";
                        delays.Add(projDelay);
                        continue;
                    }
                    else if (p.ImplementPlansFinishDate == null && plan.ImplementPlansFinishDate <= DateTime.Now)
                    {
                        HomeProjDelay projDelay = new HomeProjDelay();
                        projDelay.ProjId      = p.ProjID;
                        projDelay.DelayDetail = "实施方案结束";
                        delays.Add(projDelay);
                        continue;
                    }
                }
            }
            hr.ProjDetails = delays;

            //////////////////////////////////////////////////////////////////////

            // 列出超过计划下发日期仍未下发的
            string sql = "select distinct t.RlsNo, t.SecondRlsNo, t.PlanRlsDate from Reqs t where ((t.RlsNo is not null and t.RlsDate is null ) or (t.SecondRlsNo is not null and t.SecondRlsDate is null )) and t.PlanRlsDate < getdate()-1 and t.ReqStat=N'出池'";

            if (!IsAdminNow())
            {
                sql += " and t.ReqAcptPerson = " + user.UID;
            }
            hr.RlsDelayLS = dbContext.Database.SqlQuery <HomeRlsDelay>(sql).ToList();

            return(View(hr));
        }