|
|
|
@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.resource.ResourceMapper; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.resourceType.ResourceTypeMapper; |
|
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper; |
|
|
|
|
import cn.iocoder.yudao.module.farm.enums.TaskStatus; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.service.CpUser.CpUserService; |
|
|
|
@ -164,88 +165,6 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
return taskMapper.selectList(exportReqVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<TaskMsgDTO> getTaskMsg(List<TaskDO> taskList){ |
|
|
|
|
Set<Long> personSet = new HashSet<>(); |
|
|
|
|
Set<Long> areaSet = new HashSet<>(); |
|
|
|
|
Set<Long> taskCateSet = new HashSet<>(); |
|
|
|
|
List<TaskMsgDTO> taskMsgList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
//先获取所有任务得到 去重后的 参与人、区域、任务分类名
|
|
|
|
|
for (TaskDO taskDO : taskList) { |
|
|
|
|
//项目参与人
|
|
|
|
|
taskDO.getExecutorPerson().forEach(p ->{ |
|
|
|
|
if (p != null) { |
|
|
|
|
personSet.add(Long.valueOf( p.toString())); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
//项目区域
|
|
|
|
|
if (taskDO.getAreas() != null){ |
|
|
|
|
taskDO.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(taskDO.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 (TaskDO taskDO : taskList) { |
|
|
|
|
TaskMsgDTO msgDTO = BeanUtil.copyProperties(taskDO, TaskMsgDTO.class); |
|
|
|
|
//完成时间
|
|
|
|
|
msgDTO.setFinishTime(taskDO.getUpdateTime()); |
|
|
|
|
//任务名
|
|
|
|
|
for (TaskCateDO taskCateDO : taskCateDOList) { |
|
|
|
|
if (taskCateDO.getId().equals(taskDO.getTaskCateId())){ |
|
|
|
|
msgDTO.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()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
msgDTO.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()); |
|
|
|
|
} |
|
|
|
|
msgDTO.setAreaName(areaNameList); |
|
|
|
|
} |
|
|
|
|
taskMsgList.add(msgDTO); |
|
|
|
|
} |
|
|
|
|
return taskMsgList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public R<TaskDetailDTO> appGetTask(Long id){ |
|
|
|
|
TaskDO taskDO = taskMapper.selectById(id); |
|
|
|
|
TaskDetailDTO taskMsg = new TaskDetailDTO(); |
|
|
|
@ -287,7 +206,6 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
areaIdList.addAll(JSONArray.parseArray(area.toString(), Long.class)); |
|
|
|
|
} |
|
|
|
|
executorIdList.addAll(taskDO.getExecutorPerson().toJavaList(Long.class)); |
|
|
|
|
|
|
|
|
|
resourceMap.put(taskDO.getId(), taskDO.getResources().toJavaList(ResourceDTO.class)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -310,7 +228,6 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
List<Long> taskCateNameIdList = taskDOList.stream().map(TaskDO::getTaskCateName).collect(Collectors.toList()); |
|
|
|
|
List<TaskCateDO> taskMsgList = taskCateMapper.selectList(new LambdaQueryWrapperX<TaskCateDO>().inIfPresent(TaskCateDO::getId, taskCateNameIdList)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//资源 处理下
|
|
|
|
|
List<ResourceDTO> resourceAssemble = new ArrayList<>(); |
|
|
|
|
for (List<ResourceDTO> dto : resourceMap.values()){ |
|
|
|
@ -425,6 +342,10 @@ public class TaskServiceImpl implements TaskService {
|
|
|
|
|
List<ResourceMsgDTO> resList = preAssemblyDTO.getTaskResouceMap().get(taskDO.getId()); |
|
|
|
|
dto.setTaskResourceList(resList); |
|
|
|
|
} |
|
|
|
|
//完成的任务加个时间
|
|
|
|
|
if (taskDO.getStatus().equals(TaskStatus.COMPLETE)){ |
|
|
|
|
dto.setFinishTime(taskDO.getUpdateTime()); |
|
|
|
|
} |
|
|
|
|
map.put(taskDO.getId(), dto); |
|
|
|
|
} |
|
|
|
|
return map; |
|
|
|
|