From 763bcf516c97877a6bfd06e1554b8bef445f72ef Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 22 三月 2024 14:05:37 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/service/EmailService.java | 43 ++++++++++++++++++++++++++++++++----------- 1 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/yssh/service/EmailService.java b/src/main/java/com/yssh/service/EmailService.java index 09a4457..f1fa2c5 100644 --- a/src/main/java/com/yssh/service/EmailService.java +++ b/src/main/java/com/yssh/service/EmailService.java @@ -74,6 +74,8 @@ @Resource private QxshMapper qxshMapper; + private static boolean isBusy = false; + private final static SimpleDateFormat YMDH = new SimpleDateFormat("yyyyMMddHH"); private final static SimpleDateFormat Y_M_D_H = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -138,9 +140,33 @@ } } - 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) { @@ -154,7 +180,9 @@ if (0 == count) { 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,7 +190,8 @@ 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]); } @@ -182,14 +211,6 @@ if (0 == count) { list.add(strs[7]); } - - int size = list.size(); - if (size > 0) { - String text = String.join("銆�", list.toArray(new String[list.size()])) + "锛岃繎" + hours + "灏忔椂鍐呭瓨鍦ㄦ暟鎹己澶便��"; - send(title, text); - } - - return size; } public int countCsv(String path, Integer hours) { -- Gitblit v1.9.3