예제 #1
0
        /// <summary>
        /// 维修统计
        /// </summary>
        /// <param name="repairType">维修类型</param>
        /// <param name="selectYear">年份</param>
        /// <returns></returns>
        public ActionResult GetRepairProject(string repairType, int selectYear)
        {
            var           repairProjectViewModel = new RepairProjectViewModel();
            List <Series> serList = new List <Series>();

            try
            {
                var projectList = rp.GetRepair_DistictList(xxid, repairType);

                if (projectList.Any())
                {
                    string[] projectNames = new string[projectList.Count];

                    for (int j = 0; j < projectList.Count; j++)
                    {
                        projectNames[j] = projectList[j].RepairProjectName;
                    }

                    repairProjectViewModel.ProjectNames = projectNames;

                    var repairProjectList = rp.GetRepairListByYear(xxid, selectYear);

                    for (int i = 1; i < 13; i++)
                    {
                        Series s = new Series();
                        s.id   = i;
                        s.type = "column";
                        s.name = i + "月";

                        float?[] d = new float?[projectList.Count];

                        for (int j = 0; j < projectList.Count; j++)
                        {
                            var proCount =
                                repairProjectList.Count(
                                    w =>
                                    w.BaoXiuProject == projectList[j].RepairProjectName &&
                                    w.RepairTime.Value.Month == i);

                            d[j] = proCount;
                        }

                        s.data = d;

                        serList.Add(s);
                    }

                    repairProjectViewModel.SeriesList = serList;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Json(NewtonsoftJson(repairProjectViewModel)));
        }