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