From 87a7362709ac249c3965a392842cf24bc402b6c1 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期一, 28 十月 2024 11:49:09 +0800 Subject: [PATCH] 档案考核比、一机一档合格、注册率。数据中心视频类优化完 --- ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java | 141 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 114 insertions(+), 27 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java index 78ff3c8..931cac4 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java @@ -22,6 +22,7 @@ import com.ycl.platform.domain.result.UY.MonitorQualifyResult; import com.ycl.platform.domain.result.UY.OsdCheckResult; import com.ycl.platform.domain.result.UY.RecordMetaDSumResult; +import com.ycl.platform.domain.vo.DynamicColumnVO; import com.ycl.platform.domain.vo.TMonitorVO; import com.ycl.platform.domain.vo.WorkOrderVO; import com.ycl.platform.domain.vo.home.BaseHomeVO; @@ -30,6 +31,7 @@ import com.ycl.platform.domain.vo.home.HomeVideoVO; import com.ycl.platform.domain.vo.screen.MonitorRateVO; import com.ycl.platform.domain.vo.screen.MonitorTotalVO; +import com.ycl.platform.mapper.DynamicColumnMapper; import com.ycl.platform.mapper.TMonitorMapper; import com.ycl.platform.mapper.WorkOrderMapper; import com.ycl.platform.service.ITMonitorService; @@ -91,6 +93,8 @@ private WorkOrderMapper workOrderMapper; @Autowired private SysDictDataMapper dictDataMapper; + @Autowired + private DynamicColumnMapper dynamicColumnMapper; /** * 鏌ヨ璁惧璧勪骇 @@ -406,6 +410,14 @@ */ @Override public void exportVideoTotal(HttpServletResponse response, VideoExportForm exportForm) throws IOException { + //榛樿鏌ユ墍鏈夐儴闂� + if(CollectionUtils.isEmpty(exportForm.getDeptIds())){ + List<Integer> deptIds = new ArrayList<>(); + for (AreaDeptEnum value : AreaDeptEnum.values()) { + deptIds.add(value.getDeptId()); + } + exportForm.setDeptIds(deptIds); + } List<ExcelExp> mysheet = new ArrayList<>(); exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + "")); VideoExportForm.convertTags(exportForm); @@ -445,7 +457,7 @@ if (!CollectionUtils.isEmpty(onlines)) { videoExp.setTotal(onlines.size()); videoExp.setOnline(Integer.valueOf(onlines.stream() - .filter(TMonitorResult::getOnline) + .filter(TMonitorResult::getPingOnline) .count() + "")); videoExp.setOffline(videoExp.getTotal() - videoExp.getOnline()); } @@ -490,10 +502,29 @@ */ @Override public void exportVideoOnline(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException { + //榛樿鏌ユ墍鏈夐儴闂� + if(CollectionUtils.isEmpty(exportForm.getDeptIds())){ + List<Integer> deptIds = new ArrayList<>(); + for (AreaDeptEnum value : AreaDeptEnum.values()) { + deptIds.add(value.getDeptId()); + } + exportForm.setDeptIds(deptIds); + } List<ExcelExp> mysheet = new ArrayList<>(); exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + "")); VideoExportForm.convertTags(exportForm); List<TMonitorResult> tMonitorResults = tMonitorMapper.selectMonitorResult(exportForm); + //鑾峰彇鍔ㄦ�佸垪鏁版嵁 + List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList()); + List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds); + //琛ュ厖鍔ㄦ�佸垪鏁版嵁 + if(!CollectionUtils.isEmpty(dynamics)) { + Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId)); + for (TMonitorResult tMonitorResult : tMonitorResults) { + Integer pointId = tMonitorResult.getPointId(); + tMonitorResult.setDynamicColumnList(map.get(pointId)); + } + } List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList()); Query query = getQuery(deviceIds, exportForm.getMonth()); //鏈堜唤姣忔棩鍦ㄧ嚎鏁版嵁 @@ -514,12 +545,19 @@ videoDailyExp.setSerialNumber(result.getNo()); videoDailyExp.setDeviceName(result.getName()); videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName()); - String tag = "" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : ""); - // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲�� - if (tag.endsWith("銆�")) { - tag = tag.substring(0, tag.length() - 1); + StringBuilder tag = new StringBuilder("" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : "")); + //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲� + if(!CollectionUtils.isEmpty(result.getDynamicColumnList())){ + List<DynamicColumnVO> dynamicColumnList = result.getDynamicColumnList(); + for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) { + tag.append(dynamicColumnVO.getColumnValue()).append("銆�"); + } } - videoDailyExp.setTag(tag); + // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲�� + if (tag.toString().endsWith("銆�")) { + tag = new StringBuilder(tag.substring(0, tag.length() - 1)); + } + videoDailyExp.setTag(tag.toString()); setOnlineDaily(videoDailyExp, result, onlines); videoDailyExps.add(videoDailyExp); //鍏ㄩ噺琛� @@ -540,10 +578,29 @@ */ @Override public void exportVideoRecord(HttpServletResponse response, VideoExportForm exportForm) throws IOException, NoSuchFieldException, IllegalAccessException { + //榛樿鏌ユ墍鏈夐儴闂� + if(CollectionUtils.isEmpty(exportForm.getDeptIds())){ + List<Integer> deptIds = new ArrayList<>(); + for (AreaDeptEnum value : AreaDeptEnum.values()) { + deptIds.add(value.getDeptId()); + } + exportForm.setDeptIds(deptIds); + } List<ExcelExp> mysheet = new ArrayList<>(); exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + "")); VideoExportForm.convertTags(exportForm); List<TMonitorResult> tMonitorResults = tMonitorMapper.selectMonitorResult(exportForm); + //鑾峰彇鍔ㄦ�佸垪鏁版嵁 + List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList()); + List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds); + //琛ュ厖鍔ㄦ�佸垪鏁版嵁 + if(!CollectionUtils.isEmpty(dynamics)) { + Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId)); + for (TMonitorResult tMonitorResult : tMonitorResults) { + Integer pointId = tMonitorResult.getPointId(); + tMonitorResult.setDynamicColumnList(map.get(pointId)); + } + } List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList()); Query query = getQuery(deviceIds, exportForm.getMonth()); //鏈堜唤姣忔棩褰曞儚绾挎暟鎹� @@ -564,12 +621,19 @@ videoDailyExp.setSerialNumber(result.getNo()); videoDailyExp.setDeviceName(result.getName()); videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName()); - String tag = "" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : ""); - // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲�� - if (tag.endsWith("銆�")) { - tag = tag.substring(0, tag.length() - 1); + StringBuilder tag = new StringBuilder("" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : "")); + //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲� + if(!CollectionUtils.isEmpty(result.getDynamicColumnList())){ + List<DynamicColumnVO> dynamicColumnList = result.getDynamicColumnList(); + for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) { + tag.append(dynamicColumnVO.getColumnValue()).append("銆�"); + } } - videoDailyExp.setTag(tag); + // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲�� + if (tag.toString().endsWith("銆�")) { + tag = new StringBuilder(tag.substring(0, tag.length() - 1)); + } + videoDailyExp.setTag(tag.toString()); setRecordDaily(videoDailyExp, result, records); //鍖哄幙琛� videoDailyExps.add(videoDailyExp); @@ -590,10 +654,29 @@ */ @Override public void exportVideoLoseTime(HttpServletResponse response, VideoExportForm exportForm) throws NoSuchFieldException, IllegalAccessException, IOException { + //榛樿鏌ユ墍鏈夐儴闂� + if(CollectionUtils.isEmpty(exportForm.getDeptIds())){ + List<Integer> deptIds = new ArrayList<>(); + for (AreaDeptEnum value : AreaDeptEnum.values()) { + deptIds.add(value.getDeptId()); + } + exportForm.setDeptIds(deptIds); + } List<ExcelExp> mysheet = new ArrayList<>(); exportForm.setCameraFunType(Integer.valueOf(CheckConstants.Rule_Category_Video + "")); VideoExportForm.convertTags(exportForm); List<TMonitorResult> tMonitorResults = tMonitorMapper.selectMonitorResult(exportForm); + //鑾峰彇鍔ㄦ�佸垪鏁版嵁 + List<Integer> pointIds = tMonitorResults.stream().map(TMonitorResult::getPointId).collect(Collectors.toList()); + List<DynamicColumnVO> dynamics = dynamicColumnMapper.getDynamicsByIds("t_yw_point", pointIds); + //琛ュ厖鍔ㄦ�佸垪鏁版嵁 + if(!CollectionUtils.isEmpty(dynamics)) { + Map<Integer, List<DynamicColumnVO>> map = dynamics.stream().collect(Collectors.groupingBy(DynamicColumnVO::getRefId)); + for (TMonitorResult tMonitorResult : tMonitorResults) { + Integer pointId = tMonitorResult.getPointId(); + tMonitorResult.setDynamicColumnList(map.get(pointId)); + } + } List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList()); Query query = getQuery(deviceIds, exportForm.getMonth()); //鏈堜唤姣忔棩褰曞儚绾挎暟鎹� @@ -614,12 +697,19 @@ videoDailyExp.setSerialNumber(result.getNo()); videoDailyExp.setDeviceName(result.getName()); videoDailyExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName()); - String tag = "" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : ""); - // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲�� - if (tag.endsWith("銆�")) { - tag = tag.substring(0, tag.length() - 1); + StringBuilder tag = new StringBuilder("" + (result.getProvinceTag() ? "鐪佸巺銆�" : "") + (result.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (result.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (result.getDeptTag() ? "閮ㄧ骇銆�" : "")); + //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲� + if(!CollectionUtils.isEmpty(result.getDynamicColumnList())){ + List<DynamicColumnVO> dynamicColumnList = result.getDynamicColumnList(); + for (DynamicColumnVO dynamicColumnVO : dynamicColumnList) { + tag.append(dynamicColumnVO.getColumnValue()).append("銆�"); + } } - videoDailyExp.setTag(tag); + // 鍒犻櫎瀛楃涓叉湯灏剧殑鈥溿�佲�� + if (tag.toString().endsWith("銆�")) { + tag = new StringBuilder(tag.substring(0, tag.length() - 1)); + } + videoDailyExp.setTag(tag.toString()); setLoseDaily(videoDailyExp, result, records); videoDailyExps.add(videoDailyExp); //鍏ㄩ噺琛� @@ -789,8 +879,6 @@ matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); if (examineTag != null && examineTag.equals(1)) { matchConditions.add(new Document("provinceTag", true)); - } else if (examineTag != null && examineTag.equals(2)) { - matchConditions.add(new Document("deptTag", true)); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -799,7 +887,6 @@ .append("dataCount", new Document("$sum", "$dataCount")) ) ); - // 鎵ц鑱氬悎鏌ヨ骞惰幏鍙栫粨鏋� AggregateIterable<Document> result = collection.aggregate(pipeline); for (Document doc : result) { @@ -809,7 +896,7 @@ results.add(homecarVO); } - //mongo鏌ョ偣浣嶅湪绾� + //TODO锛氬湪绾夸慨鏀癸紝闇�瑕佹妸妫�娴嬫捣搴蜂紭浜戞娴嬬殑缁撴灉瀛樺叆mongo锛宮ongo鏌ョ偣浣嶅湪绾� MongoCollection<Document> onlineCollection = database.getCollection("t_monitor_online"); // 鏋勫缓鍩烘湰鐨�$match鏉′欢 List<Document> onlineMatch = new ArrayList<>(); @@ -817,8 +904,6 @@ onlineMatch.add(new Document("monitorType", new Document("$regex", "2"))); if (examineTag != null && examineTag.equals(1)) { onlineMatch.add(new Document("provinceTag", true)); - } else if (examineTag != null && examineTag.equals(2)) { - onlineMatch.add(new Document("deptTag", true)); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> onlinePipeline = Arrays.asList( @@ -904,8 +989,6 @@ matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_FACE))); if (examineTag != null && examineTag.equals(1)) { matchConditions.add(new Document("provinceTag", true)); - } else if (examineTag != null && examineTag.equals(2)) { - matchConditions.add(new Document("deptTag", true)); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -932,8 +1015,6 @@ onlineMatch.add(new Document("monitorType", new Document("$regex", "3"))); if (examineTag != null && examineTag.equals(1)) { onlineMatch.add(new Document("provinceTag", true)); - } else if (examineTag != null && examineTag.equals(2)) { - onlineMatch.add(new Document("deptTag", true)); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> onlinePipeline = Arrays.asList( @@ -1018,7 +1099,13 @@ for (TMonitorResult monitorResult : onlineResult) { int dayOfMonth = monitorResult.getMongoCreateTime().getDayOfMonth(); String online = ""; - online += monitorResult.getOnline() ? "鍦ㄧ嚎" : "绂荤嚎"; + if(ApiConstants.UY_OnlineSite_Online.equals(monitorResult.getOnline())){ + online +="鍦ㄧ嚎"; + }else if(ApiConstants.UY_OnlineSite_Offline.equals(monitorResult.getOnline())){ + online +="绂荤嚎"; + }else { + online +="鏈煡"; + } //鍙嶅皠璧嬪�硷紝瀛楁缁熶竴瀹氫箟涓篸ay+1锛�2锛�3... Field field = videoDailyExp.getClass().getDeclaredField("day" + dayOfMonth); field.setAccessible(true); -- Gitblit v1.8.0