燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2023-11-20 8815391f1ea20fd13f77337dc184c6259eeb90b6
src/main/java/com/yssh/service/WarningAnalyseService.java
@@ -1,6 +1,5 @@
package com.yssh.service;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CountDownLatch;
@@ -26,25 +25,28 @@
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    private WarningDetailMapper warningDetailMapper;
    WarningDetailMapper warningDetailMapper;
    @Resource
    private CommonService commonService;
    CommonService commonService;
    @Resource
    private SuYuanMapper suYuanMapper;
    SuYuanMapper suYuanMapper;
    @Resource
    private DictRecordMapper dictRecordMapper;
    DictRecordMapper dictRecordMapper;
    @Resource
    private AsyncService asyncService;
    AsyncService asyncService;
    @Resource
    private QxshMapper qxshMapper;
    QxshMapper qxshMapper;
    @Resource
    private VocValsService vocValsService;
    VocValsService vocValsService;
    @Resource
    SuYuanService suYuanService;
    private static HashMap<String, String> filterMap = new HashMap<>();
@@ -63,14 +65,18 @@
     * 获取实时报警
     */
    public List<Qxsh> getRunTimeAlarmAnalyse(Integer start, Integer end) {
        return qxshMapper.selectAlarmByBeginAndEnd(start, end);
        List<Qxsh> list = qxshMapper.selectAlarmByBeginAndEnd(start, end);
        return copeHasSuYuan(list);
    }
    /**
     * 获取实时预警
     */
    public List<Qxsh> getRunTimeWarningAnalyse(Integer start, Integer end) {
        return qxshMapper.selectWarnByBeginAndEnd(start, end);
        List<Qxsh> list = qxshMapper.selectWarnByBeginAndEnd(start, end);
        return copeHasSuYuan(list);
    }
    /**
@@ -135,11 +141,39 @@
    }
    /**
     * 获取本月监测大数据站点最大值TOP10
     * 获取本月监测站点最大值TOP10
     */
    public List<Qxsh> selectMonthTop10() {
        String time = DateUtils.getYyyyMm(new Date());
        List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%");
        return list;
    }
    /**
     * 获取本周监测站点最大值TOP10
     */
    public List<Qxsh> selectWeekTop10() {
        Date now = new Date();
        int weekOfYear = DateUtils.getWeekOfYear(now);
        int year = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYY, now));
        Date lastSun = DateUtils.getWeekOfYearForSun(year, weekOfYear);
        Date mon = DateUtils.getAPeriodOfTime(lastSun, 1, Calendar.DATE);
        Date sun = DateUtils.getAPeriodOfTime(lastSun, 7, Calendar.DATE);
        Integer intMon = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, mon) + "00"); // 2023080700
        Integer intSun = Integer.parseInt(DateUtils.parseDateToStr(DateUtils.YYYYMMDD, sun) + "23"); // 2023081323
        List<Qxsh> list = qxshMapper.selectWeekTop10(intMon, intSun);
        return list;
    }
    /**
     * 获取本日监测站点最大值TOP10
     */
    public List<Qxsh> selectDayTop10() {
        String time = DateUtils.getYyyyMmDd(new Date());
        List<Qxsh> list = qxshMapper.selectDayTop10(time + "%");
        return list;
    }
@@ -289,4 +323,37 @@
        return result;
    }
    /**
     * 处理是否含有溯源信息
     */
    private List<Qxsh> copeHasSuYuan(List<Qxsh> list) {
        if (null == list || list.isEmpty()) {
            return null;
        }
        Map<String, Integer> tabs = new HashMap<>();
        for (Qxsh qxsh : list) {
            String tab = "su_yuan_" + qxsh.getTime();
            if (!tabs.containsKey(tab)) {
                tabs.put(tab, suYuanMapper.isTableExists(tab));
            }
            int rows = tabs.get(tab);
            if (0 == rows) {
                continue;
            }
            String suYuanId = suYuanService.selectSuYuanIdByName(qxsh.getName());
            String createTime = qxsh.getTime().substring(0, 4) + "-" + qxsh.getTime().substring(4, 6) + "-" + qxsh.getTime().substring(6, 8) + " " + qxsh.getTime().substring(8, 10) + ":00:00";
            Integer isSuYuan = qxshMapper.hasSuYuan(suYuanId, createTime);
            qxsh.setIsSuYuan(isSuYuan);
            Integer isFast = qxshMapper.countFastSuYuan(suYuanId, createTime);
            qxsh.setIsFast(isFast);
        }
        return list;
    }
}