修改接口
This commit is contained in:
parent
35fdc4ada3
commit
2af108bf3d
|
|
@ -1,6 +1,13 @@
|
||||||
package com.ruoyi.task.controller.convert;
|
package com.ruoyi.task.controller.convert;
|
||||||
|
|
||||||
import com.ruoyi.task.api.domain.TaskStatQueryVO;
|
import com.ruoyi.task.api.domain.TaskStatQueryVO;
|
||||||
|
import com.ruoyi.task.api.domain.TaskStatItemDTO;
|
||||||
|
import com.ruoyi.task.service.dto.TaskStatItemServiceDTO;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务统计Controller转换器
|
* 任务统计Controller转换器
|
||||||
|
|
@ -44,7 +51,34 @@ public class TaskStatControllerConvert {
|
||||||
if (dto == null) return null;
|
if (dto == null) return null;
|
||||||
com.ruoyi.task.api.domain.TaskStatByMonthDTO apiDTO = new com.ruoyi.task.api.domain.TaskStatByMonthDTO();
|
com.ruoyi.task.api.domain.TaskStatByMonthDTO apiDTO = new com.ruoyi.task.api.domain.TaskStatByMonthDTO();
|
||||||
apiDTO.setTotal(dto.getTotal());
|
apiDTO.setTotal(dto.getTotal());
|
||||||
apiDTO.setDays(dto.getDays());
|
|
||||||
|
if (dto.getDays() != null) {
|
||||||
|
Map<Integer, List<TaskStatItemDTO>> apiDays = new HashMap<>();
|
||||||
|
for (Map.Entry<Integer, List<TaskStatItemServiceDTO>> entry : dto.getDays().entrySet()) {
|
||||||
|
List<TaskStatItemDTO> apiItems = new ArrayList<>();
|
||||||
|
for (TaskStatItemServiceDTO item : entry.getValue()) {
|
||||||
|
apiItems.add(fromItem(item));
|
||||||
|
}
|
||||||
|
apiDays.put(entry.getKey(), apiItems);
|
||||||
|
}
|
||||||
|
apiDTO.setDays(apiDays);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TaskStatItemDTO fromItem(TaskStatItemServiceDTO dto) {
|
||||||
|
if (dto == null) return null;
|
||||||
|
TaskStatItemDTO apiDTO = new TaskStatItemDTO();
|
||||||
|
apiDTO.setTaskId(dto.getTaskId());
|
||||||
|
apiDTO.setPlanId(dto.getPlanId());
|
||||||
|
apiDTO.setTaskName(dto.getTaskName());
|
||||||
|
apiDTO.setPlanName(dto.getPlanName());
|
||||||
|
apiDTO.setStartTime(dto.getStartTime());
|
||||||
|
apiDTO.setEndTime(dto.getEndTime());
|
||||||
|
apiDTO.setActualStartTime(dto.getActualStartTime());
|
||||||
|
apiDTO.setActualEndTime(dto.getActualEndTime());
|
||||||
|
apiDTO.setStatus(dto.getStatus());
|
||||||
return apiDTO;
|
return apiDTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.task.service.dto;
|
package com.ruoyi.task.service.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -13,8 +14,8 @@ public class TaskStatByMonthServiceDTO {
|
||||||
/** 总数 */
|
/** 总数 */
|
||||||
private Integer total;
|
private Integer total;
|
||||||
|
|
||||||
/** 每日统计 key:日期(1-31) value:任务数量 */
|
/** 每日任务列表 key:日期(1-31) value:任务列表 */
|
||||||
private Map<Integer, Integer> days;
|
private Map<Integer, List<TaskStatItemServiceDTO>> days;
|
||||||
|
|
||||||
public Integer getTotal() {
|
public Integer getTotal() {
|
||||||
return total;
|
return total;
|
||||||
|
|
@ -24,11 +25,11 @@ public class TaskStatByMonthServiceDTO {
|
||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Integer> getDays() {
|
public Map<Integer, List<TaskStatItemServiceDTO>> getDays() {
|
||||||
return days;
|
return days;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDays(Map<Integer, Integer> days) {
|
public void setDays(Map<Integer, List<TaskStatItemServiceDTO>> days) {
|
||||||
this.days = days;
|
this.days = days;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.ruoyi.task.service.dto;
|
||||||
|
|
||||||
|
import com.ruoyi.task.api.enums.StatusEnum;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务统计项DTO
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-03-09
|
||||||
|
*/
|
||||||
|
public class TaskStatItemServiceDTO {
|
||||||
|
|
||||||
|
private Long taskId;
|
||||||
|
private Long planId;
|
||||||
|
private String taskName;
|
||||||
|
private String planName;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
private Date actualStartTime;
|
||||||
|
private Date actualEndTime;
|
||||||
|
private StatusEnum status;
|
||||||
|
|
||||||
|
public Long getTaskId() {
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(Long taskId) {
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPlanId() {
|
||||||
|
return planId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlanId(Long planId) {
|
||||||
|
this.planId = planId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTaskName() {
|
||||||
|
return taskName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskName(String taskName) {
|
||||||
|
this.taskName = taskName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlanName() {
|
||||||
|
return planName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlanName(String planName) {
|
||||||
|
this.planName = planName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(Date startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(Date endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getActualStartTime() {
|
||||||
|
return actualStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActualStartTime(Date actualStartTime) {
|
||||||
|
this.actualStartTime = actualStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getActualEndTime() {
|
||||||
|
return actualEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActualEndTime(Date actualEndTime) {
|
||||||
|
this.actualEndTime = actualEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StatusEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(StatusEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,9 @@ package com.ruoyi.task.service.impl;
|
||||||
|
|
||||||
import com.ruoyi.task.api.enums.StatusEnum;
|
import com.ruoyi.task.api.enums.StatusEnum;
|
||||||
import com.ruoyi.task.domain.api.ITaskDomain;
|
import com.ruoyi.task.domain.api.ITaskDomain;
|
||||||
|
import com.ruoyi.task.domain.api.ITaskPlanDomain;
|
||||||
import com.ruoyi.task.domain.model.Task;
|
import com.ruoyi.task.domain.model.Task;
|
||||||
|
import com.ruoyi.task.domain.model.TaskPlan;
|
||||||
import com.ruoyi.task.service.api.ITaskService;
|
import com.ruoyi.task.service.api.ITaskService;
|
||||||
import com.ruoyi.task.service.convert.TaskDTOConvert;
|
import com.ruoyi.task.service.convert.TaskDTOConvert;
|
||||||
import com.ruoyi.task.service.dto.TaskDTO;
|
import com.ruoyi.task.service.dto.TaskDTO;
|
||||||
|
|
@ -10,9 +12,11 @@ import com.ruoyi.task.service.dto.TaskQueryDTO;
|
||||||
import com.ruoyi.task.service.dto.TaskStatQueryServiceDTO;
|
import com.ruoyi.task.service.dto.TaskStatQueryServiceDTO;
|
||||||
import com.ruoyi.task.service.dto.TaskStatByYearServiceDTO;
|
import com.ruoyi.task.service.dto.TaskStatByYearServiceDTO;
|
||||||
import com.ruoyi.task.service.dto.TaskStatByMonthServiceDTO;
|
import com.ruoyi.task.service.dto.TaskStatByMonthServiceDTO;
|
||||||
|
import com.ruoyi.task.service.dto.TaskStatItemServiceDTO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -24,6 +28,9 @@ public class TaskServiceImpl implements ITaskService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITaskDomain taskDomain;
|
private ITaskDomain taskDomain;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITaskPlanDomain taskPlanDomain;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTaskWithoutPlan(TaskDTO taskDTO) {
|
public Long createTaskWithoutPlan(TaskDTO taskDTO) {
|
||||||
Task task = TaskDTOConvert.toDomain(taskDTO);
|
Task task = TaskDTOConvert.toDomain(taskDTO);
|
||||||
|
|
@ -212,7 +219,7 @@ public class TaskServiceImpl implements ITaskService {
|
||||||
List<Task> tasks = taskDomain.getTaskList(task);
|
List<Task> tasks = taskDomain.getTaskList(task);
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
Map<Integer, Integer> days = new HashMap<>();
|
Map<Integer, List<TaskStatItemServiceDTO>> days = new HashMap<>();
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
for (Task t : tasks) {
|
for (Task t : tasks) {
|
||||||
|
|
@ -222,7 +229,25 @@ public class TaskServiceImpl implements ITaskService {
|
||||||
int month = calendar.get(Calendar.MONTH) + 1;
|
int month = calendar.get(Calendar.MONTH) + 1;
|
||||||
if (year == queryDTO.getYear() && month == queryDTO.getMonth()) {
|
if (year == queryDTO.getYear() && month == queryDTO.getMonth()) {
|
||||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
days.put(day, days.getOrDefault(day, 0) + 1);
|
|
||||||
|
TaskStatItemServiceDTO item = new TaskStatItemServiceDTO();
|
||||||
|
item.setTaskId(t.getId());
|
||||||
|
item.setPlanId(t.getPlanId());
|
||||||
|
item.setTaskName(t.getTaskName());
|
||||||
|
item.setStartTime(t.getStartTime());
|
||||||
|
item.setEndTime(t.getEndTime());
|
||||||
|
item.setActualStartTime(t.getActualStartTime());
|
||||||
|
item.setActualEndTime(t.getActualEndTime());
|
||||||
|
item.setStatus(t.getStatus());
|
||||||
|
|
||||||
|
if (t.getPlanId() != null) {
|
||||||
|
TaskPlan plan = taskPlanDomain.getTaskPlanById(t.getPlanId());
|
||||||
|
if (plan != null) {
|
||||||
|
item.setPlanName(plan.getPlanName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
days.computeIfAbsent(day, k -> new ArrayList<>()).add(item);
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue