修改数据过滤方式
This commit is contained in:
parent
f31d3fe736
commit
f500380ab2
|
|
@ -54,14 +54,14 @@ public class TaskController extends BaseController
|
|||
return R.ok(TaskControllerConvert.from(taskService.getTaskById(taskId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 复杂条件查询任务列表
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public R<List<com.ruoyi.task.api.domain.TaskDTO>> list(@RequestBody TaskQueryDTO queryDTO)
|
||||
{
|
||||
return R.ok(TaskControllerConvert.fromList(taskService.getTaskList(queryDTO)));
|
||||
}
|
||||
// /**
|
||||
// * 复杂条件查询任务列表
|
||||
// */
|
||||
// @PostMapping("/list")
|
||||
// public R<List<com.ruoyi.task.api.domain.TaskDTO>> list(@RequestBody TaskQueryDTO queryDTO)
|
||||
// {
|
||||
// return R.ok(TaskControllerConvert.fromList(taskService.getTaskList(queryDTO)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 更新任务
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public class TaskStatControllerConvert {
|
|||
com.ruoyi.task.service.dto.TaskStatQueryServiceDTO dto = new com.ruoyi.task.service.dto.TaskStatQueryServiceDTO();
|
||||
dto.setYear(apiDTO.getYear());
|
||||
dto.setMonth(apiDTO.getMonth());
|
||||
dto.setStartDate(apiDTO.getStartDate());
|
||||
dto.setEndDate(apiDTO.getEndDate());
|
||||
dto.setTaskCategory(apiDTO.getTaskCategory());
|
||||
dto.setTaskType(apiDTO.getTaskType());
|
||||
dto.setStatusList(apiDTO.getStatusList());
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ruoyi.task.api.enums.StatusEnum;
|
|||
import com.ruoyi.task.api.enums.TaskCategoryEnum;
|
||||
import com.ruoyi.task.api.enums.TaskTypeEnum;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -20,6 +21,12 @@ public class TaskStatQueryServiceDTO {
|
|||
/** 月份 */
|
||||
private Integer month;
|
||||
|
||||
/** 开始日期 */
|
||||
private Date startDate;
|
||||
|
||||
/** 结束日期 */
|
||||
private Date endDate;
|
||||
|
||||
/** 任务类别 */
|
||||
private TaskCategoryEnum taskCategory;
|
||||
|
||||
|
|
@ -51,6 +58,22 @@ public class TaskStatQueryServiceDTO {
|
|||
this.month = month;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public TaskCategoryEnum getTaskCategory() {
|
||||
return taskCategory;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,15 +222,25 @@ public class TaskServiceImpl implements ITaskService {
|
|||
continue;
|
||||
}
|
||||
|
||||
// 如果指定了日期范围,则使用日期范围过滤;否则使用年份过滤
|
||||
if (queryDTO.getStartDate() != null && queryDTO.getEndDate() != null) {
|
||||
if (t.getStartTime().before(queryDTO.getStartDate()) || t.getStartTime().after(queryDTO.getEndDate())) {
|
||||
continue;
|
||||
}
|
||||
} else if (queryDTO.getYear() != null) {
|
||||
calendar.setTime(t.getStartTime());
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
if (year == queryDTO.getYear()) {
|
||||
if (year != queryDTO.getYear()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
calendar.setTime(t.getStartTime());
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
months.put(month, months.getOrDefault(month, 0) + 1);
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TaskStatByYearServiceDTO result = new TaskStatByYearServiceDTO();
|
||||
result.setTotal(total);
|
||||
|
|
@ -273,7 +283,20 @@ public class TaskServiceImpl implements ITaskService {
|
|||
calendar.setTime(t.getStartTime());
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
int month = calendar.get(Calendar.MONTH) + 1;
|
||||
|
||||
// 如果指定了日期范围,则使用日期范围过滤;否则使用年月过滤
|
||||
boolean matchDate = false;
|
||||
if (queryDTO.getStartDate() != null && queryDTO.getEndDate() != null) {
|
||||
if (!t.getStartTime().before(queryDTO.getStartDate()) && !t.getStartTime().after(queryDTO.getEndDate())) {
|
||||
matchDate = true;
|
||||
}
|
||||
} else if (queryDTO.getYear() != null && queryDTO.getMonth() != null) {
|
||||
if (year == queryDTO.getYear() && month == queryDTO.getMonth()) {
|
||||
matchDate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchDate) {
|
||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
TaskStatItemServiceDTO item = new TaskStatItemServiceDTO();
|
||||
|
|
|
|||
Loading…
Reference in New Issue