|
@@ -149,6 +149,7 @@ public class TaskController {
|
|
|
task.setParentTname(taskService.getById(task.getParentTid()).getName());
|
|
|
}
|
|
|
boolean isNew = false;
|
|
|
+ boolean needRecalculateProgress = false;
|
|
|
List<String> msgRecepientList = new ArrayList<>();
|
|
|
List<Task> needReOrderList = new ArrayList<>();
|
|
|
//新建的任务需要计算排序
|
|
@@ -175,6 +176,9 @@ public class TaskController {
|
|
|
if (task.getExecutorId() != null) {
|
|
|
msgRecepientList = task.getExecutorList().stream().filter(exe->!StringUtils.isEmpty(exe.getExecutorId())).map(TaskExecutor::getExecutorId).collect(Collectors.toList());
|
|
|
}
|
|
|
+ if (task.getTaskType() == 1) {
|
|
|
+ needRecalculateProgress = true;
|
|
|
+ }
|
|
|
} else {
|
|
|
//更新的情况,需要对比是否修改了任务标题,更新子任务的parentTname
|
|
|
Task oldTask = taskService.getById(task.getId());
|
|
@@ -206,6 +210,9 @@ public class TaskController {
|
|
|
if(task.getFinishDate()==null){
|
|
|
taskMapper.updateFinishDate(task.getId());
|
|
|
}
|
|
|
+ if ((oldTask.getTaskType() == 1 && task.getTaskType() != 1) || (oldTask.getTaskType() != 1 && task.getTaskType() == 1)) {
|
|
|
+ needRecalculateProgress = true;
|
|
|
+ }
|
|
|
}
|
|
|
System.out.println(task.getStartDate());
|
|
|
System.out.println(task.getEndDate());
|
|
@@ -237,8 +244,8 @@ public class TaskController {
|
|
|
comment.setContent(user.getName()+(isNew?MessageUtils.message("entry.create"):MessageUtils.message("entry.editedTask"))+MessageUtils.message("entry.task"));
|
|
|
taskCommentMapper.insert(comment);
|
|
|
|
|
|
- //新增任务,需要重新计算项目进度
|
|
|
- if (isNew) {
|
|
|
+ //需要重新计算项目进度
|
|
|
+ if (needRecalculateProgress) {
|
|
|
updateProjectProgress(task.getProjectId());
|
|
|
}
|
|
|
if (msgRecepientList.size() > 0) {
|
|
@@ -281,10 +288,8 @@ public class TaskController {
|
|
|
}
|
|
|
|
|
|
private void updateProjectProgress(Integer projectId) {
|
|
|
- //更新项目完成度
|
|
|
- //只有第一级任务才更新项目进度, 非已撤销状态的
|
|
|
- List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).isNull("parent_tid").ne("task_status", 2).eq("task_type",1));
|
|
|
-
|
|
|
+ //只有里程碑才更新项目进度, 非已撤销状态的
|
|
|
+ List<Task> all = taskMapper.simpleList(new QueryWrapper<Task>().eq("project_id", projectId).ne("task_status", 2).eq("task_type",1));
|
|
|
if (all.size() > 0) {
|
|
|
long running = all.stream().filter(a -> a.getTaskStatus() == 1).count();
|
|
|
int progress = ((int) running) * 100 / all.size();
|
|
@@ -366,23 +371,16 @@ public class TaskController {
|
|
|
taskService.notifyMileStoneFinish(user.getCompanyId(), finishedMileStoneList);
|
|
|
}
|
|
|
|
|
|
- //更新项目完成度
|
|
|
- Task item = taskService.getById(task.getId());
|
|
|
- if (item.getParentTid() == null) {
|
|
|
- //只有第一级任务才更新项目进度, 非已撤销状态的
|
|
|
- long allProjectTaskCount = taskService.count(new QueryWrapper<Task>().eq("project_id", item.getProjectId()).isNull("parent_tid").ne("task_status", 2).eq("task_type",1));
|
|
|
- long finishTaskCount = taskService.count(new QueryWrapper<Task>().eq("project_id", item.getProjectId()).isNull("parent_tid").eq("task_status", 1).eq("task_type",1));
|
|
|
- if (allProjectTaskCount > 0) {
|
|
|
- int progress = ((int) finishTaskCount) * 100 / (int)allProjectTaskCount;
|
|
|
- Project project = new Project();
|
|
|
- project.setId(item.getProjectId());
|
|
|
- project.setProgress(progress);
|
|
|
- projectService.updateById(project);
|
|
|
- }
|
|
|
+ //如果是里程碑,需要更新项目完成度
|
|
|
+ task = taskMapper.selectById(task.getId());
|
|
|
+ if (task.getTaskType() == 1) {
|
|
|
+ Integer projectId = task.getProjectId();
|
|
|
+ updateProjectProgress(projectId);
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@RequestMapping("/changeOrder")
|
|
|
public HttpRespMsg changeOrder(Integer id, Integer oldIndex, Integer newIndex, Integer oldStagesId, Integer newStagesId) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
@@ -727,8 +725,8 @@ public class TaskController {
|
|
|
deleteSubTask(task);
|
|
|
|
|
|
|
|
|
- //删除根任务,需要重新计算项目进度
|
|
|
- if (task.getParentTid() == null) {
|
|
|
+ //删除里程碑,需要重新计算项目进度
|
|
|
+ if (task.getTaskType() == 1) {
|
|
|
updateProjectProgress(task.getProjectId());
|
|
|
}
|
|
|
return new HttpRespMsg();
|