From 8a53ecd1dbe7d012df51c3cb832a2e65a9f681ba Mon Sep 17 00:00:00 2001 From: nieziyan Date: Sat, 28 Oct 2023 15:19:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9AconcAvg=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/util/ClassUtil.java | 1 + .../src/main/java/org/jeecg/modules/Demo.java | 79 ------------------- .../impl/CalculateConcServiceImpl.java | 17 ++++ .../modules/quartz/job/NucliedAvgJob.java | 5 ++ 4 files changed, 23 insertions(+), 79 deletions(-) delete mode 100644 jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/Demo.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java index d2f5f7a6..f8d4d381 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java @@ -59,6 +59,7 @@ public class ClassUtil { return objsStr; } + @Deprecated public static String classPath(String path){ try { String pathPrefix = "classpath:"; diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/Demo.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/Demo.java deleted file mode 100644 index e18df39f..00000000 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/Demo.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.jeecg.modules; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.sun.mail.imap.IMAPFolder; -import com.sun.mail.imap.IMAPStore; - -import javax.mail.*; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -public class Demo { - - /*public static void main(String[] args) { - String host = "imap.163.com"; - String username = "nzyone@163.com"; - String password = "NHFYZPXSPBKZUXTJ"; - - try { - // 创建连接属性 - Properties props = new Properties(); - props.setProperty("mail.store.protocol", "imap"); - props.put("mail.imap.port", "143"); - // props.put("mail.imap.ssl.enable", "true"); - - Map IAM = new HashMap(); - //带上IMAP ID信息,由key和value组成,例如name,version,vendor,support-email等。 - IAM.put("name","liuyang"); - IAM.put("version","1.0.0"); - IAM.put("vendor","myclient"); - IAM.put("support-email","nzyone@163.com"); - Session session = Session.getInstance(props); - IMAPStore store = (IMAPStore) session.getStore("imap"); - - // 创建会话 - //Session session = Session.getInstance(props); - - // 创建IMAP存储对象并连接到服务器 - //Store store = session.getStore("imap"); - store.connect(host, username, password); - - store.id(IAM); - - Quota[] quotas = store.getQuota("INBOX"); - - // 打开收件箱 - //IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX"); - //inbox.open(Folder.READ_ONLY); - - // 获取邮箱容量信息 - //Quota[] quotas = inbox.getQuota(); - - for (Quota quota : quotas) { - Quota.Resource[] resources = quota.resources; - - for (Quota.Resource res : resources) { - long usage = res.usage; - long limit = res.limit; - - System.out.println("Resource: " + res); - System.out.println("Usage: " + usage); - System.out.println("Limit: " + limit); - } - } - - // 关闭连接 - // inbox.close(false); - store.close(); - } catch (Exception e) { - e.printStackTrace(); - } - }*/ - - public static void main(String[] args) { - double a = 4.148059e+03; - } -} diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/CalculateConcServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/CalculateConcServiceImpl.java index 7df9f770..9c5c9fa5 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/CalculateConcServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/CalculateConcServiceImpl.java @@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.DateConstant; import org.jeecg.common.constant.SymbolConstant; @@ -18,11 +19,13 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @Service +@Slf4j public class CalculateConcServiceImpl implements CalculateConcService { @Autowired @@ -96,9 +99,13 @@ public class CalculateConcServiceImpl implements CalculateConcService { manAvgs.addAll(autoAvgs); String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate; manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo)); + + // 记录日志 + log.info(log(manAvgs)); return nuclideAvgService.saveBatch(manAvgs); }catch (Throwable e){ e.printStackTrace(); + log.error("核素浓度计算过程异常,异常信息为:{}",e.getMessage()); return false; } } @@ -135,4 +142,14 @@ public class CalculateConcServiceImpl implements CalculateConcService { .collect(Collectors.toList()); return concDtos; } + + private String log(List nuclideAvgs){ + List nuclideNames = nuclideAvgs.stream() + .map(AlarmAnalysisNuclideAvg::getNuclide) + .collect(Collectors.toList()); + String nuclide = CollUtil.join(nuclideNames, ","); + String now = LocalDateTime.now() + .format(DateTimeFormatter.ofPattern(DateConstant.DATE_TIME)); + return "核素 [" + nuclide + "] 进行了浓度均值计算, 计算时间: " + now; + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java index 8538977b..53d5fd8e 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java @@ -28,6 +28,7 @@ public class NucliedAvgJob implements Job { try { init(); alarmClient.calculateConc(); + log.info(log()); }catch (Exception e){ e.printStackTrace(); }finally { @@ -45,4 +46,8 @@ public class NucliedAvgJob implements Job { // end:删除临时Token UserTokenContext.remove(); } + + private String log(){ + return "计算核素浓度均值的定时任务成功执行,任务执行类: org.jeecg.modules.quartz.job.NucliedAvgJob"; + } } From f9d780379f62d8c17c3c501adf436e0d3f4de3fe Mon Sep 17 00:00:00 2001 From: nieziyan Date: Sat, 28 Oct 2023 15:23:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=EF=BC=9AconcAvg=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/quartz/job/NucliedAvgJob.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java index 53d5fd8e..6b561cf2 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/NucliedAvgJob.java @@ -2,10 +2,14 @@ package org.jeecg.modules.quartz.job; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.config.mqtoken.UserTokenContext; +import org.jeecg.common.constant.DateConstant; import org.jeecg.common.util.SpringContextUtils; import org.jeecg.modules.feignclient.AbnormalAlarmClient; import org.quartz.*; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + import static org.jeecg.common.util.TokenUtils.getTempToken; /** @@ -48,6 +52,10 @@ public class NucliedAvgJob implements Job { } private String log(){ - return "计算核素浓度均值的定时任务成功执行,任务执行类: org.jeecg.modules.quartz.job.NucliedAvgJob"; + String now = LocalDateTime.now() + .format(DateTimeFormatter.ofPattern(DateConstant.DATE_TIME)); + return "计算核素浓度均值的定时任务成功执行, " + + "任务执行类: org.jeecg.modules.quartz.job.NucliedAvgJob, " + + "任务执行时间: " + now; } }