yusm преди 5 месеца
родител
ревизия
31a31a92e8

+ 22 - 20
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/TaskController.java

@@ -154,8 +154,6 @@ 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);
@@ -172,18 +170,18 @@ public class TaskController {
                 if (task.getRepeatType()!=null&&task.getRepeatType()==0){
                     //获取任务重复结束 重复永不结束   1:勾选
                     if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                        saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
+                        saveInformationListAndSendMsg(executorIdList,task);
                     }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                         TaskInformation taskInformation = selectTaskInformation(task);
                         int between = task.getRepeatEndCount();
-                        saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                        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());
-                        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 (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                            saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
+                            saveInformationListAndSendMsg(executorIdList,task);
                         }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             int between = task.getRepeatEndCount();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
                         }else if (task.getRepeatEndDate()!=null){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
@@ -204,7 +202,7 @@ public class TaskController {
                             }
                             int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
                             between=between/7;
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
                         }
                     }else {
                         continue;
@@ -216,11 +214,11 @@ public class TaskController {
                     //每月一号才执行
                     if (LocalDateTime.now().getDayOfMonth()==1){
                         if (task.getRepeatEndNever()!=null&&task.getRepeatEndNever()==1){
-                            saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
+                            saveInformationListAndSendMsg(executorIdList,task);
                         }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             int between = task.getRepeatEndCount();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
                         }else if (task.getRepeatEndDate()!=null){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
@@ -228,7 +226,7 @@ public class TaskController {
                             }
                             int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
                             between=between/30;
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
                         }
                     }else {
                         continue;
@@ -241,11 +239,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){
-                            saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
+                            saveInformationListAndSendMsg(executorIdList,task);
                         }else if (task.getRepeatEndCount()!=null&&task.getRepeatEndCount()>0){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             int between = task.getRepeatEndCount();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
                         }else if (task.getRepeatEndDate()!=null){
                             TaskInformation taskInformation = selectTaskInformation(task);
                             if (LocalDateTime.now().isAfter(task.getRepeatEndDate())){
@@ -253,7 +251,7 @@ public class TaskController {
                             }
                             int between = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getRepeatEndDate());
                             between=between/task.getRepeatDesignSameday();
-                            saveInformationListWithCount(task, taskInformation, between, executorIdList,wxCorpInfo);
+                            saveInformationListWithCount(task, taskInformation, between, executorIdList);
                         }
                     }else {
                         continue;
@@ -264,7 +262,7 @@ public class TaskController {
                     //获取任务重复结束 重复永不结束   1:勾选
                     int num = (int) ChronoUnit.DAYS.between(LocalDateTime.now(), task.getCreateDate());
                     if (task.getRepeatDesignDay().contains(num+"")){
-                        saveInformationListAndSendMsg(executorIdList,task,wxCorpInfo);
+                        saveInformationListAndSendMsg(executorIdList,task);
                     }else {
                         continue;
                     }
@@ -279,20 +277,20 @@ public class TaskController {
         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){
             TaskInformation taskInformationNew = new TaskInformation();
             taskInformationNew.setTaskId(task.getId())
                     .setCompanyId(task.getCompanyId()).setCount(between -1);
             taskInformationService.save(taskInformationNew);
-            saveInformationListAndSendMsg(executorIdList,task,corpInfo);
+            saveInformationListAndSendMsg(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);
-                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()){
             ArrayList<Information> informationArrayList = new ArrayList<>();
             String msg="你有新的任务:"+task.getTaskName();
@@ -331,7 +329,11 @@ public class TaskController {
                         .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);
+                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);
         }

+ 4 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Task.java

@@ -3,6 +3,8 @@ package com.management.platform.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
@@ -182,7 +184,7 @@ public class Task extends Model<Task> {
     @JsonFormat(pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @TableField("end_date")
-    private LocalDateTime endDate;
+    private LocalDate endDate;
 
     /**
      * 开始日期
@@ -190,7 +192,7 @@ public class Task extends Model<Task> {
     @JsonFormat(pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @TableField("start_date")
-    private LocalDateTime startDate;
+    private LocalDate startDate;
 
     /**
      * 完成日期

+ 25 - 20
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -111,6 +111,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     @Resource
     private InformationService informationService;
 
+    @Resource
+    private WxCorpInfoMapper wxCorpInfoMapper;
 
 
     @Override
@@ -124,7 +126,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             httpRespMsg.setError("无法获取创建人信息!");
             return httpRespMsg;
         }
-
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
         if (StringUtils.isEmpty(taskDto.getTaskName())||taskDto.getPriority()==null){
             httpRespMsg.setError("缺少任务名称或任务优先级!");
             return httpRespMsg;
@@ -133,11 +135,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         BeanUtils.copyProperties(taskDto,task);
         task.setCreateDate(LocalDateTime.now());//任务的创建时间
         //根据任务的开始时间与当下时间判断任务的状态
-        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDateTime.now())){
+        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDate.now())){
             task.setStatus(0);
-        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDateTime.now())){
+        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDate.now())){
             task.setStatus(3);
-        } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDateTime.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDateTime.now()))
+        } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDate.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDate.now()))
         {
             task.setStatus(1);
         }
@@ -174,6 +176,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             information.setTime(new Date()).setChecked(0).setMsg("你有新的任务");
             informationArrayList.add(information);
             informationService.saveBatch(informationArrayList);
+            if (wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,user.getCorpwxUserid(),"你有新的任务",null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK);
+            }
         }
 
         //添加任务编译记录
@@ -286,11 +291,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             msg.setError("请保证时间段的顺序性");
             return msg;
         }
-        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDateTime.now())){
+        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDate.now())){
             task.setStatus(0);
-        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDateTime.now())){
+        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDate.now())){
             task.setStatus(3);
-        } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDateTime.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDateTime.now()))
+        } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDate.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDate.now()))
         {
             task.setStatus(1);
         }
@@ -590,7 +595,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                     // Excel中的日期序列号的基准日期是1900年1月1日
                                     LocalDate baseDate = LocalDate.of(1900, 1, 1);
                                     LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
-                                    task.setStartDate(date.atStartOfDay());
+                                    task.setStartDate(date);
 
                                 } catch (Exception e) {
                                     System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
@@ -608,7 +613,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                     // Excel中的日期序列号的基准日期是1900年1月1日
                                     LocalDate baseDate = LocalDate.of(1900, 1, 1);
                                     LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
-                                    task.setEndDate(date.atStartOfDay());
+                                    task.setEndDate(date);
 
                                 } catch (Exception e) {
                                     System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
@@ -810,11 +815,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                         msg.setError("任务:"+task.getTaskName()+"中客户/商机/销售订单不应一同存在");
                         return msg;
                     }
-                    if (task.getStartDate()!=null&&task.getStartDate().isAfter(LocalDateTime.now())){
+                    if (task.getStartDate()!=null&&task.getStartDate().isAfter(LocalDate.now())){
                         task.setStatus(0);
-                    }else if (task.getEndDate()!=null&&task.getEndDate().isBefore(LocalDateTime.now())){
+                    }else if (task.getEndDate()!=null&&task.getEndDate().isBefore(LocalDate.now())){
                         task.setStatus(3);
-                    } else if (task.getStartDate()!=null&&task.getStartDate().isBefore(LocalDateTime.now())&&task.getEndDate()!=null&&task.getEndDate().isAfter(LocalDateTime.now()))
+                    } else if (task.getStartDate()!=null&&task.getStartDate().isBefore(LocalDate.now())&&task.getEndDate()!=null&&task.getEndDate().isAfter(LocalDate.now()))
                     {
                         task.setStatus(1);
                     }
@@ -1013,18 +1018,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 }
                 else if(model.equals("startDate")){
                     if (tasKVo.getStartDate()!=null){
-                        LocalDateTime startDate = tasKVo.getStartDate();
+                        LocalDate startDate = tasKVo.getStartDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                         // 格式化为字符串
                         value= startDate.format(formatter);
                     }
                 }
                 else if(model.equals("endDate")){
                     if (tasKVo.getEndDate()!=null){
-                        LocalDateTime endDate = tasKVo.getEndDate();
+                        LocalDate endDate = tasKVo.getEndDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                         // 格式化为字符串
                         value= endDate.format(formatter);
                     }
@@ -1165,18 +1170,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 }
                 else if(model.equals("startDate")){
                     if (tasKVo.getStartDate()!=null){
-                        LocalDateTime startDate = tasKVo.getStartDate();
+                        LocalDate startDate = tasKVo.getStartDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                         // 格式化为字符串
                         value= startDate.format(formatter);
                     }
                 }
                 else if(model.equals("endDate")){
                     if (tasKVo.getEndDate()!=null){
-                        LocalDateTime endDate = tasKVo.getEndDate();
+                        LocalDate endDate = tasKVo.getEndDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                         // 格式化为字符串
                         value= endDate.format(formatter);
                     }