diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/dataobject/BaseDO.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/dataobject/BaseDO.java index e3df175f..d3b7650b 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/dataobject/BaseDO.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/dataobject/BaseDO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.mybatis.core.dataobject; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableLogic; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; import lombok.Data; @@ -21,11 +22,13 @@ public abstract class BaseDO implements Serializable { * 创建时间 */ @TableField(fill = FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** * 最后更新时间 */ @TableField(fill = FieldFill.INSERT_UPDATE) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; /** * 创建者,目前使用 SysUser 的 id 编号 diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java index fc05b45e..a6181042 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.farm.controller.admin.project.dto; import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.*; import java.time.LocalDateTime; @@ -20,6 +21,7 @@ public class ProjectListDTO extends ProjectDO { String taskName; + @JsonFormat(pattern = "yyyy-MM-dd") Date finishTime; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectPageDTO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectPageDTO.java index 2349d1e0..2485b522 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectPageDTO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectPageDTO.java @@ -13,4 +13,10 @@ public class ProjectPageDTO extends PageDTO { private static final long serialVersionUID = 1L; private Integer state; + + @ApiModelProperty("项目名") + private String projectName; + + @ApiModelProperty("时间筛选 1全部 2两周 3三天") + private Integer timeLimit; } \ No newline at end of file diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java index 88a81cc6..74678e7f 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java @@ -1,9 +1,12 @@ package cn.iocoder.yudao.module.farm.service.project; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.page.PageUtil; import cn.iocoder.yudao.framework.common.page.PageVO; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskMsgDTO; @@ -30,6 +33,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -130,15 +134,19 @@ public class ProjectServiceImpl implements ProjectService { @Override public R> findProjectList(ProjectPageDTO pageDTO){ PageUtil.startPage(pageDTO); - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); - queryWrapper.eq(ProjectDO::getState, pageDTO.getState()); - List list = projectMapper.selectList(queryWrapper); + LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); + queryWrapperX.eqIfPresent(ProjectDO::getState, pageDTO.getState()); + queryWrapperX.likeIfPresent(ProjectDO::getName, pageDTO.getProjectName()); + if (ObjectUtil.isNotEmpty(pageDTO.getTimeLimit())){ + LocalDateTime nowTime = LocalDateTime.now(); + LocalDateTime startTime = pageDTO.getTimeLimit() == 2 ? nowTime.minusDays(3) : nowTime.minusDays(14); + queryWrapperX.between(ProjectDO::getCreateTime, startTime, nowTime); + } + + List list = projectMapper.selectList(queryWrapperX); if (ObjectUtil.isEmpty(list)){ return R.success(PageUtil.emptyPage(pageDTO, ProjectListDTO.class)); } -// List list = projectMapper.selectList(Wrappers.lambdaQuery() -// .eq(ProjectDO::getState, pageDTO.getState()) -// .last("limit " + (pageDTO.getPageNum() -1) * pageDTO.getPageSize() +"," + pageDTO.getPageSize())); List idList = list.stream().map(ProjectDO::getId).collect(Collectors.toList()); List ProjectListDTOList = BeanUtil.copyToList(list, ProjectListDTO.class); @@ -146,89 +154,6 @@ public class ProjectServiceImpl implements ProjectService { //任务完成的 List taskList = taskMapper.selectList(Wrappers.lambdaQuery().in(TaskDO::getProjectId, idList) .eq(TaskDO::getStatus, TaskStatus.COMPLETE.getCode())); - /* //项目没有任务 跳过 - if (ObjectUtil.isNotEmpty(taskList)){ - - List taskMsgDTOList = taskService.getTaskMsg(taskList); - - Set personSet = new HashSet<>(); - Set areaSet = new HashSet<>(); - Set taskCateSet = new HashSet<>(); - - taskList.stream().forEach(item ->{ - //项目参与人 - item.getExecutorPerson().forEach(p ->{ - if (p != null) { - personSet.add(Long.valueOf( p.toString())); - } - }); - //项目区域 - if (item.getAreas() != null){ - item.getAreas().forEach(area ->{ - JSONArray array = JSONArray.parseArray(area.toString()); - areaSet.add(Long.valueOf(array.get(0).toString())); - areaSet.add(Long.valueOf(array.get(1).toString())); - }); - } - //任务分类名 - taskCateSet.add(item.getTaskCateId()); - }); - - List joinPerson = new ArrayList(personSet); - List cpUserList = cpUserMapper.selectList(Wrappers.lambdaQuery().in(CpUserDO::getId, joinPerson)); - List joinArea = new ArrayList(areaSet); - List areaDOList = areaMapper.selectList(Wrappers.lambdaQuery().in(AreaDO::getId, joinArea)); - List joinTaskCate = new ArrayList<>(taskCateSet); - List taskCateDOList = taskCateMapper.selectList(Wrappers.lambdaQuery().in(TaskCateDO::getId, joinTaskCate)); - - //拼接 姓名/区域/任务名 - for (ProjectListDTO projectListDTO : ProjectListDTOList) { - for (TaskDO taskDO : taskList) { - if (Long.valueOf(taskDO.getProjectId()).equals(projectListDTO.getId())){ - //完成时间 - projectListDTO.setFinishTime(taskDO.getUpdateTime()); - //任务名 - for (TaskCateDO taskCateDO : taskCateDOList) { - if (taskCateDO.getId().equals(taskDO.getTaskCateId())){ - projectListDTO.setTaskName(taskCateDO.getName()); - } - } - - //执行人 - List personNameList = new ArrayList<>(); - for (Long executorPerson : taskDO.getExecutorPerson().toJavaList(Long.class)) { - for (CpUserDO cpUserDO : cpUserList) { - if (cpUserDO.getId().equals(executorPerson)){ - personNameList.add(cpUserDO.getName()); - } - } - projectListDTO.setExecutorName(personNameList); - } - //任务区域 - List areaNameList = new ArrayList<>(); - for (Object area : taskDO.getAreas()) { - JSONArray array = JSONArray.parseArray(area.toString()); - Long areaParent = Long.valueOf(String.valueOf(array.get(0))); - Long areaSon = Long.valueOf(String.valueOf(array.get(1))); - StringBuilder areaName = new StringBuilder(); - for (AreaDO areaDO : areaDOList) { - if (areaDO.getId().equals(areaParent)){ - areaName.append(areaDO.getName()); - } - if (areaDO.getId().equals(areaSon)){ - areaName.append(areaDO.getName()); - } - } - if (ObjectUtil.isNotEmpty(areaName)){ - areaNameList.add(areaName.toString()); - } - projectListDTO.setAreaName(areaNameList); - } - } - } - } - }*/ - if (ObjectUtil.isNotEmpty(taskList)) { List taskMsgDTOList = taskService.getTaskMsg(taskList);