|
@@ -3,19 +3,16 @@ package com.wtkj.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
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.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.wutong.file.feign.IFileClient;
|
|
|
import com.wutong.file.vo.FileVO;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
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.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
@@ -27,6 +24,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -43,19 +41,30 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
|
private final IFileAndFolderService fileAndFolderService;
|
|
|
private final IFileClient fileClient;
|
|
|
private final IUserClient userClient;
|
|
|
+ private final IProjectStageService stageService;
|
|
|
+ private final BladeRedis redis;
|
|
|
|
|
|
@Override
|
|
|
public boolean submit(Task task) {
|
|
|
boolean flag = false;
|
|
|
Long taskId = task.getId();
|
|
|
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();
|
|
|
Integer year = now.getYear();
|
|
|
Integer month = now.getMonthValue();
|
|
|
task.setYear(year);
|
|
|
task.setMonth(month);
|
|
|
flag = this.save(task);
|
|
|
- asyncService.createTaskLog(task);
|
|
|
+ asyncService.createTask(task);
|
|
|
} else {
|
|
|
//执行的顶级单位
|
|
|
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) {
|
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
|
lqw.eq(Task::getProjectId, dto.getProjectId());
|
|
|
+ lqw.eq(Task::getStageId, dto.getStageId());
|
|
|
if (dto.getDeptCategory().equals(3)) {
|
|
|
//是业主
|
|
|
dto.setOrgDeptId(null);
|
|
@@ -198,16 +208,16 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MyTaskStatistics taskStatistics(Long projectId, Integer year, Integer month) {
|
|
|
+ public MyTaskStatistics taskStatistics(Long stageId, Integer year, Integer month) {
|
|
|
MyTaskStatistics statistics = new MyTaskStatistics();
|
|
|
Long userId = AuthUtil.getUserId();
|
|
|
List<Task> tasks = null;
|
|
|
- if (projectId == null) {
|
|
|
+ if (stageId == null) {
|
|
|
//个人任务统计
|
|
|
tasks = this.listByUser(userId, year, month);
|
|
|
} else {
|
|
|
//项目下的所有任务
|
|
|
- tasks = this.listByProjectId(projectId);
|
|
|
+ tasks = this.listByStageId(stageId);
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
//全部任务数
|
|
@@ -275,9 +285,9 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Task> listByProjectId(Long projectId) {
|
|
|
+ public List<Task> listByStageId(Long stageId) {
|
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
|
- lqw.eq(Task::getProjectId, projectId);
|
|
|
+ lqw.eq(Task::getStageId, stageId);
|
|
|
lqw.orderByAsc(Task::getEndTime);
|
|
|
return this.list(lqw);
|
|
|
}
|
|
@@ -329,11 +339,11 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, String>> projectTaskSummary(Long projectId) {
|
|
|
+ public List<Map<String, String>> projectTaskSummary(Long stageId) {
|
|
|
List<Map<String, String>> res = new ArrayList<>();
|
|
|
//项目下任务执行者的情况
|
|
|
Set<Long> userIds = new HashSet<>();
|
|
|
- List<Task> tasks = this.listByProjectId(projectId);
|
|
|
+ List<Task> tasks = this.listByStageId(stageId);
|
|
|
if (!CollectionUtils.isEmpty(tasks)) {
|
|
|
for (Task task : tasks) {
|
|
|
String executeUser = task.getExecuteUser();
|
|
@@ -348,7 +358,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
|
if (userR.isSuccess()) {
|
|
|
- List<Task> tasks1 = this.listByUserAndProject(userId, projectId);
|
|
|
+ List<Task> tasks1 = this.listByUserAndProject(userId, stageId);
|
|
|
if (!CollectionUtils.isEmpty(tasks1)) {
|
|
|
map.put("value", String.valueOf(tasks1.size()));
|
|
|
map.put("name", userR.getData().getName());
|
|
@@ -362,11 +372,46 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Task> listByUserAndProject(Long userId, Long projectId) {
|
|
|
+ public List<Task> listByUserAndProject(Long userId, Long stageId) {
|
|
|
LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
|
|
|
- lqw.eq(Task::getProjectId, projectId);
|
|
|
+ lqw.eq(Task::getStageId, stageId);
|
|
|
lqw.like(Task::getExecuteUser, String.valueOf(userId));
|
|
|
lqw.orderByAsc(Task::getEndTime);
|
|
|
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;
|
|
|
+ }
|
|
|
}
|