From 2b0d6901597206d1c24abad0ff3ac0889f9194dd Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 목, 03 3월 2022 10:14:25 +0900
Subject: [PATCH] - 이슈 엑셀 임포트 시 부서 추가 코드 수정

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  835 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 600 insertions(+), 235 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 fe45e8d..e5c057b 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -46,7 +46,10 @@
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
+import java.text.ParseException;
 import java.util.*;
+
+import static kr.wisestone.owl.domain.enumType.CustomFieldType.*;
 
 @Service
 public class IssueServiceImpl extends AbstractServiceImpl<Issue, Long, JpaRepository<Issue, Long>> implements IssueService {
@@ -212,6 +215,9 @@
     @Autowired
     private IssueRelationMapper issueRelationMapper;
 
+    @Autowired
+    private WorkflowTransitionService workflowTransitionService;
+
     @Override
     protected JpaRepository<Issue, Long> getRepository() {
         return this.issueRepository;
@@ -262,6 +268,9 @@
             }
         } else if (issueApiForm.getIssueStatusId() == null){
             throw new ApiParameterException(this.messageAccessor.getMessage(MsgConstants.API_ISSUE_STATUS_NOT_EXIST));
+        } else if (!this.workflowTransitionService.contains(issueApiForm.getIssueStatusId(), workflow.getId())) {
+            //�씠�뒋 �긽�깭 �쑀�슚�꽦 �솗�씤
+            throw new ApiParameterException(this.messageAccessor.getMessage(MsgConstants.API_ISSUE_STATUS_NOT_EXIST_IN_WORKFLOW));
         }
 
         // �봽濡쒖젥�듃 �엯�젰
@@ -300,7 +309,7 @@
                     issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId());
                 }
 
-                // 醫낅즺�긽�깭媛� �븘�땶 以묐났�맂 �긽�쐞 �씠�뒋寃��깋
+                // 以묐났�맂 �긽�쐞 �씠�뒋寃��깋
                 List<Issue> issues = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId());
                 int size = issues.size();
                 if (size > 0) {
@@ -346,17 +355,17 @@
                     if(companyFields != null && companyFields.size() > 0) {
                         for (Map<String, Object> companyField : companyFields) {
                             CompanyFieldVo companyFieldVo = ConvertUtil.convertMapToClass(companyField, CompanyFieldVo.class);
-                            if(useValue.equals(companyFieldVo.getUrl())) {
+                            if(companyFieldVo.getUrl() != null && useValue.equals(companyFieldVo.getUrl())) {
                                 companyField.put("companyId", companyField.get("id"));
                                 issueCompanyFields.add(companyField);
-                                if(companyFieldVo.getIspId() != null) {
+                                if(companyFieldVo.getIspId() != null && companyFieldVo.getIspId() != -1) {
                                     Map<String, Object> ispField = this.ispFieldService.find(companyFieldVo.getIspId());
                                     if (ispField != null) {
                                         ispField.put("ispId", ispField.get("id"));
                                         issueIspFields.add(ispField);
                                     }
                                 }
-                                if(companyFieldVo.getHostingId() != null) {
+                                if(companyFieldVo.getHostingId() != null && companyFieldVo.getHostingId() != -1) {
                                     Map<String, Object> hostingField = this.hostingFieldService.find(companyFieldVo.getHostingId());
                                     if (hostingField != null) {
                                         hostingField.put("hostingId", hostingField.get("id"));
@@ -457,7 +466,7 @@
             issueCustomFieldValueCondition.setUseValue(concatUseValue);
             issueCustomFieldValueCondition.setUseValues(userValues);
             issueCustomFieldValueCondition.setIssueTypeId(issueApiform.getIssueTypeId());
-            issueCustomFieldValueCondition.setIssueStatusType("CLOSE");
+//            issueCustomFieldValueCondition.setIssueStatusType("CLOSE");
             List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition);
             if (results != null && results.size() > 0) {
                 for (Map<String, Object> result : results) {
@@ -480,6 +489,8 @@
     @Override
     @Transactional
     public Issue addIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) {
+        StringBuilder detectIssueChange = new StringBuilder();
+
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
         Workspace workspace = this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId());
         //  �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕
@@ -510,6 +521,12 @@
         if (issueForm.getParentIssueId() != null){
             Issue parentIssue = this.getIssue(issueForm.getParentIssueId());
             issue.setParentIssue(parentIssue);
+
+            // �긽�쐞 �씠�뒋媛� 醫낅즺�씪寃쎌슦 ��湲곕줈 蹂�寃�
+            IssueStatus parentIssueStatus = parentIssue.getIssueStatus();
+            if (parentIssueStatus.getIssueStatusType().equals(IssueStatusType.CLOSE)) {
+                parentIssue.setIssueStatus(issueStatus);
+            }
         }
 
         issue.setIssueNumber(this.issueNumberGeneratorService.generateIssueNumber(project));    //  媛� �봽濡쒖젥�듃�쓽 怨좎쑀 �씠�뒋 踰덊샇 �깮�꽦
@@ -522,11 +539,20 @@
         //  �떞�떦遺��꽌 吏��젙
         this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds());
         //  �뾽泥� �젙蹂� ���옣
-        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm);
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange);
         //  ISP �젙蹂� ���옣
-        this.issueIspService.modifyIssueIspField(issue, issueForm);
+        this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange);
         //  HOSTING �젙蹂� ���옣
-        this.issueHostingService.modifyIssueHostingField(issue, issueForm);
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange);
+
+        if (issueForm.getParentIssueId() != null){
+            Issue parentIssue = this.getIssue(issueForm.getParentIssueId());
+            if (issueForm.getIsApi().equals(Issue.IS_API_YES)
+                    || (issueForm.getInheritYn() != null && issueForm.getInheritYn())) {
+                //  �븯�쐞�씠�뒋�뿉 �긽�쐞�씠�뒋�쓽 �뙆�듃�꼫 �젙蹂� �쟻�슜
+                this.inheritPartners(issue, parentIssue);
+            }
+        }
 
         //  泥⑤� �뙆�씪 ���옣
         //  multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎.
@@ -564,15 +590,17 @@
     //  �븯�쐞�씠�뒋瑜� �깮�꽦�븳�떎.
     @Override
     @Transactional
-    public Issue addDownIssue(IssueForm issueForm, List<MultipartFile> multipartFiles) {
+    public Issue addDownIssue(Map<String, Object> resJsonData, IssueForm issueForm, List<MultipartFile> multipartFiles) {
         User user = this.webAppUtil.getLoginUserObject();
-        return addDownIssue(user, issueForm, multipartFiles);
+        return addDownIssue(resJsonData, user, issueForm, multipartFiles);
     }
 
     //  �븯�쐞�씠�뒋瑜� �깮�꽦�븳�떎.
     @Override
     @Transactional
-    public Issue addDownIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) {
+    public Issue addDownIssue(Map<String, Object> resJsonData, User user, IssueForm issueForm, List<MultipartFile> multipartFiles) {
+        StringBuilder detectIssueChange = new StringBuilder();
+
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
         Workspace workspace = this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId());
         //  �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕
@@ -615,11 +643,11 @@
         //  �떞�떦遺��꽌 吏��젙
         this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds());
         //  �뾽泥� �젙蹂� ���옣
-        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm);
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange);
         //  ISP �젙蹂� ���옣
-        this.issueIspService.modifyIssueIspField(issue, issueForm);
+        this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange);
         //  HOSTING �젙蹂� ���옣
-        this.issueHostingService.modifyIssueHostingField(issue, issueForm);
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange);
 
         //  泥⑤� �뙆�씪 ���옣
         //  multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎.
@@ -634,6 +662,7 @@
         this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.ADD, null);
         //  �씠�뒋 �쐞�뿕 愿�由� �깮�꽦
         this.issueRiskService.addIssueRisk(issue, project.getWorkspace());
+
         //  �쁺�냽�꽦 而⑦뀓�뒪�듃 鍮꾩슦湲�
         this.clear();
         //  �씠�뒋 �깮�꽦, �궘�젣�떆 �삁�빟 �씠硫붿씪�뿉 �벑濡앺빐�넃�뒗�떎.
@@ -643,13 +672,29 @@
         UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class);
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(userVo, ElasticSearchConstants.ISSUE_ADD));
 
+        IssueVo issueVo = this.convertToIssueVo(issue);
+        resJsonData.put(Constants.RES_KEY_CONTENTS, issueVo);
+
         return issue;
+    }
+
+    /**
+     * Issue瑜� IssueVo濡� 蹂��솚(�븯�쐞�씠�뒋�쓽 �뙆�듃�꼫 �젙蹂� �긽�냽 �떆 �븘�슂)
+     * @param issue Issue
+     * @return IssueVo
+     */
+    private IssueVo convertToIssueVo(Issue issue) {
+        IssueVo issueVo = ConvertUtil.copyProperties(issue, IssueVo.class);
+        issueVo.setInheritPartners(issue.getIssueType().getInheritPartners());
+        issueVo.setUsePartner(issue.getIssueType().getUsePartner());
+        return issueVo;
     }
 
     //  �뿰愿��씠�뒋瑜� �깮�꽦�븳�떎.
     @Override
     @Transactional
     public Issue addRelIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) {
+        StringBuilder detectIssueChange = new StringBuilder();
         //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
         Workspace workspace = this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId());
         //  �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕
@@ -692,11 +737,11 @@
         //  �떞�떦遺��꽌 吏��젙
         this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds());
         //  �뾽泥� �젙蹂� ���옣
-        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm);
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange);
         //  ISP �젙蹂� ���옣
-        this.issueIspService.modifyIssueIspField(issue, issueForm);
+        this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange);
         //  HOSTING �젙蹂� ���옣
-        this.issueHostingService.modifyIssueHostingField(issue, issueForm);
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange);
 
         //  泥⑤� �뙆�씪 ���옣
         //  multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎.
@@ -798,7 +843,7 @@
                 useValues.add(issueCustomFieldValueVo.getUseValue());
                 customField.put(issueCustomFieldValueVo.getCustomFieldVo().getName(), useValues);
             } else {
-                if (issueCustomFieldValueVo.getCustomFieldVo().getCustomFieldType().equals(CustomFieldType.INPUT.toString())) {
+                if (issueCustomFieldValueVo.getCustomFieldVo().getCustomFieldType().equals(INPUT.toString())) {
                     customField.put(issueCustomFieldValueVo.getCustomFieldVo().getName(), issueCustomFieldValueVo.getUseValue());
                 } else {
                     customField.put(issueCustomFieldValueVo.getCustomFieldVo().getName(), Lists.newArrayList(issueCustomFieldValueVo.getUseValue()));
@@ -852,15 +897,28 @@
         }
     }
 
-    //  �궇吏� �쑀�슚�꽦 泥댄겕
+    /**
+     * �궇吏� �쑀�슚�꽦 泥댄겕
+     * @param startDate �떆�옉 �씪�옄(臾몄옄)
+     * @param completeDate 醫낅즺 �씪�옄(臾몄옄)
+     */
     private void checkStartCompleteDate(String startDate, String completeDate) {
         if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(completeDate)) {
             Date start = DateUtil.convertStrToDate(startDate, "yy-MM-dd");
             Date end = DateUtil.convertStrToDate(completeDate, "yy-MM-dd");
-            if (start.getTime() > end.getTime()) {
-                throw new OwlRuntimeException(
-                        this.messageAccessor.getMessage(MsgConstants.DATE_PICKER_NOT_AVAILABLE));
-            }
+            checkStartCompleteDate(start, end);
+        }
+    }
+
+    /**
+     * �궇吏� �쑀�슚�꽦 泥댄겕
+     * @param start �떆�옉 �씪�옄
+     * @param end 醫낅즺 �씪�옄
+     */
+    private void checkStartCompleteDate(Date start, Date end) {
+        if (start.getTime() > end.getTime()) {
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.DATE_PICKER_NOT_AVAILABLE));
         }
     }
 
@@ -1241,6 +1299,9 @@
     private void setMapToIssueVo(List<Map<String, Object>> results, List<IssueVo> issueVos, IssueCondition issueCondition, User user) {
         for (Map<String, Object> result : results) {
             IssueVo issueVo = ConvertUtil.convertMapToClass(result, IssueVo.class);
+            if (MapUtil.getString(result, "inheritPartners") != null && MapUtil.getString(result, "inheritPartners").equals("1")) {
+                issueVo.setInheritPartners(true);
+            }
             issueVos.add(issueVo);
             issueCondition.addIssueIds(String.valueOf(issueVo.getId()));
         }
@@ -1521,7 +1582,7 @@
 
                 case "02": //  �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭,  �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂�, �뙎湲�, 湲곕줉�쓣 �뀑�똿�븳�떎.
                     this.setIssueDetail(issueVo, issue, user);    //  �씠�뒋 �긽�꽭 �젙蹂대�� �뀑�똿�븳�떎.
-                    this.setIssueTableConfigs(issue, issueVo);
+                    this.setIssueTableConfigs(issue, issueVo, issueCondition);
                     issueVo.setProjectVo(ConvertUtil.copyProperties(issue.getProject(), ProjectVo.class));
                     break;
             }
@@ -1533,8 +1594,9 @@
     }
 
     // �뀒�씠釉� �꽕�젙 �뀑�똿
-    private void setIssueTableConfigs(Issue issue, IssueVo issueVo) {
-        Long IssueTypeId = issue.getIssueType().getId();
+    private void setIssueTableConfigs(Issue issue, IssueVo issueVo, IssueCondition issueCondition) {
+        //Long IssueTypeId = issue.getIssueType().getId();
+        Long IssueTypeId = issueCondition.getIssueTypeId();
 
         for (int tableConfigType : IssueTableConfig.IssueTableTypes) {
             if (tableConfigType != IssueTableConfig.ISSUE_TABLE_TYPE_MAIN) {
@@ -1585,6 +1647,9 @@
                 this.setIssueCustomFields(downIssue, downIssueVo);   // �궗�슜�옄�젙�쓽�븘�뱶 �젙蹂� �꽭�똿
                 this.setIssueHistory(downIssue, downIssueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
                 this.setIssueComments(downIssue, downIssueVo);  //  �뙎湲� �젙蹂� �뀑�똿
+                this.setIssueCompanyField(downIssue, downIssueVo);  //�뾽泥� �젙蹂� �꽭�똿
+                this.setIssueIspField(downIssue, downIssueVo);  //ISP �젙蹂� �꽭�똿
+                this.setIssueHostingField(downIssue, downIssueVo);  //HOSTING �젙蹂� �꽭�똿
 
                 downIssueVo.setModifyPermissionCheck(issueVo.getModifyPermissionCheck());
 
@@ -1598,6 +1663,11 @@
     @Override
     @Transactional(readOnly = true)
     public void setIssueDetail(IssueVo issueVo, Issue issue, User user) {
+        //  �씠�뒋 �닔�젙 沅뚰븳�쓣 媛뽮퀬 �엳�뒗吏� �솗�씤
+        if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user, issueVo.getDepartmentVos())) {
+            issueVo.setModifyPermissionCheck(Boolean.TRUE);
+        }
+
         issueVo.setProjectVo(ConvertUtil.copyProperties(issue.getProject(), ProjectVo.class));
         issueVo.setIssueTypeVo(ConvertUtil.copyProperties(issue.getIssueType(), IssueTypeVo.class));
         IssueStatusVo issueStatusVo = ConvertUtil.copyProperties(issue.getIssueStatus(), IssueStatusVo.class, "issueStatusType");
@@ -1633,11 +1703,6 @@
         this.setIssueIspField(issue, issueVo);  //ISP �젙蹂� �꽭�똿
         this.setIssueHostingField(issue, issueVo);  //HOSTING �젙蹂� �꽭�똿
         this.setParentIssue(issue,issueVo); //�긽�쐞 �씠�뒋 �젙蹂� �꽭�똿
-
-        //  �씠�뒋 �닔�젙 沅뚰븳�쓣 媛뽮퀬 �엳�뒗吏� �솗�씤
-        if (this.checkHasPermission(issueVo, issueVo.getUserVos(), user, issueVo.getDepartmentVos())) {
-            issueVo.setModifyPermissionCheck(Boolean.TRUE);
-        }
     }
 
     //  �긽�쐞�씪媛� �젙蹂� 異붽�
@@ -1701,6 +1766,25 @@
                 this.setRegister(relationIssue, relIssueVo); // �벑濡앹옄
                 this.setIssueDepartment(relationIssue, relIssueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
                 this.setIssueCustomFields(relationIssue, relIssueVo);   // �궗�슜�옄�젙�쓽�븘�뱶 �젙蹂� �꽭�똿
+
+                Set<IssueCompany> issueCompanies = relationIssue.getIssueCompanies();
+                Iterator<IssueCompany> itrCompany = issueCompanies.iterator();
+                while (itrCompany.hasNext()) {
+                    issueRelationVo.addIssueCompanyVo(ConvertUtil.copyProperties(itrCompany.next(), IssueCompanyVo.class));
+                }
+
+                Set<IssueIsp> issueIsps = relationIssue.getIssueIspFields();
+                Iterator<IssueIsp> itrIsp = issueIsps.iterator();
+                while (itrIsp.hasNext()) {
+                    issueRelationVo.addIssueIspVo(ConvertUtil.copyProperties(itrIsp.next(), IssueIspVo.class));
+                }
+
+                Set<IssueHosting> issueHostings = relationIssue.getIssueHostingFields();
+                Iterator<IssueHosting> itrHosting = issueHostings.iterator();
+                while (itrHosting.hasNext()) {
+                    issueRelationVo.addIssueHostingVo(ConvertUtil.copyProperties(itrHosting.next(), IssueHostingVo.class));
+                }
+
                 issueVo.addIssueRelationVo(issueRelationVo);
             }
         } else {
@@ -1833,6 +1917,7 @@
             issueCustomFieldValueCondition.setUseValue(concatUseValue);
             issueCustomFieldValueCondition.setUseValues(userValues);
             issueCustomFieldValueCondition.setIssueTypeId(issueApiform.getIssueTypeId());
+            issueCustomFieldValueCondition.setIssueStatusType("CLOSE");
             List<Map<String, Object>> results = this.issueMapper.findByCustomFieldValue(issueCustomFieldValueCondition);
             if (results != null && results.size() > 0) {
                 for (Map<String, Object> result : results) {
@@ -2057,20 +2142,30 @@
         this.checkNotHaveIssueIdAttachedFile(issue, issueForm);
         //  �궗�슜�옄 �젙�쓽 �븘�뱶 ���옣
         this.issueCustomFieldValueService.modifyIssueCustomFieldValue(issue, issueForm.getIssueCustomFields());
-        //  �씠�뒋 �씠�젰 �벑濡�
-        if (!StringUtils.isEmpty(detectIssueChange.toString())) {
-            this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.MODIFY, detectIssueChange.toString());
-        }
         //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
         UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class);
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(userVo, ElasticSearchConstants.ISSUE_MODIFY));
 
         //  �뾽泥� �젙蹂� ���옣
-        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm);
+        this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange);
         //  ISP �젙蹂� ���옣
-        this.issueIspService.modifyIssueIspField(issue, issueForm);
+        this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange);
         //  HOSTING �젙蹂� ���옣
-        this.issueHostingService.modifyIssueHostingField(issue, issueForm);
+        this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange);
+
+        //  �뙆�듃�꼫�젙蹂� �븯�쐞�씠�뒋 �긽�냽
+        List<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId());
+        if (issueForm.getInheritYn() != null && issueForm.getInheritYn()
+                && downIssues != null && downIssues.size() > 0) {
+            for (Issue downIssue : downIssues) {
+                this.inheritPartners(downIssue, issue);
+            }
+        }
+
+        //  �씠�뒋 �씠�젰 �벑濡�
+        if (!StringUtils.isEmpty(detectIssueChange.toString())) {
+            this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.MODIFY, detectIssueChange.toString());
+        }
 
         return issue;
     }
@@ -2715,6 +2810,9 @@
         excelInfo.addAttrInfos(new ExportExcelAttrVo("register", this.messageAccessor.message("common.register"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �벑濡앹옄
         excelInfo.addAttrInfos(new ExportExcelAttrVo("period", this.messageAccessor.message("common.period"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 湲곌컙
         excelInfo.addAttrInfos(new ExportExcelAttrVo("modifyDate", this.messageAccessor.message("common.modifyDate"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // 理쒖쥌 蹂�寃쎌씪
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("companyName", this.messageAccessor.message("common.company"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �뾽泥�
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("ispName", this.messageAccessor.message("common.isp"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // ISP
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("hostingName", this.messageAccessor.message("common.hosting"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �샇�뒪�똿
 
 
         //  �궗�슜�옄 �젙�쓽 �븘�뱶瑜� �궗�슜�븳 �씠�뒋瑜� 李얜뒗�떎. 留뚯빟 �씠�뒋媛� �뾾�떎硫� �뿬湲곗꽌 �씠�뒋 議고쉶媛� �걹�궃�떎.
@@ -2775,8 +2873,16 @@
 
         for (IssueVo issueVo : issueVos) {
             for (Map<String, Object> issueCustomFieldValue : issueCustomFieldValues) {
+                int count = 0;
+                Map<String, Object> useValues = new HashMap<>();
+
                 if (issueVo.getId().equals(MapUtil.getLong(issueCustomFieldValue, "issueId"))) {
                     IssueCustomFieldValueVo issueCustomFieldValueVo = new IssueCustomFieldValueVo();
+
+                    useValues.put("useValue"+count, MapUtil.getString(issueCustomFieldValue, "useValue"));
+                    useValues.put("customFieldId", MapUtil.getLong(issueCustomFieldValue, "customFieldId"));
+                    issueCustomFieldValueVo.setUseValues(useValues);
+
                     issueCustomFieldValueVo.setUseValue(MapUtil.getString(issueCustomFieldValue, "useValue"));
 
                     CustomFieldVo customFieldVo = new CustomFieldVo();
@@ -2798,25 +2904,29 @@
             CompanyField companyField = issueCompany.getCompanyField();
             if (companyField != null) {
                 issueCompanyVo.setCompanyId(issueCompany.getCompanyField().getId());
-                if (issueCompany.getCompanyTypeId() != null) {
+                if (issueCompany.getCompanyTypeId() != null && issueCompany.getCompanyTypeId() != -1) {
                     CompanyFieldCategory companyType = this.companyFieldCategoryService.find(issueCompany.getCompanyTypeId());
                     issueCompanyVo.setCompanyTypeName(companyType.getUseValue());
                 }
-                if (issueCompany.getParentSectorId() != null) {
+                if (issueCompany.getParentSectorId() != null && issueCompany.getParentSectorId() != -1) {
                     CompanyFieldCategory parentSector = this.companyFieldCategoryService.find(issueCompany.getParentSectorId());
                     issueCompanyVo.setParentSectorName(parentSector.getUseValue());
                 }
-                if (issueCompany.getChildSectorId() != null) {
+                if (issueCompany.getChildSectorId() != null && issueCompany.getChildSectorId() != -1) {
                     CompanyFieldCategory childSector = this.companyFieldCategoryService.find(issueCompany.getChildSectorId());
                     issueCompanyVo.setChildSectorName(childSector.getUseValue());
                 }
-                if (issueCompany.getRegionId() != null) {
+                if (issueCompany.getRegionId() != null && issueCompany.getRegionId() != -1) {
                     CompanyFieldCategory region = this.companyFieldCategoryService.find(issueCompany.getRegionId());
                     issueCompanyVo.setRegionName(region.getUseValue());
                 }
-                if (issueCompany.getStatusId() != null) {
-                    CompanyFieldCategory status = this.companyFieldCategoryService.find(issueCompany.getStatusId());
-                    issueCompanyVo.setStatusName(status.getUseValue());
+                if (issueCompany.getStatusId() != null && issueCompany.getStatusId() != -1) {
+                    if (issueCompany.getStatusName() != null && !issueCompany.getStatusName().equals("")) {
+                        issueCompanyVo.setStatusName(issueCompany.getStatusName());
+                    } else {
+                        CompanyFieldCategory status = this.companyFieldCategoryService.find(issueCompany.getStatusId());
+                        issueCompanyVo.setStatusName(status.getUseValue());
+                    }
                 }
             }
             issueCompanyVos.add(issueCompanyVo);
@@ -2887,6 +2997,9 @@
                 result.put("departments", CommonUtil.convertDepartmentVosToString(issueVo.getDepartmentVos()));
                 result.put("priorityName", issueVo.getPriorityName());
                 result.put("severityName", issueVo.getSeverityName());
+                result.put("companyName", issueVo.getCompanyName());
+                result.put("ispName", issueVo.getIspName());
+                result.put("hostingName", issueVo.getHostingName());
 
                 UserVo register = this.userService.removeSensitiveUser(issueVo.getRegisterId());
                 //  �벑濡앹옄
@@ -2964,6 +3077,9 @@
         excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.importance"), 5, 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)); // 醫낅즺�씪
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.company"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �뾽泥�
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.isp"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // ISP
+        excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.hosting"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �샇�뒪�똿
         //  �봽濡쒖젥�듃�뿉 �뿰寃곕맂 �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� 異붿텧�븯�뿬 �뿊�� download �뀥�뵆由우쓣 留뚮뱺�떎.
         this.makeIssueExcelTemplateCustomFields(excelInfo, conditions);
         //  �뿊���뿉 �꽔�쓣 �뜲�씠�꽣 - IssueVos �뜲�씠�꽣瑜� �뿊���뿉�꽌 �몴�떆�븷 �닔 �엳�뒗 �뜲�씠�꽣濡� 蹂�寃쏀븳�떎.
@@ -3003,15 +3119,23 @@
             Map<Long, Long> issueNumberMaps = new HashMap<>();  //  �씠�뒋 踰덊샇 紐⑥쓬
             Map<String, Long> issueTypeCustomFieldMaps = new HashMap<>(); //  �씠�뒋 ���엯 + �궗�슜�옄 �젙�쓽 �븘�뱶 �뿰寃� �젙蹂�
 
+            Map<String, CompanyField> companyFieldMaps = new HashMap<>();   //�뾽泥� 紐⑥쓬
+            Map<String, IspField> ispFieldMaps = new HashMap<>();   //isp 紐⑥쓬
+            Map<String, HostingField> hostingFieldMaps = new HashMap<>();   //�샇�뒪�똿 紐⑥쓬
+
             Workspace workspace = this.workspaceService.getWorkspace(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());  //  �씠�뒋瑜� �꽔�쑝�젮�뒗 �뾽臾� 怨듦컙
             //  �씠�뒋�쓽 二쇱슂 �냽�꽦�쓣 map �뿉 ���옣�븯�뿬 �뿊�� import �뿉�꽌 吏��젙�븳 ���긽(�씠�뒋 �냽�꽦)�쓣 鍮좊Ⅴ寃� 李얠쓣 �닔 �엳寃� �븳�떎.
-            this.IssueAttributeMapToList(issueForm, priorityMaps, severityMaps, departmentMaps, customFieldMaps, issueTypeCustomFieldMaps);
+            this.IssueAttributeMapToList(issueForm, priorityMaps, severityMaps, departmentMaps, customFieldMaps,
+                    issueTypeCustomFieldMaps, companyFieldMaps, ispFieldMaps, hostingFieldMaps);
             //  0.237 - 0.230
 
             List<IssueForm> issueForms = Lists.newArrayList();
             List<String> headers = Lists.newArrayList();
 
             Workbook workbook;
+
+            IssueType issueType = new IssueType();
+            Workflow workflow = new Workflow();
 
             workbook = WorkbookFactory.create(multipartFile.getInputStream());
             Sheet sheet = workbook.getSheetAt(0);
@@ -3048,14 +3172,20 @@
                 //  1踰� �뿤�뜑遺��꽣 �뜲�씠�꽣 �쁺�뿭
                 if (rowIndex > 1) {
                     //  �씠�뒋濡� �벑濡앺븯湲� �쐞�빐 IssueForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎.
-                    IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, departmentMaps, customFieldMaps, headers);
+                    IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, customFieldMaps,
+                            companyFieldMaps, ispFieldMaps, hostingFieldMaps, headers);
                     ConvertUtil.copyProperties(issueForm, newIssueForm);
 
+                    Project project = this.projectService.getProject(newIssueForm.getProjectId());
+                    Long issueNumber = this.issueNumberGeneratorService.generateIssueNumber(project);
+                    newIssueForm.setIssueNumber(issueNumber);
 
+                    issueType = this.issueTypeService.getIssueType(newIssueForm.getIssueTypeId());
+                    workflow = issueType.getWorkflow();
+                    IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(workflow);
 
+                    newIssueForm.setIssueStatusId(issueStatus.getId());
                     issueForms.add(newIssueForm);
-
-
                 }
             }
 
@@ -3064,51 +3194,28 @@
             }
             //  1.176
 
-
             //  �씠�뒋 �벑濡�
-//            this.issueMapper.insertBatch(issueForms);
+            this.issueMapper.insertBatch(issueForms);
 
             for (IssueForm saveIssueForm : issueForms) {
                 Issue issue = new Issue();
                 ConvertUtil.copyProperties(saveIssueForm, issue);
 
-                IssueType issueType = this.issueTypeService.getIssueType(saveIssueForm.getIssueTypeId());
-                Workflow workflow = issueType.getWorkflow();
-
-                Project project = this.projectService.getProject(saveIssueForm.getProjectId());
-                Long issueNumber = this.issueNumberGeneratorService.generateIssueNumber(project);
-
-                IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(workflow);
-
-                issue.setPriority(this.priorityService.getPriority(saveIssueForm.getPriorityId()));
-                issue.setSeverity(this.severityService.getSeverity(saveIssueForm.getSeverityId()));
-                issue.setIssueStatus(issueStatus);
-                issue.setIssueType(issueType);
-                issue.setProject(project);
-                issue.setIssueNumber(issueNumber);
-                if (saveIssueForm.getParentIssueId() != null && saveIssueForm.getParentIssueId() > -1) {
-                    issue.setParentIssue(this.getIssue(saveIssueForm.getParentIssueId()));
+                if (issueForm.getInheritYn() != null && issueForm.getInheritYn() && issueForm.getParentIssueId() != null) {
+                    Issue parentIssue = this.getIssue(issueForm.getParentIssueId());
+                    //  �긽�쐞�씠�뒋�쓽 �뙆�듃�꼫 �젙蹂� �긽�냽
+                    this.inheritPartners(issue, parentIssue);
                 }
-
-                issue = this.issueRepository.saveAndFlush(issue);
 
                 saveIssueForm.setId(issue.getId());
-
-                IssueDepartment issueDepartment = new IssueDepartment();
-                issueDepartment.setIssue(issue);
-                issueDepartment.setWorkspace(workspace);
-
+                
+                //  �썙�겕�뵆濡쒖슦 ��湲� �긽�깭�쓽 遺��꽌 異붽�
                 List<Long> departmentsIds = this.workflowDepartmentService.findFirstDepartmentIds(workflow);
                 if (departmentsIds != null && departmentsIds.size() > 0) {
-                    for (Long departmentId : departmentsIds) {
-                        issueDepartment.setDepartment(this.departmentService.getDepartment(departmentId));
-                    }
-                    issue.addIssueDepartment(issueDepartment);
+                    this.issueDepartmentService.add(departmentsIds, workspace, issue);
                 }
-
-                saveIssueForm.setIssueStatusId(issueStatus.getId());
+                this.setIssuePartners(saveIssueForm, issue);
             }
-
 
             //  0.416 - 0.439
 
@@ -3139,6 +3246,66 @@
             //  利앷��맂 �씠�뒋 踰덊샇瑜� �뾽�뜲�씠�듃 �븳�떎.
 //            issueNumberMaps.put(issueForm.getProjectId(), issueForm.getProjectId());
 //            this.issueNumberGeneratorService.updateIssueNumber(issueNumberMaps);
+        }
+    }
+
+    /**
+     * �뿊��濡� �엯�젰�븳 �뙆�듃�꼫 �젙蹂� ���옣
+     * @param issueForm IssueForm
+     */
+    private void setIssuePartners(IssueForm issueForm, Issue issue) {
+        //issueCompany �벑濡�
+        if (issueForm.getIssueCompanyFields() != null && issueForm.getIssueCompanyFields().size() > 0) {
+            for (Map<String, Object> issueCompanyMap : issueForm.getIssueCompanyFields()) {
+                CompanyField companyField =  ConvertUtil.convertMapToClass(issueCompanyMap, CompanyField.class);
+                IssueCompany issueCompany = ConvertUtil.convertMapToClass(issueCompanyMap, IssueCompany.class, "id", "registerDate", "modifyDate");
+                issueCompany.setCompanyField(companyField);
+                issueCompany.setIssue(issue);
+                this.issueCompanyRepository.saveAndFlush(issueCompany);
+
+                //  �궗�슜�옄媛� ISP瑜� 吏곸젒 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 �뾽泥댁뿉 �벑濡앸릺�뼱�엳�뒗 ISP �꽕�젙
+                if (issueForm.getIssueIspFields() == null || issueForm.getIssueIspFields().size() < 1) {
+                    //  �뾽泥댁쓽 ISP媛� �엳�뒗 寃쎌슦 issueISP �벑濡�
+                    if (companyField.getIspId() != null && companyField.getIspId() != -1) {
+                        IspField ispField = this.ispFieldService.getIsp(companyField.getIspId());
+                        IssueIsp issueIsp = ConvertUtil.copyProperties(ispField, IssueIsp.class, "id", "registerDate", "modifyDate");
+                        issueIsp.setIspField(ispField);
+                        issueIsp.setIssue(issue);
+                        this.issueIspRepository.saveAndFlush(issueIsp);
+                    }
+                }
+                //  �궗�슜�옄媛� �샇�뒪�똿�쓣 吏곸젒 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 �뾽泥댁뿉 �벑濡앸릺�뼱�엳�뒗 �샇�뒪�똿 �꽕�젙
+                if (issueForm.getIssueHostingFields() == null || issueForm.getIssueHostingFields().size() < 1) {
+                    //  �뾽泥댁쓽 �샇�뒪�똿�씠 �엳�뒗 寃쎌슦 issueHosting �벑濡�
+                    if (companyField.getHostingId() != null && companyField.getHostingId() != -1) {
+                        HostingField hostingField = this.hostingFieldService.getHosting(companyField.getHostingId());
+                        IssueHosting issueHosting = ConvertUtil.copyProperties(hostingField, IssueHosting.class, "id", "registerDate", "modifyDate");
+                        issueHosting.setHostingField(hostingField);
+                        issueHosting.setIssue(issue);
+                        this.issueHostingRepository.saveAndFlush(issueHosting);
+                    }
+                }
+            }
+        }
+        //issueIsp �벑濡�
+        if (issueForm.getIssueIspFields() != null && issueForm.getIssueIspFields().size() > 0) {
+            for (Map<String, Object> issueIspMap : issueForm.getIssueIspFields()) {
+                IssueIsp issueIsp = ConvertUtil.convertMapToClass(issueIspMap, IssueIsp.class, "id", "registerDate", "modifyDate");
+                IspField ispField = ConvertUtil.convertMapToClass(issueIspMap, IspField.class);
+                issueIsp.setIspField(ispField);
+                issueIsp.setIssue(issue);
+                this.issueIspRepository.saveAndFlush(issueIsp);
+            }
+        }
+        //issueHosting �벑濡�
+        if (issueForm.getIssueHostingFields() != null && issueForm.getIssueHostingFields().size() > 0) {
+            for (Map<String, Object> issueHostingMap : issueForm.getIssueHostingFields()) {
+                IssueHosting issueHosting = ConvertUtil.convertMapToClass(issueHostingMap, IssueHosting.class, "id", "registerDate", "modifyDate");
+                HostingField hostingField = ConvertUtil.convertMapToClass(issueHostingMap, HostingField.class);
+                issueHosting.setHostingField(hostingField);
+                issueHosting.setIssue(issue);
+                this.issueHostingRepository.saveAndFlush(issueHosting);
+            }
         }
     }
 
@@ -3239,29 +3406,9 @@
                 issueCustomField.put("registerId", this.webAppUtil.getLoginId());
                 issueCustomFieldValueMaps.add(issueCustomField);
             }
-            IssueForm partners = this.findCompanyField(issueForm); // 媛숈� �룄硫붿씤 �뾽泥� 李얘린
-            Issue issue = this.findOne(issueForm.getId());
-            if (partners.getIssueCompanyFields() != null && partners.getIssueCompanyFields().size() > 0) {
-                for (Map<String, Object> company : partners.getIssueCompanyFields()) {
-                    IssueCompany issueCompany = ConvertUtil.convertMapToClass(company, IssueCompany.class);
-                    issueCompany.setIssue(issue);
-                    this.issueCompanyRepository.saveAndFlush(issueCompany);
-                }
-            }
-            if (partners.getIssueIspFields() != null && partners.getIssueIspFields().size() > 0) {
-                for (Map<String, Object> isp : partners.getIssueIspFields()) {
-                    IssueIsp issueIsp = ConvertUtil.convertMapToClass(isp, IssueIsp.class);
-                    issueIsp.setIssue(issue);
-                    this.issueIspRepository.saveAndFlush(issueIsp);
-                }
-            }
-            if (partners.getIssueHostingFields() != null && partners.getIssueHostingFields().size() > 0) {
-                for (Map<String, Object> hosting : partners.getIssueHostingFields()) {
-                    IssueHosting issueHosting = ConvertUtil.convertMapToClass(hosting, IssueHosting.class);
-                    issueHosting.setIssue(issue);
-                    this.issueHostingRepository.saveAndFlush(issueHosting);
-                }
-            }
+
+            //  �뿊���뿉 �뾽泥대챸�쓣 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 媛숈� �룄硫붿씤 �뾽泥� 李얘린
+            this.findPartnerByDomain(issueForm);
         }
 
         if (issueCustomFieldValueMaps.size() > 0) {
@@ -3269,9 +3416,50 @@
         }
     }
 
+    /**
+     * �뿊���뿉 �뾽泥대챸�쓣 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 媛숈� �룄硫붿씤 �뾽泥� 李얘린
+     * @param issueForm IssueForm
+     */
+    private void findPartnerByDomain(IssueForm issueForm) {
+        if (issueForm.getIssueCompanyFields() == null || issueForm.getIssueCompanyFields().size() < 1) {
+            // 媛숈� �룄硫붿씤 �뾽泥� 李얘린
+            IssueForm partners = this.findCompanyField(issueForm);
+            Issue issue = this.findOne(issueForm.getId());
+            if (partners.getIssueCompanyFields() != null && partners.getIssueCompanyFields().size() > 0) {
+                for (Map<String, Object> company : partners.getIssueCompanyFields()) {
+                    IssueCompany issueCompany = ConvertUtil.convertMapToClass(company, IssueCompany.class);
+                    CompanyField companyField = ConvertUtil.convertMapToClass(company, CompanyField.class);
+                    issueCompany.setCompanyField(companyField);
+                    issueCompany.setIssue(issue);
+
+                    this.issueCompanyRepository.saveAndFlush(issueCompany);
+                }
+            }
+            if (partners.getIssueIspFields() != null && partners.getIssueIspFields().size() > 0) {
+                for (Map<String, Object> isp : partners.getIssueIspFields()) {
+                    IssueIsp issueIsp = ConvertUtil.convertMapToClass(isp, IssueIsp.class);
+                    IspField ispField = ConvertUtil.convertMapToClass(isp, IspField.class);
+                    issueIsp.setIspField(ispField);
+                    issueIsp.setIssue(issue);
+                    this.issueIspRepository.saveAndFlush(issueIsp);
+                }
+            }
+            if (partners.getIssueHostingFields() != null && partners.getIssueHostingFields().size() > 0) {
+                for (Map<String, Object> hosting : partners.getIssueHostingFields()) {
+                    IssueHosting issueHosting = ConvertUtil.convertMapToClass(hosting, IssueHosting.class);
+                    HostingField hostingField = ConvertUtil.convertMapToClass(hosting, HostingField.class);
+                    issueHosting.setHostingField(hostingField);
+                    issueHosting.setIssue(issue);
+                    this.issueHostingRepository.saveAndFlush(issueHosting);
+                }
+            }
+        }
+    }
+
     //  �씠�뒋�쓽 二쇱슂 �냽�꽦�쓣 map �뿉 ���옣�븯�뿬 �뿊�� import �뿉�꽌 吏��젙�븳 ���긽(�씠�뒋 �냽�꽦)�쓣 鍮좊Ⅴ寃� 李얠쓣 �닔 �엳寃� �븳�떎.
     private void IssueAttributeMapToList(IssueForm issueForm, Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps,
-                                         Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps,Map<String, Long> issueTypeCustomFieldMaps) {
+                                         Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps,Map<String, Long> issueTypeCustomFieldMaps,
+                                         Map<String, CompanyField> companyFieldMaps, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps) {
 
         Project project = this.projectService.getProject(issueForm.getProjectId());
 
@@ -3298,43 +3486,112 @@
         for (CustomField customField : customFields) {
             customFieldMaps.put(customField.getName(), customField);
         }
+
+        //  �뾽泥� �젙蹂대�� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮�
+        List<CompanyField> companyFields = this.companyFieldService.findAll();
+        for (CompanyField companyField : companyFields) {
+            companyFieldMaps.put(companyField.getName(), companyField);
+        }
+        //  ISP �젙蹂대�� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮�
+        List<IspField> ispFields = this.ispFieldService.findAll();
+        for (IspField ispField : ispFields) {
+            ispFieldMaps.put(ispField.getName(), ispField);
+        }
+        //  �샇�뒪�똿 �젙蹂대�� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮�
+        List<HostingField> hostingFields = this.hostingFieldService.findAll();
+        for (HostingField hostingField : hostingFields) {
+            hostingFieldMaps.put(hostingField.getName(), hostingField);
+        }
+    }
+
+    /**
+     * cell String�쑝濡� 蹂��솚 �븿�닔
+     * @param cell Cell
+     * @param isNull boolean
+     * @return String
+     */
+    private String stringToCell (Cell cell, boolean isNull) {
+        String cellStr = "";
+        if (!isNull) {
+            cellStr = CommonUtil.convertExcelStringToCell(cell);
+            //  怨듬갚 �젣嫄�
+            cell.setCellValue(cellStr.trim());
+        } else {
+            cell.setCellValue(cellStr);
+        }
+        return cellStr;
+    }
+
+    /**
+     * cell NULL 泥댄겕 �븿�닔
+     * 鍮� 媛믪씠 �븘�땶 cell 泥댄겕
+     * @param cell Cell
+     * @return boolean
+     */
+    private Boolean cellNullCheck (Cell cell) {
+        int cellType = cell.getCellType();
+        if (cellType < Cell.CELL_TYPE_BLANK) {
+            if (cellType == Cell.CELL_TYPE_STRING) {
+                if (cell.getStringCellValue() != null && !cell.getStringCellValue().equals("")) {
+                    return false;
+                }
+            } else {
+                return false;
+            }
+        }
+        return true;
     }
 
     //  �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 form �쑝濡� �삷湲대떎.
     private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, Priority> priorityMaps,
-                                               Map<String, Severity> severityMaps, Map<String, DepartmentVo> departmentMaps,
-                                               Map<String, CustomField> customFieldMaps, List<String> headers) {
+                                               Map<String, Severity> severityMaps, Map<String, CustomField> customFieldMaps,
+                                               Map<String, CompanyField> companyFieldMaps, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps,
+                                               List<String> headers) throws ParseException {
         IssueForm issueForm = new IssueForm();
         issueForm.setRegisterId(this.webAppUtil.getLoginId());
-        Project project = null;
 
         //  �젣紐�, �궡�슜, �봽濡쒖젥�듃 �궎, �씠�뒋 ���엯, �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦�옄, �떆�옉�씪, 醫낅즺�씪, �궗�슜�옄 �젙�쓽 �븘�뱶
         for (int cellIndex = 0; cellIndex < headers.size(); cellIndex++) {
             Cell cell = row.getCell(cellIndex);
+
+            String cellStr = "";
+            boolean isNull = true;
+
+            if (cell != null) {
+                isNull = cellNullCheck(cell);
+                cellStr = stringToCell(cell, isNull); //cell�쓣 String�쑝濡� 蹂��솚
+            }
+
             switch (cellIndex) {
                 case 0:
                     //  �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎.
-                    this.setIssueFormTitle(cell, issueForm, rowIndex);
+                    if (isNull) {
+                        throw new OwlRuntimeException(
+                                this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex));
+                    }
+                    this.setIssueFormTitle(cellStr, issueForm, rowIndex);
                     break;
 
                 case 1:    //  �궡�슜
-                    if (cell != null) {
-                        issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell));
-                    } else {
-                        //  null �엯�젰 諛⑹�
-                        issueForm.setDescription("");
-                    }
-
+                    issueForm.setDescription(cellStr);
                     break;
 
                 case 2:
                     //  �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎.
-                    this.setIssueFormPriority(cell, priorityMaps, issueForm, rowIndex);
+                    if (isNull) {
+                        throw new OwlRuntimeException(
+                                this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex));
+                    }
+                    this.setIssueFormPriority(cellStr, priorityMaps, issueForm, rowIndex);
                     break;
 
                 case 3:
                     //  以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎.
-                    this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex);
+                    if (isNull) {
+                        throw new OwlRuntimeException(
+                                this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex));
+                    }
+                    this.setIssueFormSeverity(cellStr, severityMaps, issueForm, rowIndex);
                     break;
                 /*case 6:
                     //  �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎.
@@ -3342,34 +3599,74 @@
                     break;*/
                 case 4:
                     //  �떆�옉�씪�쓣 IssueForm �뿉 ���옣�븳�떎.
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setIssueFormPeriod(cell, issueForm, true, rowIndex);
-                    }
+                    this.setIssueFormPeriod(cellStr, issueForm, true, rowIndex, isNull);
                     break;
                 case 5:
                     //  醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎.
-                    if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) {
-                        this.setIssueFormPeriod(cell, issueForm, false, rowIndex);
-                    }
+                    this.setIssueFormPeriod(cellStr, issueForm, false, rowIndex, isNull);
+                    break;
+                case 6:
+                    //  �뾽泥대�� IssueForm �뿉 ���옣�븳�떎.
+                    this.setIssueFormCompanyField(cellStr, companyFieldMaps, issueForm, rowIndex);
+                    break;
+                case 7:
+                    //  ISP瑜� IssueForm �뿉 ���옣�븳�떎.
+                    this.setIssueFormIspField(cellStr, ispFieldMaps, issueForm, rowIndex);
+                    break;
+                case 8:
+                    //  �샇�뒪�똿�쓣 IssueForm �뿉 ���옣�븳�떎.
+                    this.setIssueFormHostingField(cellStr, hostingFieldMaps, issueForm, rowIndex);
                     break;
                 default:
                     //  9踰� 遺��꽣�뒗 �궗�슜�옄 �젙�쓽 �븘�뱶. �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎.
-                    this.setIssueFormCustomFieldValue(cell, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex);
+                    this.setIssueFormCustomFieldValue(cellStr, customFieldMaps, issueForm, headers.get(cellIndex), rowIndex);
             }
         }
 
         return issueForm;
     }
 
-    //  �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎.
-    private void setIssueFormTitle(Cell cell, IssueForm issueForm, int rowIndex) {
-        if (cell == null) {
-            throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex));
+    private void setIssueFormHostingField(String cell, Map<String, HostingField> hostingFieldMaps, IssueForm issueForm, int rowIndex) {
+        if (cell.length() > 0) {
+            Map<String, Object> issueHostingFields = new HashMap<>();
+            HostingField hostingFieldMap = hostingFieldMaps.get(cell);
+            if (hostingFieldMap == null) {
+                throw new OwlRuntimeException(
+                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NOT_EXIST, rowIndex));
+            }
+            ConvertUtil.copyProperties(hostingFieldMap, issueHostingFields);
+            issueForm.addIssueHostingField(issueHostingFields);
         }
+    }
 
-        String title = CommonUtil.convertExcelStringToCell(cell);
+    private void setIssueFormIspField(String cell, Map<String, IspField> ispFieldMaps, IssueForm issueForm, int rowIndex) {
+        if (cell.length() > 0) {
+            Map<String, Object> issueIspFields = new HashMap<>();
+            IspField ispFieldMap = ispFieldMaps.get(cell);
+            if (ispFieldMap == null) {
+                throw new OwlRuntimeException(
+                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISP_NOT_EXIST, rowIndex));
+            }
+            ConvertUtil.copyProperties(ispFieldMap, issueIspFields);
+            issueForm.addIssueIspField(issueIspFields);
+        }
+    }
 
+    private void setIssueFormCompanyField(String cell, Map<String, CompanyField> companyFieldMaps, IssueForm issueForm, int rowIndex) {
+        if (cell.length() > 0) {
+            Map<String, Object> issueCompanyFields = new HashMap<>();
+            CompanyField companyFieldMap = companyFieldMaps.get(cell);
+            if (companyFieldMap == null) {
+                throw new OwlRuntimeException(
+                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_COMPANY_NOT_EXIST, rowIndex));
+            }
+            ConvertUtil.copyProperties(companyFieldMap, issueCompanyFields);
+            issueForm.addissueCompanyField(issueCompanyFields);
+        }
+    }
+
+    //  �씠�뒋 �젣紐⑹쓣 IssueForm �뿉 ���옣�븳�떎.
+    private void setIssueFormTitle(String title, IssueForm issueForm, int rowIndex) {
         //  �젣紐� �쑀�슚�꽦 泥댄겕
         this.verifyTitle(title);
         issueForm.setTitle(title);
@@ -3410,13 +3707,8 @@
 
 
     //  �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎.
-    private void setIssueFormPriority(Cell cell, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) {
-        if (cell == null) {
-            throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex));
-        }
-
-        Priority priority = priorityMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setIssueFormPriority(String priorityStr, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) {
+        Priority priority = priorityMaps.get(priorityStr);
 
         if (priority == null) {
             throw new OwlRuntimeException(
@@ -3427,13 +3719,8 @@
     }
 
     //  以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎.
-    private void setIssueFormSeverity(Cell cell, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) {
-        if (cell == null) {
-            throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex));
-        }
-
-        Severity severity = severityMaps.get(CommonUtil.convertExcelStringToCell(cell));
+    private void setIssueFormSeverity(String strSeverity, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) {
+        Severity severity = severityMaps.get(strSeverity);
 
         if (severity == null) {
             throw new OwlRuntimeException(
@@ -3459,20 +3746,11 @@
         }
     }
     //  �떆�옉�씪, 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎.
-    private void setIssueFormPeriod(Cell cell, IssueForm issueForm, Boolean checkStartDate, int rowIndex) {
-        if (cell != null && !cell.toString().equals("")) {
+    private void setIssueFormPeriod(String periodDate, IssueForm issueForm, Boolean checkStartDate, int rowIndex, boolean isNull) throws ParseException {
+        if (!isNull) {
 
-            //  媛믪씠 怨듬갚�씠硫� 以묒�
-            String cellValue = CommonUtil.convertExcelStringToCell(cell);
-            if (StringUtils.isEmpty(cellValue) || !cell.toString().equals("null")) {
-                return;
-            }
-
-            Date startDate;
-
-            try {
-                startDate = cell.getDateCellValue();
-            } catch (Exception e) {
+            Date startDate = DateUtil.convertStrToDateOnly(periodDate);
+            if (startDate == null) {
                 throw new OwlRuntimeException(
                         this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY_EMPTY, rowIndex));
             }
@@ -3482,96 +3760,121 @@
             } else {
                 issueForm.setCompleteDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd"));
 
+                //  醫낅즺�씪留� �엯�젰 �뻽�쓣 寃쎌슦
+                if (issueForm.getCompleteDate() != null && issueForm.getStartDate() == null) {
+                    throw new OwlRuntimeException(
+                            this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY_EMPTY_START, rowIndex));
+                }
+
                 try {
                     //  �궇吏� �쑀�슚�꽦 泥댄겕
                     this.checkStartCompleteDate(issueForm.getStartDate(), issueForm.getCompleteDate());
                 } catch (OwlRuntimeException e) {
                     throw new OwlRuntimeException(
-                            this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALIDITY, rowIndex));
+                            this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_VALID, rowIndex));
                 }
             }
         }
     }
 
     //  �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎.-
-    private void setIssueFormCustomFieldValue(Cell cell, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) {
-        if (cell != null) {
-            String cellValue = CommonUtil.convertExcelStringToCell(cell);
-            Map<String, Object> issueCustomFieldMap = new HashMap<>();
-            CustomField customField = customFieldMaps.get(customFieldName);
+    private void setIssueFormCustomFieldValue(String cellValue, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) {
+        Map<String, Object> issueCustomFieldMap = new HashMap<>();
+        CustomField customField = customFieldMaps.get(customFieldName);
 
-            if (customField == null) {
-                throw new OwlRuntimeException(
-                        this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST, rowIndex));
-            }
-            //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛믪씠 怨듬갚�씠硫� 以묒�
-            if (StringUtils.isEmpty(cellValue)) {
-                return;
-            }
+        if (customField == null) {
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HEADER_CUSTOM_FIELD_NOT_EXIST, rowIndex));
+        }
+        //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛믪씠 怨듬갚�씠硫� 以묒�
+        if (StringUtils.isEmpty(cellValue)) {
+            return;
+        }
 
-            boolean validity = false;
+        boolean validity = false;
 
-            switch (customField.getCustomFieldType()) {
-                case INPUT:
-                case NUMBER:
-                case DATETIME:
-                case IP_ADDRESS:
-                case EMAIL:
-                case SITE:
-                case TEL:
-                    if (cellValue.length() > 100) {
+        switch (customField.getCustomFieldType()) {
+            case INPUT:
+            case NUMBER:
+            case DATETIME:
+            case IP_ADDRESS:
+            case EMAIL:
+            case SITE:
+            case TEL:
+                if (customField.getCustomFieldType() != INPUT && cellValue.length() > 100) { //INPUT ���엯�� 100�옄 �젣�븳 �뾾�쓬
+                    throw new OwlRuntimeException(
+                            this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT));
+                }
+
+                //DATETIME�씪 寃쎌슦 format 蹂�寃�
+                if (customField.getCustomFieldType() == DATETIME) {
+                    Date date = DateUtil.convertStrToDate(cellValue);
+                    if (date == null) {
                         throw new OwlRuntimeException(
-                                this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT));
+                                this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_DATETIME_NOT_DASH, rowIndex));
                     }
+                }
 
-                    issueCustomFieldMap.put("customFieldId", customField.getId());
-                    issueCustomFieldMap.put("useValue", cellValue);
-                    issueForm.addIssueCustomFields(issueCustomFieldMap);
-                    break;
-                case SINGLE_SELECT:
-                    //  媛� �쑀�슚�꽦 泥댄겕
+                //IP_ADDRESS�씪 寃쎌슦 �젙洹쒗몴�쁽�떇 泥댄겕
+                if (customField.getCustomFieldType() == IP_ADDRESS) {
+                    String regExp = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
+                            + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
+                            + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
+                            + "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
+
+                    if (!cellValue.matches(regExp)) {
+                        throw new OwlRuntimeException(
+                                this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_IP_ADDRESS_NOT_VALIDITY, rowIndex));
+                    }
+                }
+
+                issueCustomFieldMap.put("customFieldId", customField.getId());
+                issueCustomFieldMap.put("useValue", cellValue);
+                issueForm.addIssueCustomFields(issueCustomFieldMap);
+                break;
+            case SINGLE_SELECT:
+                //  媛� �쑀�슚�꽦 泥댄겕
+                for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) {
+                    if (customFieldValue.getValue().equals(cellValue)) {
+                        validity = true;
+                        break;
+                    }
+                }
+
+                if (!validity) {
+                    throw new OwlRuntimeException(
+                            this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex));
+                }
+
+                issueCustomFieldMap.put("customFieldId", customField.getId());
+                issueCustomFieldMap.put("useValue", cellValue);
+                issueForm.addIssueCustomFields(issueCustomFieldMap);
+
+                break;
+            case MULTI_SELECT:
+                //  媛� �쑀�슚�꽦 泥댄겕
+                String[] useValues = cellValue.split("#");
+                //  �빐, �떖
+                for (String useValue : useValues) {
                     for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) {
-                        if (customFieldValue.getValue().equals(cellValue)) {
+
+                        if (customFieldValue.getValue().equals(useValue)) {
                             validity = true;
-                            break;
+                            Map<String, Object> multiValueMap = new HashMap<>();
+                            multiValueMap.put("customFieldId", customField.getId());
+                            multiValueMap.put("useValue", useValue);
+                            issueForm.addIssueCustomFields(multiValueMap);
                         }
+
                     }
+                }
 
-                    if (!validity) {
-                        throw new OwlRuntimeException(
-                                this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex));
-                    }
+                if (!validity) {
+                    throw new OwlRuntimeException(
+                            this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex));
+                }
 
-                    issueCustomFieldMap.put("customFieldId", customField.getId());
-                    issueCustomFieldMap.put("useValue", cellValue);
-                    issueForm.addIssueCustomFields(issueCustomFieldMap);
-
-                    break;
-                case MULTI_SELECT:
-                    //  媛� �쑀�슚�꽦 泥댄겕
-                    String[] useValues = cellValue.split("#");
-                    //  �빐, �떖
-                    for (String useValue : useValues) {
-                        for (CustomFieldValue customFieldValue : customField.getCustomFieldValues()) {
-
-                            if (customFieldValue.getValue().equals(useValue)) {
-                                validity = true;
-                                Map<String, Object> multiValueMap = new HashMap<>();
-                                multiValueMap.put("customFieldId", customField.getId());
-                                multiValueMap.put("useValue", useValue);
-                                issueForm.addIssueCustomFields(multiValueMap);
-                            }
-
-                        }
-                    }
-
-                    if (!validity) {
-                        throw new OwlRuntimeException(
-                                this.messageAccessor.getMessage(MsgConstants.EXCEL_CUSTOM_FIELD_VALUE_NOT_VALIDITY, rowIndex));
-                    }
-
-                    break;
-            }
+                break;
         }
     }
 
@@ -3629,7 +3932,7 @@
     //  �씠�뒋瑜� �뀥�뵆由우뿉 �뵲�씪 �뙆�듃�꼫 �떞�떦�옄�뿉寃� 硫붿씪濡� 諛쒖넚�븳�떎.
     @Override
     @Transactional(readOnly = true)
-    public void sendIssueEmailPartners(EmailTemplateForm emailTemplateForm) {
+    public void sendIssueEmailPartners(EmailTemplateForm emailTemplateForm, List<MultipartFile> multipartFiles) {
         if (emailTemplateForm.getSendEmails().size() < 1) {
             throw new OwlRuntimeException(
                     this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SEND_USER));
@@ -3656,23 +3959,23 @@
         for(int i=0; i < sendMails.length; i++) {
             sendMails[i] = CommonUtil.decryptAES128(sendMails[i]);
         }
-        this.systemEmailService.sendEmail(emailTemplateForm.getTitle(), emailTemplateForm.getTemplate(), sendMails, null);
+        this.systemEmailService.sendEmail(emailTemplateForm.getTitle(), emailTemplateForm.getTemplate(), sendMails, null, multipartFiles);
 
         this.issueHistoryService.detectSendIssueMail(IssueHistoryType.SEND, emailTemplateForm.getSendEmails(), sb);
         this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.SEND, sb.toString());
     }
 
     @Override
-    public void sendCommonEmail(EmailCommonForm emailCommonForm) {
+    public void sendCommonEmail(EmailCommonForm emailCommonForm, List<MultipartFile> multipartFiles) {
         if (emailCommonForm.getSendEmails().size() < 1) {
             throw new OwlRuntimeException(
                     this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SEND_USER));
-        } else if (emailCommonForm.getIssueId() == null) {
-            throw new OwlRuntimeException(
-                    this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_EXIST));
         }
 
-        Issue issue = this.getIssue(emailCommonForm.getIssueId());
+        Issue issue = null;
+        if(emailCommonForm.getIssueId() != null) {
+            issue = this.getIssue(emailCommonForm.getIssueId());
+        }
 
         //  諛쒖떊�옄 �몴�떆
         User user = this.webAppUtil.getLoginUserObject();
@@ -3687,10 +3990,12 @@
         for(int i=0; i < sendMails.length; i++) {
             sendMails[i] = CommonUtil.decryptAES128(sendMails[i]);
         }
-        this.systemEmailService.sendEmail(emailCommonForm.getTitle(), emailCommonForm.getDescription(), sendMails, null);
+        this.systemEmailService.sendEmail(emailCommonForm.getTitle(), emailCommonForm.getDescription(), sendMails, null, multipartFiles);
 
-        this.issueHistoryService.detectSendIssueMail(IssueHistoryType.SEND, emailCommonForm.getSendEmails(), sb);
-        this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.SEND, sb.toString());
+        if (issue != null) {
+            this.issueHistoryService.detectSendIssueMail(IssueHistoryType.SEND, emailCommonForm.getSendEmails(), sb);
+            this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.SEND, sb.toString());
+        }
     }
 
     //  �삁�빟 諛쒖깮 �씠�뒋瑜� �떎�뻾�븳�떎
@@ -3883,11 +4188,71 @@
                 this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb);
                 issue.setParentIssue(null);
             }
+
+            if (issueDownForm.getInheritYn() != null && issueDownForm.getInheritYn() && issue.getParentIssue() != null) {
+                //  �긽�쐞�씠�뒋�쓽 �뙆�듃�꼫 �젙蹂� �긽�냽諛쏄린
+                issue = this.inheritPartners(issue, parentIssue);
+            }
+
             this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); //parentIssue = myIssue(湲곕줉�� �쁽�옱 �긽�꽭�럹�씠吏��뿉 �빐�빞�븯�땲源�)
             this.issueRepository.saveAndFlush(issue);
         }
     }
 
+    /**
+     * �긽�쐞�씠�뒋�쓽 �뙆�듃�꼫 �젙蹂� �긽�냽諛쏄린
+     * @param issue Issue
+     * @param parentIssue Issue
+     * @return Issue
+     */
+    private Issue inheritPartners(Issue issue, Issue parentIssue) {
+        if (parentIssue != null) {
+            if (parentIssue.getIssueType().getInheritPartners()) {
+                IssueCompany issueCompany = new IssueCompany();
+                IssueIsp issueIsp = new IssueIsp();
+                IssueHosting issueHosting = new IssueHosting();
+
+                if (parentIssue.getIssueCompanies() != null && parentIssue.getIssueCompanies().size() > 0) {
+                    issue.getIssueCompanies().clear();
+                    issue.getIssueCompanies().addAll(parentIssue.getIssueCompanies());
+                    Iterator<IssueCompany> itrCompany = issue.getIssueCompanies().iterator();
+                    ConvertUtil.copyProperties(itrCompany.next(), issueCompany, "id");
+                    issueCompany.setIssue(issue);
+                    issueCompany.setCompanyField(parentIssue.getIssueCompanies().iterator().next().getCompanyField());
+                    this.issueCompanyRepository.saveAndFlush(issueCompany);
+                } else {
+                    this.issueCompanyRepository.deleteByIssueId(issue.getId());
+                    this.issueCompanyRepository.flush();
+                }
+                if (parentIssue.getIssueIspFields() != null && parentIssue.getIssueIspFields().size() > 0) {
+                    issue.getIssueIspFields().clear();
+                    issue.getIssueIspFields().addAll(parentIssue.getIssueIspFields());
+                    Iterator<IssueIsp> itrIsp = issue.getIssueIspFields().iterator();
+                    ConvertUtil.copyProperties(itrIsp.next(), issueIsp, "id");
+                    issueIsp.setIssue(issue);
+                    issueIsp.setIspField(parentIssue.getIssueIspFields().iterator().next().getIspField());
+                    this.issueIspRepository.saveAndFlush(issueIsp);
+                } else {
+                    this.issueIspRepository.deleteByIssueId(issue.getId());
+                    this.issueIspRepository.flush();
+                }
+                if (parentIssue.getIssueHostingFields() != null && parentIssue.getIssueHostingFields().size() > 0) {
+                    issue.getIssueHostingFields().clear();
+                    issue.getIssueHostingFields().addAll(parentIssue.getIssueHostingFields());
+                    Iterator<IssueHosting> itrHosting = issue.getIssueHostingFields().iterator();
+                    ConvertUtil.copyProperties(itrHosting.next(), issueHosting, "id");
+                    issueHosting.setIssue(issue);
+                    issueHosting.setHostingField(parentIssue.getIssueHostingFields().iterator().next().getHostingField());
+                    this.issueHostingRepository.saveAndFlush(issueHosting);
+                } else {
+                    this.issueHostingRepository.deleteByIssueId(issue.getId());
+                    this.issueHostingRepository.flush();
+                }
+            }
+        }
+        return issue;
+    }
+
     @Override
     public void findPartner(Map<String, Object> resJsonData, Map<String, Object> params) {
         Long issueTypeId = MapUtil.getLong(params, "issueTypeId");

--
Gitblit v1.8.0