|
@@ -144,12 +144,11 @@ public class TaskController {
|
|
|
/**
|
|
|
* 消息提醒
|
|
|
*/
|
|
|
-// @Scheduled(cron = "0 8 * * * ?")
|
|
|
- public void InfoMationAlerts(){
|
|
|
- log.info("定时执行了===========>");
|
|
|
+ @Scheduled(cron = "0 0 9 * * ?")
|
|
|
+ public void InfomationAlerts(){
|
|
|
+ log.info("定时执行了11111===========>");
|
|
|
QueryWrapper<Task> taskQueryWrapper = new QueryWrapper<>();
|
|
|
- //应该不用考虑任务的状态
|
|
|
- taskQueryWrapper.eq("is_delete",0).eq("is_repeat",1);
|
|
|
+ taskQueryWrapper.eq("is_delete",0).eq("is_repeat",1).ne("status",2).isNotNull("executor_id");
|
|
|
List<Task> list = taskService.list(taskQueryWrapper);
|
|
|
if (!list.isEmpty()){
|
|
|
for (Task task : list) {
|
|
@@ -164,7 +163,7 @@ public class TaskController {
|
|
|
if (task.getRepeatType()!=null&&task.getRepeatType()==0){
|
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
- saveInformationList(executorIdList);
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
@@ -184,7 +183,7 @@ public class TaskController {
|
|
|
//每周一才执行
|
|
|
if (LocalDateTime.now().getDayOfWeek().getValue()==1){
|
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
- saveInformationList(executorIdList);
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
@@ -208,7 +207,7 @@ public class TaskController {
|
|
|
//每月一号才执行
|
|
|
if (LocalDateTime.now().getDayOfMonth()==1){
|
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
- saveInformationList(executorIdList);
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
@@ -226,6 +225,41 @@ public class TaskController {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
+ //自定义周期
|
|
|
+ else if (task.getRepeatType() != null && task.getRepeatType() == 3 && task.getRepeatDesignSameday()!=null) {
|
|
|
+ //获取任务重复结束 重复永不结束 1:勾选
|
|
|
+ //每月一号才执行
|
|
|
+ int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
|
+ if (num%task.getRepeatDesignSameday()==0){
|
|
|
+ if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
+ }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
+ TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
+ int between = task.getRepeatEndCount();
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ }else if (task.getRepeatEndDate()!=null){
|
|
|
+ TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
+ if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
|
+ between=between/task.getRepeatDesignSameday();
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //自定义日期
|
|
|
+ else if (task.getRepeatType() != null && task.getRepeatType() == 4 && !StringUtils.isEmpty(task.getRepeatDesignDay())) {
|
|
|
+ //获取任务重复结束 重复永不结束 1:勾选
|
|
|
+ int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
|
+ if (task.getRepeatDesignDay().contains(num+"")){
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
+ }else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -242,24 +276,30 @@ public class TaskController {
|
|
|
taskInformationNew.setTaskId(task.getId())
|
|
|
.setCompanyId(task.getCompanyId()).setCount(between -1);
|
|
|
taskInformationService.save(taskInformationNew);
|
|
|
- saveInformationList(executorIdList);
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
}else {
|
|
|
Integer count = taskInformation.getCount();
|
|
|
if (count>0){
|
|
|
count -= 1;
|
|
|
UpdateWrapper<TaskInformation> updateWrapper = new UpdateWrapper<TaskInformation>().set("count", count).eq("id", taskInformation.getId());
|
|
|
taskInformationService.update(updateWrapper);
|
|
|
- saveInformationList(executorIdList);
|
|
|
+ saveInformationList(executorIdList,task);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void saveInformationList(List<String> executorIdList) {
|
|
|
+ private void saveInformationList(List<String> executorIdList,Task task) {
|
|
|
if (!executorIdList.isEmpty()){
|
|
|
ArrayList<Information> informationArrayList = new ArrayList<>();
|
|
|
+ String msg="你有新的任务:"+task.getTaskName();
|
|
|
+ if (task.getStatus()!=null&&task.getStatus()==1){
|
|
|
+ msg="你有任务:"+task.getTaskName()+"执行中";
|
|
|
+ } else if (task.getStatus() != null && task.getStatus() == 3) {
|
|
|
+ msg="你有任务:"+task.getTaskName()+"已逾期";
|
|
|
+ }
|
|
|
for (String userId : executorIdList) {
|
|
|
Information information = new Information();
|
|
|
- information.setUserId(userId).setMsg("任务提醒")
|
|
|
+ information.setUserId(userId).setMsg(msg)
|
|
|
.setTime(LocalDateTime.now()).setChecked(0);
|
|
|
informationArrayList.add(information);
|
|
|
}
|