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 1470a305..8d0d0eb7 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 @@ -26,6 +26,7 @@ import cn.iocoder.yudao.module.farm.service.task.TaskService; import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper; +import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.service.CpUser.CpUserService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.alibaba.fastjson.JSONArray; @@ -54,6 +55,7 @@ import cn.iocoder.yudao.module.farm.convert.project.ProjectConvert; import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*; @@ -75,8 +77,6 @@ public class ProjectServiceImpl implements ProjectService { private CpUserMapper cpUserMapper; @Resource private TaskService taskService; - @Resource - private AdminUserService adminUserService; @Override public Long createProject(ProjectCreateReqVO createReqVO) { @@ -158,8 +158,7 @@ public class ProjectServiceImpl implements ProjectService { } if (ObjectUtil.isNotEmpty(pageDTO.getMyProject()) && pageDTO.getMyProject()){ - AdminUserDO adminUser = adminUserService.getUser(getLoginUserId()); - CpUserDO user = cpUserMapper.selectOne(Wrappers.lambdaQuery().eq(CpUserDO::getUserId, adminUser.getUsername())); + CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, getLoginUser().getUsername()); if (ObjectUtil.isNotEmpty(user)){ //查看我参与或创建的项目 queryWrapperX.apply(" ((JSON_CONTAINS(members, '"+ user.getId()+"') or creator = " + getLoginUserId() +"))"); diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java index 87d564a2..7a23fe1f 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java @@ -178,16 +178,7 @@ public class TaskServiceImpl implements TaskService { PageResult pageResult = taskMapper.selectPage(pageReqVO, queryWrapperX); Map map = this.taskAssemble(pageResult.getList()); - List list = new ArrayList<>(); - pageResult.getList().forEach(item ->{ - if (map.containsKey(item.getId())){ - TaskAssemblyDTO taskAssemblyDTO = map.get(item.getId()); - TaskAssemblyDTO dto = BeanUtil.copyProperties(item, TaskAssemblyDTO.class); - dto.setProjectName(taskAssemblyDTO.getProjectName()); - dto.setTaskMsg(taskAssemblyDTO.getTaskMsg()); - list.add(dto); - } - }); + List list = new ArrayList<>(map.values()); PageResult assemble = new PageResult<>(); assemble.setTotal(pageResult.getTotal()); @@ -199,23 +190,7 @@ public class TaskServiceImpl implements TaskService { public PageResult getAdminTaskPage(TaskPageReqVO pageReqVO){ PageResult taskPage = taskMapper.selectPage(pageReqVO); Map map = this.taskAssemble(taskPage.getList()); - List list = new ArrayList<>(); - taskPage.getList().forEach(item ->{ - if (map.containsKey(item.getId())){ - TaskAssemblyDTO dto = map.get(item.getId()); - TaskAssemblyDTO newDTO = BeanUtil.copyProperties(item, TaskAssemblyDTO.class); - newDTO.setProjectName(dto.getProjectName()); - newDTO.setTaskName(dto.getTaskName()); - newDTO.setTaskResourceList(dto.getTaskResourceList()); - newDTO.setAreaNameList(dto.getAreaNameList()); - newDTO.setExecutorNameList(dto.getExecutorNameList()); - newDTO.setTaskMsg(dto.getTaskMsg()); - newDTO.setMainPersonName(dto.getMainPersonName()); - newDTO.setCropName(dto.getCropName()); - newDTO.setCreateTime(dto.getCreateTime()); - list.add(newDTO); - } - }); + List list = new ArrayList<>(map.values()); PageResult page = new PageResult<>(); page.setList(list); page.setTotal(taskPage.getTotal()); @@ -388,7 +363,7 @@ public class TaskServiceImpl implements TaskService { Map map = new HashMap<>(); for (TaskDO taskDO : taskDOList) { - TaskAssemblyDTO dto = new TaskAssemblyDTO(); + TaskAssemblyDTO dto = BeanUtil.copyProperties(taskDO, TaskAssemblyDTO.class); //项目名 preAssemblyDTO.getProjectDOList().stream().filter(project -> project.getId().equals(taskDO.getProjectId())).findFirst() .ifPresent(item ->{