feat:持久化监控项
This commit is contained in:
parent
72a8d901ea
commit
77bea6bda4
|
@ -30,4 +30,8 @@ public interface Prompt {
|
||||||
String PARAM_REQUIRED = "Param Is Required!";
|
String PARAM_REQUIRED = "Param Is Required!";
|
||||||
|
|
||||||
String PARAM_NOT_EMPTY = "Param Cat Not Be Empty!";
|
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 lombok.Data;
|
||||||
import org.jeecg.modules.base.entity.monitor.Item;
|
import org.jeecg.modules.base.entity.monitor.Item;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ -14,9 +15,9 @@ public class ItemDto implements Serializable{
|
||||||
|
|
||||||
private String units;
|
private String units;
|
||||||
|
|
||||||
public ItemDto(Item item) {
|
public ItemDto(AlarmItem alarmItem) {
|
||||||
this.itemId = item.getItemId();
|
this.itemId = alarmItem.getId();
|
||||||
this.name = item.getName();
|
this.name = alarmItem.getName();
|
||||||
this.units = item.getUnits();
|
this.units = alarmItem.getUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ public class AlarmAnalysisNuclideParamController extends JeecgController<AlarmAn
|
||||||
|
|
||||||
@GetMapping("refresh")
|
@GetMapping("refresh")
|
||||||
@ApiOperation(value = "定时刷新核素计算参数信息",notes = "定时刷新核素计算参数信息")
|
@ApiOperation(value = "定时刷新核素计算参数信息",notes = "定时刷新核素计算参数信息")
|
||||||
public void refreshParam(){
|
public boolean refreshParam(){
|
||||||
service.refresh();
|
return service.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("findInfo")
|
@GetMapping("findInfo")
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
package org.jeecg.modules.controller;
|
package org.jeecg.modules.controller;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||||
import org.jeecg.modules.service.IAlarmItemService;
|
import org.jeecg.modules.service.IAlarmItemService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Api(value = "监控项管理",tags = "监控项管理")
|
@Api(value = "监控项管理",tags = "监控项管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/alarmitem")
|
@RequestMapping("alarmItem")
|
||||||
public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemService> {
|
public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemService> {
|
||||||
|
|
||||||
@Autowired
|
@GetMapping("syncItem")
|
||||||
private IAlarmItemService alarmItemService;
|
@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.dto.ItemDto;
|
||||||
import org.jeecg.modules.base.entity.monitor.Host;
|
import org.jeecg.modules.base.entity.monitor.Host;
|
||||||
import org.jeecg.modules.base.entity.monitor.Servers;
|
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.entity.postgre.AlarmRule;
|
||||||
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
import org.jeecg.modules.base.vo.AlarmRuleVo;
|
||||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||||
|
import org.jeecg.modules.service.IAlarmItemService;
|
||||||
import org.jeecg.modules.service.IAlarmRuleService;
|
import org.jeecg.modules.service.IAlarmRuleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -28,6 +30,9 @@ public class AlarmRuleController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAlarmRuleService alarmRuleService;
|
private IAlarmRuleService alarmRuleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAlarmItemService alarmItemService;
|
||||||
|
|
||||||
@GetMapping("findPage")
|
@GetMapping("findPage")
|
||||||
@ApiOperation(value = "分页查询报警规则", notes = "分页查询报警规则")
|
@ApiOperation(value = "分页查询报警规则", notes = "分页查询报警规则")
|
||||||
public Result findPage(AlarmRuleVo alarmRuleVo){
|
public Result findPage(AlarmRuleVo alarmRuleVo){
|
||||||
|
@ -66,17 +71,9 @@ public class AlarmRuleController {
|
||||||
|
|
||||||
@GetMapping("getItems")
|
@GetMapping("getItems")
|
||||||
@ApiOperation(value = "根据资源名称获取监控项",notes = "根据资源名称获取监控项")
|
@ApiOperation(value = "根据资源名称获取监控项",notes = "根据资源名称获取监控项")
|
||||||
public Result getItems(@RequestParam String sourceName){
|
public Result getItems(@RequestParam String sourceId){
|
||||||
Result<Servers> result = monitorAlarm.listBack(sourceName);
|
List<AlarmItem> alarmItems = alarmItemService.alarmItems(sourceId);
|
||||||
List<Host> hosts = result.getResult().getRecords();
|
List<ItemDto> itemDtos = alarmItems.stream().map(ItemDto::new).collect(Collectors.toList());
|
||||||
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());
|
|
||||||
}
|
|
||||||
return Result.OK(itemDtos);
|
return Result.OK(itemDtos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ public class CalculateConcController {
|
||||||
|
|
||||||
@GetMapping("caclAndSave")
|
@GetMapping("caclAndSave")
|
||||||
@ApiOperation(value = "计算并保存核素浓度",notes = "计算并保存核素浓度")
|
@ApiOperation(value = "计算并保存核素浓度",notes = "计算并保存核素浓度")
|
||||||
public void caclAndSave(){
|
public boolean caclAndSave(){
|
||||||
calculateConcService.calcAndSave();
|
return calculateConcService.calcAndSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
@Component
|
@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 {
|
public interface MonitorAlarm {
|
||||||
|
|
||||||
// --------------------后端专用-------------------
|
// --------------------后端专用-------------------
|
||||||
|
|
|
@ -38,10 +38,10 @@
|
||||||
AND source_id = #{sourceId}
|
AND source_id = #{sourceId}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
ORDER BY enabled DESC, create_time DESC
|
||||||
<if test="pageFlag == null">
|
<if test="pageFlag == null">
|
||||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||||
</if>
|
</if>
|
||||||
ORDER BY enabled DESC, create_time DESC
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findInfo" parameterType="String" resultType="org.jeecg.modules.base.dto.AlarmRuleInfo">
|
<select id="findInfo" parameterType="String" resultType="org.jeecg.modules.base.dto.AlarmRuleInfo">
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public interface CalculateConcService {
|
public interface CalculateConcService {
|
||||||
|
|
||||||
void calcAndSave();
|
boolean calcAndSave();
|
||||||
|
|
||||||
Map<String,String> calculate(List<ConcDto> concDtos, BigDecimal index);
|
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.common.api.vo.Result;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface IAlarmItemService extends IService<AlarmItem> {
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnalysisNuclideParamMapper, AlarmAnalysisNuclideParam> implements IAlarmAnalysisNuclideParamService {
|
public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnalysisNuclideParamMapper, AlarmAnalysisNuclideParam> implements IAlarmAnalysisNuclideParamService {
|
||||||
|
|
||||||
|
@ -22,11 +25,22 @@ public class AlarmAnalysisNuclideParamServiceImpl extends ServiceImpl<AlarmAnaly
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean refresh() {
|
public boolean refresh() {
|
||||||
AlarmAnalysisNuclideParam nuclideParam = new AlarmAnalysisNuclideParam();
|
try {
|
||||||
CopyOptions options = CopyOptions.create()
|
AlarmAnalysisNuclideParam nuclideParam = new AlarmAnalysisNuclideParam();
|
||||||
.setIgnoreProperties("id","createTime");
|
AlarmAnalysisNuclideParam latest = getLatest();
|
||||||
BeanUtil.copyProperties(getLatest(),nuclideParam,options);
|
LocalDate localDate = latest.getCreateTime().toInstant()
|
||||||
return save(nuclideParam);
|
.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
|
@Override
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.jeecg.modules.service.impl;
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.Prompt;
|
import org.jeecg.common.constant.Prompt;
|
||||||
|
@ -17,6 +19,7 @@ import org.jeecg.modules.service.ISysDatabaseService;
|
||||||
import org.jeecg.modules.service.ISysServerService;
|
import org.jeecg.modules.service.ISysServerService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,41 +41,50 @@ public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem
|
||||||
private ISysDatabaseService databaseService;
|
private ISysDatabaseService databaseService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result syncItem(String type,String code) {
|
public boolean syncItem(String type,String code) {
|
||||||
String sourceId = null;
|
try {
|
||||||
if (SERVER.getType().equals(type)){
|
String sourceId = null;
|
||||||
sourceId = serverService.getByName(code);
|
if (SERVER.getType().equals(type)){
|
||||||
} else if (DATABASE.getType().equals(type)) {
|
sourceId = serverService.getByName(code);
|
||||||
|
} else if (DATABASE.getType().equals(type)) {
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
return Result.error("Soucrce Type Not Extis!");
|
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))
|
if (StrUtil.isBlank(sourceId))
|
||||||
return Result.error(Prompt.DATA_NOT_EXITS);
|
return ListUtil.empty();
|
||||||
|
LambdaQueryWrapper<AlarmItem> wrapper = new LambdaQueryWrapper<>();
|
||||||
Result<Servers> result = monitorAlarm.listBack(code);
|
wrapper.eq(AlarmItem::getSourceId,sourceId);
|
||||||
List<Host> hosts = result.getResult().getRecords();
|
return list(wrapper);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,54 +46,59 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
private IAlarmAnalysisNuclideParamService nuclideParamService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void calcAndSave() {
|
public boolean calcAndSave() {
|
||||||
String comma = SymbolConstant.COMMA;
|
try {
|
||||||
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
String comma = SymbolConstant.COMMA;
|
||||||
Set<String> nuclideNames = analysisRules.stream()
|
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
||||||
.filter(rule -> StrUtil.isNotBlank(rule.getNuclides()))
|
Set<String> nuclideNames = analysisRules.stream()
|
||||||
.map(AlarmAnalysisRule::getNuclides)
|
.filter(rule -> StrUtil.isNotBlank(rule.getNuclides()))
|
||||||
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
.map(AlarmAnalysisRule::getNuclides)
|
||||||
.collect(Collectors.toSet());
|
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
||||||
Map<String,Object> params = new HashMap<>();
|
.collect(Collectors.toSet());
|
||||||
params.put("nuclideName",nuclideNames);
|
Map<String,Object> params = new HashMap<>();
|
||||||
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
|
params.put("nuclideName",nuclideNames);
|
||||||
BigDecimal index = paramLatest.getIndex();
|
AlarmAnalysisNuclideParam paramLatest = nuclideParamService.getLatest();
|
||||||
Integer days = paramLatest.getDays();
|
BigDecimal index = paramLatest.getIndex();
|
||||||
LocalDate dayAgo = LocalDate.now().minusDays(1);
|
Integer days = paramLatest.getDays();
|
||||||
LocalDate daysAgo = dayAgo.minusDays(days);
|
LocalDate dayAgo = LocalDate.now().minusDays(1);
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE);
|
LocalDate daysAgo = dayAgo.minusDays(days);
|
||||||
String startDate = daysAgo.format(formatter);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE);
|
||||||
String endDate = dayAgo.format(formatter);
|
String startDate = daysAgo.format(formatter);
|
||||||
params.put("startDate",startDate + DateConstant.TIME_START);
|
String endDate = dayAgo.format(formatter);
|
||||||
params.put("endDate",endDate + DateConstant.TIME_END);
|
params.put("startDate",startDate + DateConstant.TIME_START);
|
||||||
/* Auto自动处理 */
|
params.put("endDate",endDate + DateConstant.TIME_END);
|
||||||
// beta-gamma
|
/* Auto自动处理 */
|
||||||
List<ConcDto> xeConcAuto = xeResultsAutoService.getConc(params);
|
// beta-gamma
|
||||||
// gamma
|
List<ConcDto> xeConcAuto = xeResultsAutoService.getConc(params);
|
||||||
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
|
// gamma
|
||||||
Map<String,String> autoResult = new HashMap<>();
|
List<ConcDto> nuclConcAuto = nuclIdedAutoService.getConc(params);
|
||||||
autoResult.putAll(calculate(xeConcAuto,index));
|
Map<String,String> autoResult = new HashMap<>();
|
||||||
autoResult.putAll(calculate(nuclConcAuto,index));
|
autoResult.putAll(calculate(xeConcAuto,index));
|
||||||
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
|
autoResult.putAll(calculate(nuclConcAuto,index));
|
||||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
List<AlarmAnalysisNuclideAvg> autoAvgs = autoResult.entrySet().stream()
|
||||||
.collect(Collectors.toList());
|
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||||
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
|
.collect(Collectors.toList());
|
||||||
/* Man人工交互 */
|
autoAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDARR));
|
||||||
// beta-gamma
|
/* Man人工交互 */
|
||||||
List<ConcDto> xeConcMan = xeResultsManService.getConc(params);
|
// beta-gamma
|
||||||
// gamma
|
List<ConcDto> xeConcMan = xeResultsManService.getConc(params);
|
||||||
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
|
// gamma
|
||||||
Map<String,String> manResult = new HashMap<>();
|
List<ConcDto> nuclConcMan = nuclIdedManService.getConc(params);
|
||||||
manResult.putAll(calculate(xeConcMan,index));
|
Map<String,String> manResult = new HashMap<>();
|
||||||
manResult.putAll(calculate(nuclConcMan,index));
|
manResult.putAll(calculate(xeConcMan,index));
|
||||||
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
|
manResult.putAll(calculate(nuclConcMan,index));
|
||||||
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
List<AlarmAnalysisNuclideAvg> manAvgs = manResult.entrySet().stream()
|
||||||
.collect(Collectors.toList());
|
.map(entry -> new AlarmAnalysisNuclideAvg(entry.getKey(), entry.getValue()))
|
||||||
manAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDRRR));
|
.collect(Collectors.toList());
|
||||||
manAvgs.addAll(autoAvgs);
|
manAvgs.forEach(item -> item.setDataSourceType(CommonConstant.ARMDRRR));
|
||||||
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
manAvgs.addAll(autoAvgs);
|
||||||
manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
String cycle = startDate + SymbolConstant.WELL_NUMBER + endDate;
|
||||||
nuclideAvgService.saveBatch(manAvgs);
|
manAvgs.forEach(item -> item.setCycle(cycle).setCaclDate(dayAgo));
|
||||||
|
return nuclideAvgService.saveBatch(manAvgs);
|
||||||
|
}catch (Throwable e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,9 +31,14 @@ public interface AbnormalAlarmClient {
|
||||||
|
|
||||||
/* CalculateConcController下相关接口 */
|
/* CalculateConcController下相关接口 */
|
||||||
@GetMapping("/calculateConc/caclAndSave")
|
@GetMapping("/calculateConc/caclAndSave")
|
||||||
void calculateConc();
|
boolean calculateConc();
|
||||||
|
|
||||||
/* AlarmAnalysisNuclideParamController下相关接口 */
|
/* AlarmAnalysisNuclideParamController下相关接口 */
|
||||||
@GetMapping("/nuclideParam/refresh")
|
@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.apache.shiro.SecurityUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.common.constant.Prompt;
|
||||||
import org.jeecg.common.constant.SymbolConstant;
|
import org.jeecg.common.constant.SymbolConstant;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
@ -272,19 +273,17 @@ public class QuartzJobController {
|
||||||
//@RequiresRoles("admin")
|
//@RequiresRoles("admin")
|
||||||
//@RequiresPermissions("system:quartzJob:execute")
|
//@RequiresPermissions("system:quartzJob:execute")
|
||||||
@GetMapping("/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);
|
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||||
if (quartzJob == null) {
|
if (quartzJob == null) {
|
||||||
return Result.error("未找到对应实体");
|
return Result.error("The specified task entity class was not found");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
quartzJobService.execute(quartzJob);
|
return quartzJobService.execute(quartzJob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.info("定时任务 立即执行失败>>"+e.getMessage());
|
return Result.error(Prompt.EXEC_Faild);
|
||||||
return Result.error("执行失败!");
|
|
||||||
}
|
}
|
||||||
return Result.ok("执行成功!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.modules.quartz.job;
|
package org.jeecg.modules.quartz.job;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||||
|
@ -15,17 +16,27 @@ import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||||
/**
|
/**
|
||||||
* 定时更新核素浓度计算参数
|
* 定时更新核素浓度计算参数
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@DisallowConcurrentExecution
|
@DisallowConcurrentExecution
|
||||||
@PersistJobDataAfterExecution
|
@PersistJobDataAfterExecution
|
||||||
public class NuclideParamJob implements Job {
|
public class NuclideParamJob implements Job {
|
||||||
|
|
||||||
private AbnormalAlarmClient alarmClient;
|
private AbnormalAlarmClient alarmClient;
|
||||||
|
|
||||||
|
private boolean success = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
init();
|
try {
|
||||||
alarmClient.refreshParam();
|
init();
|
||||||
destroy();
|
success = alarmClient.refreshParam();
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
success = false;
|
||||||
|
}finally {
|
||||||
|
destroy();
|
||||||
|
context.getJobDetail().getJobDataMap().put("success",success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(){
|
private void init(){
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.modules.quartz.job;
|
package org.jeecg.modules.quartz.job;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||||
|
@ -15,23 +16,34 @@ import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||||
/**
|
/**
|
||||||
* 定时计算核素浓度均值
|
* 定时计算核素浓度均值
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@DisallowConcurrentExecution
|
@DisallowConcurrentExecution
|
||||||
@PersistJobDataAfterExecution
|
@PersistJobDataAfterExecution
|
||||||
public class NucliedAvgJob implements Job {
|
public class NucliedAvgJob implements Job {
|
||||||
|
|
||||||
private AbnormalAlarmClient alarmClient;
|
private AbnormalAlarmClient alarmClient;
|
||||||
|
|
||||||
|
private boolean success = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
init();
|
try {
|
||||||
alarmClient.calculateConc();
|
init();
|
||||||
destroy();
|
success = alarmClient.calculateConc();
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
success = false;
|
||||||
|
}finally {
|
||||||
|
destroy();
|
||||||
|
context.getJobDetail().getJobDataMap().put("success",success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(){
|
private void init(){
|
||||||
// start:生成临时Token到线程中
|
// start:生成临时Token到线程中
|
||||||
UserTokenContext.setToken(getTempToken());
|
UserTokenContext.setToken(getTempToken());
|
||||||
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
alarmClient = SpringContextUtils.getBean(AbnormalAlarmClient.class);
|
||||||
|
throw new RuntimeException("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroy(){
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.quartz.service;
|
package org.jeecg.modules.quartz.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public interface IQuartzJobService extends IService<QuartzJob> {
|
||||||
* @param quartzJob
|
* @param quartzJob
|
||||||
* @throws Exception
|
* @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;
|
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.common.constant.Prompt;
|
||||||
import org.jeecg.common.exception.JeecgBootException;
|
import org.jeecg.common.exception.JeecgBootException;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||||
|
@ -102,7 +106,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(QuartzJob quartzJob) throws Exception {
|
public Result<?> execute(QuartzJob quartzJob) throws Exception {
|
||||||
String jobName = quartzJob.getJobClassName().trim();
|
String jobName = quartzJob.getJobClassName().trim();
|
||||||
Date startDate = new Date();
|
Date startDate = new Date();
|
||||||
String ymd = DateUtils.date2Str(startDate,DateUtils.yyyymmddhhmmss.get());
|
String ymd = DateUtils.date2Str(startDate,DateUtils.yyyymmddhhmmss.get());
|
||||||
|
@ -117,11 +121,21 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||||
.startAt(startDate)
|
.startAt(startDate)
|
||||||
.build();
|
.build();
|
||||||
// 构建job信息
|
// 构建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 加入这个调度
|
// 将trigger和 jobDetail 加入这个调度
|
||||||
scheduler.scheduleJob(jobDetail, trigger);
|
scheduler.scheduleJob(jobDetail, trigger);
|
||||||
// 启动scheduler
|
// 启动scheduler
|
||||||
scheduler.start();
|
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
|
@Override
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
|
||||||
item.setDetectorName(detectorName);
|
item.setDetectorName(detectorName);
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(item.getStartTime())) {
|
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();
|
Date endDateTime = new Date();
|
||||||
endDateTime.setTime(endSecond*1000);
|
endDateTime.setTime(endSecond*1000);
|
||||||
item.setEndTime(endDateTime);
|
item.setEndTime(endDateTime);
|
||||||
|
@ -162,7 +162,7 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
|
||||||
Date startT = sohDatum.getStartTime();
|
Date startT = sohDatum.getStartTime();
|
||||||
if (ObjectUtil.isNotNull(startT)) {
|
if (ObjectUtil.isNotNull(startT)) {
|
||||||
long stratSecod = startT.getTime() / 1000;
|
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);
|
Date endDateTime = new Date(endSecond * 1000);
|
||||||
sohDatum.setEndTime(endDateTime);
|
sohDatum.setEndTime(endDateTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,4 @@ spring:
|
||||||
monitor:
|
monitor:
|
||||||
username: wmhr
|
username: wmhr
|
||||||
password: Wmhr.123
|
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