|
@@ -154,8 +154,6 @@ public class TaskController {
|
|
@Scheduled(cron = "0 0 9 * * ?")
|
|
@Scheduled(cron = "0 0 9 * * ?")
|
|
public void InfomationAlerts(){
|
|
public void InfomationAlerts(){
|
|
log.info("定时执行了11111===========>");
|
|
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<>();
|
|
QueryWrapper<Task> taskQueryWrapper = new QueryWrapper<>();
|
|
taskQueryWrapper.eq("is_delete",0).eq("is_repeat",1).ne("status",2).isNotNull("executor_id");
|
|
taskQueryWrapper.eq("is_delete",0).eq("is_repeat",1).ne("status",2).isNotNull("executor_id");
|
|
List<Task> list = taskService.list(taskQueryWrapper);
|
|
List<Task> list = taskService.list(taskQueryWrapper);
|
|
@@ -172,18 +170,18 @@ public class TaskController {
|
|
if (task.getRepeatType()!=null&&task.getRepeatType()==0){
|
|
if (task.getRepeatType()!=null&&task.getRepeatType()==0){
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
- saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
int between = task.getRepeatEndCount();
|
|
int between = task.getRepeatEndCount();
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//每周
|
|
//每周
|
|
@@ -192,11 +190,11 @@ public class TaskController {
|
|
//每周一才执行
|
|
//每周一才执行
|
|
if (LocalDateTime.now().getDayOfWeek().getValue()==1){
|
|
if (LocalDateTime.now().getDayOfWeek().getValue()==1){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
- saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
int between = task.getRepeatEndCount();
|
|
int between = task.getRepeatEndCount();
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
@@ -204,7 +202,7 @@ public class TaskController {
|
|
}
|
|
}
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
between=between/7;
|
|
between=between/7;
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
continue;
|
|
continue;
|
|
@@ -216,11 +214,11 @@ public class TaskController {
|
|
//每月一号才执行
|
|
//每月一号才执行
|
|
if (LocalDateTime.now().getDayOfMonth()==1){
|
|
if (LocalDateTime.now().getDayOfMonth()==1){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
- saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
int between = task.getRepeatEndCount();
|
|
int between = task.getRepeatEndCount();
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
@@ -228,7 +226,7 @@ public class TaskController {
|
|
}
|
|
}
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
between=between/30;
|
|
between=between/30;
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
continue;
|
|
continue;
|
|
@@ -241,11 +239,11 @@ public class TaskController {
|
|
int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
if (num%task.getRepeatDesignSameday()==0){
|
|
if (num%task.getRepeatDesignSameday()==0){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
|
|
- saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
}else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
int between = task.getRepeatEndCount();
|
|
int between = task.getRepeatEndCount();
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
}else if (task.getRepeatEndDate()!=null){
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
TaskInformation taskInformation = selectTaskInformation(task);
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
|
|
@@ -253,7 +251,7 @@ public class TaskController {
|
|
}
|
|
}
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
|
|
between=between/task.getRepeatDesignSameday();
|
|
between=between/task.getRepeatDesignSameday();
|
|
- saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListWithCount(task, taskInformation, between, executorIdList);
|
|
}
|
|
}
|
|
}else {
|
|
}else {
|
|
continue;
|
|
continue;
|
|
@@ -264,7 +262,7 @@ public class TaskController {
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
//获取任务重复结束 重复永不结束 1:勾选
|
|
int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
|
|
if (task.getRepeatDesignDay().contains(num+"")){
|
|
if (task.getRepeatDesignDay().contains(num+"")){
|
|
- saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}else {
|
|
}else {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -279,20 +277,20 @@ public class TaskController {
|
|
return taskInformationService.getOne(lqw);
|
|
return taskInformationService.getOne(lqw);
|
|
}
|
|
}
|
|
|
|
|
|
- private void saveInformationListWithCount(Task task, TaskInformation taskInformation, int between, List<String> executorIdList,WxCorpInfo corpInfo) {
|
|
|
|
|
|
+ private void saveInformationListWithCount(Task task, TaskInformation taskInformation, int between, List<String> executorIdList) {
|
|
if (taskInformation ==null){
|
|
if (taskInformation ==null){
|
|
TaskInformation taskInformationNew = new TaskInformation();
|
|
TaskInformation taskInformationNew = new TaskInformation();
|
|
taskInformationNew.setTaskId(task.getId())
|
|
taskInformationNew.setTaskId(task.getId())
|
|
.setCompanyId(task.getCompanyId()).setCount(between -1);
|
|
.setCompanyId(task.getCompanyId()).setCount(between -1);
|
|
taskInformationService.save(taskInformationNew);
|
|
taskInformationService.save(taskInformationNew);
|
|
- saveInformationListAndSendMsg(executorIdList,task,corpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}else {
|
|
}else {
|
|
Integer count = taskInformation.getCount();
|
|
Integer count = taskInformation.getCount();
|
|
if (count>0){
|
|
if (count>0){
|
|
count -= 1;
|
|
count -= 1;
|
|
UpdateWrapper<TaskInformation> updateWrapper = new UpdateWrapper<TaskInformation>().set("count", count).eq("id", taskInformation.getId());
|
|
UpdateWrapper<TaskInformation> updateWrapper = new UpdateWrapper<TaskInformation>().set("count", count).eq("id", taskInformation.getId());
|
|
taskInformationService.update(updateWrapper);
|
|
taskInformationService.update(updateWrapper);
|
|
- saveInformationListAndSendMsg(executorIdList,task,corpInfo);
|
|
|
|
|
|
+ saveInformationListAndSendMsg(executorIdList,task);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -316,7 +314,7 @@ public class TaskController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void saveInformationListAndSendMsg(List<String> executorIdList,Task task,WxCorpInfo corpinfo) {
|
|
|
|
|
|
+ private void saveInformationListAndSendMsg(List<String> executorIdList,Task task) {
|
|
if (!executorIdList.isEmpty()){
|
|
if (!executorIdList.isEmpty()){
|
|
ArrayList<Information> informationArrayList = new ArrayList<>();
|
|
ArrayList<Information> informationArrayList = new ArrayList<>();
|
|
String msg="你有新的任务:"+task.getTaskName();
|
|
String msg="你有新的任务:"+task.getTaskName();
|
|
@@ -331,7 +329,11 @@ public class TaskController {
|
|
.setTime(new Date()).setChecked(0);
|
|
.setTime(new Date()).setChecked(0);
|
|
informationArrayList.add(information);
|
|
informationArrayList.add(information);
|
|
User user = userMapper.selectById(userId);
|
|
User user = userMapper.selectById(userId);
|
|
- wxCorpInfoService.sendWXCorpMsg(corpinfo,user.getCorpwxUserid(),msg,null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK);
|
|
|
|
|
|
+ WxCorpInfo corpinfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ if (corpinfo!=null&&corpinfo.getSaasSyncContact()==1) {
|
|
|
|
+ wxCorpInfoService.sendWXCorpMsg(corpinfo, user.getCorpwxUserid(), msg, null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK);
|
|
|
|
+ log.info("给{}发送信息:{}",user.getCorpwxUserid(),msg);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
informationService.saveBatch(informationArrayList);
|
|
informationService.saveBatch(informationArrayList);
|
|
}
|
|
}
|