From 98123c3ea5bb8fc53d1258046403801deb5b1584 Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 수, 01 12월 2021 13:09:02 +0900
Subject: [PATCH] 이슈 이메일 전송 백엔드

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  363 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 322 insertions(+), 41 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
index c6c5436..0005bb0 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -6,6 +6,7 @@
 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.domain.*;
 import kr.wisestone.owl.domain.enumType.CustomFieldType;
 import kr.wisestone.owl.domain.enumType.EmailType;
@@ -44,7 +45,6 @@
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.locks.Condition;
 
 @Service
 public class IssueServiceImpl extends AbstractServiceImpl<Issue, Long, JpaRepository<Issue, Long>> implements IssueService {
@@ -53,6 +53,9 @@
 
     @Autowired
     private IssueRepository issueRepository;
+
+    @Autowired
+    private IssueTableConfigService issueTableConfigService;
 
     @Autowired
     private ProjectService projectService;
@@ -91,6 +94,15 @@
     private IssueCustomFieldValueService issueCustomFieldValueService;
 
     @Autowired
+    private IssueCompanyService issueCompanyService;
+
+    @Autowired
+    private IssueIspService issueIspService;
+
+    @Autowired
+    private IssueHostingService issueHostingService;
+
+    @Autowired
     private IssueUserService issueUserService;
 
     @Autowired
@@ -104,6 +116,9 @@
 
     @Autowired
     private UserService userService;
+
+    @Autowired
+    private DepartmentService departmentService;
 
     @Autowired
     private IssueCommentService issueCommentService;
@@ -186,6 +201,8 @@
         this.verifyTitle(issueForm.getTitle());
         //  �궇吏� �쑀�슚�꽦 泥댄겕
         this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
+        //  �떞�떦 遺��꽌 �쑀�슚�꽦 泥댄겕
+        this.verifyIssueDepartment(project, issueForm);
 
         //  �씠�뒋 �긽�깭 �쑀�삎�씠 '��湲�' �씤 �씠�뒋 �긽�깭 媛��졇�삤湲�
         IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow());
@@ -197,22 +214,6 @@
         issue.setPriority(priority);
         issue.setSeverity(severity);
 
-        //  �뾽泥� �븘�뱶 �쑀�슚�꽦 泥댄겕
-        if(issueForm.getCompanyId() != null){
-            CompanyField companyField = this.companyFieldService.getCompany(issueForm.getCompanyId());
-            issue.setCompanyField(companyField);
-        }
-        //  ISP �븘�뱶 �쑀�슚�꽦 泥댄겕
-        if(issueForm.getIspId() != null) {
-            IspField ispField = this.ispFieldService.getIsp(issueForm.getIspId());
-            issue.setIspFieldId(ispField);
-        }
-        //  HOSTING �븘�뱶 �쑀�슚�꽦 泥댄겕
-        if (issueForm.getHostingId() != null){
-            HostingField hostingField = this.hostingFieldService.getHosting(issueForm.getHostingId());
-            issue.setHostingFieldId(hostingField);
-        }
-
         issue.setIssueNumber(this.issueNumberGeneratorService.generateIssueNumber(project));    //  媛� �봽濡쒖젥�듃�쓽 怨좎쑀 �씠�뒋 踰덊샇 �깮�꽦
 
         this.issueRepository.saveAndFlush(issue);
@@ -222,6 +223,12 @@
         //this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds());
         //  �떞�떦遺��꽌 吏��젙
         this.issueDepartmentService.modifyIssueDepartment(issue, project.getWorkspace(), issueForm.getDepartmentIds());
+        //  �뾽泥� �젙蹂� ���옣
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields());
+        //  ISP �젙蹂� ���옣
+        this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields());
+        //  HOSTING �젙蹂� ���옣
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields());
 
         //  multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎.
         List<Map<String, Object>> convertFileMaps = this.convertMultipartFileToFile(multipartFiles);
@@ -346,6 +353,9 @@
         issueMap.put("customFields", customFields);
         issueMap.put("description", issue.getDescription());
 
+        //�뾽泥�,ISP,HOSTING 異붽�
+
+
         StringBuilder attachedFileBuilder = new StringBuilder();
 
         List<AttachedFile> attachedFiles = this.attachedFileService.findByIssueId(issue.getId());
@@ -427,13 +437,13 @@
         List<Map<String, Object>> results = this.issueMapper.find(issueCondition);
 
         //  �뒠�떇 �쟾 - 0.8, 0.9, 0.9, 0.9, 0.9
-        StopWatch serviceStart = new StopWatch();
-        serviceStart.start();
+        /*StopWatch serviceStart = new StopWatch();
+        serviceStart.start();*/
         Long totalCount = this.issueMapper.count(issueCondition);
         //  �뒠�떇 �쟾 - 1.1, 1.1, 1.3, 1.2
 
-        serviceStart.stop();
-        log.debug("serviceENd1 : " + serviceStart.getTime());
+        /*serviceStart.stop();
+        log.debug("serviceENd1 : " + serviceStart.getTime());*/
 
         int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1;
         //  �씠�뒋 �븘�씠�뵒 珥덇린�솕
@@ -454,7 +464,7 @@
     @Override
     @Transactional(readOnly = true)
     public List<IssueVo> findChartIssue(Map<String, Object> resJsonData,
-                                   IssueCondition issueCondition, Pageable pageable) {
+                                        IssueCondition issueCondition, Pageable pageable) {
 
         //  寃��깋 議곌굔�쓣 留뚮뱺�떎
         if (!this.makeIssueSearchCondition(issueCondition,Lists.newArrayList("01", "02", "03"), pageable)) {
@@ -566,7 +576,7 @@
         this.setIssueCustomFieldValue(issueVos, issueCondition);
     }
 
-        //  寃��깋 議곌굔�쓣 留뚮뱺�떎
+    //  寃��깋 議곌굔�쓣 留뚮뱺�떎
     private boolean makeIssueSearchCondition(IssueCondition condition, List<String> projectStatues, Pageable pageable) {
         if (pageable != null) {
             condition.setPage(pageable.getPageNumber() * pageable.getPageSize());
@@ -799,6 +809,7 @@
                     this.setAttachedFiles(issue, issueVo);  //  泥⑤� �뙆�씪 �젙蹂� �뀑�똿
                     this.setIssueCustomFields(issue, issueVo);  //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿
                     this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+                    this.setDownIssues(issue, issueVo); //�븯�쐞 �씠�뒋 �꽭�똿
 
                     break;
 
@@ -812,6 +823,30 @@
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_DETAIL));
 
         resJsonData.put(Constants.RES_KEY_CONTENTS, issueVo);
+    }
+
+    // �븯�쐞 �씠�뒋 �젙蹂대�� �뀑�똿�븳�떎
+    private void setDownIssues(Issue issue, IssueVo issueVo) {
+        List<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId());
+        List<IssueVo> downIssueVos = ConvertUtil.convertObjectsToClasses(downIssues, IssueVo.class);
+        List<IssueVo> resultList = new ArrayList<>();
+        if(downIssues != null && downIssueVos.size()>0){
+            for(IssueVo downIssueVo : downIssueVos){
+                for(Issue downIssue : downIssues){
+                    downIssueVo.setTitle(downIssue.getTitle());
+                    downIssueVo.setIssueTypeVo(ConvertUtil.copyProperties(downIssue.getIssueType(), IssueTypeVo.class));
+                    downIssueVo.setPriorityVo(ConvertUtil.copyProperties(downIssue.getPriority(), PriorityVo.class));
+                    downIssueVo.setSeverityVo(ConvertUtil.copyProperties(downIssue.getSeverity(), SeverityVo.class));
+                    this.setRegister(downIssue, downIssueVo); // �벑濡앹옄
+                    this.setIssueDepartment(downIssue, downIssueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
+                    this.setIssueCustomFields(downIssue, downIssueVo);   // �궗�슜�옄�젙�쓽�븘�뱶 �젙蹂� �꽭�똿
+                }
+                resultList.add(downIssueVo);
+            }
+            issueVo.setIssueDownVos(resultList); //�봽濡좏듃�뿉�꽌 List�삎�깭濡� 諛쏆븘以섏꽌 由ъ뒪�듃 �삎�떇�쑝濡� 蹂대궡以�
+        }else{
+            issueVo.setIssueDownVos(null);
+        }
     }
 
     //  �씠�뒋 �긽�꽭 �젙蹂대�� �뀑�똿�븳�떎.
@@ -833,6 +868,34 @@
         this.setIssueComments(issue, issueVo);  //  �뙎湲� �젙蹂� �뀑�똿
         this.setIssueHistory(issue, issueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
         this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+        this.setDownIssues(issue, issueVo); //�븯�쐞 �씪媛� �꽭�똿
+
+        IssueType issueType = this.issueTypeService.getIssueType(issueVo.getIssueTypeVo().getId()); // �씠�뒋�쓽 �씠�뒋�쑀�삎 媛앹껜
+        Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // �씠�뒋�쑀�삎蹂꾨줈 �궗�슜以묒씤 �뾽泥�/ISP/�샇�뒪�똿 媛�
+
+        List<UsePartnerVo> usePartnerVos = Lists.newArrayList();
+        for (Integer usePartner : UsePartner.partners) { //1(�뾽泥�), 2(ISP), 4(�샇�뒪�똿)
+            UsePartnerVo usePartnerVo = UsePartner.checkUsePartner(using, usePartner);
+
+            if (usePartnerVo != null) {
+                usePartnerVos.add(usePartnerVo);
+                //useCompanyVo.setValues();
+            }
+            issueVo.setUsePartnerVos(usePartnerVos);
+        }
+
+        this.setIssueCompanyField(issue, issueVo);  //�뾽泥� �젙蹂� �꽭�똿
+        this.setIssueIspField(issue, issueVo);  //ISP �젙蹂� �꽭�똿
+        this.setIssueHostingField(issue, issueVo);  //HOSTING �젙蹂� �꽭�똿
+
+        this.setParentIssue(issue,issueVo); //�긽�쐞 �씠�뒋 �젙蹂� �꽭�똿
+    }
+
+    //  �긽�쐞�씪媛� �젙蹂� 異붽�
+    private void setParentIssue(Issue issue, IssueVo issueVo) {
+        if(issue.getParentIssue() != null){
+            issueVo.setParentIssueVo(ConvertUtil.copyProperties(issue.getParentIssue(), IssueVo.class));
+        }
     }
 
     //  �벑濡앹옄 �젙蹂� 異붽�
@@ -871,6 +934,12 @@
 
                 issueRelationVo.setIssueRelation(relIssueVo);
                 issueRelationVo.setTitle(relationIssue.getTitle());
+                issueRelationVo.setIssueTypeVo(ConvertUtil.copyProperties(relationIssue.getIssueType(), IssueTypeVo.class));
+                issueRelationVo.setPriorityVo(ConvertUtil.copyProperties(relationIssue.getPriority(), PriorityVo.class));
+                issueRelationVo.setSeverityVo(ConvertUtil.copyProperties(relationIssue.getSeverity(), SeverityVo.class));
+                this.setRegister(relationIssue, relIssueVo); // �벑濡앹옄
+                this.setIssueDepartment(relationIssue, relIssueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
+                this.setIssueCustomFields(relationIssue, relIssueVo);   // �궗�슜�옄�젙�쓽�븘�뱶 �젙蹂� �꽭�똿
                 issueVo.addIssueRelationVo(issueRelationVo);
             }
         } else {
@@ -920,7 +989,7 @@
 
         for (IssueDepartment issueDepartment : issue.getIssueDepartments()) {
             DepartmentVo departmentVo = ConvertUtil.copyProperties(issueDepartment.getDepartment(), DepartmentVo.class);
-            departmentVo.setByName(departmentVo.getByName());
+            departmentVo.setByName(departmentVo.getDepartmentName());
             departmentVos.add(departmentVo);
         }
         issueVo.setDepartmentVos(departmentVos);
@@ -1039,9 +1108,15 @@
         if (!StringUtils.isEmpty(detectIssueChange.toString())) {
             this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.MODIFY, detectIssueChange.toString());
         }
-
         //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_MODIFY));
+
+        //  �뾽泥� �젙蹂� ���옣
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields());
+        //  ISP �젙蹂� ���옣
+        this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields());
+        //  HOSTING �젙蹂� ���옣
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields());
 
         return issue;
     }
@@ -1116,7 +1191,7 @@
                 //  �뜲�씠�꽣 蹂댁젙 �옉�뾽 - �봽濡쒖젥�듃�뿉�꽌 �젣�쇅�맂 �궗�슜�옄�뒗 �떞�떦�옄�뿉�꽌 �젣�쇅 �맆 �닔 �엳�룄濡� 泥섎━
                 if (!includeProject) {
                     throw new OwlRuntimeException(
-                            this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_INCLUDE_USER));
+                            this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_INCLUDE_DEPARTMENT));
                 }
             }
             //  李몄뿬 �솗�씤�맂 遺��꽌濡� �떞�떦遺��꽌 蹂�寃�
@@ -1181,11 +1256,11 @@
         boolean hasPermission = false;
 
         //  �뾽臾� 怨듦컙 愿�由ъ옄�씪 寃쎌슦 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
-        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.WORKSPACE_MANAGER, issueVo, null);
+        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.WORKSPACE_MANAGER, issueVo, null, null);
         //  �봽濡쒖젥�듃 愿�由ъ옄�씪 寃쎌슦 �빐�떦 �봽濡쒖젥�듃�뿉 �벑濡앸맂 �씠�뒋�뒗 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
-        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.PROJECT_MANAGER, issueVo, null);
+        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.PROJECT_MANAGER, issueVo, null, null);
         //   �씠�뒋 �벑濡앹옄�씪 寃쎌슦 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
-        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.REGISTER, issueVo, null);
+        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.REGISTER, issueVo, null, null);
         //  �씠�뒋 �떞�떦�옄�씪 寃쎌슦 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎. => �떞�떦遺��꽌濡� �닔�젙 - 泥댄겕
         //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos);
         //  �떞�떦�옄媛� �뾾�쑝硫� 紐⑤뱺 �궗�슜�옄媛� �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
@@ -1194,7 +1269,7 @@
     }
 
     //  �씠�뒋 �닔�젙 沅뚰븳�쓣 �솗�씤�븳�떎.
-    private boolean checkIssueModifyPermission(Boolean hasPermission, String checkType, IssueVo issueVo, List<UserVo> issueUserVos) {
+    private boolean checkIssueModifyPermission(Boolean hasPermission, String checkType, IssueVo issueVo, List<UserVo> issueUserVos, List<DepartmentVo> issueDepartmentVos) {
         if (!hasPermission) {
             switch (checkType) {
                 case Issue.WORKSPACE_MANAGER:  //  �뾽臾� 怨듦컙 愿�由ъ옄
@@ -1218,15 +1293,28 @@
                         hasPermission = true;
                         break;
                     }
-
-                    //   �씠�뒋 �떞�떦�옄 �뿬遺� �솗�씤 => �떞�떦遺��꽌濡� �닔�젙 - 泥댄겕
-                    /*for (UserVo issueUserVo : issueUserVos) {
+                    //   �씠�뒋 �떞�떦�옄 �뿬遺� �솗�씤
+                    for (UserVo issueUserVo : issueUserVos) {
                         if (issueUserVo.getId().equals(this.webAppUtil.getLoginId())) {
                             hasPermission = true;
                             break;
                         }
-                    }*/
+                    }
+                    break;
 
+                case Issue.DEPARTMENT:
+                    //  �떞�떦遺��꽌媛� �뾾�쑝硫� 紐⑤뱺 �궗�슜�옄媛� �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
+                    if (issueDepartmentVos.size() < 1) {
+                        hasPermission = true;
+                        break;
+                    }
+                    //   �씠�뒋 �떞�떦遺��꽌 �뿬遺� �솗�씤
+                    /*for (DepartmentVo issueDepartmentVo : issueDepartmentVos) {
+                        if (issueDepartmentVo.getId().equals()) {
+                            hasPermission = true;
+                            break;
+                        }
+                    }*/
                     break;
             }
         }
@@ -1281,7 +1369,7 @@
     }
 
     //  �씠�뒋 �떞�떦�옄 蹂�寃�
-    /*@Override
+    @Override
     @Transactional
     public void modifyIssueUser(IssueForm issueForm) {
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
@@ -1314,7 +1402,7 @@
 
         //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_USER_CHANGE));
-    }*/
+    }
 
     @Override
     @Transactional
@@ -1329,7 +1417,7 @@
         issue.setProject(this.projectService.getProject(issueForm.getProjectId()));
 
         //  蹂�寃� �씠�젰 �젙蹂� 異붿텧
-        this.issueHistoryService.detectIssueManager(issue, issueForm, detectIssueChange);
+        this.issueHistoryService.detectIssueDepartment(issue, issueForm, detectIssueChange);
 
         //this.issueUserService.modifyIssueUser(issue, issue.getProject().getWorkspace(), issueForm.getUserIds());
         this.issueDepartmentService.modifyIssueDepartment(issue, issue.getProject().getWorkspace(), issueForm.getDepartmentIds());
@@ -1519,7 +1607,7 @@
         excelInfo.addAttrInfos(new ExportExcelAttrVo("title", this.messageAccessor.message("common.issueTitle"), 40, ExportExcelAttrVo.ALIGN_LEFT)); // �씠�뒋 �젣紐�
         excelInfo.addAttrInfos(new ExportExcelAttrVo("description", this.messageAccessor.message("common.content"), 60, ExportExcelAttrVo.ALIGN_LEFT)); // �궡�슜
         excelInfo.addAttrInfos(new ExportExcelAttrVo("issueTypeName", this.messageAccessor.message("common.issueType"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �씠�뒋 ���엯
-        excelInfo.addAttrInfos(new ExportExcelAttrVo("department", this.messageAccessor.message("common.department"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦遺��꽌
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("departments", this.messageAccessor.message("common.department"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦遺��꽌
         excelInfo.addAttrInfos(new ExportExcelAttrVo("priorityName", this.messageAccessor.message("common.priority"), 6, ExportExcelAttrVo.ALIGN_CENTER)); // �슦�꽑�닚�쐞
         excelInfo.addAttrInfos(new ExportExcelAttrVo("severityName", this.messageAccessor.message("common.importance"), 6, ExportExcelAttrVo.ALIGN_CENTER)); // 以묒슂�룄
         excelInfo.addAttrInfos(new ExportExcelAttrVo("register", this.messageAccessor.message("common.register"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �벑濡앹옄
@@ -1597,6 +1685,46 @@
         }
     }
 
+    //  �뾽泥� �젙蹂� 異붽�
+    private void setIssueCompanyField(Issue issue, IssueVo issueVo) {
+        List<IssueCompanyVo> issueCompanyVos = Lists.newArrayList();
+
+        for(IssueCompany issueCompany : issue.getIssueCompanies()){
+            IssueCompanyVo issueCompanyVo = ConvertUtil.copyProperties(issueCompany, IssueCompanyVo.class);
+            issueCompanyVo.setId(issueCompany.getId());
+            CompanyField companyField = issueCompany.getCompanyField();
+            if (companyField != null) {
+                issueCompanyVo.setCompanyId(issueCompany.getCompanyField().getId());
+            }
+            issueCompanyVos.add(issueCompanyVo);
+        }
+        issueVo.setIssueCompanyVos(issueCompanyVos);
+    }
+
+    //  Isp �젙蹂� 異붽�
+    private void setIssueIspField(Issue issue, IssueVo issueVo) {
+        List<IssueIspVo> issueIspVos = Lists.newArrayList();
+
+        for(IssueIsp issueIsp : issue.getIssueIspFields()){
+            IssueIspVo issueIspVo = ConvertUtil.copyProperties(issueIsp, IssueIspVo.class);
+            issueIspVo.setId(issueIsp.getId());
+            issueIspVos.add(issueIspVo);
+        }
+        issueVo.setIssueIspVos(issueIspVos);
+    }
+
+    // Hosting �젙蹂� 異붽�
+    private void setIssueHostingField(Issue issue, IssueVo issueVo) {
+        List<IssueHostingVo> issueHostingVos = Lists.newArrayList();
+
+        for(IssueHosting issueHosting : issue.getIssueHostingFields()){
+            IssueHostingVo issueHostingVo = ConvertUtil.copyProperties(issueHosting, IssueHostingVo.class);
+            issueHostingVo.setId(issueHosting.getId());
+            issueHostingVos.add(issueHostingVo);
+        }
+        issueVo.setIssueHostingVos(issueHostingVos);
+    }
+
     //  �뿰愿��씪媛� �젙蹂� 異붽�
     private void setRelationIssue(IssueVo issueVo, Long issueId) {
         List<IssueVo> relationIssues = this.issueRelationService.findRelationIssue(issueId);
@@ -1624,6 +1752,7 @@
                 result.put("description", description);
                 result.put("issueTypeName", issueVo.getIssueTypeName());
                 result.put("assignees", CommonUtil.convertUserVosToString(issueVo.getUserVos()));
+                result.put("departments", CommonUtil.convertDepartmentVosToString(issueVo.getDepartmentVos()));
                 result.put("priorityName", issueVo.getPriorityName());
                 result.put("severityName", issueVo.getSeverityName());
 
@@ -1650,6 +1779,8 @@
                     }
                 }
 
+                //�뾽泥�, ISP, �샇�뒪�똿 異붽�
+
                 results.add(result);
             } catch (Exception e) {
                 log.error("�뿊�� �떎�슫濡쒕뱶 �삤瑜� 諛쒖깮");
@@ -1670,6 +1801,14 @@
             issueForm.setId(issueId);
             //  �씠�뒋 �긽�깭 蹂�寃�
             this.modifyIssueStatus(issueForm);
+        }
+
+        // �떞�떦 遺��꽌 �닔�젙
+        if (issueForm.getDepartmentIds().size() > 0) {
+            Issue issue = this.getIssue(issueForm.getId());
+            Project project = this.projectService.getProject(issueForm.getProjectId());
+
+            this.issueDepartmentService.modifyIssueDepartment(issue, project.getWorkspace(), issueForm.getDepartmentIds());
         }
     }
 
@@ -1735,13 +1874,14 @@
             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, CustomField> customFieldMaps = new HashMap<>();
             Map<String, IssueStatus> issueStatusReadyMaps = new HashMap<>();   //  �긽�깭 �냽�꽦 '��湲�'�씤 �씠�뒋 �긽�깭
             Map<Long, Long> issueNumberMaps = new HashMap<>();  //  �씠�뒋 踰덊샇 紐⑥쓬
             Map<String, Long> issueTypeCustomFieldMaps = new HashMap<>(); //  �씠�뒋 ���엯 + �궗�슜�옄 �젙�쓽 �븘�뱶 �뿰寃� �젙蹂�
             Workspace workspace = this.workspaceService.getWorkspace(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());  //  �씠�뒋瑜� �꽔�쑝�젮�뒗 �뾽臾� 怨듦컙
             //  �씠�뒋�쓽 二쇱슂 �냽�꽦�쓣 map �뿉 ���옣�븯�뿬 �뿊�� import �뿉�꽌 吏��젙�븳 ���긽(�씠�뒋 �냽�꽦)�쓣 鍮좊Ⅴ寃� 李얠쓣 �닔 �엳寃� �븳�떎.
-            this.IssueAttributeMapToList(projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, customFieldMaps, issueNumberMaps, issueTypeCustomFieldMaps, issueStatusReadyMaps);
+            this.IssueAttributeMapToList(projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, departmentMaps, customFieldMaps, issueNumberMaps, issueTypeCustomFieldMaps, issueStatusReadyMaps);
             //  0.237 - 0.230
 
             List<IssueForm> issueForms = Lists.newArrayList();
@@ -1813,6 +1953,8 @@
             //  �씠�뒋 �궗�슜�옄 �젙�쓽 媛� �븘�뱶 踰뚰겕 �벑濡�
             this.bulkInsertIssueCustomFieldValue(issueForms, issueTypeCustomFieldMaps);
             //  3.628 - 3.445
+
+            // �뾽泥�,ISP,�샇�뒪�똿 異붽�
 
             /*serviceStart.stop();
             log.debug("2李� ���옣 �떆媛� : " + serviceStart.getTime());*/
@@ -1892,6 +2034,7 @@
             Map<String, Long> issueRiskMap = new HashMap<>();
             issueRiskMap.put("issueId", issueForm.getId());
             issueRiskMap.put("changeAssigneeCount", 0L);
+            issueRiskMap.put("changeDepartmentCount", 0L);
             issueRiskMap.put("changeIssueStatusCount", 0L);
             issueRiskMap.put("workspaceId", workspace.getId());
             issueRiskMap.put("issueStatusIds", issueForm.getIssueStatusId());
@@ -1932,7 +2075,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, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, Map<String, Long> issueTypeCustomFieldMaps, Map<String, IssueStatus> issueStatusReadyMaps) {
+                                         Map<String, Object> userMaps, Map<String, Object> 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();
@@ -1958,6 +2101,14 @@
             }
 
             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"));
+            }
         }
 
         //  �씠�뒋 �쑀�삎�쓣 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮�
@@ -2243,6 +2394,12 @@
 
             switch (customField.getCustomFieldType()) {
                 case INPUT:
+                case NUMBER:
+                case DATETIME:
+                case IP_ADDRESS:
+                case EMAIL:
+                case SITE:
+                case TEL:
                     if (cellValue.length() > 100) {
                         throw new OwlRuntimeException(
                                 this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT));
@@ -2323,6 +2480,9 @@
         if (issueForm.getSendEmails().size() < 1) {
             throw new OwlRuntimeException(
                     this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SEND_USER));
+        }else if (issueForm.getTemplate() != null){
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SELECT_TEMPLATE));
         }
 
         Issue issue = this.getIssue(issueForm.getId());
@@ -2344,8 +2504,15 @@
 
         //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_ANOTHER_USER_SEND_EMAIL));
+        //this.systemEmailService.directEmail(issueForm.getSendEmails().toArray(new String[issueForm.getSendEmails().size()]), EmailType.ISSUE_SEND, issueMap, null);
 
-        this.systemEmailService.directEmail(issueForm.getSendEmails().toArray(new String[issueForm.getSendEmails().size()]), EmailType.ISSUE_SEND, issueMap, null);
+        if(issueForm.getTemplate().equals("SEND1")){
+            this.systemEmailService.directEmail(issueForm.getSendEmails().toArray(new String[issueForm.getSendEmails().size()]), EmailType.ISSUE_SEND_1, issueMap, null);
+        }else if(issueForm.getTemplate().equals("SEND2")){
+            this.systemEmailService.directEmail(issueForm.getSendEmails().toArray(new String[issueForm.getSendEmails().size()]), EmailType.ISSUE_SEND_2, issueMap, null);
+        }else if(issueForm.getTemplate().equals("SEND3")){
+            this.systemEmailService.directEmail(issueForm.getSendEmails().toArray(new String[issueForm.getSendEmails().size()]), EmailType.ISSUE_SEND_3, issueMap, null);
+        }
     }
 
     //  �삁�빟 諛쒖깮 �씠�뒋瑜� �떎�뻾�븳�떎
@@ -2353,6 +2520,7 @@
     @Transactional
     public void reservationIssue() {
         List<IssueReservation> issueReservations = this.issueReservationService.findByIssueReservationTypeNotNull();
+
 
         Calendar calendar = Calendar.getInstance();
         int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
@@ -2512,4 +2680,117 @@
 
         return tasks;
     }
+
+    @Transactional
+    @Override
+    public void modifyParentIssue(IssueForm issueDownForm) {
+        Issue issue = this.getIssue(issueDownForm.getId()); //�븯�쐞 �씠�뒋
+        Long newParentIssueId = issueDownForm.getParentIssueId(); //蹂�寃쏀븷 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋
+
+        StringBuilder sb = new StringBuilder();
+
+        Issue parentIssue = issue.getParentIssue(); //蹂�寃� �쟾 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋
+        if(parentIssue != null){ //蹂�寃� �쟾 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋媛� 議댁옱 �븷 寃쎌슦
+            this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb);
+            this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString());
+        }
+
+        if (newParentIssueId != null) { // 異붽� �븷 寃쎌슦
+            parentIssue = this.getIssue(newParentIssueId); //�긽�쐞�씠�뒋(myIssue)
+            issue.setParentIssue(parentIssue); //myIssue瑜� �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋濡� set
+            this.issueHistoryService.detectDownIssues(IssueHistoryType.ADD, issue, sb); //issue = �븯�쐞�씠�뒋
+        } else  {
+            // �궘�젣 �븷 寃쎌슦
+            this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb);
+            issue.setParentIssue(null);
+        }
+        this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); //parentIssue = myIssue(湲곕줉�� �쁽�옱 �긽�꽭�럹�씠吏��뿉 �빐�빞�븯�땲源�)
+        this.issueRepository.saveAndFlush(issue);
+
+    }
+
+    @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();
+        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);
+        }
+    }
+
+    /*@Override
+    @Transactional
+    public void findMailTargetAll(Map<String, Object> resJsonData, IssueCondition condition, Pageable pageable) {
+        IssueVo issueVo = new IssueVo();
+        //Long issueId = MapUtil.getLong(params, "issueId");
+        Long issueId = condition.getId();
+
+        List<String> emailList = Lists.newArrayList();
+
+        if(issueId != null){
+            Issue issue = this.getIssue(issueId);
+            issueVo = ConvertUtil.copyProperties(issue, IssueVo.class);
+            this.setIssueCompanyField(issue, issueVo);  //�뾽泥� �젙蹂� �꽭�똿
+            this.setIssueIspField(issue, issueVo);  //ISP �젙蹂� �꽭�똿
+            this.setIssueHostingField(issue, issueVo);  //HOSTING �젙蹂� �꽭�똿
+            for(IssueCompanyVo issueCompanyVo : issueVo.getIssueCompanyVos()) {
+                emailList.add(issueCompanyVo.getEmail());
+            }
+            for(IssueIspVo issueIspVo : issueVo.getIssueIspVos()) {
+                emailList.add(issueIspVo.getEmail());
+            }
+            for(IssueHostingVo issueHostingVo : issueVo.getIssueHostingVos()) {
+                emailList.add(issueHostingVo.getEmail());
+            }
+
+        }
+
+        Long totalCount = this.issueMapper.count(condition);
+        int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1;
+
+        condition.setPage(pageable.getPageNumber() * pageable.getPageSize());
+        condition.setPageSize(pageable.getPageSize());
+        //resJsonData.put(Constants.RES_KEY_CONTENTS, emailList);
+        resJsonData.put(Constants.RES_KEY_CONTENTS, emailList);
+        resJsonData.put(Constants.REQ_KEY_PAGE_VO, new ResPage(pageable.getPageNumber(), pageable.getPageSize(),
+                totalPage, totalCount));
+    }*/
+
+    /*@Override
+    @Transactional
+    public void findMailTargetCompany(Map<String, Object> resJsonData, Map<String, Object> params) {
+        IssueVo issueVo = new IssueVo();
+        Long issueId = MapUtil.getLong(params, "issueId");
+
+        List<String> emailList = Lists.newArrayList();
+
+        if(issueId != null){
+            Issue issue = this.getIssue(issueId);
+            issueVo = ConvertUtil.copyProperties(issue, IssueVo.class);
+            this.setIssueCompanyField(issue, issueVo);  //�뾽泥� �젙蹂� �꽭�똿
+            for(IssueCompanyVo issueCompanyVo : issueVo.getIssueCompanyVos()) {
+                emailList.add(issueCompanyVo.getEmail());
+            }
+        }
+        resJsonData.put(Constants.RES_KEY_CONTENTS, emailList);
+    }
+
+    @Override
+    @Transactional
+    public void findMailTargetIsp(Map<String, Object> resJsonData, Map<String, Object> params) {
+
+    }
+
+    @Override
+    @Transactional
+    public void findMailTargetHosting(Map<String, Object> resJsonData, Map<String, Object> params) {
+
+    }*/
 }

--
Gitblit v1.8.0