燕山石化溯源三维电子沙盘-【后端】-服务
4
13693261870
2023-07-29 450688a18ced81ec1bd77a535492b12548249e69
4
已修改4个文件
163 ■■■■ 文件已修改
src/main/java/com/yssh/controller/WarningAnalyseController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/mapper/QxshMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/WarningAnalyseService.java 133 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QxshMapper.xml 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/controller/WarningAnalyseController.java
@@ -60,7 +60,7 @@
    }
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "每日预警报警数量变化趋势", notes = "一周每日预警、报警数量统计,返回参数alarmDayCount为一周每日报警统计数量列表,参数warningDayCount为一周每日预警统计数量列表")
    @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;
src/main/java/com/yssh/mapper/QxshMapper.java
@@ -5,6 +5,7 @@
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
 * @author WWW
@@ -17,6 +18,10 @@
    public List<Qxsh> selectMonthTop10(String time);
    public List<Map<String, Object>> count7DayForWarn(@Param("start") Integer start, @Param("end") Integer end);
    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 Qxsh selectByTimeAndName(@Param("time") Integer time, @Param("name") String name);
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -202,139 +202,14 @@
        Date startDate = DateUtils.getAPeriodOfTime(endDate, -6, Calendar.DATE);
        Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate));
        Map<String, List<Map<String, Object>>> result = new HashMap<>();
        List<Map<String, Object>> warnList = qxshMapper.count7DayForWarn(start, end);
        result.put("warningDayCount", warnList);
        Map<String, Object> param = new HashMap<String, Object>();
        Date now = new Date();
        Date last = DateUtils.getAPeriodOfTime(now, -7, Calendar.DATE); // 上周的今天
        param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(last));
        param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(now));
        param.put("type", 0);
        List<Map<String, Object>> alarmDayCount = warningDetailMapper.selectWarningDayCountByMap(param);
        result.put("alarmDayCount", alarmDayCount);
        param.put("type", 1);
        List<Map<String, Object>> warningDayCount = warningDetailMapper.selectWarningDayCountByMap(param);
        result.put("warningDayCount", warningDayCount);
        List<Map<String, Object>> alarmList = qxshMapper.count7DayForAlarm(start, end);
        result.put("alarmDayCount", alarmList);
        return result;
    }
    public Map<String, List<Double>> selectEachLocationDataChange() {
        /*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)));
        List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime);
        checkPoints.forEach(c -> {
            List<String> tableNames = new ArrayList<>();
            recordList.forEach(r -> {
                tableNames.add(r.getTableName());
            });
            List<Double> values = new ArrayList<>();
            if (StringUtils.isNotNull(tableNames)) {
                List<SuYuanMonitorData> data = suYuanMapper.getMonitorData(tableNames, c.getId());
                data.forEach(v -> {
                    values.add(v.getValue());
                });
                result.put(c.getName(), values);
            }
        });
        return result;*/
        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)));
        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) {
            List<Double> values = new ArrayList<>();
            List<SuYuanMonitorData> data = suYuanMapper.getMonitorData(tableNames, c.getId());
            if (null != data && data.size() > 0) {
                for (SuYuanMonitorData v : data) {
                    values.add(v.getValue());
                }
            }
            result.put(c.getName(), values);
        }
        return result;
    }
    public List<Map<String, Object>> selectThisMonthLocationValueDataTop10() {
        /*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);
        checkPoints.forEach(c -> {
            List<String> tableNames = new ArrayList<>();
            recordList.forEach(r -> {
                tableNames.add(r.getTableName());
            });
            Map<String, Object> map = suYuanMapper.getMonthValueDataMax(tableNames, c.getId());
            if (StringUtils.isNotNull(map) && StringUtils.isNotEmpty(map)) {
                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);*/
        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()));
        //startTime = 2023040100L;
        //endTime = 2023043023L;
        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;
        }
        /*List<String> idList = new ArrayList<>();
        for (MonitorPointPosition c : checkPoints) {
            idList.add("'" + c.getId() + "'");
        }
        String ids = String.join(",", idList);*/
        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");
                map.put("name", c.getName());
                result.add(map);
            }
        }
        return CalculateUtils.sort(result, "value", true).subList(0, 10);
    }
    /**
src/main/resources/mapper/QxshMapper.xml
@@ -19,12 +19,23 @@
        limit 10;
    </select>
    <select id="count7DayForWarn" resultType="com.yssh.entity.Qxsh">
        select id, name, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end}
            and value > (select jcyj from alert_config limit 1) and name like 'AI-%'
        order by time, name;
    <select id="count7DayForWarn" resultType="java.util.Map">
        with rs as (
            select left(time, 8) "createTime"
            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)
        )
        select createTime, count(*) "num" from rs group by createTime order by createTime;
    </select>
    <select id="count7DayForAlarm" resultType="java.util.Map">
        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)
        )
        select createTime, count(*) "num" from rs group by createTime order by createTime;
    </select>
    <select id="selectByBeginAndEnd" resultType="com.yssh.entity.Qxsh">