燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-03-22 9e261bfd67ab407abcdebf753d7369cf39f4d7aa
src/main/java/com/yssh/service/EmailService.java
@@ -71,8 +71,13 @@
    @Value("${email.enable}")
    private Boolean enable;
    @Value("${email.debug}")
    private Boolean debug;
    @Resource
    private QxshMapper qxshMapper;
    private static boolean isBusy = false;
    private final static SimpleDateFormat YMDH = new SimpleDateFormat("yyyyMMddHH");
@@ -98,7 +103,7 @@
        });
        // 控制台打印调试信息
        session.setDebug(true);
        session.setDebug(debug);
        return session;
    }
@@ -138,23 +143,49 @@
        }
    }
    public int calcData() {
        List<String> list = new ArrayList<>();
    public Integer calcData() {
        try {
            if (isBusy) {
                return null;
            }
            isBusy = true;
            List<String> list = new ArrayList<>();
            calcCsvData(list);
            calcDbData(list);
            int size = list.size();
            if (size > 0) {
                String text = String.join("、", list.toArray(new String[list.size()])) + ",近" + hours + "小时内存在数据缺失。";
                send(title, text);
            }
            isBusy = false;
            return size;
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
            isBusy = false;
            return null;
        }
    }
    private void calcCsvData(List<String> list) {
        String[] strs = names.split(",");
        int count = countCsv(bigPath, hours);
        if (0 == count) {
            list.add(strs[0] + "近" + hours + "小时存在文件缺失,");
            list.add(strs[0]);
        }
        count = countCsv(filePath, hours);
        if (0 == count) {
            list.add(strs[1] + "近" + hours + "小时存在文件缺失,");
            list.add(strs[1]);
        }
        count = countCsv(vocPath, hours);
        if (0 == count) {
            list.add(strs[2] + "近" + hours + "小时存在文件缺失,");
            list.add(strs[2]);
        }
    }
    private void calcDbData(List<String> list) {
        Calendar calendar = getCalendar(0);
        Integer iEnd = Integer.parseInt(YMDH.format(calendar.getTime()));
        String sEnd = Y_M_D_H.format(calendar.getTime());
@@ -162,34 +193,27 @@
        Integer iStart = Integer.parseInt(YMDH.format(calendar.getTime()));
        String sStart = Y_M_D_H.format(calendar.getTime());
        count = qxshMapper.countGcsjByTime(iStart, iEnd);
        String[] strs = names.split(",");
        int count = qxshMapper.countGcsjByTime(iStart, iEnd);
        if (0 == count) {
            list.add(strs[3] + "近" + hours + "小时存在数据缺失");
            list.add(strs[3]);
        }
        count = qxshMapper.countQxshByTime(iStart, iEnd);
        if (0 == count) {
            list.add(strs[4] + "近" + hours + "小时存在数据缺失");
            list.add(strs[4]);
        }
        count = qxshMapper.countSuYuan46ByTime(sStart, sEnd);
        if (0 == count) {
            list.add(strs[5] + "近" + hours + "小时存在数据缺失");
            list.add(strs[5]);
        }
        count = qxshMapper.countSuYuan70ByTime(sStart, sEnd);
        if (0 == count) {
            list.add(strs[6] + "近" + hours + "小时存在数据缺失");
            list.add(strs[6]);
        }
        count = qxshMapper.countSuYuanFastByTime(sStart, sEnd);
        if (0 == count) {
            list.add(strs[7] + "近" + hours + "小时存在数据缺失");
            list.add(strs[7]);
        }
        int size = list.size();
        if (size > 0) {
            String text = String.join(",", list.toArray(new String[list.size()])) + "。";
            send(title, text);
        }
        return size;
    }
    public int countCsv(String path, Integer hours) {