Browse Source

项目筛选

zyh
小久哥 3 years ago
parent
commit
a3ff0accb6
  1. 3
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/dataobject/BaseDO.java
  2. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectListDTO.java
  3. 6
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/dto/ProjectPageDTO.java
  4. 103
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java

3
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.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -21,11 +22,13 @@ public abstract class BaseDO implements Serializable {
* 创建时间 * 创建时间
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime;
/** /**
* 最后更新时间 * 最后更新时间
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime; private Date updateTime;
/** /**
* 创建者目前使用 SysUser id 编号 * 创建者目前使用 SysUser id 编号

2
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 cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*; import lombok.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -20,6 +21,7 @@ public class ProjectListDTO extends ProjectDO {
String taskName; String taskName;
@JsonFormat(pattern = "yyyy-MM-dd")
Date finishTime; Date finishTime;

6
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 static final long serialVersionUID = 1L;
private Integer state; private Integer state;
@ApiModelProperty("项目名")
private String projectName;
@ApiModelProperty("时间筛选 1全部 2两周 3三天")
private Integer timeLimit;
} }

103
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; package cn.iocoder.yudao.module.farm.service.project;
import cn.hutool.core.bean.BeanUtil; 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.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.page.PageUtil; import cn.iocoder.yudao.framework.common.page.PageUtil;
import cn.iocoder.yudao.framework.common.page.PageVO; 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.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskMsgDTO; 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 javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -130,15 +134,19 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public R<PageVO<ProjectListDTO>> findProjectList(ProjectPageDTO pageDTO){ public R<PageVO<ProjectListDTO>> findProjectList(ProjectPageDTO pageDTO){
PageUtil.startPage(pageDTO); PageUtil.startPage(pageDTO);
LambdaQueryWrapper<ProjectDO> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapperX<ProjectDO> queryWrapperX = new LambdaQueryWrapperX<>();
queryWrapper.eq(ProjectDO::getState, pageDTO.getState()); queryWrapperX.eqIfPresent(ProjectDO::getState, pageDTO.getState());
List<ProjectDO> list = projectMapper.selectList(queryWrapper); 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<ProjectDO> list = projectMapper.selectList(queryWrapperX);
if (ObjectUtil.isEmpty(list)){ if (ObjectUtil.isEmpty(list)){
return R.success(PageUtil.emptyPage(pageDTO, ProjectListDTO.class)); return R.success(PageUtil.emptyPage(pageDTO, ProjectListDTO.class));
} }
// List<ProjectDO> list = projectMapper.selectList(Wrappers.<ProjectDO>lambdaQuery()
// .eq(ProjectDO::getState, pageDTO.getState())
// .last("limit " + (pageDTO.getPageNum() -1) * pageDTO.getPageSize() +"," + pageDTO.getPageSize()));
List<Long> idList = list.stream().map(ProjectDO::getId).collect(Collectors.toList()); List<Long> idList = list.stream().map(ProjectDO::getId).collect(Collectors.toList());
List<ProjectListDTO> ProjectListDTOList = BeanUtil.copyToList(list, ProjectListDTO.class); List<ProjectListDTO> ProjectListDTOList = BeanUtil.copyToList(list, ProjectListDTO.class);
@ -146,89 +154,6 @@ public class ProjectServiceImpl implements ProjectService {
//任务完成的 //任务完成的
List<TaskDO> taskList = taskMapper.selectList(Wrappers.<TaskDO>lambdaQuery().in(TaskDO::getProjectId, idList) List<TaskDO> taskList = taskMapper.selectList(Wrappers.<TaskDO>lambdaQuery().in(TaskDO::getProjectId, idList)
.eq(TaskDO::getStatus, TaskStatus.COMPLETE.getCode())); .eq(TaskDO::getStatus, TaskStatus.COMPLETE.getCode()));
/* //项目没有任务 跳过
if (ObjectUtil.isNotEmpty(taskList)){
List<TaskMsgDTO> taskMsgDTOList = taskService.getTaskMsg(taskList);
Set<Long> personSet = new HashSet<>();
Set<Long> areaSet = new HashSet<>();
Set<Long> 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<Long> joinPerson = new ArrayList<Long>(personSet);
List<CpUserDO> cpUserList = cpUserMapper.selectList(Wrappers.<CpUserDO>lambdaQuery().in(CpUserDO::getId, joinPerson));
List<Long> joinArea = new ArrayList<Long>(areaSet);
List<AreaDO> areaDOList = areaMapper.selectList(Wrappers.<AreaDO>lambdaQuery().in(AreaDO::getId, joinArea));
List<Long> joinTaskCate = new ArrayList<>(taskCateSet);
List<TaskCateDO> taskCateDOList = taskCateMapper.selectList(Wrappers.<TaskCateDO>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<String> 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<String> 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)) { if (ObjectUtil.isNotEmpty(taskList)) {
List<TaskMsgDTO> taskMsgDTOList = taskService.getTaskMsg(taskList); List<TaskMsgDTO> taskMsgDTOList = taskService.getTaskMsg(taskList);

Loading…
Cancel
Save