浏览代码

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

Lijy 10 月之前
父节点
当前提交
4314fc0d9d

+ 52 - 12
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/TaskController.java

@@ -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);
             }

+ 2 - 8
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Information.java

@@ -6,8 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -18,7 +16,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author Seyason
- * @since 2021-05-17
+ * @since 2024-07-05
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -40,7 +38,7 @@ public class Information extends Model<Information> {
     private String userId;
 
     /**
-     * 类型 0-审批未通过或撤销,1-任务待执行, 2-任务有进展
+     * 类型 0-审批未通过或撤销,1-任务待执行, 2-任务有进展,3-费用报销待审核 4-合同被驳回,5-合同审核通过,6-合同待审核
      */
     @TableField("type")
     private Integer type;
@@ -55,7 +53,6 @@ public class Information extends Model<Information> {
      * 时间
      */
     @TableField("time")
-    @JsonFormat(pattern = "MM-dd HH:mm:ss")
     private LocalDateTime time;
 
     /**
@@ -64,9 +61,6 @@ public class Information extends Model<Information> {
     @TableField("checked")
     private Integer checked;
 
-    /**
-     * 通知内容
-     */
     @TableField("msg")
     private String msg;
 

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

@@ -108,6 +108,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     @Resource
     private ContactsMapper contactsMapper;
 
+    @Resource
+    private InformationService informationService;
+
 
 
     @Override
@@ -154,7 +157,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
 //            taskRepeatDesignMapper.insert(taskRepeatDesign);
 //        }
         //保存任务执行人 //一对多
+        ArrayList<Information> informationArrayList = new ArrayList<>();
         if (StringUtils.isNotEmpty(taskDto.getExecutorId())){
+            Information information = new Information();
             String[] executorIds = taskDto.getExecutorId().split(",");
             for (String executorId : executorIds) {
                 TaskExecutor taskExecutor = new TaskExecutor();
@@ -164,7 +169,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                         .setExecutorName(selectedUser.getName())
                         .setCompanyId(user.getCompanyId());
                 taskExecutorMapper.insert(taskExecutor);
+                information.setUserId(executorId);
             }
+            information.setTime(LocalDateTime.now()).setChecked(0).setMsg("你有新的任务");
+            informationArrayList.add(information);
+            informationService.saveBatch(informationArrayList);
         }
 
         //添加任务编译记录
@@ -665,6 +674,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                         task.setBusinessOpportunityId(businessOpportunity.getId());
                                         task.setTaskType(1);
                                     }
+                                }else {
+                                    task.setBusinessOpportunityId(businessOpportunity.getId());
+                                    task.setTaskType(1);
                                 }
                             }else {
                                 msg.setError("["+businessName+"]对应的商机不存在");
@@ -694,6 +706,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                         task.setOrderId(order.getId());
                                         task.setTaskType(2);
                                     }
+                                }else {
+                                    task.setOrderId(order.getId());
+                                    task.setTaskType(2);
                                 }
                             }else {
                                 msg.setError("["+orderName+"]对应的销售订单不存在");
@@ -817,8 +832,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 if(saveOrUpdateBatch(importTaskList)){
                     ArrayList<TaskExecutor> taskExecutors = new ArrayList<>();
                     ArrayList<TaskLog> taskLogs = new ArrayList<>();
+                    ArrayList<Information> informationArrayList = new ArrayList<>();
                     for (Task task : importTaskList) {
                         String executorId = task.getExecutorId();
+                        Information information = new Information();
 
                         if (StringUtils.isNotEmpty(executorId)){
                             String[] split = executorId.split(",");
@@ -829,6 +846,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                                 taskExecutor.setExecutorName(userList.stream().filter(u -> u.getId().equals(userId)).collect(Collectors.toList()).get(0).getName());
                                 taskExecutor.setCompanyId(user.getCompanyId());
                                 taskExecutors.add(taskExecutor);
+
+                                information.setUserId(userList.stream().filter(u -> u.getId().equals(userId)).collect(Collectors.toList()).get(0).getId());
                             }
                         }
                         TaskLog taskLog = new TaskLog();
@@ -838,16 +857,23 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                         taskLog.setUserId(user.getId());
                         taskLog.setCompanyId(user.getCompanyId());
                         taskLogs.add(taskLog);
+
+
+                        information.setMsg("你有新的任务").setTime(LocalDateTime.now()).setChecked(0);
+                        informationArrayList.add(information);
                     }
 
                     boolean b1 = true;
                     boolean b2 = true;
+                    boolean b3 = true;
                     if (!taskExecutors.isEmpty()) {
                         b1=taskExecutorService.saveOrUpdateBatch(taskExecutors);
                     }if (!taskLogs.isEmpty()){
                         b2=taskLogService.saveOrUpdateBatch(taskLogs);
+                    }if (!informationArrayList.isEmpty()){
+                        b3=informationService.saveBatch(informationArrayList);
                     }
-                    if (b1&&b2){
+                    if (b1&&b2&&b3){
                         return msg;
                     }else {
                         msg.setError("验证失败");