| | |
| | | import com.google.common.collect.Lists; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import kr.wisestone.owl.common.ExcelConditionCheck; |
| | | import kr.wisestone.owl.common.IssueCustomFieldValueFormComparator; |
| | | import kr.wisestone.owl.config.CommonConfiguration; |
| | | import kr.wisestone.owl.constant.Constants; |
| | | import kr.wisestone.owl.constant.ElasticSearchConstants; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.constant.UsePartner; |
| | | import kr.wisestone.owl.constant.*; |
| | | import kr.wisestone.owl.data.CheckIssueData; |
| | | import kr.wisestone.owl.domain.*; |
| | | import kr.wisestone.owl.domain.enumType.CustomFieldType; |
| | |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.mapper.IssueMapper; |
| | | import kr.wisestone.owl.mapper.ProjectMapper; |
| | | import kr.wisestone.owl.repository.IssueRelationRepository; |
| | | import kr.wisestone.owl.repository.IssueRepository; |
| | | import kr.wisestone.owl.repository.UserDepartmentRepository; |
| | | import kr.wisestone.owl.repository.WorkflowDepartmentRepository; |
| | | import kr.wisestone.owl.service.*; |
| | | import kr.wisestone.owl.util.*; |
| | | import kr.wisestone.owl.util.DateUtil; |
| | |
| | | |
| | | @Autowired |
| | | private ProjectService projectService; |
| | | |
| | | @Autowired |
| | | private IssueTableConfigService issueTableConfigService; |
| | | |
| | | @Autowired |
| | | private IssueStatusService issueStatusService; |
| | |
| | | private UserWorkspaceService userWorkspaceService; |
| | | |
| | | @Autowired |
| | | private UserLevelService userLevelService; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentService workflowDepartmentService; |
| | | |
| | | @Autowired |
| | | private IssueRelationService issueRelationService; |
| | | |
| | | @Autowired |
| | | private IssueRelationRepository issueRelationRepository; |
| | | |
| | | @Autowired |
| | | private ExcelView excelView; |
| | |
| | | |
| | | @Autowired |
| | | private SimpMessagingTemplate simpMessagingTemplate; |
| | | |
| | | @Autowired |
| | | private UserDepartmentRepository userDepartmentRepository; |
| | | |
| | | @Autowired |
| | | private WorkflowDepartmentRepository workflowDepartmentRepository; |
| | | |
| | | @Override |
| | | protected JpaRepository<Issue, Long> getRepository() { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 프로젝트 입력 |
| | | Project project = issueType.getProject(); |
| | | if (project == null){ |
| | |
| | | issueForm.setSeverityId(issueApiDefault.getSeverity().getId()); |
| | | } |
| | | |
| | | // 중복 값 하위 이슈로 처리하기 |
| | | // 중복 값 상위 이슈의 하위 이슈로 처리하기 |
| | | CustomFieldApiOverlapForm customFieldApiOverlapForm = new CustomFieldApiOverlapForm(); |
| | | customFieldApiOverlapForm.setUserId(user.getId()); |
| | | customFieldApiOverlapForm.setIssueTypeId(issueForm.getIssueTypeId()); |
| | | |
| | | List<IssueVo> issueVos = this.findIssue(issueApiForm, user.getId()); |
| | | // 상위일감에 사용할 중복값 설정 |
| | | List<CustomFieldApiOverlap> customFieldApiOverlaps = this.customFieldApiOverlapService.find(user.getId(), issueApiForm.getIssueTypeId()); |
| | | for(int i=0; i < customFieldApiOverlaps.size() ; i++ ){ |
| | | CustomFieldApiOverlap customFieldApiOverlap = customFieldApiOverlaps.get(i); |
| | | issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId()); |
| | | } |
| | | |
| | | List<IssueVo> issueVos = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId()); |
| | | int size = issueVos.size(); |
| | | if (size == 1) { |
| | | if (size > 0) { |
| | | issueForm.setParentIssueId(issueVos.get(0).getId()); |
| | | } else if (size > 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.API_OVERLAP_ERROR)); |
| | | } |
| | | |
| | | issueForm.setIsApi(Issue.IS_API_YES); |
| | |
| | | // API 를 통해 이슈 추가. |
| | | @Override |
| | | @Transactional |
| | | public Issue addApiIssue(IssueApiForm issueApiForm) { |
| | | public List<Issue> addApiIssue(IssueApiForm issueApiForm) throws CloneNotSupportedException { |
| | | User user = convertToUser(issueApiForm.getToken()); |
| | | IssueForm issueForm = this.convertToIssueForm(issueApiForm, user); |
| | | |
| | | return addIssue(user, issueForm, issueApiForm.getMultipartFiles()); |
| | | List<Issue> issues = Lists.newArrayList(); |
| | | if (issueForm.getParentIssueId() != null) { |
| | | issues.add(addIssue(user, issueForm, issueApiForm.getMultipartFiles())); |
| | | } else { |
| | | // 상위 이슈 추가 |
| | | IssueForm parentIssueForm = issueForm.clone(); |
| | | parentIssueForm.setUseIssueCustomFields(issueApiForm.getUseIssueCustomFieldIds()); |
| | | Issue issue = addIssue(user, parentIssueForm, null); |
| | | issues.add(issue); |
| | | // 하위 이슈 추가 |
| | | issueForm.setParentIssueId(issue.getId()); |
| | | issues.add(addIssue(user, issueForm, issueApiForm.getMultipartFiles())); |
| | | } |
| | | |
| | | return issues; |
| | | } |
| | | |
| | | |
| | | // 상위 이슈 가져오기 |
| | | private IssueVo getParentIssueVo(Long parentIssueId) { |
| | | if (parentIssueId != null) { |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | return ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // 중복된 상위 이슈 검색 |
| | | private List<IssueVo> findIssue(IssueApiForm issueApiForm, Long userId) { |
| | | private List<IssueVo> findIssue(IssueApiForm issueApiform, List<CustomFieldApiOverlap> customFieldApiOverlaps, Long userId) { |
| | | List<IssueCustomFieldValueForm> issueCustomFieldValueForms = issueApiform.getIssueCustomFieldValues(); |
| | | List<IssueVo> resultIssueVos = Lists.newArrayList(); |
| | | String comma = ","; |
| | | |
| | | List<CustomFieldApiOverlap> customFieldApiOverlaps = this.customFieldApiOverlapService.find(userId, issueApiForm.getIssueTypeId()); |
| | | if (issueCustomFieldValueForms.size() > 0) { |
| | | String concatUseValue = ""; |
| | | int useIdx = 0; |
| | | |
| | | List<IssueVo> resultIssueVos = new ArrayList<>(); |
| | | if (customFieldApiOverlaps != null && customFieldApiOverlaps.size() > 0) { |
| | | for (CustomFieldApiOverlap customFieldApiOverlap : customFieldApiOverlaps) { |
| | | for (IssueCustomFieldValueForm issueCustomFieldValue : issueApiForm.getIssueCustomFieldValues()) { |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | if (customFieldApiOverlap.getCustomField().getId().equals(issueCustomFieldValue.getCustomFieldId())) { |
| | | issueCustomFieldValueCondition.setUseValue(issueCustomFieldValue.getUseValue()); |
| | | IssueCustomFieldValueFormComparator comp = new IssueCustomFieldValueFormComparator(); |
| | | Collections.sort(issueCustomFieldValueForms, comp); |
| | | |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | List<IssueVo> findIssueVos = new ArrayList<>(); |
| | | Collections.copy(resultIssueVos, findIssueVos); |
| | | resultIssueVos.clear(); |
| | | for (Map<String, Object> result : results) { |
| | | IssueVo issueVo = ConvertUtil.convertMapToClass(result, IssueVo.class); |
| | | if (findIssueVos.size() == 0) { |
| | | resultIssueVos.add(issueVo); |
| | | } else { |
| | | IssueVo findIssueVo = findIssueVo(findIssueVos, issueVo.getId()); |
| | | if (findIssueVo != null) { |
| | | resultIssueVos.add(findIssueVo); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | resultIssueVos.clear(); |
| | | return resultIssueVos; |
| | | for (IssueCustomFieldValueForm issueCustomFieldValueForm : issueCustomFieldValueForms) { |
| | | for(CustomFieldApiOverlap customFieldApiOverlap : customFieldApiOverlaps) { |
| | | if (customFieldApiOverlap.getCustomField().getId().equals(issueCustomFieldValueForm.getCustomFieldId())) { |
| | | if (useIdx > 0) { |
| | | concatUseValue = concatUseValue.concat(comma); |
| | | } |
| | | concatUseValue = concatUseValue.concat(issueCustomFieldValueForm.getUseValue()); |
| | | useIdx++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | issueCustomFieldValueCondition.setUseValue(concatUseValue); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | for (Map<String, Object> result : results) { |
| | | resultIssueVos.add(ConvertUtil.convertMapToClass(result, IssueVo.class)); |
| | | } |
| | | } |
| | | } |
| | |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | // 담당 부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | // 이슈 상태 유형이 '대기' 인 이슈 상태 가져오기 |
| | | IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); |
| | |
| | | // 날짜 유효성 체크 |
| | | this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate()); |
| | | // 담당 부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | // 이슈 상태 유형이 '대기' 인 이슈 상태 가져오기 |
| | | IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); |
| | |
| | | } |
| | | } |
| | | |
| | | void SetMyDepartmentId(IssueCondition issueCondition){ |
| | | Long loginId = issueCondition.getLoginUserId(); |
| | | List<Long> myDepartmentIds = Lists.newArrayList(); |
| | | List<UserDepartment> myDepartments = this.userDepartmentRepository.findByUserId(loginId); |
| | | |
| | | if(myDepartments != null && myDepartments.size() > 0){ |
| | | for(UserDepartment myDepartment : myDepartments){ |
| | | myDepartmentIds.add(myDepartment.getDepartmentId()); |
| | | } |
| | | } |
| | | issueCondition.setMyDepartmentIds(myDepartmentIds); |
| | | } |
| | | |
| | | void SetWorkflowDepartment(List<IssueVo> issueVos){ |
| | | for(IssueVo issueVo : issueVos){ |
| | | Long issueTypeId = issueVo.getIssueTypeId(); |
| | | IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); |
| | | Long workflowId = issueType.getWorkflow().getId(); |
| | | List<WorkflowDepartment> workflowDepartmentList = this.workflowDepartmentRepository.findByWorkflowId(workflowId); |
| | | List<Long> workflowDepartmentIds = Lists.newArrayList(); |
| | | if(workflowDepartmentList != null && workflowDepartmentList.size()>0){ |
| | | for(WorkflowDepartment workflowDepartment : workflowDepartmentList){ |
| | | workflowDepartmentIds.add(workflowDepartment.getDepartment().getId()); |
| | | } |
| | | } |
| | | if(issueVo.getIssueTypeId().equals(issueTypeId)){ |
| | | issueVo.setWorkflowDepartmentIds(workflowDepartmentIds); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 이슈 목록을 조회한다. |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public List<IssueVo> findIssue(Map<String, Object> resJsonData, |
| | | IssueCondition issueCondition, Pageable pageable) { |
| | | public List<IssueVo> findIssue(Map<String, Object> resJsonData, IssueCondition issueCondition, Pageable pageable) { |
| | | |
| | | // 검색 조건을 만든다 |
| | | if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) { |
| | | /*if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) { |
| | | // 이슈 목록을 찾지 못할 경우 기본 정보로 리턴한다. |
| | | this.notFoundIssueList(resJsonData, pageable); |
| | | return Lists.newArrayList(); |
| | | } |
| | | }*/ |
| | | |
| | | Set<String> issueIds = new HashSet<>(); // 사용자 정의 필드 검색시 나오는 이슈 아이디 저장 컬렉션 |
| | | |
| | |
| | | List<String> issueKeys = Lists.newArrayList(issueIds); |
| | | issueCondition.setIssueIds(issueKeys); |
| | | |
| | | List<Map<String, Object>> results = this.issueMapper.find(issueCondition); |
| | | issueCondition.setLoginUserId(this.webAppUtil.getLoginId()); |
| | | issueCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | |
| | | |
| | | List<Map<String, Object>> results = Lists.newArrayList(); |
| | | Long totalCount = 0L; |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_PROJECT_ALL)) { |
| | | results = this.issueMapper.find(issueCondition); |
| | | totalCount = this.issueMapper.count(issueCondition); |
| | | } else{ |
| | | this.SetMyDepartmentId(issueCondition); |
| | | results = this.issueMapper.findByDepartment(issueCondition); |
| | | totalCount = this.issueMapper.countByDepartment(issueCondition); |
| | | } |
| | | |
| | | |
| | | // 튜닝 전 - 0.8, 0.9, 0.9, 0.9, 0.9 |
| | | /*StopWatch serviceStart = new StopWatch(); |
| | | serviceStart.start();*/ |
| | | Long totalCount = this.issueMapper.count(issueCondition); |
| | | // 튜닝 전 - 1.1, 1.1, 1.3, 1.2 |
| | | |
| | | /*serviceStart.stop(); |
| | |
| | | |
| | | int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1; |
| | | // 이슈 아이디 초기화 |
| | | issueCondition.setIsApi(issueCondition.getIsApi()); |
| | | issueCondition.setIssueIds(Lists.newArrayList()); |
| | | // Map 에 있는 데이터를 IssueVo 데이터로 변환한다. |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | this.setMapToIssueVo(results, issueVos, issueCondition, user); |
| | | |
| | | this.setCountDownIssues(results, issueVos); |
| | | this.SetWorkflowDepartment(issueVos); //워크플로우에 설정한 담당부서 가져오기 |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, issueVos); |
| | | resJsonData.put(Constants.REQ_KEY_PAGE_VO, new ResPage(pageable.getPageNumber(), pageable.getPageSize(), |
| | |
| | | return issueVos; |
| | | } |
| | | |
| | | private void setCountDownIssues(List<Map<String, Object>> results, List<IssueVo> issueVos) { |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | | public void setCountDownIssues(List<Map<String, Object>> results, List<IssueVo> issueVos) { |
| | | for (Map<String, Object> result : results){ |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId((Long) result.get("id")); //하위이슈 가져오기 |
| | | if(downIssues != null && downIssues.size() > 0){ //상위이슈 가지고 있는 애들이 있으면 |
| | | int downIssueCount = 0; |
| | | int downIssueAllCount = 0;// 하위이슈 전체 카운트 |
| | | int downIssueCount = 0;// 하위이슈 미완료 카운트 |
| | | for(Issue downIssue : downIssues){ |
| | | downIssueCount ++; |
| | | downIssueAllCount ++; |
| | | Long parentIssueId = downIssue.getParentIssue().getId(); |
| | | Issue parentIssue = this.getIssue(parentIssueId); |
| | | IssueVo parentIssueVo = ConvertUtil.copyProperties(parentIssue, IssueVo.class); |
| | | parentIssueVo.setDownIssueCount(downIssueCount); |
| | | parentIssueVo.setDownIssueAllCount(downIssueAllCount); |
| | | |
| | | IssueStatus downIssueStatus = this.issueStatusService.getIssueStatus(downIssue.getIssueStatus().getId()); |
| | | IssueVo downIssueVo = ConvertUtil.copyProperties(downIssue, IssueVo.class); |
| | | downIssueVo.setIssueStatusType(downIssueStatus.getIssueStatusType().toString()); |
| | | |
| | | if(!downIssueVo.getIssueStatusType().equals("CLOSE")){ //미완료 하위이슈 체크 |
| | | downIssueCount ++; |
| | | } |
| | | |
| | | for(IssueVo issueVo : issueVos){ |
| | | if(issueVo.getId().equals(parentIssueVo.getId())){ |
| | | issueVo.setDownIssueCount(parentIssueVo.getDownIssueCount()); |
| | | issueVo.setDownIssueCount(downIssueCount); |
| | | issueVo.setDownIssueAllCount(parentIssueVo.getDownIssueAllCount()); |
| | | } |
| | | } |
| | | } |
| | |
| | | condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); |
| | | projectCondition.setWorkspaceId(condition.getWorkspaceId()); |
| | | |
| | | |
| | | // 프로젝트 키가 존재할 경우 프로젝트 키에 해당하는 프로젝트를 조회하고 검색 조건에 셋팅한다. |
| | | if (!this.getProjectByProjectKey(condition.getProjectKey(), condition)) { |
| | | return false; |
| | |
| | | // 프로젝트를 선택하지 않았으면 해당 업무 공간에서 참여하고 있는 프로젝트를 찾는다. |
| | | if (condition.getProjectIds().size() < 1) { |
| | | List<Map<String, Object>> projects = null; |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user)) { |
| | | UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); |
| | | if (this.userWorkspaceService.checkWorkspaceManager(user) |
| | | || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_PROJECT_ALL)) { |
| | | projects = this.projectMapper.findByWorkspaceManagerAll(projectCondition); |
| | | } else { |
| | | projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectCondition); |
| | |
| | | |
| | | case "02": // 프로젝트, 이슈 유형, 이슈 상태, 우선순위, 중요도, 담당자, 첨부파일, 사용자 정의 필드 정보, 댓글, 기록을 셋팅한다. |
| | | this.setIssueDetail(issueVo, issue); // 이슈 상세 정보를 셋팅한다. |
| | | this.setIssueTableConfigs(issue, issueVo); |
| | | issueVo.setProjectVo(ConvertUtil.copyProperties(issue.getProject(), ProjectVo.class)); |
| | | break; |
| | | } |
| | |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, issueVo); |
| | | } |
| | | |
| | | // 테이블 설정 셋팅 |
| | | private void setIssueTableConfigs(Issue issue, IssueVo issueVo) { |
| | | Long IssueTypeId = issue.getIssueType().getId(); |
| | | |
| | | for (int tableConfigType : IssueTableConfig.IssueTableTypes) { |
| | | if (tableConfigType != IssueTableConfig.ISSUE_TABLE_TYPE_MAIN) { |
| | | issueVo.addIssueTableConfigVo(createIssueTableConfigVo(IssueTypeId, tableConfigType)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private IssueTableConfigVo createIssueTableConfigVo(Long issueTypeId, int tableConfigType) { |
| | | IssueTableConfig issueTableConfig = this.issueTableConfigService.findByUserIdAndWorkspaceIdAndIssueTypeIdAndIssueTableType(issueTypeId, tableConfigType); |
| | | if (issueTableConfig != null) { |
| | | return ConvertUtil.copyProperties(issueTableConfig, IssueTableConfigVo.class); |
| | | } |
| | | return new IssueTableConfigVo(); |
| | | } |
| | | |
| | | |
| | | // 하위 이슈 정보를 셋팅한다 |
| | | private void setDownIssues(Issue issue, IssueVo issueVo) { |
| | |
| | | @Override |
| | | @Transactional |
| | | public List<IssueVo> findIssue(IssueApiForm issueApiform) { |
| | | |
| | | List<IssueCustomFieldValueForm> issueCustomFieldValueForms = issueApiform.getIssueCustomFieldValues(); |
| | | List<IssueVo> resultIssueVos = new ArrayList<>(); |
| | | List<IssueVo> resultIssueVos = Lists.newArrayList(); |
| | | String comma = ","; |
| | | |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | if (issueCustomFieldValueForms.size() > 0) { |
| | | for (IssueCustomFieldValueForm issueCustomFieldValueForm : issueCustomFieldValueForms) { |
| | | // issueCustomFieldValueCondition.addUseValue(issueCustomFieldValueForm.getUseValue()); |
| | | issueCustomFieldValueCondition.setUseValue(issueCustomFieldValueForm.getUseValue()); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | List<IssueVo> findIssueVos = new ArrayList<>(); |
| | | Collections.copy(resultIssueVos, findIssueVos); |
| | | resultIssueVos.clear(); |
| | | for (Map<String, Object> result : results) { |
| | | IssueVo issueVo = ConvertUtil.convertMapToClass(result, IssueVo.class); |
| | | String concatUseValue = ""; |
| | | for (int i = 0; i < issueCustomFieldValueForms.size(); i++) { |
| | | IssueCustomFieldValueForm issueCustomFieldValueForm = issueCustomFieldValueForms.get(i); |
| | | if (i > 0) { |
| | | concatUseValue = concatUseValue.concat(comma); |
| | | } |
| | | concatUseValue = concatUseValue.concat(issueCustomFieldValueForm.getUseValue()); |
| | | } |
| | | |
| | | if (findIssueVos.size() == 0) { |
| | | resultIssueVos.add(issueVo); |
| | | } else { |
| | | IssueVo findIssueVo = findIssueVo(findIssueVos, issueVo.getId()); |
| | | if (findIssueVo != null) { |
| | | resultIssueVos.add(findIssueVo); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | resultIssueVos.clear(); |
| | | return resultIssueVos; |
| | | IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); |
| | | issueCustomFieldValueCondition.setUseValue(concatUseValue); |
| | | List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition); |
| | | if (results != null && results.size() > 0) { |
| | | for (Map<String, Object> result : results) { |
| | | resultIssueVos.add(ConvertUtil.convertMapToClass(result, IssueVo.class)); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (issueVos != null && issueVos.size() > 0) { |
| | | List<Issue> issue = Lists.newArrayList(); |
| | | for (IssueVo issueVo : issueVos) { |
| | | IssueVo parentIssueVo = issueVo.getParentIssueVo(); |
| | | issueForm.setId(issueVo.getId()); |
| | | issue.add(this.modifyIssueForApi(user, issueForm, files)); |
| | | |
| | | // 자동 종료 상태 설정이 되어 있지 않으면 오류발생 |
| | | Issue modifyIssue = this.modifyIssueForApi(user, issueForm, files); |
| | | Issue parentIssue = modifyIssue.getParentIssue(); |
| | | IssueType issueType = modifyIssue.getIssueType(); |
| | | IssueStatus issueStatus = issueType.getIssueStatus(); |
| | | if (issueStatus == null) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_COMPLETE_ISSUE_STATUS_NOT_EXIST)); |
| | | } |
| | | |
| | | if (parentIssue != null) { |
| | | IssueCondition issueCondition = new IssueCondition(issueVo.getId(), parentIssue.getId()); |
| | | List<Map<String, Object>> results = this.issueMapper.findNotCompleteByParentIssueId(issueCondition); |
| | | // 하위 일감이 모두 종료 상태일때 상위 일감도 종료 처리 |
| | | if (results == null || results.size() == 0) { |
| | | parentIssue.setIssueStatus(issueType.getIssueStatus()); |
| | | this.issueRepository.saveAndFlush(parentIssue); |
| | | } |
| | | } |
| | | |
| | | issue.add(modifyIssue); |
| | | } |
| | | return issue; |
| | | } else { |
| | |
| | | // 담당자 유효성 체크 |
| | | //this.verifyIssueAssignee(project, issueForm); |
| | | // 담당부서 유효성 체크 |
| | | this.verifyIssueDepartment(project, issueForm); |
| | | //this.verifyIssueDepartment(project, issueForm); |
| | | |
| | | CheckIssueData checkIssueData = new CheckIssueData(); |
| | | checkIssueData.setIssue(issue); |
| | |
| | | this.issueHistoryService.detectIssueStatus(issue, issueForm, detectIssueChange, oldIssueStatus, issueStatus); |
| | | } |
| | | |
| | | // db에 저장 |
| | | issue = this.saveIssue(issueForm, checkIssueData); |
| | | |
| | | // 이슈 이력 등록 |
| | |
| | | //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos); |
| | | // 담당자가 없으면 모든 사용자가 수정 권한을 갖는다. |
| | | |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_ISSUE_MANAGER, issueVo, null, null, user); |
| | | hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_PROJECT_MANAGER, issueVo, null, null, user); |
| | | |
| | | return hasPermission; |
| | | } |
| | | |
| | |
| | | List<Issue> removeIssues = Lists.newArrayList(); |
| | | |
| | | for (Long issueId : issueForm.getRemoveIds()) { |
| | | //하위이슈 체크 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId); |
| | | if(downIssues != null && downIssues.size() > 0){ |
| | | for(Issue downIssue : downIssues){ |
| | | if(downIssue.getParentIssue() != null){ |
| | | downIssue.setParentIssue(null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Issue issue = this.issueRemoves(issueId, user); |
| | | removeIssues.add(issue); |
| | | } |
| | | |
| | | if (removeIssues.size() > 0) { |
| | | //this.issueRepository.deleteAll(removeIssues); |
| | | } |
| | | /*if (removeIssues.size() > 0) { |
| | | this.issueRepository.deleteAll(removeIssues); |
| | | }*/ |
| | | |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE)); |
| | | } |
| | | |
| | | private Issue issueRemoves(Long issueId, User user) { |
| | | Issue issue = this.getIssue(issueId); |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | this.verifyIssueModifyPermission(issue, user); |
| | | // 이슈를 삭제한다. |
| | | @Override |
| | | @Transactional |
| | | public void removeAllIssues(IssueForm issueForm) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | this.workspaceService.checkUseWorkspace(); |
| | | |
| | | // 이슈 첨부 파일을 삭제한다. |
| | | if (issue.getAttachedFiles().size() > 0) { |
| | | List<Long> attachedFileIds = Lists.newArrayList(); |
| | | |
| | | for (AttachedFile attachedFile : issue.getAttachedFiles()) { |
| | | attachedFileIds.add(attachedFile.getId()); |
| | | } |
| | | // 첨부파일 삭제 |
| | | this.attachedFileService.removeAttachedFiles(attachedFileIds); |
| | | if (issueForm.getRemoveIds().size() < 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.ISSUE_REMOVE_NOT_SELECT)); |
| | | } |
| | | |
| | | // 이슈 생성, 삭제시 예약 이메일에 등록해놓는다. |
| | | this.reservationIssueEmail(issue, EmailType.ISSUE_REMOVE); |
| | | // 이슈 삭제 |
| | | this.issueRepository.delete(issue); |
| | | List<Issue> removeIssues = Lists.newArrayList(); |
| | | |
| | | for (Long issueId : issueForm.getRemoveIds()) { |
| | | //하위이슈 체크 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId); |
| | | if(downIssues != null && downIssues.size() > 0){ |
| | | for(Issue downIssue : downIssues){ |
| | | Long downIssueId = downIssue.getId(); |
| | | downIssue = this.issueRemoves(downIssueId, user); |
| | | removeIssues.add(downIssue); |
| | | } |
| | | } |
| | | Issue issue = this.issueRemoves(issueId, user); |
| | | removeIssues.add(issue); |
| | | } |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE)); |
| | | } |
| | | |
| | | // 하위이슈를 삭제한다. |
| | | @Override |
| | | @Transactional |
| | | public void removeDownIssues(IssueForm issueForm) { |
| | | // 사용하고 있는 업무 공간이 활성 상태인지 확인한다. 사용 공간에서 로그인한 사용자가 비활성인지 확인한다. |
| | | User user = this.webAppUtil.getLoginUserObject(); |
| | | this.workspaceService.checkUseWorkspace(); |
| | | |
| | | if (issueForm.getRemoveIds().size() < 1) { |
| | | throw new OwlRuntimeException( |
| | | this.messageAccessor.getMessage(MsgConstants.ISSUE_REMOVE_NOT_SELECT)); |
| | | } |
| | | |
| | | List<Issue> removeIssues = Lists.newArrayList(); |
| | | Long downIssueId = 0L; |
| | | for (Long issueId : issueForm.getRemoveIds()) { |
| | | //삭제 할 이슈의 하위이슈 체크 |
| | | List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId); |
| | | if(downIssues != null && downIssues.size() > 0){ |
| | | for(Issue downIssue : downIssues){ |
| | | downIssueId = downIssue.getId(); |
| | | } |
| | | } |
| | | Issue issue = this.issueRemoves(downIssueId, user); |
| | | removeIssues.add(issue); |
| | | } |
| | | // 사용자 시스템 기능 사용 정보 수집 |
| | | log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE)); |
| | | } |
| | | |
| | | private Issue issueRemoves(Long issueId, User user) { |
| | | Issue issue = this.findOne(issueId); |
| | | if(issue != null){ |
| | | // 이슈 수정 권한을 갖고 있는지 확인 |
| | | this.verifyIssueModifyPermission(issue, user); |
| | | |
| | | // 이슈 첨부 파일을 삭제한다. |
| | | if (issue.getAttachedFiles().size() > 0) { |
| | | List<Long> attachedFileIds = Lists.newArrayList(); |
| | | |
| | | for (AttachedFile attachedFile : issue.getAttachedFiles()) { |
| | | attachedFileIds.add(attachedFile.getId()); |
| | | } |
| | | // 첨부파일 삭제 |
| | | this.attachedFileService.removeAttachedFiles(attachedFileIds); |
| | | } |
| | | |
| | | // 지울 이슈가 연관이슈인지 체크 후 연관이슈 테이블에서도 삭제한다. |
| | | List<IssueRelation> issueRelationList = this.issueRelationRepository.findByRelationIssueId(issueId); |
| | | if (issueRelationList != null && issueRelationList.size() > 0) { |
| | | for(IssueRelation issueRelation : issueRelationList){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | issueHistoryService.detectRelationIssue(IssueHistoryType.DELETE, issueRelation, sb); |
| | | issueHistoryService.addIssueHistory(issueRelation.getIssue(), IssueHistoryType.MODIFY, sb.toString()); |
| | | this.issueRelationRepository.delete(issueRelation); |
| | | } |
| | | } |
| | | |
| | | // 이슈 생성, 삭제시 예약 이메일에 등록해놓는다. |
| | | this.reservationIssueEmail(issue, EmailType.ISSUE_REMOVE); |
| | | // 이슈 삭제 |
| | | this.issueRepository.delete(issue); |
| | | } |
| | | |
| | | return issue; |
| | | } |