diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DataTool.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DataTool.java index a4d64593..dd879352 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DataTool.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DataTool.java @@ -1,13 +1,14 @@ package org.jeecg.common.util; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; public class DataTool { private int counter = 1; - private final Map data = new HashMap<>(); + private final Map data = new LinkedHashMap<>(); public DataTool put(Object value) { data.put(String.format("p%d", counter), value); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TemplateUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TemplateUtil.java index f3a902c0..f3fb479b 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TemplateUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TemplateUtil.java @@ -61,7 +61,8 @@ public class TemplateUtil { for (String key : keys) { contents.add(ReUtil.getGroup1(StrUtil.format(pattern, key), templateContent)); } - templateContent = CollUtil.join(contents, "#"); + String join = StrUtil.SPACE + "#" + StrUtil.SPACE; + templateContent = CollUtil.join(contents, join); String content = FreemarkerParseFactory .parseTemplateContent(templateContent, data, true); messageDTO.setContent(content); @@ -102,7 +103,8 @@ public class TemplateUtil { for (String key : keys) { contents.add(ReUtil.getGroup1(StrUtil.format(pattern, key), templateContent)); } - templateContent = CollUtil.join(contents, "#"); + String join = StrUtil.SPACE + "#" + StrUtil.SPACE; + templateContent = CollUtil.join(contents, join); String content = FreemarkerParseFactory .parseTemplateContent(templateContent, data, true); messageDTO.setContent(content); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java index eb58f6d9..bafe618e 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/TokenUtils.java @@ -164,8 +164,8 @@ public class TokenUtils { String secret = CommonConstant.TEMP_TOKEN_SECRET; // 模拟登录生成Token String token = JwtUtil.sign(username, secret); - // 设置Token缓存有效时间为 3 分钟 - redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token, 3 * 60); + // 设置Token缓存有效时间为 60 秒 + redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token, 60); return token; } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/SampNucl.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/SampNucl.java new file mode 100644 index 00000000..afb06760 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/SampNucl.java @@ -0,0 +1,11 @@ +package org.jeecg.modules.base.dto; + +import lombok.Data; + +@Data +public class SampNucl { + + private String sampleId; + + private String nuclideName; +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/Item.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/Item.java index 32214f11..ac3c8279 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/Item.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/Item.java @@ -7,12 +7,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum Item { - EMAIL_CONN("1", "Connection Status"), - TABLESPACE_USAGE("2", "TableSpace Usage"); + EMAIL_CONN("1", "Email Connection Status"), + TABLESPACE_USAGE("2", "TableSpace Usage"), + EMAIL_UNPROCESSED("3", "Email Unprocessed"); - private String value; + private final String value; - private String name; + private final String name; public static Item of(String value){ for (Item item : Item.values()) { diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/SourceType.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/SourceType.java index 10a104b5..49c30bee 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/SourceType.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/SourceType.java @@ -2,6 +2,7 @@ package org.jeecg.modules.base.enums; import cn.hutool.core.util.StrUtil; +import lombok.Getter; /** * 资源类型 @@ -9,22 +10,19 @@ import cn.hutool.core.util.StrUtil; * @author nieziyan * @date 2023-06-30 */ +@Getter public enum SourceType { EMAIL("Email"), DATABASE("Database"), SERVER("Server"); - private String type; + private final String type; SourceType(String type) { this.type = type; } - public String getType() { - return type; - } - public static SourceType typeOf(String type){ for (SourceType sourceType : SourceType.values()) { if (StrUtil.equals(sourceType.getType(),type)) diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/SysEmailLogController.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/SysEmailLogController.java index 56c2fd8d..f9427cea 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/SysEmailLogController.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/SysEmailLogController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; +import java.util.List; import java.util.Map; @RestController @@ -63,8 +64,13 @@ public class SysEmailLogController { @GetMapping("analysis") @ApiOperation("根据日期统计-折线图") public Result analysis(@RequestParam("emailId") String emailId, - @RequestParam("startDate") String startDate, - @RequestParam("endDate") String endDate){ + @RequestParam("startDate") String startDate, + @RequestParam("endDate") String endDate){ return sysEmailLogService.analysis(emailId, startDate, endDate); } + + @GetMapping("getMinus") + public Integer getMinus(@RequestParam("emailId") String emailId){ + return sysEmailLogService.getMinus(emailId); + } } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/feignclient/SystemClient.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/feignclient/SystemClient.java index ccd00db5..312486f8 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/feignclient/SystemClient.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/feignclient/SystemClient.java @@ -43,5 +43,7 @@ public interface SystemClient { @PostMapping("/sys/appMessage/pushMessageToSingle") void pushMessageToSingle(@RequestBody MessageDTO messageDTO, @RequestParam String groupId); - + /* GardsSampleDataController下相关接口 */ + @GetMapping("/gardsSampleData/getDetectorId") + String getDetectorId(@RequestParam String sampleId); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedAutoMapper.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedAutoMapper.java index 38ea7d56..36eb8f3c 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedAutoMapper.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedAutoMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnauto.GardsNuclIded; import java.util.List; @@ -15,5 +16,5 @@ public interface GardsNuclIdedAutoMapper extends BaseMapper { List getConc(Map param); - List nuclideNames(Set nuclideNames); + List sampNucl(String stationId, String detectorId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedManMapper.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedManMapper.java index 44891d11..cfb5c1b6 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedManMapper.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsNuclIdedManMapper.java @@ -3,6 +3,7 @@ package org.jeecg.modules.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.jeecg.modules.base.dto.ConcDto; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnman.GardsNuclIded; import java.util.List; @@ -12,7 +13,7 @@ import java.util.Set; @Mapper public interface GardsNuclIdedManMapper extends BaseMapper { - List getConc(Map param); + List getConc(Map param); - List nuclideNames(Set nuclideNames); + List sampNucl(String stationId, String detectorId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsAutoMapper.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsAutoMapper.java index 4f2107cc..1cc60251 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsAutoMapper.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsAutoMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import java.util.List; @@ -15,5 +16,5 @@ public interface GardsXeResultsAutoMapper extends BaseMapper { List getConc(Map params); - List nuclideNames(Set nuclideNames); + List sampNucl(String stationId, String detectorId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsManMapper.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsManMapper.java index 0fc80607..5b74bb57 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsManMapper.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/GardsXeResultsManMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnman.GardsXeResults; import java.util.List; @@ -15,5 +16,5 @@ public interface GardsXeResultsManMapper extends BaseMapper { List getConc(Map params); - List nuclideNames(Set nuclideNames); + List sampNucl(String stationId, String detectorId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedAutoMapper.xml b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedAutoMapper.xml index 744b8b74..671cf586 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedAutoMapper.xml +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedAutoMapper.xml @@ -23,18 +23,20 @@ - - SELECT - NUCLIDENAME + n.SAMPLE_ID, + n.NUCLIDENAME AS nuclideName FROM - RNAUTO.GARDS_NUCL_IDED - WHERE - NUCLIDENAME IN - - #{nuclideName} + ORIGINAL.GARDS_SAMPLE_DATA s + INNER JOIN RNAUTO.GARDS_NUCL_IDED n ON s.SAMPLE_ID = n.SAMPLE_ID + WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId} + + AND n.NUCLIDENAME IN + + #{item} - GROUP BY - NUCLIDENAME + + AND TO_NUMBER(n.CONCENTRATION) > TO_NUMBER(n.MDC) \ No newline at end of file diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedManMapper.xml b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedManMapper.xml index 4433c6fa..5f408b1f 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedManMapper.xml +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsNuclIdedManMapper.xml @@ -23,18 +23,20 @@ - - SELECT - NUCLIDENAME + n.SAMPLE_ID, + n.NUCLIDENAME AS nuclideName FROM - RNMAN.GARDS_NUCL_IDED - WHERE - NUCLIDENAME IN - - #{nuclideName} + ORIGINAL.GARDS_SAMPLE_DATA s + INNER JOIN RNMAN.GARDS_NUCL_IDED n ON s.SAMPLE_ID = n.SAMPLE_ID + WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId} + + AND n.NUCLIDENAME IN + + #{item} - GROUP BY - NUCLIDENAME + + AND TO_NUMBER(n.CONCENTRATION) > TO_NUMBER(n.MDC) \ No newline at end of file diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsAutoMapper.xml b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsAutoMapper.xml index 6f75f1cb..097238fc 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsAutoMapper.xml +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsAutoMapper.xml @@ -23,18 +23,20 @@ - - SELECT - NUCLIDE_NAME + n.SAMPLE_ID, + n.NUCLIDE_NAME FROM - RNAUTO.GARDS_XE_RESULTS - WHERE - NUCLIDE_NAME IN - - #{nuclideName} - - GROUP BY - NUCLIDE_NAME + ORIGINAL.GARDS_SAMPLE_DATA s + INNER JOIN RNAUTO.GARDS_XE_RESULTS n ON s.SAMPLE_ID = n.SAMPLE_ID + WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId} + + AND n.NUCLIDE_NAME IN + + #{item} + + + AND n.NID_FLAG = 1 \ No newline at end of file diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsManMapper.xml b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsManMapper.xml index 9d36d7dd..b2c107af 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsManMapper.xml +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/GardsXeResultsManMapper.xml @@ -23,18 +23,20 @@ - - SELECT - NUCLIDE_NAME + n.SAMPLE_ID, + n.NUCLIDE_NAME FROM - RNMAN.GARDS_XE_RESULTS - WHERE - NUCLIDE_NAME IN - - #{nuclideName} + ORIGINAL.GARDS_SAMPLE_DATA s + INNER JOIN RNMAN.GARDS_XE_RESULTS n ON s.SAMPLE_ID = n.SAMPLE_ID + WHERE s.STATION_ID = #{stationId} AND s.DETECTOR_ID = #{detectorId} + + AND n.NUCLIDE_NAME IN + + #{item} - GROUP BY - NUCLIDE_NAME + + AND n.NID_FLAG = 1 \ No newline at end of file diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java index 7bf3492c..cd617ed1 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java @@ -5,21 +5,18 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.map.MapUtil; -import cn.hutool.core.text.StrBuilder; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import lombok.Data; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.hwpf.sprm.SprmIterator; import org.jeecg.common.api.dto.message.MessageDTO; import org.jeecg.common.config.mqtoken.UserTokenContext; -import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.constant.enums.SampleType; import org.jeecg.common.util.*; -import org.jeecg.common.util.dynamic.db.FreemarkerParseFactory; import org.jeecg.modules.base.dto.NuclideInfo; import org.jeecg.modules.base.dto.Info; import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog; @@ -40,13 +37,10 @@ import org.springframework.stereotype.Component; import static org.jeecg.common.constant.enums.MessageTypeEnum.*; import static org.jeecg.common.util.TokenUtils.getTempToken; import static org.jeecg.modules.base.enums.Template.ANALYSIS_NUCLIDE; -import static org.jeecg.modules.base.enums.Template.MONITOR_EMAIL; import java.math.BigDecimal; import java.time.LocalDate; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; @Data @@ -156,6 +150,8 @@ public class AnalysisConsumer implements StreamListener conditions = ListUtil.toList(conditionStr.split(COMMA)); List firstDetected = new ArrayList<>(); // 首次发现 List moreThanAvg = new ArrayList<>(); // 超浓度均值 - List meanwhile = new ArrayList<>(); // 同时出现两种及以上核素 + List meanWhile = new ArrayList<>(); // 同时出现两种及以上核素 for (String con : conditions) { Condition condition = Condition.valueOf1(con); if (ObjectUtil.isNull(condition)) continue; switch (condition){ case FIRST_FOUND: // 首次发现该元素 - firstDetected = firstDetected(betaOrGamma, datasource, nuclideNames); + firstDetected = firstDetected(betaOrGamma, datasource, stationId, sampleId, nuclideNames); break; case ABOVE_AVERAGE: // 元素浓度高于均值 moreThanAvg = moreThanAvg(datasource, stationId, collDate, nuclidesCross); break; case MEANWHILE: // 同时出现两种及以上核素 - if (CollUtil.isNotEmpty(nuclideNames) && nuclideNames.size() >= 2) - meanwhile.addAll(nuclideNames); + meanWhile = meanWhile(betaOrGamma, datasource, sampleId, nuclideNames); + if (meanWhile.size() < 2) meanWhile = ListUtil.empty(); break; default: break; @@ -192,10 +188,13 @@ public class AnalysisConsumer implements StreamListener firstDetected(String betaOrGamma, - String dataSourceType, - Set nuclideNames){ - List existNames = analysisResultService - .nuclideNames(betaOrGamma, dataSourceType, nuclideNames); - // 两个集合元素相减 - return CollUtil.subtractToList(nuclideNames, existNames); + private List firstDetected(String betaOrGamma, String dataSourceType, + String stationId, String sampleId, Set nuclideNames){ + /* 查询用户关注的核素是否存在 如果不存在则为首次发现该核素 + 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 + */ + String detectorId = systemClient.getDetectorId(sampleId); + return analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId, + detectorId, sampleId, nuclideNames); } /** @@ -240,8 +240,6 @@ public class AnalysisConsumer implements StreamListener meanWhile(String betaOrGamma, String dataSourceType, + String sampleId, Set nuclideNames){ + /* 查询用户关注的核素中 该谱中是否存在两种及以上核素 + 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 + */ + return analysisResultService.nuclideExist(betaOrGamma, dataSourceType, sampleId, nuclideNames); + } + private void init() { // start 生成临时Token到线程中 UserTokenContext.setToken(getTempToken()); diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/AnalysisResultService.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/AnalysisResultService.java index 475d5504..930777a2 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/AnalysisResultService.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/AnalysisResultService.java @@ -5,7 +5,10 @@ import java.util.Set; public interface AnalysisResultService { - List nuclideNames(String betaOrGamma, - String dataSourceType, - Set nuclideNames); + List nuclideExist(String betaOrGamma, String dataSourceType, + String sampleId, Set nuclideNames); + + List nuclideFirst(String betaOrGamma, String dataSourceType, + String stationId, String detectorId, + String sampleId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedAutoService.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedAutoService.java index 7d950222..f3b61bb0 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedAutoService.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedAutoService.java @@ -2,7 +2,6 @@ package org.jeecg.modules.service; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.base.dto.ConcDto; -import org.jeecg.modules.base.dto.ConcDtoXe; import org.jeecg.modules.base.entity.rnauto.GardsNuclIded; import java.util.List; @@ -13,5 +12,8 @@ public interface IGardsNuclIdedAutoService extends IService { List getConc(Map params); - List nuclideNames(Set nuclideNames); + List nuclideExist(String sampleId, Set nuclideNames); + + List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedManService.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedManService.java index cccde05e..8543ccfc 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedManService.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsNuclIdedManService.java @@ -10,7 +10,10 @@ import java.util.Set; public interface IGardsNuclIdedManService extends IService { - List getConc(Map params); + List getConc(Map params); - List nuclideNames(Set nuclideNames); + List nuclideExist(String sampleId, Set nuclideNames); + + List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsAutoService.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsAutoService.java index e66886e2..c468d3e3 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsAutoService.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsAutoService.java @@ -1,7 +1,6 @@ package org.jeecg.modules.service; import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; import org.jeecg.modules.base.entity.rnauto.GardsXeResults; @@ -13,5 +12,8 @@ public interface IGardsXeResultsAutoService extends IService { List getConc(Map params, Set nuclides); - List nuclideNames(Set nuclideNames); + List nuclideExist(String sampleId, Set nuclideNames); + + List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsManService.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsManService.java index 34997d5d..7eb3032e 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsManService.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/IGardsXeResultsManService.java @@ -1,7 +1,6 @@ package org.jeecg.modules.service; import com.baomidou.mybatisplus.extension.service.IService; -import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; import org.jeecg.modules.base.entity.rnman.GardsXeResults; @@ -13,5 +12,8 @@ public interface IGardsXeResultsManService extends IService { List getConc(Map params, Set nuclides); - List nuclideNames(Set nuclideNames); + List nuclideExist(String sampleId, Set nuclideNames); + + List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/ISysEmailLogService.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/ISysEmailLogService.java index aec848c3..f23491fe 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/ISysEmailLogService.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/ISysEmailLogService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.base.entity.postgre.SysEmailLog; +import java.util.List; import java.util.Map; public interface ISysEmailLogService extends IService { @@ -16,4 +17,6 @@ public interface ISysEmailLogService extends IService { Result todayMin(String emailId); Result analysis(String emailId, String startDate, String endDate); + + Integer getMinus(String emailId); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AnalysisResultServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AnalysisResultServiceImpl.java index 06cb4679..f1453a0c 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AnalysisResultServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AnalysisResultServiceImpl.java @@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.ListUtil; import org.jeecg.common.constant.CommonConstant; +import org.jeecg.modules.feignclient.SystemClient; import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,25 +27,51 @@ public class AnalysisResultServiceImpl implements AnalysisResultService { @Override - public List nuclideNames(String betaOrGamma, String dataSourceType, Set nuclideNames) { + public List nuclideExist(String betaOrGamma, String dataSourceType, + String sampleId, Set nuclideNames) { if (CommonConstant.ARMDARR.equals(dataSourceType)){ if (CommonConstant.BETA.equals(betaOrGamma)){ - return xeResultsAutoService.nuclideNames(nuclideNames); + return xeResultsAutoService.nuclideExist(sampleId, nuclideNames); }else if (CommonConstant.GAMMA.equals(betaOrGamma)){ - return nuclIdedAutoService.nuclideNames(nuclideNames); + return nuclIdedAutoService.nuclideExist(sampleId, nuclideNames); }else { - return ListUtil.toList(nuclideNames); + return ListUtil.empty(); } } else if (CommonConstant.ARMDRRR.equals(dataSourceType)) { if (CommonConstant.BETA.equals(betaOrGamma)){ - return xeResultsManService.nuclideNames(nuclideNames); + return xeResultsManService.nuclideExist(sampleId, nuclideNames); }else if (CommonConstant.GAMMA.equals(betaOrGamma)){ - return nuclIdedManService.nuclideNames(nuclideNames); + return nuclIdedManService.nuclideExist(sampleId, nuclideNames); }else { - return ListUtil.toList(nuclideNames); + return ListUtil.empty(); } }else { - return ListUtil.toList(nuclideNames); + return ListUtil.empty(); + } + } + + @Override + public List nuclideFirst(String betaOrGamma, String dataSourceType, + String stationId, String detectorId, + String sampleId, Set nuclideNames) { + if (CommonConstant.ARMDARR.equals(dataSourceType)){ + if (CommonConstant.BETA.equals(betaOrGamma)){ + return xeResultsAutoService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames); + }else if (CommonConstant.GAMMA.equals(betaOrGamma)){ + return nuclIdedAutoService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames); + }else { + return ListUtil.empty(); + } + } else if (CommonConstant.ARMDRRR.equals(dataSourceType)) { + if (CommonConstant.BETA.equals(betaOrGamma)){ + return xeResultsManService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames); + }else if (CommonConstant.GAMMA.equals(betaOrGamma)){ + return nuclIdedManService.nuclideFirst(stationId, detectorId, sampleId, nuclideNames); + }else { + return ListUtil.empty(); + } + }else { + return ListUtil.empty(); } } } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedAutoServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedAutoServiceImpl.java index b2b0b706..45118424 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedAutoServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedAutoServiceImpl.java @@ -1,10 +1,15 @@ package org.jeecg.modules.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.jeecg.common.constant.DateConstant; import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnauto.GardsNuclIded; import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import org.jeecg.modules.mapper.GardsNuclIdedAutoMapper; @@ -13,6 +18,7 @@ import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.List; @@ -30,7 +36,34 @@ public class GardsNuclIdedAutoServiceImpl extends ServiceImpl nuclideNames(Set nuclideNames) { - return baseMapper.nuclideNames(nuclideNames); + public List nuclideExist(String sampleId, Set nuclideNames) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsNuclIded::getSampleId, sampleId); + wrapper.in(GardsNuclIded::getNuclideName, nuclideNames); + List nuclIdeds = this.list(wrapper); + // 判断核素是否存在的条件: 该核素Conc值是否大于MDC值 + Set existNuclides = nuclIdeds.stream() + .filter(item -> NumberUtil.isNumber(item.getConcentration())) + .filter(item -> NumberUtil.isNumber(item.getMdc())) + .filter(item -> NumberUtil.isGreater(new BigDecimal(item.getConcentration()), new BigDecimal(item.getMdc()))) + .map(GardsNuclIded::getNuclideName) + .collect(Collectors.toSet()); + return ListUtil.toList(existNuclides); + } + + @Override + public List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames) { + List sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames); + // 获取除了当前谱的所有存在的核素 + Set notCurrent = sampNucls.stream() + .filter(item -> !StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 获取当前谱的所有存在的核素 + Set current = sampNucls.stream() + .filter(item -> StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素 + return CollUtil.subtractToList(current, notCurrent); } } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedManServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedManServiceImpl.java index fdcd2a2c..69150fd2 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedManServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsNuclIdedManServiceImpl.java @@ -1,16 +1,21 @@ package org.jeecg.modules.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.constant.DateConstant; import org.jeecg.modules.base.dto.ConcDto; -import org.jeecg.modules.base.entity.rnauto.GardsXeResults; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnman.GardsNuclIded; import org.jeecg.modules.mapper.GardsNuclIdedManMapper; import org.jeecg.modules.service.IGardsNuclIdedManService; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.List; @@ -28,7 +33,34 @@ public class GardsNuclIdedManServiceImpl extends ServiceImpl nuclideNames(Set nuclideNames) { - return baseMapper.nuclideNames(nuclideNames); + public List nuclideExist(String sampleId, Set nuclideNames) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsNuclIded::getSampleId, sampleId); + wrapper.in(GardsNuclIded::getNuclideName, nuclideNames); + List nuclIdeds = this.list(wrapper); + // 判断核素是否存在的条件: 该核素Conc值是否大于MDC值 + Set existNuclides = nuclIdeds.stream() + .filter(item -> NumberUtil.isNumber(item.getConcentration())) + .filter(item -> NumberUtil.isNumber(item.getMdc())) + .filter(item -> NumberUtil.isGreater(new BigDecimal(item.getConcentration()), new BigDecimal(item.getMdc()))) + .map(GardsNuclIded::getNuclideName) + .collect(Collectors.toSet()); + return ListUtil.toList(existNuclides); + } + + @Override + public List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames) { + List sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames); + // 获取除了当前谱的所有存在的核素 + Set notCurrent = sampNucls.stream() + .filter(item -> !StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 获取当前谱的所有存在的核素 + Set current = sampNucls.stream() + .filter(item -> StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素 + return CollUtil.subtractToList(current, notCurrent); } } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsAutoServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsAutoServiceImpl.java index ec1b8314..d538c25f 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsAutoServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsAutoServiceImpl.java @@ -2,12 +2,14 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.jeecg.common.constant.DateConstant; import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnauto.GardsXeResults; import org.jeecg.modules.mapper.GardsXeResultsAutoMapper; import org.jeecg.modules.service.IGardsXeResultsAutoService; @@ -51,7 +53,33 @@ public class GardsXeResultsAutoServiceImpl extends ServiceImpl nuclideNames(Set nuclideNames) { - return baseMapper.nuclideNames(nuclideNames); + public List nuclideExist(String sampleId, Set nuclideNames) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsXeResults::getSampleId, sampleId); + wrapper.in(GardsXeResults::getNuclideName, nuclideNames); + List xeResults = this.list(wrapper); + // 判断核素是否存在的条件: 该核素NidFlag值是否为1 + Set existNuclides = xeResults.stream() + .filter(item -> ObjectUtil.isNotNull(item.getNidFlag())) + .filter(item -> item.getNidFlag() == 1) + .map(GardsXeResults::getNuclideName) + .collect(Collectors.toSet()); + return ListUtil.toList(existNuclides); + } + + @Override + public List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames) { + List sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames); + // 获取除了当前谱的所有存在的核素 + Set notCurrent = sampNucls.stream() + .filter(item -> !StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 获取当前谱的所有存在的核素 + Set current = sampNucls.stream() + .filter(item -> StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素 + return CollUtil.subtractToList(current, notCurrent); } } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsManServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsManServiceImpl.java index 6406d07b..6a02bcee 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsManServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/GardsXeResultsManServiceImpl.java @@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -9,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.constant.DateConstant; import org.jeecg.modules.base.dto.ConcDto; import org.jeecg.modules.base.dto.ConcDtoXe; +import org.jeecg.modules.base.dto.SampNucl; import org.jeecg.modules.base.entity.rnman.GardsXeResults; import org.jeecg.modules.mapper.GardsXeResultsManMapper; import org.jeecg.modules.service.IGardsXeResultsManService; @@ -51,7 +53,33 @@ public class GardsXeResultsManServiceImpl extends ServiceImpl nuclideNames(Set nuclideNames) { - return baseMapper.nuclideNames(nuclideNames); + public List nuclideExist(String sampleId, Set nuclideNames) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsXeResults::getSampleId, sampleId); + wrapper.in(GardsXeResults::getNuclideName, nuclideNames); + List xeResults = this.list(wrapper); + // 判断核素是否存在的条件: 该核素NidFlag值是否为1 + Set existNuclides = xeResults.stream() + .filter(item -> ObjectUtil.isNotNull(item.getNidFlag())) + .filter(item -> item.getNidFlag() == 1) + .map(GardsXeResults::getNuclideName) + .collect(Collectors.toSet()); + return ListUtil.toList(existNuclides); + } + + @Override + public List nuclideFirst(String stationId, String detectorId, + String sampleId, Set nuclideNames) { + List sampNucls = this.baseMapper.sampNucl(stationId, detectorId, nuclideNames); + // 获取除了当前谱的所有存在的核素 + Set notCurrent = sampNucls.stream() + .filter(item -> !StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 获取当前谱的所有存在的核素 + Set current = sampNucls.stream() + .filter(item -> StrUtil.equals(item.getSampleId(), sampleId)) + .map(SampNucl::getNuclideName).collect(Collectors.toSet()); + // 两集合相减即为当前谱中的首次在当前台站当前探测器中出现的核素 + return CollUtil.subtractToList(current, notCurrent); } } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java index 3649d851..ef71e437 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysEmailLogServiceImpl.java @@ -1,6 +1,9 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; @@ -227,4 +230,20 @@ public class SysEmailLogServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SysEmailLog::getEmailId, emailId); + wrapper.orderByDesc(SysEmailLog::getCreateTime); + wrapper.last("limit 1"); + SysEmailLog emailLog = getOne(wrapper, false); + if (ObjectUtil.isNull(emailLog)) + return -1; + Date createTime = emailLog.getCreateTime(); + if (ObjectUtil.isNull(createTime)) + return -1; + // 获取最新一条数据和当前时间所间隔的分钟数 + return Math.toIntExact(DateUtil.between(createTime, new Date(), DateUnit.MINUTE)); + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 8b997d75..602eb352 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.cache.Cache; import com.google.common.collect.Maps; -import io.swagger.models.auth.In; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.shiro.SecurityUtils; @@ -44,7 +43,6 @@ import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.thymeleaf.TemplateEngine; @@ -301,7 +299,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements Result result = new Result(); List> resultList = new LinkedList<>(); String userName = JwtUtil.getUserNameByToken(request); - String filePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName; + String filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName; String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.PHD"; Pattern regexPattern = Pattern.compile(sampleRx); String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD"; @@ -482,9 +480,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements betaDataFile.setSampleId(String.valueOf(sampleId)); //判断sample信息是否存在 if (Objects.nonNull(sample)) { - betaDataFile.setSampleFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath()); + betaDataFile.setSampleFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath()); betaDataFile.setSampleFileName(sampleFileName); - sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName()); + sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma"); if (Objects.nonNull(sampleTmp)) { //sample临时文件路径存储 betaDataFile.setSampleTmpPath(sampleTmp.getAbsolutePath()); @@ -519,9 +517,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //判断gas信息是否存在 if (Objects.nonNull(gasBg)) { - betaDataFile.setGasFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath()); + betaDataFile.setGasFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath()); betaDataFile.setGasFileName(gasFileName); - gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName()); + gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma"); if (Objects.nonNull(gasTmp)) { //存储gas临时文件路径 betaDataFile.setGasTmpPath(gasTmp.getAbsolutePath()); @@ -556,9 +554,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //判断det信息是否存在 if (Objects.nonNull(detBg)) { - betaDataFile.setDetFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath()); + betaDataFile.setDetFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getDetBgFilePath()); betaDataFile.setDetFileName(detFileName); - detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName()); + detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma"); if (Objects.nonNull(detTmp)) { //存储det临时文件路径 betaDataFile.setDetTmpPath(detTmp.getAbsolutePath()); @@ -593,9 +591,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //判断qc信息是否存在 if (Objects.nonNull(qc)) { - betaDataFile.setQcFilePathName(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath); + betaDataFile.setQcFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbQcFilePath); betaDataFile.setQcFileName(qcFileName); - qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName()); + qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma"); if (Objects.nonNull(qcTmp)) { betaDataFile.setQcTmpPath(qcTmp.getAbsolutePath()); EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(qcTmp.getAbsolutePath()); @@ -673,7 +671,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements //获取用户名 String userName = JwtUtil.getUserNameByToken(request); //上传文件路径 - String path = spectrumPathProperties.getRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; Map resultMap = new HashMap<>(); Map sampleMap = new HashMap<>(); Map gasBgMap = new HashMap<>(); @@ -785,7 +783,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements File file = null; try { //根据完整的文件路径 获取临时文件 - file = ftpUtil.downloadFile(filePathName); + file = ftpUtil.downloadFile(filePathName, "betaGamma"); if (Objects.nonNull(file)) { if (type.equalsIgnoreCase("sample")) { betaDataFile.setSampleTmpPath(file.getAbsolutePath()); @@ -882,6 +880,26 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements String betaKey = sampleFileName + "-" + userName; Cache cache = betaCache.getBetaCache(); BetaDataFile betaDataFile = cache.getIfPresent(betaKey); + String sampleTmpPath = betaDataFile.getSampleTmpPath(); + if (StringUtils.isNotBlank(sampleTmpPath)) { + File file = new File(sampleTmpPath); + file.delete(); + } + String gasTmpPath = betaDataFile.getGasTmpPath(); + if (StringUtils.isNotBlank(gasTmpPath)) { + File file = new File(gasTmpPath); + file.delete(); + } + String detTmpPath = betaDataFile.getDetTmpPath(); + if (StringUtils.isNotBlank(detTmpPath)) { + File file = new File(detTmpPath); + file.delete(); + } + String qcTmpPath = betaDataFile.getQcTmpPath(); + if (StringUtils.isNotBlank(qcTmpPath)) { + File file = new File(qcTmpPath); + file.delete(); + } betaCache.deleteBetaCache(betaKey); } @@ -930,7 +948,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements InputStream inputStream = null; ServletOutputStream outputStream = null; try { - inputStream = ftpUtil.downloadFileStream(spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt"); + inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt"); if (Objects.nonNull(inputStream)){ outputStream = response.getOutputStream(); byte[] buffer = new byte[1024]; @@ -4005,7 +4023,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements InputStream inputStream = null; ServletOutputStream outputStream = null; try { - inputStream = ftpUtil.downloadFileStream(spectrumPathProperties.getRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath); + inputStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath); if (Objects.nonNull(inputStream)){ outputStream = response.getOutputStream(); byte[] buffer = new byte[1024]; @@ -4284,68 +4302,55 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements } //上传本次文件到ftp人工交互存储路径下 try { - if (StringUtils.isNotBlank(sampleFilePathName)) { - //sample文件的saveFile存储路径 - String saveSamplePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName; - if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath()) && !saveSamplePath.equals(betaDataFile.getSampleTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) { - File sampleTmp = new File(betaDataFile.getSampleTmpPath()); - ftpUtil.saveFile(saveSamplePath, new FileInputStream(sampleTmp)); - } + if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) { + File sampleTmp = new File(betaDataFile.getSampleTmpPath()); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp)); } - if (StringUtils.isNotBlank(gasFilePathName)) { - //gas文件的saveFile存储路径 - String saveGasPath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName; - if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath()) && !saveGasPath.equals(betaDataFile.getGasTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) { - File gasTmp = new File(betaDataFile.getGasTmpPath()); - ftpUtil.saveFile(saveGasPath, new FileInputStream(gasTmp)); - } + if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) { + File gasTmp = new File(betaDataFile.getGasTmpPath()); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp)); } - if (StringUtils.isNotBlank(detFilePathName)) { - //det文件的saveFile存储路径 - String saveDetPath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName; - if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath()) && !saveDetPath.equals(betaDataFile.getDetTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) { - File detTmp = new File(betaDataFile.getDetTmpPath()); - ftpUtil.saveFile(saveDetPath, new FileInputStream(detTmp)); - } + if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) { + File detTmp = new File(betaDataFile.getDetTmpPath()); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp)); } - if (StringUtils.isNotBlank(qcFilePathName)) { - //qc文件的saveFile存储路径 - String saveQcPath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName; - if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath()) && !saveQcPath.equals(betaDataFile.getQcTmpPath().replace(StringPool.BACK_SLASH, StringPool.SLASH))) { - File qcTmp = new File(betaDataFile.getQcTmpPath()); - ftpUtil.saveFile(saveQcPath, new FileInputStream(qcTmp)); - } + if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) { + File qcTmp = new File(betaDataFile.getQcTmpPath()); + ftpUtil.saveFile(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp)); } //分析成功后存储日志文件和报告文件 { - String logFileName = betaDataFile.getSampleFileName().replace("PHD", "log"); + String logPathName = analyses_absolute_LogPath.substring(0, analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)); + String logFileName = analyses_absolute_LogPath.substring(analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1); //获取日志的文件存放路径 String logFilePath = parameterProperties.getLogFilePath() + File.separator + DateUtils.formatDate(new Date(), "yyyy-MM-dd"); + String localLogName = betaDataFile.getSampleFileName().replace("PHD", "log"); //判断文件路径是否存在 File logPath = new File(logFilePath); if (!logPath.exists()) { logPath.mkdirs(); } - File logFile = new File(logFilePath + File.separator +logFileName); + File logFile = new File(logFilePath + File.separator +localLogName); try { //判断日志文件是否存在 如果不存在创建一个空的文件 上传到ftp if (!logFile.exists()) { FileUtil.writeString("", logFile, "UTF-8"); } FileInputStream in = new FileInputStream(logFile); - ftpUtil.saveFile(spectrumPathProperties.getRootPath()+analyses_absolute_LogPath, in); + ftpUtil.saveFile(logPathName, logFileName, in); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } { String rptContent = phdFileUtil.OutPutRnRpt(betaDataFile); + String rptPathName = analyses_absolute_ReportPath.substring(0, analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)); String rptFileName = analyses_absolute_ReportPath.substring(analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1)+".txt"; File rptFile = new File(rptFileName); try { FileUtil.writeString(rptContent, rptFile, "UTF-8"); FileInputStream in = new FileInputStream(rptFile); - ftpUtil.saveFile(spectrumPathProperties.getRootPath()+analyses_absolute_ReportPath+".txt", in); + ftpUtil.saveFile(rptPathName, rptFileName, in); } catch (FileNotFoundException e) { throw new RuntimeException(e); } finally { @@ -4420,7 +4425,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements String error = "get station_id or detect_id error"; return false; } - betaDataFile.setDetectorId(detectorId.toString()); //新增Gards_Sample_Data表数据 sampleDataSpectrumService.saveSampleData(sourceData, stationId, detectorId, filePathName, readLines); //获取sampleId diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/feignclient/AbnormalAlarmClient.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/feignclient/AbnormalAlarmClient.java index 8f8e5e73..4ae04ee8 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/feignclient/AbnormalAlarmClient.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/feignclient/AbnormalAlarmClient.java @@ -43,4 +43,8 @@ public interface AbnormalAlarmClient { /* SysServerController下相关接口 */ @GetMapping("/sysServer/getNameById") String getServerName(@RequestParam String id); + + /* SysEmailLogController下相关接口 */ + @GetMapping("/sysEmailLog/getMinus") + Integer getMinus(@RequestParam String emailId); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/DatabaseJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/DatabaseJob.java index 5f76098c..573b63f5 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/DatabaseJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/DatabaseJob.java @@ -105,31 +105,30 @@ public class DatabaseJob extends Monitor { String op = rule.getOperator(); Double threshold = rule.getThreshold(); boolean needWarn = NumUtil.compare(current, threshold, op); - if (needWarn){ - // 记录报警日志 - AlarmLog alarmLog = new AlarmLog(); - alarmLog.setRuleId(ruleId); - alarmLog.setOperator(operator); - alarmLog.setAlarmValue(StrUtil.toString(current)); + if (!needWarn) continue; + // 记录报警日志 + AlarmLog alarmLog = new AlarmLog(); + alarmLog.setRuleId(ruleId); + alarmLog.setOperator(operator); + alarmLog.setAlarmValue(StrUtil.toString(current)); - String ruleName = alarmRule.getName(); - Map data = DataTool.getInstance(). - put(databaseName).put(ruleName).put(rule.joint()).put(current).get(); - MessageDTO messageDTO = TemplateUtil.parse(MONITOR_DATABASE.getCode(), data); + String ruleName = alarmRule.getName(); + Map data = DataTool.getInstance(). + put(databaseName).put(ruleName).put(rule.joint()).put(current).get(); + MessageDTO messageDTO = TemplateUtil.parse(MONITOR_DATABASE.getCode(), data); - alarmLog.setAlarmInfo(messageDTO.getContent()); - getAlarmClient().create(alarmLog); - // 规则触发报警后,设置该规则的沉默周期(如果有) - // 沉默周期失效之前,该规则不会再次被触发 - Long silenceCycle = alarmRule.getSilenceCycle(); - ruleSilence(silenceKey, silenceCycle); + alarmLog.setAlarmInfo(messageDTO.getContent()); + getAlarmClient().create(alarmLog); + // 规则触发报警后,设置该规则的沉默周期(如果有) + // 沉默周期失效之前,该规则不会再次被触发 + Long silenceCycle = alarmRule.getSilenceCycle(); + ruleSilence(silenceKey, silenceCycle); - // 发送报警信息 - String groupId = alarmRule.getContactId(); - String notific = alarmRule.getNotification(); - getSendMessage().send(messageDTO, groupId, notific); - getPushAppUtil().pushToSingle(messageDTO, groupId); - } + // 发送报警信息 + String groupId = alarmRule.getContactId(); + String notific = alarmRule.getNotification(); + getSendMessage().send(messageDTO, groupId, notific); + getPushAppUtil().pushToSingle(messageDTO, groupId); }catch (FeignException.Unauthorized e){ ManageUtil.refreshToken(); log.warn("向运管系统查询ItemHistory信息异常: Token失效,已刷新Token"); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/EmailJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/EmailJob.java index ef51c991..49db39aa 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/EmailJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/EmailJob.java @@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.dto.message.MessageDTO; import org.jeecg.common.constant.RedisConstant; @@ -18,13 +17,11 @@ import org.jeecg.modules.base.entity.postgre.AlarmLog; import org.jeecg.modules.base.entity.postgre.AlarmRule; import org.jeecg.modules.base.enums.Item; import org.jeecg.modules.quartz.entity.Monitor; -import org.quartz.*; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.Map; import java.util.Set; -import java.util.concurrent.TimeUnit; import static org.jeecg.modules.base.enums.SourceType.EMAIL; import static org.jeecg.modules.base.enums.Template.MONITOR_EMAIL; @@ -32,6 +29,7 @@ import static org.jeecg.modules.base.enums.Template.MONITOR_EMAIL; @Slf4j @Component public class EmailJob extends Monitor{ + /** * 解析Email预警规则 **/ @@ -69,8 +67,11 @@ public class EmailJob extends Monitor{ if (ObjectUtil.isNull(item)) continue; Number current = null; switch (item){ - case EMAIL_CONN: // 监控项-1: 测试邮箱服务是否可以连接成功 - current = isConnection(sourceId); + case EMAIL_CONN: // 监控项id 1: 测试邮箱服务是否可以连接成功 + current = connectionStatus(sourceId); + break; + case EMAIL_UNPROCESSED: // 监控项id 3: 邮箱邮件是否被自动处理程序处理 + current = unProcess(sourceId); break; // 追加的监控项... default: @@ -82,31 +83,30 @@ public class EmailJob extends Monitor{ String op = rule.getOperator(); Double threshold = rule.getThreshold(); boolean needWarn = NumUtil.compare(current, threshold, op); - if (needWarn){ - // 记录报警日志 - AlarmLog alarmLog = new AlarmLog(); - alarmLog.setRuleId(ruleId); - alarmLog.setOperator(operator); - alarmLog.setAlarmValue(StrUtil.toString(current)); + if (!needWarn) continue; + // 记录报警日志 + AlarmLog alarmLog = new AlarmLog(); + alarmLog.setRuleId(ruleId); + alarmLog.setOperator(operator); + alarmLog.setAlarmValue(StrUtil.toString(current)); - String ruleName = alarmRule.getName(); - Map data = DataTool.getInstance(). - put(emailName).put(ruleName).put(rule.joint()).put(current).get(); - MessageDTO messageDTO = TemplateUtil.parse(MONITOR_EMAIL.getCode(), data); + String ruleName = alarmRule.getName(); + Map data = DataTool.getInstance(). + put(emailName).put(ruleName).put(rule.joint()).put(current).get(); + MessageDTO messageDTO = TemplateUtil.parse(MONITOR_EMAIL.getCode(), data); - alarmLog.setAlarmInfo(messageDTO.getContent()); - getAlarmClient().create(alarmLog); - // 规则触发报警后,设置该规则的沉默周期(如果有) - // 沉默周期失效之前,该规则不会再次被触发 - Long silenceCycle = alarmRule.getSilenceCycle(); - ruleSilence(silenceKey, silenceCycle); + alarmLog.setAlarmInfo(messageDTO.getContent()); + getAlarmClient().create(alarmLog); + // 规则触发报警后,设置该规则的沉默周期(如果有) + // 沉默周期失效之前,该规则不会再次被触发 + Long silenceCycle = alarmRule.getSilenceCycle(); + ruleSilence(silenceKey, silenceCycle); - // 发送报警信息 - String groupId = alarmRule.getContactId(); - String notific = alarmRule.getNotification(); - getSendMessage().send(messageDTO, groupId, notific); - getPushAppUtil().pushToSingle(messageDTO, groupId); - } + // 发送报警信息 + String groupId = alarmRule.getContactId(); + String notific = alarmRule.getNotification(); + getSendMessage().send(messageDTO, groupId, notific); + getPushAppUtil().pushToSingle(messageDTO, groupId); } catch (JsonProcessingException e) { log.error("Email预警规则: {}解析失败,失败原因: {}", operator, e.getMessage()); }catch (Exception e){ @@ -117,9 +117,9 @@ public class EmailJob extends Monitor{ } /* - * 监控项-1: 测试邮箱服务是否可以连接成功 (0:失败 1:成功) + * 监控项id: 1 测试邮箱服务是否可以连接成功 (预警值: 0 非0值则不需要报警) * */ - private Integer isConnection(String emailId){ + private Integer connectionStatus(String emailId){ int res = 1; String statusKey = RedisConstant.EMAIL_STATUS; NameValue nameValue = (NameValue)getRedisUtil().hget(statusKey, emailId); @@ -127,4 +127,11 @@ public class EmailJob extends Monitor{ res = 0; return res; } + + /* + * 监控项id: 3 邮箱邮件在一定时间内是否被自动处理程序处理 + * */ + private Integer unProcess(String emailId){ + return getAlarmClient().getMinus(emailId); + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/ServerJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/ServerJob.java index 42182ba7..a8069b36 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/ServerJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/ServerJob.java @@ -102,31 +102,30 @@ public class ServerJob extends Monitor{ String op = rule.getOperator(); Double threshold = rule.getThreshold(); boolean needWarn = NumUtil.compare(current, threshold, op); - if (needWarn){ - // 记录报警日志 - AlarmLog alarmLog = new AlarmLog(); - alarmLog.setRuleId(ruleId); - alarmLog.setOperator(operator); - alarmLog.setAlarmValue(StrUtil.toString(current)); + if (!needWarn) continue; + // 记录报警日志 + AlarmLog alarmLog = new AlarmLog(); + alarmLog.setRuleId(ruleId); + alarmLog.setOperator(operator); + alarmLog.setAlarmValue(StrUtil.toString(current)); - String ruleName = alarmRule.getName(); - Map data = DataTool.getInstance(). - put(serverName).put(ruleName).put(rule.joint()).put(current).get(); - MessageDTO messageDTO = TemplateUtil.parse(MONITOR_SERVER.getCode(), data); + String ruleName = alarmRule.getName(); + Map data = DataTool.getInstance(). + put(serverName).put(ruleName).put(rule.joint()).put(current).get(); + MessageDTO messageDTO = TemplateUtil.parse(MONITOR_SERVER.getCode(), data); - alarmLog.setAlarmInfo(messageDTO.getContent()); - getAlarmClient().create(alarmLog); - // 规则触发报警后,设置该规则的沉默周期(如果有) - // 沉默周期失效之前,该规则不会再次被触发 - Long silenceCycle = alarmRule.getSilenceCycle(); - ruleSilence(silenceKey, silenceCycle); + alarmLog.setAlarmInfo(messageDTO.getContent()); + getAlarmClient().create(alarmLog); + // 规则触发报警后,设置该规则的沉默周期(如果有) + // 沉默周期失效之前,该规则不会再次被触发 + Long silenceCycle = alarmRule.getSilenceCycle(); + ruleSilence(silenceKey, silenceCycle); - // 发送报警信息 - String groupId = alarmRule.getContactId(); - String notific = alarmRule.getNotification(); - getSendMessage().send(messageDTO, groupId, notific); - getPushAppUtil().pushToSingle(messageDTO, groupId); - } + // 发送报警信息 + String groupId = alarmRule.getContactId(); + String notific = alarmRule.getNotification(); + getSendMessage().send(messageDTO, groupId, notific); + getPushAppUtil().pushToSingle(messageDTO, groupId); } catch (FeignException.Unauthorized e){ ManageUtil.refreshToken(); log.warn("向运管系统查询ItemHistory信息异常: Token失效,已刷新Token"); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/TableSpaceJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/TableSpaceJob.java index 9705aceb..fc652610 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/TableSpaceJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/jobs/TableSpaceJob.java @@ -95,31 +95,30 @@ public class TableSpaceJob extends Monitor { } // 如果当前值超过阈值 则需要发送报警信息 - if (needWarn){ - // 记录报警日志 - AlarmLog alarmLog = new AlarmLog(); - alarmLog.setRuleId(ruleId); - alarmLog.setOperator(operator); - alarmLog.setAlarmValue(value(spaceMap, result)); + if (!needWarn) continue; + // 记录报警日志 + AlarmLog alarmLog = new AlarmLog(); + alarmLog.setRuleId(ruleId); + alarmLog.setOperator(operator); + alarmLog.setAlarmValue(value(spaceMap, result)); - String ruleName = alarmRule.getName(); - Map data = DataTool.getInstance(). - put(databaseName).put(ruleName).put(rule.joint()).put(info(spaceMap, result)).get(); - MessageDTO messageDTO = TemplateUtil.parse(MONITOR_DATABASE.getCode(), data); + String ruleName = alarmRule.getName(); + Map data = DataTool.getInstance(). + put(databaseName).put(ruleName).put(rule.joint()).put(info(spaceMap, result)).get(); + MessageDTO messageDTO = TemplateUtil.parse(MONITOR_DATABASE.getCode(), data); - alarmLog.setAlarmInfo(messageDTO.getContent()); - getAlarmClient().create(alarmLog); - // 规则触发报警后,设置该规则的沉默周期(如果有) - // 沉默周期失效之前,该规则不会再次被触发 - Long silenceCycle = alarmRule.getSilenceCycle(); - ruleSilence(silenceKey, silenceCycle); + alarmLog.setAlarmInfo(messageDTO.getContent()); + getAlarmClient().create(alarmLog); + // 规则触发报警后,设置该规则的沉默周期(如果有) + // 沉默周期失效之前,该规则不会再次被触发 + Long silenceCycle = alarmRule.getSilenceCycle(); + ruleSilence(silenceKey, silenceCycle); - // 发送报警信息 - String groupId = alarmRule.getContactId(); - String notific = alarmRule.getNotification(); - getSendMessage().send(messageDTO, groupId, notific); - getPushAppUtil().pushToSingle(messageDTO, groupId); - } + // 发送报警信息 + String groupId = alarmRule.getContactId(); + String notific = alarmRule.getNotification(); + getSendMessage().send(messageDTO, groupId, notific); + getPushAppUtil().pushToSingle(messageDTO, groupId); } catch (JsonProcessingException e) { log.error("Database-TableSpace预警规则: {}解析失败,失败原因: {}", operator, e.getMessage()); }catch (Exception e){ diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/GardsSampleDataController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/GardsSampleDataController.java index ddfa3bb0..789806b5 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/GardsSampleDataController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/GardsSampleDataController.java @@ -19,7 +19,7 @@ import java.util.Map; public class GardsSampleDataController { @Autowired - private IGardsSampleDataService gardsSampleDataService; + private IGardsSampleDataService sampleDataService; @Autowired private RedisUtil redisUtil; @@ -28,7 +28,7 @@ public class GardsSampleDataController { public Result> findPage(QueryRequest queryRequest, GardsSampleDataSystem gardsSampleData, boolean collectStopCheck, boolean acqDotStartCheck){ - return gardsSampleDataService.findPage(queryRequest, gardsSampleData, collectStopCheck, acqDotStartCheck); + return sampleDataService.findPage(queryRequest, gardsSampleData, collectStopCheck, acqDotStartCheck); } @GetMapping("findStations") @@ -49,7 +49,11 @@ public class GardsSampleDataController { @ApiOperation(value = "删除DATA_BASE数据", notes = "删除DATA_BASE数据") public Result deleteById(@RequestParam Integer sampleId, boolean sampleData, boolean rnAuto, boolean rnMan){ - return gardsSampleDataService.deleteById(sampleId, sampleData, rnAuto, rnMan); + return sampleDataService.deleteById(sampleId, sampleData, rnAuto, rnMan); } + @GetMapping("getDetectorId") + public String getDetectorId(@RequestParam String sampleId){ + return sampleDataService.getDetectorId(sampleId); + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsSampleDataService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsSampleDataService.java index 61fd98f8..48d335f6 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsSampleDataService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsSampleDataService.java @@ -31,4 +31,6 @@ public interface IGardsSampleDataService extends IService GardsSampleDataSystem getOne(Integer sampleId); void delTables(List tableNames, Integer sampleId); + + String getDetectorId(String sampleId); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java index 71e490fc..0f983736 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsSampleDataServiceImpl.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.toolkit.SqlRunner; @@ -25,6 +26,7 @@ import org.jeecg.common.util.FTPUtil; import org.jeecg.common.util.RedisUtil; import org.jeecg.modules.base.dto.AnalysesDto; import org.jeecg.modules.base.dto.OwnerDto; +import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.rnauto.GardsAnalyses; import org.jeecg.modules.system.entity.GardsSampleDataSystem; import org.jeecg.modules.system.mapper.GardsSampleDataMapper; @@ -201,6 +203,15 @@ public class GardsSampleDataServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsSampleDataSystem::getSampleId, sampleId); + Integer detectorId = Optional.of(this.getOne(wrapper, false)) + .orElse(new GardsSampleDataSystem()).getDetectorId(); + return ObjectUtil.isNull(detectorId) ? null : detectorId.toString(); + } + private String samplePath(String savePath, Integer sampleId){ GardsSampleDataSystem sampleData = getOne(sampleId); String inputFileName = sampleData.getInputFileName();