OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-12-08 7b4b71ee33c7a42383d3e6a69885d521fd7b6688
src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -17,8 +17,10 @@
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;
@@ -154,6 +156,9 @@
    private IssueRelationService issueRelationService;
    @Autowired
    private IssueRelationRepository issueRelationRepository;
    @Autowired
    private ExcelView excelView;
    @Autowired
@@ -167,6 +172,9 @@
    @Autowired
    private UserDepartmentRepository userDepartmentRepository;
    @Autowired
    private WorkflowDepartmentRepository workflowDepartmentRepository;
    @Override
    protected JpaRepository<Issue, Long> getRepository() {
@@ -384,7 +392,7 @@
        //  날짜 유효성 체크
        this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
        //  담당 부서 유효성 체크
        this.verifyIssueDepartment(project, issueForm);
        //this.verifyIssueDepartment(project, issueForm);
        //  이슈 상태 유형이 '대기' 인 이슈 상태 가져오기
        IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow());
@@ -470,7 +478,7 @@
        //  날짜 유효성 체크
        this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
        //  담당 부서 유효성 체크
        this.verifyIssueDepartment(project, issueForm);
        //this.verifyIssueDepartment(project, issueForm);
        //  이슈 상태 유형이 '대기' 인 이슈 상태 가져오기
        IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow());
@@ -688,11 +696,28 @@
        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)) {
@@ -734,6 +759,7 @@
            totalCount = this.issueMapper.countByDepartment(issueCondition);
        }
        //  튜닝 전 - 0.8, 0.9, 0.9, 0.9, 0.9
        /*StopWatch serviceStart = new StopWatch();
        serviceStart.start();*/
@@ -749,6 +775,7 @@
        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(),
@@ -1486,13 +1513,21 @@
    }
    // 하위 이슈가 모두 종료 처리 되었을 경우 상위이슈도 완료 처리
    private void setParentIssueComplete(Issue parentIssue) {
        if (parentIssue != null) {
            this.issueMapper.findNotCompleteByParentIssueId(parentIssue.getId());
        }
    }
    // 이슈를 수정한다(api용)
    @Override
    @Transactional
    public List<Issue> modifyIssue(IssueApiForm issueApiForm, List<MultipartFile> files) {
        User user = this.convertToUser(issueApiForm.getToken());
        IssueForm issueForm = this.convertToIssueForm(issueApiForm, user);
        List<IssueVo> issueVos = this.findIssue(issueApiForm);
        if (issueVos != null && issueVos.size() > 0) {
@@ -1504,7 +1539,13 @@
                } else {
                    issueForm.setId(issueVo.getId());
                }
                issue.add(this.modifyIssueForApi(user, issueForm, files));
                Issue modifyIssue = this.modifyIssueForApi(user, issueForm, files);
                Issue parentIssue = modifyIssue.getParentIssue();
                if (parentIssue != null) {
                    List<Map<String, Object>> results = this.issueMapper.findNotCompleteByParentIssueId(parentIssue.getId());
                }
                issue.add(modifyIssue);
            }
            return issue;
        } else {
@@ -1549,7 +1590,7 @@
        //  담당자 유효성 체크
        //this.verifyIssueAssignee(project, issueForm);
        //  담당부서 유효성 체크
        this.verifyIssueDepartment(project, issueForm);
        //this.verifyIssueDepartment(project, issueForm);
        CheckIssueData checkIssueData = new CheckIssueData();
        checkIssueData.setIssue(issue);
@@ -2051,6 +2092,17 @@
            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);
        //  이슈 삭제