From 9bccd99ac672bba8427aa3e28204d6dcf9fa3460 Mon Sep 17 00:00:00 2001
From: wyu <kknd09321@nate.com>
Date: 수, 17 11월 2021 18:08:14 +0900
Subject: [PATCH] 이슈 수정 진행[프론트]

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  112 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 91 insertions(+), 21 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..1fdcfc3 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -70,6 +70,15 @@
     private SeverityService severityService;
 
     @Autowired
+    private CompanyFieldService companyFieldService;
+
+    @Autowired
+    private IspFieldService ispFieldService;
+
+    @Autowired
+    private HostingFieldService hostingFieldService;
+
+    @Autowired
     private CommonConfiguration configuration;
 
     @Autowired
@@ -104,6 +113,9 @@
 
     @Autowired
     private ProjectRoleUserService projectRoleUserService;
+
+    @Autowired
+    private ProjectRoleDepartmentService projectRoleDepartmentService;
 
     @Autowired
     private IssueRiskService issueRiskService;
@@ -184,6 +196,23 @@
         issue.setIssueType(issueType);
         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);
@@ -247,18 +276,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());
@@ -756,6 +792,9 @@
                     issueVo.setIssueStatusVo(ConvertUtil.copyProperties(issue.getIssueStatus(), IssueStatusVo.class));
                     issueVo.setPriorityVo(ConvertUtil.copyProperties(issue.getPriority(), PriorityVo.class));
                     issueVo.setSeverityVo(ConvertUtil.copyProperties(issue.getSeverity(), SeverityVo.class));
+                    issueVo.setCompanyFieldVo(ConvertUtil.copyProperties(issue.getCompanyField(), CompanyFieldVo.class));
+                    issueVo.setIspFieldVo(ConvertUtil.copyProperties(issue.getIspFieldId(), IspFieldVo.class));
+                    issueVo.setHostingFieldVo(ConvertUtil.copyProperties(issue.getHostingFieldId(), HostingFieldVo.class));
 
                     this.setRegister(issue, issueVo);   //  �벑濡앹옄 �젙蹂� �뀑�똿
                     //this.setIssueUser(issue, issueVo);  //  �떞�떦�옄 �젙蹂� �뀑�똿
@@ -763,6 +802,8 @@
                     this.setAttachedFiles(issue, issueVo);  //  泥⑤� �뙆�씪 �젙蹂� �뀑�똿
                     this.setIssueCustomFields(issue, issueVo);  //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿
                     this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+                    this.setDownIssues(issue, issueVo);
+
                     break;
 
                 case "02": //  �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭,  �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂�, �뙎湲�, 湲곕줉�쓣 �뀑�똿�븳�떎.
@@ -777,6 +818,13 @@
         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);
+    }
+
     //  �씠�뒋 �긽�꽭 �젙蹂대�� �뀑�똿�븳�떎.
     @Override
     @Transactional(readOnly = true)
@@ -788,6 +836,9 @@
         issueVo.setIssueStatusVo(issueStatusVo);
         issueVo.setPriorityVo(ConvertUtil.copyProperties(issue.getPriority(), PriorityVo.class));
         issueVo.setSeverityVo(ConvertUtil.copyProperties(issue.getSeverity(), SeverityVo.class));
+        issueVo.setCompanyFieldVo(ConvertUtil.copyProperties(issue.getCompanyField(), CompanyFieldVo.class));
+        issueVo.setIspFieldVo(ConvertUtil.copyProperties(issue.getIspFieldId(), IspFieldVo.class));
+        issueVo.setHostingFieldVo(ConvertUtil.copyProperties(issue.getHostingFieldId(), HostingFieldVo.class));
         this.setRegister(issue, issueVo);   //  �벑濡앹옄 �젙蹂� �뀑�똿
         //this.setIssueUser(issue, issueVo);  //  �떞�떦�옄 �젙蹂� �뀑�똿
         this.setIssueDepartment(issue, issueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
@@ -796,6 +847,7 @@
         this.setIssueComments(issue, issueVo);  //  �뙎湲� �젙蹂� �뀑�똿
         this.setIssueHistory(issue, issueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
         this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+        this.setDownIssues(issue, issueVo);
     }
 
     //  �벑濡앹옄 �젙蹂� 異붽�
@@ -934,7 +986,7 @@
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
         this.workspaceService.checkUseWorkspace();
         //  �씠�뒋 �닔�젙 沅뚰븳 泥댄겕
-        //this.verifyIssueModifyPermission(issueForm.getId());
+        this.verifyIssueModifyPermission(issueForm.getId());
         //  �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕
         Project project = this.projectService.getProject(issueForm.getProjectId());
         //  �씠�뒋 �긽�깭 �쑀�슚�꽦 泥댄겕
@@ -950,8 +1002,10 @@
         //  �궇吏� �쑀�슚�꽦 泥댄겕
         this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
 
-        //  �떞�떦�옄 �쑀�슚�꽦 泥댄겕 => �떞�떦遺��꽌濡� 蹂�寃�
+        //  �떞�떦�옄 �쑀�슚�꽦 泥댄겕
         //this.verifyIssueAssignee(project, issueForm);
+        //  �떞�떦遺��꽌 �쑀�슚�꽦 泥댄겕
+        this.verifyIssueDepartment(project, issueForm);
 
         Issue issue = this.getIssue(issueForm.getId());
 
@@ -1057,35 +1111,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));
-                }*/
+                }
             }
             //  李몄뿬 �솗�씤�맂 遺��꽌濡� �떞�떦遺��꽌 蹂�寃�
             issueForm.setDepartmentIds(trustDepartmentIds);
         }
     }
 
-    /*//  �씠�뒋 �떞�떦�옄濡� 吏��젙�맆 �궗�슜�옄媛� �빐�떦 �봽濡쒖젥�듃�뿉 李몄뿬 �븯怨� �엳�뒗 �궗�슜�옄 �씤吏� �솗�씤
+    //  �씠�뒋 �떞�떦�옄濡� 吏��젙�맆 �궗�슜�옄媛� �빐�떦 �봽濡쒖젥�듃�뿉 李몄뿬 �븯怨� �엳�뒗 �궗�슜�옄 �씤吏� �솗�씤
     private void verifyIssueAssignee(Project project, IssueForm issueForm) {
         if (issueForm.getUserIds().size() > 0) {
             List<Long> trustUserIds = Lists.newArrayList(); //  李몄뿬 �솗�씤�맂 �궗�슜�옄
@@ -1104,15 +1158,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 +1534,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)); // �벑濡앹옄
@@ -1585,6 +1639,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());
 
@@ -2473,4 +2528,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