| | |
| | | import me.zhengjie.modules.project.domain.*; |
| | | import me.zhengjie.modules.project.repository.*; |
| | | import me.zhengjie.modules.project.service.ProjectCostService; |
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeQueryCriteria; |
| | | import me.zhengjie.modules.system.domain.DictDetail; |
| | | import me.zhengjie.modules.system.domain.SysGoalSetting; |
| | | import me.zhengjie.modules.system.repository.SysGoalSettingRepository; |
| | |
| | | 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.service.TaskService; |
| | | import me.zhengjie.modules.task.service.dto.TaskDto; |
| | | import me.zhengjie.modules.task.service.dto.TaskQueryCriteria; |
| | | import me.zhengjie.modules.task.service.mapstruct.TaskMapper; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private final CostRepository costRepository; |
| | | private final ContractProjectRepository contractProjectRepository; |
| | | private final SysGoalSettingService sysGoalSettingService; |
| | | private final TaskService taskService; |
| | | private final TaskMapper taskMapper; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(ProjectQueryCriteria criteria, Pageable pageable) { |
| | |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> querySubgroupWorkingHours(ProjectQueryCriteria criteria){ |
| | | // 根据字典名称查询 |
| | | List<DictDetail> dictDetailList = dictDetailRepository.findByDictName(Constant.PROJECT_DISTINGUISH); |
| | | // 查询项目列表 |
| | | List<Project> projectList = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)); |
| | | List<Long> projectIdList = projectList.stream().map(Project::getId).collect(Collectors.toList()); |
| | | // 查询任务列表 |
| | | List<TaskInterface> taskInterfaceList = taskRepository.findSubgroupWorkingHoursByProjectId(projectIdList); |
| | | // 返回列表 |
| | | List<Map<String, Object>> returnList = new ArrayList<>(); |
| | | // 循环项目区分 |
| | | for (int i = 0; i < dictDetailList.size(); i ++) { |
| | | // 已分配工时 |
| | | Double divideHours = 0D; |
| | | // 未完成工时 |
| | | Double incompleteHours = 0D; |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | // 当前项目区分 |
| | | DictDetail dictDetail = dictDetailList.get(i); |
| | | // 返回集合 |
| | | returnMap.put("projectDistinguish", dictDetail.getLabel()); |
| | | // 当前任务列表 |
| | | List<TaskInterface> currentTaskInterfaceList = taskInterfaceList.stream().filter(item -> item.getProjectDistinguish().equals(dictDetail.getValue())).collect(Collectors.toList()); |
| | | // 循环当前任务列表 |
| | | for (int j = 0; j < currentTaskInterfaceList.size(); j ++) { |
| | | // 当前任务 |
| | | TaskInterface currentTaskInterface = currentTaskInterfaceList.get(j); |
| | | Task task = taskRepository.findById(currentTaskInterface.getTaskId()).orElseGet(Task::new); |
| | | // 当前任务二次处理 |
| | | TaskDto taskDto = taskMapper.toDto(task); |
| | | taskDto = taskService.customHandle(taskDto); |
| | | // 已分配工时 |
| | | divideHours += taskDto.getDivideHours(); |
| | | // 未完成工时 |
| | | incompleteHours += (taskDto.getDivideHours() - taskDto.getCompletedHours()); |
| | | } |
| | | // 返回集合 |
| | | returnMap.put("divideHours", divideHours); |
| | | returnMap.put("incompleteHours", incompleteHours); |
| | | // 返回列表 |
| | | returnList.add(returnMap); |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> queryProjectWorkingHours(ProjectQueryCriteria criteria){ |
| | | // 查询任务列表 |
| | | List<Task> taskList = taskRepository.findByProjectId(criteria.getId()); |
| | | // 已分配工时 |
| | | Double divideHours = 0D; |
| | | // 未完成工时 |
| | | Double incompleteHours = 0D; |
| | | // 循环当前任务列表 |
| | | for (int i = 0; i < taskList.size(); i ++) { |
| | | // 当前任务 |
| | | Task task = taskList.get(i); |
| | | // 当前任务二次处理 |
| | | TaskDto taskDto = taskMapper.toDto(task); |
| | | taskDto = taskService.customHandle(taskDto); |
| | | // 已分配工时 |
| | | divideHours += taskDto.getDivideHours(); |
| | | // 未完成工时 |
| | | incompleteHours += (taskDto.getDivideHours() - taskDto.getCompletedHours()); |
| | | } |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("divideHours", divideHours); |
| | | returnMap.put("incompleteHours", incompleteHours); |
| | | return returnMap; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryTypeContractPrice(ProjectQueryCriteria criteria){ |
| | | // 根据项目区分、目标年份查询类型营业额 |
| | | List<ProjectSummary> projectSummaryList = projectRepository.findTypeContractPriceByProjectDistinguishAndTargetYear(criteria.getProjectDistinguish(), criteria.getTargetYear()); |
| | | // 返回列表 |
| | | List<Map<String, Object>> returnList = new ArrayList<>(); |
| | | // 循环类型营业额 |
| | | for (int i = 0; i < projectSummaryList.size(); i ++) { |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("name", projectSummaryList.get(i).getProjectTypeName()); |
| | | returnMap.put("value", projectSummaryList.get(i).getContractPrice()); |
| | | // 返回列表 |
| | | returnList.add(returnMap); |
| | | } |
| | | return returnList; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryTypeWorkingHours(ProjectQueryCriteria criteria){ |
| | | // 根据项目区分、目标年份查询项目 |
| | | List<Project> projectList = projectRepository.findProjectByProjectDistinguishAndTargetYear(criteria.getProjectDistinguish(), criteria.getTargetYear()); |
| | | // 查询项目类型列表 |
| | | ProjectTypeQueryCriteria projectTypeQueryCriteria = new ProjectTypeQueryCriteria(); |
| | | List<ProjectType> projectTypeList = projectTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,projectTypeQueryCriteria,criteriaBuilder)); |
| | | // 返回列表 |
| | | List<Map<String, Object>> returnList = new ArrayList<>(); |
| | | // 循环项目类型列表 |
| | | for (int i = 0; i < projectTypeList.size(); i ++) { |
| | | // 项目类型 |
| | | ProjectType projectType = projectTypeList.get(i); |
| | | // 处理后项目列表 |
| | | List<Project> handleProjectList = projectList.stream().filter(item -> item.getProjectTypeId() == projectType.getId()).collect(Collectors.toList()); |
| | | // 判断处理后项目列表长度 |
| | | if (handleProjectList.size() != 0) { |
| | | // 处理后项目ID列表 |
| | | List<Long> handleProjectIdList = handleProjectList.stream().map(Project::getId).collect(Collectors.toList()); |
| | | // 根据项目ID查询总工时 |
| | | Double sumWorkingHours = taskRepository.sumWorkingHoursByProjectId(handleProjectIdList); |
| | | // 返回集合 |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | returnMap.put("name", projectType.getName()); |
| | | returnMap.put("value", sumWorkingHours); |
| | | // 返回列表 |
| | | returnList.add(returnMap); |
| | | } |
| | | } |
| | | return returnList; |
| | | } |
| | | } |