Browse Source

任务管理--添加、提交、修改功能

buzhanyi 8 months ago
parent
commit
388e239c92
20 changed files with 336 additions and 88 deletions
  1. 2 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/ProjectInfoApi.java
  2. 5 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/ProjectInfoServiceApi.java
  3. 10 2
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/TaskInfoApi.java
  4. 32 2
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/TaskInfoServiceApi.java
  5. 12 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/ProjectInfoController.java
  6. 17 6
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/SubmitUserTaskController.java
  7. 49 16
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/TaskInfoController.java
  8. 14 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/entity/ProjectInfoEntity.java
  9. 18 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/entity/TaskInfoEntity.java
  10. 3 3
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/enums/TaskStatus.java
  11. 12 3
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/mapper/ProjectInfoMapper.java
  12. 4 4
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/mapper/TaskInfoMapper.java
  13. 2 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/ProjectInfoService.java
  14. 35 7
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/TaskInfoService.java
  15. 4 4
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ManHourServiceImpl.java
  16. 15 3
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ProjectInfoServiceImpl.java
  17. 89 33
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/TaskInfoServiceImpl.java
  18. 4 0
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/vo/ProjectInfoVo.java
  19. 8 4
      application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/vo/TaskInfoVo.java
  20. 1 1
      common/common-flow/src/main/java/com/ankaibei/workFlow/common/flow/constant/FlowTaskStatus.java

+ 2 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/ProjectInfoApi.java

@@ -19,6 +19,8 @@ public interface ProjectInfoApi extends ApiMixin<ProjectInfoVo, Integer> {
 
     ResMsg findProjectInfoAll(String projectName);
 
+    ResMsg findProjectInfoAtFlowStatus(Integer flowTaskStatus);
+
     ResMsg findProjectParticulars(ProjectInfoVo projectInfoVo);
 
     ResMsg addProject(ProjectInfoVo projectInfoVo);

+ 5 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/ProjectInfoServiceApi.java

@@ -36,6 +36,11 @@ public class ProjectInfoServiceApi implements ProjectInfoApi {
         return projectInfoService.findProjectInfoAll(projectName);
     }
 
+    @Override
+    public ResMsg findProjectInfoAtFlowStatus(Integer flowTaskStatus) {
+        return projectInfoService.findProjectInfoAtFlowStatus(flowTaskStatus);
+    }
+
     @Override
     public ResMsg findProjectParticulars(ProjectInfoVo projectInfoVo) {
         ProjectInfoEntity projectInfoEntity = this.copyProperties(projectInfoVo, ProjectInfoEntity.class);

+ 10 - 2
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/TaskInfoApi.java

@@ -16,13 +16,21 @@ import java.util.List;
 public interface TaskInfoApi extends ApiMixin<TaskInfoVo, Integer> {
     ResMsg findTaskInfo(TaskInfoVo taskInfoVo);
 
+    ResMsg findTaskById(TaskInfoVo taskInfoVo);
+
     ResMsg addTaskInfo(TaskInfoVo taskInfoVo);
 
-    ResMsg findTaskById(TaskInfoVo taskInfoVo);
+    ResMsg submitTaskBySave(TaskInfoVo taskInfoVo);
+
+    ResMsg submitTaskBatch(List<TaskInfoVo> taskInfoVos);
+
+    ResMsg submitTaskByEdit(TaskInfoVo taskInfoVo);
+
+    ResMsg editTask(TaskInfoVo taskInfoVo);
 
     ResMsg performTask(TaskInfoVo taskInfoVo);
 
     ResMsg deleteTask(List<TaskInfoVo> taskInfoVos);
 
-    ResMsg findTaskIsFinish(String userId, Integer flowTaskStatus);
+    ResMsg findTaskIsFinish(String userId, Integer taskStatus);
 }

+ 32 - 2
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/TaskInfoServiceApi.java

@@ -4,9 +4,11 @@ import com.ankaibei.workFlow.webadmin.ankaibei.entity.TaskInfoEntity;
 import com.ankaibei.workFlow.webadmin.ankaibei.service.TaskInfoService;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.TaskInfoVo;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -33,6 +35,34 @@ public class TaskInfoServiceApi implements TaskInfoApi {
         return taskInfoService.addTaskInfo(taskInfoEntity, taskInfoVo.getTaskParticipant());
     }
 
+    @Override
+    public ResMsg submitTaskBySave(TaskInfoVo taskInfoVo) {
+        TaskInfoEntity taskInfoEntity = this.copyProperties(taskInfoVo, TaskInfoEntity.class);
+        return taskInfoService.submitTaskBySave(taskInfoEntity, taskInfoVo.getTaskParticipant());
+    }
+
+    @Override
+    public ResMsg submitTaskBatch(List<TaskInfoVo> taskInfoVos) {
+        ArrayList<TaskInfoEntity> list = new ArrayList<>();
+        for (TaskInfoVo infoVo : taskInfoVos) {
+            TaskInfoEntity entity = this.copyProperties(infoVo, TaskInfoEntity.class);
+            list.add(entity);
+        }
+        return taskInfoService.submitTaskBatch(list);
+    }
+
+    @Override
+    public ResMsg submitTaskByEdit(TaskInfoVo taskInfoVo) {
+        TaskInfoEntity taskInfoEntity = this.copyProperties(taskInfoVo, TaskInfoEntity.class);
+        return taskInfoService.submitTaskByEdit(taskInfoEntity, taskInfoVo.getTaskParticipant());
+    }
+
+    @Override
+    public ResMsg editTask(TaskInfoVo taskInfoVo) {
+        TaskInfoEntity taskInfoEntity = this.copyProperties(taskInfoVo, TaskInfoEntity.class);
+        return taskInfoService.editTask(taskInfoEntity, taskInfoVo.getTaskParticipant());
+    }
+
     @Override
     public ResMsg findTaskById(TaskInfoVo taskInfoVo) {
         return taskInfoService.findTaskById(taskInfoVo);
@@ -50,8 +80,8 @@ public class TaskInfoServiceApi implements TaskInfoApi {
     }
 
     @Override
-    public ResMsg findTaskIsFinish(String userId, Integer flowTaskStatus) {
-        return taskInfoService.findTaskIsFinish(userId, flowTaskStatus);
+    public ResMsg findTaskIsFinish(String userId, Integer taskStatus) {
+        return taskInfoService.findTaskIsFinish(userId, taskStatus);
     }
 
 }

+ 12 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/ProjectInfoController.java

@@ -66,6 +66,18 @@ public class ProjectInfoController {
         return projectInfoApi.findProjectInfoAll(projectName);
     }
 
+    /**
+     * 查询项目--查询指定审核状态的项目
+     *
+     * @param flowTaskStatus
+     * @return ResMsg
+     */
+    @NoAuthInterface
+    @RequestMapping("/findProjectInfoAtFlowStatus")
+    public ResMsg findProjectInfoAtFlowStatus(@RequestParam Integer flowTaskStatus) {
+        return projectInfoApi.findProjectInfoAtFlowStatus(flowTaskStatus);
+    }
+
     /**
      * 新建项目--保存
      *

+ 17 - 6
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/SubmitUserTaskController.java

@@ -31,9 +31,12 @@ import com.ankaibei.workFlow.common.online.object.ColumnData;
 import com.ankaibei.workFlow.common.online.service.OnlineOperationService;
 import com.ankaibei.workFlow.common.online.util.OnlineOperationHelper;
 import com.ankaibei.workFlow.webadmin.ankaibei.entity.ManHourInfoEntity;
+import com.ankaibei.workFlow.webadmin.ankaibei.entity.ProjectInfoEntity;
+import com.ankaibei.workFlow.webadmin.ankaibei.entity.TaskInfoEntity;
 import com.ankaibei.workFlow.webadmin.ankaibei.enums.CodeEnum;
 import com.ankaibei.workFlow.webadmin.ankaibei.enums.CostEnum;
 import com.ankaibei.workFlow.webadmin.ankaibei.enums.ManHourStatus;
+import com.ankaibei.workFlow.webadmin.ankaibei.enums.TaskStatus;
 import com.ankaibei.workFlow.webadmin.ankaibei.mapper.CommunicationMapper;
 import com.ankaibei.workFlow.webadmin.ankaibei.mapper.CostInfoMapper;
 import com.ankaibei.workFlow.webadmin.ankaibei.mapper.ManHourMapper;
@@ -305,19 +308,27 @@ public class SubmitUserTaskController {
         }
         switch (CostEnum.getEnumByCode(subVo.getCostType())) {
             case PROJECTADD:
-                projectInfoMapper.updateProjectFlowStatus(flowStatus + "", subVo.getApplyDataId());
+                ProjectInfoEntity projectInfo = projectInfoMapper.getById(subVo.getApplyDataId());
+                String projectRatifyUser = projectInfo.getRatifyUser() + "," + userId;
+                projectInfoMapper.updateProjectFlowStatus(flowStatus + "", projectRatifyUser, subVo.getApplyDataId());
                 break;
             case MANHOUR:
-                ManHourInfoEntity byId = manHourMapper.getById(subVo.getApplyDataId());
-                String ratifyUser = byId.getRatifyUser() + "," + userId + ",";
+                ManHourInfoEntity manHourInfo = manHourMapper.getById(subVo.getApplyDataId());
+                String manHourRatifyUser = manHourInfo.getRatifyUser() + "," + userId;
                 if (flowStatus == FlowTaskStatus.REFUSED) {
-                    manHourMapper.updateManHourFlowStatus(ManHourStatus.REFUSE_ED.getCode(), flowStatus + "", ratifyUser, subVo.getApplyDataId());
+                    manHourMapper.updateManHourFlowStatus(ManHourStatus.REFUSE_ED.getCode(), flowStatus + "", manHourRatifyUser, subVo.getApplyDataId());
                 } else if (flowStatus == FlowTaskStatus.FINISHED) {
-                    manHourMapper.updateManHourFlowStatus(ManHourStatus.FINISH_ED.getCode(), flowStatus + "", ratifyUser, subVo.getApplyDataId());
+                    manHourMapper.updateManHourFlowStatus(ManHourStatus.FINISH_ED.getCode(), flowStatus + "", manHourRatifyUser, subVo.getApplyDataId());
                 }
                 break;
             case PROJECTTASKADD:
-                taskInfoMapper.updateTaskFlowStatus(flowStatus + "", subVo.getApplyDataId());
+                TaskInfoEntity taskInfo = taskInfoMapper.getById(subVo.getApplyDataId());
+                String taskRatifyUser = taskInfo.getRatifyUser() + "," + userId;
+                if (flowStatus == FlowTaskStatus.REFUSED) {
+                    taskInfoMapper.updateTaskFlowStatus(TaskStatus.REFUSE_ED.getCode(), flowStatus + "", taskRatifyUser, subVo.getApplyDataId());
+                } else if (flowStatus == FlowTaskStatus.FINISHED) {
+                    taskInfoMapper.updateTaskFlowStatus(TaskStatus.ALLOCATION_ED.getCode(), flowStatus + "", taskRatifyUser, subVo.getApplyDataId());
+                }
                 break;
             case COMMUNICATION:
                 communicationMapper.updateCommunicationFlowStatus(flowStatus + "", subVo.getApplyDataId());

+ 49 - 16
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/TaskInfoController.java

@@ -3,17 +3,14 @@ package com.ankaibei.workFlow.webadmin.ankaibei.controller;
 import com.ankaibei.workFlow.common.core.object.TokenData;
 import com.ankaibei.workFlow.common.flow.constant.FlowTaskStatus;
 import com.ankaibei.workFlow.webadmin.ankaibei.api.TaskInfoApi;
-import com.ankaibei.workFlow.webadmin.ankaibei.enums.CodeEnum;
-import com.ankaibei.workFlow.webadmin.ankaibei.utils.JwtUtil;
+import com.ankaibei.workFlow.webadmin.ankaibei.enums.TaskStatus;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.TaskInfoVo;
-import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 /**
@@ -54,27 +51,50 @@ public class TaskInfoController {
     }
 
     /**
-     * 完成任务
+     * 新增任务
      *
      * @param taskInfoVo
      * @return ResMsg
      */
-    @RequestMapping("/performTask")
-    public ResMsg performTask(@RequestBody TaskInfoVo taskInfoVo) {
+    @RequestMapping("/addTaskInfo")
+    public ResMsg addTaskInfo(@RequestBody TaskInfoVo taskInfoVo) {
+        taskInfoVo.setTaskCreator(TokenData.takeFromRequest().getUserId());
+        return taskInfoApi.addTaskInfo(taskInfoVo);
+    }
 
-        return taskInfoApi.performTask(taskInfoVo);
+    /**
+     * 保存后提交任务
+     */
+    @RequestMapping("/submitTaskBySave")
+    public ResMsg submitTaskBySave(@RequestBody TaskInfoVo taskInfoVo) {
+        taskInfoVo.setTaskCreator(TokenData.takeFromRequest().getUserId());
+        return taskInfoApi.submitTaskBySave(taskInfoVo);
     }
 
     /**
-     * 新增任务
-     *
-     * @param taskInfoVo
-     * @return ResMsg
+     * 批量提交
      */
-    @RequestMapping("/addTaskInfo")
-    public ResMsg addTaskInfo(@RequestBody TaskInfoVo taskInfoVo) {
+    @RequestMapping("/submitTaskBatch")
+    public ResMsg submitTaskBatch(@RequestBody List<TaskInfoVo> taskInfoVos) {
+        return taskInfoApi.submitTaskBatch(taskInfoVos);
+    }
+
+    /**
+     * 编辑任务--保存
+     */
+    @RequestMapping("/editTask")
+    public ResMsg editTask(@RequestBody TaskInfoVo taskInfoVo) {
         taskInfoVo.setTaskCreator(TokenData.takeFromRequest().getUserId());
-        return taskInfoApi.addTaskInfo(taskInfoVo);
+        return taskInfoApi.editTask(taskInfoVo);
+    }
+
+    /**
+     * 编辑任务--提交
+     */
+    @RequestMapping("/submitTaskByEdit")
+    public ResMsg submitTaskByEdit(@RequestBody TaskInfoVo taskInfoVo) {
+        taskInfoVo.setTaskCreator(TokenData.takeFromRequest().getUserId());
+        return taskInfoApi.submitTaskByEdit(taskInfoVo);
     }
 
     /**
@@ -88,6 +108,19 @@ public class TaskInfoController {
         return taskInfoApi.deleteTask(taskInfoVos);
     }
 
+
+    /**
+     * 完成任务
+     *
+     * @param taskInfoVo
+     * @return ResMsg
+     */
+    @RequestMapping("/performTask")
+    public ResMsg performTask(@RequestBody TaskInfoVo taskInfoVo) {
+
+        return taskInfoApi.performTask(taskInfoVo);
+    }
+
     /**
      * 查找登录用户参与的审批已完成的任务
      *
@@ -96,7 +129,7 @@ public class TaskInfoController {
     @RequestMapping("/findTaskIsFinish")
     public ResMsg findTaskIsFinish() {
         String userId = TokenData.takeFromRequest().getUserId();
-        return taskInfoApi.findTaskIsFinish(userId, FlowTaskStatus.FINISHED);
+        return taskInfoApi.findTaskIsFinish(userId, Integer.parseInt(TaskStatus.FINISH_ED.getCode()));
     }
 
 

+ 14 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/entity/ProjectInfoEntity.java

@@ -87,6 +87,10 @@ public class ProjectInfoEntity {
      * 立项时间
      */
     private Date createDate;
+    /**
+     * 审批人
+     */
+    private String ratifyUser;
     /**
      * 进入流程后获取到的流程实例的id
      */
@@ -135,6 +139,16 @@ public class ProjectInfoEntity {
         this.processInstanceId = processInstanceId;
     }
 
+    @Basic
+    @Column(name = "ratify_user")
+    public String getRatifyUser() {
+        return ratifyUser;
+    }
+
+    public void setRatifyUser(String ratifyUser) {
+        this.ratifyUser = ratifyUser;
+    }
+
     @Basic
     @Column(name = "flow_task_status")
     public Integer getFlowTaskStatus() {

+ 18 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/entity/TaskInfoEntity.java

@@ -14,6 +14,10 @@ import java.util.Objects;
 @Table(name = "task_info", schema = "ankaibei")
 public class TaskInfoEntity {
 
+    /**
+     * 主键ID
+     */
+    @Id
     private Integer taskId;
     /**
      * 目标任务
@@ -71,6 +75,10 @@ public class TaskInfoEntity {
      * 工作流任务处理状态
      */
     private Integer flowTaskStatus;
+    /**
+     * 审批人
+     */
+    private String ratifyUser;
     /**
      * 流程定义Id
      */
@@ -161,6 +169,16 @@ public class TaskInfoEntity {
         this.taskParticipant = taskParticipant;
     }
 
+    @Basic
+    @Column(name = "ratify_user")
+    public String getRatifyUser() {
+        return ratifyUser;
+    }
+
+    public void setRatifyUser(String ratifyUser) {
+        this.ratifyUser = ratifyUser;
+    }
+
     @Basic
     @Column(name = "start_time")
     public Date getStartTime() {

+ 3 - 3
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/enums/TaskStatus.java

@@ -5,10 +5,10 @@ package com.ankaibei.workFlow.webadmin.ankaibei.enums;
  */
 
 public enum TaskStatus {
-    //1 未分配 2已分配 3已延期 4 已完成 5 已拒绝
+    //1 未分配 2审核中 3已分配 4已完成 5已拒绝
     NO_ALLOCATION("1", "未分配"),
-    ALLOCATION_ED("2", "已分配"),
-    EXTENSION_ED("3", "已延期"),
+    AUDITING("2", "审核中"),
+    ALLOCATION_ED("3", "已分配"),
     FINISH_ED("4", "已完成"),
     REFUSE_ED("5", "已拒绝");
 

+ 12 - 3
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/mapper/ProjectInfoMapper.java

@@ -37,8 +37,8 @@ public interface ProjectInfoMapper extends JpaRepository<ProjectInfoEntity, Inte
 
     @Transactional
     @Modifying
-    @Query(value = "update project_info SET flow_task_status = ?1 WHERE project_id = ?2", nativeQuery = true)
-    void updateProjectFlowStatus(String flowTaskStatus, Integer projectId);
+    @Query(value = "update project_info SET flow_task_status = ?1 ,ratify_user = ?2 WHERE project_id = ?3", nativeQuery = true)
+    void updateProjectFlowStatus(String flowTaskStatus, String projectRatifyUser, Integer projectId);
 
     @Transactional
     @Modifying
@@ -78,5 +78,14 @@ public interface ProjectInfoMapper extends JpaRepository<ProjectInfoEntity, Inte
     @Query(value = "SELECT *  FROM project_info  WHERE project_code=?1 and is_delete='1'",
             //countQuery = "SELECT count(1) FROM project_info pro WHERE if( ?1 !='', pro.project_name like %?1% , 1=1) ",
             nativeQuery = true)
-    ProjectInfoEntity  findProjectInfoByCode(@Param("projectCode") String projectCode);
+    ProjectInfoEntity findProjectInfoByCode(@Param("projectCode") String projectCode);
+
+    /**
+     * 根据流程状态查询项目信息
+     *
+     * @param flowTaskStatus
+     * @return
+     */
+    @Query
+    List<ProjectInfoEntity> findAllByFlowTaskStatusIsAndIsDeleteEquals(Integer flowTaskStatus, String isDelete);
 }

+ 4 - 4
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/mapper/TaskInfoMapper.java

@@ -76,8 +76,8 @@ public interface TaskInfoMapper extends JpaRepository<TaskInfoEntity, Integer>,
      */
     @Transactional
     @Modifying
-    @Query(value = "update task_info SET flow_task_status = ?1 WHERE task_id = ?2", nativeQuery = true)
-    void updateTaskFlowStatus(String flowTaskStatus, Integer taskId);
+    @Query(value = "update task_info SET task_status = ?1, flow_task_status = ?2, ratify_user = ?3 WHERE task_id = ?2", nativeQuery = true)
+    void updateTaskFlowStatus(String taskStatus, String flowTaskStatus, String taskRatifyUser, Integer taskId);
 
     /**
      * 删除任务
@@ -91,8 +91,8 @@ public interface TaskInfoMapper extends JpaRepository<TaskInfoEntity, Integer>,
 
 
     /**
-     * 查询改用户提交的审核已完成的任务
+     * 查询登录用户已完成的任务
      */
     @Query
-    List<TaskInfoEntity> findAllByTaskParticipantContainsAndFlowTaskStatusEquals(String userId, Integer flowTaskStatus);
+    List<TaskInfoEntity> findAllByTaskParticipantContainsAndTaskStatusIsAndIsDeleteIs(String userId, Integer taskStatus, String isDelete);
 }

+ 2 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/ProjectInfoService.java

@@ -20,6 +20,8 @@ public interface ProjectInfoService {
 
     ResMsg findProjectInfoAll(String projectName);
 
+    ResMsg findProjectInfoAtFlowStatus(Integer flowTaskStatus);
+
     ResMsg findProjectParticulars(ProjectInfoEntity projectInfoEntity);
 
     ResMsg addProject(ProjectInfoEntity projectInfoEntity);

+ 35 - 7
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/TaskInfoService.java

@@ -5,6 +5,7 @@ import com.ankaibei.workFlow.webadmin.ankaibei.entity.TaskInfoEntity;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.TaskInfoVo;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -22,6 +23,14 @@ public interface TaskInfoService {
      */
     ResMsg findTaskInfo(Integer pageIndex, Integer pageSize, TaskInfoEntity taskInfoEntity);
 
+    /**
+     * 查询指定任务
+     * * @param taskInfoEntity
+     *
+     * @return
+     */
+    ResMsg findTaskById(TaskInfoVo taskInfoVo);
+
     /**
      * 添加任务
      * * @param taskInfoEntity
@@ -31,20 +40,39 @@ public interface TaskInfoService {
     ResMsg addTaskInfo(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant);
 
     /**
-     * 删除任务
-     * * @param taskInfoEntity
+     * 保存后提交任务
+     */
+    ResMsg submitTaskBySave(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant);
+
+    /**
+     * 批量提交任务
      *
+     * @param list
      * @return
      */
-    ResMsg deleteTask(List<TaskInfoVo> taskInfoVos);
+    ResMsg submitTaskBatch(ArrayList<TaskInfoEntity> list);
 
     /**
-     * 查询指定任务
+     * 编辑任务--保存
+     */
+    ResMsg editTask(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant);
+
+    /**
+     * 编辑任务--提交
+     *
+     * @param taskInfoEntity
+     * @param taskParticipant
+     * @return
+     */
+    ResMsg submitTaskByEdit(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant);
+
+    /**
+     * 删除任务
      * * @param taskInfoEntity
      *
      * @return
      */
-    ResMsg findTaskById(TaskInfoVo taskInfoVo);
+    ResMsg deleteTask(List<TaskInfoVo> taskInfoVos);
 
     /**
      * 任务完成
@@ -58,8 +86,8 @@ public interface TaskInfoService {
      * 查找登录用户参与的审批已完成的任务
      *
      * @param userId
-     * @param flowTaskStatus
+     * @param taskStatus
      * @return
      */
-    ResMsg findTaskIsFinish(String userId, Integer flowTaskStatus);
+    ResMsg findTaskIsFinish(String userId, Integer taskStatus);
 }

+ 4 - 4
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ManHourServiceImpl.java

@@ -67,12 +67,12 @@ public class ManHourServiceImpl implements ManHourService {
         Page<Map<String, String>> manHourAll = manHourMapper.findManHourAll(userId, manHourInfoEntity.getFlowTaskStatus(), manHourInfoEntity.getStartDate(), endDate, page);
         //匹配项目信息和任务信息
         List<ProjectInfoEntity> projectInfos = projectInfoMapper.findAll();
-        List<TaskInfoEntity> finishedTasks = taskInfoMapper.findAllByTaskParticipantContainsAndFlowTaskStatusEquals(userId, FlowTaskStatus.FINISHED);
+        List<TaskInfoEntity> finishedTasks = taskInfoMapper.findAllByTaskParticipantContainsAndTaskStatusIsAndIsDeleteIs(userId, FlowTaskStatus.FINISHED, DataIsDeleteEnum.NORMAL.getCode());
         return new ResMsg(CodeEnum.OK, ResMsg.getMap(manHourAll.map(map -> {
             Map<Object, Object> map1 = new HashMap<>(map);
-            for (TaskInfoEntity task : finishedTasks) {
-                if (map1.get("taskId").equals(task.getTaskId().toString())) {
-                    map1.put("taskName", task.getTargetTask());
+            for (TaskInfoEntity taskInfo : finishedTasks) {
+                if (map1.get("taskId").equals(taskInfo.getTaskId())) {
+                    map1.put("targetTask", taskInfo.getTargetTask());
                     break;
                 }
             }

+ 15 - 3
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ProjectInfoServiceImpl.java

@@ -61,12 +61,18 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
     @Override
     public ResMsg findProjectInfo(Integer pageIndex, Integer pageSize, ProjectInfoEntity projectInfoEntity) {
         Pageable page = PageRequest.of(pageIndex - 1, pageSize);
+        //String userId = TokenData.takeFromRequest().getUserId();
         Page<Map<String, String>> projectInfo = projectInfoMapper.findProjectInfo(projectInfoEntity.getProjectStatus(), projectInfoEntity.getProjectName(), page);
+        List<UserInfoEntity> userAll = userInfoMapper.findAll();
         return new ResMsg(CodeEnum.OK, ResMsg.getMap(projectInfo.map(map -> {
             Map<Object, Object> map1 = new HashMap<>();
             map1.putAll(map);
-            UserInfoEntity userInfoEntity = userInfoMapper.findByUserIdEquals((map.get("projectPrincipal")));
-            map1.put("projectPrincipal", userInfoEntity != null ? userInfoEntity.getShowName() : null);
+            for (UserInfoEntity user : userAll) {
+                if (map.get("projectPrincipal").equals(user.getUserId())) {
+                    map1.put("projectPrincipal", user.getShowName() + "");
+                    break;
+                }
+            }
             String projectStage = map.get("projectStage");
             //项目阶段不为空时赋值
             if (!ObjectUtils.isEmpty(projectStage)) {
@@ -129,6 +135,12 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
         return new ResMsg(CodeEnum.OK, all);
     }
 
+    @Override
+    public ResMsg findProjectInfoAtFlowStatus(Integer flowTaskStatus) {
+        List<ProjectInfoEntity> all = projectInfoMapper.findAllByFlowTaskStatusIsAndIsDeleteEquals(flowTaskStatus, DataIsDeleteEnum.NORMAL.getCode());
+        return new ResMsg(CodeEnum.OK, all);
+    }
+
     @Override
     public ResMsg findProjectParticulars(ProjectInfoEntity projectInfoEntity) {
         Optional<ProjectInfoEntity> byId = projectInfoMapper.findById(projectInfoEntity.getProjectId());
@@ -228,7 +240,7 @@ public class ProjectInfoServiceImpl implements ProjectInfoService {
         byId.setProjectStatus(entity.getProjectStatus());//项目状态
         if (FlowTaskStatus.REFUSED.equals(flowStatus)) {
             // 更新流程状态和流程信息,以便建立下一个流程实例
-            byId.setFlowTaskStatus(Integer.valueOf(flowStatus));//流程状态
+            byId.setFlowTaskStatus(FlowTaskStatus.DRAFT);//流程状态
             byId.setProcessDefinitionId(null);//流程定义id
             byId.setProcessInstanceId(null);//流程实例id
         }

+ 89 - 33
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/TaskInfoServiceImpl.java

@@ -22,6 +22,7 @@ import com.ankaibei.workFlow.webadmin.ankaibei.mapper.TaskInfoMapper;
 import com.ankaibei.workFlow.webadmin.ankaibei.mapper.UserInfoMapper;
 import com.ankaibei.workFlow.webadmin.ankaibei.service.TaskInfoService;
 import com.ankaibei.workFlow.webadmin.ankaibei.utils.FlowTaskStart;
+import com.ankaibei.workFlow.webadmin.ankaibei.vo.ManHourInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.TaskInfoVo;
 import org.apache.commons.lang3.ObjectUtils;
@@ -123,19 +124,7 @@ public class TaskInfoServiceImpl implements TaskInfoService {
                 Duration duration = Duration.between(startDateTime, endDateTime);
                 long daysDiff = duration.toDays();
                 long hoursDiff = duration.toHours() % 24;
-                map1.put("duration_ch", daysDiff + "天" + hoursDiff + "时");
-                //任务是否已延期:结束时间已过但是未完成的,就是延期
-                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                try {
-                    if (sdf.parse(map1.get("endTime").toString()).before(new Date()) && !TaskStatus.FINISH_ED.getCode().equals(map1.get("taskStatus").toString())) {
-                        if (!TaskStatus.EXTENSION_ED.getCode().equals(map1.get("taskStatus").toString())) {
-                            taskInfoMapper.extensionTask(Integer.valueOf(map1.get("taskId").toString()));
-                        }
-                        map1.put("taskStatus", TaskStatus.EXTENSION_ED.getCode());
-                    }
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                }
+                map1.put("timeConsuming", daysDiff + "天" + hoursDiff + "时");
             }
 
             map1.put("taskPriority", TaskPriority.getEnumByCode(map.get("taskPriority")));
@@ -146,33 +135,98 @@ public class TaskInfoServiceImpl implements TaskInfoService {
     @Override
     @Transactional
     public ResMsg addTaskInfo(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
-        if (taskInfoMapper.countByTargetTaskEqualsAndIsDeleteEquals(taskInfoEntity.getTargetTask(), "1") > 1) {
+        if (taskInfoMapper.countByTargetTaskEqualsAndIsDeleteEquals(taskInfoEntity.getTargetTask(), "1") > 0) {
             return new ResMsg(CodeEnum.TASK_ALREADY_EXISTS);
         }
-        if (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) || ObjectUtils.isEmpty(taskInfoEntity.getEndTime()) || (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) && ObjectUtils.isEmpty(taskInfoEntity.getEndTime()))) {
+        //判断开始时间和结束时间是否为空
+        if (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) || ObjectUtils.isEmpty(taskInfoEntity.getEndTime())) {
             return new ResMsg(CodeEnum.PARAM_IS_NULL, "请录入任务计划的开始时间和结束时间");
-        } else {
-            //结束时间在此时之前,就已是延期任务
-            if (taskInfoEntity.getEndTime().before(new Date())) {
-                taskInfoEntity.setTaskStatus(TaskStatus.EXTENSION_ED.getCode());
+        }
+        StringBuffer str = new StringBuffer();
+        for (Long id : taskParticipant) {
+            str.append(id).append(",");
+        }
+        taskInfoEntity.setTaskParticipant(str.toString());
+        //设置默认值
+        taskInfoEntity.setTaskStatus(TaskStatus.NO_ALLOCATION.getCode());
+        taskInfoEntity.setCreateDate(new Date());
+        taskInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
+        TaskInfoEntity save = taskInfoMapper.save(taskInfoEntity);
+        return new ResMsg(CodeEnum.OK, save);
+    }
+
+    @Override
+    public ResMsg submitTaskBySave(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
+        ResMsg msg = addTaskInfo(taskInfoEntity, taskParticipant);
+        if (msg.getCode() == CodeEnum.OK.getCode()) {
+            return submitProjectTask((TaskInfoEntity) msg.getData());
+        }
+        return new ResMsg(CodeEnum.OK);
+    }
+
+    @Override
+    public ResMsg submitTaskBatch(ArrayList<TaskInfoEntity> list) {
+        //先判断ID是否为空:不为空就是批量提交的
+        if (ObjectUtils.isNotEmpty(list)) {
+            List<TaskInfoEntity> taskList = taskInfoMapper.findAllById(list.stream().map(TaskInfoEntity::getTaskId).collect(Collectors.toList()));
+            for (TaskInfoEntity taskInfoEntity : taskList) {
+                ResMsg msg = submitProjectTask(taskInfoEntity);
+                if (!"200".equals(msg.getCode())) {
+                    return msg;
+                }
             }
         }
-        if (taskParticipant.size() < 1) {
-            //(1 未分配 2已分配 3已延期)
-            taskInfoEntity.setTaskStatus(TaskStatus.NO_ALLOCATION.getCode());
-        } else {
-            taskInfoEntity.setTaskStatus(TaskStatus.ALLOCATION_ED.getCode());
+        return new ResMsg(CodeEnum.OK);
+    }
+
+    /**
+     * 编辑任务--编辑后保存
+     *
+     * @param taskInfoEntity
+     * @param taskParticipant
+     * @return
+     */
+    @Override
+    public ResMsg editTask(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
+        if (taskInfoMapper.countByTargetTaskEqualsAndIsDeleteEquals(taskInfoEntity.getTargetTask(), "1") > 0) {
+            return new ResMsg(CodeEnum.TASK_ALREADY_EXISTS);
+        }
+        //判断开始时间和结束时间是否为空
+        if (ObjectUtils.isEmpty(taskInfoEntity.getStartTime()) || ObjectUtils.isEmpty(taskInfoEntity.getEndTime())) {
+            return new ResMsg(CodeEnum.PARAM_IS_NULL, "请录入任务计划的开始时间和结束时间");
         }
         StringBuffer str = new StringBuffer();
         for (Long id : taskParticipant) {
             str.append(id).append(",");
         }
         taskInfoEntity.setTaskParticipant(str.toString());
-        taskInfoEntity.setTaskCreator(taskInfoEntity.getTaskCreator());
+        //设置默认值
+        taskInfoEntity.setTaskStatus(TaskStatus.NO_ALLOCATION.getCode());
         taskInfoEntity.setCreateDate(new Date());
         taskInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
         TaskInfoEntity save = taskInfoMapper.save(taskInfoEntity);
+        return new ResMsg(CodeEnum.OK, save);
+    }
 
+    /**
+     * 编辑任务--编辑后提交
+     *
+     * @param taskInfoEntity
+     * @param taskParticipant
+     * @return
+     */
+    @Override
+    public ResMsg submitTaskByEdit(TaskInfoEntity taskInfoEntity, List<Long> taskParticipant) {
+        ResMsg msg = editTask(taskInfoEntity, taskParticipant);
+        if (msg.getCode() == CodeEnum.OK.getCode()) {
+            TaskInfoEntity data = (TaskInfoEntity) msg.getData();
+            return submitProjectTask(data);
+        }
+        return new ResMsg(CodeEnum.OK);
+    }
+
+
+    public ResMsg submitProjectTask(TaskInfoEntity taskInfoEntity) {
         /**
          *调用新增项目任务申请流程的启动
          *获取流程开始节点之后的第一个任务节点的数据
@@ -207,16 +261,18 @@ public class TaskInfoServiceImpl implements TaskInfoService {
         stringObjectHashMap.put("task_statements", taskInfoEntity.getTaskStatements());
         stringObjectHashMap.put("project_id", taskInfoEntity.getProjectId());
         stringObjectHashMap.put("create_date", taskInfoEntity.getCreateDate());
-        stringObjectHashMap.put("task_id", save.getTaskId());
+        stringObjectHashMap.put("task_id", taskInfoEntity.getTaskId());
         JSONObject masterData = (JSONObject) JSONObject.toJSON(stringObjectHashMap);
         Map<String, String> map = flowTaskStart.startAndTakeUserTaskSS(processDefinitionKey, flowTaskCommentDto, null, masterData, null, null).getData();
-        save.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
-        save.setProcessInstanceId(map.get("processInstanceId"));
-        save.setProcessDefinitionId(map.get("processDefinitionId"));
-        taskInfoMapper.save(save);
-        return new ResMsg(CodeEnum.OK);
+        taskInfoEntity.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+        taskInfoEntity.setTaskStatus(TaskStatus.AUDITING.getCode());
+        taskInfoEntity.setProcessInstanceId(map.get("processInstanceId"));
+        taskInfoEntity.setProcessDefinitionId(map.get("processDefinitionId"));
+        TaskInfoEntity infoEntity = taskInfoMapper.save(taskInfoEntity);
+        return new ResMsg(CodeEnum.OK, infoEntity);
     }
 
+
     @Override
     public ResMsg deleteTask(List<TaskInfoVo> taskInfoVos) {
         //   //审批状态   已提交:0; 审批中:1; 被拒绝:2; 已结束:3; 提前停止:4; 已取消:5;
@@ -261,8 +317,8 @@ public class TaskInfoServiceImpl implements TaskInfoService {
     }
 
     @Override
-    public ResMsg findTaskIsFinish(String userId, Integer flowTaskStatus) {
-        List<TaskInfoEntity> contains = taskInfoMapper.findAllByTaskParticipantContainsAndFlowTaskStatusEquals(userId, flowTaskStatus);
+    public ResMsg findTaskIsFinish(String userId, Integer taskStatus) {
+        List<TaskInfoEntity> contains = taskInfoMapper.findAllByTaskParticipantContainsAndTaskStatusIsAndIsDeleteIs(userId, taskStatus, DataIsDeleteEnum.NORMAL.getCode());
         return new ResMsg(CodeEnum.OK, contains);
     }
 

+ 4 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/vo/ProjectInfoVo.java

@@ -35,6 +35,10 @@ public class ProjectInfoVo extends BaseVo {
     private String projectNode;
     private String projectDescribe;
     private Date createDate;
+    /**
+     * 审批人
+     */
+    private String ratifyUser;
     /**
      * 进入流程后获取到的流程实例的id
      */

+ 8 - 4
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/vo/TaskInfoVo.java

@@ -34,14 +34,18 @@ public class TaskInfoVo extends BaseVo {
     private String taskStandard;
     private String taskStatements;
     private String projectId;
-    /**
-     * 进入流程后获取到的流程实例的id
-     */
-    private String processInstanceId;
     /**
      * 工作流任务处理状态
      */
     private Integer flowTaskStatus;
+    /**
+     * 审批人
+     */
+    private String ratifyUser;
+    /**
+     * 进入流程后获取到的流程实例的id
+     */
+    private String processInstanceId;
     /**
      * 流程定义Id
      */

+ 1 - 1
common/common-flow/src/main/java/com/ankaibei/workFlow/common/flow/constant/FlowTaskStatus.java

@@ -10,7 +10,7 @@ import java.util.Map;
  * @date 2022-09-25
  */
 public final class FlowTaskStatus {
-
+    //0"已提交",1"审批中",2"被拒绝",3"已结束",4"提前停止",5"已取消",6"保存草稿"
     /**
      * 已提交。
      */