Kaynağa Gözat

美莱德任务计划修改

QuYueTing 3 gün önce
ebeveyn
işleme
0e51852244
14 değiştirilmiş dosya ile 443 ekleme ve 329 silme
  1. 1 1
      fhKeeper/formulahousekeeper/management-platform-mld/pom.xml
  2. 4 5
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/ProjectController.java
  3. 193 208
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/TaskController.java
  4. 1 1
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/TaskTypeController.java
  5. 39 6
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/entity/Task.java
  6. 15 5
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/entity/TaskExecutor.java
  7. 1 0
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/mapper/TaskMapper.java
  8. 1 1
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/ProjectService.java
  9. 3 1
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/TaskService.java
  10. 14 5
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  11. 143 86
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java
  12. 2 1
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/TaskExecutorMapper.xml
  13. 24 7
      fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/TaskMapper.xml
  14. 2 2
      fhKeeper/formulahousekeeper/timesheet_mld/src/views/project/projectInside.vue

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform-mld/pom.xml

@@ -10,7 +10,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>com.hssx.parent</groupId>
-    <artifactId>timesheet</artifactId>
+    <artifactId>timesheet-mld</artifactId>
     <version>3.4.0</version>
 
     <dependencies>

+ 4 - 5
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/ProjectController.java

@@ -102,8 +102,9 @@ public class ProjectController {
      * 获取项目列表
      */
     @RequestMapping("/getProjectList")
-    public HttpRespMsg getProjectList(@RequestParam(required = false, defaultValue = "0") Integer forReport, String userId,@RequestParam(required = false) Integer projectMainId) {
-        return projectService.getProjectList(forReport, userId,projectMainId, request);
+    public HttpRespMsg getProjectList(@RequestParam(required = false, defaultValue = "0") Integer forReport,
+                                      @RequestParam(required = false, defaultValue = "0") Integer forTask, String userId,@RequestParam(required = false) Integer projectMainId) {
+        return projectService.getProjectList(forReport,forTask, userId,projectMainId, request);
     }
 
     /**
@@ -656,7 +657,7 @@ public class ProjectController {
             String[] n = names.split("\\,");
             for (int i=0;i<id.length; i++) {
                 HashMap map = new HashMap();
-                map.put("id", id[i]);
+                map.put("id", Integer.parseInt(id[i]));
                 map.put("name", n[i]);
                 list.add(map);
             }
@@ -1622,8 +1623,6 @@ public class ProjectController {
     }
 
 
-
-
     //FTE报表
     @RequestMapping("/getProjectTaskPlanFTEData")
     public HttpRespMsg getProjectTaskPlanFTEData(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,String monthStart,String monthEnd,String area,String userId,String sortProp, Integer sortOrder,Integer departmentId,HttpServletRequest request){

+ 193 - 208
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/TaskController.java

@@ -16,6 +16,7 @@ import com.management.platform.service.impl.WxCorpInfoServiceImpl;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import lombok.extern.slf4j.Slf4j;
+import net.sourceforge.tess4j.ITessAPI;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.poi.hssf.usermodel.*;
 import org.assertj.core.util.Lists;
@@ -52,6 +53,15 @@ import java.util.stream.Collectors;
 @RequestMapping("/task")
 @Slf4j
 public class TaskController {
+    //任务状态,0-进行中 1-已完成 2-已撤销 3-待第一审核人审核 4-待第二审核人审核 5-第一审校人驳回 6-第二审校人驳回
+    public static final Integer STATUS_DOING = 0;
+    public static final Integer STATUS_FINISH = 1;
+    public static final Integer STATUS_CANCEL = 2;
+    public static final Integer STATUS_FIRST_CHECK = 3;
+    public static final Integer STATUS_SECOND_CHECK = 4;
+    public static final Integer STATUS_FIRST_REJECT = 5;
+    public static final Integer STATUS_SECOND_REJECT = 6;
+
     @Resource
     private HttpServletRequest request;
     @Resource
@@ -83,6 +93,8 @@ public class TaskController {
     @Resource
     private TaskMapper taskMapper;
     @Resource
+    private TaskTypeService taskTypeService;
+    @Resource
     private TaskExecutorMapper taskExecutorMapper;
     @Resource
     private ParticipationMapper participationMapper;
@@ -137,6 +149,10 @@ public class TaskController {
     public static HashMap<String, Integer> corpddJobCenter = new HashMap();
     @Autowired
     private ProjectCategoryMapper projectCategoryMapper;
+    @Autowired
+    private ReportExtraDegreeMapper reportExtraDegreeMapper;
+    @Autowired
+    private TaskTypeMapper taskTypeMapper;
 
     @PostMapping("/sendMsgToChargers")
     public HttpRespMsg sendMsgToChargers(
@@ -171,7 +187,7 @@ public class TaskController {
 
     @RequestMapping("/save")
     @Transactional
-    public HttpRespMsg save(Task task, @RequestParam(required = false, defaultValue = "false") boolean auditPass) throws Exception {
+    public HttpRespMsg save(Task task) throws Exception {
         String userId = request.getHeader("Token");
         String executorListStr = task.getExecutorListStr();
 
@@ -180,30 +196,35 @@ public class TaskController {
         HttpRespMsg msg = new HttpRespMsg();
         WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
         int isInsert=0;
-        int isUpdate=0;
+        boolean shouldResetAuditStatus = false;
+        List<TaskType> typeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", user.getCompanyId()));
+        TaskType taskType = typeList.stream().filter(t->t.getId()==task.getTaskPlanType()).findAny().orElse(null);
+        if (taskType == null){
+            msg.setError("任务类型不存在");
+            return msg;
+        }
         Project project = projectMapper.selectById(task.getProjectId());
-        String inchargerId = project.getInchargerId();
-        if (StringUtils.isEmpty(inchargerId)) {
+        String inchargerId = project != null ? project.getInchargerId() : null;
+        if (taskType.getNeedAudit() && project != null && StringUtils.isEmpty(inchargerId)) {
             msg.setError("请先设置项目经理");
             return msg;
         }
+
         //新建的任务,需要设置创建人,创建时间
         if (task.getId() == null) {
+            //检查权限,只有项目的LA才能创建
+            boolean isLA = projectLeaderMapper.selectCount(new LambdaQueryWrapper<ProjectLeader>().eq(ProjectLeader::getProjectId, task.getProjectId()).eq(ProjectLeader::getLeaderId, userId)) > 0;
             isInsert=1;
             task.setCreateDate(LocalDate.now());
             task.setCreaterId(userId);
             task.setCreaterName(user.getName());
             task.setCreatorColor(user.getColor());
             task.setCompanyId(user.getCompanyId());
-            if (task.getIsTaskPlan()==1){
-                task.setTaskPlan(1);
-                task.setTaskStatus(3);
-                //状态是请假 直接变成任务
-                if (task.getTaskPlanType()==3){
-                    task.setIsTaskPlan(0);
-                    task.setTaskStatus(0);
-                    task.setTaskPlan(1);
-                }
+            //无需审核,直接通过
+            if (!taskType.getNeedAudit()){
+                task.setTaskStatus(STATUS_DOING);
+            } else {
+                task.setTaskStatus(STATUS_FIRST_CHECK);
             }
         }
         if (!StringUtils.isEmpty(executorListStr)) {
@@ -214,15 +235,18 @@ public class TaskController {
                 User exeUser = allUsers.stream().filter(al->al.getId().equals(ex.getExecutorId())).findFirst().get();
                 ex.setExecutorName(exeUser.getName());
                 ex.setExecutorColor(exeUser.getColor());
-                ex.setFirstAuditorId(inchargerId);
-                //设置第二负责人,员工部门主要负责人
-                if (exeUser.getDepartmentId() != null && exeUser.getDepartmentId() > 0) {
-                    Department byId = departmentService.getById(exeUser.getDepartmentId());
-                    String managerId = byId.getManagerId();
-                    if (!StringUtils.isEmpty(managerId)) {
-                        ex.setSecondAuditorId(managerId);
-                    } else {
-                        msg.setError("请设置["+byId.getDepartmentName()+"]部门主要负责人");
+                //对于需要审核的任务,设置审核人
+                if (taskType.getNeedAudit()){
+                    ex.setFirstAuditorId(inchargerId);
+                    //设置第二负责人,员工部门主要负责人
+                    if (exeUser.getDepartmentId() != null && exeUser.getDepartmentId() > 0) {
+                        Department byId = departmentService.getById(exeUser.getDepartmentId());
+                        String managerId = byId.getManagerId();
+                        if (!StringUtils.isEmpty(managerId)) {
+                            ex.setSecondAuditorId(managerId);
+                        } else {
+                            msg.setError("请设置["+byId.getDepartmentName()+"]部门主要负责人");
+                        }
                     }
                 }
             });
@@ -333,8 +357,15 @@ public class TaskController {
                 needRecalculateProgress = true;
             }
         } else {
-            //更新的情况,需要对比是否修改了任务标题,更新子任务的parentTname
             Task oldTask = taskService.getById(task.getId());
+            if (taskType.getNeedAudit()) {
+                if (oldTask.getTaskStatus() == STATUS_CANCEL || oldTask.getTaskStatus() == STATUS_FIRST_REJECT || oldTask.getTaskStatus() == STATUS_SECOND_REJECT) {
+                    //重新提交
+                    task.setTaskStatus(STATUS_FIRST_CHECK);
+                    shouldResetAuditStatus = true;
+                }
+            }
+            //更新的情况,需要对比是否修改了任务标题,更新子任务的parentTname
             if (!oldTask.getName().equals(task.getName())) {
                 Task sample = new Task();
                 sample.setParentTname(task.getName());
@@ -366,14 +397,19 @@ public class TaskController {
                 taskExecutorService.removeByIds(ids);
             }
             if (task.getExecutorList().size() > 0) {
-                task.getExecutorList().forEach(exe->exe.setTaskId(task.getId()));
+                List<TaskExecutor> exeList = task.getExecutorList();
+                exeList.forEach(exe->exe.setTaskId(task.getId()));
+                if (shouldResetAuditStatus) {
+                    //重置审核状态为待第一审核人审核
+                    exeList.forEach(exe->exe.setAuditStatus(STATUS_FIRST_CHECK));
+                }
                 //之前就存在的执行人数据
-                List<TaskExecutor> oldHas = task.getExecutorList().stream().filter(t -> t.getId() != null).collect(Collectors.toList());
-                taskExecutorService.saveOrUpdateBatch(task.getExecutorList());
+                List<TaskExecutor> oldHas = exeList.stream().filter(t -> t.getId() != null).collect(Collectors.toList());
+                taskExecutorService.saveOrUpdateBatch(exeList);
                 //新增的执行人
-                msgRecepientList = task.getExecutorList().stream().filter(newT->!StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old->newT.getExecutorId().equals(old.getExecutorId())))
+                msgRecepientList = exeList.stream().filter(newT->!StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old->newT.getExecutorId().equals(old.getExecutorId())))
                         .map(TaskExecutor::getExecutorId).collect(Collectors.toList());
-                List<TaskExecutor> newAddExecutor = task.getExecutorList().stream().filter(newT -> !StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old -> newT.getExecutorId().equals(old.getExecutorId()))).collect(Collectors.toList());
+                List<TaskExecutor> newAddExecutor = exeList.stream().filter(newT -> !StringUtils.isEmpty(newT.getExecutorId()) && !oldExeList.stream().anyMatch(old -> newT.getExecutorId().equals(old.getExecutorId()))).collect(Collectors.toList());
                 if(newAddExecutor.size()>0){
                     newAddExecutor=newAddExecutor.stream().filter(n->n.getExecutorId()!=null).collect(Collectors.toList());
                     if((wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1)||(dingding!=null&&dingding.getContactNeedTranslate()==1)){
@@ -408,7 +444,6 @@ public class TaskController {
                         }
                     }
                 }
-
             }
             if(task.getStartDate()==null){
                 taskMapper.updateStartDate(task.getId());
@@ -422,40 +457,9 @@ public class TaskController {
             if ((oldTask.getTaskType() == 1 && task.getTaskType() != 1) || (oldTask.getTaskType() != 1 && task.getTaskType() == 1)) {
                 needRecalculateProgress = true;
             }
-            // 未驳回之前 第一审核人 修改工作计划
-            if (task.getIsTaskPlan()==1
-                    && auditPass
-                    &&task.getTaskStatus()==3){
-                isUpdate=1;
-                task.setTaskStatus(4);//待第二审核人审核
-            } else if (task.getIsTaskPlan() == 1
-                    && auditPass
-                    &&task.getTaskStatus()==4) {
-                isUpdate=2;
-                task.setTaskStatus(0);//变化为进行中
-                task.setIsTaskPlan(0);//不再是计划
-            }
-            // 驳回后,小组长对计划进行修改
-            if (task.getIsTaskPlan()==1
-                    &&(task.getTaskStatus()==5||task.getTaskStatus()==6)
-                    && auditPass //小组长保存并提交
-                    ){
-                isUpdate=3;
-                task.setTaskStatus(3);//待第一审核人审核
-            }
-            // 撤回后,对计划进行修改
-            if (task.getIsTaskPlan()==1 && (task.getTaskStatus()==2) && auditPass) {
-                if (user.getId().equals(project.getInchargerId())) {
-                    task.setTaskStatus(4);//待第二审核人审核
-                    isUpdate=5;
-                }
-                else {
-                    task.setTaskStatus(3);//待第一审核人审核
-                    isUpdate=4;
-                }
-            }
+
         }
-        if (task.getIsTaskPlan()==1) {
+        if (taskType.getNeedAudit()) {
             if (!task.getExecutorList().isEmpty()) {
                 List<User> userManagers = userMapper.selectList(new QueryWrapper<User>()
                         .eq("role_name", "区域经理&PM").eq("company_id",user.getCompanyId()));
@@ -467,11 +471,12 @@ public class TaskController {
                     }
                 }
             }
+
         }
         boolean saved = taskService.saveOrUpdate(task);
         //新增成功,给第一审核人发送信息提醒
         if (saved&&isInsert==1){
-            if (task.getIsTaskPlan()==1){
+            if (taskType.getNeedAudit()){
                 //给第一审核人发送信息提醒
                 msgRecepientList=new ArrayList<>();
                 log.info("添加工作计划,给第一审核人发送信息提醒");
@@ -484,59 +489,18 @@ public class TaskController {
                 information.setTime(LocalDateTime.now());
                 informationService.save(information);
             }
-        } else if (saved && isUpdate > 0) {
+        } else if (saved && shouldResetAuditStatus) {
             msgRecepientList=new ArrayList<>();
-            //第一审核人修改后, 变成待第二审核人审核
-            if (isUpdate==1||isUpdate==5){
-                for (TaskExecutor taskExecutor : task.getExecutorList()) {
-                    //给第二审核人发消息
-                    Information information = new Information();
-                    information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
-                    information.setTaskId(task.getId());
-                    information.setType(11);
-                    information.setUserId(taskExecutor.getSecondAuditorId());
-                    information.setTime(LocalDateTime.now());
-                    informationService.save(information);
-                }
-
-            }else if(isUpdate==2||isUpdate==6){
-                List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", task.getId()));
-                if(CollectionUtils.isNotEmpty(taskExecutorList)){
-                    for (TaskExecutor taskExecutor : taskExecutorList) {
-                        //给任务的执行人发送信息提醒
-                        User owner = userMapper.selectById(taskExecutor.getExecutorId());
-                        Information information = new Information();
-                        information.setMsg("您有新的任务");
-                        information.setContent(taskExecutor.getProjectId()==null?null:(""+taskExecutor.getProjectId()));
-                        information.setType(1);
-                        information.setUserId(owner.getId());
-                        information.setTime(LocalDateTime.now());
-                        informationService.save(information);
-                    }
-                }
-            } else if (isUpdate==3) {
-                //给第一审核人发送信息提醒
-                log.info("驳回后小组长修改,给第一审核人发送信息提醒");
-                User owner = userMapper.selectById(inchargerId);
-                Information information = new Information();
-                information.setType(11);
-                information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
-                information.setTaskId(task.getId());
-                information.setUserId(owner.getId());
-                information.setTime(LocalDateTime.now());
-                informationService.save(information);
-            } else if (isUpdate==4) {
-                //给第一审核人发送信息提醒
-                log.info("撤销后小组长修改,给第一审核人发送信息提醒");
-                User owner = userMapper.selectById(inchargerId);
-                Information information = new Information();
-                information.setType(11);
-                information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
-                information.setTaskId(task.getId());
-                information.setUserId(owner.getId());
-                information.setTime(LocalDateTime.now());
-                informationService.save(information);
-            }
+            //给第一审核人发送信息提醒
+            log.info("撤销/驳回后小组长修改,给第一审核人发送信息提醒");
+            User owner = userMapper.selectById(inchargerId);
+            Information information = new Information();
+            information.setType(11);
+            information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
+            information.setTaskId(task.getId());
+            information.setUserId(owner.getId());
+            information.setTime(LocalDateTime.now());
+            informationService.save(information);
         }
         if (task.getExecutorId() == null) {
             //清空执行人
@@ -564,9 +528,9 @@ public class TaskController {
         taskCommentMapper.insert(comment);
 
         //需要重新计算项目进度
-        if (needRecalculateProgress) {
-            updateProjectProgress(task.getProjectId());
-        }
+//        if (needRecalculateProgress) {
+//            updateProjectProgress(task.getProjectId());
+//        }
         if (msgRecepientList.size() > 0) {
             //发消息通知执行人, 带项目id
             msgRecepientList.forEach(msgRecepient->{
@@ -585,19 +549,6 @@ public class TaskController {
                         }
                         companyDingdingService.sendNewTaskMsg(dingding, recpUserList.stream().map(User::getDingdingUserid).collect(Collectors.joining(",")),
                                 task.getName(), endStr);
-                    } else if (recpUserList.get(0).getCorpwxUserid() != null) {
-                        String corpUid = recpUserList.stream().map(User::getCorpwxUserid).distinct().collect(Collectors.joining("|"));
-                        JSONObject json = new JSONObject();
-                        JSONArray dataJson = new JSONArray();
-                        JSONObject jsonObj = new JSONObject();
-                        jsonObj.put("key", "任务内容");
-                        jsonObj.put("value", task.getName());
-                        dataJson.add(jsonObj);
-                        json.put("template_id", "tty9TkCAAAovv416zsWtn0e06CJ635HA");
-                        json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=task#wechat_redirect");
-                        json.put("content_item", dataJson);
-                        //todo:发送消息提醒任务
-                        wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo, corpUid, json);
                     }
                 }
             }
@@ -650,20 +601,20 @@ public class TaskController {
         return msg;
     }
 
-    private void updateProjectProgress(Integer projectId) {
-        //只有里程碑才更新项目进度, 非已撤销状态的
-        List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1),null,null);
-        Project project = new Project();
-        project.setId(projectId);
-        if (all.size() > 0) {
-            long running = all.stream().filter(a -> a.getTaskStatus() == 1).count();
-            int progress = ((int) running) * 100 / all.size();
-            project.setProgress(progress);
-        } else {
-            project.setProgress(0);
-        }
-        projectService.updateById(project);
-    }
+//    private void updateProjectProgress(Integer projectId) {
+//        //只有里程碑才更新项目进度, 非已撤销状态的
+//        List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1),null,null);
+//        Project project = new Project();
+//        project.setId(projectId);
+//        if (all.size() > 0) {
+//            long running = all.stream().filter(a -> a.getTaskStatus() == 1).count();
+//            int progress = ((int) running) * 100 / all.size();
+//            project.setProgress(progress);
+//        } else {
+//            project.setProgress(0);
+//        }
+//        projectService.updateById(project);
+//    }
 
     @RequestMapping("/finish")
     public HttpRespMsg finish(Task task,String personLiableIds,String reason) {
@@ -790,10 +741,10 @@ public class TaskController {
         }
 
         //如果是里程碑,需要更新项目完成度
-        if (curTask.getTaskType() == 1) {
-            Integer projectId = curTask.getProjectId();
-            updateProjectProgress(projectId);
-        }
+//        if (curTask.getTaskType() == 1) {
+//            Integer projectId = curTask.getProjectId();
+//            updateProjectProgress(projectId);
+//        }
         return msg;
     }
 
@@ -897,7 +848,6 @@ public class TaskController {
             //已超期的任务,未完成的任务
             queryWrapper.lt("end_date", LocalDate.now()).eq("task_status", 0);
         }
-        queryWrapper.eq("is_task_plan",0);
         List<Task> list = taskService.simpleList(queryWrapper,start,size);
         int total = taskMapper.selectCount(queryWrapper);
         //没有权限只能看到自己创建的,负责的和待分配的任务
@@ -1028,7 +978,6 @@ public class TaskController {
         String userId = request.getHeader("Token");
         User user = userMapper.selectById(userId);
         Task t = taskService.getById(id);
-        List<SapProjectService> serviceList = sapProjectServiceService.list(new LambdaQueryWrapper<SapProjectService>().eq(SapProjectService::getCompanyId, user.getCompanyId()));
         if (t == null) {
             //msg.setError("该任务已不存在");
             msg.setError(MessageUtils.message("Stages.noExist"));
@@ -1061,47 +1010,50 @@ public class TaskController {
             userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, phone, job_number, department_id, is_active").eq("company_id", user.getCompanyId()).eq("is_active", 1));
         }
         t.setUserList(userList);
-        if (t.getTaskPlanType()==null||t.getTaskPlanType()!=3) {
-            //查询项目负责人id以及所属任务分组负责人id
-            Project project = projectService.getOne(new QueryWrapper<Project>().eq("id", t.getProjectId()));
-            TaskGroup group = taskGroupService.getOne(new QueryWrapper<TaskGroup>().eq("id", t.getGroupId()));
-            t.setProjectInchargerId(project.getInchargerId() == null ? "" : project.getInchargerId());
-            t.setGroupInchargerId(group.getInchargerId() == null ? "" : group.getInchargerId());
-            //判断当前用户是否有权限创建任务: 有权限的包括管理全部项目,项目创建人,项目PM, 分组负责人,分组参与人
-            List<SysRichFunction> manageAllProjects = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "管理全部项目");
-            boolean canAddTask = false;
-            Integer companyId = user.getCompanyId();
-            TaskAddCtrl taskAddCtrl = taskAddCtrlMapper.selectById(companyId);
-            if (taskAddCtrl == null) {
-                //没有的话,默认生成一个
-                taskAddCtrl = new TaskAddCtrl();
-                taskAddCtrl.setCompanyId(companyId);
-                taskAddCtrl.setCtrlType(1);//0-普通项目参与人不可添加任务,1-项目参与人可添加,2-仅分组参与人可添加
-                taskAddCtrlMapper.insert(taskAddCtrl);
-            }
-            if (manageAllProjects.size() > 0 || userId.equals(project.getCreatorId()) || userId.equals(project.getInchargerId())) {
-                canAddTask = true;
+        String associateDegrees = "";
+        String names = "";
+        Project project = projectService.getById(t.getProjectId());
+        associateDegrees = project.getAssociateDegrees();
+        names = project.getAssociateDegreeNames();
+        List<HashMap> degreeList = new ArrayList<>();
+        if (!StringUtils.isEmpty(associateDegrees)) {
+            String[] idArray = associateDegrees.split("\\,");
+            String[] n = names.split("\\,");
+            for (int i=0;i<idArray.length; i++) {
+                HashMap map = new HashMap();
+                map.put("id", Integer.parseInt(idArray[i]));
+                map.put("name", n[i]);
+                degreeList.add(map);
             }
-            if (!canAddTask) {
-                //进一步判断是否是分组的负责人,参与人
-                if (userId.equals(group.getInchargerId())) {
-                    canAddTask = true;
-                }
-                if (!canAddTask) {
-                    Integer ctrlType = taskAddCtrl.getCtrlType();
-                    if (ctrlType == 1) {
-                        canAddTask = true;
-                    } else if (ctrlType == 2) {
-                        //分组参与人可以创建任务
-                        int count = groupParticipatorMapper.selectCount(new QueryWrapper<GroupParticipator>().eq("user_id", userId).eq("group_id", group.getId()));
-                        if (count > 0) {
-                            canAddTask = true;
-                        }
-                    }
+        }
+        t.setDegreeList(degreeList);
+
+        //判断任务是否处于可编辑状态,以及当前人员是否有编辑权限
+        List<TaskType> taskTypeList = taskTypeService.list(new QueryWrapper<TaskType>().eq("company_id", user.getCompanyId()));
+        Optional<TaskType> taskType = taskTypeList.stream().filter(t1 -> t1.getId().equals(t.getTaskPlanType())).findFirst();
+        Boolean needAudit = taskType.get().getNeedAudit();
+        //判断是否是LA
+        boolean isLA = projectLeaderMapper.selectCount(new LambdaQueryWrapper<ProjectLeader>().eq(ProjectLeader::getProjectId, t.getProjectId()).eq(ProjectLeader::getLeaderId, userId)) > 0;
+        if (needAudit) {
+            //不同状态下对应不同的人员可以修改
+            if (isLA && (t.getTaskStatus() == STATUS_CANCEL || t.getTaskStatus() == STATUS_FIRST_REJECT || t.getTaskStatus() == STATUS_SECOND_REJECT)) {
+                t.setCanEditTask(true);
+            } else if (t.getTaskStatus() == STATUS_FIRST_CHECK && project.getInchargerId().equals(userId)) {
+                t.setCanEditTask(true);
+            } else if (t.getTaskStatus() == STATUS_SECOND_CHECK) {
+                //检查第二审核人
+                boolean isSecondAuditor = executorList.stream().anyMatch(e->e.getSecondAuditorId().equals(userId));
+                if (isSecondAuditor) {
+                    t.setCanEditTask(true);
                 }
             }
-            t.setCanAddTask(canAddTask);
+        } else {
+            //无需审核,LA随时可以修改
+            if (isLA) {
+                t.setCanEditTask(true);
+            }
         }
+
         msg.data = t;
         return msg;
     }
@@ -1180,23 +1132,23 @@ public class TaskController {
              * 任务状态,0-进行中 1-已完成 2-已撤销 3-待第一审核人审核 4-待第二审核人审核 5-第一审核人驳回  6-第二审核人驳回
              */
             //待第一审核人审核
-            if (task.getTaskStatus()==3&&task.getIsTaskPlan()==1){
+            if (task.getTaskStatus()==3){
                 msg.setError("当前计划已处于一级审核状态,小组长不能删除");
                 return msg;
-            }else if(task.getTaskStatus()==4&&task.getIsTaskPlan()==1){
+            }else if(task.getTaskStatus()==4){
                 msg.setError("当前计划已处于二级审核状态,小组长不能删除");
                 return msg;
-            }else if(task.getTaskStatus()==0&&task.getIsTaskPlan()==0){
+            }else if(task.getTaskStatus()==0){
                 msg.setError("当前计划已审核通过,小组长不能删除");
                 return msg;
             }
         }
 
         if (project.getInchargerId()!=null&&project.getInchargerId().equals(user.getId())){
-            if(task.getTaskStatus()==4&&task.getIsTaskPlan()==1){
+            if(task.getTaskStatus()==4){
                 msg.setError("当前计划已处于二级审核状态,项目经理不能删除");
                 return msg;
-            }else if(task.getTaskStatus()==0&&task.getIsTaskPlan()==0){
+            }else if(task.getTaskStatus()==0){
                 msg.setError("当前计划已审核通过,项目经理不能删除");
                 return msg;
             }
@@ -1204,7 +1156,7 @@ public class TaskController {
 
         List<TaskExecutor> executorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", id));
         for (TaskExecutor executor : executorList) {
-            if (task.getTaskStatus()==3&&task.getIsTaskPlan()==1 && user.getId().equals(executor.getSecondAuditorId())) {
+            if (task.getTaskStatus()==3 && user.getId().equals(executor.getSecondAuditorId())) {
                 msg.setError("当前计划已处于一级审核状态,区域经理不能删除");
                 return msg;
             }
@@ -1237,9 +1189,9 @@ public class TaskController {
 
 
         //删除里程碑,需要重新计算项目进度
-        if (task.getTaskType() == 1) {
-            updateProjectProgress(task.getProjectId());
-        }
+//        if (task.getTaskType() == 1) {
+//            updateProjectProgress(task.getProjectId());
+//        }
         return new HttpRespMsg();
     }
 
@@ -1505,19 +1457,32 @@ public class TaskController {
         QueryWrapper<Task> queryWrapper = new QueryWrapper<>();
 
         //任务状态
-        queryWrapper.eq("task_status", status).eq("task.company_id", companyId);
+        queryWrapper.eq("task.company_id", companyId);
+        if (viewId == 0 || viewId == 1 || viewId == 2) {
+            if (status == 1 || status == 0) {
+                queryWrapper.eq("task.task_status", status);
+            } else if (status == 2) {
+                //待审核,包括第一个和第二审核人待审核
+                queryWrapper.and(i -> i.eq("task.task_status", 3).or().eq("task.task_status", 4));
+            } else if (status == 3) {
+                //已驳回,包括第一个和第二审核人驳回,5,6
+                queryWrapper.and(i -> i.eq("task.task_status", 5).or().eq("task.task_status", 6));
+            } else if (status == 4) {
+                //撤回状态的
+                queryWrapper.eq("task.task_status", 2);
+            }
+        }
         if (viewId == 1) {
             //我执行的任务
-            queryWrapper.like("executor_id", userId);
+            queryWrapper.like("task.executor_id", userId);
         } else if (viewId == 2) {
             //我创建的任务
-            queryWrapper.eq("creater_id", userId);
+            queryWrapper.eq("task.creater_id", userId);
         } else if (viewId == 3) {
-            //我审核的
-
+            //我审核的,忽略状态,只查询待审核的任务
         }
         if(type!=null){
-            queryWrapper.eq("task_type",type);
+            queryWrapper.eq("task_plan_type",type);
         }
         if(dateType!=null){
             switch (dateType){
@@ -1551,8 +1516,7 @@ public class TaskController {
         if(pageIndex!=null&&pageSize!=null){
             pageStart = (pageIndex - 1) * pageSize;
         }
-        //美莱德 任务计划状态是1
-        queryWrapper.ne("is_task_plan",1);
+        List<TaskType> taskTypeList = taskTypeMapper.selectList(new QueryWrapper<TaskType>().eq("company_id", companyId));
         List<TaskWithAuditor> list;
         if (viewId == 3) {
             list = taskMapper.getMyAuditTaskList(queryWrapper,pageStart, pageSize,userId);
@@ -1572,8 +1536,9 @@ public class TaskController {
             if (first.isPresent()) {
                 l.setProjectInchargerId(first.get().getInchargerId());
             }
+            taskTypeList.stream().filter(t->t.getId().equals(l.getTaskPlanType())).findFirst().ifPresent(t->l.setTaskPlanTypeName(t.getName()));
         });
-        int total = taskMapper.selectCount(queryWrapper);
+        int total = viewId == 3?taskMapper.getMyAuditTaskCount(queryWrapper,userId):taskMapper.selectCount(queryWrapper);
         Map<String, Object> map = new HashMap<>();
         map.put("records", list);
         map.put("total", total);
@@ -1581,6 +1546,21 @@ public class TaskController {
         return msg;
     }
 
+    /**
+     * 获取待审核的数量
+     * @return
+     */
+    @RequestMapping("/getMyAuditCount")
+    public HttpRespMsg getMyAuditCount() {
+        HttpRespMsg msg = new HttpRespMsg();
+        String userId = request.getHeader("Token");
+        User user = userMapper.selectById(userId);
+        Integer companyId = user.getCompanyId();
+        Integer count = taskMapper.getMyAuditTaskCount(new QueryWrapper<Task>().eq("task.company_id", companyId), userId);
+        msg.data = count;
+        return msg;
+    }
+
     private List<Integer> getBranchDepartment(Integer departmentId, List<Department> departmentList) {
         List<Integer> list = new ArrayList<>();
         list.add(departmentId);
@@ -1790,8 +1770,13 @@ public class TaskController {
     //工作计划的通过或者驳回
     //通过 type=true ,驳回 type=false
     @RequestMapping("/taskPlanPassOrReject")
-    public HttpRespMsg taskPlanPassOrReject(Integer taskId, boolean type){
-        return taskService.taskPlanPassOrReject(taskId,type,request);
+    public HttpRespMsg taskPlanPassOrReject(Integer taskId, boolean type, String reason){
+        return taskService.taskPlanPassOrReject(taskId,type,reason,request);
+    }
+
+    @RequestMapping("/cancelByManager")
+    public HttpRespMsg cancelByManager(Integer id){
+        return taskService.cancelByManager(id,request);
     }
 
 

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/controller/TaskTypeController.java

@@ -58,7 +58,7 @@ public class TaskTypeController {
             }
         }
 
-        taskTypeService.save(taskType);
+        taskTypeService.saveOrUpdate(taskType);
         return new HttpRespMsg();
     }
 

+ 39 - 6
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/entity/Task.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+import java.util.HashMap;
 import java.util.List;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -17,11 +18,11 @@ import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * @author Seyason
- * @since 2025-05-12
+ * @since 2025-05-14
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -85,7 +86,7 @@ public class Task extends Model<Task> {
     private Integer taskLevel;
 
     /**
-     * 任务状态,0-进行中 1-已完成 2-已撤销 3-待第一审核人审核 4-待第二审核人审核 5-驳回
+     * 任务状态,0-进行中 1-已完成 2-已撤销 3-待第一审核人审核 4-待第二审核人审核 5-第一审校人驳回 6-第二审校人驳回
      */
     @TableField("task_status")
     private Integer taskStatus;
@@ -94,8 +95,6 @@ public class Task extends Model<Task> {
      * 创建时间
      */
     @TableField("create_date")
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
     private LocalDate createDate;
 
     /**
@@ -128,6 +127,8 @@ public class Task extends Model<Task> {
      * 创建时间戳
      */
     @TableField("indate")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime indate;
 
     /**
@@ -241,6 +242,27 @@ public class Task extends Model<Task> {
      */
     @TableField("center_name")
     private String centerName;
+
+    /**
+     * 驳回人
+     */
+    @TableField("reject_user_id")
+    private String rejectUserId;
+
+    /**
+     * 驳回原因
+     */
+    @TableField("task_reject_reason")
+    private String taskRejectReason;
+
+    /**
+     * 驳回时间
+     */
+    @TableField("reject_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime rejectTime;
+
     /**
      * 项目负责人id
      */
@@ -266,7 +288,7 @@ public class Task extends Model<Task> {
     private String departmentName;
 
     @TableField(exist = false)
-    private boolean canAddTask;
+    private boolean canEditTask;
 
     @TableField(exist = false)
     private String finalChargeStatusText;
@@ -281,6 +303,7 @@ public class Task extends Model<Task> {
      * 任务的外置状态显示 1审核中[待审核+(审核通过)] 2驳回[存在驳回文件]  3审核通过[全部审核通过]
      * */
     private int fileChargeStatus;
+
     @TableField(exist = false)
     private List<Task> subTaskList;
 
@@ -294,6 +317,16 @@ public class Task extends Model<Task> {
 
     @TableField(exist = false)
     private String projectName;
+
+    @TableField(exist = false)
+    private List<HashMap> degreeList;
+
+    @TableField(exist = false)
+    private String taskPlanTypeName;
+
+    @TableField(exist = false)
+    private String rejectUserName;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 15 - 5
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/entity/TaskExecutor.java

@@ -18,7 +18,7 @@ import lombok.experimental.Accessors;
  * </p>
  *
  * @author Seyason
- * @since 2025-05-12
+ * @since 2025-05-14
  */
 @Data
 @EqualsAndHashCode(callSuper = false)
@@ -96,6 +96,17 @@ public class TaskExecutor extends Model<TaskExecutor> {
     @TableField("second_auditor_id")
     private String secondAuditorId;
 
+    /**
+     * 0-已通过,3-待第一审核人审核,4-待第二审核人审核,5-第一审核人驳回,6-第二审核人驳回
+     */
+    @TableField("audit_status")
+    private Integer auditStatus;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
     @TableField(exist = false)
     private String fileChargeTwoName;
 
@@ -107,10 +118,9 @@ public class TaskExecutor extends Model<TaskExecutor> {
 
     @TableField(exist = false)
     private String chargeOneWxId;
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
+
+    @TableField(exist = false)
+    private boolean isSecAuditor;
 
     public static List<TaskExecutor> fromTask(Task task) {
         String[] executorIdString = task.getExecutorId().split(",");

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/mapper/TaskMapper.java

@@ -90,5 +90,6 @@ public interface TaskMapper extends BaseMapper<Task> {
     List<ProjectTimeCostVO> getProjectTaskTimeCostByIds(@Param("projectIds")List<Integer> projectIds);
 
     List getMyAuditTaskList(@Param(Constants.WRAPPER) Wrapper wrapper, Integer pageStart, Integer pageSize,String userId);
+    Integer getMyAuditTaskCount(@Param(Constants.WRAPPER) Wrapper wrapper,String userId);
 
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/ProjectService.java

@@ -21,7 +21,7 @@ import java.time.LocalDate;
  * @since 2020-01-03
  */
 public interface ProjectService extends IService<Project> {
-    HttpRespMsg getProjectList(Integer forReport, String userId,Integer projectMainId, HttpServletRequest request);
+    HttpRespMsg getProjectList(Integer forReport, Integer forTask, String userId,Integer projectMainId, HttpServletRequest request);
 
     HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
                                Integer status, Integer category, Integer projectId,Integer projectMainId,Integer deptId, String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate, HttpServletRequest request);

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/TaskService.java

@@ -65,5 +65,7 @@ public interface TaskService extends IService<Task> {
 
     HttpRespMsg sendMsgToChargers(String ids, HttpServletRequest request);
 
-    HttpRespMsg taskPlanPassOrReject(Integer taskId,boolean type, HttpServletRequest request);
+    HttpRespMsg taskPlanPassOrReject(Integer taskId,boolean type, String reason,HttpServletRequest request);
+
+    HttpRespMsg cancelByManager(Integer id, HttpServletRequest request);
 }

+ 14 - 5
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -695,7 +695,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     //获取项目列表
     @Override
-    public HttpRespMsg getProjectList(Integer forReport, String userId,Integer projectMainId, HttpServletRequest request) {
+    public HttpRespMsg getProjectList(Integer forReport,Integer forTask, String userId,Integer projectMainId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             System.out.println("userId===="+userId);
@@ -718,6 +718,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     }
                     httpRespMsg.data = projectMapper.selectList(queryWrapper);
                 }
+            } if (forTask == 1) {
+                //创建任务计划,只能获取自己担任LA的项目
+                //有权限的填报全部的进行中项目
+                QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("company_id", user.getCompanyId())
+                        .eq("status", 1).orderByDesc("id");
+                List<Integer> leaderProjectIds = projectLeaderService.list(new QueryWrapper<ProjectLeader>().eq("leader_id", user.getId())).stream().map(ProjectLeader::getProjectId).collect(Collectors.toList());
+                if (leaderProjectIds.size() > 0) {
+                    queryWrapper.in("id", leaderProjectIds);
+                    httpRespMsg.data = projectMapper.selectList(queryWrapper);
+                } else {
+                    httpRespMsg.data = new ArrayList<>();
+                }
             } else {
                 if (!sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部项目")) {
                     if (projectMainId!=null){
@@ -1896,10 +1909,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         projectLeaderService.saveBatch(leaderArrayList);
                     }
                     id = project.getId();
-                    if(companyId==936){
-                        projectSeparate.setId(id);
-                        projectSeparateMapper.insert(projectSeparate);
-                    }
                     //项目管理专业版要自动生成任务分组
                     if (company.getPackageProject() == 1) {
                         taskGroupService.initGroup(companyId, id, user);

+ 143 - 86
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.util.StringUtil;
+import com.management.platform.controller.TaskController;
 import com.management.platform.entity.*;
 import com.management.platform.entity.bo.QueryTaskChargePage;
 import com.management.platform.entity.vo.OtherTaskFileInfoVO;
@@ -1057,95 +1058,151 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     }
 
     @Override
-    public HttpRespMsg taskPlanPassOrReject(Integer taskId,boolean type, HttpServletRequest request) {
+    public HttpRespMsg taskPlanPassOrReject(Integer taskId,boolean type, String reason, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
         String userId = request.getHeader("Token");
-        User user = userMapper.selectById(userId);
+        Task task = taskMapper.selectById(taskId);
+        Project project = projectMapper.selectById(task.getProjectId());
+        List<TaskExecutor> executorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", task.getId()));;
+        if (task.getTaskStatus() == TaskController.STATUS_FIRST_CHECK || task.getTaskStatus() == TaskController.STATUS_SECOND_CHECK){
+            if (task.getTaskStatus() == TaskController.STATUS_FIRST_CHECK){
+                //校验第一审核人
+                if (!userId.equals(project.getInchargerId())){
+                    msg.setError("当前人员不是第一审核人,不能审核");
+                    return msg;
+                }
+            } else if (task.getTaskStatus() == TaskController.STATUS_SECOND_CHECK){
+                //校验第二审核人
+                executorList.forEach(e->{
+                    if (userId.equals(e.getSecondAuditorId())){
+                        e.setSecAuditor(true);
+                    }
+                });
+                if (executorList.stream().noneMatch(e->e.isSecAuditor())) {
+                    msg.setError("当前人员不是第二审核人,不能审核");
+                    return msg;
+                }
+            }
+        } else {
+            msg.setError("当前任务不是待审核状态,不能审核");
+            return msg;
+        }
+        //通过
+        if (type){
+            //第一审核人通过
+            if (task.getTaskStatus()== TaskController.STATUS_FIRST_CHECK){
+                task.setTaskStatus(TaskController.STATUS_SECOND_CHECK);
+                taskMapper.updateById(task);
+                executorList.forEach(e->{
+                    e.setAuditStatus(TaskController.STATUS_SECOND_CHECK);
+                    taskExecutorMapper.updateById(e);
+                });
 
-//        Task task = taskMapper.selectById(taskId);
-//        if (!userId.equals(task.getCheckFirstId())&&!userId.equals(task.getCheckSecondId())){
-//            msg.setError("当前人员不是审核人,不能审核");
-//            return msg;
-//        }
-//        //通过
-//        if (type){
-//            //第一审核人通过
-//            if (task.getIsTaskPlan()==1&&task.getTaskStatus()==3
-//                    && StringUtils.isNotEmpty(task.getCheckFirstId())
-//                    &&userId.equals(task.getCheckFirstId())){
-//                task.setTaskStatus(4);
-//                taskMapper.updateById(task);
-//                //给第二审核人发送信息提醒
-//                User owner = userMapper.selectById(task.getCheckSecondId());
-//                Information information = new Information();
-//                Project project = projectMapper.selectById(task.getProjectId());
-//                information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
-//                information.setTaskId(task.getId());
-//                information.setUserId(owner.getId());
-//                information.setType(11);
-//                information.setTime(LocalDateTime.now());
-//                informationMapper.insert(information);
-//            }
-//            //第二审核人通过
-//            else if (task.getIsTaskPlan() == 1 && task.getTaskStatus() == 4
-//                    && StringUtils.isNotEmpty(task.getCheckSecondId())
-//                    && userId.equals(task.getCheckSecondId())) {
-//
-//                task.setTaskStatus(0);
-//                task.setIsTaskPlan(0);
-//                taskMapper.updateById(task);
-//
-//                List<TaskExecutor> taskExecutorList = taskExecutorMapper.selectList(new QueryWrapper<TaskExecutor>().eq("task_id", taskId));
-//                if(CollectionUtils.isNotEmpty(taskExecutorList)){
-//                    for (TaskExecutor taskExecutor : taskExecutorList) {
-//                        //给任务的执行人发送信息提醒
-//                        User owner = userMapper.selectById(taskExecutor.getExecutorId());
-//                        Information information = new Information();
-//                        information.setMsg("您有新的任务");
-//                        information.setContent(taskExecutor.getProjectId()==null?null:(""+taskExecutor.getProjectId()));
-//                        information.setType(1);
-//                        information.setUserId(owner.getId());
-//                        information.setTime(LocalDateTime.now());
-//                        informationMapper.insert(information);
-//                    }
-//                }
-//            }
-//        }
-//        //驳回
-//        else {
-//            //第一审核人驳回
-//            if (task.getIsTaskPlan()==1&&task.getTaskStatus()==3
-//                    && StringUtils.isNotEmpty(task.getCheckFirstId())
-//                    &&userId.equals(task.getCheckFirstId())){
-//                task.setTaskStatus(5);
-//                taskMapper.updateById(task);
-//                //给小组长发送信息提醒
-//                User owner = userMapper.selectById(task.getCreaterId());
-//                Information information = new Information();
-//                information.setMsg("您有工作计划被驳回");
-//                information.setType(11);
-//                information.setUserId(owner.getId());
-//                information.setTime(LocalDateTime.now());
-//                informationMapper.insert(information);
-//            }
-//            //第二审核人驳回
-//            else if (task.getIsTaskPlan() == 1 && task.getTaskStatus() == 4
-//                    && StringUtils.isNotEmpty(task.getCheckSecondId())
-//                    && userId.equals(task.getCheckSecondId())) {
-//
-//                task.setTaskStatus(6);
-//                taskMapper.updateById(task);
-//
-//                //给小组长发送信息提醒
-//                User owner = userMapper.selectById(task.getCreaterId());
-//                Information information = new Information();
-//                information.setMsg("您有工作计划被驳回");
-//                information.setType(11);
-//                information.setUserId(owner.getId());
-//                information.setTime(LocalDateTime.now());
-//                informationMapper.insert(information);
-//            }
-//        }
+                //给第二审核人发送信息提醒
+                executorList.forEach(e->{
+                    User owner = userMapper.selectById(e.getSecondAuditorId());
+                    Information information = new Information();
+                    information.setMsg(project.getProjectName()+"项目有新的预计FTE计划审批任务,请您查收.");
+                    information.setTaskId(task.getId());
+                    information.setUserId(owner.getId());
+                    information.setType(11);
+                    information.setTime(LocalDateTime.now());
+                    informationMapper.insert(information);
+                });
+            }
+            //第二审核人通过
+            else if (task.getTaskStatus() == TaskController.STATUS_SECOND_CHECK) {
+                executorList.stream().filter(e->e.isSecAuditor()).forEach(e->{
+                    e.setAuditStatus(TaskController.STATUS_DOING);
+                    taskExecutorMapper.updateById(e);
+                });
+                //如果没有待审核的,整个任务都算审核通过
+                if (executorList.stream().noneMatch(e->e.getAuditStatus() != TaskController.STATUS_DOING)) {
+                    task.setTaskStatus(TaskController.STATUS_DOING);
+                    taskMapper.updateById(task);
+                    //整个任务都审核通过了,才算正式发布
+                    if(CollectionUtils.isNotEmpty(executorList)){
+                        for (TaskExecutor taskExecutor : executorList) {
+                            //给任务的执行人发送信息提醒
+                            User owner = userMapper.selectById(taskExecutor.getExecutorId());
+                            Information information = new Information();
+                            information.setMsg("您有新的任务");
+                            information.setContent(taskExecutor.getProjectId()==null?null:(""+taskExecutor.getProjectId()));
+                            information.setType(1);
+                            information.setUserId(owner.getId());
+                            information.setTime(LocalDateTime.now());
+                            informationMapper.insert(information);
+                        }
+                    }
+                }
+            }
+        }
+        //驳回
+        else {
+            //第一审核人驳回
+            if (task.getTaskStatus() == TaskController.STATUS_FIRST_CHECK){
+                task.setTaskStatus(TaskController.STATUS_FIRST_REJECT);
+                task.setRejectUserId(userId);
+                task.setRejectTime(LocalDateTime.now());
+                task.setTaskRejectReason(reason);
+                taskMapper.updateById(task);
+                executorList.forEach(e->{
+                    e.setAuditStatus(TaskController.STATUS_FIRST_REJECT);
+                    taskExecutorMapper.updateById(e);
+                });
+                //给小组长发送信息提醒
+                User owner = userMapper.selectById(task.getCreaterId());
+                Information information = new Information();
+                information.setMsg("您有工作计划被驳回");
+                information.setType(11);
+                information.setUserId(owner.getId());
+                information.setTime(LocalDateTime.now());
+                informationMapper.insert(information);
+            }
+            //第二审核人驳回
+            else if (task.getTaskStatus() == TaskController.STATUS_SECOND_CHECK) {
+                executorList.stream().filter(e->e.isSecAuditor()).forEach(e->{
+                    e.setAuditStatus(TaskController.STATUS_SECOND_REJECT);
+                    taskExecutorMapper.updateById(e);
+                });
+                //只要有一个驳回了,这个任务就算驳回了
+                task.setTaskStatus(TaskController.STATUS_SECOND_REJECT);
+                task.setRejectUserId(userId);
+                task.setRejectTime(LocalDateTime.now());
+                task.setTaskRejectReason(reason);
+                taskMapper.updateById(task);
+
+                //给小组长发送信息提醒
+                User owner = userMapper.selectById(task.getCreaterId());
+                Information information = new Information();
+                information.setMsg("您有工作计划被驳回");
+                information.setType(11);
+                information.setUserId(owner.getId());
+                information.setTime(LocalDateTime.now());
+                informationMapper.insert(information);
+            }
+        }
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg cancelByManager(Integer id, HttpServletRequest request) {
+        HttpRespMsg msg = new HttpRespMsg();
+        String token = request.getHeader("TOKEN");
+        User user = userMapper.selectById(token);
+        Task task = taskMapper.selectById(id);
+        if (task.getTaskStatus() == TaskController.STATUS_DOING) {
+            task.setTaskStatus(TaskController.STATUS_CANCEL);
+            taskMapper.updateById(task);
+            //给小组长发送信息提醒
+            User owner = userMapper.selectById(task.getCreaterId());
+            Information information = new Information();
+            information.setMsg("您有工作计划被取消");
+            information.setType(11);
+            information.setUserId(owner.getId());
+            information.setTime(LocalDateTime.now());
+            informationMapper.insert(information);
+        }
         return msg;
     }
 

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/TaskExecutorMapper.xml

@@ -17,11 +17,12 @@
         <result column="file_charge_two_id" property="fileChargeTwoId" />
         <result column="first_auditor_id" property="firstAuditorId" />
         <result column="second_auditor_id" property="secondAuditorId" />
+        <result column="audit_status" property="auditStatus" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, task_id, executor_id, executor_name, executor_color, plan_hours, project_id, service_id, real_cost, file_charge_one_id, file_charge_two_id, first_auditor_id, second_auditor_id
+        id, task_id, executor_id, executor_name, executor_color, plan_hours, project_id, service_id, real_cost, file_charge_one_id, file_charge_two_id, first_auditor_id, second_auditor_id, audit_status
     </sql>
     <select id="getInfoWithFileCharge" resultType="com.management.platform.entity.TaskExecutor">
         select te.id as id,   task_id, executor_id, executor_name, executor_color, plan_hours, project_id

+ 24 - 7
fhKeeper/formulahousekeeper/management-platform-mld/src/main/resources/mapper/TaskMapper.xml

@@ -39,6 +39,9 @@
         <result column="is_task_plan" property="isTaskPlan" />
         <result column="center_id" property="centerId" />
         <result column="center_name" property="centerName" />
+        <result column="reject_user_id" property="rejectUserId" />
+        <result column="task_reject_reason" property="taskRejectReason" />
+        <result column="reject_time" property="rejectTime" />
     </resultMap>
     <resultMap id="timeResultMap" type="com.management.platform.entity.TimeTask" >
         <id column="id" property="id" />
@@ -146,12 +149,11 @@
         <result column="first_auditor_name" property="firstAuditorName" />
         <result column="second_auditor_id" property="secondAuditorId" />
         <result column="second_auditor_name" property="secondAuditorName" />
+        <result column="reject_user_name" property="rejectUserName" />
     </resultMap>
-
-
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, name, task_desc, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date, meeting_id, ahead_tid, sap_task_code, plan_cost, attach_file_required, task_plan_type, task_plan, is_task_plan, center_id, center_name
+        id, name, task_desc, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date, meeting_id, ahead_tid, sap_task_code, plan_cost, attach_file_required, task_plan_type, task_plan, is_task_plan, center_id, center_name, reject_user_id, task_reject_reason, reject_time
     </sql>
     <select id="simpleList" resultMap="BaseResultMap">
         select id, name, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date
@@ -321,9 +323,13 @@
     </select>
     <select id="getTaskWithProjectName" resultMap="AuditorResultMap">
         SELECT task.id, task.project_id, task.name, task.executor_name, task.start_date, task.`end_date`,task.create_date, task.`creater_id`, task.`creater_name`, task.group_id,
-        task.plan_hours, task.task_type, task.task_level, task.task_status, task.`finish_date`, project.`project_name`, stages.stages_name,department.department_name
-        <!-- ,task.charge_one_id,task.charge_one_status,task.charge_two_id,task.charge_two_status,task.charge_stage,task.final_charge_status -->
+        task.plan_hours, task.task_type,task.task_plan_type, task.task_reject_reason,task.reject_user_id, user.name as reject_user_name, task.reject_time, task.task_level, task.task_status, task.`finish_date`, project.`project_name`, stages.stages_name,department.department_name,
+        task_executor.`first_auditor_id`, group_concat(task_executor.`second_auditor_id`) as second_auditor_id, u1.name AS first_auditor_name, group_concat(u2.`name`) AS second_auditor_name
         FROM task LEFT JOIN project ON project.id = task.`project_id`
+        left join task_executor on task_executor.task_id=task.id
+        LEFT JOIN USER u1 ON u1.id = task_executor.`first_auditor_id`
+        LEFT JOIN USER u2 ON u2.id = task_executor.`second_auditor_id`
+        left join user on user.id = task.`reject_user_id`
         left join stages on stages.id = task.stages_id
         left join department on department.department_id=project.dept_id
         ${ew.customSqlSegment}
@@ -333,6 +339,7 @@
                 #{item}
             </foreach>
         </if>
+        group by task.id
         ORDER BY task.indate desc
         <if test="pageStart != null and pageSize != null">
             limit #{pageStart}, #{pageSize}
@@ -840,13 +847,23 @@
 
     <select id="getMyAuditTaskList"
             resultMap="AuditorResultMap">
-        SELECT DISTINCT task.*, task_executor.`first_auditor_id`, task_executor.`second_auditor_id`, u1.name AS first_auditor_name, u2.`name` AS second_auditor_name FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
+        SELECT DISTINCT task.*, task_executor.`first_auditor_id`, task_executor.`second_auditor_id`, u1.name AS first_auditor_name, u2.`name` AS second_auditor_name, project.`project_name`, stages.stages_name
+        FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
+        left join project on project.id = task.`project_id`
         LEFT JOIN USER u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN USER u2 ON u2.id = task_executor.`second_auditor_id`
+        left join stages on stages.id = task.stages_id
         ${ew.customSqlSegment}
-        and (task.`task_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.`task_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
+        and (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.task_status = 4 and task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
         order by task.id desc
         <if test="pageStart != null and pageSize != null">
             limit #{pageStart}, #{pageSize}
         </if>
     </select>
+    <select id="getMyAuditTaskCount"
+            resultType="java.lang.Integer">
+        SELECT count(DISTINCT task.id) FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
+                                                 LEFT JOIN USER u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN USER u2 ON u2.id = task_executor.`second_auditor_id`
+            ${ew.customSqlSegment}
+        and (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.task_status = 4 and task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
+    </select>
 </mapper>

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet_mld/src/views/project/projectInside.vue

@@ -179,9 +179,9 @@
                                                     <el-dropdown trigger="click" style="float:right;cursor:pointer;" v-if="canEditStageList">
                                                             <i class="el-icon-more" ></i>
                                                             <el-dropdown-menu slot="dropdown">
-                                                                <el-dropdown-item @click.native="addTask(stage)">
+                                                                <!-- <el-dropdown-item @click.native="addTask(stage)">
                                                                     <i class="el-icon-document-add"></i>
-                                                                    {{ $t('createtask ') }}</el-dropdown-item>
+                                                                    {{ $t('createtask ') }}</el-dropdown-item> -->
                                                                 <el-dropdown-item @click.native="renameStage(stage)">
                                                                     <i class="el-icon-edit"></i>
                                                                     {{ $t('renamingalist') }} </el-dropdown-item>