From 4ab15ca2bb74d0d33d1325d849422635b9d415b1 Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 월, 07 2월 2022 15:31:39 +0900 Subject: [PATCH] 업체 임포트 시 코드 보완 --- src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java | 828 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 591 insertions(+), 237 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 2485611..8e87053 100644 --- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java +++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java @@ -11,14 +11,14 @@ import kr.wisestone.owl.domain.enumType.EmailType; import kr.wisestone.owl.domain.enumType.IssueHistoryType; import kr.wisestone.owl.domain.enumType.IssueStatusType; +import kr.wisestone.owl.exception.ApiAuthException; +import kr.wisestone.owl.exception.ApiParameterException; import kr.wisestone.owl.exception.OwlRuntimeException; import kr.wisestone.owl.mapper.DepartmentMapper; import kr.wisestone.owl.mapper.IssueMapper; +import kr.wisestone.owl.mapper.IssueRelationMapper; import kr.wisestone.owl.mapper.ProjectMapper; -import kr.wisestone.owl.repository.IssueRelationRepository; -import kr.wisestone.owl.repository.IssueRepository; -import kr.wisestone.owl.repository.UserDepartmentRepository; -import kr.wisestone.owl.repository.WorkflowDepartmentRepository; +import kr.wisestone.owl.repository.*; import kr.wisestone.owl.service.*; import kr.wisestone.owl.util.*; import kr.wisestone.owl.util.DateUtil; @@ -33,6 +33,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.messaging.simp.SimpMessagingTemplate; @@ -44,7 +46,11 @@ import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.*; + +import static kr.wisestone.owl.domain.enumType.CustomFieldType.DATETIME; +import static kr.wisestone.owl.domain.enumType.CustomFieldType.INPUT; @Service public class IssueServiceImpl extends AbstractServiceImpl<Issue, Long, JpaRepository<Issue, Long>> implements IssueService { @@ -83,6 +89,9 @@ @Autowired private CompanyFieldService companyFieldService; + + @Autowired + private CompanyFieldCategoryService companyFieldCategoryService; @Autowired private IspFieldService ispFieldService; @@ -178,6 +187,15 @@ private IssueMapper issueMapper; @Autowired + private IssueCompanyRepository issueCompanyRepository; + + @Autowired + private IssueIspRepository issueIspRepository; + + @Autowired + private IssueHostingRepository issueHostingRepository; + + @Autowired private ExcelConditionCheck excelConditionCheck; @Autowired @@ -194,6 +212,12 @@ @Autowired private WorkflowDepartmentRepository workflowDepartmentRepository; + + @Autowired + private IssueRelationMapper issueRelationMapper; + + @Autowired + private WorkflowTransitionService workflowTransitionService; @Override protected JpaRepository<Issue, Long> getRepository() { @@ -223,14 +247,14 @@ private IssueForm convertToIssueForm(IssueApiForm issueApiForm, User user) { if (issueApiForm.getIssueTypeId() == null) { - throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_ISSUE_TYPE_ERROR)); + throw new ApiParameterException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_ISSUE_TYPE_ERROR)); } IssueForm issueForm = ConvertUtil.copyProperties(issueApiForm, IssueForm.class); // issueForm.setFiles(issueApiForm.getFiles()); IssueType issueType = this.issueTypeService.getIssueType(issueApiForm.getIssueTypeId()); if (issueType == null){ - throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_ISSUE_TYPE_ERROR)); + throw new ApiParameterException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_ISSUE_TYPE_ERROR)); } Workflow workflow = issueType.getWorkflow(); @@ -244,13 +268,16 @@ } } } else if (issueApiForm.getIssueStatusId() == null){ - throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_ISSUE_STATUS_NOT_EXIST)); + 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)); } // �봽濡쒖젥�듃 �엯�젰 Project project = issueType.getProject(); if (project == null){ - throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_PROJECT_ERROR)); + throw new ApiParameterException(this.messageAccessor.getMessage(MsgConstants.API_PARAMETER_PROJECT_ERROR)); } issueForm.setProjectId(project.getId()); @@ -283,7 +310,7 @@ issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId()); } - // 以묐났�맂 �씠�뒋寃��깋 + // 醫낅즺�긽�깭媛� �븘�땶 以묐났�맂 �긽�쐞 �씠�뒋寃��깋 List<Issue> issues = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId()); int size = issues.size(); if (size > 0) { @@ -309,11 +336,11 @@ return issueForm; } else { - throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_USER_ERROR)); + throw new ApiAuthException(this.messageAccessor.getMessage(MsgConstants.API_USER_ERROR)); } } - private void findCompanyField(IssueForm issueForm) { + private IssueForm findCompanyField(IssueForm issueForm) { if(issueForm.getIssueCustomFields() != null && issueForm.getIssueCustomFields().size() > 0) { CompanyFieldCondition condition = new CompanyFieldCondition(); List<Map<String, Object>> companyFields = this.companyFieldService.find(condition); @@ -322,25 +349,24 @@ List<Map<String, Object>> issueHostingFields = Lists.newArrayList(); for (Map<String, Object> issueCustomField : issueForm.getIssueCustomFields()) { - int customFieldId = (Integer) issueCustomField.get("customFieldId"); - Long customId = (long) customFieldId; - CustomField customField = this.customFieldService.getCustomField(customId); + Long customFieldId = MapUtil.getLong(issueCustomField, "customFieldId"); + CustomField customField = this.customFieldService.getCustomField(customFieldId); if(customField != null && customField.getCustomFieldType().toString().equals("SITE") && customField.getName().equals("�룄硫붿씤")) { String useValue = issueCustomField.get("useValue").toString(); 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")); @@ -356,6 +382,8 @@ issueForm.setIssueHostingFields(issueHostingFields); } } + + return issueForm; } private User convertToUser(String token) { @@ -381,7 +409,14 @@ } else { // 媛��긽 �긽�쐞 �씠�뒋 異붽� IssueForm parentIssueForm = issueForm.clone(); + // 媛��긽 �긽�쐞 �씠�뒋 異붽� parentIssueForm.setUseIssueCustomFields(issueApiForm.getUseIssueCustomFieldIds()); + // 媛숈� �룄硫붿씤 �뾽泥� 李얘린 + IssueForm partners = this.findCompanyField(parentIssueForm); + parentIssueForm.setIssueCompanyFields(partners.getIssueCompanyFields()); + parentIssueForm.setIssueIspFields(partners.getIssueIspFields()); + parentIssueForm.setIssueHostingFields(partners.getIssueHostingFields()); + Issue issue = addIssue(user, parentIssueForm, null); issues.add(issue); // �븯�쐞 �씠�뒋 異붽� @@ -414,7 +449,9 @@ IssueCustomFieldValueFormComparator comp = new IssueCustomFieldValueFormComparator(); Collections.sort(issueCustomFieldValueForms, comp); + List<String> userValues = Lists.newArrayList(); for (IssueCustomFieldValueForm issueCustomFieldValueForm : issueCustomFieldValueForms) { + userValues.add(issueCustomFieldValueForm.getUseValue()); for(CustomFieldApiOverlap customFieldApiOverlap : customFieldApiOverlaps) { if (customFieldApiOverlap.getCustomField().getId().equals(issueCustomFieldValueForm.getCustomFieldId())) { if (useIdx > 0) { @@ -428,7 +465,9 @@ IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); 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) { @@ -451,6 +490,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()); // �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕 @@ -493,12 +534,11 @@ // �떞�떦遺��꽌 吏��젙 this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds()); // �뾽泥� �젙蹂� ���옣 - this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields()); + this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange); // ISP �젙蹂� ���옣 - this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields()); + this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange); // HOSTING �젙蹂� ���옣 - this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields()); - + this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange); // 泥⑤� �뙆�씪 ���옣 // multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎. @@ -545,6 +585,8 @@ @Override @Transactional public Issue addDownIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) { + StringBuilder detectIssueChange = new StringBuilder(); + // �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎. Workspace workspace = this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId()); // �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕 @@ -587,11 +629,11 @@ // �떞�떦遺��꽌 吏��젙 this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds()); // �뾽泥� �젙蹂� ���옣 - this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields()); + this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange); // ISP �젙蹂� ���옣 - this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields()); + this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange); // HOSTING �젙蹂� ���옣 - this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields()); + this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange); // 泥⑤� �뙆�씪 ���옣 // multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎. @@ -622,6 +664,7 @@ @Override @Transactional public Issue addRelIssue(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) { + StringBuilder detectIssueChange = new StringBuilder(); // �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎. Workspace workspace = this.workspaceService.checkUseWorkspace(user, user.getLastWorkspaceId()); // �봽濡쒖젥�듃 �쑀�슚�꽦 泥댄겕 @@ -664,11 +707,11 @@ // �떞�떦遺��꽌 吏��젙 this.issueDepartmentService.modifyIssueDepartment(issue, user, project.getWorkspace(), issueForm.getDepartmentIds()); // �뾽泥� �젙蹂� ���옣 - this.issueCompanyService.modifyIssueCompanyField(issue, issueForm.getIssueCompanyFields()); + this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange); // ISP �젙蹂� ���옣 - this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields()); + this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange); // HOSTING �젙蹂� ���옣 - this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields()); + this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange); // 泥⑤� �뙆�씪 ���옣 // multipartFile �쓣 file Map List 媛앹껜濡� 蹂�寃쏀븳�떎. @@ -716,7 +759,7 @@ } // �씠�뒋 �젙蹂대�� �씠硫붿씪 �쟾�넚�뿉 �궗�슜�븯湲� �쐞�빐 Map �삎�깭濡� 蹂��솚�븳�떎. - private void makeIssueMapToIssue(Issue issue, Map<String, Object> issueMap) { + public void makeIssueMapToIssue(Issue issue, Map<String, Object> issueMap) { issueMap.put("title", issue.getTitle()); issueMap.put("issueNumber", issue.getIssueNumber()); issueMap.put("issueTypeName", issue.getIssueType().getName()); @@ -770,7 +813,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())); @@ -908,42 +951,40 @@ return Lists.newArrayList(); } - // �뒠�떇 �쟾 - 1.3 / 1.2 / 1.1 - // �뒠�떇 �썑 (�떒�씪/�떎以� 寃��깋 議곌굔 3媛� 湲곗�) - 0.49 / 0.41 / 0.47 / 0.41 - List<IssueVo> issueVos = Lists.newArrayList(); // �씠�뒋 紐⑸줉 �뜲�씠�꽣 ���옣 而щ젆�뀡 // �궗�슜�옄 �젙�쓽 �븘�뱶濡� 寃��깋�븳 �씠�뒋 �븘�씠�뵒 媛� List<String> issueKeys = Lists.newArrayList(issueIds); issueCondition.setIssueIds(issueKeys); - - issueCondition.setLoginUserId(this.webAppUtil.getLoginId()); - issueCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId()); User user = this.webAppUtil.getLoginUserObject(); + + issueCondition.setLoginUserId(user.getId()); + issueCondition.setWorkspaceId(user.getLastWorkspaceId()); List<Map<String, Object>> results = Lists.newArrayList(); Long totalCount = 0L; - UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); +// UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId()); // if (!this.userWorkspaceService.checkWorkspaceManager(user) // && !MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)) { //理쒓퀬愿�由ъ옄 & �봽濡쒖젥�듃,�씠�뒋 愿�由ъ옄 �씪 寃쎌슦 紐⑤뱺 �씠�뒋 蹂닿린 // this.SetMyDepartmentId(issueCondition); - //this.SetAllDepartmentId(issueCondition); + //this.SetAllDepartmentId(issueCondition); // } /*else{ // results = this.issueMapper.findByDepartment(issueCondition); // totalCount = this.issueMapper.countByDepartment(issueCondition); // }*/ +// StopWatch serviceStart = new StopWatch(); +// serviceStart.start(); results = this.issueMapper.find(issueCondition); +// serviceStart.stop(); +// log.error("result : " + serviceStart.toString()); + +// serviceStart = new StopWatch(); +// serviceStart.start(); totalCount = this.issueMapper.count(issueCondition); - - // �뒠�떇 �쟾 - 0.8, 0.9, 0.9, 0.9, 0.9 - /*StopWatch serviceStart = new StopWatch(); - serviceStart.start();*/ - // �뒠�떇 �쟾 - 1.1, 1.1, 1.3, 1.2 - - /*serviceStart.stop(); - log.debug("serviceENd1 : " + serviceStart.getTime());*/ +// serviceStart.stop(); +// log.error("totalCount : " + serviceStart.toString()); int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1; // �씠�뒋 �븘�씠�뵒 珥덇린�솕 @@ -959,8 +1000,8 @@ this.setDownIssues(user, issueVos); this.setRelationIssues(issueVos); } - this.setCountDownIssues(issueVos); + this.setCountDownIssues(issueVos); this.SetWorkflowDepartment(issueVos); //�썙�겕�뵆濡쒖슦�뿉 �꽕�젙�븳 �떞�떦遺��꽌 媛��졇�삤湲� resJsonData.put(Constants.RES_KEY_CONTENTS, issueVos); @@ -1457,11 +1498,24 @@ @Transactional(readOnly = true) public void detailIssue(Map<String, Object> resJsonData, IssueCondition issueCondition) { IssueVo issueVo = new IssueVo(); + Pageable relPageable = issueCondition.getRelPageable(); + Pageable downPageable = issueCondition.getDownPageable(); if (issueCondition.getId() != null) { Issue issue = this.getIssue(issueCondition.getId()); issueVo = ConvertUtil.copyProperties(issue, IssueVo.class); User user = this.webAppUtil.getLoginUserObject(); + + if (relPageable != null) { + issueVo.setRelPageNumber(relPageable.getPageNumber()); + issueVo.setRelPageSize(relPageable.getPageSize()); + issueVo.setRelPage(relPageable.getPageNumber() * relPageable.getPageSize()); + } + if (downPageable != null) { + issueVo.setDownPageNumber(downPageable.getPageNumber()); + issueVo.setDownPage(downPageable.getPageNumber() * downPageable.getPageSize()); + issueVo.setDownPageSize(downPageable.getPageSize()); + } switch (issueCondition.getDeep()) { case "01": // �봽濡쒖젥�듃, �씠�뒋 �쑀�삎, �씠�뒋 �긽�깭, �슦�꽑�닚�쐞, 以묒슂�룄, �떞�떦遺��꽌, 泥⑤��뙆�씪, �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� �뀑�똿�븳�떎. @@ -1478,17 +1532,15 @@ this.setIssueCustomFields(issue, issueVo); // �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿 this.setRelationIssue(issue, issueVo); //�뿰愿� �씪媛� �뀑�똿 this.setDownIssues(issue, issueVo); //�븯�쐞 �씠�뒋 �꽭�똿 - break; 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; } } - // �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏� log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_DETAIL)); @@ -1496,8 +1548,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) { @@ -1517,8 +1570,21 @@ // �븯�쐞 �씠�뒋 �젙蹂대�� �뀑�똿�븳�떎 private void setDownIssues(Issue issue, IssueVo issueVo) { - List<Issue> downIssues = this.issueRepository.findByParentIssueId(issue.getId()); - if(downIssues != null && downIssues.size()>0){ + Page<Issue> downIssues = null; + + List<Issue> downIssueList = this.issueRepository.findByParentIssueId(issue.getId()); + if(downIssueList != null && downIssueList.size() > 0) { + int startPage = 0; + if (issueVo.getDownPage() != 0) { + startPage = (int) Math.floor(issueVo.getDownPage()/issueVo.getDownPageSize()); + } + Pageable pageable = PageRequest.of(startPage, issueVo.getDownPageSize()); + downIssues = this.issueRepository.findByParentIssueId(issue.getId(), pageable); + } + if(downIssues != null){ + issueVo.setDownTotalPage(downIssues.getTotalPages()); + issueVo.setDownTotalCount(downIssues.getTotalElements()); + List<IssueVo> resultList = new ArrayList<>(); for(Issue downIssue : downIssues){ IssueVo downIssueVo = ConvertUtil.copyProperties(downIssue, IssueVo.class); @@ -1535,6 +1601,11 @@ 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()); resultList.add(downIssueVo); } @@ -1546,6 +1617,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"); @@ -1581,11 +1657,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); - } } // �긽�쐞�씪媛� �젙蹂� 異붽� @@ -1616,13 +1687,18 @@ // �뿰愿� �씠�뒋 �젙蹂대�� �뀑�똿�븳�떎 private void setRelationIssue(Issue issue, IssueVo issueVo) { - Set<IssueRelation> issueRelations = issue.getIssueRelations(); - if (issue != null && issueVo != null && issueRelations.size() > 0) { - for (IssueRelation issueRelation : issueRelations) { - IssueRelationVo issueRelationVo = ConvertUtil.copyProperties(issueRelation, IssueRelationVo.class); + //Set<IssueRelation> issueRelations = issue.getIssueRelations(); - Issue relationIssue = issueRelation.getRelationIssue(); + List<Map<String, Object>> results = this.issueRelationMapper.findByIssueId(issueVo); + Long totalCount = this.issueRelationMapper.count(issueVo); + if (issue != null && issueVo != null && results.size() > 0) { + int totalPage = (int) Math.ceil((totalCount - 1) / issueVo.getRelPageSize()) + 1; + issueVo.setRelTotalPage(totalPage); + issueVo.setRelTotalCount(totalCount); + for (Map<String, Object> result : results) { + IssueRelationVo issueRelationVo = ConvertUtil.convertMapToClass(result, IssueRelationVo.class); + Issue relationIssue = this.findOne(MapUtil.getLong(result, "relationIssueId")); IssueVo relIssueVo = ConvertUtil.copyProperties(relationIssue, IssueVo.class); Project project = this.projectService.getProject(relationIssue.getProject().getId()); relIssueVo.setProjectId(project.getId()); @@ -1639,9 +1715,30 @@ issueStatusVo.setIssueStatusType(relationIssue.getIssueStatus().getIssueStatusType().toString()); issueRelationVo.setIssueStatusVo(issueStatusVo); + issueRelationVo.setModifyPermissionCheck(issueVo.getModifyPermissionCheck()); + 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 { @@ -1755,10 +1852,15 @@ List<Issue> resultIssueVos = Lists.newArrayList(); String comma = ","; + List<String> userValues = Lists.newArrayList(); if (issueCustomFieldValueForms.size() > 0) { + IssueCustomFieldValueFormComparator comp = new IssueCustomFieldValueFormComparator(); + Collections.sort(issueCustomFieldValueForms, comp); + String concatUseValue = ""; for (int i = 0; i < issueCustomFieldValueForms.size(); i++) { IssueCustomFieldValueForm issueCustomFieldValueForm = issueCustomFieldValueForms.get(i); + userValues.add(issueCustomFieldValueForm.getUseValue()); if (i > 0) { concatUseValue = concatUseValue.concat(comma); } @@ -1767,7 +1869,9 @@ IssueCustomFieldValueCondition issueCustomFieldValueCondition = new IssueCustomFieldValueCondition(); 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) { @@ -1802,6 +1906,7 @@ List<Issue> issues = Lists.newArrayList(); for (Issue issueVo : issue) { issueForm.setId(issueVo.getId()); + issueForm.setTitle(issueVo.getTitle()); // �옄�룞 醫낅즺 �긽�깭 �꽕�젙�씠 �릺�뼱 �엳吏� �븡�쑝硫� �삤瑜섎컻�깮 Issue modifyIssue = this.modifyIssueForApi(user, issueForm, files); @@ -1889,6 +1994,13 @@ // �씠�뒋 �닔�젙(API�슜) private Issue modifyIssueForApi(User user, IssueForm issueForm, List<MultipartFile> multipartFiles) { CheckIssueData checkIssueData = this.checkIssue(user, issueForm); + + if (issueForm.getComment() != null && !issueForm.getComment().equals("")) { //�뙎湲� 異붽� + IssueCommentForm issueCommentForm = new IssueCommentForm(); + issueCommentForm.setDescription(issueForm.getComment()); + issueCommentForm.setIssueId(issueForm.getId()); + this.issueCommentService.addIssueComment(issueCommentForm, user); + } // �씠�뒋 �씠�젰 �궓湲곌린 this.addIssueHistoryModify(user, issueForm, checkIssueData, multipartFiles); @@ -1984,20 +2096,21 @@ 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.getIssueCompanyFields()); + this.issueCompanyService.modifyIssueCompanyField(issue, issueForm, detectIssueChange); // ISP �젙蹂� ���옣 - this.issueIspService.modifyIssueIspField(issue, issueForm.getIssueIspFields()); + this.issueIspService.modifyIssueIspField(issue, issueForm, detectIssueChange); // HOSTING �젙蹂� ���옣 - this.issueHostingService.modifyIssueHostingField(issue, issueForm.getIssueHostingFields()); + this.issueHostingService.modifyIssueHostingField(issue, issueForm, detectIssueChange); + + // �씠�뒋 �씠�젰 �벑濡� + if (!StringUtils.isEmpty(detectIssueChange.toString())) { + this.issueHistoryService.addIssueHistory(issue, user, IssueHistoryType.MODIFY, detectIssueChange.toString()); + } return issue; } @@ -2642,6 +2755,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)); // �샇�뒪�똿 // �궗�슜�옄 �젙�쓽 �븘�뱶瑜� �궗�슜�븳 �씠�뒋瑜� 李얜뒗�떎. 留뚯빟 �씠�뒋媛� �뾾�떎硫� �뿬湲곗꽌 �씠�뒋 議고쉶媛� �걹�궃�떎. @@ -2725,6 +2841,30 @@ CompanyField companyField = issueCompany.getCompanyField(); if (companyField != null) { issueCompanyVo.setCompanyId(issueCompany.getCompanyField().getId()); + if (issueCompany.getCompanyTypeId() != null && issueCompany.getCompanyTypeId() != -1) { + CompanyFieldCategory companyType = this.companyFieldCategoryService.find(issueCompany.getCompanyTypeId()); + issueCompanyVo.setCompanyTypeName(companyType.getUseValue()); + } + if (issueCompany.getParentSectorId() != null && issueCompany.getParentSectorId() != -1) { + CompanyFieldCategory parentSector = this.companyFieldCategoryService.find(issueCompany.getParentSectorId()); + issueCompanyVo.setParentSectorName(parentSector.getUseValue()); + } + if (issueCompany.getChildSectorId() != null && issueCompany.getChildSectorId() != -1) { + CompanyFieldCategory childSector = this.companyFieldCategoryService.find(issueCompany.getChildSectorId()); + issueCompanyVo.setChildSectorName(childSector.getUseValue()); + } + if (issueCompany.getRegionId() != null && issueCompany.getRegionId() != -1) { + CompanyFieldCategory region = this.companyFieldCategoryService.find(issueCompany.getRegionId()); + issueCompanyVo.setRegionName(region.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); } @@ -2794,6 +2934,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()); // �벑濡앹옄 @@ -2867,13 +3010,13 @@ excelInfo.setFileName(this.messageAccessor.message("common.registerExcelIssue")); // �뿊��濡� �씠�뒋 �벑濡앺븯湲� excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.title"), 20, ExportExcelAttrVo.ALIGN_CENTER)); // �젣紐� excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.content"), 40, ExportExcelAttrVo.ALIGN_CENTER)); // �궡�슜 - excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.projectKey"), 10, ExportExcelAttrVo.ALIGN_LEFT)); // �봽濡쒖젥�듃 �궎 - excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.issueType"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �씠�뒋 ���엯 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.priority"), 5, ExportExcelAttrVo.ALIGN_CENTER)); // �슦�꽑�닚�쐞 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.importance"), 5, ExportExcelAttrVo.ALIGN_CENTER)); // 以묒슂�룄 - excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.department"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떞�떦遺��꽌 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.startDate"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // �떆�옉�씪 excelInfo.addAttrInfos(new ExportExcelAttrVo("id", this.messageAccessor.message("common.endDate"), 10, ExportExcelAttrVo.ALIGN_CENTER)); // 醫낅즺�씪 + 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 �뜲�씠�꽣瑜� �뿊���뿉�꽌 �몴�떆�븷 �닔 �엳�뒗 �뜲�씠�꽣濡� 蹂�寃쏀븳�떎. @@ -2895,7 +3038,7 @@ // �뿊�� import 濡� �씠�뒋瑜� �벑濡앺븳�떎. @Override @Transactional - public void importExcel(MultipartFile multipartFile) throws Exception { + public void importExcel(IssueForm issueForm, MultipartFile multipartFile) throws Exception { /*StopWatch serviceStart = new StopWatch(); serviceStart.start();*/ @@ -2906,19 +3049,21 @@ // �뾽濡쒕뱶 �뙆�씪 �솗�옣�옄 泥댄겕 this.verifyMultipartFileExtension(multipartFile); - Map<String, Project> projectMaps = new HashMap<>(); // �봽濡쒖젥�듃 紐⑥쓬 - Map<String, IssueType> issueTypeMaps = new HashMap<>(); // �씠�뒋 ���엯 紐⑥쓬 Map<String, Priority> priorityMaps = new HashMap<>(); // �슦�꽑 �닚�쐞 紐⑥쓬 Map<String, Severity> severityMaps = new HashMap<>(); // 以묒슂�룄 紐⑥쓬 - Map<String, Object> userMaps = new HashMap<>(); // �궗�슜�옄 紐⑥쓬 Map<String, DepartmentVo> departmentMaps = new HashMap<>(); // 遺��꽌 紐⑥쓬 Map<String, CustomField> customFieldMaps = new HashMap<>(); - Map<String, IssueStatus> issueStatusReadyMaps = new HashMap<>(); // �긽�깭 �냽�꽦 '��湲�'�씤 �씠�뒋 �긽�깭 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(projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, departmentMaps, customFieldMaps, issueNumberMaps, issueTypeCustomFieldMaps, issueStatusReadyMaps); + this.IssueAttributeMapToList(issueForm, priorityMaps, severityMaps, departmentMaps, customFieldMaps, + issueTypeCustomFieldMaps, companyFieldMaps, ispFieldMaps, hostingFieldMaps); // 0.237 - 0.230 List<IssueForm> issueForms = Lists.newArrayList(); @@ -2961,7 +3106,11 @@ // 1踰� �뿤�뜑遺��꽣 �뜲�씠�꽣 �쁺�뿭 if (rowIndex > 1) { // �씠�뒋濡� �벑濡앺븯湲� �쐞�빐 IssueForm �뿉 �뜲�씠�꽣瑜� �뀑�똿�븳�떎. - issueForms.add(this.setIssueFormToExcelField(row, (rowIndex + 1), issueStatusReadyMaps, projectMaps, issueTypeMaps, priorityMaps, severityMaps, userMaps, departmentMaps, customFieldMaps, issueNumberMaps, headers)); + IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, departmentMaps, customFieldMaps, + companyFieldMaps, ispFieldMaps, hostingFieldMaps, headers); + ConvertUtil.copyProperties(issueForm, newIssueForm); + + issueForms.add(newIssueForm); } } @@ -2972,7 +3121,52 @@ // �씠�뒋 �벑濡� - 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())); + } + + 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); + } + + saveIssueForm.setIssueStatusId(issueStatus.getId()); + + this.setIssuePartners(saveIssueForm, issue); + } + + // 0.416 - 0.439 // 1.373 ~ 1.394 @@ -2983,15 +3177,13 @@ // �씠�뒋 �떞�떦�옄 踰뚰겕 �벑濡� this.bulkInsertIssueAssignee(issueForms, workspace); // 0.361 - 0.705 - + // 1.816 /*StopWatch serviceStart = new StopWatch(); serviceStart.start();*/ // �씠�뒋 �궗�슜�옄 �젙�쓽 媛� �븘�뱶 踰뚰겕 �벑濡� this.bulkInsertIssueCustomFieldValue(issueForms, issueTypeCustomFieldMaps); // 3.628 - 3.445 - - // �뾽泥�,ISP,�샇�뒪�똿 異붽� /*serviceStart.stop(); log.debug("2李� ���옣 �떆媛� : " + serviceStart.getTime());*/ @@ -3002,7 +3194,71 @@ // reverse index �뾽�뜲�씠�듃 this.issueMapper.updateBatch(issueForms); // 利앷��맂 �씠�뒋 踰덊샇瑜� �뾽�뜲�씠�듃 �븳�떎. - this.issueNumberGeneratorService.updateIssueNumber(issueNumberMaps); +// issueNumberMaps.put(issueForm.getProjectId(), issueForm.getProjectId()); +// this.issueNumberGeneratorService.updateIssueNumber(issueNumberMaps); + } + } + + /** + * �뿊��濡� �엯�젰�븳 �뙆�듃�꼫 �젙蹂� ���옣 + * @param issueForm IssueForm + */ + private void setIssuePartners(IssueForm issueForm, Issue issue) { + IssueCompany issueCompany = new IssueCompany(); + IssueIsp issueIsp = new IssueIsp(); + IssueHosting issueHosting = new IssueHosting(); + //issueCompany �벑濡� + if (issueForm.getIssueCompanyFields() != null && issueForm.getIssueCompanyFields().size() > 0) { + for (Map<String, Object> issueCompanyMap : issueForm.getIssueCompanyFields()) { + CompanyField companyField = ConvertUtil.convertMapToClass(issueCompanyMap, CompanyField.class); + issueCompany = ConvertUtil.convertMapToClass(issueCompanyMap, IssueCompany.class, "id"); + 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 = ConvertUtil.copyProperties(ispField, IssueIsp.class, "id"); + 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 = ConvertUtil.copyProperties(hostingField, IssueHosting.class, "id"); + 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 = ConvertUtil.convertMapToClass(issueIspMap, IssueIsp.class, "id"); + 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 = ConvertUtil.convertMapToClass(issueHostingMap, IssueHosting.class, "id"); + HostingField hostingField = ConvertUtil.convertMapToClass(issueHostingMap, HostingField.class); + issueHosting.setHostingField(hostingField); + issueHosting.setIssue(issue); + this.issueHostingRepository.saveAndFlush(issueHosting); + } } } @@ -3103,6 +3359,41 @@ issueCustomField.put("registerId", this.webAppUtil.getLoginId()); issueCustomFieldValueMaps.add(issueCustomField); } + + // �뿊���뿉 �뾽泥대챸�쓣 �엯�젰�븯吏� �븡�븯�쓣 寃쎌슦 媛숈� �룄硫붿씤 �뾽泥� 李얘린 + 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); + } + } + } } if (issueCustomFieldValueMaps.size() > 0) { @@ -3111,48 +3402,16 @@ } // �씠�뒋�쓽 二쇱슂 �냽�꽦�쓣 map �뿉 ���옣�븯�뿬 �뿊�� import �뿉�꽌 吏��젙�븳 ���긽(�씠�뒋 �냽�꽦)�쓣 鍮좊Ⅴ寃� 李얠쓣 �닔 �엳寃� �븳�떎. - private void IssueAttributeMapToList(Map<String, Project> projectMaps, Map<String, IssueType> issueTypeMaps, Map<String, Priority> priorityMaps, Map<String, Severity> severityMaps, - Map<String, Object> userMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, Map<String, Long> issueTypeCustomFieldMaps, Map<String, IssueStatus> issueStatusReadyMaps) { - // �봽濡쒖젥�듃 �궎濡� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮� - List<Project> projects = this.projectService.findByWorkspaceId(); - List<Long> projectIds = Lists.newArrayList(); + 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, CompanyField> companyFieldMaps, Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps) { - for (Project project : projects) { - projectIds.add(project.getId()); - // �빐�떦 �봽濡쒖젥�듃�뿉�꽌 �깮�꽦�릺�뒗 �떎�쓬 �씠�뒋 踰덊샇瑜� �깮�꽦�빐�삩�떎. - issueNumberMaps.put(project.getId(), this.issueNumberGeneratorService.generateIssueNumber(project)); - projectMaps.put(project.getProjectKey(), project); + Project project = this.projectService.getProject(issueForm.getProjectId()); - for (IssueTypeCustomField issueTypeCustomField : project.getIssueTypeCustomFields()) { - // 鍮좊Ⅴ寃� 李얘린 �쐞�빐 �씠�뒋 ���엯 �븘�씠�뵒 + �궗�슜�옄 �젙�쓽 �븘�뱶 �븘�씠�뵒瑜� �궎濡� �븳�떎. - String makeKey = issueTypeCustomField.getIssueType().getId().toString() + issueTypeCustomField.getCustomField().getId().toString(); - issueTypeCustomFieldMaps.put(makeKey, issueTypeCustomField.getId()); - } - - // �봽濡쒖젥�듃�뿉 李몄뿬�븯�뒗 �궗�슜�옄 �젙蹂� - List<Map<String, Object>> users = this.userService.findProjectMember(project); - Map<String, Object> userMap = new HashMap<>(); - // �궗�슜�옄 �젙蹂대�� Map �뿉 ���옣 - for (Map<String, Object> user : users) { - userMap.put(CommonUtil.decryptAES128(MapUtil.getString(user, "account")), MapUtil.getLong(user, "userId")); - } - userMaps.put(project.getProjectKey(), userMap); - } - - // �씠�뒋 �쑀�삎�쓣 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮� - List<IssueType> issueTypes = this.issueTypeService.findByWorkspaceId(); - for (IssueType issueType : issueTypes) { - issueTypeMaps.put(issueType.getName(), issueType); - - IssueStatus issueStatus = this.issueStatusService.findByIssueStatusTypeIsReady(issueType.getWorkflow()); - issueStatusReadyMaps.put(issueType.getId().toString(), issueStatus); - - // �썙�겕�뵆濡쒖슦�뿉 �냽�빐�엳�뒗 遺��꽌 �젙蹂� - List<DepartmentVo> departments = this.departmentService.findWorkflowDepartment(issueType.getId()); - // 遺��꽌 �젙蹂대�� ���옣 - for (DepartmentVo department : departments) { - departmentMaps.put(department.getDepartmentName(), department); - } + for (IssueTypeCustomField issueTypeCustomField : project.getIssueTypeCustomFields()) { + // 鍮좊Ⅴ寃� 李얘린 �쐞�빐 �씠�뒋 ���엯 �븘�씠�뵒 + �궗�슜�옄 �젙�쓽 �븘�뱶 �븘�씠�뵒瑜� �궎濡� �븳�떎. + String makeKey = issueTypeCustomField.getIssueType().getId().toString() + issueTypeCustomField.getCustomField().getId().toString(); + issueTypeCustomFieldMaps.put(makeKey, issueTypeCustomField.getId()); } // �슦�꽑�닚�쐞瑜� 諛붾줈 李얠쓣 �닔 �엳寃� 以�鍮� @@ -3172,11 +3431,56 @@ 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 NULL 泥댄겕 �븿�닔 + * @param cell Cell + * @return boolean + */ + private Boolean cellNullCheck (Cell cell, int rowIndex) { + boolean result = false; + + // 臾몄옄�삎�떇�씤吏� 泥댄겕 + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK && cell.getCellType() != Cell.CELL_TYPE_STRING) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_NOT_STRING_TYPE, rowIndex)); + } + // 怨듬갚 �젣嫄� + if (cell != null && cell.getStringCellValue() != null) { + cell.setCellValue(cell.getStringCellValue().trim()); + } + + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK && cell.getCellType() == cell.CELL_TYPE_STRING + && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("")) { + result = true; + } + + return result; } // �뿊�� �븘�뱶�뿉 �엳�뒗 �젙蹂대�� �씠�뒋 form �쑝濡� �삷湲대떎. - private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, IssueStatus> issueStatusReadyMaps, Map<String, Project> projectMaps, Map<String, IssueType> issueTypeMaps, Map<String, - Priority> priorityMaps, Map<String, Severity> severityMaps, Map<String, Object> userMaps, Map<String, DepartmentVo> departmentMaps, Map<String, CustomField> customFieldMaps, Map<Long, Long> issueNumberMaps, List<String> headers) { + private IssueForm setIssueFormToExcelField(Row row, int rowIndex, Map<String, Priority> priorityMaps, + Map<String, Severity> severityMaps, Map<String, DepartmentVo> departmentMaps, + Map<String, CustomField> customFieldMaps, Map<String, CompanyField> companyFieldMaps, + Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, + List<String> headers) { IssueForm issueForm = new IssueForm(); issueForm.setRegisterId(this.webAppUtil.getLoginId()); Project project = null; @@ -3191,7 +3495,7 @@ break; case 1: // �궡�슜 - if (cell != null) { + if (cellNullCheck(cell, rowIndex)) { issueForm.setDescription(CommonUtil.convertExcelStringToCell(cell)); } else { // null �엯�젰 諛⑹� @@ -3200,23 +3504,12 @@ break; - case 2: // �봽濡쒖젥�듃 �궎�� �씠�뒋 踰덊샇 - project = this.setIssueFormProjectKeyAndIssueNumber(cell, issueForm, projectMaps, issueNumberMaps, rowIndex); - break; - - case 3: - // �씠�뒋 ���엯�쓣 IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormIssueType(cell, issueTypeMaps, issueForm, rowIndex); - // �씠�뒋 ���엯�뿉 �뿰寃곕맂 �썙�겕�뵆濡쒖슦�쓽 �긽�깭 �냽�꽦 '��湲�' �씤 �긽�깭瑜� issueForm �뿉 ���옣�븳�떎. - this.setIssueFormIssueStatus(issueStatusReadyMaps, issueForm, rowIndex); - break; - - case 4: + case 2: // �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎. this.setIssueFormPriority(cell, priorityMaps, issueForm, rowIndex); break; - case 5: + case 3: // 以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎. this.setIssueFormSeverity(cell, severityMaps, issueForm, rowIndex); break; @@ -3224,17 +3517,35 @@ // �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎. this.setIssueFormAssignee(cell, userMaps, issueForm, project); break;*/ + case 4: + // �떆�옉�씪�쓣 IssueForm �뿉 ���옣�븳�떎. + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { + this.setIssueFormPeriod(cell, issueForm, true, rowIndex); + } + break; + case 5: + // 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎. + if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { + this.setIssueFormPeriod(cell, issueForm, false, rowIndex); + } + break; case 6: - // �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormDepartment(cell, departmentMaps, issueForm, project); + // �뾽泥대�� IssueForm �뿉 ���옣�븳�떎. + if (cellNullCheck(cell, rowIndex)) { + this.setIssueFormCompanyField(cell, companyFieldMaps, issueForm, rowIndex); + } break; case 7: - // �떆�옉�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormPeriod(cell, issueForm, true, rowIndex); + // ISP瑜� IssueForm �뿉 ���옣�븳�떎. + if (cellNullCheck(cell, rowIndex)) { + this.setIssueFormIspField(cell, ispFieldMaps, issueForm, rowIndex); + } break; case 8: - // 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormPeriod(cell, issueForm, false, rowIndex); + // �샇�뒪�똿�쓣 IssueForm �뿉 ���옣�븳�떎. + if (cellNullCheck(cell, rowIndex)) { + this.setIssueFormHostingField(cell, hostingFieldMaps, issueForm, rowIndex); + } break; default: // 9踰� 遺��꽣�뒗 �궗�슜�옄 �젙�쓽 �븘�뱶. �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎. @@ -3245,9 +3556,48 @@ return issueForm; } + private void setIssueFormHostingField(Cell cell, Map<String, HostingField> hostingFieldMaps, IssueForm issueForm, int rowIndex) { + if (cell != null) { + Map<String, Object> issueHostingFields = new HashMap<>(); + HostingField hostingFieldMap = hostingFieldMaps.get(CommonUtil.convertExcelStringToCell(cell)); + if (hostingFieldMap == null) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_HOSTING_NOT_EXIST, rowIndex)); + } + ConvertUtil.copyProperties(hostingFieldMap, issueHostingFields); + issueForm.addIssueHostingField(issueHostingFields); + } + } + + private void setIssueFormIspField(Cell cell, Map<String, IspField> ispFieldMaps, IssueForm issueForm, int rowIndex) { + if (cell != null) { + Map<String, Object> issueIspFields = new HashMap<>(); + IspField ispFieldMap = ispFieldMaps.get(CommonUtil.convertExcelStringToCell(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(Cell cell, Map<String, CompanyField> companyFieldMaps, IssueForm issueForm, int rowIndex) { + if (cell != null) { + Map<String, Object> issueCompanyFields = new HashMap<>(); + CompanyField companyFieldMap = companyFieldMaps.get(CommonUtil.convertExcelStringToCell(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(Cell cell, IssueForm issueForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell, rowIndex)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TITLE_IS_NULL, rowIndex)); } @@ -3257,17 +3607,6 @@ // �젣紐� �쑀�슚�꽦 泥댄겕 this.verifyTitle(title); issueForm.setTitle(title); - } - - // �봽濡쒖젥�듃 �궎, �씠�뒋 怨좎쑀 踰덊샇, �떞�떦�옄瑜� IssueForm �뿉 ���옣�븳�떎. - private Project setIssueFormProjectKeyAndIssueNumber(Cell cell, IssueForm issueForm, Map<String, Project> projectMaps, Map<Long, Long> issueNumberMaps, int rowIndex) { - // �봽濡쒖젥�듃 �븘�씠�뵒瑜� IssueForm �뿉 ���옣�븳�떎. - Project project = this.setIssueFormProject(cell, projectMaps, issueForm, rowIndex); - - // �씠�뒋 怨좎쑀 踰덊샇瑜� IssueForm �뿉 ���옣�븳�떎. - this.setIssueFormIssueNumber(issueForm, issueNumberMaps, project, rowIndex); - - return project; } // �봽濡쒖젥�듃 �븘�씠�뵒瑜� IssueForm �뿉 ���옣�븳�떎. @@ -3303,38 +3642,10 @@ issueNumberMaps.put(project.getId(), ++issueNumber); // �씠�뒋 踰덊샇瑜� 1�뵫 利앷� �떆�궓�떎. } - // �씠�뒋 ���엯�쓣 IssueForm �뿉 ���옣�븳�떎. - private void setIssueFormIssueType(Cell cell, Map<String, IssueType> issueTypeMaps, IssueForm issueForm, int rowIndex) { - if (cell == null) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TYPE_IS_NULL, rowIndex)); - } - - IssueType issueType = issueTypeMaps.get(CommonUtil.convertExcelStringToCell(cell)); - - if (issueType == null) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_TYPE_NOT_EXIST, rowIndex)); - } - - issueForm.setIssueTypeId(issueType.getId()); - } - - // �씠�뒋 ���엯�뿉 �뿰寃곕맂 �썙�겕�뵆濡쒖슦�쓽 �긽�깭 �냽�꽦 '��湲�' �씤 �긽�깭瑜� issueForm �뿉 ���옣�븳�떎. - private void setIssueFormIssueStatus(Map<String, IssueStatus> issueStatusReadyMaps, IssueForm issueForm, int rowIndex) { - IssueStatus issueStatus = issueStatusReadyMaps.get(issueForm.getIssueTypeId().toString()); - - if (issueStatus == null) { - throw new OwlRuntimeException( - this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_ISSUE_STATUS_READY_NOT_EXIST, rowIndex)); - } - - issueForm.setIssueStatusId(issueStatus.getId()); - } // �슦�꽑�닚�쐞瑜� IssueForm �뿉 ���옣�븳�떎. private void setIssueFormPriority(Cell cell, Map<String, Priority> priorityMaps, IssueForm issueForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell, rowIndex)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PRIORITY_IS_NULL, rowIndex)); } @@ -3351,7 +3662,7 @@ // 以묒슂�룄瑜� IssueForm �뿉 ���옣�븳�떎. private void setIssueFormSeverity(Cell cell, Map<String, Severity> severityMaps, IssueForm issueForm, int rowIndex) { - if (cell == null) { + if (!cellNullCheck(cell, rowIndex)) { throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_SEVERITY_IS_NULL, rowIndex)); } @@ -3381,36 +3692,19 @@ issueForm.setUserIds(userIds); } } - - // �떞�떦遺��꽌瑜� IssueForm �뿉 ���옣�븳�떎. - private void setIssueFormDepartment(Cell cell, Map<String, DepartmentVo> departmentMaps, IssueForm issueForm, Project project) { - if (cell != null) { - String[] splitDepartment = CommonUtil.convertExcelStringToCell(cell).split("#"); - - // 媛믪씠 怨듬갚�씠硫� 以묒� - String cellValue = CommonUtil.convertExcelStringToCell(cell); - if (StringUtils.isEmpty(cellValue)) { - return; - } - - List<Long> departmentIds = Lists.newArrayList(); - - for (String department : splitDepartment) { - DepartmentVo departmentVo = departmentMaps.get(department); - departmentIds.add(departmentVo.getId()); - } - issueForm.setDepartmentIds(departmentIds); - } - } - // �떆�옉�씪, 醫낅즺�씪�쓣 IssueForm �뿉 ���옣�븳�떎. private void setIssueFormPeriod(Cell cell, IssueForm issueForm, Boolean checkStartDate, int rowIndex) { if (cell != null && !cell.toString().equals("")) { // 媛믪씠 怨듬갚�씠硫� 以묒� String cellValue = CommonUtil.convertExcelStringToCell(cell); - if (StringUtils.isEmpty(cellValue)) { + if (StringUtils.isEmpty(cellValue) || cell.toString().equals("null")) { return; + } + + if (cell.toString().length() < 10 && cell.toString().contains("-")) { //�궇吏� �삎�떇 泥댄겕 + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_PERIOD_NOT_DASH, rowIndex)); } Date startDate; @@ -3426,6 +3720,12 @@ issueForm.setStartDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); } 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 { // �궇吏� �쑀�슚�꽦 泥댄겕 @@ -3438,7 +3738,7 @@ } } - // �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎. + // �궗�슜�옄 �젙�쓽 �븘�뱶 �젙蹂대�� IssueForm �뿉 ���옣�븳�떎.- private void setIssueFormCustomFieldValue(Cell cell, Map<String, CustomField> customFieldMaps, IssueForm issueForm, String customFieldName, int rowIndex) { if (cell != null) { String cellValue = CommonUtil.convertExcelStringToCell(cell); @@ -3464,9 +3764,18 @@ case EMAIL: case SITE: case TEL: - if (cellValue.length() > 100) { + if (customField.getCustomFieldType() != INPUT && cellValue.length() > 100) { //INPUT ���엯�� 100�옄 �젣�븳 �뾾�쓬 throw new OwlRuntimeException( this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT)); + } + + if (customField.getCustomFieldType() == DATETIME) { //DATETIME�씪 寃쎌슦 format 蹂�寃� + if (cell.toString().length() < 10 && cell.toString().contains("-")) { //�궇吏� �삎�떇 泥댄겕 + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_DATETIME_NOT_DASH, rowIndex)); + } + Date date = cell.getDateCellValue(); + cellValue = new SimpleDateFormat("yyyy-MM-dd H:mm:ss").format(date); } issueCustomFieldMap.put("customFieldId", customField.getId()); @@ -3574,7 +3883,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)); @@ -3601,10 +3910,43 @@ 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, List<MultipartFile> multipartFiles) { + if (emailCommonForm.getSendEmails().size() < 1) { + throw new OwlRuntimeException( + this.messageAccessor.getMessage(MsgConstants.ISSUE_NOT_SEND_USER)); + } + + Issue issue = null; + if(emailCommonForm.getIssueId() != null) { + issue = this.getIssue(emailCommonForm.getIssueId()); + } + + // 諛쒖떊�옄 �몴�떆 + User user = this.webAppUtil.getLoginUserObject(); + UserVo toUser = this.webAppUtil.getLoginUser(); + + // �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏� + log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_ANOTHER_USER_SEND_EMAIL)); + StringBuilder sb = new StringBuilder(); + + Locale locale = CommonUtil.getUserLanguage(user.getLanguage()); + String[] sendMails = ConvertUtil.ToArray(emailCommonForm.getSendEmails()); + for(int i=0; i < sendMails.length; i++) { + sendMails[i] = CommonUtil.decryptAES128(sendMails[i]); + } + this.systemEmailService.sendEmail(emailCommonForm.getTitle(), emailCommonForm.getDescription(), sendMails, null, multipartFiles); + + if (issue != null) { + this.issueHistoryService.detectSendIssueMail(IssueHistoryType.SEND, emailCommonForm.getSendEmails(), sb); + this.issueHistoryService.addIssueHistory(issue, IssueHistoryType.SEND, sb.toString()); + } } // �삁�빟 諛쒖깮 �씠�뒋瑜� �떎�뻾�븳�떎 @@ -3775,44 +4117,56 @@ @Transactional @Override public void modifyParentIssue(IssueForm issueDownForm) { - Issue issue = this.getIssue(issueDownForm.getId()); //�븯�쐞 �씠�뒋 + //Issue issue = this.getIssue(issueDownForm.getId()); //�븯�쐞 �씠�뒋 Long newParentIssueId = issueDownForm.getParentIssueId(); //蹂�寃쏀븷 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋 - StringBuilder sb = new StringBuilder(); - Issue parentIssue = issue.getParentIssue(); //蹂�寃� �쟾 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋 - if(parentIssue != null && parentIssue.getId().equals(newParentIssueId)){ //蹂�寃� �쟾 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋媛� 議댁옱 �븷 寃쎌슦 - this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb); - this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); - } + for (Long downId : issueDownForm.getIds()) { + Issue issue = this.getIssue(downId); - if (newParentIssueId != null) { // 異붽� �븷 寃쎌슦 - parentIssue = this.getIssue(newParentIssueId); //�긽�쐞�씠�뒋(myIssue) - issue.setParentIssue(parentIssue); //myIssue瑜� �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋濡� set - this.issueHistoryService.detectDownIssues(IssueHistoryType.ADD, issue, sb); //issue = �븯�쐞�씠�뒋 - } else{ - // �궘�젣 �븷 寃쎌슦 - this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb); - issue.setParentIssue(null); + Issue parentIssue = issue.getParentIssue(); //蹂�寃� �쟾 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋 + if(parentIssue != null && parentIssue.getId().equals(newParentIssueId)){ //蹂�寃� �쟾 �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋媛� 議댁옱 �븷 寃쎌슦 + this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb); + this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); + } + + if (newParentIssueId != null) { // 異붽� �븷 寃쎌슦 + parentIssue = this.getIssue(newParentIssueId); //�긽�쐞�씠�뒋(myIssue) + issue.setParentIssue(parentIssue); //myIssue瑜� �븯�쐞�씠�뒋�쓽 �긽�쐞�씠�뒋濡� set + this.issueHistoryService.detectDownIssues(IssueHistoryType.ADD, issue, sb); //issue = �븯�쐞�씠�뒋 + } else{ + // �궘�젣 �븷 寃쎌슦 + this.issueHistoryService.detectDownIssues(IssueHistoryType.DELETE, issue, sb); + issue.setParentIssue(null); + } + this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); //parentIssue = myIssue(湲곕줉�� �쁽�옱 �긽�꽭�럹�씠吏��뿉 �빐�빞�븯�땲源�) + this.issueRepository.saveAndFlush(issue); } - this.issueHistoryService.addIssueHistory(parentIssue, IssueHistoryType.MODIFY, sb.toString()); //parentIssue = myIssue(湲곕줉�� �쁽�옱 �긽�꽭�럹�씠吏��뿉 �빐�빞�븯�땲源�) - this.issueRepository.saveAndFlush(issue); } @Override public void findPartner(Map<String, Object> resJsonData, Map<String, Object> params) { Long issueTypeId = MapUtil.getLong(params, "issueTypeId"); - IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); // �씠�뒋�쓽 �씠�뒋�쑀�삎 媛앹껜 - Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // �씠�뒋�쑀�삎蹂꾨줈 �궗�슜以묒씤 �뾽泥�/ISP/�샇�뒪�똿 媛� - List<UsePartnerVo> usePartnerVos = Lists.newArrayList(); + Integer using = 0; + + if (issueTypeId != null) { + IssueType issueType = this.issueTypeService.getIssueType(issueTypeId); // �씠�뒋�쓽 �씠�뒋�쑀�삎 媛앹껜 + using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // �씠�뒋�쑀�삎蹂꾨줈 �궗�슜以묒씤 �뾽泥�/ISP/�샇�뒪�똿 媛� + } else { + for (int partner : UsePartner.partners) { + using += partner; + } + } + for (Integer usePartner : UsePartner.partners) { //1(�뾽泥�), 2(ISP), 4(�샇�뒪�똿) UsePartnerVo usePartnerVo = UsePartner.checkUsePartner(using, usePartner); if (usePartnerVo != null) { usePartnerVos.add(usePartnerVo); } - resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos); } + + resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos); } @Override -- Gitblit v1.8.0