Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
eb726a9061
|
@ -30,4 +30,8 @@ public interface Prompt {
|
|||
String PARAM_REQUIRED = "Param Is Required!";
|
||||
|
||||
String PARAM_NOT_EMPTY = "Param Cat Not Be Empty!";
|
||||
|
||||
String EXEC_SUCC = "Task executed successfully!";
|
||||
|
||||
String EXEC_Faild = "Task executed Faild!";
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.base.dto;
|
|||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.base.entity.monitor.Item;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -14,9 +15,9 @@ public class ItemDto implements Serializable{
|
|||
|
||||
private String units;
|
||||
|
||||
public ItemDto(Item item) {
|
||||
this.itemId = item.getItemId();
|
||||
this.name = item.getName();
|
||||
this.units = item.getUnits();
|
||||
public ItemDto(AlarmItem alarmItem) {
|
||||
this.itemId = alarmItem.getId();
|
||||
this.name = alarmItem.getName();
|
||||
this.units = alarmItem.getUnits();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import lombok.experimental.Accessors;
|
|||
import org.jeecg.modules.base.enums.SourceType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
|
@ -30,8 +31,14 @@ public class RuleDto implements Serializable{
|
|||
// 谱id
|
||||
private String sampleId;
|
||||
|
||||
// 谱Name
|
||||
private String sampleName;
|
||||
|
||||
// 采样时间
|
||||
private LocalDateTime collectionDate;
|
||||
|
||||
// 数据源类型(ARMDARR=1|ARMDRRR=2|IDCARR=3|IDCRRR=4)
|
||||
private String dataSourceType;
|
||||
private String datasource;
|
||||
|
||||
// 谱类型 (FULL|PREL)
|
||||
private String fullOrPrel;
|
||||
|
@ -41,4 +48,11 @@ public class RuleDto implements Serializable{
|
|||
|
||||
// 核素名称-浓度值
|
||||
private Map<String,String> nuclides;
|
||||
|
||||
/* 以下属性不需要传值 */
|
||||
private String ruleId;
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String conditions;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public class AlarmAnalysisLog implements Serializable{
|
|||
|
||||
private String datasource;
|
||||
|
||||
private String sampleName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<NuclideInfo> nuclideInfoList;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||
import org.jeecg.common.system.base.entity.JeecgEntity;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
@Data
|
||||
@TableName("alarm_analysis_rule")
|
||||
|
|
|
@ -20,8 +20,8 @@ public class AlarmAnalysisNuclideParamController extends JeecgController<AlarmAn
|
|||
|
||||
@GetMapping("refresh")
|
||||
@ApiOperation(value = "定时刷新核素计算参数信息",notes = "定时刷新核素计算参数信息")
|
||||
public void refreshParam(){
|
||||
service.refresh();
|
||||
public boolean refreshParam(){
|
||||
return service.refresh();
|
||||
}
|
||||
|
||||
@GetMapping("findInfo")
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||
import org.jeecg.modules.service.IAlarmItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(value = "监控项管理",tags = "监控项管理")
|
||||
@RestController
|
||||
@RequestMapping("/alarmitem")
|
||||
@RequestMapping("alarmItem")
|
||||
public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemService> {
|
||||
|
||||
@Autowired
|
||||
private IAlarmItemService alarmItemService;
|
||||
|
||||
|
||||
@GetMapping("syncItem")
|
||||
@ApiOperation(value = "同步监控项信息",notes = "同步监控项信息")
|
||||
public boolean syncItem(@RequestParam String type,
|
||||
@RequestParam String code){
|
||||
return service.syncItem(type,code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,11 @@ import org.jeecg.common.api.vo.Result;
|
|||
import org.jeecg.modules.base.dto.ItemDto;
|
||||
import org.jeecg.modules.base.entity.monitor.Host;
|
||||
import org.jeecg.modules.base.entity.monitor.Servers;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmRule;
|
||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||
import org.jeecg.modules.service.IAlarmItemService;
|
||||
import org.jeecg.modules.service.IAlarmRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -28,6 +30,9 @@ public class AlarmRuleController {
|
|||
@Autowired
|
||||
private IAlarmRuleService alarmRuleService;
|
||||
|
||||
@Autowired
|
||||
private IAlarmItemService alarmItemService;
|
||||
|
||||
@GetMapping("findPage")
|
||||
@ApiOperation(value = "分页查询报警规则", notes = "分页查询报警规则")
|
||||
public Result findPage(AlarmRuleVo alarmRuleVo){
|
||||
|
@ -66,17 +71,9 @@ public class AlarmRuleController {
|
|||
|
||||
@GetMapping("getItems")
|
||||
@ApiOperation(value = "根据资源名称获取监控项",notes = "根据资源名称获取监控项")
|
||||
public Result getItems(@RequestParam String sourceName){
|
||||
Result<Servers> result = monitorAlarm.listBack(sourceName);
|
||||
List<Host> hosts = result.getResult().getRecords();
|
||||
List<ItemDto> itemDtos = new ArrayList<>();
|
||||
for (Host host : hosts) {
|
||||
boolean equals = host.getCode().equals(sourceName);
|
||||
if(!equals)continue;
|
||||
itemDtos = host.getItems().values().stream()
|
||||
.map(ItemDto::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
public Result getItems(@RequestParam String sourceId){
|
||||
List<AlarmItem> alarmItems = alarmItemService.alarmItems(sourceId);
|
||||
List<ItemDto> itemDtos = alarmItems.stream().map(ItemDto::new).collect(Collectors.toList());
|
||||
return Result.OK(itemDtos);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ public class CalculateConcController {
|
|||
|
||||
@GetMapping("caclAndSave")
|
||||
@ApiOperation(value = "计算并保存核素浓度",notes = "计算并保存核素浓度")
|
||||
public void caclAndSave(){
|
||||
calculateConcService.calcAndSave();
|
||||
public boolean caclAndSave(){
|
||||
return calculateConcService.calcAndSave();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Component
|
||||
@FeignClient(name = "monitorAlarm",url = "http://218.249.158.97:7008/mobile/monitor")
|
||||
@FeignClient(name = "monitorAlarm",url = "http://123.124.245.134:7008/mobile/monitor")
|
||||
public interface MonitorAlarm {
|
||||
|
||||
// --------------------后端专用-------------------
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
AND source_id = #{sourceId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY enabled DESC, create_time DESC
|
||||
<if test="pageFlag == null">
|
||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
ORDER BY enabled DESC, create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="findInfo" parameterType="String" resultType="org.jeecg.modules.base.dto.AlarmRuleInfo">
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
package org.jeecg.modules.redisStream;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.RedisConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.util.RedisStreamUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.dto.NuclideInfo;
|
||||
import org.jeecg.modules.base.dto.RuleDto;
|
||||
|
@ -29,7 +25,6 @@ import org.jeecg.modules.service.AnalysisResultService;
|
|||
import org.jeecg.modules.service.IAlarmAnalysisLogService;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisNuclideAvgService;
|
||||
import org.jeecg.modules.service.IAlarmAnalysisRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.stream.ObjectRecord;
|
||||
import org.springframework.data.redis.connection.stream.RecordId;
|
||||
import org.springframework.data.redis.stream.StreamListener;
|
||||
|
@ -38,8 +33,6 @@ import static org.jeecg.common.constant.enums.MessageTypeEnum.*;
|
|||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -101,8 +94,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
String stationId = ruleDto.getStationId();
|
||||
String sampleId = ruleDto.getSampleId();
|
||||
String fullOrPrel = ruleDto.getFullOrPrel();
|
||||
String betaOrGamma = ruleDto.getBetaOrGamma();
|
||||
String dataSourceType = ruleDto.getDataSourceType();
|
||||
String datasource = ruleDto.getDatasource();
|
||||
Map<String, String> nuclides = ruleDto.getNuclides();
|
||||
if (StrUtil.isBlank(stationId)) return;
|
||||
if (StrUtil.isBlank(sampleId)) return;
|
||||
|
@ -118,7 +110,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
continue;
|
||||
// 是否在当前规则关注的数据源内
|
||||
String source = rule.getSource();
|
||||
if (!StrUtil.contains(source,dataSourceType))
|
||||
if (!StrUtil.contains(source,datasource))
|
||||
continue;
|
||||
// 是否在当前规则关注的谱类型内
|
||||
String spectralQualifier = rule.getSpectralQualifier();
|
||||
|
@ -136,34 +128,32 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
.filter(entry -> cross.contains(entry.getKey()))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
// 开始对交集中的核素进行条件判断
|
||||
List<String> conditions = ListUtil.toList(conditionStr.split(comma));
|
||||
String ruleId = rule.getId();
|
||||
String groupId = rule.getContactGroup();
|
||||
judge(ruleId,groupId,sampleId,betaOrGamma,dataSourceType,conditions,nuclidesCross);
|
||||
ruleDto.setRuleId(rule.getId());
|
||||
ruleDto.setGroupId(rule.getContactGroup());
|
||||
ruleDto.setConditions(rule.getConditions());
|
||||
judge(ruleDto,nuclidesCross);
|
||||
}
|
||||
}
|
||||
|
||||
private void judge(String ruleId,
|
||||
String groupId,
|
||||
String sampleId,
|
||||
String betaOrGamma,
|
||||
String dataSourceType,
|
||||
List<String> conditions,
|
||||
Map<String,String> nuclidesCross){
|
||||
private void judge(RuleDto ruleDto, Map<String,String> nuclidesCross){
|
||||
String ONE = "1";String TWO = "2";String THREE = "3";
|
||||
Set<String> nuclideNames = nuclidesCross.keySet();
|
||||
String alarmInfo = "";
|
||||
List<String> firstDetected;
|
||||
List<NuclideInfo> moreThanAvg = new ArrayList<>();
|
||||
String conditionStr = ruleDto.getConditions();
|
||||
String betaOrGamma = ruleDto.getBetaOrGamma();
|
||||
String datasource = ruleDto.getDatasource();
|
||||
List<String> conditions = ListUtil.toList(conditionStr.split(comma));
|
||||
for (String con : conditions) {
|
||||
if (ONE.equals(con)){ // 首次发现该元素
|
||||
firstDetected = firstDetected(betaOrGamma,dataSourceType,nuclideNames);
|
||||
firstDetected = firstDetected(betaOrGamma,datasource,nuclideNames);
|
||||
if (CollUtil.isNotEmpty(firstDetected)){
|
||||
String message = "核素"+StrUtil.join(comma,firstDetected)+"首次发现";
|
||||
alarmInfo += message;
|
||||
}
|
||||
} else if (TWO.equals(con)) { // 元素浓度高于均值
|
||||
moreThanAvg = moreThanAvg(dataSourceType,nuclidesCross);
|
||||
moreThanAvg = moreThanAvg(datasource,nuclidesCross);
|
||||
if (CollUtil.isNotEmpty(moreThanAvg)){
|
||||
for (NuclideInfo nuclideInfo : moreThanAvg) {
|
||||
String nuclide = nuclideInfo.getNuclide();
|
||||
|
@ -182,8 +172,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
if (StrUtil.isNotBlank(alarmInfo)){
|
||||
// 保存报警日志
|
||||
AlarmAnalysisLog logInfo = new AlarmAnalysisLog();
|
||||
logInfo.setRuleId(ruleId);
|
||||
logInfo.setSampleId(sampleId);
|
||||
BeanUtil.copyProperties(ruleDto,logInfo);
|
||||
if (alarmInfo.startsWith(comma))
|
||||
alarmInfo = StrUtil.sub(alarmInfo, 1, alarmInfo.length());
|
||||
logInfo.setAlarmInfo(alarmInfo);
|
||||
|
@ -191,6 +180,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
|
|||
logInfo.setNuclideInfoList(moreThanAvg);
|
||||
logService.saveLog(logInfo);
|
||||
// 发送报警信息
|
||||
String groupId = ruleDto.getGroupId();
|
||||
if (StrUtil.isNotBlank(groupId))
|
||||
systemClient.sendMessage(alarmInfo,groupId, ALL.getValue());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||
|
||||
public interface CalculateConcService {
|
||||
|
||||
void calcAndSave();
|
||||
boolean calcAndSave();
|
||||
|
||||
Map<String,String> calculate(List<ConcDto> concDtos, BigDecimal index);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IAlarmItemService extends IService<AlarmItem> {
|
||||
Result syncItem(String sourceType,String code);
|
||||
boolean syncItem(String sourceType,String code);
|
||||
|
||||
List<AlarmItem> alarmItems(String sourceId);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
|
||||
@Service
|
||||
public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnalysisNuclideParamMapper, AlarmAnalysisNuclideParam> implements IAlarmAnalysisNuclideParamService {
|
||||
|
||||
|
@ -22,11 +25,22 @@ public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnaly
|
|||
|
||||
@Override
|
||||
public boolean refresh() {
|
||||
AlarmAnalysisNuclideParam nuclideParam = new AlarmAnalysisNuclideParam();
|
||||
CopyOptions options = CopyOptions.create()
|
||||
.setIgnoreProperties("id","createTime");
|
||||
BeanUtil.copyProperties(getLatest(),nuclideParam,options);
|
||||
return save(nuclideParam);
|
||||
try {
|
||||
AlarmAnalysisNuclideParam nuclideParam = new AlarmAnalysisNuclideParam();
|
||||
AlarmAnalysisNuclideParam latest = getLatest();
|
||||
LocalDate localDate = latest.getCreateTime().toInstant()
|
||||
.atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate today = LocalDate.now();
|
||||
boolean isToday = today.equals(localDate);
|
||||
if (isToday) return true;
|
||||
CopyOptions options = CopyOptions.create()
|
||||
.setIgnoreProperties("id","createTime");
|
||||
BeanUtil.copyProperties(latest,nuclideParam,options);
|
||||
return save(nuclideParam);
|
||||
}catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
|
@ -17,6 +19,7 @@ import org.jeecg.modules.service.ISysDatabaseService;
|
|||
import org.jeecg.modules.service.ISysServerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -38,41 +41,50 @@ public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem
|
|||
private ISysDatabaseService databaseService;
|
||||
|
||||
@Override
|
||||
public Result syncItem(String type,String code) {
|
||||
String sourceId = null;
|
||||
if (SERVER.getType().equals(type)){
|
||||
sourceId = serverService.getByName(code);
|
||||
} else if (DATABASE.getType().equals(type)) {
|
||||
public boolean syncItem(String type,String code) {
|
||||
try {
|
||||
String sourceId = null;
|
||||
if (SERVER.getType().equals(type)){
|
||||
sourceId = serverService.getByName(code);
|
||||
} else if (DATABASE.getType().equals(type)) {
|
||||
|
||||
}else {
|
||||
return Result.error("Soucrce Type Not Extis!");
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
if (StrUtil.isBlank(sourceId))
|
||||
return false;
|
||||
|
||||
Result<Servers> result = monitorAlarm.listBack(code);
|
||||
List<Host> hosts = result.getResult().getRecords();
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (Host host : hosts) {
|
||||
boolean equals = host.getCode().equals(code);
|
||||
if(!equals) continue;
|
||||
items = ListUtil.toList(host.getItems().values());
|
||||
}
|
||||
if (CollUtil.isEmpty(items))
|
||||
return false;
|
||||
|
||||
List<AlarmItem> alarmItems = new ArrayList<>();
|
||||
for (Item item : items) {
|
||||
AlarmItem alarmItem = BeanUtil.copyProperties(item, AlarmItem.class);
|
||||
alarmItem.setId(item.getItemId());
|
||||
alarmItem.setSourceId(sourceId);
|
||||
alarmItems.add(alarmItem);
|
||||
}
|
||||
return saveOrUpdateBatch(alarmItems);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlarmItem> alarmItems(String sourceId) {
|
||||
if (StrUtil.isBlank(sourceId))
|
||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
||||
|
||||
Result<Servers> result = monitorAlarm.listBack(code);
|
||||
List<Host> hosts = result.getResult().getRecords();
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (Host host : hosts) {
|
||||
boolean equals = host.getCode().equals(code);
|
||||
if(!equals) continue;
|
||||
items = ListUtil.toList(host.getItems().values());
|
||||
}
|
||||
if (CollUtil.isEmpty(items))
|
||||
return Result.error(Prompt.DATA_IS_EMPTY);
|
||||
|
||||
List<AlarmItem> alarmItems = new ArrayList<>();
|
||||
for (Item item : items) {
|
||||
AlarmItem alarmItem = new AlarmItem();
|
||||
alarmItem.setId(item.getItemId());
|
||||
alarmItem.setName(item.getName());
|
||||
alarmItem.setUnits(item.getUnits());
|
||||
alarmItem.setSourceId(sourceId);
|
||||
alarmItem.setDescription(item.getDescription());
|
||||
alarmItems.add(alarmItem);
|
||||
}
|
||||
if(saveOrUpdateBatch(alarmItems))
|
||||
return Result.OK(Prompt.UPDATE_SUCC);
|
||||
return Result.error(Prompt.UPDATE_ERR);
|
||||
return ListUtil.empty();
|
||||
LambdaQueryWrapper<AlarmItem> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AlarmItem::getSourceId,sourceId);
|
||||
return list(wrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,54 +46,59 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
|||
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
||||
|
||||
@Override
|
||||
public void calcAndSave() {
|
||||
String comma = SymbolConstant.COMMA;
|
||||
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
||||
Set<String> nuclideNames = analysisRules.stream()
|
||||
.filter(rule -> StrUtil.isNotBlank(rule.getNuclides()))
|
||||
.map(AlarmAnalysisRule::getNuclides)
|
||||
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
||||
.collect(Collectors.toSet());
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("nuclideName",nuclideNames);
|
||||
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
|
||||
BigDecimal index = paramLatest.getIndex();
|
||||
Integer days = paramLatest.getDays();
|
||||
LocalDate dayAgo = LocalDate.now().minusDays(1);
|
||||
LocalDate daysAgo = dayAgo.minusDays(days);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE);
|
||||
String startDate = daysAgo.format(formatter);
|
||||
String endDate = dayAgo.format(formatter);
|
||||
params.put("startDate",startDate + DateConstant.TIME_START);
|
||||
params.put("endDate",endDate + DateConstant.TIME_END);
|
||||
/* Auto自动处理 */
|
||||
// beta-gamma
|
||||
List<ConcDto> xeConcAuto = xeResultsAutoService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
|
||||
Map<String,String> autoResult = new HashMap<>();
|
||||
autoResult.putAll(calculate(xeConcAuto,index));
|
||||
autoResult.putAll(calculate(nuclConcAuto,index));
|
||||
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
|
||||
/* Man人工交互 */
|
||||
// beta-gamma
|
||||
List<ConcDto> xeConcMan = xeResultsManService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
|
||||
Map<String,String> manResult = new HashMap<>();
|
||||
manResult.putAll(calculate(xeConcMan,index));
|
||||
manResult.putAll(calculate(nuclConcMan,index));
|
||||
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
manAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDRRR));
|
||||
manAvgs.addAll(autoAvgs);
|
||||
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
||||
manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||
nuclideAvgService.saveBatch(manAvgs);
|
||||
public boolean calcAndSave() {
|
||||
try {
|
||||
String comma = SymbolConstant.COMMA;
|
||||
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
||||
Set<String> nuclideNames = analysisRules.stream()
|
||||
.filter(rule -> StrUtil.isNotBlank(rule.getNuclides()))
|
||||
.map(AlarmAnalysisRule::getNuclides)
|
||||
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
||||
.collect(Collectors.toSet());
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("nuclideName",nuclideNames);
|
||||
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
|
||||
BigDecimal index = paramLatest.getIndex();
|
||||
Integer days = paramLatest.getDays();
|
||||
LocalDate dayAgo = LocalDate.now().minusDays(1);
|
||||
LocalDate daysAgo = dayAgo.minusDays(days);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE);
|
||||
String startDate = daysAgo.format(formatter);
|
||||
String endDate = dayAgo.format(formatter);
|
||||
params.put("startDate",startDate + DateConstant.TIME_START);
|
||||
params.put("endDate",endDate + DateConstant.TIME_END);
|
||||
/* Auto自动处理 */
|
||||
// beta-gamma
|
||||
List<ConcDto> xeConcAuto = xeResultsAutoService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
|
||||
Map<String,String> autoResult = new HashMap<>();
|
||||
autoResult.putAll(calculate(xeConcAuto,index));
|
||||
autoResult.putAll(calculate(nuclConcAuto,index));
|
||||
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
|
||||
/* Man人工交互 */
|
||||
// beta-gamma
|
||||
List<ConcDto> xeConcMan = xeResultsManService.getConc(params);
|
||||
// gamma
|
||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
|
||||
Map<String,String> manResult = new HashMap<>();
|
||||
manResult.putAll(calculate(xeConcMan,index));
|
||||
manResult.putAll(calculate(nuclConcMan,index));
|
||||
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
|
||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
manAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDRRR));
|
||||
manAvgs.addAll(autoAvgs);
|
||||
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
||||
manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||
return nuclideAvgService.saveBatch(manAvgs);
|
||||
}catch (Throwable e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,9 +31,14 @@ public interface AbnormalAlarmClient {
|
|||
|
||||
/* CalculateConcController下相关接口 */
|
||||
@GetMapping("/calculateConc/caclAndSave")
|
||||
void calculateConc();
|
||||
boolean calculateConc();
|
||||
|
||||
/* AlarmAnalysisNuclideParamController下相关接口 */
|
||||
@GetMapping("/nuclideParam/refresh")
|
||||
void refreshParam();
|
||||
boolean refreshParam();
|
||||
|
||||
/* AlarmItemController下相关接口 */
|
||||
@GetMapping("/alarmItem/syncItem")
|
||||
boolean syncItem(@RequestParam String type,
|
||||
@RequestParam String code);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
|
@ -272,19 +273,17 @@ public class QuartzJobController {
|
|||
//@RequiresRoles("admin")
|
||||
//@RequiresPermissions("system:quartzJob:execute")
|
||||
@GetMapping("/execute")
|
||||
public Result<?> execute(@RequestParam(name = "id", required = true) String id) {
|
||||
public Result<?> execute(@RequestParam("id") String id) {
|
||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||
if (quartzJob == null) {
|
||||
return Result.error("未找到对应实体");
|
||||
return Result.error("The specified task entity class was not found");
|
||||
}
|
||||
try {
|
||||
quartzJobService.execute(quartzJob);
|
||||
return quartzJobService.execute(quartzJob);
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
log.info("定时任务 立即执行失败>>"+e.getMessage());
|
||||
return Result.error("执行失败!");
|
||||
e.printStackTrace();
|
||||
return Result.error(Prompt.EXEC_Faild);
|
||||
}
|
||||
return Result.ok("执行成功!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.quartz.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||
|
@ -15,17 +16,27 @@ import static org.jeecg.common.util.TokenUtils.getTempToken;
|
|||
/**
|
||||
* 定时更新核素浓度计算参数
|
||||
*/
|
||||
@Slf4j
|
||||
@DisallowConcurrentExecution
|
||||
@PersistJobDataAfterExecution
|
||||
public class NuclideParamJob implements Job {
|
||||
|
||||
private AbnormalAlarmClient alarmClient;
|
||||
|
||||
private boolean success = true;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
init();
|
||||
alarmClient.refreshParam();
|
||||
destroy();
|
||||
try {
|
||||
init();
|
||||
success = alarmClient.refreshParam();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
success = false;
|
||||
}finally {
|
||||
destroy();
|
||||
context.getJobDetail().getJobDataMap().put("success",success);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(){
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.quartz.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||
|
@ -15,23 +16,34 @@ import static org.jeecg.common.util.TokenUtils.getTempToken;
|
|||
/**
|
||||
* 定时计算核素浓度均值
|
||||
*/
|
||||
@Slf4j
|
||||
@DisallowConcurrentExecution
|
||||
@PersistJobDataAfterExecution
|
||||
public class NucliedAvgJob implements Job {
|
||||
|
||||
private AbnormalAlarmClient alarmClient;
|
||||
|
||||
private boolean success = true;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
init();
|
||||
alarmClient.calculateConc();
|
||||
destroy();
|
||||
try {
|
||||
init();
|
||||
success = alarmClient.calculateConc();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
success = false;
|
||||
}finally {
|
||||
destroy();
|
||||
context.getJobDetail().getJobDataMap().put("success",success);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(){
|
||||
// start:生成临时Token到线程中
|
||||
UserTokenContext.setToken(getTempToken());
|
||||
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
||||
throw new RuntimeException("test");
|
||||
}
|
||||
|
||||
private void destroy(){
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package org.jeecg.modules.quartz.job;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.enums.SourceType;
|
||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||
import org.quartz.*;
|
||||
|
||||
import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||
|
||||
/**
|
||||
* 此处的同步是指:当定时任务的执行时间大于任务的时间
|
||||
* 间隔时会等待第一个任务执行完成才会走第二个任务
|
||||
*/
|
||||
|
||||
/**
|
||||
* 监控项信息更新保存
|
||||
*/
|
||||
@DisallowConcurrentExecution
|
||||
@PersistJobDataAfterExecution
|
||||
public class SyncItemJob implements Job {
|
||||
|
||||
private AbnormalAlarmClient alarmClient;
|
||||
|
||||
private boolean success = true;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
try {
|
||||
init();
|
||||
success = alarmClient.syncItem(SourceType.SERVER.getType(), "172.21.60.231");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
success = false;
|
||||
}finally {
|
||||
destroy();
|
||||
context.getJobDetail().getJobDataMap().put("success",success);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(){
|
||||
// start:生成临时Token到线程中
|
||||
UserTokenContext.setToken(getTempToken());
|
||||
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
||||
}
|
||||
|
||||
private void destroy(){
|
||||
// end:删除临时Token
|
||||
UserTokenContext.remove();
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import org.jeecg.common.util.SpringContextUtils;
|
|||
import org.jeecg.modules.base.dto.RuleDto;
|
||||
import org.quartz.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -22,11 +23,13 @@ public class Test implements Job {
|
|||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
init();
|
||||
RuleDto ruleDto = new RuleDto();
|
||||
ruleDto.setStationId("101");
|
||||
ruleDto.setSampleId("424249");
|
||||
ruleDto.setStationId("205");
|
||||
ruleDto.setSampleId("425496");
|
||||
ruleDto.setBetaOrGamma("Gamma");
|
||||
ruleDto.setFullOrPrel("FULL");
|
||||
ruleDto.setDataSourceType("1");
|
||||
ruleDto.setDatasource("1");
|
||||
ruleDto.setSampleName("CAX05_001-20230624_0220_Q_FULL_299.3.PHD");
|
||||
ruleDto.setCollectionDate(LocalDateTime.now());
|
||||
Map<String, String> nuclides = MapUtil.newHashMap();
|
||||
nuclides.put("Be7","1000000");
|
||||
nuclides.put("sss","1000000");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.quartz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
|
@ -55,7 +56,7 @@ public interface IQuartzJobService extends IService<QuartzJob> {
|
|||
* @param quartzJob
|
||||
* @throws Exception
|
||||
*/
|
||||
void execute(QuartzJob quartzJob) throws Exception;
|
||||
Result<?> execute(QuartzJob quartzJob) throws Exception;
|
||||
|
||||
/**
|
||||
* 暂停任务
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package org.jeecg.modules.quartz.service.impl;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||
|
@ -102,7 +106,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(QuartzJob quartzJob) throws Exception {
|
||||
public Result<?> execute(QuartzJob quartzJob) throws Exception {
|
||||
String jobName = quartzJob.getJobClassName().trim();
|
||||
Date startDate = new Date();
|
||||
String ymd = DateUtils.date2Str(startDate,DateUtils.yyyymmddhhmmss.get());
|
||||
|
@ -117,11 +121,21 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
|||
.startAt(startDate)
|
||||
.build();
|
||||
// 构建job信息
|
||||
JobDetail jobDetail = JobBuilder.newJob(getClass(jobName).getClass()).withIdentity(identity).usingJobData("parameter", quartzJob.getParameter()).build();
|
||||
JobDetail jobDetail = JobBuilder.newJob(getClass(jobName).getClass())
|
||||
.withIdentity(identity)
|
||||
.storeDurably()
|
||||
.usingJobData("parameter", quartzJob.getParameter())
|
||||
.build();
|
||||
// 将trigger和 jobDetail 加入这个调度
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
// 启动scheduler
|
||||
scheduler.start();
|
||||
// 获取 JobDetail 对象
|
||||
JobDetail detail = scheduler.getJobDetail(new JobKey(identity));
|
||||
if (ObjectUtil.isNull(detail))
|
||||
return Result.OK(Prompt.EXEC_SUCC);
|
||||
boolean success = detail.getJobDataMap().getBoolean("success");
|
||||
return success ? Result.OK(Prompt.EXEC_SUCC) : Result.error(Prompt.EXEC_Faild);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,7 +71,7 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
|
|||
item.setDetectorName(detectorName);
|
||||
}
|
||||
if (Objects.nonNull(item.getStartTime())) {
|
||||
long endSecond = (item.getStartTime().getTime() / 1000) + Long.valueOf(item.getTime());
|
||||
long endSecond = (item.getStartTime().getTime() / 1000) + Math.round(item.getTime());
|
||||
Date endDateTime = new Date();
|
||||
endDateTime.setTime(endSecond*1000);
|
||||
item.setEndTime(endDateTime);
|
||||
|
@ -162,7 +162,7 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
|
|||
Date startT = sohDatum.getStartTime();
|
||||
if (ObjectUtil.isNotNull(startT)) {
|
||||
long stratSecod = startT.getTime() / 1000;
|
||||
long endSecond = stratSecod + Long.valueOf(sohDatum.getTime());
|
||||
long endSecond = stratSecod + Math.round(sohDatum.getTime());
|
||||
Date endDateTime = new Date(endSecond * 1000);
|
||||
sohDatum.setEndTime(endDateTime);
|
||||
}
|
||||
|
|
|
@ -20,4 +20,4 @@ spring:
|
|||
monitor:
|
||||
username: wmhr
|
||||
password: Wmhr.123
|
||||
url: http://218.249.158.97:7008/mobile/monitor
|
||||
url: http://123.124.245.134:7008/mobile/monitor
|
Loading…
Reference in New Issue
Block a user