| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import me.zhengjie.modules.task.domain.*; |
| | | import me.zhengjie.modules.task.service.dto.TaskMongoDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | import me.zhengjie.modules.system.service.dto.SysExchangeRateQueryCriteria; |
| | | import me.zhengjie.modules.system.service.dto.SysGoalSettingDto; |
| | | import me.zhengjie.modules.system.service.dto.SysGoalSettingQueryCriteria; |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskInterface; |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.modules.task.repository.TaskUserRepository; |
| | |
| | | |
| | | |
| | | /** |
| | | * @author HuaZhe |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author HuaZhe |
| | | * @date 2022-12-15 |
| | | **/ |
| | | @Service |
| | |
| | | private TaskService taskService; |
| | | private final TaskMapper taskMapper; |
| | | private final SysExchangeRateService sysExchangeRateService; |
| | | |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(ProjectQueryCriteria criteria, Pageable pageable) { |
| | |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<ProjectDto> queryAll2(ProjectQueryCriteria criteria) { |
| | | List<ProjectDto> projectDtoList = projectMapper.toDto(projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); |
| | | |
| | | Long userId = SecurityUtils.getCurrentUserId(); |
| | | List<Long> projectIdList = projectRepository.findIdByLiableUserId(userId); |
| | | return projectDtoList; |
| | | } |
| | | |
| | | private ProjectDto customHandle(ProjectDto projectDto) { |
| | | // 任务合计(已分配) |
| | | Double divideTaskTime = 0D; |
| | |
| | | List<Integer> levels = roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()); |
| | | // 登录用户最大角色等级 |
| | | int min = Collections.min(levels); |
| | | List<Long> projectIdList = new ArrayList<>(); |
| | | // 判断角色等级 |
| | | if (min == Constant.ROLE_LEVEL_MANAGER || min == Constant.ROLE_LEVEL_LEADER || min == Constant.ROLE_LEVEL_ORDINARY) { |
| | | // 根据用户ID查询参与的项目ID |
| | | List<Long> taskUserProjectIdList = taskDaliyRepository.findProjectIdByUserId(SecurityUtils.getCurrentUserId()); |
| | | //List<Long> taskUserProjectIdList = taskDaliyRepository.findProjectIdByUserId(SecurityUtils.getCurrentUserId()); |
| | | //如果当前用户属于一个任务,那么他也可以看见当前这个任务的项目 |
| | | Query query = Query.query(Criteria.where("containUserList").is(SecurityUtils.getCurrentUserId())); |
| | | List<TaskMongo> taskMongoList = mongoTemplate.find(query, TaskMongo.class); |
| | | |
| | | ArrayList<Long> projectList = new ArrayList<>(); |
| | | for (TaskMongo taskMongo : taskMongoList) { |
| | | projectList.add(taskMongo.getProjectId()); |
| | | } |
| | | // 根据用户ID查询负责的项目ID |
| | | List<Long> projectIdList = projectRepository.findIdByLiableUserId(SecurityUtils.getCurrentUserId()); |
| | | projectIdList = projectRepository.findIdByLiableUserId(SecurityUtils.getCurrentUserId()); |
| | | // 检索条件 |
| | | List<Long> totalProjectIdList = Stream.of(taskUserProjectIdList, projectIdList).flatMap(Collection::stream).distinct().collect(Collectors.toList()); |
| | | List<Long> totalProjectIdList = Stream.of(projectList, projectIdList).flatMap(Collection::stream).distinct().collect(Collectors.toList()); |
| | | if (totalProjectIdList.size() == 0) { |
| | | return Collections.emptyList(); |
| | | } |
| | |
| | | projectDto.setLiableUserIdList(liableUserIdList); |
| | | } |
| | | } |
| | | |
| | | if (!(min == Constant.ROLE_LEVEL_MANAGER || min == Constant.ROLE_LEVEL_LEADER || min == Constant.ROLE_LEVEL_ORDINARY)){ |
| | | for (ProjectDto projectDto : projectDtoList) { |
| | | projectDto.setFlag(true); |
| | | } |
| | | return projectDtoList; |
| | | } |
| | | |
| | | for (ProjectDto projectDto : projectDtoList) { |
| | | for (Long project : projectIdList) { |
| | | //当前用户所负责的项目ID |
| | | //如果当前用户负责的项目ID在这个集合中,就给那个项目打一个标识 |
| | | if (projectDto.getId().equals(project)) { |
| | | projectDto.setFlag(true); |
| | | break; |
| | | } else { |
| | | projectDto.setFlag(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return projectDtoList; |
| | | } |
| | | |