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

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

自查完成终止系统发起的自查
上级 f1ba3b61
......@@ -13,6 +13,7 @@ import com.tykj.dev.misc.base.StatusEnum;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
......@@ -28,6 +29,7 @@ import java.util.concurrent.ScheduledFuture;
@Component
@EnableAsync
@Data
@EnableScheduling
public class SelfCheckSchedulerTask {
// private String cron = "0 0 0 1 1/3 ? ";
......@@ -47,17 +49,17 @@ public class SelfCheckSchedulerTask {
//
// private String cron4 = "0 0/1 * * * ? ";
//
final UnitsDao unitsDao;
final TaskService taskService;
final SystemVariableService systemVariableService;
final SystemVariableDao systemVariableDao;
final SelfCheckBillService selfCheckBillService;
private ScheduledFuture scheduledFuture;
// final UnitsDao unitsDao;
//
// final TaskService taskService;
//
// final SystemVariableService systemVariableService;
//
// final SystemVariableDao systemVariableDao;
//
// final SelfCheckBillService selfCheckBillService;
//
// private ScheduledFuture scheduledFuture;
//
// //最终需求是改成每个季度的最后一个月的第一天开始执行
// private String corner = "0 0 0 1 3,9 ? *";
......@@ -175,47 +177,49 @@ public class SelfCheckSchedulerTask {
// scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(corner).nextExecutionTime(triggerContext));
// }
@Scheduled(cron = "0 0 0 1 3,9 ?")
public void selfCheckStart() {
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("[自查模块]:自查定时任务执行了");
}
}
@Scheduled(cron = "0 0 0 1 4,10 ?")
public void selfCheckEnd() {
log.info("[自查模块]:自动完结自查定时任务准备执行");
selfCheckBillService.getNoFinShBySystem();
}
// @Scheduled(cron = "0 0 0 1 3,9 ?")
// 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 ?")
// 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 {
// Map<String, Object> detail = selfCheckBillService.selectDetail(billId);
// return ResultUtil.success(detail);
// }
@ApiOperation(value = "test", notes = "解析二维码")
@PostMapping(value = "/test1")
@ApiOperation(value = "生成定时任务", notes = "生成定时任务")
@GetMapping(value = "/test1")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity parseCode(@RequestBody List<String> strings) {
public ResponseEntity test1() {
List<Units> unitsList = unitsDao.findAll();
unitsList.forEach(units -> {
//添加账单
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论