|
|
|
@ -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<PageVO<ProjectListDTO>> findProjectList(ProjectPageDTO pageDTO){ |
|
|
|
|
PageUtil.startPage(pageDTO); |
|
|
|
|
LambdaQueryWrapper<ProjectDO> queryWrapper = Wrappers.lambdaQuery(); |
|
|
|
|
queryWrapper.eq(ProjectDO::getState, pageDTO.getState()); |
|
|
|
|
List<ProjectDO> list = projectMapper.selectList(queryWrapper); |
|
|
|
|
LambdaQueryWrapperX<ProjectDO> 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<ProjectDO> list = projectMapper.selectList(queryWrapperX); |
|
|
|
|
if (ObjectUtil.isEmpty(list)){ |
|
|
|
|
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<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) |
|
|
|
|
.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)) { |
|
|
|
|
List<TaskMsgDTO> taskMsgDTOList = taskService.getTaskMsg(taskList); |
|
|
|
|