OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -211,6 +211,15 @@
        this.issueVersionService.addIssueVersion(issue);
    }
    @Override
    @Transactional
    public void addIssueVersion(Long id, Long userId) {
        Issue issue = this.getIssue(id);
        User user = this.userService.getUser(userId);
        //  이슈 버전 생성
        this.issueVersionService.addIssueVersion(issue, user);
    }
    private IssueForm convertToIssueForm(IssueApiForm issueApiForm, User user) {
        if (issueApiForm.getIssueTypeId() == null) {
@@ -366,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);
@@ -1512,6 +1522,8 @@
                this.setRegister(downIssue, downIssueVo); // 등록자
                this.setIssueDepartment(downIssue, downIssueVo);  //  담당부서 정보 셋팅
                this.setIssueCustomFields(downIssue, downIssueVo);   // 사용자정의필드 정보 세팅
                this.setIssueHistory(downIssue, downIssueVo);   //  이슈 기록 정보 셋팅
                this.setIssueComments(downIssue, downIssueVo);  //  댓글 정보 셋팅
                resultList.add(downIssueVo);
            }
@@ -1535,10 +1547,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/호스팅 값
@@ -1560,7 +1572,7 @@
        this.setParentIssue(issue,issueVo); //상위 이슈 정보 세팅
        //  이슈 수정 권한을 갖고 있는지 확인
        if (user != null && this.checkHasPermission(issueVo, issueVo.getUserVos(), user, issueVo.getDepartmentVos())) {
        if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user, issueVo.getDepartmentVos())) {
            issueVo.setModifyPermissionCheck(Boolean.TRUE);
        }
    }
@@ -1720,7 +1732,7 @@
    //  이슈 기록 정보를 셋팅한다.
    private void setIssueHistory(Issue issue, IssueVo issueVo) {
        issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue.getId()));
        issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue));
    }
    // 사용자 정의 필드 값이 같은 이슈 찾기
@@ -2232,6 +2244,19 @@
        this.verifyIssueModifyPermission(issue, user);
        IssueStatus issueStatus = this.issueStatusService.getIssueStatus(issueForm.getIssueStatusId());
        if (issueStatus.getIssueStatusType().toString().equals("CLOSE")) {
            List<String> downIssuesStatus = issueForm.getDownIssuesStatus();
            if (downIssuesStatus != null && downIssuesStatus.size() > 0) {
                for (String downIssueStatus : downIssuesStatus) {
                    if (!downIssueStatus.equals("CLOSE")) {
                        throw new OwlRuntimeException(
                                this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_MODIFY_STATUS));
                    }
                }
            }
        }
        //  이슈 상태를 변경할 때 선택한 이슈 상태로 변경할 수 있는지 확인한다.
        this.issueStatusService.checkNextIssueStatus(issue, issueStatus);
        //  변경 이력 정보 추출
@@ -2869,7 +2894,7 @@
            Map<String, Priority> priorityMaps = new HashMap<>();   //  우선 순위 모음
            Map<String, Severity> severityMaps = new HashMap<>();   //  중요도 모음
            Map<String, Object> userMaps = new HashMap<>(); //  사용자 모음
            Map<String, Object> departmentMaps = new HashMap<>(); //  부서 모음
            Map<String, DepartmentVo> departmentMaps = new HashMap<>(); //  부서 모음
            Map<String, CustomField> customFieldMaps = new HashMap<>();
            Map<String, IssueStatus> issueStatusReadyMaps = new HashMap<>();   //  상태 속성 '대기'인 이슈 상태
            Map<Long, Long> issueNumberMaps = new HashMap<>();  //  이슈 번호 모음
@@ -2919,7 +2944,7 @@
                //  1번 헤더부터 데이터 영역
                if (rowIndex > 1) {
                    //  이슈로 등록하기 위해 IssueForm 에 데이터를 셋팅한다.
                    issueForms.add(this.setIssueFormToExcelField(row, (rowIndex + 1), issueStatusReadyMaps, projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, customFieldMaps, issueNumberMaps, headers));
                    issueForms.add(this.setIssueFormToExcelField(row, (rowIndex + 1), issueStatusReadyMaps, projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, departmentMaps, customFieldMaps, issueNumberMaps, headers));
                }
            }
@@ -3070,7 +3095,7 @@
    //  이슈의 주요 속성을 map 에 저장하여 엑셀 import 에서 지정한 대상(이슈 속성)을 빠르게 찾을 수 있게 한다.
    private void IssueAttributeMapToList(Map<String, Project> projectMaps, Map<String, IssueType> issueTypeMaps, Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps,
                                         Map<String, Object> userMaps, Map<String, Object> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, Map<String, Long> issueTypeCustomFieldMaps, Map<String, IssueStatus> issueStatusReadyMaps) {
                                         Map<String, Object> userMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, Map<String, Long> issueTypeCustomFieldMaps, Map<String, IssueStatus> issueStatusReadyMaps) {
        //  프로젝트 키로 바로 찾을 수 있게 준비
        List<Project> projects = this.projectService.findByWorkspaceId();
        List<Long> projectIds = Lists.newArrayList();
@@ -3094,16 +3119,7 @@
            for (Map<String, Object> user : users) {
                userMap.put(CommonUtil.decryptAES128(MapUtil.getString(user, "account")), MapUtil.getLong(user, "userId"));
            }
            userMaps.put(project.getProjectKey(), userMap);
            //  프로젝트에 참여하는 부서 정보
            List<Map<String, Object>> departments = this.departmentService.findProjectDepartment(project);
            List<Long> departmentList = Lists.newArrayList();
            //  부서 정보를 저장
            for (Map<String, Object> department : departments) {
                departmentList.add(MapUtil.getLong(department, "departmentId"));
            }
        }
        //  이슈 유형을 바로 찾을 수 있게 준비
@@ -3113,6 +3129,13 @@
            IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow());
            issueStatusReadyMaps.put(issueType.getId().toString(), issueStatus);
            //  워크플로우에 속해있는 부서 정보
            List<DepartmentVo> departments = this.departmentService.findWorkflowDepartment(issueType.getId());
            //  부서 정보를 저장
            for (DepartmentVo department : departments) {
                departmentMaps.put(department.getDepartmentName(), department);
            }
        }
        //  우선순위를 바로 찾을 수 있게 준비
@@ -3136,7 +3159,7 @@
    //  엑셀 필드에 있는 정보를 이슈 form 으로 옮긴다.
    private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, IssueStatus> issueStatusReadyMaps, Map<String, Project> projectMaps, Map<String, IssueType> issueTypeMaps, Map<String,
            Priority> priorityMaps, Map<String, Severity> severityMaps, Map<String, Object> userMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, List<String> headers) {
            Priority> priorityMaps, Map<String, Severity> severityMaps, Map<String, Object> userMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, List<String> headers) {
        IssueForm issueForm = new IssueForm();
        issueForm.setRegisterId(this.webAppUtil.getLoginId());
        Project project = null;
@@ -3180,9 +3203,13 @@
                    //  중요도를 IssueForm 에 저장한다.
                    this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex);
                    break;
                /*case 6:
                    //  담당자를 IssueForm 에 저장한다.
                    this.setIssueFormAssignee(cell, userMaps, issueForm, project);
                    break;*/
                case 6:
                    //  담당부서를 IssueForm 에 저장한다.
                    this.setIssueFormAssignee(cell, userMaps, issueForm, project);
                    this.setIssueFormDepartment(cell, departmentMaps, issueForm, project);
                    break;
                case 7:
                    //  시작일을 IssueForm 에 저장한다.
@@ -3193,7 +3220,7 @@
                    this.setIssueFormPeriod(cell, issueForm, false, rowIndex);
                    break;
                default:
                    //  8번 이상부터는 사용자 정의 필드. 사용자 정의 필드 정보를 IssueForm 에 저장한다.
                    //  9번 부터는 사용자 정의 필드. 사용자 정의 필드 정보를 IssueForm 에 저장한다.
                    this.setIssueFormCustomFieldValue(cell, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex);
            }
        }
@@ -3322,20 +3349,39 @@
        issueForm.setSeverityId(severity.getId());
    }
    //  담당부서를 IssueForm 에 저장한다.
    private void setIssueFormAssignee(Cell cell, Map<String, Object> userMaps, IssueForm issueForm, Project project) {
        if (cell != null) {
            String[] splitAssignee = CommonUtil.convertExcelStringToCell(cell).split("#");
            Map<String, Object> userMap = (Map<String, Object>) MapUtil.getObject(userMaps, project.getProjectKey());
            List<Long> departmentIds = Lists.newArrayList();
            List<Long> userIds = Lists.newArrayList();
            for (String account : splitAssignee) {
                if (MapUtil.getLong(userMap, account) != null) {
                    departmentIds.add(MapUtil.getLong(userMap, account));
                    userIds.add(MapUtil.getLong(userMap, account));
                }
            }
            issueForm.setUserIds(userIds);
        }
    }
    //  담당부서를 IssueForm 에 저장한다.
    private void setIssueFormDepartment(Cell cell, Map<String, DepartmentVo> departmentMaps, IssueForm issueForm, Project project) {
        if (cell != null) {
            String[] splitDepartment = CommonUtil.convertExcelStringToCell(cell).split("#");
            //  값이 공백이면 중지
            String cellValue = CommonUtil.convertExcelStringToCell(cell);
            if (StringUtils.isEmpty(cellValue)) {
                return;
            }
            List<Long> departmentIds = Lists.newArrayList();
            for (String department : splitDepartment) {
                DepartmentVo departmentVo = departmentMaps.get(department);
                departmentIds.add(departmentVo.getId());
            }
            issueForm.setDepartmentIds(departmentIds);
        }
    }
@@ -3343,6 +3389,12 @@
    //  시작일, 종료일을 IssueForm 에 저장한다.
    private void setIssueFormPeriod(Cell cell, IssueForm issueForm, Boolean checkStartDate, int rowIndex) {
        if (cell != null && !cell.toString().equals("")) {
            //  값이 공백이면 중지
            String cellValue = CommonUtil.convertExcelStringToCell(cell);
            if (StringUtils.isEmpty(cellValue)) {
                return;
            }
            Date startDate;
@@ -3745,4 +3797,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);
    }
}