feat:持久化监控项

This commit is contained in:
nieziyan 2023-08-22 16:52:26 +08:00
parent 72a8d901ea
commit 77bea6bda4
22 changed files with 272 additions and 135 deletions

View File

@ -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!";
}

View File

@ -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();
}
}

View File

@ -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")

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -19,8 +19,8 @@ public class CalculateConcController {
@GetMapping("caclAndSave")
@ApiOperation(value = "计算并保存核素浓度",notes = "计算并保存核素浓度")
public void caclAndSave(){
calculateConcService.calcAndSave();
public boolean caclAndSave(){
return calculateConcService.calcAndSave();
}
}

View File

@ -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 {
// --------------------后端专用-------------------

View File

@ -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">

View File

@ -8,7 +8,7 @@ import java.util.Map;
public interface CalculateConcService {
void calcAndSave();
boolean calcAndSave();
Map<String,String> calculate(List<ConcDto> concDtos, BigDecimal index);
}

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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);
}

View File

@ -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("执行成功!");
}
}

View File

@ -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(){

View File

@ -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(){

View File

@ -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();
}
}

View File

@ -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;
/**
* 暂停任务

View File

@ -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

View File

@ -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);
}

View File

@ -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