|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.dto.TaskDto;
|
|
|
+import com.management.platform.entity.vo.DailyTaskVO;
|
|
|
import com.management.platform.entity.vo.TasKVo;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.*;
|
|
@@ -1466,6 +1467,92 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|
|
return respMsg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getTaskListByStartAndEnd(Integer type, String startDate, String endDate, HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ String token = String.valueOf(request.getHeader("Token"));
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部任务");
|
|
|
+ boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门任务");
|
|
|
+
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDateTime parseStartDate = LocalDateTime.parse(startDate + " 00:00", formatter);
|
|
|
+ LocalDateTime parseEndDate = LocalDateTime.parse(endDate + " 00:00", formatter).plusDays(1L);
|
|
|
+
|
|
|
+ Integer departmentId=null;
|
|
|
+ String executor=null;
|
|
|
+
|
|
|
+ if (isAll){
|
|
|
+ departmentId=null;
|
|
|
+ }
|
|
|
+ else if (isNotAll){
|
|
|
+ departmentId= user.getDepartmentId();//找出对应的部门id
|
|
|
+ }else {
|
|
|
+ executor=user.getId();
|
|
|
+
|
|
|
+ }
|
|
|
+ List<TaskDto> taskDtoList= taskMapper.getTaskListByStartAndEnd(parseStartDate,parseEndDate,departmentId,executor,companyId);
|
|
|
+
|
|
|
+ // 使用LinkedHashMap保持日期顺序
|
|
|
+ Map<LocalDate, List<TaskDto>> dailyTasks = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ // 生成从startDate到endDate的所有日期,并初始化空列表
|
|
|
+ LocalDate parseStart = LocalDate.parse(startDate, formatterDate);
|
|
|
+ LocalDate parseEnd = LocalDate.parse(endDate, formatterDate);
|
|
|
+ LocalDate currentDate = parseStart;
|
|
|
+ while (!currentDate.isAfter(parseEnd)) {
|
|
|
+ dailyTasks.put(currentDate, new ArrayList<>());
|
|
|
+ currentDate = currentDate.plusDays(1);
|
|
|
+ }
|
|
|
+
|
|
|
+// 遍历任务,填充到对应的日期
|
|
|
+ for (TaskDto task : taskDtoList) {
|
|
|
+ // 根据实际字段获取任务日期,例如getExecuteDate()
|
|
|
+ LocalDateTime taskStartDate = task.getStartDate();
|
|
|
+ LocalDateTime taskEndDate = task.getEndDate();
|
|
|
+ if (taskStartDate!=null && taskEndDate!=null){
|
|
|
+ LocalDate task_start = LocalDate.from(taskStartDate);
|
|
|
+ LocalDate task_end = LocalDate.from(taskEndDate);
|
|
|
+ for (Map.Entry<LocalDate, List<TaskDto>> entry : dailyTasks.entrySet()) {
|
|
|
+ LocalDate date = entry.getKey(); // 获取日期
|
|
|
+ List<TaskDto> tasks = entry.getValue(); // 获取任务列表
|
|
|
+ if (date.isAfter(task_start)&&date.isBefore(task_end)||date.isEqual(task_start)){
|
|
|
+ tasks.add(task);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (taskStartDate == null && taskEndDate != null ) {
|
|
|
+ LocalDate task_end = LocalDate.from(taskEndDate);
|
|
|
+ for (Map.Entry<LocalDate, List<TaskDto>> entry : dailyTasks.entrySet()) {
|
|
|
+ LocalDate date = entry.getKey(); // 获取日期
|
|
|
+ List<TaskDto> tasks = entry.getValue(); // 获取任务列表
|
|
|
+ if (date.isEqual(task_end)){
|
|
|
+ tasks.add(task);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if (taskStartDate != null) {
|
|
|
+ LocalDate task_start = LocalDate.from(taskStartDate);
|
|
|
+ for (Map.Entry<LocalDate, List<TaskDto>> entry : dailyTasks.entrySet()) {
|
|
|
+ LocalDate date = entry.getKey(); // 获取日期
|
|
|
+ List<TaskDto> tasks = entry.getValue(); // 获取任务列表
|
|
|
+ if (date.isEqual(task_start)){
|
|
|
+ tasks.add(task);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //自定义DTO类
|
|
|
+ List<DailyTaskVO> result = dailyTasks.entrySet().stream()
|
|
|
+ .map(entry -> new DailyTaskVO(entry.getKey(), entry.getValue()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ msg.setData(result);
|
|
|
+ return msg;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public void updateTaskRepeatConfigure(Task task){
|
|
|
task.setRepeatType(null).setRepeatEndNever(null).setRepeatEndCount(null)
|
|
|
.setRepeatEndDate(null).setRepeatDesignDay(null).setRepeatDesignSameday(null)
|