OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -375,10 +375,11 @@
        IssueForm issueForm = this.convertToIssueForm(issueApiForm, user);
        List<Issue> issues = Lists.newArrayList();
        if (issueForm.getParentIssueId() != null) {
        if (issueForm.getParentIssueId() != null    // 기존 추가된 상위 일감이 없거나 설정된 중복 이슈 id가 없을때
                || issueApiForm.getUseIssueCustomFieldIds().size() == 0) {
            issues.add(addIssue(user, issueForm, issueApiForm.getMultipartFiles()));
        } else {
            // 상위 이슈 추가
            // 가상 상위 이슈 추가
            IssueForm parentIssueForm = issueForm.clone();
            parentIssueForm.setUseIssueCustomFields(issueApiForm.getUseIssueCustomFieldIds());
            Issue issue = addIssue(user, parentIssueForm, null);
@@ -891,7 +892,6 @@
    @Override
    @Transactional(readOnly = true)
    public List<IssueVo> findIssue(Map<String, Object> resJsonData, IssueCondition issueCondition, Pageable pageable) {
        //  검색 조건을 만든다
        if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) {
            //  이슈 목록을 찾지 못할 경우 기본 정보로 리턴한다.
@@ -925,14 +925,14 @@
        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)) {
            this.SetAllDepartmentId(issueCondition);
        } else{
            this.SetMyDepartmentId(issueCondition);
            /*results = this.issueMapper.findByDepartment(issueCondition);
            totalCount = this.issueMapper.countByDepartment(issueCondition);*/
        }
//        if (!this.userWorkspaceService.checkWorkspaceManager(user)
//                && !MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)) { //최고관리자 & 프로젝트,이슈 관리자 일 경우 모든 이슈 보기
//            this.SetMyDepartmentId(issueCondition);
            //this.SetAllDepartmentId(issueCondition);
//        } /*else{
//            results = this.issueMapper.findByDepartment(issueCondition);
//            totalCount = this.issueMapper.countByDepartment(issueCondition);
//        }*/
        results = this.issueMapper.find(issueCondition);
        totalCount = this.issueMapper.count(issueCondition);
@@ -1239,6 +1239,9 @@
        condition.setLoginUserId(this.webAppUtil.getLoginId());
        condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
        User user = this.webAppUtil.getLoginUserObject();
        UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
        //  프로젝트 키가 존재할 경우 프로젝트 키에 해당하는 프로젝트를 조회하고 검색 조건에 셋팅한다.
        if (!this.getProjectByProjectKey(condition.getProjectKey(), condition)) {
            return false;
@@ -1246,9 +1249,17 @@
        //  프로젝트를 선택하지 않았으면 해당 업무 공간에서 참여하고 있는 프로젝트를 찾는다.
        if (condition.getProjectIds().size() < 1) {
            List<Map<String, Object>> projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectStatues, condition.getProjectType());
            List<Long> projectIds = Lists.newArrayList();
            List<Map<String, Object>> projects = Lists.newArrayList();
            if (this.userWorkspaceService.checkWorkspaceManager(user) || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)){
                return true;
            }/*else if (MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)){
                projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectStatues, condition.getProjectType());
            }*/
            else {
                projects = this.projectService.findByWorkspaceIdAndIncludeProject(projectStatues, condition.getProjectType());
            }
            List<Long> projectIds = Lists.newArrayList();
            for (Map<String, Object> result : projects) {
                Long projectId = MapUtil.getLong(result, "id");
@@ -1288,7 +1299,8 @@
            List<Map<String, Object>> projects = null;
            UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
            if (this.userWorkspaceService.checkWorkspaceManager(user)
                    || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)) {
                    || (MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT) &&
                    MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE))) {
                projects = this.projectMapper.findByWorkspaceManagerAll(projectCondition);
            } else  {
                projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectCondition);
@@ -1521,6 +1533,8 @@
                this.setRegister(downIssue, downIssueVo); // 등록자
                this.setIssueDepartment(downIssue, downIssueVo);  //  담당부서 정보 셋팅
                this.setIssueCustomFields(downIssue, downIssueVo);   // 사용자정의필드 정보 세팅
                this.setIssueHistory(downIssue, downIssueVo);   //  이슈 기록 정보 셋팅
                this.setIssueComments(downIssue, downIssueVo);  //  댓글 정보 셋팅
                resultList.add(downIssueVo);
            }
@@ -1544,10 +1558,10 @@
        this.setIssueDepartment(issue, issueVo);  //  담당부서 정보 셋팅
        this.setAttachedFiles(issue, issueVo);  //  첨부 파일 정보 셋팅
        this.setIssueCustomFields(issue, issueVo);  //  사용자 정의 필드 값 정보 셋팅
        this.setIssueComments(issue, issueVo);  //  댓글 정보 셋팅
        this.setIssueHistory(issue, issueVo);   //  이슈 기록 정보 셋팅
        this.setRelationIssue(issue, issueVo);        //연관 일감 셋팅
        this.setDownIssues(issue, issueVo); //하위 일감 세팅
        this.setIssueComments(issue, issueVo);  //  댓글 정보 셋팅
        this.setIssueHistory(issue, issueVo);   //  이슈 기록 정보 셋팅
        IssueType issueType = this.issueTypeService.getIssueType(issueVo.getIssueTypeVo().getId()); // 이슈의 이슈유형 객체
        Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // 이슈유형별로 사용중인 업체/ISP/호스팅 값
@@ -1729,7 +1743,7 @@
    //  이슈 기록 정보를 셋팅한다.
    private void setIssueHistory(Issue issue, IssueVo issueVo) {
        issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue.getId()));
        issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue));
    }
    // 사용자 정의 필드 값이 같은 이슈 찾기
@@ -1793,16 +1807,22 @@
                Issue modifyIssue = this.modifyIssueForApi(user, issueForm, files);
                Issue parentIssue = modifyIssue.getParentIssue();
                IssueType issueType = modifyIssue.getIssueType();
                IssueStatus issueStatus = issueType.getIssueStatus();
                Set<IssueTypeApiEndStatus> issueTypeApiEndStatuses = issueType.getIssueTypeApiEndStatuses();
                IssueTypeApiEndStatus issueStatus = null;
                if (issueTypeApiEndStatuses != null && issueTypeApiEndStatuses.size() > 0) {
                    issueStatus = issueTypeApiEndStatuses.iterator().next();
                } else {
                    throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_COMPLETE_ISSUE_STATUS_NOT_EXIST));
                }
                if (parentIssue != null) {
                    if (issueStatus == null) {
                        throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_COMPLETE_ISSUE_STATUS_NOT_EXIST));
                    }
                    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());
                        parentIssue.setIssueStatus(issueStatus.getIssueStatus());
                        this.issueRepository.saveAndFlush(parentIssue);
                    }
                }
@@ -3794,4 +3814,18 @@
            resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos);
        }
    }
    @Override
    public void findReadyDepartments(Map<String, Object> resJsonData, DepartmentCondition condition, Pageable pageable) {
        Integer issueStatusId = 1;
        condition.setIssueStatusId(issueStatusId);
        IssueType issueType = this.issueTypeService.getIssueType(condition.getIssueTypeId());
        if (issueType != null) {
            condition.setWorkflowId(issueType.getWorkflow().getId());
        }
        List<Map<String, Object>> departmentVos = this.departmentMapper.findByIssueStatusId(condition);
        resJsonData.put(Constants.RES_KEY_CONTENTS, departmentVos);
    }
}