From 4cef9a63afe347bcc007f2f18c21da69b346da64 Mon Sep 17 00:00:00 2001
From: wyu <kknd09321@nate.com>
Date: 금, 19 11월 2021 14:41:30 +0900
Subject: [PATCH] 이슈 상세 수정 -부서 [프론트]

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  179 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 152 insertions(+), 27 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 c692a5e..5ab920c 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -44,7 +44,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 {
@@ -70,6 +69,15 @@
     private SeverityService severityService;
 
     @Autowired
+    private CompanyFieldService companyFieldService;
+
+    @Autowired
+    private IspFieldService ispFieldService;
+
+    @Autowired
+    private HostingFieldService hostingFieldService;
+
+    @Autowired
     private CommonConfiguration configuration;
 
     @Autowired
@@ -80,6 +88,15 @@
 
     @Autowired
     private IssueCustomFieldValueService issueCustomFieldValueService;
+
+    @Autowired
+    private IssueCompanyService issueCompanyService;
+
+    @Autowired
+    private IssueIspService issueIspService;
+
+    @Autowired
+    private IssueHostingService issueHostingService;
 
     @Autowired
     private IssueUserService issueUserService;
@@ -104,6 +121,9 @@
 
     @Autowired
     private ProjectRoleUserService projectRoleUserService;
+
+    @Autowired
+    private ProjectRoleDepartmentService projectRoleDepartmentService;
 
     @Autowired
     private IssueRiskService issueRiskService;
@@ -184,6 +204,7 @@
         issue.setIssueType(issueType);
         issue.setPriority(priority);
         issue.setSeverity(severity);
+
         issue.setIssueNumber(this.issueNumberGeneratorService.generateIssueNumber(project));    //  媛� �봽濡쒖젥�듃�쓽 怨좎쑀 �씠�뒋 踰덊샇 �깮�꽦
 
         this.issueRepository.saveAndFlush(issue);
@@ -212,6 +233,12 @@
         this.reservationIssueEmail(issue.getId(), EmailType.ISSUE_ADD);
         //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_ADD));
+        //  �뾽泥� �젙蹂� ���옣
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields());
+        //  ISP �젙蹂� ���옣
+        this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields());
+        //  HOSTING �젙蹂� ���옣
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields());
 
         return issue;
     }
@@ -247,18 +274,25 @@
         issueMap.put("issueTypeName", issue.getIssueType().getName());
         issueMap.put("issueStatusName", issue.getIssueStatus().getName());
 
-        //  �떞�떦遺��꽌
+        //  �떞�떦�옄
         StringBuilder assigneeBuilder = new StringBuilder();
-        for (IssueDepartment issueDepartment : issue.getIssueDepartments()) {
-            //assigneeBuilder.append(issueUser.getUser().getName());
-            assigneeBuilder.append(issueDepartment.getDepartment().getDepartmentName());
-            /*assigneeBuilder.append("(");
+        for (IssueUser issueUser : issue.getIssueUsers()) {
+            assigneeBuilder.append(issueUser.getUser().getName());
+            assigneeBuilder.append("(");
             assigneeBuilder.append(CommonUtil.decryptAES128(issueUser.getUser().getAccount()));
-            assigneeBuilder.append(")");*/
+            assigneeBuilder.append(")");
             assigneeBuilder.append("\n");
         }
-
         issueMap.put("assignees", assigneeBuilder.toString());
+
+        //  �떞�떦遺��꽌
+        StringBuilder departsBuilder = new StringBuilder();
+        for (IssueDepartment issueDepartment : issue.getIssueDepartments()) {
+            departsBuilder.append(issueDepartment.getDepartment().getDepartmentName());
+            departsBuilder.append("\n");
+        }
+        issueMap.put("departsBuilder", departsBuilder.toString());
+
         //  湲곌컙
         if (!StringUtils.isEmpty(issue.getStartDate())) {
             issueMap.put("period", issue.getStartDate() + " ~ " + issue.getCompleteDate());
@@ -309,6 +343,9 @@
 
         issueMap.put("customFields", customFields);
         issueMap.put("description", issue.getDescription());
+
+        //�뾽泥�,ISP,HOSTING 異붽�
+
 
         StringBuilder attachedFileBuilder = new StringBuilder();
 
@@ -418,7 +455,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)) {
@@ -528,9 +565,16 @@
 
         //  �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂� 異붽�
         this.setIssueCustomFieldValue(issueVos, issueCondition);
+        //  �뾽泥� �젙蹂� 異붽�
+        //this.setIssueCompanyField(issueVos, issueCondition);
+        //  ISP �젙蹂� 異붽�
+        //this.setIssueIspField(issueVos, issueCondition);
+        //  HOSTING �젙蹂� 異붽�
+        //this.setIssueHostingField(issueVos, issueCondition);
+
     }
 
-        //  寃��깋 議곌굔�쓣 留뚮뱺�떎
+    //  寃��깋 議곌굔�쓣 留뚮뱺�떎
     private boolean makeIssueSearchCondition(IssueCondition condition, List<String> projectStatues, Pageable pageable) {
         if (pageable != null) {
             condition.setPage(pageable.getPageNumber() * pageable.getPageSize());
@@ -763,6 +807,8 @@
                     this.setAttachedFiles(issue, issueVo);  //  泥⑤� �뙆�씪 �젙蹂� �뀑�똿
                     this.setIssueCustomFields(issue, issueVo);  //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿
                     this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+                    this.setDownIssues(issue, issueVo);
+
                     break;
 
                 case "02": //  �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭,  �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂�, �뙎湲�, 湲곕줉�쓣 �뀑�똿�븳�떎.
@@ -775,6 +821,13 @@
         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> issueVos = ConvertUtil.convertObjectsToClasses(downIssues, IssueVo.class);
+        issueVo.setIssueDownVos(issueVos);
     }
 
     //  �씠�뒋 �긽�꽭 �젙蹂대�� �뀑�똿�븳�떎.
@@ -796,6 +849,10 @@
         this.setIssueComments(issue, issueVo);  //  �뙎湲� �젙蹂� �뀑�똿
         this.setIssueHistory(issue, issueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
         this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+        this.setDownIssues(issue, issueVo);
+        this.setIssueCompanyField(issue, issueVo);  //�뾽泥� �젙蹂� �꽭�똿
+        this.setIssueIspField(issue, issueVo);  //ISP �젙蹂� �꽭�똿
+        this.setIssueHostingField(issue, issueVo);  //HOSTING �젙蹂� �꽭�똿
     }
 
     //  �벑濡앹옄 �젙蹂� 異붽�
@@ -883,7 +940,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);
@@ -934,7 +991,7 @@
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
         this.workspaceService.checkUseWorkspace();
         //  �씠�뒋 �닔�젙 沅뚰븳 泥댄겕
-        //this.verifyIssueModifyPermission(issueForm.getId());
+        this.verifyIssueModifyPermission(issueForm.getId());
         //  �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕
         Project project = this.projectService.getProject(issueForm.getProjectId());
         //  �씠�뒋 �긽�깭 �쑀�슚�꽦 泥댄겕
@@ -950,8 +1007,10 @@
         //  �궇吏� �쑀�슚�꽦 泥댄겕
         this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
 
-        //  �떞�떦�옄 �쑀�슚�꽦 泥댄겕 => �떞�떦遺��꽌濡� 蹂�寃�
+        //  �떞�떦�옄 �쑀�슚�꽦 泥댄겕
         //this.verifyIssueAssignee(project, issueForm);
+        //  �떞�떦遺��꽌 �쑀�슚�꽦 泥댄겕
+        this.verifyIssueDepartment(project, issueForm);
 
         Issue issue = this.getIssue(issueForm.getId());
 
@@ -1000,9 +1059,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;
     }
@@ -1057,35 +1122,35 @@
     }
 
     //  �씠�뒋 �떞�떦遺��꽌濡� 吏��젙�맆 遺��꽌媛� �빐�떦 �봽濡쒖젥�듃�뿉 李몄뿬 �븯怨� �엳�뒗 遺��꽌�씤吏� �솗�씤
-    private void verifyIssueAssignee(Project project, IssueForm issueForm) {
+    private void verifyIssueDepartment(Project project, IssueForm issueForm) {
         if (issueForm.getDepartmentIds().size() > 0) {
             List<Long> trustDepartmentIds = Lists.newArrayList(); //  李몄뿬 �솗�씤�맂 遺��꽌
 
             for (Long departmentId : issueForm.getDepartmentIds()) {
                 boolean includeProject = false;
 
-                /*for (ProjectRole projectRole : project.getProjectRoles()) {
-                    ProjectRoleUser projectRoleUser = this.projectRoleUserService.findByProjectRoleIdAndDepartmentId(projectRole.getId(), departmentId);
+                for (ProjectRole projectRole : project.getProjectRoles()) {
+                    ProjectRoleDepartment projectRoleDepartment = this.projectRoleDepartmentService.findByProjectRoleIdAndDepartmentId(projectRole.getId(), departmentId);
 
-                    if (projectRoleUser != null) {
+                    if (projectRoleDepartment != null) {
                         includeProject = true;
                         trustDepartmentIds.add(departmentId);
                         break;
                     }
-                }*/
+                }
 
                 //  �뜲�씠�꽣 蹂댁젙 �옉�뾽 - �봽濡쒖젥�듃�뿉�꽌 �젣�쇅�맂 �궗�슜�옄�뒗 �떞�떦�옄�뿉�꽌 �젣�쇅 �맆 �닔 �엳�룄濡� 泥섎━
-                /*if (!includeProject) {
+                if (!includeProject) {
                     throw new OwlRuntimeException(
-                            this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_INCLUDE_USER));
-                }*/
+                            this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_INCLUDE_DEPARTMENT));
+                }
             }
             //  李몄뿬 �솗�씤�맂 遺��꽌濡� �떞�떦遺��꽌 蹂�寃�
             issueForm.setDepartmentIds(trustDepartmentIds);
         }
     }
 
-    /*//  �씠�뒋 �떞�떦�옄濡� 吏��젙�맆 �궗�슜�옄媛� �빐�떦 �봽濡쒖젥�듃�뿉 李몄뿬 �븯怨� �엳�뒗 �궗�슜�옄 �씤吏� �솗�씤
+    //  �씠�뒋 �떞�떦�옄濡� 吏��젙�맆 �궗�슜�옄媛� �빐�떦 �봽濡쒖젥�듃�뿉 李몄뿬 �븯怨� �엳�뒗 �궗�슜�옄 �씤吏� �솗�씤
     private void verifyIssueAssignee(Project project, IssueForm issueForm) {
         if (issueForm.getUserIds().size() > 0) {
             List<Long> trustUserIds = Lists.newArrayList(); //  李몄뿬 �솗�씤�맂 �궗�슜�옄
@@ -1104,15 +1169,15 @@
                 }
 
                 //  �뜲�씠�꽣 蹂댁젙 �옉�뾽 - �봽濡쒖젥�듃�뿉�꽌 �젣�쇅�맂 �궗�슜�옄�뒗 �떞�떦�옄�뿉�꽌 �젣�쇅 �맆 �닔 �엳�룄濡� 泥섎━
-                *//*if (!includeProject) {
+                if (!includeProject) {
                     throw new OwlRuntimeException(
                             this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_INCLUDE_USER));
-                }*//*
+                }
             }
             //  李몄뿬 �솗�씤�맂 �궗�슜�옄濡� �떞�떦�옄 蹂�寃�
             issueForm.setUserIds(trustUserIds);
         }
-    }*/
+    }
 
     //  �씠�뒋 �닔�젙 沅뚰븳 泥댄겕
     private void verifyIssueModifyPermission(Long issueId) {
@@ -1480,7 +1545,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)); // �벑濡앹옄
@@ -1558,6 +1623,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);
@@ -1585,6 +1690,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());
 
@@ -1610,6 +1716,8 @@
                         result.put("customField_" + issueCustomFieldValueVo.getCustomFieldVo().getId().toString(), useValue + ", " + issueCustomFieldValueVo.getUseValue());
                     }
                 }
+
+                //�뾽泥�, ISP, �샇�뒪�똿 異붽�
 
                 results.add(result);
             } catch (Exception e) {
@@ -1774,6 +1882,8 @@
             //  �씠�뒋 �궗�슜�옄 �젙�쓽 媛� �븘�뱶 踰뚰겕 �벑濡�
             this.bulkInsertIssueCustomFieldValue(issueForms, issueTypeCustomFieldMaps);
             //  3.628 - 3.445
+
+            // �뾽泥�,ISP,�샇�뒪�똿 異붽�
 
             /*serviceStart.stop();
             log.debug("2李� ���옣 �떆媛� : " + serviceStart.getTime());*/
@@ -2473,4 +2583,19 @@
 
         return tasks;
     }
+
+    @Transactional
+    @Override
+    public void modifyParentIssue(IssueForm issueForm) {
+        Issue issue = this.issueRepository.getOne(issueForm.getId());
+        Long parentIssueId = issueForm.getParentIssueId();
+        if (parentIssueId != null) {
+            Issue parentIssue = this.issueRepository.getOne(parentIssueId);
+            issue.setParentIssue(parentIssue);
+        } else  {
+            issue.setParentIssue(null);
+        }
+
+        this.issueRepository.saveAndFlush(issue);
+    }
 }

--
Gitblit v1.8.0