/// <summary> /// 获取主机/镜头/异常镜头按监控室分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetDVRCameraTotal() { List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var DVRRooms = _dvrrepository.Select(i => new { Monitoring_room = i.Monitoring_room }).Distinct(); //获取各监控室DVR在线数量 ////var dataDvrcheckInfo = _dVRCheckInfoAppService.GetListAsync(resultRequestDto).Result.Items; //var listDvrcheckInfo = dataDvrcheckInfo.Where(u => u.DVR_Online == true); //List<DVR> dataDvrOnline = new List<DVR>(); //foreach (var item in listDvrcheckInfo) //{ // dataDvrOnline.Add(_dvrrepository.Where(u => u.DVR_ID == item.DVR_ID).FirstOrDefault()); //} // var listDvrOnline = dataDvrOnline.ToList(); foreach (var item in DVRRooms) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.DVRRoom = item.Monitoring_room; //加载主机总数 var totalDVR = listdVRCamera.Where(u => u.Monitoring_room == item.Monitoring_room).Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); var totalCamera = listdVRCamera.Where(u => u.Monitoring_room == item.Monitoring_room).Select(i => new { CameraID = i.CameraID }).Distinct().Count(); //加载维修数据 var totalCameraRepair = listcameraRepair.Where(u => u.DVR_Room == item.Monitoring_room).Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); //加载在线主机数 // var totalDVROnline = dataDvrOnline.Where(u => u.Monitoring_room == item.Monitoring_room).Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); formsDto.CameraAnomaly = totalCameraRepair; // formsDto.DVROnLine = totalDVROnline; formsDto.CameraTotal = totalCamera; formsDto.DVRTotal = totalDVR; // formsDto.DVRAnomaly = totalDVR - totalDVROnline; listreportForms.Add(formsDto); } ReportFormsDto formsDto1 = new ReportFormsDto(); formsDto1.DVRRoom = "Total"; formsDto1.CameraAnomaly = listcameraRepair.Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); // formsDto1.DVROnLine = dataDvrOnline.Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); ; formsDto1.CameraTotal = listdVRCamera.Select(i => new { CameraID = i.CameraID }).Distinct().Count(); formsDto1.DVRTotal = listdVRCamera.Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); formsDto1.DVRAnomaly = formsDto1.DVRTotal - formsDto1.DVROnLine; listreportForms.Add(formsDto1); return(listreportForms); }
/// <summary> /// 按监控室分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByMonitorRoom() { dVRCameraRepairlist(); var listroom = listdVRCamera.Select(u => new { Monitoring_room = u.Monitoring_room }).Distinct(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); foreach (var item in listroom) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.DVRRoom = item.Monitoring_room; //镜头总数 formsDto.CameraTotal = listdVRCamera.Where(u => u.Monitoring_room == item.Monitoring_room).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(u => u.DVR_Room == item.Monitoring_room).Where(i => i.RepairState == false).Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(u => u.DVR_Room == item.Monitoring_room).Where(i => i.RepairState == true).Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal;; } listreportForms.Add(formsDto); } return(listreportForms); }
/// <summary> /// 获取在线DVR数量 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetDVROnlineTotal() { var dvrlist = _dvrrepository.Join(_dvrchenkrepository, b => b.DVR_ID, p => p.DVR_ID, (b, p) => new RequstDVRCheckInfoDto { Monitoring_room = b.Monitoring_room, DVR_ID = b.DVR_ID, DVR_Online = p.DVR_Online, SNChenk = p.SNChenk, LastModificationTime = p.LastModificationTime, DiskChenk = p.DiskChenk, Id = p.Id }); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var Chanklist = dvrlist.Where(u => u.LastModificationTime > DateTime.Now.AddDays(-1)).Where(i => i.LastModificationTime < DateTime.Now.AddDays(+1)).Distinct().ToList(); foreach (var item in _monitorRommrepository) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.DVRRoom = item.RoomLocation; //加载主机总数 formsDto.DVRTotal = Chanklist.Where(u => u.Monitoring_room == item.RoomLocation).Distinct().Count(); formsDto.DVRAnomaly = Chanklist.Where(u => u.Monitoring_room == item.RoomLocation).Where(r => r.DiskChenk != null).Where(u => u.DiskChenk == false).Count(); formsDto.DVROnLine = Chanklist.Where(u => u.Monitoring_room == item.RoomLocation).Where(r => r.DVR_Online != null).Where(u => u.DVR_Online == true).Count(); listreportForms.Add(formsDto); } return(listreportForms); }
/// <summary> /// 按部门分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsBydepartment() { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var departments = listdVRCamera.Select(i => new { department = i.Department }).Distinct(); foreach (var item in departments) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.department = item.department; //镜头总数 formsDto.CameraTotal = listDVRCameraRepair.Where(u => u.department == item.department).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(r => !string.IsNullOrEmpty(r.department)).Where(u => u.department == item.department).Where(i => i.RepairState == false).Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(r => !string.IsNullOrEmpty(r.department)).Where(u => u.department == item.department).Where(i => i.RepairState == true).Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal; } listreportForms.Add(formsDto); } return(listreportForms); }
/// <summary> /// 按时间分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByTime(string StartTime, string EndTime, string AnomalyGrade, string AnomalyType, string MonitorRoom) { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); List <DateTime> timelist = new List <DateTime>(); DateTime dateTimeStart = DateTime.Parse(StartTime); DateTime dateTimeEnd = DateTime.Parse(EndTime); for (int i = 0; dateTimeStart.Day + i < dateTimeEnd.Day; i++) { timelist.Add(dateTimeStart.AddDays(i)); } if (!string.IsNullOrEmpty(AnomalyGrade)) { listDVRCameraRepair = listDVRCameraRepair.Where(u => u.AnomalyGrade.Contains(AnomalyGrade)); } if (!string.IsNullOrEmpty(AnomalyType)) { listDVRCameraRepair = listDVRCameraRepair.Where(u => u.AnomalyType.Contains(AnomalyType)); } if (!string.IsNullOrEmpty(MonitorRoom)) { listDVRCameraRepair = listDVRCameraRepair.Where(r => r.DVR_Room != null).Where(u => u.DVR_Room.Contains(MonitorRoom)); } foreach (var item in timelist) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.install_time = item.ToString("yyyy-MM-dd"); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(u => u.CollectTime.Contains(item.ToString("yyyy-MM-dd"))).Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(u => u.RepairedTime.Contains(item.ToString("yyyy-MM-dd"))).Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; formsDto.CameraTotal = _camerarepository.Count(); listreportForms.Add(formsDto); } return(listreportForms); }
/// <summary> /// 按监控室分类数据,指定时间及异常等级/类别 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByMonitorRoomorAnomalyCondition(string StartTime, string EndTime, string AnomalyGrade, string AnomalyType) { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var DVRRooms = _monitorRommrepository.ToList(); listDVRCameraRepair = listDVRCameraRepair.Where(u => u.AnomalyTime != null); if (!string.IsNullOrEmpty(StartTime) && !string.IsNullOrEmpty(EndTime)) { listDVRCameraRepair = listDVRCameraRepair.Where(r => r.AnomalyTime != null).Where(u => string.Compare(u.AnomalyTime, StartTime) >= 0 && string.Compare(u.AnomalyTime, EndTime) <= 0); } if (!string.IsNullOrEmpty(AnomalyGrade)) { listDVRCameraRepair = listDVRCameraRepair.Where(r => r.AnomalyGrade != null).Where(u => u.AnomalyGrade.Contains(AnomalyGrade)); } if (!string.IsNullOrEmpty(AnomalyType)) { listDVRCameraRepair = listDVRCameraRepair.Where(r => r != null).Where(u => u.AnomalyType == AnomalyGrade); } foreach (var item in DVRRooms) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.DVRRoom = item.RoomLocation; //加载主机总数 var data = _dvrrepository.Where(u => u.Monitoring_room == item.RoomLocation).Distinct(); formsDto.DVRTotal = data.Count(); //镜头总数 formsDto.CameraTotal = listdVRCamera.Where(u => u.Monitoring_room == item.RoomLocation).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(u => u.DVR_Room == item.RoomLocation).Where(i => i.RepairState == false).Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(u => u.DVR_Room == item.RoomLocation).Where(i => i.RepairState == true).Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal;; } listreportForms.Add(formsDto); } return(listreportForms); }
/// <summary> /// 按部门分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsBydepartment() { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var departments = _camerarepository.Select(i => new { department = i.department }).Distinct(); foreach (var item in departments) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.Camera_build = item.department; //加载主机总数 formsDto.DVRTotal = listDVRCameraRepair.Where(u => u.department == item.department).Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); //镜头总数 formsDto.CameraTotal = listDVRCameraRepair.Where(u => u.department == item.department).Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(u => u.department == item.department).Where(i => i.RepairState == false).Distinct().Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(u => u.department == item.department).Where(i => i.RepairState == true).Distinct().Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal; } listreportForms.Add(formsDto); } //加载总数 ReportFormsDto formsDto1 = new ReportFormsDto(); formsDto1.DVRRoom = "Total"; formsDto1.CameraAnomaly = listDVRCameraRepair.Where(u => u.RepairState == false).Distinct().Count(); formsDto1.RepairTotal = listDVRCameraRepair.Where(u => u.RepairState == true).Distinct().Count(); formsDto1.CameraTotal = listDVRCameraRepair.Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); formsDto1.DVRTotal = listDVRCameraRepair.Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); //异常+维修总数 formsDto1.CameraAnomalyRepair = formsDto1.CameraAnomaly + formsDto1.RepairTotal; //异常比例 formsDto1.AnomalyProportion = (float)formsDto1.CameraAnomaly / (float)formsDto1.CameraTotal; listreportForms.Add(formsDto1); return(listreportForms); }
/// <summary> /// 按年份分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByYear() { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var yeartimes = _camerarepository.Select(i => new { YearTime = i.install_time }).Distinct().DefaultIfEmpty().ToList(); List <string> yearlist = new List <string>(); Dictionary <int, string> dic = new Dictionary <int, string>(); foreach (var item in yeartimes) { if (item.YearTime != null && item.YearTime != "") { yearlist.Add(item.YearTime.Substring(0, 4)); } } yearlist = yearlist.Distinct().ToList(); foreach (var item in yearlist) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.install_time = item; //镜头总数 formsDto.CameraTotal = listDVRCameraRepair.Where(u => u.install_time.Contains(item)).Distinct().ToList().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(i => i.RepairState == false).Where(u => u.install_time != null).Where(r => r.install_time.Contains(item)).Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(i => i.RepairState == true).Where(u => u.install_time != null).Where(r => r.install_time.Contains(item)).Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal; } listreportForms.Add(formsDto); } return(listreportForms); }
/// <summary> /// 获取在线DVR数量 /// </summary> /// <returns></returns> public async Task <List <ReportFormsDto> > GetDVROnlineTotal() { List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); List <DVRDto> listdvrs = new List <DVRDto>(); var DVRRooms = _dvrrepository.Select(i => new { Monitoring_room = i.Monitoring_room }).Distinct().ToList(); string url = "http://172.30.116.49/api/DVRInfo?"; foreach (var item in DVRRooms) { var data = _dvrrepository.Where(u => u.Monitoring_room == item.Monitoring_room).ToList(); foreach (var tem in data) { url = $"{url}IP=10.10.10.10&name={tem.DVR_usre}&password={tem.DVR_possword}"; using (HttpClient client = new HttpClient()) { HttpResponseMessage response = client.GetAsync(url).Result; var results = response.Content.ReadAsStringAsync().Result; if (results != "[]") { ReportFormsDto report = new ReportFormsDto() { DVROnLine = 100 }; listreportForms.Add(report); return(listreportForms); } } } } return(null); }
/// <summary> /// 按楼栋分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByBuild() { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var builds = listdVRCamera.Select(i => new { build = i.Build }).Distinct(); foreach (var item in builds) { if (!String.IsNullOrEmpty(item.build)) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.Camera_build = item.build; //镜头总数 formsDto.CameraTotal = listdVRCamera.Where(u => u.Build == item.build).Select(t => new { Camera_ID = t.CameraID }).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(r => !string.IsNullOrEmpty(r.Build)).Where(u => u.Build == item.build).Where(i => i.RepairState == false).Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(r => !string.IsNullOrEmpty(r.Build)).Where(u => u.Build == item.build).Where(i => i.RepairState == true).Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal; } listreportForms.Add(formsDto); } } return(listreportForms); }
/// <summary> /// 按监控室分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByMonitorRoom() { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); var DVRRooms = _monitorRommrepository.ToList(); foreach (var item in DVRRooms) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.DVRRoom = item.RoomLocation; //加载主机总数 var data = listDVRCameraRepair.Where(u => u.DVR_Room == item.RoomLocation).Select(i => new { DVR_ID = i.DVR_ID }).Distinct(); formsDto.DVRTotal = data.Count(); //加载主机异常数 List <DVRCheckInfoDto> data2 = new List <DVRCheckInfoDto>(); foreach (var tem in data) { data2.Add(dVRCheckInfos.Where(u => u.DVR_ID == tem.DVR_ID).FirstOrDefault()); } data2 = data2.Distinct().DefaultIfEmpty().ToList(); formsDto.DVRAnomaly = data2.Count; //加载主机在线数据 List <DVRCheckInfoDto> data8 = new List <DVRCheckInfoDto>(); foreach (var tem in data) { data8.Add(dVRCheckOnlines.Where(u => u.DVR_ID == tem.DVR_ID).FirstOrDefault()); } data8 = data8.Distinct().DefaultIfEmpty().ToList(); formsDto.DVROnLine = data8.Count; //镜头总数 formsDto.CameraTotal = listDVRCameraRepair.Where(u => u.DVR_Room == item.RoomLocation).Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(u => u.DVR_Room == item.RoomLocation).Where(i => i.RepairState == false).Distinct().Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(u => u.DVR_Room == item.RoomLocation).Where(i => i.RepairState == true).Distinct().Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal;; } listreportForms.Add(formsDto); } //加载总数 ReportFormsDto formsDto1 = new ReportFormsDto(); formsDto1.DVRRoom = "Total"; formsDto1.CameraAnomaly = listDVRCameraRepair.Where(u => u.RepairState == false).Distinct().Count(); formsDto1.RepairTotal = listDVRCameraRepair.Where(u => u.RepairState == true).Distinct().Count(); formsDto1.CameraTotal = listDVRCameraRepair.Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); formsDto1.DVRTotal = listDVRCameraRepair.Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); //异常+维修总数 formsDto1.CameraAnomalyRepair = formsDto1.CameraAnomaly + formsDto1.RepairTotal; //异常比例 formsDto1.AnomalyProportion = (float)formsDto1.CameraAnomaly / (float)formsDto1.CameraTotal; listreportForms.Add(formsDto1); return(listreportForms); }
/// <summary> /// 按年份分类数据 /// </summary> /// <returns></returns> public List <ReportFormsDto> GetReportFormsByYear() { dVRCameraRepairlist(); List <ReportFormsDto> listreportForms = new List <ReportFormsDto>(); //var yeartimes = _camerarepository.Select(i => new { YearTime = i.install_time }).Distinct().DefaultIfEmpty().ToList(); //List<string> yearlist =new List<string>() ; //foreach (var item in yeartimes) //{ // if (item.YearTime!=null&& item.YearTime != "") // { // yearlist.Add(item.YearTime.Substring(0, 4)); // } //} //yearlist = yearlist.Distinct().ToList(); for (int i = 2007; i < DateTime.Now.Year; i++) { ReportFormsDto formsDto = new ReportFormsDto(); formsDto.install_time = i.ToString(); //加载主机总数 formsDto.DVRTotal = listDVRCameraRepair.Where(u => u.install_time.Contains(i.ToString())).Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); //镜头总数 formsDto.CameraTotal = listDVRCameraRepair.Where(u => u.install_time.Contains(i.ToString())).Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); //加载异常数量 formsDto.CameraAnomaly = listDVRCameraRepair.Where(u => u.install_time.Contains(i.ToString())).Where(i => i.RepairState == false).Distinct().Count(); //加载维修数据 formsDto.RepairTotal = listDVRCameraRepair.Where(u => u.install_time.Contains(i.ToString())).Where(i => i.RepairState == true).Distinct().Count(); //异常+维修总数 formsDto.CameraAnomalyRepair = formsDto.CameraAnomaly + formsDto.RepairTotal; //异常比例 if (formsDto.CameraTotal != 0) { formsDto.AnomalyProportion = (float)formsDto.CameraAnomaly / (float)formsDto.CameraTotal; } listreportForms.Add(formsDto); } //加载总数 ReportFormsDto formsDto1 = new ReportFormsDto(); formsDto1.DVRRoom = "Total"; formsDto1.CameraAnomaly = listDVRCameraRepair.Where(u => u.RepairState == false).Distinct().Count(); formsDto1.RepairTotal = listDVRCameraRepair.Where(u => u.RepairState == true).Distinct().Count(); formsDto1.CameraTotal = listDVRCameraRepair.Select(i => new { CameraID = i.Camera_ID }).Distinct().Count(); formsDto1.DVRTotal = listDVRCameraRepair.Select(i => new { DVR_ID = i.DVR_ID }).Distinct().Count(); //异常+维修总数 formsDto1.CameraAnomalyRepair = formsDto1.CameraAnomaly + formsDto1.RepairTotal; //异常比例 formsDto1.AnomalyProportion = (float)formsDto1.CameraAnomaly / (float)formsDto1.CameraTotal; listreportForms.Add(formsDto1); return(listreportForms); }