From 34351d822ce35efe2488004e586beeb074fbe5ae Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 화, 04 1월 2022 13:25:28 +0900
Subject: [PATCH] - API 수정 명령시 댓글 추가 가능(comment) - API 이슈 입력시 상위 이슈에 같은 도메인 업체 등록되도록 수정

---
 src/main/java/kr/wisestone/owl/service/impl/IssueHistoryServiceImpl.java |  327 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 308 insertions(+), 19 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/IssueHistoryServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IssueHistoryServiceImpl.java
index c6dce73..1e2a2b3 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueHistoryServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueHistoryServiceImpl.java
@@ -4,6 +4,7 @@
 import kr.wisestone.owl.constant.Constants;
 import kr.wisestone.owl.constant.ElasticSearchConstants;
 import kr.wisestone.owl.constant.MsgConstants;
+import kr.wisestone.owl.data.CheckIssueData;
 import kr.wisestone.owl.domain.*;
 import kr.wisestone.owl.domain.enumType.CustomFieldType;
 import kr.wisestone.owl.domain.enumType.IssueHistoryType;
@@ -13,7 +14,9 @@
 import kr.wisestone.owl.service.*;
 import kr.wisestone.owl.util.*;
 import kr.wisestone.owl.vo.IssueHistoryVo;
+import kr.wisestone.owl.vo.IssueVo;
 import kr.wisestone.owl.web.condition.IssueHistoryCondition;
+import kr.wisestone.owl.web.form.EmailTemplateForm;
 import kr.wisestone.owl.web.form.IssueForm;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -39,6 +42,9 @@
     private UserService userService;
 
     @Autowired
+    private DepartmentService departmentService;
+
+    @Autowired
     private IssueHistoryMapper issueHistoryMapper;
 
     @Autowired
@@ -59,13 +65,22 @@
     @Override
     @Transactional
     public void addIssueHistory(Issue issue, IssueHistoryType issueHistoryType, String issueChangeDescription) {
+        User user = this.webAppUtil.getLoginUserObject();
+        addIssueHistory(issue, user, issueHistoryType, issueChangeDescription);
+    }
+
+    //  �씠�젰 �깮�꽦
+    @Override
+    @Transactional
+    public void addIssueHistory(Issue issue, User user, IssueHistoryType issueHistoryType, String issueChangeDescription) {
         IssueHistory issueHistory = new IssueHistory();
         issueHistory.setIssue(issue);
         issueHistory.setProject(issue.getProject());
         issueHistory.setIssueHistoryType(issueHistoryType);
         StringBuilder description = new StringBuilder();
         //  �씠�젰 �젙蹂대�� 留뚮뱾�뼱 �궦�떎.
-        this.makeDescription(description, issueHistoryType, issueChangeDescription);
+
+        this.makeDescription(user, description, issueHistoryType, issueChangeDescription);
         issueHistory.setDescription(description.toString());
 
         this.issueHistoryRepository.saveAndFlush(issueHistory);
@@ -77,6 +92,13 @@
     //  �씠�젰 �젙蹂대�� 留뚮뱾�뼱 �궦�떎.
     @Override
     public void makeDescription(StringBuilder description, IssueHistoryType issueHistoryType, String issueChangeDescription) {
+        User user = this.webAppUtil.getLoginUserObject();
+        makeDescription(user, description, issueHistoryType, issueChangeDescription);
+    }
+
+    //  �씠�젰 �젙蹂대�� 留뚮뱾�뼱 �궦�떎.
+    @Override
+    public void makeDescription(User user, StringBuilder description, IssueHistoryType issueHistoryType, String issueChangeDescription) {
         description.append("<div class=\"activity-text\">");
 
         //  �깮�꽦, �닔�젙, �궘�젣�뿉 ���빐 湲곕줉�쓣 �궓湲대떎.
@@ -86,9 +108,9 @@
                 description.append("<span class='activity-timestamp'>");
                 description.append(DateUtil.convertDateToStr(new Date()));
                 description.append(" (");
-                description.append(this.webAppUtil.getLoginUser().getName());
+                description.append(user.getName());
                 description.append(" - ");
-                description.append(CommonUtil.decryptAES128(this.webAppUtil.getLoginUser().getAccount()));
+                description.append(CommonUtil.decryptAES128(user.getAccount()));
                 description.append(")");
                 description.append("</span></h6>");
                 break;
@@ -99,10 +121,10 @@
                 description.append(DateUtil.convertDateToStr(new Date()));
                 description.append(" (");
 
-                if (this.webAppUtil.getLoginUser() != null) {
-                    description.append(this.webAppUtil.getLoginUser().getName());
+                if (user != null) {
+                    description.append(user.getName());
                     description.append(" - ");
-                    description.append(CommonUtil.decryptAES128(this.webAppUtil.getLoginUser().getAccount()));
+                    description.append(CommonUtil.decryptAES128(user.getAccount()));
                 }
                 else {
                     description.append("OWL-ITS-SYSTEM");
@@ -120,11 +142,33 @@
                 description.append("<span class=\"activity-timestamp\">");
                 description.append(DateUtil.convertDateToStr(new Date()));
                 description.append(" (");
-                description.append(this.webAppUtil.getLoginUser().getName());
+                description.append(user.getName());
                 description.append(" - ");
-                description.append(CommonUtil.decryptAES128(this.webAppUtil.getLoginUser().getAccount()));
+                description.append(CommonUtil.decryptAES128(user.getAccount()));
                 description.append(")");
                 description.append("</span></h6>");
+                break;
+
+            case SEND:
+                description.append("<h6 class=\"creat\"><span class=\"dot\"></span><span translate=\"common.sendMailIssue\">�씠�뒋 硫붿씪 �쟾�넚</span>");
+                description.append("<span class=\"activity-timestamp\">");
+                description.append(DateUtil.convertDateToStr(new Date()));
+                description.append(" (");
+
+                if (user != null) {
+                    description.append(user.getName());
+                    description.append(" - ");
+                    description.append(CommonUtil.decryptAES128(user.getAccount()));
+                }
+                else {
+                    description.append("OWL-ITS-SYSTEM");
+                    description.append(" - ");
+                    description.append(this.systemEmail);
+                }
+
+                description.append(")");
+                description.append("</span></h6>");
+                description.append(issueChangeDescription);
                 break;
         }
 
@@ -268,13 +312,25 @@
     //  �씠�뒋 �븘�씠�뵒�뿉 �빐�떦�븯�뒗 湲곕줉 �젙蹂대�� 媛��졇�삩�떎.
     @Override
     @Transactional(readOnly = true)
-    public List<IssueHistoryVo> findIssueHistory(Long issueId) {
-        return this.issueHistoryRepository.findByIssueId(issueId);
+    public List<IssueHistoryVo> findIssueHistory(Issue issue) {
+        List<IssueHistoryVo> issueHistoryVos = this.issueHistoryRepository.findByIssueId(issue.getId());
+        if (issueHistoryVos != null && issueHistoryVos.size() > 0) {
+            for (IssueHistoryVo issueHistoryVo : issueHistoryVos) {
+                issueHistoryVo.setTitle(issue.getTitle());
+            }
+        }
+        return issueHistoryVos;
     }
 
     //  �씠�뒋 蹂�寃� �궡�뿭�쓣 異붿텧�븳�떎.
     @Override
-    public StringBuilder detectIssueChange(Issue issue, IssueForm issueForm, Project project, IssueStatus issueStatus, IssueType issueType, Priority priority, Severity severity, List<MultipartFile> files) {
+    public StringBuilder detectIssueChange(IssueForm issueForm, CheckIssueData data, List<MultipartFile> files) {
+        return this.detectIssueChange(data.getIssue(), issueForm, data.getProject(), data.getOldIssueStatus(), data.getNewIssueStatus(), data.getIssueType(), data.getPriority(), data.getSeverity(), files);
+    }
+
+    //  �씠�뒋 蹂�寃� �궡�뿭�쓣 異붿텧�븳�떎.
+    @Override
+    public StringBuilder detectIssueChange(Issue issue, IssueForm issueForm, Project project, IssueStatus oldIssueStatus, IssueStatus issueStatus, IssueType issueType, Priority priority, Severity severity, List<MultipartFile> files) {
         StringBuilder description = new StringBuilder();
 
         //  �씠�뒋 �봽濡쒖젥�듃 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
@@ -284,7 +340,7 @@
         //  �씠�뒋 �슦�꽑�닚�쐞 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
         this.detectIssuePriority(issue, issueForm, description, priority);
         //  �씠�뒋 �긽�깭 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
-        this.detectIssueStatus(issue, issueForm, description, issueStatus);
+        this.detectIssueStatus(issue, issueForm, description, oldIssueStatus, issueStatus);
         //  �씠�뒋 ���엯 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
         this.detectIssueType(issue, issueForm, description, issueType);
         //  �씠�뒋�뿉 泥⑤��맂 �뙆�씪�뿉 ���빐 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
@@ -292,7 +348,12 @@
         //  �씠�뒋 湲곌컙 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
         this.detectIssuePeriod(issue, issueForm, description);
         //  �떞�떦�옄 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
-        //this.detectIssueManager(issue, issueForm, description);
+        this.detectIssueManager(issue, issueForm, description);
+
+        if (issueForm.getIsApi().equals(Issue.IS_API_NO)) { //api濡� 蹂�寃� �떆 �떞�떦遺��꽌 蹂�寃� 遺덇�
+            //  �떞�떦遺��꽌 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
+            this.detectIssueDepartment(issue, issueForm, description);
+        }
         //  �궗�슜�옄 �젙�쓽 �븘�뱶 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
         this.detectCustomField(issue, issueForm, description);
 
@@ -363,11 +424,12 @@
 
     //  �씠�뒋 �긽�깭 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
     @Override
-    public void detectIssueStatus(Issue issue, IssueForm issueForm, StringBuilder description, IssueStatus issueStatus) {
-        if (!issue.getIssueStatus().getId().equals(issueForm.getIssueStatusId())) {
+    @Transactional
+    public void detectIssueStatus(Issue issue, IssueForm issueForm, StringBuilder description, IssueStatus oldIssueStatus, IssueStatus issueStatus) {
+        if (!oldIssueStatus.getId().equals(issueForm.getIssueStatusId())) {
             String title = "<span translate=\"common.updateHasStatus\">�긽�깭媛� 蹂�寃쎈릺�뿀�뒿�땲�떎.</span>";
             //  �씠�젰 �젙蹂대�� html �깭洹몃줈 留뚮뱾�뼱 以��떎.
-            this.makeIssueHistoryHtml(description, title, issue.getIssueStatus().getName(), issueStatus.getName());
+            this.makeIssueHistoryHtml(description, title, oldIssueStatus.getName(), issueStatus.getName());
 
             //  �씠�뒋 �쐞�뿕 愿�由ъ뿉 �긽�깭 蹂�寃� �젙蹂대�� �뾽�뜲�씠�듃�븳�떎. - �떞�떦�옄 蹂�寃�
             this.issueRiskService.modifyIssueRisk(issue, true, false, issueForm.getIssueStatusId());
@@ -391,7 +453,7 @@
     public void recordRemoveWorkflowToIssueStatus(String oldIssueStatusName, String newIssueStatusName, StringBuilder description) {
         description.append("<ul class=\"activity-list\">");
 
-        String title = "<span translate=\"common.upddetectReservationIssueStatusateWorkflowNotExist\">蹂�寃쎈맂 �썙�겕�뵆濡쒖슦�뿉�꽌 �긽�깭媛� 議댁옱�븯吏� �븡�븘 �씠�뒋�쓽 �긽�깭媛� 蹂�寃쎈릺�뿀�뒿�땲�떎.</span>";
+        String title = "<span translate=\"common.updateWorkflowNotExist\">蹂�寃쎈맂 �썙�겕�뵆濡쒖슦�뿉�꽌 �긽�깭媛� 議댁옱�븯吏� �븡�븘 �씠�뒋�쓽 �긽�깭媛� 蹂�寃쎈릺�뿀�뒿�땲�떎.</span>";
         //  �씠�젰 �젙蹂대�� html �깭洹몃줈 留뚮뱾�뼱 以��떎.
         this.makeIssueHistoryHtml(description, title, oldIssueStatusName, newIssueStatusName);
 
@@ -447,10 +509,8 @@
         else {
             recodeIssuePeriod.append("<span translate=\"common.unspecified\">誘몄��젙</span>");
         }
-
         return recodeIssuePeriod.toString();
     }
-
 
     // �뿰愿� �씪媛� 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
     @Override
@@ -462,6 +522,160 @@
            description.append("<span translate=\"issue.relationIssueRemoveHistory\">�뿰愿� �씪媛먯씠 �궘�젣�릺�뿀�뒿�땲�떎. " + issueRelation.getRelationIssue().getTitle() + "</span>");
            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueRelation.getRelationIssue().getTitle() + "</span>");
        }
+    }
+
+    // �븯�쐞 �씪媛� 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectDownIssues(IssueHistoryType type, Issue issue, StringBuilder description) {
+        if (type == IssueHistoryType.ADD) {
+            description.append("<span translate=\"issue.downIssueAddHistory\">�븯�쐞 �씪媛먯씠 異붽��릺�뿀�뒿�땲�떎. </span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issue.getTitle() + "</span>");
+        }else {
+            description.append("<span translate=\"issue.downIssueRemoveHistory\">�븯�쐞 �씪媛먯씠 �궘�젣�릺�뿀�뒿�땲�떎. </span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issue.getTitle() + "</span>");
+        }
+    }
+
+    // �씠�뒋 硫붿씪 �쟾�넚 �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectSendIssueMail(IssueHistoryType type, IssueForm issueForm, StringBuilder description) {
+        this.detectSendIssueMail(type, issueForm.getSendEmails(), description);
+    }
+
+    // �씠�뒋 硫붿씪 �쟾�넚 �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectSendIssueMail(IssueHistoryType type, List<String> sendMails, StringBuilder description) {
+        if (type == IssueHistoryType.SEND) {
+            description.append("<span translate=\"issue.sendIssueMailHistory\">�씠�뒋 硫붿씪 �쟾�넚�쓣 �셿猷뚰뻽�뒿�땲�떎. </span>");
+            if(sendMails != null && sendMails.size() > 0){
+                for (String sendEmail : sendMails){
+                    description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + CommonUtil.decryptAES128(sendEmail) + "</span>");
+                }
+            }
+        }
+    }
+
+    // �뾽泥� �젙蹂� 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectIssueCompany(IssueHistoryType type, Map<String, Object> param, CompanyField companyField, IssueCompany issueCompany, StringBuilder description) {
+        Long id = 0L;
+        if (param != null) {
+            id = MapUtil.getLong(param, "companyId");
+        }else if(companyField != null) {
+            id = companyField.getId();
+        }
+        Long companyFieldId = issueCompany.getCompanyField().getId();
+
+        if (type == IssueHistoryType.ADD) { //異붽� �븷 寃쎌슦
+            description.append("<span translate=\"issue.issueCompanyAddHistory\">�뾽泥� �젙蹂닿� 異붽��릺�뿀�뒿�땲�떎. </span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueCompany.getCompanyField().getName() + "</span>");
+        } else if (type == IssueHistoryType.MODIFY) { //�닔�젙 �븷 寃쎌슦
+            if (id != null && !companyFieldId.equals(id)) {
+                description.append("<span translate=\"issue.issueCompanyModifyHistory\">�뾽泥� �젙蹂닿� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("name") + "</span>");
+            }
+            if (companyFieldId.equals(id) && param.get("manager") != null && (issueCompany.getManager() == null || !issueCompany.getManager().equals(param.get("manager")))) {
+                description.append("<span translate=\"issue.issueCompanyModifyManagerHistory\">&nbsp;>&nbsp;�뾽泥� �젙蹂댁쓽 �떞�떦�옄媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("manager") + "</span>");
+            }
+            if (companyFieldId.equals(id) && param.get("tel") != null && (issueCompany.getTel() == null || !issueCompany.getTel().equals(param.get("tel")))) {
+                description.append("<span translate=\"issue.issueCompanyModifyTelHistory\">&nbsp;>&nbsp;�뾽泥� �젙蹂댁쓽 �쟾�솕踰덊샇媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("tel") + "</span>");
+            }
+            if (companyFieldId.equals(id) && param.get("email") != null && (issueCompany.getEmail() == null || !issueCompany.getEmail().equals(param.get("email")))) {
+                description.append("<span translate=\"issue.issueCompanyModifyEmailHistory\">&nbsp;>&nbsp;�뾽泥� �젙蹂댁쓽 �씠硫붿씪�씠 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("email") + "</span>");
+            }
+            if (companyFieldId.equals(id) && param.get("memo") != null && (issueCompany.getMemo() == null || !issueCompany.getMemo().equals(param.get("memo")))) {
+                description.append("<span translate=\"issue.issueCompanyModifyMemoHistory\">&nbsp;>&nbsp;�뾽泥� �젙蹂댁쓽 鍮꾧퀬媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("memo") + "</span>");
+            }
+        } else {
+            description.append("<span translate=\"issue.issueCompanyRemoveHistory\">�뾽泥� �젙蹂닿� �궘�젣�릺�뿀�뒿�땲�떎. " + issueCompany.getCompanyField().getName() + "</span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueCompany.getCompanyField().getName() + "</span>");
+        }
+    }
+
+    // ISP �젙蹂� 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectIssueIsp(IssueHistoryType type, Map<String, Object> param, IspField ispField, IssueIsp issueIsp, StringBuilder description) {
+        Long id = 0L;
+        if (param != null) {
+            id = MapUtil.getLong(param, "companyId");
+        } else if(ispField != null) {
+            id = ispField.getId();
+        }
+        Long ispFieldId = issueIsp.getIspField().getId();
+
+        if (type == IssueHistoryType.ADD) {
+            description.append("<span translate=\"issue.issueIspAddHistory\">ISP �젙蹂닿� 異붽��릺�뿀�뒿�땲�떎. </span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueIsp.getIspField().getName() + "</span>");
+        } else if (type == IssueHistoryType.MODIFY) {
+            if (id != null && !ispFieldId.equals(id)) { //�닔�젙 �븷 寃쎌슦
+                description.append("<span translate=\"issue.issueIspModifyHistory\">ISP �젙蹂닿� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("name") + "</span>");
+            }
+            if (ispFieldId.equals(id) && param.get("manager") != null && (issueIsp.getManager() == null || !issueIsp.getManager().equals(param.get("manager")))) {
+                description.append("<span translate=\"issue.issueIspModifyManagerHistory\">ISP �젙蹂댁쓽 �떞�떦�옄媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("manager") + "</span>");
+            }
+            if (ispFieldId.equals(id) && param.get("tel") != null && (issueIsp.getTel() == null || !issueIsp.getTel().equals(param.get("tel")))) {
+                description.append("<span translate=\"issue.issueIspModifyTelHistory\">ISP �젙蹂댁쓽 �쟾�솕踰덊샇媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("tel") + "</span>");
+            }
+            if (ispFieldId.equals(id) && param.get("email") != null && (issueIsp.getEmail() == null || !issueIsp.getEmail().equals(param.get("email")))) {
+                description.append("<span translate=\"issue.issueIspModifyEmailHistory\">ISP �젙蹂댁쓽 �씠硫붿씪�씠 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("email") + "</span>");
+            }
+            if (ispFieldId.equals(id) && param.get("memo") != null && (issueIsp.getMemo() == null || !issueIsp.getMemo().equals(param.get("memo")))) {
+                description.append("<span translate=\"issue.issueIspModifyMemoHistory\">ISP �젙蹂댁쓽 鍮꾧퀬媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("memo") + "</span>");
+            }
+        } else {
+            description.append("<span translate=\"issue.issueIspRemoveHistory\">ISP �젙蹂닿� �궘�젣�릺�뿀�뒿�땲�떎. " + issueIsp.getIspField().getName() + "</span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueIsp.getIspField().getName() + "</span>");
+        }
+    }
+
+    // �샇�뒪�똿 �젙蹂� 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectIssueHosting(IssueHistoryType type, Map<String, Object> param, HostingField hostingField, IssueHosting issueHosting, StringBuilder description) {
+        Long id = 0L;
+        if (param != null) {
+            id = MapUtil.getLong(param, "companyId");
+        }else if(hostingField != null) {
+            id = hostingField.getId();
+        }
+        Long hostingFieldId = issueHosting.getHostingField().getId();
+
+        if (type == IssueHistoryType.ADD) {
+            description.append("<span translate=\"issue.issueHostingAddHistory\">�샇�뒪�똿 �젙蹂닿� 異붽��릺�뿀�뒿�땲�떎. </span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueHosting.getHostingField().getName() + "</span>");
+        }else if(type == IssueHistoryType.MODIFY){
+            if(id != null && !hostingFieldId.equals(id)){ //�닔�젙 �븷 寃쎌슦
+                description.append("<span translate=\"issue.issueHostingModifyHistory\">�샇�뒪�똿 �젙蹂닿� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("name") + "</span>");
+            }
+            if(hostingFieldId.equals(id) && param.get("manager") != null && (issueHosting.getManager() == null || !issueHosting.getManager().equals(param.get("manager")))){
+                description.append("<span translate=\"issue.issueHostingModifyManagerHistory\">�샇�뒪�똿 �젙蹂댁쓽 �떞�떦�옄媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("manager") + "</span>");
+            }
+            if(hostingFieldId.equals(id) && param.get("tel") != null && (issueHosting.getTel() == null || !issueHosting.getTel().equals(param.get("tel")))){
+                description.append("<span translate=\"issue.issueHostingModifyTelHistory\">�샇�뒪�똿 �젙蹂댁쓽 �쟾�솕踰덊샇媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("tel") + "</span>");
+            }
+            if(hostingFieldId.equals(id) && param.get("email") != null && (issueHosting.getEmail() == null || !issueHosting.getEmail().equals(param.get("email")))){
+                description.append("<span translate=\"issue.issueHostingModifyEmailHistory\">�샇�뒪�똿 �젙蹂댁쓽 �씠硫붿씪�씠 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("email") + "</span>");
+            }
+            if(hostingFieldId.equals(id) && param.get("memo") != null && (issueHosting.getMemo() == null || !issueHosting.getMemo().equals(param.get("memo")))){
+                description.append("<span translate=\"issue.issueHostingModifyMemoHistory\">�샇�뒪�똿 �젙蹂댁쓽 鍮꾧퀬媛� 蹂�寃쎈릺�뿀�뒿�땲�떎. </span>");
+                description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + param.get("memo") + "</span>");
+            }
+        } else {
+            description.append("<span translate=\"issue.issueHostingRemoveHistory\">�샇�뒪�똿 �젙蹂닿� �궘�젣�릺�뿀�뒿�땲�떎. " + issueHosting.getHostingField().getName() + "</span>");
+            description.append("<span class=\"text-primary bold\">&nbsp;>&nbsp;" + issueHosting.getHostingField().getName() + "</span>");
+        }
     }
 
     //  �떞�떦�옄 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
@@ -535,6 +749,75 @@
 
         //  �씠�젰 �젙蹂대�� html �깭洹몃줈 留뚮뱾�뼱 以��떎.
         this.makeIssueHistoryHtml(description, title, beforeUser.toString(), afterUser.toString());
+    }
+
+    //  �떞�떦遺��꽌 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
+    @Override
+    public void detectIssueDepartment(Issue issue, IssueForm issueForm, StringBuilder description) {
+        boolean saveIssueRisk = false;  //  �씠�뒋 �쐞�뿕 愿�由ъ뿉 �씠以� ���옣�릺�뒗 寃껋쓣 諛⑹��븯湲� �쐞�븳 援щ텇 媛�
+
+        //  �떞�떦遺��꽌 �닔媛� �떖�씪議뚯쓣 寃쎌슦
+        if(issue.getIssueDepartments().size() != issueForm.getDepartmentIds().size()){
+            this.recodeIssueDepartment(issue, issueForm, description);
+            // �씠�뒋 �쐞�뿕 愿�由ъ뿉 �떞�떦遺��꽌 蹂�寃� �젙蹂대�� �뾽�뜲�씠�듃 �븳�떎. - �떞�떦遺��꽌 蹂�寃�
+            this.issueRiskService.modifyIssueRisk(issue, false, true, null);
+            saveIssueRisk = true;
+        }else if (issue.getIssueDepartments().size() > 0 && issueForm.getDepartmentIds().size() > 0) {//  �떞�떦遺��꽌 �닔�뒗 媛숈쑝�굹 �떞�떦遺��꽌媛� �떖�씪議뚯쓣 寃쎌슦
+            //  �씠�쟾 �떞�떦�옄 �몴�떆
+            for (IssueDepartment issueDepartment : issue.getIssueDepartments()) {
+                boolean change = true;
+                Department department = issueDepartment.getDepartment();
+
+                for (Long departmentId : issueForm.getDepartmentIds()) {
+                    if (department.getId().equals(departmentId)) {
+                        change = false;
+                        break;
+                    }
+                }
+
+                if (change) {
+                    //  �떞�떦遺��꽌 蹂�寃� �젙蹂� 湲곕줉
+                    this.recodeIssueDepartment(issue, issueForm, description);
+                    //  �떞�떦遺��꽌 �닔媛� �떖�씪議뚯쓣 寃쎌슦�뿉 ���옣�릺吏� �븡�븯�떎硫� �뿬湲곗꽌 �씠�뒋 �쐞�뿕 愿�由� ���옣�쓣 �븳�떎.
+                    if (!saveIssueRisk) {
+                        //  �씠�뒋 �쐞�뿕 愿�由ъ뿉 �떞�떦遺��꽌 蹂�寃� �젙蹂대�� �뾽�뜲�씠�듃�븳�떎. - �떞�떦遺��꽌 蹂�寃�
+                        this.issueRiskService.modifyIssueRisk(issue, false, true, null);
+                    }
+                    break;
+                }
+            }
+        }
+    }
+
+    //  �떞�떦遺��꽌 蹂�寃� �젙蹂� 湲곕줉
+    private void recodeIssueDepartment(Issue issue, IssueForm issueForm, StringBuilder description) {
+        String title = "<span translate=\"common.updateDepartment\">�떞�떦遺��꽌媛� 蹂�寃쎈릺�뿀�뒿�땲�떎.</span>";
+        StringBuilder beforeDepartment = new StringBuilder();
+
+        //  �씠�쟾 �떞�떦遺��꽌 �몴�떆
+        for (IssueDepartment issueDepartment : issue.getIssueDepartments()) {
+            beforeDepartment.append(issueDepartment.getDepartment().getDepartmentName());
+            beforeDepartment.append(", ");
+        }
+        //  �떞�떦遺��꽌媛� �뾾�뿀�쑝硫� �뾾�쓬�쑝濡� �몴�떆
+        if (issue.getIssueDepartments().size() < 1) {
+            beforeDepartment.append("<span translate=\"common.none\">�뾾�쓬</span>");
+        }
+
+        StringBuilder afterDepartment = new StringBuilder();
+        for (Long departmentId : issueForm.getDepartmentIds()) {
+            Department department = this.departmentService.getDepartment(departmentId);
+            afterDepartment.append(department.getDepartmentName());
+            afterDepartment.append(", ");
+        }
+
+        //  �떞�떦遺��꽌媛� �뾾�뿀�쑝硫� �뾾�쓬�쑝濡� �몴�떆
+        if (issueForm.getDepartmentIds().size() < 1) {
+            afterDepartment.append("<span translate=\"common.none\">�뾾�쓬</span>");
+        }
+
+        //  �씠�젰 �젙蹂대�� html �깭洹몃줈 留뚮뱾�뼱 以��떎.
+        this.makeIssueHistoryHtml(description, title, beforeDepartment.toString(), afterDepartment.toString());
     }
 
     //  �씠�뒋�뿉 泥⑤��맂 �뙆�씪�뿉 ���빐 蹂�寃� �젙蹂대�� 湲곕줉�븳�떎.
@@ -730,6 +1013,12 @@
         if (StringUtils.isEmpty(value)) {
             switch(customFieldType) {
                 case INPUT:
+                case NUMBER:
+                case DATETIME:
+                case IP_ADDRESS:
+                case EMAIL:
+                case SITE:
+                case TEL:
                     result = "<span translate=\"common.noValueEntered\">�엯�젰�븳 媛믪씠 �뾾�뒿�땲�떎.</span>";
                     break;
                 case SINGLE_SELECT:

--
Gitblit v1.8.0