燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-04-26 a3d41aaa84c64dd296a2bd89198682276ef7b1d3
1
已修改2个文件
62 ■■■■ 文件已修改
src/main/java/com/yssh/controller/WarningAnalyseController.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -34,6 +34,7 @@
    public static final long CACHE_HOLD_TIME_24H = 24 * 60 * 60 * 1000L;
    //报警分析
    /**
     * 1.查询当前时间的所有点位value值(以47.dat查询即可)
     * 2.筛选大于yssh_bjyj中的jcbj字段的值 返回id+经纬度+value
@@ -46,6 +47,7 @@
    }
    
    //预警分析
    /**
     * 1.查询当前时间的所有点位value值(以47.dat查询即可)
     * 2.筛选大于yssh_bjyj中的jcyj字段的值 返回id+经纬度+value
@@ -77,16 +79,13 @@
    public Result locationDataChange() {
        //return Result.OK(warningService.selectEachLocationDataChange());
        String key = dateFormat.format(new Date());
        Map<String, List<Double>> map = null;
        String key = dateFormat.format(new Date()) + "_local";
        Map<String, List<Double>> map;
        if (cache.containsKey(key)) {
            map = (Map<String, List<Double>>) cache.get(key);
        } else {
            map = warningService.selectEachLocationDataChange();
            if (null != map && map.size() > 0) {
                if (cache.size() > 0) {
                    cache.clear();
                }
                cache.put(key, map);
            }
        }
@@ -98,6 +97,19 @@
    @ApiOperation(value = "获取本月监测大数据站点最大值TOP10", notes = "获取本月监测大数据站点最大值TOP10数量列表")
    @GetMapping("/monthTop10")
    public Result monthTop10(){
        return Result.OK(warningService.selectThisMonthLocationValueDataTop10());
        //return Result.OK(warningService.selectThisMonthLocationValueDataTop10());
        String key = dateFormat.format(new Date()) + "_top10";
        List<Map<String, Object>> list;
        if (cache.containsKey(key)) {
            list = (List<Map<String, Object>>) cache.get(key);
        } else {
            list = warningService.selectThisMonthLocationValueDataTop10();
            if (null != list && list.size() > 0) {
                cache.put(key, list);
            }
        }
        return Result.OK(list);
    }
}
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
@@ -253,7 +253,6 @@
        Map<String, List<Double>> result = new LinkedHashMap<>();
        List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d();
        Date nowDate = DateUtils.getNowDate();
        Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate));
        Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getAPeriodOfTime(nowDate, -3, Calendar.HOUR_OF_DAY)));
@@ -272,9 +271,11 @@
        for(MonitorPointPosition c : checkPoints){
            List<Double> values = new ArrayList<>();
            List<SuYuanMonitorData> data = suYuanMapper.getMonitorData(tableNames, c.getId());
            data.forEach(v -> {
            if (null != data && data.size() > 0) {
                for (SuYuanMonitorData v : data) {
                values.add(v.getValue());
            });
                }
            }
            result.put(c.getName(), values);
        }
        return result;
@@ -282,7 +283,7 @@
    @Override
    public List<Map<String, Object>> selectThisMonthLocationValueDataTop10() {
        List<Map<String, Object>> result = new ArrayList<>();
        /*List<Map<String, Object>> result = new ArrayList<>();
        List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d();
        Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart()));
        Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd()));
@@ -300,7 +301,34 @@
            }
            result.add(map);
        });
        return CalculateUtils.sort(result, "value", true).subList(0, 10);
        return CalculateUtils.sort(result, "value", true).subList(0, 10);*/
        List<Map<String, Object>> result = new ArrayList<>();
        List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d();
        Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart()));
        Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd()));
        List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime);
        List<String> tableNames = new ArrayList<>();
        for (DictRecord dr : recordList) {
            if (suYuanMapper.isTableExists(dr.getTableName()) > 0) {
                tableNames.add(dr.getTableName());
            }
        }
        if (tableNames.isEmpty()) {
            return result;
    }
        for (MonitorPointPosition c : checkPoints) {
            Map<String, Object> map = suYuanMapper.getMonthValueDataMax(tableNames, c.getId());
            if (null != map && map.size() > 0) {
                String suYuanId = map.get("id").toString();
                map.put("name", commonService.select3dCheckPointById(suYuanId).getName());
                map.remove("id");
            }
            result.add(map);
        }
        return CalculateUtils.sort(result, "value", true).subList(0, 10);
    }
}