|
@@ -3,19 +3,16 @@ package com.wtkj.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.wtkj.dto.ProjectTaskPageDTO;
|
|
import com.wtkj.dto.ProjectTaskPageDTO;
|
|
-import com.wtkj.entity.FileAndFolder;
|
|
|
|
-import com.wtkj.entity.Task;
|
|
|
|
-import com.wtkj.entity.TaskFile;
|
|
|
|
|
|
+import com.wtkj.entity.*;
|
|
import com.wtkj.mapper.TaskMapper;
|
|
import com.wtkj.mapper.TaskMapper;
|
|
-import com.wtkj.service.IAsyncService;
|
|
|
|
-import com.wtkj.service.IFileAndFolderService;
|
|
|
|
-import com.wtkj.service.ITaskFileService;
|
|
|
|
-import com.wtkj.service.ITaskService;
|
|
|
|
|
|
+import com.wtkj.service.*;
|
|
import com.wtkj.vo.MyTaskStatistics;
|
|
import com.wtkj.vo.MyTaskStatistics;
|
|
import com.wutong.file.feign.IFileClient;
|
|
import com.wutong.file.feign.IFileClient;
|
|
import com.wutong.file.vo.FileVO;
|
|
import com.wutong.file.vo.FileVO;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
|
+import org.springblade.core.redis.cache.BladeRedis;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
@@ -27,6 +24,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -43,19 +41,30 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
private final IFileAndFolderService fileAndFolderService;
|
|
private final IFileAndFolderService fileAndFolderService;
|
|
private final IFileClient fileClient;
|
|
private final IFileClient fileClient;
|
|
private final IUserClient userClient;
|
|
private final IUserClient userClient;
|
|
|
|
+ private final IProjectStageService stageService;
|
|
|
|
+ private final BladeRedis redis;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean submit(Task task) {
|
|
public boolean submit(Task task) {
|
|
boolean flag = false;
|
|
boolean flag = false;
|
|
Long taskId = task.getId();
|
|
Long taskId = task.getId();
|
|
if (taskId == null) {
|
|
if (taskId == null) {
|
|
|
|
+ Long stageId = task.getStageId();
|
|
|
|
+ ProjectStage stage = stageService.getById(stageId);
|
|
|
|
+ if (stage != null) {
|
|
|
|
+ Date startTime = stage.getStartTime();
|
|
|
|
+ Date endTime = stage.getEndTime();
|
|
|
|
+ if (task.getStartTime().before(startTime) || task.getEndTime().after(endTime)) {
|
|
|
|
+ throw new ServiceException(String.format("任务时间异常,不可超出当前阶段的起止时间%s-%s", startTime, endTime));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
LocalDate now = LocalDate.now();
|
|
LocalDate now = LocalDate.now();
|
|
Integer year = now.getYear();
|
|
Integer year = now.getYear();
|
|
Integer month = now.getMonthValue();
|
|
Integer month = now.getMonthValue();
|
|
task.setYear(year);
|
|
task.setYear(year);
|
|
task.setMonth(month);
|
|
task.setMonth(month);
|
|
flag = this.save(task);
|
|
flag = this.save(task);
|
|
- asyncService.createTaskLog(task);
|
|
|
|
|
|
+ asyncService.createTask(task);
|
|
} else {
|
|
} else {
|
|
//执行的顶级单位
|
|
//执行的顶级单位
|
|
Long userId = AuthUtil.getUserId();
|
|
Long userId = AuthUtil.getUserId();
|
|
@@ -91,6 +100,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
public IPage<Task> projectTaskPage(ProjectTaskPageDTO dto, IPage<Task> page) {
|
|
public IPage<Task> projectTaskPage(ProjectTaskPageDTO dto, IPage<Task> page) {
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
lqw.eq(Task::getProjectId, dto.getProjectId());
|
|
lqw.eq(Task::getProjectId, dto.getProjectId());
|
|
|
|
+ lqw.eq(Task::getStageId, dto.getStageId());
|
|
if (dto.getDeptCategory().equals(3)) {
|
|
if (dto.getDeptCategory().equals(3)) {
|
|
//是业主
|
|
//是业主
|
|
dto.setOrgDeptId(null);
|
|
dto.setOrgDeptId(null);
|
|
@@ -198,16 +208,16 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public MyTaskStatistics taskStatistics(Long projectId, Integer year, Integer month) {
|
|
|
|
|
|
+ public MyTaskStatistics taskStatistics(Long stageId, Integer year, Integer month) {
|
|
MyTaskStatistics statistics = new MyTaskStatistics();
|
|
MyTaskStatistics statistics = new MyTaskStatistics();
|
|
Long userId = AuthUtil.getUserId();
|
|
Long userId = AuthUtil.getUserId();
|
|
List<Task> tasks = null;
|
|
List<Task> tasks = null;
|
|
- if (projectId == null) {
|
|
|
|
|
|
+ if (stageId == null) {
|
|
//个人任务统计
|
|
//个人任务统计
|
|
tasks = this.listByUser(userId, year, month);
|
|
tasks = this.listByUser(userId, year, month);
|
|
} else {
|
|
} else {
|
|
//项目下的所有任务
|
|
//项目下的所有任务
|
|
- tasks = this.listByProjectId(projectId);
|
|
|
|
|
|
+ tasks = this.listByStageId(stageId);
|
|
}
|
|
}
|
|
if (!CollectionUtils.isEmpty(tasks)) {
|
|
if (!CollectionUtils.isEmpty(tasks)) {
|
|
//全部任务数
|
|
//全部任务数
|
|
@@ -275,9 +285,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<Task> listByProjectId(Long projectId) {
|
|
|
|
|
|
+ public List<Task> listByStageId(Long stageId) {
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
- lqw.eq(Task::getProjectId, projectId);
|
|
|
|
|
|
+ lqw.eq(Task::getStageId, stageId);
|
|
lqw.orderByAsc(Task::getEndTime);
|
|
lqw.orderByAsc(Task::getEndTime);
|
|
return this.list(lqw);
|
|
return this.list(lqw);
|
|
}
|
|
}
|
|
@@ -329,11 +339,11 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<Map<String, String>> projectTaskSummary(Long projectId) {
|
|
|
|
|
|
+ public List<Map<String, String>> projectTaskSummary(Long stageId) {
|
|
List<Map<String, String>> res = new ArrayList<>();
|
|
List<Map<String, String>> res = new ArrayList<>();
|
|
//项目下任务执行者的情况
|
|
//项目下任务执行者的情况
|
|
Set<Long> userIds = new HashSet<>();
|
|
Set<Long> userIds = new HashSet<>();
|
|
- List<Task> tasks = this.listByProjectId(projectId);
|
|
|
|
|
|
+ List<Task> tasks = this.listByStageId(stageId);
|
|
if (!CollectionUtils.isEmpty(tasks)) {
|
|
if (!CollectionUtils.isEmpty(tasks)) {
|
|
for (Task task : tasks) {
|
|
for (Task task : tasks) {
|
|
String executeUser = task.getExecuteUser();
|
|
String executeUser = task.getExecuteUser();
|
|
@@ -348,7 +358,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
if (userR.isSuccess()) {
|
|
if (userR.isSuccess()) {
|
|
- List<Task> tasks1 = this.listByUserAndProject(userId, projectId);
|
|
|
|
|
|
+ List<Task> tasks1 = this.listByUserAndProject(userId, stageId);
|
|
if (!CollectionUtils.isEmpty(tasks1)) {
|
|
if (!CollectionUtils.isEmpty(tasks1)) {
|
|
map.put("value", String.valueOf(tasks1.size()));
|
|
map.put("value", String.valueOf(tasks1.size()));
|
|
map.put("name", userR.getData().getName());
|
|
map.put("name", userR.getData().getName());
|
|
@@ -362,11 +372,46 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<Task> listByUserAndProject(Long userId, Long projectId) {
|
|
|
|
|
|
+ public List<Task> listByUserAndProject(Long userId, Long stageId) {
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
- lqw.eq(Task::getProjectId, projectId);
|
|
|
|
|
|
+ lqw.eq(Task::getStageId, stageId);
|
|
lqw.like(Task::getExecuteUser, String.valueOf(userId));
|
|
lqw.like(Task::getExecuteUser, String.valueOf(userId));
|
|
lqw.orderByAsc(Task::getEndTime);
|
|
lqw.orderByAsc(Task::getEndTime);
|
|
return this.list(lqw);
|
|
return this.list(lqw);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public LineChartDataSet projectTaskSituation(Long stageId) {
|
|
|
|
+ LineChartDataSet set = new LineChartDataSet();
|
|
|
|
+ List<LineChartData> list = new ArrayList<>();
|
|
|
|
+ //1.阶段周期
|
|
|
|
+ List<LocalDate> dateList = redis.get("dateList::" + stageId);
|
|
|
|
+ if (!CollectionUtils.isEmpty(dateList)) {
|
|
|
|
+ LineChartData line = new LineChartData();
|
|
|
|
+ line.setType("line");
|
|
|
|
+ line.setName("leftTask");
|
|
|
|
+ List<Map<String, Object>> data = new ArrayList<>();
|
|
|
|
+ dateList.forEach(date -> {
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 设置日期格
|
|
|
|
+ String formatDate = date.format(formatter);
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put(formatDate, null);
|
|
|
|
+ });
|
|
|
|
+ line.setData(data);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ list.add(line);
|
|
|
|
+ }
|
|
|
|
+ set.setLineChartDataList(list);
|
|
|
|
+ return set;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public LineChartDataSet projectTaskBurnout(Long stageId) {
|
|
|
|
+ LineChartDataSet set = new LineChartDataSet();
|
|
|
|
+ List<LineChartData> list = new ArrayList<>();
|
|
|
|
+ set.setLineChartDataList(list);
|
|
|
|
+ return set;
|
|
|
|
+ }
|
|
}
|
|
}
|