| | |
| | | */ |
| | | @Query(value = "SELECT * FROM project WHERE project_distinguish = ?1 AND plan_start_date LIKE concat(?2,'%')", nativeQuery = true) |
| | | List<Project> findProjectByProjectDistinguishAndTargetYear(String projectDistinguish, String targetYear); |
| | | |
| | | @Query(value = "select id from project where id = ?1",nativeQuery = true) |
| | | Long findByProjectId(Long id); |
| | | } |
| | |
| | | * @param projectId |
| | | */ |
| | | void deleteByProjectId(Long projectId); |
| | | |
| | | |
| | | /* |
| | | 参数说明: |
| | | 参数1:用户ID |
| | | 方法作用:根据用户ID查询一下他都是那些任务的项目负责人。 |
| | | */ |
| | | |
| | | // List<Long> findProjectIdByUserId(Long userId); |
| | | } |
| | |
| | | */ |
| | | Map<String,Object> queryAll(ProjectQueryCriteria criteria, Pageable pageable); |
| | | |
| | | List<ProjectDto> queryAll2 (ProjectQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | |
| | | |
| | | /** 负责人名称 */ |
| | | private String liableUserName; |
| | | |
| | | private boolean flag; |
| | | } |
| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | public ResponseEntity<Object> getUserBaseInfo(@PathVariable Date yearMonth) throws ParseException { |
| | | return new ResponseEntity<>(userService.getUserBaseInfo(yearMonth), HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/getProjectUser") |
| | | public ResponseEntity<Object> getUserByTaskId(String taskId){ |
| | | return new ResponseEntity<>(userService.getUserByTaskId(taskId),HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | |
| | | List<DeptUserNodeDto> queryDeptUserByDeptId(Long deptId); |
| | | |
| | | List<UserDto> getUserByTaskId(String taskId); |
| | | |
| | | } |
| | |
| | | import me.zhengjie.modules.system.service.mapstruct.UserLoginMapper; |
| | | import me.zhengjie.modules.system.service.mapstruct.UserMapper; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskMongo; |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.service.TaskDaliyService; |
| | | import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria; |
| | |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | 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 org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.File; |
| | |
| | | private final TaskDaliyService taskDaliyService; |
| | | private final DeptRepository deptRepository; |
| | | |
| | | private final MongoTemplate mongoTemplate; |
| | | |
| | | @Override |
| | | public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { |
| | | Page<User> page = userRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); |
| | |
| | | }); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<UserDto> getUserByTaskId(String taskId) { |
| | | // 日历类 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 日期格式化 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 日历字符串 |
| | | String calendarStr = sdf.format(calendar.getTime()); |
| | | |
| | | TaskMongo taskMongo = mongoTemplate.findById(taskId, TaskMongo.class); |
| | | List<Long> containUserList = taskMongo.getContainUserList(); |
| | | List<User> userList = new ArrayList<>(); |
| | | if(containUserList.size() != 0){ |
| | | for (Long userId : containUserList) { |
| | | userList.add(userRepository.findById(userId).get()); |
| | | } |
| | | } |
| | | List<UserDto> userDto = userMapper.toDto(userList); |
| | | for (int i = 0; i < userDto.size(); i++) { |
| | | // 根据用户ID、指定年月查询用户级别工资 |
| | | SysUserLevelWage sysUserLevelWage = sysUserLevelWageRepository.findTargetYearMonth(userDto.get(i).getId(), calendarStr); |
| | | // 判断用户级别工资是否为空 |
| | | if (sysUserLevelWage != null) { |
| | | // 根据ID查询用户级别 |
| | | SysLevel sysLevel = sysLevelRepository.findById(sysUserLevelWage.getLevelId()).orElseGet(SysLevel::new); |
| | | // 用户 |
| | | userDto.get(i).setLevelName(sysLevel.getName()); |
| | | } else { |
| | | // 用户 |
| | | userDto.get(i).setLevelName(null); |
| | | } |
| | | } |
| | | return userDto; |
| | | } |
| | | |
| | | @Override |
| | |
| | | onlineUserService.kickOutForUsername(resources.getUsername()); |
| | | } |
| | | // 临时旧用户级别ID |
| | | Long tempOldLevelId = user.getLevelId();; |
| | | Long tempOldLevelId = user.getLevelId(); |
| | | ; |
| | | user.setUsername(resources.getUsername()); |
| | | user.setEmail(resources.getEmail()); |
| | | user.setEnabled(resources.getEnabled()); |
| | |
| | | |
| | | /** |
| | | * 获取日历信息 |
| | | * |
| | | * @param month |
| | | * @return |
| | | * @throws Exception |
| | |
| | | |
| | | /** |
| | | * 判断状态 |
| | | * |
| | | * @param result |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | *获取用户基础信息 |
| | | * |
| | | * @return |
| | | * @throws ParseException |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 判断用户级别变更 |
| | | * |
| | | * @param userId |
| | | * @param oldLevelId |
| | | * @param newLevelId |
| | |
| | | |
| | | /** |
| | | * 创建用户级别工资 |
| | | * |
| | | * @param userId |
| | | * @param levelId |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 创建用户级别其他 |
| | | * |
| | | * @param userId |
| | | * @param levelId |
| | | */ |
| | |
| | | // 保存 |
| | | sysUserLevelOtherRepository.save(sysUserLevelOther); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @Id |
| | | private String id; |
| | | |
| | | private Long old_id; |
| | | |
| | | @ApiModelProperty(value = "项目ID") |
| | | private Long projectId; |
| | | |
| | |
| | | |
| | | private List<Long> userIdList = new ArrayList<Long>(); |
| | | |
| | | private List<Long> containUserList = new ArrayList<Long>(); |
| | | |
| | | private List<String> tagList = new ArrayList<String>(); |
| | | |
| | | @ApiModelProperty(value = "绩效类型") |
| | |
| | | @ApiModelProperty(value = "ID") |
| | | private String id; |
| | | |
| | | private Long old_id; |
| | | |
| | | @ApiModelProperty(value = "任务ID") |
| | | @DBRef |
| | | private TaskMongo task; |
| | |
| | | * @return |
| | | */ |
| | | List<TaskDaliy> findByProjectIdAndTaskId(Long projectId, Long id); |
| | | |
| | | |
| | | @Query(value = "select DISTINCT user_id from task_daliy where task_id = ?1",nativeQuery = true) |
| | | List<Long> findByTaskId(Long TaskId); |
| | | } |
| | |
| | | */ |
| | | @Query(value = "SELECT COALESCE(SUM(plan_hours), 0.0) FROM task WHERE project_id IN (?1)", nativeQuery = true) |
| | | Double sumWorkingHoursByProjectId(List<Long> projectId); |
| | | |
| | | } |
| | |
| | | void deleteByProjectId(Long projectId); |
| | | |
| | | List<TaskUser> findByTaskId(Long id); |
| | | |
| | | @Query(value = "select DISTINCT user_id from task_user where task_id = ?1",nativeQuery = true) |
| | | List<Long> getAllTaskCountByUserId(Long task_id); |
| | | } |
| | |
| | | return new ResponseEntity<>(taskService.queryChildren(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/ChildrenTaskAnyParent") |
| | | public ResponseEntity<Object> queryChildrenTaskAnyParent(TaskQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskService.queryChildrenTaskAnyParent(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增任务") |
| | | @ApiOperation("新增任务") |
| | |
| | | public ResponseEntity<Object> queryTaskUserIds(TaskUserQueryCriteria criteria){ |
| | | return new ResponseEntity<>(taskUserService.queryTaskUserIds(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/addTaskUser") |
| | | @Log("用户自己认领任务") |
| | | @ApiOperation("用户自己认领任务") |
| | | public ResponseEntity<Object> addTaskUser(String TaskId){ |
| | | taskUserService.addTaskUser(TaskId); |
| | | return new ResponseEntity<>(1,HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | */ |
| | | List<TaskMongoDto> queryChildren(TaskQueryCriteria criteria); |
| | | |
| | | List<TaskMongoDto> queryChildrenTaskAnyParent(TaskQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | |
| | | **/ |
| | | public interface TaskUserService { |
| | | |
| | | void addTaskUser(String taskId); |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import me.zhengjie.modules.task.domain.TaskMongo; |
| | | |
| | |
| | | /** ID */ |
| | | private String id; |
| | | |
| | | private Long old_id; |
| | | |
| | | /** 项目ID */ |
| | | private Long projectId; |
| | | |
| | |
| | | |
| | | /** 任务责任人 */ |
| | | private List<Long> userIdList = new ArrayList<Long>(); |
| | | |
| | | private List<Long> containUserList = new ArrayList<>(); |
| | | |
| | | /** 绩效类型 */ |
| | | private String performanceType; |
| | |
| | | private List<TaskMongoDto> children; |
| | | |
| | | private Long version; |
| | | |
| | | |
| | | @ApiModelProperty(value = "权限分级") |
| | | private boolean flag; |
| | | } |
| | |
| | | |
| | | /** 任务ID */ |
| | | private String taskId; |
| | | |
| | | private Long old_id; |
| | | |
| | | private String name; |
| | | |
| | |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | |
| | | /** |
| | | * @author 赵士淞 |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-27 |
| | | **/ |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public List<ProjectDto> getAllProjects(ProjectQueryCriteria criteria) { |
| | | Long userId = SecurityUtils.getCurrentUserId(); |
| | | Criteria criteriaMongo = new Criteria(); |
| | | criteriaMongo = criteriaMongo.and("userIdList").is(userId); |
| | | Query query = new Query(criteriaMongo); |
| | | Query query = Query.query(Criteria.where("containUserList").is(SecurityUtils.getCurrentUserId())); |
| | | List<TaskMongo> taskMongoList = mongoTemplate.find(query, TaskMongo.class); |
| | | Set<Long> projectIds = taskMongoList.stream().map(taskMongo -> taskMongo.getProjectId()).collect(Collectors.toSet()); |
| | | |
| | | ArrayList<Long> projectList = new ArrayList<>(); |
| | | for (TaskMongo taskMongo : taskMongoList) { |
| | | projectList.add(taskMongo.getProjectId()); |
| | | } |
| | | // 根据用户ID查询负责的项目ID |
| | | List<Long> projectIdList = projectRepository.findIdByLiableUserId(SecurityUtils.getCurrentUserId()); |
| | | |
| | | Set<Long> projectIds = Stream.of(projectList, projectIdList).flatMap(Collection::stream).distinct().collect(Collectors.toSet()); |
| | | criteria.setApproveStatus(Constant.APPROVE_STATUS_ACKNOWLEDGED); |
| | | criteria.setProjectStatusNotEqual(Constant.PROJECT_STATUS_COMPLETED); |
| | | criteria.setIdInList(new ArrayList<Long>(projectIds)); |
| | | |
| | | return projectService.queryAll(criteria); |
| | | return projectService.queryAll2(criteria); |
| | | } |
| | | |
| | | @Override |
| | |
| | | TaskMongoDto taskMongoDto = new TaskMongoDto(); |
| | | taskMongoDto.setId(taskMongo.getId()); |
| | | taskMongoDto.setName(taskMongo.getName()); |
| | | taskMongoDto.setOld_id(taskMongo.getOld_id()); |
| | | |
| | | taskMongoDto.setProjectId(taskMongo.getProjectId()); |
| | | |
| | |
| | | taskMongoDto.setDescription(taskMongo.getDescription()); |
| | | |
| | | taskMongoDto.setUserIdList(taskMongo.getUserIdList()); |
| | | taskMongoDto.setContainUserList(taskMongo.getContainUserList()); |
| | | taskMongoDto.setTagList(taskMongo.getTagList()); |
| | | taskMongoDto.setVersion(taskMongo.getVersion()); |
| | | |
| | |
| | | TaskMongoDto taskMongoDto = new TaskMongoDto(); |
| | | taskMongoDto.setId(taskMongo.getId()); |
| | | taskMongoDto.setName(taskMongo.getName()); |
| | | taskMongoDto.setOld_id(taskMongo.getOld_id()); |
| | | |
| | | taskMongoDto.setProjectId(taskMongo.getProjectId()); |
| | | |
| | |
| | | taskMongoDto.setDescription(taskMongo.getDescription()); |
| | | |
| | | taskMongoDto.setUserIdList(taskMongo.getUserIdList()); |
| | | taskMongoDto.setContainUserList(taskMongo.getContainUserList()); |
| | | taskMongoDto.setTagList(taskMongo.getTagList()); |
| | | taskMongoDto.setVersion(taskMongo.getVersion()); |
| | | |
| | |
| | | public List<TaskMongoDto> queryChildren(TaskQueryCriteria criteria) { |
| | | Long userId = SecurityUtils.getCurrentUserId(); |
| | | Criteria criteriaMongo = new Criteria(); |
| | | criteriaMongo = criteriaMongo.and("userIdList").is(userId); |
| | | criteriaMongo = criteriaMongo.and("containUserList").is(userId); |
| | | if (criteria.getProjectId() != null) { |
| | | criteriaMongo = criteriaMongo.and("projectId").is(criteria.getProjectId()); |
| | | } |
| | | if (criteria.getPid() == null) { |
| | | criteriaMongo = criteriaMongo.and("parent").exists(false); |
| | | } else { |
| | | TaskMongo parent = mongoTemplate.findById(new ObjectId(criteria.getPid()), TaskMongo.class); |
| | | criteriaMongo = criteriaMongo.and("parent").is(parent); |
| | | } |
| | | // if (criteria.getPid() == null) { |
| | | // criteriaMongo = criteriaMongo.and("parent").exists(false); |
| | | // } else { |
| | | // TaskMongo parent = mongoTemplate.findById(new ObjectId(criteria.getPid()), TaskMongo.class); |
| | | // criteriaMongo = criteriaMongo.and("parent").is(parent); |
| | | // } |
| | | if (criteria.getName() != null) { |
| | | criteriaMongo = criteriaMongo.and("name").regex(Pattern.compile("^.*" + criteria.getName() + ".*$", Pattern.CASE_INSENSITIVE)); |
| | | } |
| | |
| | | return taskMongoDtoList; |
| | | } |
| | | |
| | | public List<TaskMongoDto> queryChildrenTaskAnyParent(TaskQueryCriteria criteria) { |
| | | //看看当前这个用户是不是这个项目的项目负责人,如果是项目负责人的话显示全部的任务 |
| | | Long userId = SecurityUtils.getCurrentUserId(); |
| | | List<Long> idByLiableUserId = projectRepository.findIdByLiableUserId(userId); |
| | | for (Long aLong : idByLiableUserId) { |
| | | if (criteria.getProjectId().equals(aLong)) { |
| | | Criteria criteriaAll = new Criteria(); |
| | | criteriaAll = criteriaAll.and("projectId").is(criteria.getProjectId()); |
| | | Query query = new Query(criteriaAll); |
| | | List<TaskMongo> taskMongos = mongoTemplate.find(query, TaskMongo.class); |
| | | |
| | | List<TaskMongoDto> taskMongoDtoList = new ArrayList<TaskMongoDto>(); |
| | | for (TaskMongo taskMongo : taskMongos) { |
| | | TaskMongoDto taskMongoDto = new TaskMongoDto(); |
| | | |
| | | taskMongoDto.setId(taskMongo.getId()); |
| | | taskMongoDto.setName(taskMongo.getName()); |
| | | taskMongoDto.setProjectId(taskMongo.getProjectId()); |
| | | taskMongoDto.setPlanStartTime(taskMongo.getPlanStartTime()); |
| | | taskMongoDto.setPlanEndTime(taskMongo.getPlanEndTime()); |
| | | |
| | | Query childrenQuery = new Query(Criteria.where("parent").is(taskMongo)); |
| | | long children = mongoTemplate.count(childrenQuery, TaskMongo.class); |
| | | taskMongoDto.setLeaf(children == 0); |
| | | |
| | | //如果时项目负责人有最高权限 |
| | | taskMongoDto.setFlag(true); |
| | | |
| | | taskMongoDtoList.add(taskMongoDto); |
| | | } |
| | | return taskMongoDtoList; |
| | | } |
| | | } |
| | | Criteria criteriaMongo = new Criteria(); |
| | | criteriaMongo = criteriaMongo.and("containUserList").is(userId); |
| | | if (criteria.getProjectId() != null) { |
| | | criteriaMongo = criteriaMongo.and("projectId").is(criteria.getProjectId()); |
| | | } |
| | | if (criteria.getName() != null) { |
| | | criteriaMongo = criteriaMongo.and("name").regex(Pattern.compile("^.*" + criteria.getName() + ".*$", Pattern.CASE_INSENSITIVE)); |
| | | } |
| | | Query query = new Query(criteriaMongo); |
| | | Long totalCount = mongoTemplate.count(query, TaskMongo.class); |
| | | if (totalCount == 0) { |
| | | return Collections.emptyList(); |
| | | } |
| | | //获取包含成员 |
| | | List<TaskMongo> taskMongoList = mongoTemplate.find(query, TaskMongo.class); |
| | | |
| | | List<TaskMongoDto> taskMongoDtoList = new ArrayList<TaskMongoDto>(); |
| | | for (TaskMongo taskMongo : taskMongoList) { |
| | | |
| | | TaskMongoDto taskMongoDto = new TaskMongoDto(); |
| | | |
| | | taskMongoDto.setId(taskMongo.getId()); |
| | | taskMongoDto.setName(taskMongo.getName()); |
| | | taskMongoDto.setProjectId(taskMongo.getProjectId()); |
| | | taskMongoDto.setPlanStartTime(taskMongo.getPlanStartTime()); |
| | | taskMongoDto.setPlanEndTime(taskMongo.getPlanEndTime()); |
| | | |
| | | Query childrenQuery = new Query(Criteria.where("parent").is(taskMongo)); |
| | | long children = mongoTemplate.count(childrenQuery, TaskMongo.class); |
| | | taskMongoDto.setLeaf(children == 0); |
| | | |
| | | if(taskMongo.getUserIdList().contains(SecurityUtils.getCurrentUserId())){ |
| | | //如果当前用户是某个任务的任务负责人的话,也可拥有全部的分配任务的权限 |
| | | taskMongoDto.setFlag(true); |
| | | } |
| | | taskMongoDtoList.add(taskMongoDto); |
| | | } |
| | | return taskMongoDtoList; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public TaskDto findById(Long id) { |
| | |
| | | |
| | | @Override |
| | | public TaskMongo update(TaskMongo resources) { |
| | | |
| | | //如果他不是任务的负责人但是他还可能是任务的参与人员 |
| | | List<Long> containUserList = resources.getContainUserList(); |
| | | List<Long> userIdList = resources.getUserIdList(); |
| | | |
| | | //如果他已经不是任务的参与人员他就一定要删除 |
| | | List<Long> removeList = userIdList.stream().filter(o -> !containUserList.contains(o)).collect(Collectors.toList()); |
| | | userIdList.removeAll(removeList); |
| | | resources.setUserIdList(userIdList); |
| | | |
| | | containUserList.addAll(userIdList.stream().filter(o -> !containUserList.contains(o)).collect(Collectors.toList())); |
| | | |
| | | |
| | | return mongoTemplate.save(resources); |
| | | |
| | | } |
| | | |
| | | private Boolean deleteWithChildren(List<TaskMongo> taskMongoList) { |
| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskUser; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.utils.SecurityUtils; |
| | | import org.bson.types.ObjectId; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | |
| | | /** |
| | | * @author 赵士淞 |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-28 |
| | | **/ |
| | | @Service |
| | |
| | | private final TaskUserMapper taskUserMapper; |
| | | private final UserRepository userRepository; |
| | | private final SysConfigHolidayRepository sysConfigHolidayRepository; |
| | | private final TaskRepository taskRepository; |
| | | private final UserService userService; |
| | | private final MongoTemplate mongoTemplate; |
| | | |
| | |
| | | AggregationResults<TaskUserTotalDetailMongoDto> taskUserMongoList = mongoTemplate.aggregate(customerAgg, TaskUserMongo.class, TaskUserTotalDetailMongoDto.class); |
| | | result.setDetails(taskUserMongoList.getMappedResults()); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void addTaskUser(String taskId) { |
| | | //如果有用户认领了这个任务 |
| | | TaskUserMongo byId = mongoTemplate.findById(taskId, TaskUserMongo.class); |
| | | if(byId != null){ |
| | | byId.setUserId(SecurityUtils.getCurrentUserId()); |
| | | mongoTemplate.save(byId); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | TaskUserMongoDto taskUserMongoDto = new TaskUserMongoDto(); |
| | | taskUserMongoDto.setId(taskUserMongo.getId()); |
| | | taskUserMongoDto.setName(taskUserMongo.getName()); |
| | | taskUserMongoDto.setOld_id(taskUserMongo.getTask().getOld_id()); |
| | | taskUserMongoDto.setTaskClassification(taskUserMongo.getTaskClassification()); |
| | | |
| | | if (taskUserMongo.getUserId() != null) { |
| | | taskUserMongoDto.setUserId(taskUserMongo.getUserId()); |
| | | UserDto userDto = userService.findById(taskUserMongo.getUserId()); |
| | |
| | | // taskUserRepository.save(taskUserNew); |
| | | // } |
| | | |
| | | if(resources.getUserId() == null){ |
| | | TaskUserMongo byId = mongoTemplate.findById(resources.getId(), TaskUserMongo.class); |
| | | if(byId != null){ |
| | | byId.setUserId(null); |
| | | mongoTemplate.save(byId); |
| | | } |
| | | } |
| | | |
| | | mongoTemplate.save(resources); |
| | | |
| | | // // 根据项目ID查询项目信息 |
| | |
| | | import { encrypt } from '@/utils/rsaEncrypt' |
| | | import qs from 'qs' |
| | | |
| | | export function getProjectUser(param) { |
| | | return request({ |
| | | url: 'api/users/getProjectUser?taskId=' + param, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/users/all' + '?' + qs.stringify(params, { indices: false }), |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, get, getApprovalUsers, getUserCalendarInfo, getUserBaseInfo, getByDept } |
| | | export default { getAll, add, edit, del, get, getApprovalUsers, getUserCalendarInfo, getUserBaseInfo, getByDept, getProjectUser } |
| | |
| | | }) |
| | | } |
| | | |
| | | export function ChildrenTaskAnyParent(params) { |
| | | return request({ |
| | | url: 'api/task/ChildrenTaskAnyParent', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/task', |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, getTags, getNames, getProjects, getChildren, add, edit, del, divide, getPartake, getProjectTotal } |
| | | export default { getAll, getTags, getNames, getProjects, getChildren, add, edit, del, divide, getPartake, getProjectTotal, ChildrenTaskAnyParent } |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, calcHours, getTaskUserIds, getSum } |
| | | export function addTaskUser(params) { |
| | | return request({ |
| | | url: 'api/taskUser/addTaskUser?TaskId=' + params.TaskId, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export default { getAll, add, edit, del, calcHours, getTaskUserIds, getSum, addTaskUser } |
| | |
| | | <el-descriptions-item label="剩余天数">{{ curProject === null ? '0' : '0' }}</el-descriptions-item> |
| | | <el-descriptions-item label="总任务数">{{ curProject === null ? '0' : curProject.totalTask }}</el-descriptions-item> |
| | | <el-descriptions-item label="完成任务数">{{ curProject === null ? '0' : curProject.completeTask }}</el-descriptions-item> |
| | | <el-descriptions-item label="任务完成比">{{ curProject === null ? '0%' : (curProject.completeTask / curProject.totalTask) * 100 + '%' }}</el-descriptions-item> |
| | | <el-descriptions-item label="任务完成比">{{ curProject === null ? '0%' : (parseFloat((curProject.completeTask / curProject.totalTask) * 100) ).toFixed(2)+ '%' }}</el-descriptions-item> |
| | | <el-descriptions-item label="总工时数">{{ curProject === null ? '0.0' : curProject.totalHours }}</el-descriptions-item> |
| | | <el-descriptions-item label="完成工时数">{{ curProject === null ? '0.0' : curProject.completeHours }}</el-descriptions-item> |
| | | <el-descriptions-item label="工时完成比">{{ curProject === null ? '0%' : (curProject.completeHours / curProject.totalHours) * 100 + '%' }}</el-descriptions-item> |
| | | <el-descriptions-item label="工时完成比">{{ curProject === null ? '0%' : (parseFloat((curProject.completeHours / curProject.totalHours) * 100)).toFixed(2) + '%' }}</el-descriptions-item> |
| | | </el-descriptions> |
| | | </el-card> |
| | | </div> |
| | |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <crudOperation v-if="this.crud.query.flag" :permission="permission" /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> |
| | |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="所属员工" prop="userId"> |
| | | <el-select v-model="form.userIdList" multiple filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-form-item label="任务负责人" prop="userId"> |
| | | <el-select v-model="form.userIdList" :no-data-text=" '未任务成员' " multiple filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in containUserList" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | > |
| | | <span style="float: left">{{ item.nickName }}</span> |
| | | <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务成员" prop="containUserList"> |
| | | <el-select v-model="form.containUserList" multiple filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | |
| | | row-key="id" |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | @selection-change="crud.selectionChangeHandler" |
| | | @row-click="getTaskUser" |
| | | > |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180" /> |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" /> |
| | | <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del'])" label="操作" width="180px" align="center" fixed="right"> |
| | | <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del']) && this.crud.query.flag === true" label="操作" width="180px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation :data="scope.row" :permission="permission" /> |
| | | </template> |
| | |
| | | tags: [], |
| | | // tag标签 |
| | | inputVisible: false, |
| | | inputValue: '' |
| | | inputValue: '', |
| | | containUserList: [] |
| | | } |
| | | }, |
| | | created() { |
| | |
| | | queryByProjectId(project) { |
| | | this.crud.resetQuery(false) |
| | | this.crud.query.projectId = project.id |
| | | this.crud.query.flag = project.flag |
| | | this.crud.toQuery() |
| | | this.getProjectTotal() |
| | | }, |
| | |
| | | this.tags = res |
| | | }) |
| | | }, |
| | | getTaskUser(even) { |
| | | this.containUserList = [] |
| | | var containList = even.containUserList |
| | | for (var i = 0; i < this.users.length; i++) { |
| | | for (var j = 0; j < containList.length; j++) { |
| | | if (containList[j] === this.users[i].id) { |
| | | this.containUserList.push(this.users[i]) |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | handleClose(id) { |
| | | this.form.tagList.splice(id, 1) |
| | | }, |
| | |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <crudOperation :permission="permission"> |
| | | <crudOperation v-if="flag" :permission="permission"> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.generate" |
| | |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> |
| | | <el-form-item label="所属" prop="taskId"> |
| | | <el-input v-show="false" v-model="form.task.id" style="width: 340px;"></el-input> |
| | | <el-input v-model="form.task.name" :disabled="true" style="width: 340px;"></el-input> |
| | | <el-input v-show="false" v-model="form.task.id" style="width: 340px;" /> |
| | | <el-input v-model="form.task.name" :disabled="true" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务名称"> |
| | | <el-input v-model="form.name" style="width: 340px;" /> |
| | |
| | | <el-tag>{{ dict.label[taskStatus][scope.row.taskStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="180" align="center" fixed="right"> |
| | | <el-table-column v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="200" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | v-if="flag" |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | > |
| | | <el-button |
| | | slot="left" |
| | | v-if="scope.row.userNickName" |
| | | slot="left" |
| | | v-permission="permission.list" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-check" |
| | | style="display:none" |
| | | @click="toPick(scope.row)" |
| | | /> |
| | | <el-button |
| | | slot="left" |
| | | v-else |
| | | slot="left" |
| | | v-permission="permission.list" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | @click="unPick(scope.row)" |
| | | /> |
| | | >获取</el-button> |
| | | </udOperation> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | const defaultForm = { id: null, userId: null, projectId: null, task: { id: null }, taskStartDate: null, taskEndDate: null, taskHours: null, taskStatus: null, remarks: null, divideUserIds: [] } |
| | | export default { |
| | | name: 'TaskUser', |
| | | // eslint-disable-next-line vue/no-unused-components |
| | | components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker, UploadExcelComponent }, |
| | | cruds() { |
| | | return CRUD({ title: '任务分配', url: 'api/taskUser', crudMethod: { ...crudTaskUser }}) |
| | |
| | | dicts: [constant.TASK_STATUS, constant.TAST_CLASSIFICATION, constant.STANDARD_WORKLOAD_UNIT, constant.PERFORMANCE_TYPE], |
| | | data() { |
| | | // 时长(万内)验证 |
| | | // eslint-disable-next-line no-unused-vars |
| | | var durationValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | |
| | | // 生成表单加载 |
| | | generateLoading: false, |
| | | uploading: true, |
| | | flag: false |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | mounted() { |
| | | this.getAllProjectDatas() |
| | | this.getTaskDatas() |
| | | this.getUser() |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | |
| | | return time.getTime() < new Date(this.planStartTime) -8.64e7 || time.getTime() > new Date(this.planEndTime).getTime() |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | | getUser(taskId) { |
| | | // 获取用户 |
| | | crudUser.getAll().then(res => { |
| | | crudUser.getProjectUser(taskId).then(res => { |
| | | // 用户列表 |
| | | this.users = res |
| | | }) |
| | |
| | | } |
| | | this.taskLoading = true |
| | | setTimeout(() => { |
| | | crudTask.getChildren(params).then(res => { |
| | | crudTask.ChildrenTaskAnyParent(params).then(res => { |
| | | if (resolve) { |
| | | resolve(res) |
| | | } else { |
| | |
| | | this.query.taskId = data.id |
| | | this.query.taskStatus = ['task_status_not_started', 'task_status_in_hand', 'task_status_test', 'task_status_stop'] |
| | | this.selectedTaskName = data.name |
| | | this.flag = data.flag |
| | | console.log('data : ', data) |
| | | this.planStartTime = data.planStartTime |
| | | this.planEndTime = data.planEndTime |
| | |
| | | }) |
| | | } |
| | | this.crud.toQuery() |
| | | this.getUser(this.query.taskId) |
| | | }, |
| | | beforeUpload(file) { |
| | | const isLt1M = file.size / 1024 / 1024 < 1 |
| | |
| | | // // 生成表单加载 |
| | | // this.generateLoading = false |
| | | // }) |
| | | }, |
| | | |
| | | unPick(e) { |
| | | crudTaskUser.addTaskUser({ 'TaskId': e.id }).then(res => { |
| | | if (res === 1) { |
| | | this.$notify({ |
| | | title: '获取成功', |
| | | type: 'success', |
| | | duration: 2500 |
| | | }) |
| | | window.location.reload() |
| | | } else { |
| | | this.$notify({ |
| | | title: '获取失败', |
| | | type: 'error', |
| | | duration: 2500 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |