From cae71f98572da0f6809ce888ef9a2ecacead34b2 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期六, 10 八月 2024 11:11:17 +0800 Subject: [PATCH] 重点指挥图像在线率 --- ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml | 99 +++++++++++++++++--------------- ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java | 4 ycl-server/src/main/java/com/ycl/task/VideoTask.java | 5 + ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java | 24 ++++--- ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java | 40 +++++++++--- 5 files changed, 100 insertions(+), 72 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java b/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java index 637ef58..6546b7b 100644 --- a/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java +++ b/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java @@ -9,13 +9,11 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; /** @@ -127,14 +125,20 @@ //杩斿洖鐪佸巺鍥芥爣鐮侀泦鍚� public List<String> getProvince() { - List<YwPoint> province = pointMapper.selectByTag(null, Boolean.TRUE); - return province.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList()); + List<YwPoint> province = pointMapper.selectByTag(null, Boolean.TRUE, null); + return CollectionUtils.isEmpty(province) ? new ArrayList<>() : province.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList()); } //杩斿洖閲嶇偣鐐逛綅闆嗗悎 public List<String> getImportant() { - List<YwPoint> important = pointMapper.selectByTag(Boolean.TRUE, null); - return important.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList()); + List<YwPoint> important = pointMapper.selectByTag(Boolean.TRUE, null, null); + return CollectionUtils.isEmpty(important) ? new ArrayList<>() : important.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList()); + } + + //杩斿洖閲嶇偣鎸囨尌鍥惧儚闆嗗悎 + public List<String> getCommandImage() { + List<YwPoint> commandImages = pointMapper.selectByTag(null, null, Boolean.TRUE); + return CollectionUtils.isEmpty(commandImages) ? new ArrayList<>() : commandImages.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList()); } //妫�鏌ユ槸鍚﹀瓨鍦ㄥ綋鏃ユ暟鎹� @@ -153,8 +157,8 @@ } else { try { checkIndex = clazz.getDeclaredConstructor().newInstance(); - checkIndex.setDeptId(key.startsWith(ApiConstants.Province ) ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); - checkIndex.setExamineTag(key.startsWith(ApiConstants.Province ) ? CheckConstants.Examine_Tag_Province : CheckConstants.Examine_Tag_County); + checkIndex.setDeptId(key.startsWith(ApiConstants.Province) ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); + checkIndex.setExamineTag(key.startsWith(ApiConstants.Province) ? CheckConstants.Examine_Tag_Province : CheckConstants.Examine_Tag_County); checkIndex.setCreateTime(new Date()); } catch (Exception e) { checkIndex = null; diff --git a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java index 6258a85..9a8d1b4 100644 --- a/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java +++ b/ycl-server/src/main/java/com/ycl/calculate/VideoOnlineCalculation.java @@ -5,6 +5,7 @@ import com.ycl.platform.domain.entity.TMonitor; import com.ycl.platform.domain.result.HK.SnapshotDelayMonitorResult; import com.ycl.platform.domain.result.UY.QueryVqdResult; +import com.ycl.platform.domain.result.UY.VideoOnlineResult; import com.ycl.platform.domain.vo.TMonitorVO; import com.ycl.platform.mapper.CheckIndexVideoMapper; import com.ycl.platform.mapper.TMonitorMapper; @@ -26,15 +27,14 @@ import java.util.stream.Collectors; /** - * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼 + * 璁$畻瑙嗛璁惧鐐逛綅鍦ㄧ嚎鐜囥�侀噸鐐圭偣浣嶅湪绾跨巼銆侀噸鐐规寚鎸ュ浘鍍忓湪绾跨巼 * 鍥惧儚鐩戞祴璇婃柇缁撴灉 * 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId * 寰幆map璁$畻鏁版嵁涓婁紶鍙婃椂鎬� * 鏇存柊鎴栨柊澧� */ @Component -//TODO锛氶噸鐐规寚鎸ュ浘鍍忓湪绾跨巼 -public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<QueryVqdResult> { +public class VideoOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<VideoOnlineResult> { @Autowired private CheckIndexVideoMapper checkIndexVideoMapper; @Autowired @@ -48,34 +48,38 @@ int onlineSites = 0; int importantSites = 0; int importantOnlineSites = 0; + int commandSites = 0; + int commandOnlineSites =0; } @Override - public void calculate(List<QueryVqdResult> list) { + public void calculate(List<VideoOnlineResult> list) { if (CollectionUtils.isEmpty(list)) { return; } //鑾峰緱鍥芥爣鐮佷负key鐨勮澶噈ap - Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(QueryVqdResult::getDeviceId).collect(Collectors.toList())) + Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(VideoOnlineResult::getDeviceId).collect(Collectors.toList())) .stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity())); //鑾峰彇鐪佸巺鍥芥爣鐮侀泦鍚� List<String> provinceIds = getProvince(); //閲嶇偣鐐逛綅闆嗗悎 List<String> important = getImportant(); + //閲嶇偣鎸囨尌鍥惧儚闆嗗悎 + List<String> commandImage = getCommandImage(); Map<String, AreaStats> areaStatsMap = new HashMap<>(); - for (QueryVqdResult result : list) { + for (VideoOnlineResult result : list) { TMonitorVO monitor = monitorMap.get(result.getDeviceId()); if (monitor == null) continue; String deptId = monitor.getDeptId().toString(); - updateAreaStats(areaStatsMap, deptId, result, important); + updateAreaStats(areaStatsMap, deptId, result, important,commandImage); // 澶勭悊鐪佸巺鏁版嵁 if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { String provinceKey = ApiConstants.Province + deptId; - updateAreaStats(areaStatsMap, provinceKey, result, important); + updateAreaStats(areaStatsMap, provinceKey, result, important,commandImage); } } @@ -95,19 +99,27 @@ } /** - * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟 + * 绱鎬荤偣浣嶆暟銆佸湪绾跨偣浣嶆暟銆侀噸鐐圭偣浣嶆暟銆侀噸鐐圭偣浣嶅湪绾挎暟銆佹寚鎸ュ浘鍍忔暟銆佹寚鎸ュ浘鍍忓湪绾挎暟 */ - private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, QueryVqdResult result, List<String> important) { + private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, VideoOnlineResult result, List<String> important, List<String> commandImage) { //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); stats.totalSites++; + //閲嶇偣鐐逛綅 if(important.contains(result.getDeviceId())){ stats.importantSites++; } - if (ApiConstants.UY_OnlineSite_Online.equals(result.getOnlineStatus())){ + //鎸囨尌鍥惧儚鐐逛綅 + if(commandImage.contains(result.getDeviceId())){ + stats.commandSites++; + } + if (ApiConstants.UY_OnlineSite_Online.equals(result.getStatus())){ stats.onlineSites++; if(important.contains(result.getDeviceId())){ stats.importantOnlineSites++; + } + if(commandImage.contains(result.getDeviceId())){ + stats.commandOnlineSites++; } } } @@ -132,6 +144,12 @@ param.put("onlineSites", stats.importantOnlineSites); BigDecimal importantSiteOnline = siteOnline(importantParam); checkIndexVideo.setKeySiteOnline(importantSiteOnline); + //璋冪敤鐐逛綅鍦ㄧ嚎鐜囪绠楁柟娉� 璁$畻鎸囨尌鍥惧儚鍦ㄧ嚎鐜� + Map<String, Object> commandParam = new HashMap<>(); + param.put("totalSites", stats.commandSites); + param.put("onlineSites", stats.commandOnlineSites); + BigDecimal commandSiteOnline = siteOnline(importantParam); + checkIndexVideo.setKeyCommandImageOnline(commandSiteOnline); return checkIndexVideo; } } diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java index 12756ed..4a15433 100644 --- a/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java +++ b/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java @@ -38,9 +38,9 @@ List<YwPoint> home(); /** - * 閫氳繃鏍囩鏌ラ噸鐐圭偣浣嶆垨鐪佸巺鐐逛綅 + * 閫氳繃鏍囩鏌ラ噸鐐圭偣浣嶆垨鐪佸巺鐐逛綅鎴栭噸鐐规寚鎸ュ浘鍍� */ - List<YwPoint> selectByTag(@Param("important")Boolean important, @Param("province")Boolean province); + List<YwPoint> selectByTag(@Param("important")Boolean important, @Param("province")Boolean province, @Param("commandImage")Boolean commandImage); /** * 瀵煎嚭鏁版嵁 diff --git a/ycl-server/src/main/java/com/ycl/task/VideoTask.java b/ycl-server/src/main/java/com/ycl/task/VideoTask.java index fe804d8..7b0f7ec 100644 --- a/ycl-server/src/main/java/com/ycl/task/VideoTask.java +++ b/ycl-server/src/main/java/com/ycl/task/VideoTask.java @@ -8,6 +8,7 @@ import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; import com.ycl.platform.domain.result.UY.MonitorQualifyResult; import com.ycl.platform.domain.result.UY.QueryVqdResult; +import com.ycl.platform.domain.result.UY.VideoOnlineResult; import com.ycl.platform.domain.vo.PlatformOnlineVO; import com.ycl.platform.mapper.CheckIndexVideoMapper; import com.ycl.platform.mapper.PlatformOnlineMapper; @@ -46,12 +47,12 @@ public void siteOnlineTask() { Date yesterday = DateUtils.addDays(new Date(), -1); - //TODO锛氳绠楃偣浣嶅湪绾跨巼鍜岄噸鐐圭偣浣嶅湪绾跨巼 + //璁$畻鐐逛綅鍦ㄧ嚎鐜囧拰閲嶇偣鐐逛綅鍦ㄧ嚎鐜囧拰鎸囨尌鍥惧儚鍦ㄧ嚎鐜� Query query = new Query(); query.addCriteria(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); - List<QueryVqdResult> results = mongoTemplate.find(query, QueryVqdResult.class); + List<VideoOnlineResult> results = mongoTemplate.find(query, VideoOnlineResult.class); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Video_SiteOnline); calculator.calculate(results); } diff --git a/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml index 28f53bf..ed1861a 100644 --- a/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml +++ b/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml @@ -4,21 +4,21 @@ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> <resultMap id="BaseResultMap" type="com.ycl.platform.domain.vo.YwPointVO"> - <result column="id" property="id" /> - <result column="point_name" property="pointName" /> - <result column="start_time" property="startTime" /> - <result column="end_time" property="endTime" /> - <result column="unit_id" property="unitId" /> - <result column="unit_name" property="unitName" /> - <result column="status" property="status" /> - <result column="dept_id" property="deptId" /> - <result column="dept_name" property="deptName" /> - <result column="remark" property="remark" /> - <result column="create_time" property="createTime" /> - <result column="update_time" property="updateTime" /> - <result column="province_tag" property="provinceTag" /> - <result column="important_tag" property="importantTag" /> - <result column="important_command_image_tag" property="importantCommandImageTag" /> + <result column="id" property="id"/> + <result column="point_name" property="pointName"/> + <result column="start_time" property="startTime"/> + <result column="end_time" property="endTime"/> + <result column="unit_id" property="unitId"/> + <result column="unit_name" property="unitName"/> + <result column="status" property="status"/> + <result column="dept_id" property="deptId"/> + <result column="dept_name" property="deptName"/> + <result column="remark" property="remark"/> + <result column="create_time" property="createTime"/> + <result column="update_time" property="updateTime"/> + <result column="province_tag" property="provinceTag"/> + <result column="important_tag" property="importantTag"/> + <result column="important_command_image_tag" property="importantCommandImageTag"/> </resultMap> <select id="selectData" resultType="com.ycl.platform.base.BaseSelect"> @@ -27,25 +27,25 @@ <select id="page" resultMap="BaseResultMap"> SELECT - typ.id, - typ.point_name, - typ.start_time, - typ.end_time, - typ.unit_id, - tyu.unit_name, - typ.status, - typ.dept_id, - sd.dept_name, - typ.remark, - typ.create_time, - typ.update_time, - typ.important_tag, - typ.province_tag, - typ.important_command_image_tag + typ.id, + typ.point_name, + typ.start_time, + typ.end_time, + typ.unit_id, + tyu.unit_name, + typ.status, + typ.dept_id, + sd.dept_name, + typ.remark, + typ.create_time, + typ.update_time, + typ.important_tag, + typ.province_tag, + typ.important_command_image_tag FROM - t_yw_point typ - LEFT JOIN t_yw_unit tyu ON typ.unit_id = tyu.id AND tyu.deleted = 0 - LEFT JOIN sys_dept sd ON typ.dept_id = sd.dept_id AND sd.del_flag = 0 + t_yw_point typ + LEFT JOIN t_yw_unit tyu ON typ.unit_id = tyu.id AND tyu.deleted = 0 + LEFT JOIN sys_dept sd ON typ.dept_id = sd.dept_id AND sd.del_flag = 0 <where> <if test="query.pointName != null and query.pointName != ''"> AND typ.point_name like concat('%', #{query.pointName}, '%') @@ -57,9 +57,11 @@ <![CDATA[ SELECT t_yw_point.id, point_name, start_time, end_time, status, unit_name AS remark FROM t_yw_point - LEFT JOIN t_yw_unit ON t_yw_unit.id = t_yw_point.unit_id AND t_yw_point.deleted = 0 + LEFT JOIN t_yw_unit ON t_yw_unit.id = t_yw_point.unit_id AND t_yw_point.deleted = 0 WHERE t_yw_point.deleted = 0 - AND TIMESTAMPDIFF(MONTH, NOW(), end_time) <= (SELECT config_value FROM sys_config WHERE config_key = 'operation.and.maintenance.expiration.warning.time') + AND TIMESTAMPDIFF(MONTH, NOW(), end_time) <= (SELECT config_value + FROM sys_config + WHERE config_key = 'operation.and.maintenance.expiration.warning.time') ORDER BY end_time ]]> </select> @@ -73,24 +75,27 @@ <if test="province!=null and province == true "> and province_tag = #{province} </if> + <if test="commandImage!=null and commandImage == true "> + and important_command_image_tag = #{commandImage} + </if> </where> </select> <select id="export" resultType="com.ycl.platform.domain.excel.PointExport"> SELECT - m.name as pointName, - m.serial_number, - m.ip, - yu.unit_name, - yp.start_time, - yp.end_time, - yp.province_tag, - yp.important_tag, - yp.important_command_image_tag + m.name as pointName, + m.serial_number, + m.ip, + yu.unit_name, + yp.start_time, + yp.end_time, + yp.province_tag, + yp.important_tag, + yp.important_command_image_tag FROM - t_yw_point yp - INNER JOIN t_monitor m ON yp.serial_number = m.serial_number - INNER JOIN t_yw_unit yu ON yu.id = yp.unit_id + t_yw_point yp + INNER JOIN t_monitor m ON yp.serial_number = m.serial_number + INNER JOIN t_yw_unit yu ON yu.id = yp.unit_id <where> <if test="query.pointName != null and query.pointName != ''"> AND m.name like concat('%', #{query.pointName} ,'%') -- Gitblit v1.8.0