燕山石化溯源三维电子沙盘-【后端】-服务
6
13693261870
2023-07-29 4b4a150626f7943ee0811d7c3c718be0abe68b23
6
已修改4个文件
113 ■■■■ 文件已修改
src/main/java/com/yssh/controller/WarningAnalyseController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/mapper/QxshMapper.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/WarningAnalyseService.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QxshMapper.xml 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -27,15 +27,15 @@
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "获取实时报警", notes = "获取实时报警分析数据")
    @GetMapping("/runAlarm")
    public Result alarmAnalyse() {
        return Result.OK(warningService.getRunTimeAlarmAnalyse());
    public Result alarmAnalyse(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.getRunTimeAlarmAnalyse(null == date ? new Date() : date));
    }
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "获取实时预警", notes = "获取实时预警分析数据")
    @GetMapping("/runWarning")
    public Result warningAnalyse() {
        return Result.OK(warningService.getRunTimeWarningAnalyse());
    public Result warningAnalyse(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        return Result.OK(warningService.getRunTimeWarningAnalyse(null == date ? new Date() : date));
    }
    @ApiOperationSupport(order = 3)
@@ -49,23 +49,21 @@
    @ApiOperation(value = "一周预警报警数量变化趋势", notes = "一周预警报警数量变化趋势,返回参数alarmDayCount为一周每日报警统计数量列表,参数warningDayCount为一周每日预警统计数量列表")
    @GetMapping("/everydayCount")
    public Result everydayCount(@RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date) {
        Date endDate = null == date ? new Date() : date;
        return Result.OK(warningService.everydayCount(endDate));
        return Result.OK(warningService.everydayCount(null == date ? new Date() : date));
    }
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "三小时监测站点数据变化趋势", notes = "返回值为三小时监测站点监测数据,返回值为map集合,其中key为站点名称,value为list集合,保存每天监测数值数据")
    @GetMapping("/locationDataChange")
    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;
        return Result.OK(warningService.select3Hours(endDate));
        return Result.OK(warningService.select3Hours(null == date ? new Date() : date));
    }
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "获取本月监测大数据站点最大值TOP10", notes = "获取本月监测大数据站点最大值TOP10数量列表")
    @GetMapping("/monthTop10")
    public Result monthTop10() {
        return Result.ok(warningService.selectMonthTop10());
        return Result.OK(warningService.selectMonthTop10());
    }
    @ApiOperationSupport(order = 5)
src/main/java/com/yssh/mapper/QxshMapper.java
@@ -18,6 +18,10 @@
    public List<Qxsh> selectMonthTop10(String time);
    public List<Qxsh> selectWarnByBeginAndEnd(@Param("start") Integer start, @Param("end") Integer end);
    public List<Qxsh> selectAlarmByBeginAndEnd(@Param("start") Integer start, @Param("end") Integer end);
    public Integer countMonthForWarn(@Param("start") Integer start, @Param("end") Integer end);
    public Integer countMonthForAlarm(@Param("start") Integer start, @Param("end") Integer end);
@@ -26,7 +30,7 @@
    public List<Map<String, Object>> count7DayForAlarm(@Param("start") Integer start, @Param("end") Integer end);
    public List<Qxsh> selectByBeginAndEnd(@Param("start") Integer start, @Param("end") Integer end);
    public List<Qxsh> select3Hours(@Param("start") Integer start, @Param("end") Integer end);
    public Qxsh selectByTimeAndName(@Param("time") Integer time, @Param("name") String name);
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -51,7 +51,7 @@
    @Async("threadPoolTaskExecutor")
    public void insertWarningDetails(List<WarningDetail> warning) throws Exception {
        //插入数据
        // 插入数据
        List<List<WarningDetail>> list = Lists.partition(warning, AsyncService.BATCH_INSERT_NUMBER);
        CountDownLatch countDownLatch = new CountDownLatch(list.size());
        for (List<WarningDetail> corpReserveList : list) {
@@ -60,30 +60,15 @@
        countDownLatch.await();
    }
    public List<WarningVo> getRunTimeAlarmAnalyse() {
        List<WarningVo> result = new ArrayList<>();
        Date nowDate = DateUtils.getNowDate();
        //String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate);
        //DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time));
        //if (StringUtils.isNull(dictRecord)) {
        //    nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY);
        //}
        //List<WarningDetail> list = alarmAnalyseOperation(nowDate);
    /**
     * 获取实时报警
     */
    public List<Qxsh> getRunTimeAlarmAnalyse(Date endDate) {
        Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate));
        Date startDate = DateUtils.getAPeriodOfTime(endDate, -5, Calendar.HOUR_OF_DAY);
        Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate));
        List<WarningDetail> list = new ArrayList<>();
        Calendar calendar = getCalendar(nowDate);
        for (int i = 0; i < 8; i++) {
            calendar.add(Calendar.HOUR, -1);
            List<WarningDetail> rs = getAlarmWarnAnalyse(calendar.getTime(), false);
            if (null != rs && rs.size() > 0) {
                list.addAll(rs);
            }
        }
        list.forEach(s -> {
            String time = DateUtils.getYyyyMmDdHh(s.getCreateTime());
            result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time));
        });
        return result;
        return qxshMapper.selectAlarmByBeginAndEnd(start, end);
    }
    private Calendar getCalendar(Date nowDate) {
@@ -94,30 +79,15 @@
        return calendar;
    }
    public List<WarningVo> getRunTimeWarningAnalyse() {
        List<WarningVo> result = new ArrayList<>();
        Date nowDate = DateUtils.getNowDate();
        //String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate);
        //DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time));
        //if (StringUtils.isNull(dictRecord)) {
        //    nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY);
        //}
        //List<WarningDetail> list = warningAnalyseOperation(nowDate);
    /**
     * 获取实时预警
     */
    public List<Qxsh> getRunTimeWarningAnalyse(Date endDate) {
        Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate));
        Date startDate = DateUtils.getAPeriodOfTime(endDate, -5, Calendar.HOUR_OF_DAY);
        Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate));
        List<WarningDetail> list = new ArrayList<>();
        Calendar calendar = getCalendar(nowDate);
        for (int i = 0; i < 8; i++) {
            calendar.add(Calendar.HOUR, -1);
            List<WarningDetail> rs = getAlarmWarnAnalyse(calendar.getTime(), true);
            if (null != rs && rs.size() > 0) {
                list.addAll(rs);
            }
        }
        list.forEach(s -> {
            String time = DateUtils.getYyyyMmDdHh(s.getCreateTime());
            result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time));
        });
        return result;
        return qxshMapper.selectWarnByBeginAndEnd(start, end);
    }
    private List<WarningDetail> getAlarmWarnAnalyse(Date date, boolean isWarn) {
@@ -145,6 +115,7 @@
        return result;
    }
    // 已废弃 *
    public void warningOperationStorage(Date date) {
        List<WarningDetail> allData = new ArrayList<>();
        List<WarningDetail> alarms = this.getAlarmWarnAnalyse(date, false);
@@ -213,7 +184,7 @@
        Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate));
        //  List<String> times = DateUtils.get3Hours();
        List<Qxsh> list = qxshMapper.selectByBeginAndEnd(start, end);
        List<Qxsh> list = qxshMapper.select3Hours(start, end);
        if (null == list || list.isEmpty()) {
            return null;
        }
src/main/resources/mapper/QxshMapper.xml
@@ -19,6 +19,22 @@
        limit 10;
    </select>
    <select id="selectWarnByBeginAndEnd" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcyj from alert_config limit 1) and value &lt;= (select jcbj from alert_config limit 1)
        order by time desc, name;
    </select>
    <select id="selectAlarmByBeginAndEnd" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcbj from alert_config limit 1)
        order by time desc, name;
    </select>
    <select id="countMonthForWarn" resultType="java.lang.Integer">
        select count(*)
        from yssh_qxsh
@@ -29,7 +45,8 @@
    <select id="countMonthForAlarm" resultType="java.lang.Integer">
        select count(*)
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%' and value > (select jcbj from alert_config limit 1);
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcbj from alert_config limit 1);
    </select>
    <select id="count7DayForWarn" resultType="java.util.Map">
@@ -46,12 +63,13 @@
        with rs as (
            select left(time, 8) "createTime"
            from yssh_qxsh
            where time between #{start} and #{end} and name like 'AI-%' and value > (select jcbj from alert_config limit 1)
            where time between #{start} and #{end} and name like 'AI-%'
                and value > (select jcbj from alert_config limit 1)
        )
        select createTime, count(*) "num" from rs group by createTime order by createTime;
    </select>
    <select id="selectByBeginAndEnd" resultType="com.yssh.entity.Qxsh">
    <select id="select3Hours" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end}