Browse Source

fit: 模型限时自动下发

main
wxc 1 year ago
parent
commit
82aa438f33
  1. 22
      src/main/java/com/biutag/supervision/config/ScheduledConfig.java
  2. 10
      src/main/java/com/biutag/supervision/constants/enums/DistributionCycleEnum.java
  3. 17
      src/main/java/com/biutag/supervision/constants/enums/DistributionFlowEnum.java
  4. 23
      src/main/java/com/biutag/supervision/constants/enums/DistributionMethodEnum.java
  5. 20
      src/main/java/com/biutag/supervision/constants/enums/ModelDistributionStateEnum.java
  6. 3
      src/main/java/com/biutag/supervision/constants/enums/ProblemSourcesEnum.java
  7. 2
      src/main/java/com/biutag/supervision/controller/LoginController.java
  8. 19
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelController.java
  9. 4
      src/main/java/com/biutag/supervision/mapper/BaseAccountMapper.java
  10. 3
      src/main/java/com/biutag/supervision/pojo/entity/Model.java
  11. 11
      src/main/java/com/biutag/supervision/pojo/entity/ModelClue.java
  12. 7
      src/main/java/com/biutag/supervision/pojo/param/ModelClueQueryParam.java
  13. 4
      src/main/java/com/biutag/supervision/service/BaseAccountService.java
  14. 76
      src/main/java/com/biutag/supervision/service/ModelClueService.java
  15. 46
      src/main/java/com/biutag/supervision/service/ModelService.java
  16. 78
      src/main/java/com/biutag/supervision/support/ModelClueDistributionAware.java
  17. 45
      src/main/java/com/biutag/supervision/support/ModelEditAspect.java
  18. 22
      src/main/java/com/biutag/supervision/util/ExpressionBuilder.java
  19. 33
      src/test/java/com/biutag/supervision/SupervisionApplicationTests.java

22
src/main/java/com/biutag/supervision/config/ScheduledConfig.java

@ -0,0 +1,22 @@
package com.biutag.supervision.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
/**
* @author wxc
* @date 2024/10/17
*/
@Configuration
public class ScheduledConfig {
@Bean
public ScheduledTaskRegistrar scheduledTaskRegistrar(TaskScheduler taskScheduler) {
ScheduledTaskRegistrar scheduledTaskRegistrar = new ScheduledTaskRegistrar();
scheduledTaskRegistrar.setTaskScheduler(taskScheduler);
return scheduledTaskRegistrar;
}
}

10
src/main/java/com/biutag/supervision/constants/enums/DistributionCycleEnum.java

@ -0,0 +1,10 @@
package com.biutag.supervision.constants.enums;
/**
* @author wxc
* @date 2024/10/17
*/
public enum DistributionCycleEnum {
day,
weekly
}

17
src/main/java/com/biutag/supervision/constants/enums/DistributionFlowEnum.java

@ -0,0 +1,17 @@
package com.biutag.supervision.constants.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wxc
* @date 2024/10/17
*/
@AllArgsConstructor
@Getter
public enum DistributionFlowEnum {
SECOND("2"),
THIRD("3");
private String value;
}

23
src/main/java/com/biutag/supervision/constants/enums/DistributionMethodEnum.java

@ -0,0 +1,23 @@
package com.biutag.supervision.constants.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wxc
* @date 2024/10/17
*/
@AllArgsConstructor
@Getter
public enum DistributionMethodEnum {
// 问题下发
NEGATIVE_DISTRIBUTE("1"),
// 数据保存
DATA_SAVE("2"),
// 预警通知
WARNING_NOTIFICATION("3");
private String value;
}

20
src/main/java/com/biutag/supervision/constants/enums/ModelDistributionStateEnum.java

@ -0,0 +1,20 @@
package com.biutag.supervision.constants.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author wxc
* @date 2024/10/17
*/
@AllArgsConstructor
public enum ModelDistributionStateEnum {
// 未分发
UNDISTRIBUTED("0"),
// 已分发
DISTRIBUTED("1");
@Getter
private String value;
}

3
src/main/java/com/biutag/supervision/constants/enums/ProblemSourcesEnum.java

@ -28,7 +28,8 @@ public enum ProblemSourcesEnum {
JYDC("警意调查", "3"),
CFJD("持法监督", "4"),
JCKH("检查考核", "8"),
QT("其他", "9");
QT("其他", "9"),
MXCS("模型超市", "10");
private String label;

2
src/main/java/com/biutag/supervision/controller/LoginController.java

@ -39,7 +39,7 @@ public class LoginController {
@Operation(summary = "登录")
@PostMapping("login")
public Result<TokenVo> login(@RequestBody AccountDto account) {
BaseAccount baseAccount = accountService.getByAccount(account.getAccount());
BaseAccount baseAccount = accountService.getByLogin(account.getAccount());
try {
if (Objects.isNull(baseAccount) || !BCrypt.checkpw(account.getPassword(), baseAccount.getPassword())) {
throw new RuntimeException("用户名或密码有误,请重新输入");

19
src/main/java/com/biutag/supervision/controller/sensitivePerception/ModelController.java

@ -3,11 +3,9 @@ package com.biutag.supervision.controller.sensitivePerception;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.common.UserContextHolder;
import com.biutag.supervision.pojo.Result;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.ModelClass;
import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.pojo.param.ModelQueryParam;
import com.biutag.supervision.pojo.vo.ModelTree;
import com.biutag.supervision.service.ModelClassService;
@ -15,7 +13,6 @@ import com.biutag.supervision.service.ModelService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -59,26 +56,20 @@ public class ModelController {
}
@PostMapping
public Result<Void> add(@RequestBody Model model) {
model.setCreateTime(LocalDateTime.now());
model.setUpdateTime(LocalDateTime.now());
UserAuth user = UserContextHolder.getCurrentUser();
model.setCreateDepartId(user.getDepartId());
model.setCreateDepartName(user.getDepartName());
modelService.save(model);
return Result.success();
public Result<Boolean> add(@RequestBody Model model) {
return Result.success(modelService.saveModel(model));
}
@PutMapping
public Result<Model> update(@RequestBody Model model) {
model.setUpdateTime(LocalDateTime.now());
modelService.updateById(model);
modelService.updateModel(model);
return Result.success(model);
}
@DeleteMapping("{id}")
public Result<Boolean> del(@PathVariable Integer id) {
return Result.success(modelService.removeById(id));
return Result.success(modelService.remove(id));
}
}

4
src/main/java/com/biutag/supervision/mapper/BaseAccountMapper.java

@ -3,8 +3,12 @@ package com.biutag.supervision.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.BaseAccount;
import org.apache.ibatis.annotations.Select;
@DS("slave")
public interface BaseAccountMapper extends BaseMapper<BaseAccount> {
@Select("select a.* from base_account a left join negative.sup_police p on a.account = p.id_code where a.account = #{account} or p.emp_no = #{account}")
BaseAccount selectByLogin(String account);
}

3
src/main/java/com/biutag/supervision/pojo/entity/Model.java

@ -45,6 +45,9 @@ public class Model {
// 分发周期 时间
private String distributionCycleTime;
// 分发周期,cron 表达式
private String distributionCycleExpression;
// 限时
@TableField("time_limit")
private String timeLimit;

11
src/main/java/com/biutag/supervision/pojo/entity/ModelClue.java

@ -27,20 +27,25 @@ public class ModelClue {
private String involveDepartId;
// 涉及人员
@TableField("involve_personnel_name")
private String involvePersonnelName;
private String involvePoliceName;
// 涉及人员警号
private String involvePoliceEmpNo;
// 预警内容
@TableField("thing_desc")
private String thingDesc;
// 分发状态
// 分发状态 默认 0-未分发 1-已分发
@TableField("distribution_state")
private String distributionState;
@TableField("create_time")
private LocalDateTime createTime;
private LocalDateTime updateTime;
// 数据详情 JSON
private String data;
}

7
src/main/java/com/biutag/supervision/pojo/param/ModelClueQueryParam.java

@ -1,9 +1,13 @@
package com.biutag.supervision.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -16,7 +20,8 @@ public class ModelClueQueryParam extends BasePage {
private Integer modelId;
private String modelType;
private List<LocalDateTime> createTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private List<Date> createTime = new ArrayList<>();
private Integer involveDepartId;
private String thingDesc;
private String distributionState;

4
src/main/java/com/biutag/supervision/service/BaseAccountService.java

@ -13,4 +13,8 @@ public class BaseAccountService extends ServiceImpl<BaseAccountMapper, BaseAccou
return getOne(new LambdaQueryWrapper<BaseAccount>().eq(BaseAccount::getAccount, account));
}
public BaseAccount getByLogin(String account) {
return baseMapper.selectByLogin(account);
}
}

76
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -5,14 +5,19 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.constants.enums.*;
import com.biutag.supervision.mapper.ModelClueMapper;
import com.biutag.supervision.mapper.ModelMapper;
import com.biutag.supervision.pojo.dto.NegativeDto;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.entity.ModelClue;
import com.biutag.supervision.mapper.ModelClueMapper;
import com.biutag.supervision.pojo.entity.SupDepart;
import com.biutag.supervision.pojo.model.ModelClueModel;
import com.biutag.supervision.pojo.param.ModelClueQueryParam;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -23,7 +28,11 @@ import java.util.stream.Collectors;
@Service
public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
private final ModelService modelService;
private final ModelMapper modelMapper;
private final NegativeService negativeService;
public final SupDepartService departService;
public Page<ModelClueModel> page(ModelClueQueryParam param) {
LambdaQueryWrapper<ModelClue> queryWrapper = new LambdaQueryWrapper<ModelClue>()
@ -31,12 +40,15 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
.eq(StrUtil.isNotBlank(param.getDistributionState()), ModelClue::getDistributionState, param.getDistributionState())
.like(StrUtil.isNotBlank(param.getThingDesc()), ModelClue::getThingDesc, param.getThingDesc())
.orderByDesc(ModelClue::getCreateTime);
if (Objects.nonNull(param.getCreateTime()) && param.getCreateTime().size() == 2) {
queryWrapper.between(ModelClue::getCreateTime, param.getCreateTime().get(0), param.getCreateTime().get(1));
}
Page<ModelClue> page = page(Page.of(param.getCurrent(), param.getSize()), queryWrapper);
if (page.getRecords().isEmpty()) {
return new Page<ModelClueModel>().setRecords(new ArrayList<>()).setTotal(0);
}
Set<Integer> modelIds = page.getRecords().stream().map(ModelClue::getModelId).collect(Collectors.toSet());
List<Model> models = modelService.listByIds(modelIds);
List<Model> models = modelMapper.selectBatchIds(modelIds);
List<ModelClueModel> list = page.getRecords().stream().map(item -> {
ModelClueModel modelClueModel = new ModelClueModel();
BeanUtil.copyProperties(item, modelClueModel);
@ -47,4 +59,62 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
return new Page<ModelClueModel>().setRecords(list).setTotal(page.getTotal());
}
public List<ModelClue> listByUnDistributed(Integer modelId) {
return list(new LambdaQueryWrapper<ModelClue>().eq(ModelClue::getModelId, modelId).eq(ModelClue::getDistributionState, ModelDistributionStateEnum.UNDISTRIBUTED.getValue()));
}
public boolean distribution(Integer modelId) {
List<ModelClue> modelClues = listByUnDistributed(modelId);
Model model = modelMapper.selectById(modelId);
modelClues.forEach(item -> {
if (Objects.isNull(item.getInvolveDepartId())) {
throw new RuntimeException("涉及单位不能为空...");
}
NegativeDto negative = new NegativeDto();
// 问题来源
negative.setProblemSourcesCode(ProblemSourcesEnum.MXCS.getValue());
negative.setProblemSourcesCode(ProblemSourcesEnum.MXCS.getLabel());
// TODO 业务类别 涉及问题
// 涉及单位
negative.setInvolveDepartId(item.getInvolveDepartId());
negative.setInvolveDepartName(item.getInvolveDepartName());
// 问题发生时间
negative.setHappenTime(item.getCreateTime());
// 问题发现时间
negative.setDiscoveryTime(item.getCreateTime());
// 事情简要描述
negative.setThingDesc(item.getThingDesc());
// 主办层级
negative.setHostLevel(HostLevelEnums.THREE.getValue());
// 办理单位
SupDepart depart = departService.getById(item.getInvolveDepartId());
if (depart.getLevel().equals(DepartLevelEnum.SECOND.getValue())) {
negative.setDepartId(depart.getId());
negative.setDepartId(depart.getName());
}
if (depart.getLevel().equals(DepartLevelEnum.THREE.getValue()) && Objects.equals(model.getDistributionFlow(), DistributionFlowEnum.SECOND.getValue())) {
SupDepart parentDepart = departService.getParentDepart(item.getInvolveDepartId());
negative.setDepartId(parentDepart.getId());
negative.setDepartId(parentDepart.getName());
}
if (depart.getLevel().equals(DepartLevelEnum.THREE.getValue()) && Objects.equals(model.getDistributionFlow(), DistributionFlowEnum.THIRD.getValue())) {
negative.setDepartId(depart.getId());
negative.setDepartId(depart.getName());
}
negative.setTimeLimit(model.getTimeLimit());
negative.setMaxSignDuration(model.getMaxSignDuration());
negative.setMaxHandleDuration(model.getMaxHandleDuration());
negative.setMaxExtensionDuration(model.getMaxExtensionDuration());
// 审批流程
negative.setApprovalFlow(model.getApprovalFlow());
negativeService.save(negative);
item.setDistributionState(ModelDistributionStateEnum.DISTRIBUTED.getValue());
item.setUpdateTime(LocalDateTime.now());
updateById(item);
});
return true;
}
}

46
src/main/java/com/biutag/supervision/service/ModelService.java

@ -1,11 +1,55 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.common.UserContextHolder;
import com.biutag.supervision.constants.enums.DistributionCycleEnum;
import com.biutag.supervision.constants.enums.DistributionMethodEnum;
import com.biutag.supervision.mapper.ModelMapper;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.util.ExpressionBuilder;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
@RequiredArgsConstructor
@Service
public class ModelService extends ServiceImpl<ModelMapper, Model> {
public List<Model> listByDistributionMethodOfNegative() {
return list(new LambdaQueryWrapper<Model>().eq(Model::getDistributionMethod, DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue()));
}
public boolean saveModel(Model model) {
if (DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue().equals(model.getDistributionMethod())) {
String expression = DistributionCycleEnum.day.name().equals(model.getDistributionCycle()) ? ExpressionBuilder.build(model.getDistributionCycleTime()) :
ExpressionBuilder.build(model.getDistributionCycleTime(), model.getDistributionCycleDayOfWeek());
model.setDistributionCycleExpression(expression);
}
model.setCreateTime(LocalDateTime.now());
model.setUpdateTime(LocalDateTime.now());
UserAuth user = UserContextHolder.getCurrentUser();
model.setCreateDepartId(user.getDepartId());
model.setCreateDepartName(user.getDepartName());
boolean save = save(model);
return save;
}
public boolean updateModel(Model model) {
if (DistributionMethodEnum.NEGATIVE_DISTRIBUTE.getValue().equals(model.getDistributionMethod())) {
String expression = DistributionCycleEnum.day.name().equals(model.getDistributionCycle()) ? ExpressionBuilder.build(model.getDistributionCycleTime()) :
ExpressionBuilder.build(model.getDistributionCycleTime(), model.getDistributionCycleDayOfWeek());
model.setDistributionCycleExpression(expression);
}
model.setUpdateTime(LocalDateTime.now());
return updateById(model);
}
public boolean remove(Integer modelId) {
return removeById(modelId);
}
}

78
src/main/java/com/biutag/supervision/support/ModelClueDistributionAware.java

@ -0,0 +1,78 @@
package com.biutag.supervision.support;
import cn.hutool.core.util.StrUtil;
import com.biutag.supervision.pojo.entity.Model;
import com.biutag.supervision.service.ModelClueService;
import com.biutag.supervision.service.ModelService;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.ScheduledTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
* 模型线索数据分发
* @author wxc
* @date 2024/10/17
*/
@Slf4j
@RequiredArgsConstructor
@Component
public class ModelClueDistributionAware {
private final ScheduledTaskRegistrar taskRegistrar;
private final Map<Integer, ScheduledTask> taskMap = new ConcurrentHashMap<>();
private final ModelService modelService;
private final ModelClueService modelClueService;
@PostConstruct
public void init() {
log.info("初始化模型分发任务-------------------------------------------");
List<Model> models = modelService.listByDistributionMethodOfNegative();
for (Model model : models) {
try {
put(model);
} catch (RuntimeException e) {
log.info("模型分发异常", e);
}
}
}
public void put(Model model) {
log.info("新增模型【{}】分发任务", model.getModelName());
String expression = model.getDistributionCycleExpression();
if (StrUtil.isBlank(expression)) {
throw new RuntimeException("分发周期配置[expression]为空");
}
if (taskMap.containsKey(model.getId())) {
remove(model.getId());
}
Runnable task = () -> {
log.info("开始执行任务-------------------------------------------");
// 线索下发
modelClueService.distribution(model.getId());
};
log.info("expression : {}", expression);
ScheduledTask scheduledTask = taskRegistrar.scheduleTriggerTask(new CronTask(task, expression));
taskMap.put(model.getId(), scheduledTask);
}
public void remove(Integer key) {
log.info("移除模型【{}】分发任务", key);
ScheduledTask scheduledTask = taskMap.get(key);
if (Objects.nonNull(scheduledTask)) {
scheduledTask.cancel();
taskMap.remove(key);
}
}
}

45
src/main/java/com/biutag/supervision/support/ModelEditAspect.java

@ -0,0 +1,45 @@
package com.biutag.supervision.support;
import com.biutag.supervision.pojo.entity.Model;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
/**
* @author wxc
* @date 2024/10/17
*/
@Slf4j
@RequiredArgsConstructor
@Aspect
@Component
public class ModelEditAspect {
private final ModelClueDistributionAware modelClueDistributionAware;
@Pointcut("execution(* com.biutag.supervision.service.ModelService.saveModel(..))")
public void saveMethod() {}
@Pointcut("execution(* com.biutag.supervision.service.ModelService.updateModel(..))")
public void updateMethod() {}
@Pointcut("execution(* com.biutag.supervision.service.ModelService.remove(Integer))")
public void removeMethod() {}
@After("saveMethod() || updateMethod()")
public void afterSaveOrUpdateAdvice(JoinPoint joinPoint) {
Model model = (Model) joinPoint.getArgs()[0];
modelClueDistributionAware.put(model);
log.info("afterSaveOrUpdateAdvice---------------");
}
@After("removeMethod()")
public void afterRemove(JoinPoint joinPoint) {
Integer modelId = (Integer) joinPoint.getArgs()[0];
modelClueDistributionAware.remove(modelId);
log.info("afterRemove---------------");
}
}

22
src/main/java/com/biutag/supervision/util/ExpressionBuilder.java

@ -0,0 +1,22 @@
package com.biutag.supervision.util;
import java.util.Optional;
/**
* @author wxc
* @date 2024/10/17
*/
public class ExpressionBuilder {
public static String build(String time) {
return build(time, null);
}
public static String build(String time, String week) {
String expressionFormat = "%s %s %s * * %s";
String[] split = time.split(":");
String weekArg = Optional.ofNullable(week).orElse("*");
return String.format(expressionFormat, Integer.parseInt(split[2]), Integer.parseInt(split[1]), Integer.parseInt(split[0]), weekArg);
}
}

33
src/test/java/com/biutag/supervision/SupervisionApplicationTests.java

@ -1,16 +1,17 @@
package com.biutag.supervision;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.AppendFileStorageClient;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.time.LocalDateTime;
import java.util.Date;
@SpringBootTest
class SupervisionApplicationTests {
@ -18,12 +19,24 @@ class SupervisionApplicationTests {
@Autowired
private FastFileStorageClient fastFileStorageClient;
@Autowired
private ScheduledTaskRegistrar taskRegistrar;
@Autowired
private TaskScheduler taskScheduler;
@Test
void contextLoads() throws FileNotFoundException {
File file = new File("D:\\deploy\\response.txt");
StorePath storePath = fastFileStorageClient.uploadFile("group1", new FileInputStream(file), file.length(), "txt");
System.out.println(storePath);
void contextLoads() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(5);
scheduler.setThreadNamePrefix("scheduled-task-");
scheduler.initialize();
Runnable runnable = () -> {
System.out.println("Executing task at " + LocalDateTime.now());
};
taskRegistrar.setTaskScheduler(scheduler);
taskRegistrar.addTriggerTask(runnable, new CronTrigger("0 2 * * * ?"));
}
}

Loading…
Cancel
Save