| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | |
| | | //返回省厅国标码集合 |
| | | 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()); |
| | | } |
| | | |
| | | //检查是否存在当日数据 |
| | |
| | | } 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; |
| | |
| | | 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; |
| | |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 计算视频设备点位在线率、重点点位在线率 |
| | | * 计算视频设备点位在线率、重点点位在线率、重点指挥图像在线率 |
| | | * 图像监测诊断结果 |
| | | * 获取分省厅、区域的map<k,v> k为deptId或者Province_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 |
| | |
| | | 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的设备map |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 累计总点位数、在线点位数、重点点位数、重点点位在线数 |
| | | * 累计总点位数、在线点位数、重点点位数、重点点位在线数、指挥图像数、指挥图像在线数 |
| | | */ |
| | | 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++; |
| | | } |
| | | } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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); |
| | | |
| | | /** |
| | | * 导出数据 |
| | |
| | | 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; |
| | |
| | | |
| | | 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); |
| | | } |
| | |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <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"> |
| | |
| | | |
| | | <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}, '%') |
| | |
| | | <![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> |
| | |
| | | <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} ,'%') |