|
@@ -14,6 +14,7 @@ import com.management.platform.entity.dto.TaskDto;
|
|
|
import com.management.platform.entity.vo.SysRichFunction;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
|
+import com.management.platform.service.impl.WxCorpInfoServiceImpl;
|
|
|
import com.management.platform.util.DateTimeUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
@@ -62,6 +63,12 @@ public class TaskController {
|
|
|
private InformationService informationService;
|
|
|
@Resource
|
|
|
private TaskInformationService taskInformationService;
|
|
|
+ @Resource
|
|
|
+ WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
+ @Resource
|
|
|
+ WxCorpInfoService wxCorpInfoService;
|
|
|
+ @Resource
|
|
|
+ UserMapper userMapper;
|
|
|
|
|
|
|
|
|
|
|
@@ -147,6 +154,8 @@ public class TaskController {
|
|
|
@Scheduled(cron = "0 0 9 * * ?")
|
|
|
public void InfomationAlerts(){
|
|
|
log.info("定时执行了11111===========>");
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
QueryWrapper<Task> taskQueryWrapper = new QueryWrapper<>();
|
|
|
taskQueryWrapper.eq("is_delete",0).eq("is_repeat",1).ne("status",2).isNotNull("executor_id");
|
|
|
List<Task> list = taskService.list(taskQueryWrapper);
|
|
@@ -163,18 +172,18 @@ public class TaskController {
|
|
|
if (task.getRepeatType()!=null&&task.getRepeatType()==0){
|
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
- saveInformationList(executorIdList,task);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}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());
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}
|
|
|
}
|
|
|
//每周
|
|
@@ -183,11 +192,11 @@ public class TaskController {
|
|
|
//每周一才执行
|
|
|
if (LocalDateTime.now().getDayOfWeek().getValue()==1){
|
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
- saveInformationList(executorIdList,task);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
@@ -195,7 +204,7 @@ public class TaskController {
|
|
|
}
|
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
|
between=between/7;
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}
|
|
|
}else {
|
|
|
continue;
|
|
@@ -207,11 +216,11 @@ public class TaskController {
|
|
|
//每月一号才执行
|
|
|
if (LocalDateTime.now().getDayOfMonth()==1){
|
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
|
- saveInformationList(executorIdList,task);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
@@ -219,7 +228,7 @@ public class TaskController {
|
|
|
}
|
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
|
between=between/30;
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}
|
|
|
}else {
|
|
|
continue;
|
|
@@ -232,11 +241,11 @@ public class TaskController {
|
|
|
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);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
int between = task.getRepeatEndCount();
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
@@ -244,7 +253,7 @@ public class TaskController {
|
|
|
}
|
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
|
between=between/task.getRepeatDesignSameday();
|
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
}
|
|
|
}else {
|
|
|
continue;
|
|
@@ -255,7 +264,7 @@ public class TaskController {
|
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
|
int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
|
if (task.getRepeatDesignDay().contains(num+"")){
|
|
|
- saveInformationList(executorIdList,task);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
}else {
|
|
|
continue;
|
|
|
}
|
|
@@ -270,20 +279,20 @@ public class TaskController {
|
|
|
return taskInformationService.getOne(lqw);
|
|
|
}
|
|
|
|
|
|
- private void saveInformationListWithCount(Task task, TaskInformation taskInformation, int between, List<String> executorIdList) {
|
|
|
+ private void saveInformationListWithCount(Task task, TaskInformation taskInformation, int between, List<String> executorIdList,WxCorpInfo corpInfo) {
|
|
|
if (taskInformation ==null){
|
|
|
TaskInformation taskInformationNew = new TaskInformation();
|
|
|
taskInformationNew.setTaskId(task.getId())
|
|
|
.setCompanyId(task.getCompanyId()).setCount(between -1);
|
|
|
taskInformationService.save(taskInformationNew);
|
|
|
- saveInformationList(executorIdList,task);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,corpInfo);
|
|
|
}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,task);
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task,corpInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -307,5 +316,26 @@ public class TaskController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void saveInformationListAndSendMsg(List<String> executorIdList,Task task,WxCorpInfo corpinfo) {
|
|
|
+ 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(msg)
|
|
|
+ .setTime(new Date()).setChecked(0);
|
|
|
+ informationArrayList.add(information);
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
+ wxCorpInfoService.sendWXCorpMsg(corpinfo,user.getCorpwxUserid(),msg,null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK);
|
|
|
+ }
|
|
|
+ informationService.saveBatch(informationArrayList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|