燕山石化溯源三维电子沙盘-【后端】-服务
2
13693261870
2023-07-29 5145384586f87e6c39b13fdac8180007582fee57
2
已修改3个文件
123 ■■■■ 文件已修改
src/main/java/com/yssh/controller/WarningAnalyseController.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/mapper/QxshMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/WarningAnalyseService.java 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -69,24 +69,10 @@
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "三小时监测站点数据变化趋势", notes = "返回值为三小时监测站点监测数据,返回值为map集合,其中key为站点名称,value为list集合,保存每天监测数值数据")
    @GetMapping("/locationDataChange")
    public Result locationDataChange() {
        //return Result.OK(warningService.selectEachLocationDataChange());
    public Result locationDataChange(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        Date endDate = null == date ? new Date() : date;
        String key = DateUtils.getYyyyMmDd(new Date()) + "_local";
        Object obj = CacheUtils.get(key);
        Map<String, List<Double>> map;
        //if (null != obj) {
        //    map = (Map<String, List<Double>>) obj;
        //} else {
        //map = warningService.selectEachLocationDataChange();
        map = warningService.select3Hours();
        //    if (null != map && map.size() > 0) {
        //        CacheUtils.put(key, map);
        //    }
        //}
        return Result.ok(map);
        return Result.OK(warningService.select3Hours(endDate));
    }
    @ApiOperationSupport(order = 4)
src/main/java/com/yssh/mapper/QxshMapper.java
@@ -19,9 +19,9 @@
    public List<Qxsh> select3Hours(@Param("times") List<String> times);
    public List<Qxsh> selectByBeginAndEnd(@Param("start") Integer start, @Param("end") Integer end);
    public Double selectLastYearVal(@Param("time") Integer time, @Param("name") String name);
    public Qxsh selectByTimeAndName(@Param("time") Integer time, @Param("name") String name);
    public List<Qxsh> selectByBeginAndEnd(@Param("start") Integer start, @Param("end") Integer end);
}
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -327,6 +327,33 @@
        return CalculateUtils.sort(result, "value", true).subList(0, 10);
    }
    /**
     * 三小时监测站点数据变化趋势
     */
    public Object select3Hours(Date endDate) {
        Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate));
        Date startDate = DateUtils.getAPeriodOfTime(endDate, -2, Calendar.HOUR_OF_DAY);
        Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate));
        //  List<String> times = DateUtils.get3Hours();
        List<Qxsh> list = qxshMapper.selectByBeginAndEnd(start, end);
        if (null == list || list.isEmpty()) {
            return null;
        }
        /* Map<String, List<Double>> map = new LinkedHashMap<>();
        for (Qxsh qxsh : list) {
            String name = qxsh.getName();
            List<Double> values = map.computeIfAbsent(name, k -> new ArrayList<>());
            values.add(qxsh.getValue());
        }*/
        return list;
    }
    /**
     * 获取本月监测大数据站点最大值TOP10
     */
    public List<Qxsh> selectMonthTop10() {
        String time = DateUtils.getYyyyMm(new Date());
        List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%");
@@ -334,24 +361,9 @@
        return list;
    }
    public Map<String, List<Double>> select3Hours() {
        Map<String, List<Double>> map = new LinkedHashMap<>();
        List<String> times = DateUtils.get3Hours();
        List<Qxsh> list = qxshMapper.select3Hours(times);
        if (null == list || list.isEmpty()) {
            return map;
        }
        for (Qxsh qxsh : list) {
            String name = qxsh.getName();
            List<Double> values = map.computeIfAbsent(name, k -> new ArrayList<>());
            values.add(qxsh.getValue());
        }
        return map;
    }
    /**
     * 根据时间获取报警和预警信息
     */
    public List<Report> getAlarmAndWarnByTime(Date beginDate, Date endDate) {
        String strStart = DateUtils.getYyyyMmDdHh(beginDate);
        String strEnd = DateUtils.getYyyyMmDdHh(endDate);
@@ -402,57 +414,6 @@
        }
        return dict;
    }
    public List<Report> getAlarmAndWarnByTime2(Date begin, Date end) {
        String startTime = DateUtils.getYyyyMmDdHhMmSs(begin);
        String endTime = DateUtils.getYyyyMmDdHhMmSs(end);
        List<WarningDetail> rs = new ArrayList<>();
        List<WarningDetail> rsYj = warningDetailMapper.selectByTimeForYj(startTime, endTime);
        if (null != rsYj && rsYj.size() > 0) rs.addAll(rsYj);
        List<WarningDetail> rsBj = warningDetailMapper.selectByTimeForBj(startTime, endTime);
        if (null != rsBj && rsBj.size() > 0) rs.addAll(rsBj);
        Hashtable<String, Boolean> dict = new Hashtable<>();
        List<Report> list = new ArrayList<>();
        for (WarningDetail wd : rs) {
            /*DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId());
            Double lastVal = warningDetailMapper.getLastYearVal(wd.getId());
            int rows = suYuanMapper.isTableExists(wd.getTableName());
            DistanceSuYuan suMax = null;
            if (rows > 0) {
                MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName());
                List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
                suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d);
            } else {
                suMax = suYuan;
            }*/
            if (dict.containsKey(wd.getTableName())) {
                if (!dict.get(wd.getTableName())) continue;
            } else {
                Boolean b = suYuanMapper.isTableExists(wd.getTableName()) > 0;
                dict.put(wd.getTableName(), b);
                if (!b) continue;
            }
            DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId());
            Double lastVal = warningDetailMapper.getLastYearVal(wd.getId());
            MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName());
            List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
            DistanceSuYuan suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d);
            suMax.setAddr(getAddr(suMax.getId()));
            Report report = Report.calcReport(wd, suYuan, suMax);
            report.setLastVal(lastVal);
            list.add(report);
        }
        return list;
    }
    private String getAddr(String id) {