燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-06-09 52e98d126e44db1594f46326132935e2ea85192f
1
已修改2个文件
102 ■■■■ 文件已修改
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java 96 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/utils/DateUtils.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
@@ -52,10 +52,6 @@
    private SimpleDateFormat ym = new SimpleDateFormat("yyyyMM%");
    private SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH");
    private SimpleDateFormat ymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @Override
    @Async("threadPoolTaskExecutor")
    public void insertWarningDetails(List<WarningDetail> warning) throws Exception {
@@ -89,7 +85,7 @@
            }
        }
        list.forEach(s -> {
            String time = ymdh.format(s.getCreateTime());
            String time = DateUtils.getYyyyMmDdHh(s.getCreateTime());
            result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time));
        });
        return result;
@@ -124,7 +120,7 @@
            }
        }
        list.forEach(s -> {
            String time = ymdh.format(s.getCreateTime());
            String time = DateUtils.getYyyyMmDdHh(s.getCreateTime());
            result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time));
        });
        return result;
@@ -182,8 +178,8 @@
    public Map<String, Integer> countThisMonthAlarmAndWarning() {
        Map<String, Integer> result = new HashMap<>();
        Map<String, Object> param = new HashMap<>();
        param.put("startTime", ymdhms.format(DateUtils.getMonthStart()));
        param.put("endTime", ymdhms.format(DateUtils.getMonthEnd()));
        param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(DateUtils.getMonthStart()));
        param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(DateUtils.getMonthEnd()));
        /*param.put("type", 0);
        List<WarningVo> alarms = warningDetailMapper.selectWarningDetailByMap(param);
@@ -213,8 +209,8 @@
        Map<String, Object> param = new HashMap<String, Object>();
        Date now = new Date();
        Date last = DateUtils.getAPeriodOfTime(now, -7, Calendar.DATE); // 上周的今天
        param.put("startTime", ymdhms.format(last));
        param.put("endTime", ymdhms.format(now));
        param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(last));
        param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(now));
        param.put("type", 0);
        List<Map<String, Object>> alarmDayCount = warningDetailMapper.selectWarningDayCountByMap(param);
@@ -344,9 +340,9 @@
    @Override
    public List<Qxsh> selectMonthTop10() {
        String time = ym.format(new Date());
        String time = DateUtils.getYyyyMm(new Date());
        List<Qxsh> list = qxshMapper.selectMonthTop10(time);
        List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%");
        return list;
    }
@@ -373,8 +369,8 @@
    @Override
    public List<Report> getAlarmAndWarnByTime(Date begin, Date end) {
        String startTime = ymdhms.format(begin);
        String endTime = ymdhms.format(end);
        String startTime = DateUtils.getYyyyMmDdHhMmSs(begin);
        String endTime = DateUtils.getYyyyMmDdHhMmSs(end);
        List<WarningDetail> rs = new ArrayList<>();
        List<WarningDetail> rsYj = warningDetailMapper.selectByTimeForYj(startTime, endTime);
@@ -408,77 +404,5 @@
        }
        return list;
    }
    public List<WarningVo> getAlarmAndWarnByTime_old(Date begin, Date end) {
        List<WarningVo> list = new ArrayList<>();
        List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d());
        if (ids.size() == 0) {
            return list;
        }
        List<DictRecord> dictList = dictRecordMapper.selectByTime(ymdhms.format(begin), ymdhms.format(end));
        if (null == dictList || dictList.isEmpty()) {
            return list;
        }
        List<String> tables = new ArrayList<>();
        for (DictRecord dr : dictList) {
            if (suYuanMapper.isTableExists(dr.getTableName()) > 0) {
                tables.add(dr.getTableName());
            }
        }
        if (tables.size() == 0) {
            return list;
        }
        for (String tab : tables) {
            List<WarningDetail> alarmList = getAlarmByTime(tab, ids);
            for (WarningDetail s : alarmList) {
                String time = ymdh.format(s.getCreateTime());
                list.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time));
            }
        }
        for (String tab : tables) {
            List<WarningDetail> warnList = getWarnByTime(tab, ids);
            for (WarningDetail s : warnList) {
                String time = ymdh.format(s.getCreateTime());
                list.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time));
            }
        }
        return list;
    }
    private List<WarningDetail> getAlarmByTime(String tableName, List<String> ids) {
        List<WarningDetail> result = new ArrayList<>();
        List<SuYuan2d> list = suYuanMapper.getAlarmsAnalyse(tableName, ids);
        if (null != list && list.size() > 0) {
            Date date = getDateByTabName(tableName);
            for (SuYuan2d s : list) {
                String locationName = commonService.select3dCheckPointById(s.getId()).getName();
                result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 0, s.getValue()));
            }
        }
        return result;
    }
    private List<WarningDetail> getWarnByTime(String tableName, List<String> ids) {
        List<WarningDetail> result = new ArrayList<>();
        List<SuYuan2d> list = suYuanMapper.getWarningAnalyse(tableName, ids);
        if (null != list && list.size() > 0) {
            Date date = getDateByTabName(tableName);
            for (SuYuan2d s : list) {
                String locationName = commonService.select3dCheckPointById(s.getId()).getName();
                result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 1, s.getValue()));
            }
        }
        return result;
    }
    private Date getDateByTabName(String tab) {
        try {
            return ymdh.parse(tab.replace("su_yuan_", ""));
        } catch (Exception e) {
            return new Date();
        }
    }
}
src/main/java/com/yssh/utils/DateUtils.java
@@ -19,6 +19,8 @@
    public static String YYYY_MM_DD = "yyyy-MM-dd";
    public static String YYYYMM = "yyyyMM";
    public static String YYYYMMDDHH = "yyyyMMddHH";
    
    public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
@@ -79,6 +81,10 @@
        }
    }
    public static String getYyyyMm(Date date) {
        return new SimpleDateFormat(YYYYMM).format(date);
    }
    public static String getYyyyMmDdHh(Date date) {
        return new SimpleDateFormat(YYYYMMDDHH).format(date);
    }