| | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.DATETIME; |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.INPUT; |
| | | import static kr.wisestone.owl.domain.enumType.CustomFieldType.*; |
| | | |
| | | @Service |
| | | public class IssueServiceImpl extends AbstractServiceImpl<Issue, Long, JpaRepository<Issue, Long>> implements IssueService { |
| | |
| | | issueApiForm.addUseIssueCustomFieldId(customFieldApiOverlap.getCustomField().getId()); |
| | | } |
| | | |
| | | // 종료상태가 아닌 중복된 상위 이슈검색 |
| | | // 중복된 상위 이슈검색 |
| | | List<Issue> issues = this.findIssue(issueApiForm, customFieldApiOverlaps, user.getId()); |
| | | int size = issues.size(); |
| | | if (size > 0) { |
| | |
| | | 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) { |
| | |
| | | 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)); // 각 프로젝트의 고유 이슈 번호 생성 |
| | |
| | | // 1번 헤더부터 데이터 영역 |
| | | if (rowIndex > 1) { |
| | | // 이슈로 등록하기 위해 IssueForm 에 데이터를 셋팅한다. |
| | | IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, departmentMaps, customFieldMaps, |
| | | IssueForm newIssueForm = this.setIssueFormToExcelField(row, (rowIndex + 1), priorityMaps, severityMaps, customFieldMaps, |
| | | companyFieldMaps, ispFieldMaps, hostingFieldMaps, headers); |
| | | ConvertUtil.copyProperties(issueForm, newIssueForm); |
| | | |
| | |
| | | // 이슈 담당자 벌크 등록 |
| | | this.bulkInsertIssueAssignee(issueForms, workspace); |
| | | // 0.361 - 0.705 |
| | | |
| | | |
| | | // 1.816 |
| | | /*StopWatch serviceStart = new StopWatch(); |
| | | serviceStart.start();*/ |
| | |
| | | issueCompany.setCompanyField(companyField); |
| | | issueCompany.setIssue(issue); |
| | | this.issueCompanyRepository.saveAndFlush(issueCompany); |
| | | |
| | | |
| | | // 사용자가 ISP를 직접 입력하지 않았을 경우 업체에 등록되어있는 ISP 설정 |
| | | if (issueForm.getIssueIspFields() == null || issueForm.getIssueIspFields().size() < 1) { |
| | | // 업체의 ISP가 있는 경우 issueISP 등록 |
| | |
| | | issueCustomField.put("registerId", this.webAppUtil.getLoginId()); |
| | | issueCustomFieldValueMaps.add(issueCustomField); |
| | | } |
| | | |
| | | |
| | | // 엑셀에 업체명을 입력하지 않았을 경우 같은 도메인 업체 찾기 |
| | | if (issueForm.getIssueCompanyFields() == null || issueForm.getIssueCompanyFields().size() < 1) { |
| | | // 같은 도메인 업체 찾기 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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 체크 |
| | | * 빈 값이 아닌 cell 체크 |
| | | * @param cell Cell |
| | | * @return boolean |
| | | */ |
| | | private Boolean cellNullCheck (Cell cell) { |
| | | if (cell != null ) { |
| | | if (cell.getCellType() != Cell.CELL_TYPE_BLANK) { |
| | | if (cell.getCellType() == Cell.CELL_TYPE_STRING && cell.getStringCellValue() != null) { |
| | | 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, Map<String, CompanyField> companyFieldMaps, |
| | | Map<String, IspField> ispFieldMaps, Map<String, HostingField> hostingFieldMaps, |
| | | 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); |
| | | boolean isNull = cellNullCheck(cell); |
| | | |
| | | String cellStr = ""; |
| | | if (!isNull) { |
| | | cellStr = CommonUtil.convertExcelStringToCell(cell); |
| | | boolean isNull = true; |
| | | |
| | | // 공백 제거 |
| | | cell.setCellValue(cellStr.trim()); |
| | | } else { |
| | | cell.setCellValue(cellStr); |
| | | if (cell != null) { |
| | | isNull = cellNullCheck(cell); |
| | | cellStr = stringToCell(cell, isNull); //cell을 String으로 변환 |
| | | } |
| | | |
| | | switch (cellIndex) { |
| | |
| | | } |
| | | |
| | | if (checkStartDate) { |
| | | issueForm.setStartDate(periodDate); |
| | | issueForm.setStartDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); |
| | | } else { |
| | | issueForm.setCompleteDate(periodDate); |
| | | |
| | | issueForm.setCompleteDate(DateUtil.convertDateToStr(startDate, "yyyy-MM-dd")); |
| | | |
| | | // 종료일만 입력 했을 경우 |
| | | if (issueForm.getCompleteDate() != null && issueForm.getStartDate() == null) { |
| | | throw new OwlRuntimeException( |
| | |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | this.messageAccessor.getMessage(MsgConstants.CUSTOM_FIELD_TEXT_TYPE_MAX_LENGTH_OUT)); |
| | | } |
| | | |
| | | if (customField.getCustomFieldType() == DATETIME) { //DATETIME일 경우 format 변경 |
| | | //DATETIME일 경우 format 변경 |
| | | if (customField.getCustomFieldType() == DATETIME) { |
| | | Date date = DateUtil.convertStrToDate(cellValue); |
| | | if (date == null) { |
| | | throw new OwlRuntimeException( |
| | |
| | | } |
| | | } |
| | | |
| | | //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); |