コード例 #1
0
        /// <summary>
        /// 作业实时分布统计表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetWorkRealTimeTableJson()
        {
            DistrictBLL                  districtbll = new DistrictBLL();
            List <DistrictEntity>        AreaList    = districtbll.GetListByOrgIdAndParentId("", "0");
            List <SafeworkcontrolEntity> WorkList    = safeworkcontrolbll.GetNowWork();
            List <KbssEntity>            klist       = new List <KbssEntity>();
            int Znum = 0;

            foreach (var item in AreaList)
            {
                KbssEntity kbs = new KbssEntity();
                kbs.Name         = item.DistrictName;
                kbs.Num          = WorkList.Where(a => a.Taskregioncode.Contains(item.DistrictCode)).Count();
                kbs.DistrictCode = item.DistrictCode;
                Znum            += kbs.Num;
                kbs.OnNum        = WorkList.Where(a => a.Taskregioncode.Contains(item.DistrictCode)).Count();
                klist.Add(kbs);
            }
            for (int j = 0; j < klist.Count; j++)
            {
                double Proportion = 0;
                if (Znum != 0)
                {
                    Proportion = (double)klist[j].Num / Znum;
                    Proportion = Proportion * 100;
                }
                klist[j].OnNum        = Znum;
                klist[j].OnProportion = Proportion.ToString("0") + "%";
            }
            return(Content(klist.ToJson()));
        }
コード例 #2
0
        public ActionResult GetCameraStatistics()
        {
            var                   data        = kbscameramanagebll.GetPageList("").Where(a => a.CameraTypeId == 0);
            DistrictBLL           districtbll = new DistrictBLL();
            List <DistrictEntity> AreaList    = districtbll.GetListByOrgIdAndParentId("", "0");
            List <KbssEntity>     klist       = new List <KbssEntity>();
            int                   Znum        = 0;

            foreach (var item in AreaList)
            {
                KbssEntity kbs = new KbssEntity();
                kbs.Name         = item.DistrictName;
                kbs.Num          = data.Where(a => a.AreaCode.Contains(item.DistrictCode)).Count();
                kbs.DistrictCode = item.DistrictCode;
                Znum            += kbs.Num;
                kbs.OnNum        = data.Where(a => a.AreaCode.Contains(item.DistrictCode) && a.State == "在线").Count();
                kbs.OffNum       = data.Where(a => a.AreaCode.Contains(item.DistrictCode) && a.State == "离线").Count();
                klist.Add(kbs);
            }

            for (int j = 0; j < klist.Count; j++)
            {
                double Proportion    = 0;
                double offProportion = 0;
                double OnProportion  = 0;
                if (Znum != 0)
                {
                    Proportion    = (double)klist[j].Num / Znum;
                    offProportion = (double)klist[j].OffNum / Znum;
                    OnProportion  = (double)klist[j].OnNum / Znum;
                    Proportion    = Proportion * 100;
                    offProportion = offProportion * 100;
                    OnProportion  = OnProportion * 100;
                }
                klist[j].Count             = Znum;
                klist[j].OnProportion      = OnProportion.ToString("0") + "%";
                klist[j].OfflineProportion = offProportion.ToString("0") + "%";
                klist[j].Proportion        = Proportion.ToString("0") + "%";
            }
            return(Content(klist.ToJson()));
        }