提交 cea5e8d8 authored 作者: zhoushaopan's avatar zhoushaopan

fix(自查模块): 自查完成终止系统发起的自查

自查完成终止系统发起的自查
上级 f1ba3b61
...@@ -13,6 +13,7 @@ import com.tykj.dev.misc.base.StatusEnum; ...@@ -13,6 +13,7 @@ import com.tykj.dev.misc.base.StatusEnum;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.support.CronTrigger; import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -28,6 +29,7 @@ import java.util.concurrent.ScheduledFuture; ...@@ -28,6 +29,7 @@ import java.util.concurrent.ScheduledFuture;
@Component @Component
@EnableAsync @EnableAsync
@Data @Data
@EnableScheduling
public class SelfCheckSchedulerTask { public class SelfCheckSchedulerTask {
// private String cron = "0 0 0 1 1/3 ? "; // private String cron = "0 0 0 1 1/3 ? ";
...@@ -47,17 +49,17 @@ public class SelfCheckSchedulerTask { ...@@ -47,17 +49,17 @@ public class SelfCheckSchedulerTask {
// //
// private String cron4 = "0 0/1 * * * ? "; // private String cron4 = "0 0/1 * * * ? ";
// //
final UnitsDao unitsDao; // final UnitsDao unitsDao;
//
final TaskService taskService; // final TaskService taskService;
//
final SystemVariableService systemVariableService; // final SystemVariableService systemVariableService;
//
final SystemVariableDao systemVariableDao; // final SystemVariableDao systemVariableDao;
//
final SelfCheckBillService selfCheckBillService; // final SelfCheckBillService selfCheckBillService;
//
private ScheduledFuture scheduledFuture; // private ScheduledFuture scheduledFuture;
// //
// //最终需求是改成每个季度的最后一个月的第一天开始执行 // //最终需求是改成每个季度的最后一个月的第一天开始执行
// private String corner = "0 0 0 1 3,9 ? *"; // private String corner = "0 0 0 1 3,9 ? *";
...@@ -175,47 +177,49 @@ public class SelfCheckSchedulerTask { ...@@ -175,47 +177,49 @@ public class SelfCheckSchedulerTask {
// scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(corner).nextExecutionTime(triggerContext)); // scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(corner).nextExecutionTime(triggerContext));
// } // }
@Scheduled(cron = "0 0 0 1 3,9 ?") // @Scheduled(cron = "0 0 0 1 3,9 ?")
public void selfCheckStart() { // public void selfCheckStart() {
if (unitsDao != null && taskService != null && selfCheckBillService != null) { // log.info("[自查模块]:开始自查定时任务执行了");
List<Units> unitsList = unitsDao.findAll(); // if (unitsDao != null && taskService != null && selfCheckBillService != null) {
unitsList.forEach(units -> { // List<Units> unitsList = unitsDao.findAll();
//添加账单 // unitsList.forEach(units -> {
SelfCheckBill selfCheckBill = new SelfCheckBill(); // //添加账单
selfCheckBill.setCheckStatus(3); // SelfCheckBill selfCheckBill = new SelfCheckBill();
selfCheckBill.setCheckUnit(units.getName()); // selfCheckBill.setCheckStatus(3);
selfCheckBill.setCheckUnitId(units.getUnitId()); // selfCheckBill.setCheckUnit(units.getName());
//add zsp // selfCheckBill.setCheckUnitId(units.getUnitId());
selfCheckBill.setStorageLocationId(0); // //add zsp
StringBuilder title = new StringBuilder(); // selfCheckBill.setStorageLocationId(0);
Calendar calendar = Calendar.getInstance(); // StringBuilder title = new StringBuilder();
calendar.setTime(new Date()); // Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR); // calendar.setTime(new Date());
int month = calendar.get(Calendar.MONTH) + 1; // int year = calendar.get(Calendar.YEAR);
title.append("系统发起定时") // int month = calendar.get(Calendar.MONTH) + 1;
.append(units.getName()) // title.append("系统发起定时")
.append(units.getName()) // .append(units.getName())
.append(year).append("年") // .append(units.getName())
.append(month).append("月自查任务"); // .append(year).append("年")
//修改为永远是季度发起 // .append(month).append("月自查任务");
selfCheckBill.setCycle(2); // //修改为永远是季度发起
selfCheckBill.setTitle(title.toString()); // selfCheckBill.setCycle(2);
SelfCheckBill selfCheckBill1 = selfCheckBillService.addEntity(selfCheckBill); // selfCheckBill.setTitle(title.toString());
//发起待自查任务 // SelfCheckBill selfCheckBill1 = selfCheckBillService.addEntity(selfCheckBill);
List<Integer> userIds = new ArrayList<>(); // //发起待自查任务
userIds.add(0); // List<Integer> userIds = new ArrayList<>();
TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id, title.toString(), null, ".", selfCheckBill1.getId(), 4, units.getUnitId(), 0, null, userIds); // userIds.add(0);
taskService.start(taskBto); // TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id, title.toString(), null, ".", selfCheckBill1.getId(), 4, units.getUnitId(), 0, null, userIds);
}); // taskService.start(taskBto);
log.info("[自查模块]:自查定时任务执行了"); // });
} // log.info("[自查模块]:自查定时任务执行了");
} // }
// log.info("[自查模块]:自查定时任务执行结束了");
@Scheduled(cron = "0 0 0 1 4,10 ?") // }
public void selfCheckEnd() { //
log.info("[自查模块]:自动完结自查定时任务准备执行"); // @Scheduled(cron = "0 0 0 1 4,10 ?")
selfCheckBillService.getNoFinShBySystem(); // public void selfCheckEnd() {
} // log.info("[自查模块]:自动完结自查定时任务准备执行");
// selfCheckBillService.getNoFinShBySystem();
// }
/** /**
* 当前月份属于本年第几个季度 * 当前月份属于本年第几个季度
......
package com.tykj.dev.device.selfcheck.config;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.misc.base.StatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author: zsp
* @create: 2023-09-21 13:04
**/
@Component
@Slf4j
@EnableScheduling
@EnableAsync
public class SelfCheckTask {
@Resource
private SelfCheckBillService selfCheckBillService;
@Resource
private TaskService taskService;
@Resource
private UnitsDao unitsDao;
@Scheduled(cron = "0 0 0 1 3,9 ?")
@Async
public void selfCheckStart() {
log.info("[自查模块]:开始自查定时任务执行了");
if (unitsDao != null && taskService != null && selfCheckBillService != null) {
List<Units> unitsList = unitsDao.findAll();
unitsList.forEach(units -> {
//添加账单
SelfCheckBill selfCheckBill = new SelfCheckBill();
selfCheckBill.setCheckStatus(3);
selfCheckBill.setCheckUnit(units.getName());
selfCheckBill.setCheckUnitId(units.getUnitId());
//add zsp
selfCheckBill.setStorageLocationId(0);
StringBuilder title = new StringBuilder();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
title.append("系统发起定时")
.append(units.getName())
.append(units.getName())
.append(year).append("年")
.append(month).append("月自查任务");
//修改为永远是季度发起
selfCheckBill.setCycle(2);
selfCheckBill.setTitle(title.toString());
SelfCheckBill selfCheckBill1 = selfCheckBillService.addEntity(selfCheckBill);
//发起待自查任务
List<Integer> userIds = new ArrayList<>();
userIds.add(0);
TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id, title.toString(), null, ".", selfCheckBill1.getId(), 4, units.getUnitId(), 0, null, userIds);
taskService.start(taskBto);
});
log.info("[自查模块]:自查定时任务执行了");
}
log.info("[自查模块]:自查定时任务执行结束了");
}
@Scheduled(cron = "0 0 0 1 4,10 ?")
@Async
public void selfCheckEnd() {
log.info("[自查模块]:自动完结自查定时任务准备执行");
selfCheckBillService.getNoFinShBySystem();
}
}
...@@ -1201,10 +1201,10 @@ public class SelfCheckController { ...@@ -1201,10 +1201,10 @@ public class SelfCheckController {
// Map<String, Object> detail = selfCheckBillService.selectDetail(billId); // Map<String, Object> detail = selfCheckBillService.selectDetail(billId);
// return ResultUtil.success(detail); // return ResultUtil.success(detail);
// } // }
@ApiOperation(value = "test", notes = "解析二维码") @ApiOperation(value = "生成定时任务", notes = "生成定时任务")
@PostMapping(value = "/test1") @GetMapping(value = "/test1")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity parseCode(@RequestBody List<String> strings) { public ResponseEntity test1() {
List<Units> unitsList = unitsDao.findAll(); List<Units> unitsList = unitsDao.findAll();
unitsList.forEach(units -> { unitsList.forEach(units -> {
//添加账单 //添加账单
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论