OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-01-10 f56a8597b4e99b766785d70e76291a374193049f
src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -16,10 +16,7 @@
import kr.wisestone.owl.mapper.IssueMapper;
import kr.wisestone.owl.mapper.IssueRelationMapper;
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.repository.*;
import kr.wisestone.owl.service.*;
import kr.wisestone.owl.util.*;
import kr.wisestone.owl.util.DateUtil;
@@ -181,6 +178,15 @@
    private IssueMapper issueMapper;
    @Autowired
    private IssueCompanyRepository issueCompanyRepository;
    @Autowired
    private IssueIspRepository issueIspRepository;
    @Autowired
    private IssueHostingRepository issueHostingRepository;
    @Autowired
    private ExcelConditionCheck excelConditionCheck;
    @Autowired
@@ -328,9 +334,8 @@
            List<Map<String, Object>> issueHostingFields = Lists.newArrayList();
            for (Map<String, Object> issueCustomField : issueForm.getIssueCustomFields()) {
                int customFieldId = (Integer) issueCustomField.get("customFieldId");
                Long customId = (long) customFieldId;
                CustomField customField = this.customFieldService.getCustomField(customId);
                Long customFieldId = MapUtil.getLong(issueCustomField, "customFieldId");
                CustomField customField = this.customFieldService.getCustomField(customFieldId);
                if(customField != null && customField.getCustomFieldType().toString().equals("SITE") && customField.getName().equals("도메인")) {
                    String useValue = issueCustomField.get("useValue").toString();
                    if(companyFields != null && companyFields.size() > 0) {
@@ -1482,14 +1487,16 @@
            issueVo = ConvertUtil.copyProperties(issue, IssueVo.class);
            User user = this.webAppUtil.getLoginUserObject();
            issueVo.setRelPageNumber(relPageable.getPageNumber());
            issueVo.setRelPageSize(relPageable.getPageSize());
            issueVo.setRelPage(relPageable.getPageNumber() * relPageable.getPageSize());
            issueVo.setDownPageNumber(downPageable.getPageNumber());
            issueVo.setDownPage(downPageable.getPageNumber() * downPageable.getPageSize());
            issueVo.setDownPageSize(downPageable.getPageSize());
            if (relPageable != null) {
                issueVo.setRelPageNumber(relPageable.getPageNumber());
                issueVo.setRelPageSize(relPageable.getPageSize());
                issueVo.setRelPage(relPageable.getPageNumber() * relPageable.getPageSize());
            }
            if (downPageable != null) {
                issueVo.setDownPageNumber(downPageable.getPageNumber());
                issueVo.setDownPage(downPageable.getPageNumber() * downPageable.getPageSize());
                issueVo.setDownPageSize(downPageable.getPageSize());
            }
            switch (issueCondition.getDeep()) {
                case "01": //  프로젝트, 이슈 유형, 이슈 상태,  우선순위, 중요도, 담당부서, 첨부파일, 사용자 정의 필드 정보를 셋팅한다.
@@ -1543,13 +1550,18 @@
    // 하위 이슈 정보를 셋팅한다
    private void setDownIssues(Issue issue, IssueVo issueVo) {
        //List<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId());
        int startPage = (int) Math.floor(issueVo.getDownPage()/issueVo.getDownPageSize());
        Pageable pageable = PageRequest.of(startPage, issueVo.getDownPageSize());
        Page<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId(), pageable);
        issueVo.setDownTotalPage(downIssues.getTotalPages());
        issueVo.setDownTotalCount(downIssues.getTotalElements());
        Page<Issue> downIssues = null;
        List<Issue> downIssueList = this.issueRepository.findByParentIssueId(issue.getId());
        if(downIssueList != null && downIssueList.size() > 0) {
            int startPage = (int) Math.floor(issueVo.getDownPage()/issueVo.getDownPageSize());
            Pageable pageable = PageRequest.of(startPage, issueVo.getDownPageSize());
            downIssues = this.issueRepository.findByParentIssueId(issue.getId(), pageable);
        }
        if(downIssues != null){
            issueVo.setDownTotalPage(downIssues.getTotalPages());
            issueVo.setDownTotalCount(downIssues.getTotalElements());
            List<IssueVo> resultList = new ArrayList<>();
            for(Issue downIssue : downIssues){
                IssueVo downIssueVo = ConvertUtil.copyProperties(downIssue, IssueVo.class);
@@ -1650,14 +1662,14 @@
    // 연관 이슈 정보를 셋팅한다
    private void setRelationIssue(Issue issue, IssueVo issueVo) {
        //Set<IssueRelation> issueRelations = issue.getIssueRelations();
        List<Map<String, Object>> results = this.issueRelationMapper.findByIssueId(issueVo);
        Long totalCount = this.issueRelationMapper.count(issueVo);
        int totalPage = (int) Math.ceil((totalCount - 1) / issueVo.getRelPageSize()) + 1;
        issueVo.setRelTotalPage(totalPage);
        issueVo.setRelTotalCount(totalCount);
        if (issue != null && issueVo != null && results.size() > 0) {
            int totalPage = (int) Math.ceil((totalCount - 1) / issueVo.getRelPageSize()) + 1;
            issueVo.setRelTotalPage(totalPage);
            issueVo.setRelTotalCount(totalCount);
            for (Map<String, Object> result : results) {
                IssueRelationVo issueRelationVo = ConvertUtil.convertMapToClass(result, IssueRelationVo.class);
                Issue relationIssue = this.findOne(issueRelationVo.getId());
@@ -2966,7 +2978,7 @@
            Workspace workspace = this.workspaceService.getWorkspace(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());  //  이슈를 넣으려는 업무 공간
            //  이슈의 주요 속성을 map 에 저장하여 엑셀 import 에서 지정한 대상(이슈 속성)을 빠르게 찾을 수 있게 한다.
            this.IssueAttributeMapToList(priorityMaps, severityMaps, departmentMaps, customFieldMaps, issueTypeCustomFieldMaps);
            this.IssueAttributeMapToList(issueForm, priorityMaps, severityMaps, departmentMaps, customFieldMaps, issueTypeCustomFieldMaps);
            //  0.237 - 0.230
            List<IssueForm> issueForms = Lists.newArrayList();
@@ -3047,7 +3059,9 @@
                issue.setIssueType(issueType);
                issue.setProject(project);
                issue.setIssueNumber(issueNumber);
                issue.setParentIssue(this.getIssue(saveIssueForm.getParentIssueId()));
                if (saveIssueForm.getParentIssueId() != null && saveIssueForm.getParentIssueId() > -1) {
                    issue.setParentIssue(this.getIssue(saveIssueForm.getParentIssueId()));
                }
                issue = this.issueRepository.saveAndFlush(issue);
@@ -3058,10 +3072,12 @@
                issueDepartment.setWorkspace(workspace);
                List<Long> departmentsIds = this.workflowDepartmentService.findFirstDepartmentIds(workflow);
                for (Long departmentId : departmentsIds) {
                    issueDepartment.setDepartment(this.departmentService.getDepartment(departmentId));
                if (departmentsIds != null && departmentsIds.size() > 0) {
                    for (Long departmentId : departmentsIds) {
                        issueDepartment.setDepartment(this.departmentService.getDepartment(departmentId));
                    }
                    issue.addIssueDepartment(issueDepartment);
                }
                issue.addIssueDepartment(issueDepartment);
                saveIssueForm.setIssueStatusId(issueStatus.getId());
            }
@@ -3084,8 +3100,6 @@
            //  이슈 사용자 정의 값 필드 벌크 등록
            this.bulkInsertIssueCustomFieldValue(issueForms, issueTypeCustomFieldMaps);
            //  3.628 - 3.445
            // 업체,ISP,호스팅 추가
            /*serviceStart.stop();
            log.debug("2차 저장 시간 : " + serviceStart.getTime());*/
@@ -3198,6 +3212,29 @@
                issueCustomField.put("registerId", this.webAppUtil.getLoginId());
                issueCustomFieldValueMaps.add(issueCustomField);
            }
            IssueForm partners = this.findCompanyField(issueForm); // 같은 도메인 업체 찾기
            Issue issue = this.findOne(issueForm.getId());
            if (partners.getIssueCompanyFields() != null && partners.getIssueCompanyFields().size() > 0) {
                for (Map<String, Object> company : partners.getIssueCompanyFields()) {
                    IssueCompany issueCompany = ConvertUtil.convertMapToClass(company, IssueCompany.class);
                    issueCompany.setIssue(issue);
                    this.issueCompanyRepository.saveAndFlush(issueCompany);
                }
            }
            if (partners.getIssueIspFields() != null && partners.getIssueIspFields().size() > 0) {
                for (Map<String, Object> isp : partners.getIssueIspFields()) {
                    IssueIsp issueIsp = ConvertUtil.convertMapToClass(isp, IssueIsp.class);
                    issueIsp.setIssue(issue);
                    this.issueIspRepository.saveAndFlush(issueIsp);
                }
            }
            if (partners.getIssueHostingFields() != null && partners.getIssueHostingFields().size() > 0) {
                for (Map<String, Object> hosting : partners.getIssueHostingFields()) {
                    IssueHosting issueHosting = ConvertUtil.convertMapToClass(hosting, IssueHosting.class);
                    issueHosting.setIssue(issue);
                    this.issueHostingRepository.saveAndFlush(issueHosting);
                }
            }
        }
        if (issueCustomFieldValueMaps.size() > 0) {
@@ -3206,8 +3243,16 @@
    }
    //  이슈의 주요 속성을 map 에 저장하여 엑셀 import 에서 지정한 대상(이슈 속성)을 빠르게 찾을 수 있게 한다.
    private void IssueAttributeMapToList(Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps,
    private void IssueAttributeMapToList(IssueForm issueForm, Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps,
                                         Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps,Map<String, Long> issueTypeCustomFieldMaps) {
        Project project = this.projectService.getProject(issueForm.getProjectId());
        for (IssueTypeCustomField issueTypeCustomField : project.getIssueTypeCustomFields()) {
            //  빠르게 찾기 위해 이슈 타입 아이디 + 사용자 정의 필드 아이디를 키로 한다.
            String makeKey = issueTypeCustomField.getIssueType().getId().toString() + issueTypeCustomField.getCustomField().getId().toString();
            issueTypeCustomFieldMaps.put(makeKey, issueTypeCustomField.getId());
        }
        //  우선순위를 바로 찾을 수 있게 준비
        List<Priority> priorities = this.priorityService.findByWorkspaceId();
@@ -3270,13 +3315,13 @@
                    break;*/
                case 4:
                    //  시작일을 IssueForm 에 저장한다.
                    if (cell != null) {
                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                        this.setIssueFormPeriod(cell, issueForm, true, rowIndex);
                    }
                    break;
                case 5:
                    //  종료일을 IssueForm 에 저장한다.
                    if (cell != null) {
                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                        this.setIssueFormPeriod(cell, issueForm, false, rowIndex);
                    }
                    break;
@@ -3392,7 +3437,7 @@
            //  값이 공백이면 중지
            String cellValue = CommonUtil.convertExcelStringToCell(cell);
            if (StringUtils.isEmpty(cellValue)) {
            if (StringUtils.isEmpty(cellValue) || !cell.toString().equals("null")) {
                return;
            }
@@ -3819,17 +3864,26 @@
    @Override
    public void findPartner(Map<String, Object> resJsonData, Map<String, Object> params) {
        Long issueTypeId = MapUtil.getLong(params, "issueTypeId");
        IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); // 이슈의 이슈유형 객체
        Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // 이슈유형별로 사용중인 업체/ISP/호스팅 값
        List<UsePartnerVo> usePartnerVos = Lists.newArrayList();
        Integer using = 0;
        if (issueTypeId != null) {
            IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); // 이슈의 이슈유형 객체
            using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // 이슈유형별로 사용중인 업체/ISP/호스팅 값
        } else {
            for (int partner : UsePartner.partners) {
                using += partner;
            }
        }
        for (Integer usePartner : UsePartner.partners) { //1(업체), 2(ISP), 4(호스팅)
            UsePartnerVo usePartnerVo = UsePartner.checkUsePartner(using, usePartner);
            if (usePartnerVo != null) {
                usePartnerVos.add(usePartnerVo);
            }
            resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos);
        }
        resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos);
    }
    @Override