From 61037a004e28c5e508a62f42022d20d6872dc672 Mon Sep 17 00:00:00 2001
From: jhjang <jhjang@maprex.co.kr>
Date: 수, 17 11월 2021 11:50:22 +0900
Subject: [PATCH] - 이슈 상세 페이지에 하위 일감 기능 추가

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  265 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 228 insertions(+), 37 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 797434f..947aeae 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
@@ -83,6 +92,9 @@
 
     @Autowired
     private IssueUserService issueUserService;
+
+    @Autowired
+    private IssueDepartmentService issueDepartmentService;
 
     @Autowired
     private CustomFieldService customFieldService;
@@ -101,6 +113,9 @@
 
     @Autowired
     private ProjectRoleUserService projectRoleUserService;
+
+    @Autowired
+    private ProjectRoleDepartmentService projectRoleDepartmentService;
 
     @Autowired
     private IssueRiskService issueRiskService;
@@ -181,13 +196,32 @@
         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);
 
         issue.setReverseIndex(issue.getId() * -1);  //  荑쇰━ �냽�룄 媛쒖꽑�쓣 �쐞�빐 由щ쾭�뒪 �씤�뜳�뒪 �깮�꽦
         //  �떞�떦�옄 吏��젙
-        this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds());
+        //this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds());
+        //  �떞�떦遺��꽌 吏��젙
+        this.issueDepartmentService.modifyIssueDepartment(issue, project.getWorkspace(), issueForm.getDepartmentIds());
 
         //  multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎.
         List<Map<String, Object>> convertFileMaps = this.convertMultipartFileToFile(multipartFiles);
@@ -251,8 +285,16 @@
             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());
@@ -383,6 +425,7 @@
         issueCondition.setIssueIds(issueKeys);
 
         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();
@@ -514,7 +557,8 @@
         }
 
         //  �씠�뒋 �궗�슜�옄 �젙蹂� 異붽�
-        this.setIssueUserList(issueVos, issueCondition);
+        //this.setIssueUserList(issueVos, issueCondition);
+        this.setIssueDepartmentList(issueVos, issueCondition);
         //  �벑濡앹옄 �젙蹂� 異붽�
         this.setRegister(issueVos);  //  �떞�떦�옄 �젙蹂� �뀑�똿
 
@@ -694,6 +738,43 @@
         }
     }
 
+    //  �씠�뒋 �떞�떦遺��꽌 �젙蹂대�� �뀑�똿�븳�떎.
+    private void setIssueDepartmentList(List<IssueVo> issueVos, IssueCondition issueCondition) {
+        if (issueVos.size() < 1) {
+            return;
+        }
+
+        List<Map<String, Object>> issueDepartments = this.issueMapper.findIssueDepartment(issueCondition);
+        Map<String, Object> issueConverterDepartments = new HashMap<>();
+
+        //  �씠�뒋�뿉 �빐�떦�븯�뒗 �씠�뒋 �떞�떦遺��꽌 �젙蹂� �뀑�똿
+        for (Map<String, Object> issueDepartment : issueDepartments) {
+            String issueId = MapUtil.getString(issueDepartment, "issueId");
+
+            if (MapUtil.getObject(issueConverterDepartments, issueId) != null) {
+                List<DepartmentVo> departments = (List) MapUtil.getObject(issueConverterDepartments, issueId);
+                departments.add(new DepartmentVo(MapUtil.getLong(issueDepartment, "id"), MapUtil.getString(issueDepartment, "departmentName"), MapUtil.getString(issueDepartment, "departmentDescription")));
+            } else {
+                List<DepartmentVo> departments = Lists.newArrayList(new DepartmentVo(MapUtil.getLong(issueDepartment, "id"), MapUtil.getString(issueDepartment, "departmentName"), MapUtil.getString(issueDepartment, "departmentDescription")));
+                issueConverterDepartments.put(issueId, departments);
+            }
+        }
+
+        //  �씠�뒋Vo�뿉 �떞�떦遺��꽌 �젙蹂대�� �뀑�똿
+        for (IssueVo issueVo : issueVos) {
+            if (MapUtil.getObject(issueConverterDepartments, String.valueOf(issueVo.getId())) != null) {
+                List<DepartmentVo> departmentVos = (List) MapUtil.getObject(issueConverterDepartments, String.valueOf(issueVo.getId()));
+
+                issueVo.setDepartmentVos(departmentVos);
+            }
+
+            //  �씠�뒋 �닔�젙 沅뚰븳�쓣 媛뽮퀬 �엳�뒗吏� �솗�씤
+            if (this.checkHasPermission(issueVo, issueVo.getUserVos())) {
+                issueVo.setModifyPermissionCheck(Boolean.TRUE);
+            }
+        }
+    }
+
     //  �씠�뒋 �긽�꽭 �젙蹂대�� 議고쉶�븳�떎.
     @Override
     @Transactional(readOnly = true)
@@ -705,7 +786,7 @@
             issueVo = ConvertUtil.copyProperties(issue, IssueVo.class);
 
             switch (issueCondition.getDeep()) {
-                case "01": //  �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭,  �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� �뀑�똿�븳�떎.
+                case "01": //  �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭,  �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦遺��꽌, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� �뀑�똿�븳�떎.
                     issueVo.setProjectVo(ConvertUtil.copyProperties(issue.getProject(), ProjectVo.class));
                     issueVo.setIssueTypeVo(ConvertUtil.copyProperties(issue.getIssueType(), IssueTypeVo.class));
                     issueVo.setIssueStatusVo(ConvertUtil.copyProperties(issue.getIssueStatus(), IssueStatusVo.class));
@@ -713,10 +794,13 @@
                     issueVo.setSeverityVo(ConvertUtil.copyProperties(issue.getSeverity(), SeverityVo.class));
 
                     this.setRegister(issue, issueVo);   //  �벑濡앹옄 �젙蹂� �뀑�똿
-                    this.setIssueUser(issue, issueVo);  //  �떞�떦�옄 �젙蹂� �뀑�똿
+                    //this.setIssueUser(issue, issueVo);  //  �떞�떦�옄 �젙蹂� �뀑�똿
+                    this.setIssueDepartment(issue, issueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
                     this.setAttachedFiles(issue, issueVo);  //  泥⑤� �뙆�씪 �젙蹂� �뀑�똿
                     this.setIssueCustomFields(issue, issueVo);  //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿
                     this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+                    this.setDownIssues(issue, issueVo);
+
                     break;
 
                 case "02": //  �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭,  �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂�, �뙎湲�, 湲곕줉�쓣 �뀑�똿�븳�떎.
@@ -731,6 +815,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)
@@ -743,13 +834,14 @@
         issueVo.setPriorityVo(ConvertUtil.copyProperties(issue.getPriority(), PriorityVo.class));
         issueVo.setSeverityVo(ConvertUtil.copyProperties(issue.getSeverity(), SeverityVo.class));
         this.setRegister(issue, issueVo);   //  �벑濡앹옄 �젙蹂� �뀑�똿
-        this.setIssueUser(issue, issueVo);  //  �떞�떦�옄 �젙蹂� �뀑�똿
+        //this.setIssueUser(issue, issueVo);  //  �떞�떦�옄 �젙蹂� �뀑�똿
         this.setIssueDepartment(issue, issueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
         this.setAttachedFiles(issue, issueVo);  //  泥⑤� �뙆�씪 �젙蹂� �뀑�똿
         this.setIssueCustomFields(issue, issueVo);  //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿
         this.setIssueComments(issue, issueVo);  //  �뙎湲� �젙蹂� �뀑�똿
         this.setIssueHistory(issue, issueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
         this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
+        this.setDownIssues(issue, issueVo);
     }
 
     //  �벑濡앹옄 �젙蹂� 異붽�
@@ -796,7 +888,7 @@
     }
 
     //  �씠�뒋 �떞�떦�옄 �젙蹂대�� �뀑�똿�븳�떎.
-    private void setIssueUser(Issue issue, IssueVo issueVo) {
+    /*private void setIssueUser(Issue issue, IssueVo issueVo) {
         List<UserVo> userVos = Lists.newArrayList();
 
         for (IssueUser issueUser : issue.getIssueUsers()) {
@@ -829,14 +921,14 @@
         }
 
         issueVo.setUserVos(userVos);
-    }
+    }*/
 
     //  �씠�뒋 �떞�떦遺��꽌 �젙蹂대�� �뀑�똿�븳�떎.
     private void setIssueDepartment(Issue issue, IssueVo issueVo) {
         List<DepartmentVo> departmentVos = Lists.newArrayList();
 
-        for (IssueUser issueUser : issue.getIssueUsers()) {
-            DepartmentVo departmentVo = ConvertUtil.copyProperties(issueUser.getDepartment(), DepartmentVo.class);
+        for (IssueDepartment issueDepartment : issue.getIssueDepartments()) {
+            DepartmentVo departmentVo = ConvertUtil.copyProperties(issueDepartment.getDepartment(), DepartmentVo.class);
             departmentVo.setByName(departmentVo.getByName());
             departmentVos.add(departmentVo);
         }
@@ -905,7 +997,9 @@
         this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
 
         //  �떞�떦�옄 �쑀�슚�꽦 泥댄겕
-        this.verifyIssueAssignee(project, issueForm);
+        //this.verifyIssueAssignee(project, issueForm);
+        //  �떞�떦遺��꽌 �쑀�슚�꽦 泥댄겕
+        this.verifyIssueDepartment(project, issueForm);
 
         Issue issue = this.getIssue(issueForm.getId());
 
@@ -933,8 +1027,11 @@
         issue.setCompleteDate(issueForm.getCompleteDate());
 
         this.issueRepository.saveAndFlush(issue);
-        //  �떞�떦�옄 吏��젙
-        this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds());
+        //this.issueUserService.modifyIssueUser(issue, project.getWorkspace(), issueForm.getUserIds());
+        //  �떞�떦遺��꽌 吏��젙
+        if(issueForm.getDepartmentIds().size()>0){
+            this.issueDepartmentService.modifyIssueDepartment(issue, project.getWorkspace(), issueForm.getDepartmentIds());
+        }
 
         //  multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎.
         List<Map<String, Object>> convertFileMaps = this.convertMultipartFileToFile(multipartFiles);
@@ -1007,6 +1104,35 @@
         return false;
     }
 
+    //  �씠�뒋 �떞�떦遺��꽌濡� 吏��젙�맆 遺��꽌媛� �빐�떦 �봽濡쒖젥�듃�뿉 李몄뿬 �븯怨� �엳�뒗 遺��꽌�씤吏� �솗�씤
+    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()) {
+                    ProjectRoleDepartment projectRoleDepartment = this.projectRoleDepartmentService.findByProjectRoleIdAndDepartmentId(projectRole.getId(), departmentId);
+
+                    if (projectRoleDepartment != null) {
+                        includeProject = true;
+                        trustDepartmentIds.add(departmentId);
+                        break;
+                    }
+                }
+
+                //  �뜲�씠�꽣 蹂댁젙 �옉�뾽 - �봽濡쒖젥�듃�뿉�꽌 �젣�쇅�맂 �궗�슜�옄�뒗 �떞�떦�옄�뿉�꽌 �젣�쇅 �맆 �닔 �엳�룄濡� 泥섎━
+                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) {
@@ -1026,10 +1152,10 @@
                 }
 
                 //  �뜲�씠�꽣 蹂댁젙 �옉�뾽 - �봽濡쒖젥�듃�뿉�꽌 �젣�쇅�맂 �궗�슜�옄�뒗 �떞�떦�옄�뿉�꽌 �젣�쇅 �맆 �닔 �엳�룄濡� 泥섎━
-                /*if (!includeProject) {
+                if (!includeProject) {
                     throw new OwlRuntimeException(
                             this.messageAccessor.getMessage(MsgConstants.PROJECT_NOT_INCLUDE_USER));
-                }*/
+                }
             }
             //  李몄뿬 �솗�씤�맂 �궗�슜�옄濡� �떞�떦�옄 蹂�寃�
             issueForm.setUserIds(trustUserIds);
@@ -1069,8 +1195,8 @@
         hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.PROJECT_MANAGER, issueVo, null);
         //   �씠�뒋 �벑濡앹옄�씪 寃쎌슦 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
         hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.REGISTER, issueVo, null);
-        //  �씠�뒋 �떞�떦�옄�씪 寃쎌슦 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
-        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos);
+        //  �씠�뒋 �떞�떦�옄�씪 寃쎌슦 �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎. => �떞�떦遺��꽌濡� �닔�젙 - 泥댄겕
+        //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos);
         //  �떞�떦�옄媛� �뾾�쑝硫� 紐⑤뱺 �궗�슜�옄媛� �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
 
         return hasPermission;
@@ -1102,13 +1228,13 @@
                         break;
                     }
 
-                    //   �씠�뒋 �떞�떦�옄 �뿬遺� �솗�씤
-                    for (UserVo issueUserVo : issueUserVos) {
+                    //   �씠�뒋 �떞�떦�옄 �뿬遺� �솗�씤 => �떞�떦遺��꽌濡� �닔�젙 - 泥댄겕
+                    /*for (UserVo issueUserVo : issueUserVos) {
                         if (issueUserVo.getId().equals(this.webAppUtil.getLoginId())) {
                             hasPermission = true;
                             break;
                         }
-                    }
+                    }*/
 
                     break;
             }
@@ -1164,7 +1290,7 @@
     }
 
     //  �씠�뒋 �떞�떦�옄 蹂�寃�
-    @Override
+    /*@Override
     @Transactional
     public void modifyIssueUser(IssueForm issueForm) {
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
@@ -1179,7 +1305,43 @@
         //  蹂�寃� �씠�젰 �젙蹂� 異붿텧
         this.issueHistoryService.detectIssueManager(issue, issueForm, detectIssueChange);
 
-        this.issueUserService.modifyIssueUser(issue, issue.getProject().getWorkspace(), issueForm.getUserIds());
+        this.issueUserService.modifyIssueUser(issue, issue.getProject().getWorkspace(), issueForm.getDepartmentIds()); //getUserIds -> getDepartmentIds
+        this.issueRepository.saveAndFlush(issue);
+
+        //  �씠�뒋 �씠�젰 �벑濡�
+        if (!StringUtils.isEmpty(detectIssueChange.toString())) {
+            StringBuilder stringBuilder = new StringBuilder();
+            stringBuilder.append("<ul class=\"activity-list\">");
+            stringBuilder.append(detectIssueChange.toString());
+            stringBuilder.append("</ul>");
+
+            this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.MODIFY, stringBuilder.toString());
+        }
+
+        //  �씠�뒋 踰꾩쟾 �깮�꽦
+        this.issueVersionService.addIssueVersion(issue);
+
+        //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
+        log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_USER_CHANGE));
+    }*/
+
+    @Override
+    @Transactional
+    public void modifyIssueDepartment(IssueForm issueForm) {
+        //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
+        this.workspaceService.checkUseWorkspace();
+        //  蹂�寃� �씠�젰 �젙蹂� 異붿텧
+        StringBuilder detectIssueChange = new StringBuilder();
+        //  �씠�뒋 �닔�젙 沅뚰븳 泥댄겕
+        this.verifyIssueModifyPermission(issueForm.getId());
+        Issue issue = this.getIssue(issueForm.getId());
+        issue.setProject(this.projectService.getProject(issueForm.getProjectId()));
+
+        //  蹂�寃� �씠�젰 �젙蹂� 異붿텧
+        this.issueHistoryService.detectIssueManager(issue, issueForm, detectIssueChange);
+
+        //this.issueUserService.modifyIssueUser(issue, issue.getProject().getWorkspace(), issueForm.getUserIds());
+        this.issueDepartmentService.modifyIssueDepartment(issue, issue.getProject().getWorkspace(), issueForm.getDepartmentIds());
         this.issueRepository.saveAndFlush(issue);
 
         //  �씠�뒋 �씠�젰 �벑濡�
@@ -1366,7 +1528,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("assignees", this.messageAccessor.message("common.assignee"), 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)); // �벑濡앹옄
@@ -1471,6 +1633,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());
 
@@ -1542,7 +1705,7 @@
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.issueType"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �씠�뒋 ���엯
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.priority"), 5, ExportExcelAttrVo.ALIGN_CENTER)); // �슦�꽑�닚�쐞
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.importance"), 5, ExportExcelAttrVo.ALIGN_CENTER)); // 以묒슂�룄
-        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.assignee"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦�옄
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.department"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦遺��꽌
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.startDate"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떆�옉�씪
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.endDate"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 醫낅즺�씪
         //  �봽濡쒖젥�듃�뿉 �뿰寃곕맂 �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� 異붿텧�븯�뿬 �뿊�� download �뀥�뵆由우쓣 留뚮뱺�떎.
@@ -1714,10 +1877,11 @@
         List<Map<String, Long>> issueAssigneeMaps = Lists.newArrayList();
 
         for (IssueForm issueForm : issueForms) {
-            for (Long userId : issueForm.getUserIds()) {
+            for (Long departmentId : issueForm.getDepartmentIds()) {
                 Map<String, Long> issueAssigneeMap = new HashMap<>();
                 issueAssigneeMap.put("issueId", issueForm.getId());
-                issueAssigneeMap.put("userId", userId);
+                //issueAssigneeMap.put("userId", userId);
+                issueAssigneeMap.put("departmentId", departmentId);
                 issueAssigneeMap.put("workspaceId", workspace.getId());
                 issueAssigneeMap.put("registerId", this.webAppUtil.getLoginId());
                 issueAssigneeMaps.add(issueAssigneeMap);
@@ -1726,7 +1890,8 @@
 
         if (issueAssigneeMaps.size() > 0) {
             //  �씠�뒋 �떞�떦�옄 踰뚰겕 �벑濡�
-            this.issueUserService.insertIssueUser(issueAssigneeMaps);
+            //this.issueUserService.insertIssueUser(issueAssigneeMaps);
+            this.issueDepartmentService.insertIssueDepartment(issueAssigneeMaps);
         }
     }
 
@@ -1880,7 +2045,7 @@
                     this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex);
                     break;
                 case 6:
-                    //  �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎.
+                    //  �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎.
                     this.setIssueFormAssignee(cell, userMaps, issueForm, project);
                     break;
                 case 7:
@@ -2021,21 +2186,21 @@
         issueForm.setSeverityId(severity.getId());
     }
 
-    //  �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎.
+    //  �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎.
     private void setIssueFormAssignee(Cell cell, Map<String, Object> userMaps, IssueForm issueForm, Project project) {
         if (cell != null) {
             String[] splitAssignee = CommonUtil.convertExcelStringToCell(cell).split("#");
             Map<String, Object> userMap = (Map<String, Object>) MapUtil.getObject(userMaps, project.getProjectKey());
 
-            List<Long> userIds = Lists.newArrayList();
+            List<Long> departmentIds = Lists.newArrayList();
 
             for (String account : splitAssignee) {
                 if (MapUtil.getLong(userMap, account) != null) {
-                    userIds.add(MapUtil.getLong(userMap, account));
+                    departmentIds.add(MapUtil.getLong(userMap, account));
                 }
             }
 
-            issueForm.setUserIds(userIds);
+            issueForm.setDepartmentIds(departmentIds);
         }
     }
 
@@ -2298,17 +2463,24 @@
             taskUserSave.put(taskId.toString(), Lists.newArrayList());
         }
 
-        List<Map<String, Object>> taskUsers = Lists.newArrayList();
+        List<Map<String, Object>> taskDepartments = Lists.newArrayList();
         //  task 媛� �븯�굹�룄 �뾾�쓣 寃쎌슦�뿉�뒗 議고쉶瑜� �븯吏� �븡�뒗�떎.
         if (!taskCondition.getIssueIds().isEmpty()) {
-            taskUsers = this.issueMapper.getAllTaskUser(taskCondition);
+            //taskUsers = this.issueMapper.getAllTaskUser(taskCondition);
+            taskDepartments = this.issueMapper.getAllTaskUser(taskCondition);
         }
 
         //  task_id �뿉 留ㅼ묶�릺�뒗 �떞�떦�옄 �젙蹂대�� 以�鍮꾪븳�떎.
-        for (Map<String, Object> taskUser : taskUsers) {
+        /*for (Map<String, Object> taskUser : taskUsers) {
             Long taskId = MapUtil.getLong(taskUser, "taskId");
             List<UserVo> userVos = (List<UserVo>)taskUserSave.get(taskId.toString());
             userVos.add(ConvertUtil.convertMapToClass(taskUser, UserVo.class));
+        }*/
+
+        for (Map<String, Object> taskDepartment : taskDepartments) {
+            Long taskId = MapUtil.getLong(taskDepartment, "taskId");
+            List<DepartmentVo> departmentVos = (List<DepartmentVo>)taskUserSave.get(taskId.toString());
+            departmentVos.add(ConvertUtil.convertMapToClass(taskDepartment, DepartmentVo.class));
         }
 
         for (Map<String, Object> result : results) {
@@ -2333,8 +2505,12 @@
             }
 
             //  �떞�떦�옄 �뀑�똿
-            List<UserVo> userVos =  (List<UserVo>)taskUserSave.get(taskVo.getId().toString());
-            taskVo.setUserVos(userVos);
+            //List<UserVo> userVos =  (List<UserVo>)taskUserSave.get(taskVo.getId().toString());
+            //taskVo.setUserVos(userVos);
+
+            //  �떞�떦遺��꽌 �꽭�똿
+            List<DepartmentVo> departmentVos = (List<DepartmentVo>)taskUserSave.get(taskVo.getId().toString());
+            taskVo.setDepartmentVos(departmentVos);
 
             List<IssueVo> taskVos = (List<IssueVo>)tasks.get(MapUtil.getString(result, "workflowStatusId"));
             taskVos.add(taskVo);
@@ -2346,4 +2522,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