260625_01_ENH: 연구, 실사 수정사항 적용 1차
This commit is contained in:
@@ -118,22 +118,36 @@ public class ReviewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "평가양식 업로드")
|
@Operation(summary = "평가양식 업로드")
|
||||||
@PostMapping(value = "/template/upload/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/template/upload/{reviewType}/{classification}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public String uploadReviewTemplate(
|
public String uploadReviewTemplate(
|
||||||
@PathVariable Integer reviewType,
|
@PathVariable Integer reviewType,
|
||||||
|
@PathVariable Integer classification,
|
||||||
@RequestParam("file") MultipartFile file
|
@RequestParam("file") MultipartFile file
|
||||||
) {
|
) {
|
||||||
return reviewTemplateService.uploadReviewTemplate(reviewType, file);
|
return reviewTemplateService.uploadReviewTemplate(reviewType, classification, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "평가양식 다운로드")
|
@Operation(summary = "평가양식 다운로드")
|
||||||
@GetMapping("/template/download/{reviewType}")
|
@GetMapping("/template/download/{reviewType}/{classification}")
|
||||||
public ResponseEntity<Resource> downloadReviewTemplate(
|
public ResponseEntity<Resource> downloadReviewTemplate(
|
||||||
@PathVariable Integer reviewType
|
@PathVariable Integer reviewType,
|
||||||
|
@PathVariable Integer classification
|
||||||
) {
|
) {
|
||||||
return download(
|
return download(
|
||||||
reviewTemplateService.getReviewTemplateResource(reviewType),
|
reviewTemplateService.getReviewTemplateResource(reviewType, classification),
|
||||||
reviewTemplateService.getReviewTemplateFileName(reviewType)
|
reviewTemplateService.getReviewTemplateFileName(reviewType, classification)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "평가양식 pdf 다운로드")
|
||||||
|
@GetMapping("/template/pdf/{reviewType}/{classification}")
|
||||||
|
public ResponseEntity<Resource> downloadReviewPdfTemplate(
|
||||||
|
@PathVariable Integer reviewType,
|
||||||
|
@PathVariable Integer classification
|
||||||
|
) {
|
||||||
|
return download(
|
||||||
|
reviewTemplateService.getReviewTemplatePdfResource(reviewType, classification),
|
||||||
|
reviewTemplateService.getReviewTemplatePdfFileName(reviewType, classification)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,35 +15,35 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PerformanceDownloadDto extends PerformanceUploadDto {
|
public class PerformanceDownloadDto extends PerformanceUploadDto {
|
||||||
|
|
||||||
@ExcelColumn(header = "지자체 평가자", order = 24, width = 16)
|
@ExcelColumn(header = "지자체 평가자", order = 31, width = 16)
|
||||||
@Schema(description = "지자체 평가자")
|
@Schema(description = "지자체 평가자")
|
||||||
private String localReviewUser;
|
private String localReviewUser;
|
||||||
|
|
||||||
@ExcelColumn(header = "지자체 평가 상태", order = 25, width = 16)
|
@ExcelColumn(header = "지자체 평가 상태", order = 32, width = 16)
|
||||||
@Schema(description = "지자체 평가 상태")
|
@Schema(description = "지자체 평가 상태")
|
||||||
private String localReviewStatus;
|
private String localReviewStatus;
|
||||||
|
|
||||||
@ExcelColumn(header = "지자체 평가 일시", order = 26, width = 16)
|
@ExcelColumn(header = "지자체 평가 일시", order = 33, width = 16)
|
||||||
@Schema(description = "지자체 평가 일시")
|
@Schema(description = "지자체 평가 일시")
|
||||||
private String localReviewDt;
|
private String localReviewDt;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링1 평가자", order = 27, width = 16)
|
@ExcelColumn(header = "모니터링1 평가자", order = 34, width = 16)
|
||||||
@Schema(description = "모니터링1 평가자")
|
@Schema(description = "모니터링1 평가자")
|
||||||
private String monitoringReviewUser1;
|
private String monitoringReviewUser1;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링1 평가 상태", order = 28, width = 16)
|
@ExcelColumn(header = "모니터링1 평가 상태", order = 35, width = 16)
|
||||||
@Schema(description = "모니터링1 평가 상태")
|
@Schema(description = "모니터링1 평가 상태")
|
||||||
private String monitoringReviewStatus1;
|
private String monitoringReviewStatus1;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링1 평가 일시", order = 29, width = 16)
|
@ExcelColumn(header = "모니터링1 평가 일시", order = 36, width = 16)
|
||||||
@Schema(description = "모니터링1 평가 일시")
|
@Schema(description = "모니터링1 평가 일시")
|
||||||
private String monitoringReviewDt1;
|
private String monitoringReviewDt1;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링2 평가자", order = 30, width = 16)
|
@ExcelColumn(header = "모니터링2 평가자", order = 37, width = 16)
|
||||||
@Schema(description = "모니터링2 평가자")
|
@Schema(description = "모니터링2 평가자")
|
||||||
private String monitoringReviewUser2;
|
private String monitoringReviewUser2;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링2 평가 상태", order = 31, width = 16)
|
@ExcelColumn(header = "모니터링2 평가 상태", order = 38, width = 16)
|
||||||
@Schema(description = "모니터링2 평가 상태")
|
@Schema(description = "모니터링2 평가 상태")
|
||||||
private String monitoringReviewStatus2;
|
private String monitoringReviewStatus2;
|
||||||
|
|
||||||
|
|||||||
@@ -15,99 +15,127 @@ import lombok.experimental.SuperBuilder;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PerformanceUploadDto {
|
public class PerformanceUploadDto {
|
||||||
|
|
||||||
@ExcelColumn(header = "연번", order = 0, width = 10)
|
@ExcelColumn(header = "NO", order = 0, width = 10)
|
||||||
|
@Schema(description = "NO")
|
||||||
|
private String performanceNo;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "연번", order = 1, width = 10)
|
||||||
@Schema(description = "연번")
|
@Schema(description = "연번")
|
||||||
private String performanceId;
|
private String performanceId;
|
||||||
|
|
||||||
@ExcelColumn(header = "사업유형", order = 1, width = 10)
|
@ExcelColumn(header = "사업유형", order = 2, width = 10)
|
||||||
@Schema(description = "사업유형")
|
@Schema(description = "사업유형")
|
||||||
private String businessType;
|
private String businessType;
|
||||||
|
|
||||||
@ExcelColumn(header = "분야(장르)", order = 2, width = 10)
|
@ExcelColumn(header = "분야(장르)", order = 3, width = 10)
|
||||||
@Schema(description = "분야(장르)")
|
@Schema(description = "분야(장르)")
|
||||||
private String genre;
|
private String genre;
|
||||||
|
|
||||||
@ExcelColumn(header = "지역", order = 3, width = 10)
|
@ExcelColumn(header = "지역", order = 4, width = 10)
|
||||||
@Schema(description = "지역")
|
@Schema(description = "지역")
|
||||||
private String performanceArea;
|
private String performanceArea;
|
||||||
|
|
||||||
@ExcelColumn(header = "단체(인) 명", order = 4, width = 11)
|
@ExcelColumn(header = "지역 세부", order = 5, width = 10)
|
||||||
|
@Schema(description = "지역 세부")
|
||||||
|
private String performanceAreaDetail;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "단체(인) 명", order = 6, width = 11)
|
||||||
@Schema(description = "단체(인) 명")
|
@Schema(description = "단체(인) 명")
|
||||||
private String artistName;
|
private String artistName;
|
||||||
|
|
||||||
@ExcelColumn(header = "사업 명", order = 5, width = 10)
|
@ExcelColumn(header = "사업 명", order = 7, width = 10)
|
||||||
@Schema(description = "사업 명")
|
@Schema(description = "사업 명")
|
||||||
private String performanceName;
|
private String performanceName;
|
||||||
|
|
||||||
@ExcelColumn(header = "사업 수행 월", order = 6, width = 12)
|
@ExcelColumn(header = "사업 수행 월", order = 8, width = 12)
|
||||||
@Schema(description = "사업 수행 월")
|
@Schema(description = "사업 수행 월")
|
||||||
private String performanceStartMonth;
|
private String performanceStartMonth;
|
||||||
|
|
||||||
@ExcelColumn(header = "사업 일정", order = 7, width = 10)
|
@ExcelColumn(header = "사업 일정", order = 9, width = 10)
|
||||||
@Schema(description = "사업 일정")
|
@Schema(description = "사업 일정")
|
||||||
private String performanceDtInfo;
|
private String performanceDtInfo;
|
||||||
|
|
||||||
@ExcelColumn(header = "운영 시간", order = 8, width = 10)
|
@ExcelColumn(header = "운영 시간", order = 10, width = 10)
|
||||||
@Schema(description = "운영 시간")
|
@Schema(description = "운영 시간")
|
||||||
private String performanceTimeInfo;
|
private String performanceTimeInfo;
|
||||||
|
|
||||||
@ExcelColumn(header = "티켓 예약", order = 9, width = 10)
|
@ExcelColumn(header = "티켓 예약", order = 11, width = 10)
|
||||||
@Schema(description = "티켓 예약")
|
@Schema(description = "티켓 예약")
|
||||||
private String ticketReservationStatus;
|
private String ticketReservationStatus;
|
||||||
|
|
||||||
@ExcelColumn(header = "티켓 비고", order = 10, width = 10)
|
@ExcelColumn(header = "티켓 비고", order = 12, width = 10)
|
||||||
@Schema(description = "티켓 비고")
|
@Schema(description = "티켓 비고")
|
||||||
private String ticketReservationMemo;
|
private String ticketReservationMemo;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링 일정", order = 11, width = 14)
|
@ExcelColumn(header = "모니터링 일정", order = 13, width = 14)
|
||||||
@Schema(description = "모니터링 일정")
|
@Schema(description = "모니터링 일정")
|
||||||
private String monitoringDate;
|
private String monitoringDate;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링 시간", order = 12, width = 14)
|
@ExcelColumn(header = "모니터링 시간", order = 14, width = 14)
|
||||||
@Schema(description = "모니터링 시간")
|
@Schema(description = "모니터링 시간")
|
||||||
private String monitoringTimeInfo;
|
private String monitoringTimeInfo;
|
||||||
|
|
||||||
@ExcelColumn(header = "모니터링 방문 장소", order = 13, width = 18)
|
@ExcelColumn(header = "모니터링 필요여부", order = 15, width = 14)
|
||||||
|
@Schema(description = "모니터링 필요여부")
|
||||||
|
private String needMonitoring;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "서면평가 필요여부", order = 16, width = 14)
|
||||||
|
@Schema(description = "서면평가 필요여부")
|
||||||
|
private String needWrittenReview;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "교부여부", order = 17, width = 14)
|
||||||
|
@Schema(description = "교부여부")
|
||||||
|
private String checkDeliver;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "타임트리 확인일시", order = 18, width = 14)
|
||||||
|
@Schema(description = "타임트리 확인일시")
|
||||||
|
private String timeTreeCheckDt;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "모니터링 방문 장소", order = 19, width = 18)
|
||||||
@Schema(description = "모니터링 방문 장소")
|
@Schema(description = "모니터링 방문 장소")
|
||||||
private String monitoringAddress;
|
private String monitoringAddress;
|
||||||
|
|
||||||
@ExcelColumn(header = "대표자 명", order = 14, width = 10)
|
@ExcelColumn(header = "메모", order = 20, width = 10)
|
||||||
@Schema(description = "대표자 명")
|
|
||||||
private String ownStaffName;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "대표자 연락처1", order = 15, width = 14)
|
|
||||||
@Schema(description = "대표자 연락처1")
|
|
||||||
private String ownStaffTel1;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "대표자 연락처2", order = 16, width = 14)
|
|
||||||
@Schema(description = "대표자 연락처2")
|
|
||||||
private String ownStaffTel2;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "대표자 이메일", order = 17, width = 14)
|
|
||||||
@Schema(description = "대표자 이메일")
|
|
||||||
private String ownStaffEmail;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "실무자 명", order = 18, width = 10)
|
|
||||||
@Schema(description = "실무자 명")
|
|
||||||
private String contactStaffName;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "실무자 연락처1", order = 19, width = 14)
|
|
||||||
@Schema(description = "실무자 연락처1")
|
|
||||||
private String contactStaffTel1;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "실무자 연락처2", order = 20, width = 14)
|
|
||||||
@Schema(description = "실무자 연락처2")
|
|
||||||
private String contactStaffTel2;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "실무자 이메일", order = 21, width = 14)
|
|
||||||
@Schema(description = "실무자 이메일")
|
|
||||||
private String contactStaffEmail;
|
|
||||||
|
|
||||||
@ExcelColumn(header = "메모", order = 22, width = 10)
|
|
||||||
@Schema(description = "메모")
|
@Schema(description = "메모")
|
||||||
private String performanceMemo;
|
private String performanceMemo;
|
||||||
|
|
||||||
@ExcelColumn(header = "요원 비용지급일", order = 23, width = 16)
|
@ExcelColumn(header = "보고서 확인여부", order = 21, width = 10)
|
||||||
|
@Schema(description = "보고서 확인여부")
|
||||||
|
private String checkReport;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "요원 비용지급일", order = 22, width = 16)
|
||||||
@Schema(description = "요원 비용지급일")
|
@Schema(description = "요원 비용지급일")
|
||||||
private String monitoringPaymentDate;
|
private String monitoringPaymentDate;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "대표자 명", order = 23, width = 10)
|
||||||
|
@Schema(description = "대표자 명")
|
||||||
|
private String ownStaffName;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "대표자 연락처1", order = 24, width = 14)
|
||||||
|
@Schema(description = "대표자 연락처1")
|
||||||
|
private String ownStaffTel1;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "대표자 연락처2", order = 25, width = 14)
|
||||||
|
@Schema(description = "대표자 연락처2")
|
||||||
|
private String ownStaffTel2;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "대표자 이메일", order = 26, width = 14)
|
||||||
|
@Schema(description = "대표자 이메일")
|
||||||
|
private String ownStaffEmail;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "실무자 명", order = 27, width = 10)
|
||||||
|
@Schema(description = "실무자 명")
|
||||||
|
private String contactStaffName;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "실무자 연락처1", order = 28, width = 14)
|
||||||
|
@Schema(description = "실무자 연락처1")
|
||||||
|
private String contactStaffTel1;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "실무자 연락처2", order = 29, width = 14)
|
||||||
|
@Schema(description = "실무자 연락처2")
|
||||||
|
private String contactStaffTel2;
|
||||||
|
|
||||||
|
@ExcelColumn(header = "실무자 이메일", order = 30, width = 14)
|
||||||
|
@Schema(description = "실무자 이메일")
|
||||||
|
private String contactStaffEmail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ public class TPerformanceMonitoringScheduleEntity {
|
|||||||
@Column(name = "performance_id", nullable = false)
|
@Column(name = "performance_id", nullable = false)
|
||||||
private Integer performanceId;
|
private Integer performanceId;
|
||||||
|
|
||||||
@NotNull
|
@Column(name = "monitoring_date")
|
||||||
@Column(name = "monitoring_date", nullable = false)
|
|
||||||
private LocalDate monitoringDate;
|
private LocalDate monitoringDate;
|
||||||
|
|
||||||
@Size(max = 256)
|
@Size(max = 256)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.kri.gwcf.review.back.dto.monitoring.MonitoringApplyUserDto;
|
|||||||
import com.kri.gwcf.review.back.dto.performance.PerformanceAssignDto;
|
import com.kri.gwcf.review.back.dto.performance.PerformanceAssignDto;
|
||||||
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
|
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
|
||||||
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TUserDetailEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TUserDetailEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.mapper.kon.KonMapper;
|
import com.kri.gwcf.review.back.persistence.mapper.kon.KonMapper;
|
||||||
@@ -84,22 +85,28 @@ public class AssignService {
|
|||||||
|
|
||||||
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(Integer performanceId) {
|
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(Integer performanceId) {
|
||||||
List<PerformanceApplyUserDto> applyUsers = findKonPerformanceApplyUser(performanceId);
|
List<PerformanceApplyUserDto> applyUsers = findKonPerformanceApplyUser(performanceId);
|
||||||
|
if (applyUsers.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
List<String> userIds = applyUsers.stream()
|
List<String> userIds = applyUsers.stream()
|
||||||
.map(PerformanceApplyUserDto::getUserId)
|
.map(PerformanceApplyUserDto::getUserId)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.toList();
|
||||||
|
Set<String> userIdSet = Set.copyOf(userIds);
|
||||||
|
|
||||||
Map<String, TUserEntity> userMap = userRepository.findAllById(userIds).stream()
|
Map<String, TUserEntity> userMap = userRepository.findAllById(userIds).stream()
|
||||||
.collect(Collectors.toMap(TUserEntity::getUserId, Function.identity()));
|
.collect(Collectors.toMap(TUserEntity::getUserId, Function.identity()));
|
||||||
|
|
||||||
Map<String, Map<String, String>> userDetailMap = userIds.stream()
|
Map<String, Map<String, String>> userDetailMap = userDetailRepository.findAll().stream()
|
||||||
.collect(Collectors.toMap(
|
.filter(detail -> userIdSet.contains(detail.getUserId()))
|
||||||
Function.identity(),
|
.collect(Collectors.groupingBy(
|
||||||
userId -> userDetailRepository.findByIdUserId(userId).stream()
|
TUserDetailEntity::getUserId,
|
||||||
.collect(Collectors.toMap(
|
Collectors.toMap(
|
||||||
TUserDetailEntity::getUserDetailKey,
|
TUserDetailEntity::getUserDetailKey,
|
||||||
TUserDetailEntity::getUserDetailValue
|
TUserDetailEntity::getUserDetailValue,
|
||||||
))
|
(left, right) -> right
|
||||||
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
return applyUsers.stream()
|
return applyUsers.stream()
|
||||||
@@ -256,28 +263,55 @@ public class AssignService {
|
|||||||
int successCount = 0;
|
int successCount = 0;
|
||||||
List<ExcelErrorDto> errorList = new ArrayList<>();
|
List<ExcelErrorDto> errorList = new ArrayList<>();
|
||||||
Set<Integer> uploadedPerformanceIds = new java.util.HashSet<>();
|
Set<Integer> uploadedPerformanceIds = new java.util.HashSet<>();
|
||||||
|
Set<Integer> existingPerformanceIds = performanceRepository.findAll().stream()
|
||||||
|
.map(TPerformanceEntity::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<String> existingUserIds = userRepository.findAll().stream()
|
||||||
|
.map(TUserEntity::getUserId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Map<Integer, List<TPerformanceAssignEntity>> currentWrittenAssignMap =
|
||||||
|
performanceAssignRepository.findAll().stream()
|
||||||
|
.filter(assign -> Objects.equals(assign.getAssignType(), 2))
|
||||||
|
.collect(Collectors.groupingBy(TPerformanceAssignEntity::getPerformanceId));
|
||||||
|
Set<String> reviewedAssignKeys = performanceReviewRepository.findAll().stream()
|
||||||
|
.map(review -> reviewKey(review.getPerformanceId(), review.getReviewType(), review.getRegUser()))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
WrittenUserAssignDto row = rows.get(i);
|
WrittenUserAssignDto row = rows.get(i);
|
||||||
int rowNumber = i + 2;
|
int rowNumber = i + 2;
|
||||||
|
|
||||||
List<ExcelErrorDto> rowErrors = validateWrittenAssignRow(row, rowNumber);
|
List<ExcelErrorDto> rowErrors = validateWrittenAssignRow(
|
||||||
|
row,
|
||||||
|
rowNumber,
|
||||||
|
existingPerformanceIds,
|
||||||
|
existingUserIds
|
||||||
|
);
|
||||||
if (!rowErrors.isEmpty()) {
|
if (!rowErrors.isEmpty()) {
|
||||||
errorList.addAll(rowErrors);
|
errorList.addAll(rowErrors);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
||||||
|
if (performanceId == null) {
|
||||||
|
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "사업 연번은 숫자로 입력해야 합니다."));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (performanceId % 100 != 1) {
|
||||||
|
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "사업 연번의 끝은 01로 끝나야 합니다."));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!uploadedPerformanceIds.add(performanceId)) {
|
if (!uploadedPerformanceIds.add(performanceId)) {
|
||||||
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "하나의 사업에는 서면평가위원을 1명만 배정할 수 있습니다."));
|
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "하나의 사업에는 서면평가위원을 1명만 배정할 수 있습니다."));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TPerformanceAssignEntity> currentAssigns =
|
List<TPerformanceAssignEntity> currentAssigns =
|
||||||
performanceAssignRepository.findByPerformanceIdAndAssignType(performanceId, 2);
|
currentWrittenAssignMap.getOrDefault(performanceId, Collections.emptyList());
|
||||||
boolean sameAssignExists = currentAssigns.size() == 1
|
boolean sameAssignExists = currentAssigns.size() == 1
|
||||||
&& Objects.equals(currentAssigns.get(0).getAssignUser(), row.getUserId());
|
&& Objects.equals(currentAssigns.get(0).getAssignUser(), row.getUserId());
|
||||||
if (!sameAssignExists && currentAssigns.stream().anyMatch(this::hasReview)) {
|
if (!sameAssignExists && currentAssigns.stream()
|
||||||
|
.anyMatch(assign -> reviewedAssignKeys.contains(reviewKey(assign)))) {
|
||||||
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "리뷰가 있는 배정은 변경할 수 없습니다."));
|
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "리뷰가 있는 배정은 변경할 수 없습니다."));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -319,7 +353,9 @@ public class AssignService {
|
|||||||
|
|
||||||
private List<ExcelErrorDto> validateWrittenAssignRow(
|
private List<ExcelErrorDto> validateWrittenAssignRow(
|
||||||
WrittenUserAssignDto row,
|
WrittenUserAssignDto row,
|
||||||
int rowNumber
|
int rowNumber,
|
||||||
|
Set<Integer> existingPerformanceIds,
|
||||||
|
Set<String> existingUserIds
|
||||||
) {
|
) {
|
||||||
List<ExcelErrorDto> errors = new ArrayList<>();
|
List<ExcelErrorDto> errors = new ArrayList<>();
|
||||||
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
||||||
@@ -327,13 +363,13 @@ public class AssignService {
|
|||||||
|
|
||||||
if (performanceId == null) {
|
if (performanceId == null) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "사업 연번", "사업 연번은 숫자여야 합니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "사업 연번", "사업 연번은 숫자여야 합니다."));
|
||||||
} else if (!performanceRepository.existsById(performanceId)) {
|
} else if (!existingPerformanceIds.contains(performanceId)) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "사업 연번", "존재하지 않는 사업 연번입니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "사업 연번", "존재하지 않는 사업 연번입니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtil.isNullOrBlank(userId)) {
|
if (StringUtil.isNullOrBlank(userId)) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "사용자 ID", "사용자 ID가 비어 있습니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "사용자 ID", "사용자 ID가 비어 있습니다."));
|
||||||
} else if (!userRepository.existsByUserId(userId)) {
|
} else if (!existingUserIds.contains(userId)) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "사용자 ID", "존재하지 않는 사용자 ID입니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "사용자 ID", "존재하지 않는 사용자 ID입니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +406,14 @@ public class AssignService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String reviewKey(TPerformanceAssignEntity assign) {
|
||||||
|
return reviewKey(assign.getPerformanceId(), assign.getAssignType(), assign.getAssignUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String reviewKey(Integer performanceId, Integer reviewType, String regUser) {
|
||||||
|
return performanceId + "|" + reviewType + "|" + regUser;
|
||||||
|
}
|
||||||
|
|
||||||
private void validateNoReviewBeforeAssignRemove(TPerformanceAssignEntity assign) {
|
private void validateNoReviewBeforeAssignRemove(TPerformanceAssignEntity assign) {
|
||||||
if (hasReview(assign)) {
|
if (hasReview(assign)) {
|
||||||
throw BusinessException.conflict("ASSIGN_HAS_REVIEW", "리뷰가 있는 배정은 해제하거나 삭제할 수 없습니다.")
|
throw BusinessException.conflict("ASSIGN_HAS_REVIEW", "리뷰가 있는 배정은 해제하거나 삭제할 수 없습니다.")
|
||||||
|
|||||||
@@ -20,16 +20,23 @@ import com.kri.gwcf.review.back.dto.performance.PerformanceCompactDto;
|
|||||||
import com.kri.gwcf.review.back.dto.performance.PerformanceAssignDto;
|
import com.kri.gwcf.review.back.dto.performance.PerformanceAssignDto;
|
||||||
import com.kri.gwcf.review.back.dto.performance.PerformanceFullDto;
|
import com.kri.gwcf.review.back.dto.performance.PerformanceFullDto;
|
||||||
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringScheduleDto;
|
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringScheduleDto;
|
||||||
|
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringVisitDto;
|
||||||
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
|
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
|
||||||
import com.kri.gwcf.review.back.dto.performance.PerformanceStaffDto;
|
import com.kri.gwcf.review.back.dto.performance.PerformanceStaffDto;
|
||||||
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceDetailEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceDetailEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringScheduleEntity;
|
||||||
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringVisitEntity;
|
||||||
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceStaffEntity;
|
import com.kri.gwcf.review.back.persistence.entity.TPerformanceStaffEntity;
|
||||||
import com.kri.gwcf.review.back.persistence.mapper.kon.KonMapper;
|
import com.kri.gwcf.review.back.persistence.mapper.kon.KonMapper;
|
||||||
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceAssignRepository;
|
||||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceDetailRepository;
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceDetailRepository;
|
||||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringScheduleRepository;
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringScheduleRepository;
|
||||||
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringVisitRepository;
|
||||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceRepository;
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceRepository;
|
||||||
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceReviewRepository;
|
||||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceStaffRepository;
|
import com.kri.gwcf.review.back.persistence.repository.PerformanceStaffRepository;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -37,6 +44,7 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -63,6 +71,9 @@ public class PerformanceService {
|
|||||||
private final PerformanceDetailRepository performanceDetailRepository;
|
private final PerformanceDetailRepository performanceDetailRepository;
|
||||||
private final PerformanceStaffRepository performanceStaffRepository;
|
private final PerformanceStaffRepository performanceStaffRepository;
|
||||||
private final PerformanceMonitoringScheduleRepository performanceMonitoringScheduleRepository;
|
private final PerformanceMonitoringScheduleRepository performanceMonitoringScheduleRepository;
|
||||||
|
private final PerformanceAssignRepository performanceAssignRepository;
|
||||||
|
private final PerformanceMonitoringVisitRepository performanceMonitoringVisitRepository;
|
||||||
|
private final PerformanceReviewRepository performanceReviewRepository;
|
||||||
private final CodeService codeService;
|
private final CodeService codeService;
|
||||||
private final AssignService assignService;
|
private final AssignService assignService;
|
||||||
private final ReviewService reviewService;
|
private final ReviewService reviewService;
|
||||||
@@ -77,14 +88,28 @@ public class PerformanceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<PerformanceFullDto> getPerformanceList() {
|
public List<PerformanceFullDto> getPerformanceList() {
|
||||||
return performanceRepository.findAll().stream()
|
List<TPerformanceEntity> performances = performanceRepository.findAll();
|
||||||
.map(this::toFullDto)
|
PerformanceFullLookup lookup = buildPerformanceFullLookup();
|
||||||
|
|
||||||
|
return performances.stream()
|
||||||
|
.map(performance -> toFullDto(performance, lookup))
|
||||||
|
.sorted(Comparator.comparing(
|
||||||
|
this::getPerformanceNoForSort,
|
||||||
|
Comparator.nullsLast(Integer::compareTo)
|
||||||
|
))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PerformanceCompactDto> getPerformanceCompactList() {
|
public List<PerformanceCompactDto> getPerformanceCompactList() {
|
||||||
return performanceRepository.findAll().stream()
|
List<TPerformanceEntity> performances = performanceRepository.findAll();
|
||||||
.map(this::toCompactDto)
|
PerformanceCompactLookup lookup = buildPerformanceCompactLookup();
|
||||||
|
|
||||||
|
return performances.stream()
|
||||||
|
.map(performance -> toCompactDto(performance, lookup))
|
||||||
|
.sorted(Comparator.comparing(
|
||||||
|
this::getPerformanceNoForSort,
|
||||||
|
Comparator.nullsLast(Integer::compareTo)
|
||||||
|
))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +145,9 @@ public class PerformanceService {
|
|||||||
int totalCount = rows.size();
|
int totalCount = rows.size();
|
||||||
int successCount = 0;
|
int successCount = 0;
|
||||||
List<ExcelErrorDto> errorList = new ArrayList<>();
|
List<ExcelErrorDto> errorList = new ArrayList<>();
|
||||||
|
Set<Integer> existingPerformanceIds = performanceRepository.findAll().stream()
|
||||||
|
.map(TPerformanceEntity::getId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
PerformanceUploadDto row = rows.get(i);
|
PerformanceUploadDto row = rows.get(i);
|
||||||
@@ -131,7 +159,8 @@ public class PerformanceService {
|
|||||||
businessTypeList,
|
businessTypeList,
|
||||||
genreList,
|
genreList,
|
||||||
areaList,
|
areaList,
|
||||||
ticketReservationStatusList
|
ticketReservationStatusList,
|
||||||
|
existingPerformanceIds
|
||||||
);
|
);
|
||||||
if (!rowErrors.isEmpty()) {
|
if (!rowErrors.isEmpty()) {
|
||||||
errorList.addAll(rowErrors);
|
errorList.addAll(rowErrors);
|
||||||
@@ -140,6 +169,7 @@ public class PerformanceService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
createPerformanceInternal(row, regUser, regDt);
|
createPerformanceInternal(row, regUser, regDt);
|
||||||
|
existingPerformanceIds.add(NumericUtil.parseOnlyInteger(row.getPerformanceId()));
|
||||||
successCount++;
|
successCount++;
|
||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
errorList.add(ExcelErrorDto.of(rowNumber, "SYSTEM", e.getMessage()));
|
errorList.add(ExcelErrorDto.of(rowNumber, "SYSTEM", e.getMessage()));
|
||||||
@@ -395,6 +425,22 @@ public class PerformanceService {
|
|||||||
return value == null ? null : String.valueOf(value);
|
return value == null ? null : String.valueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Integer getPerformanceNoForSort(PerformanceFullDto performance) {
|
||||||
|
if (performance == null || performance.getPerformanceDetail() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NumericUtil.parseOnlyInteger(performance.getPerformanceDetail().get("performanceNo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getPerformanceNoForSort(PerformanceCompactDto performance) {
|
||||||
|
if (performance == null || performance.getPerformanceDetail() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NumericUtil.parseOnlyInteger(performance.getPerformanceDetail().get("performanceNo"));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
||||||
public List<PerformanceApplyCountDto> findPerformanceApplyCount() {
|
public List<PerformanceApplyCountDto> findPerformanceApplyCount() {
|
||||||
return konMapper.findPerformanceApplyCount(surveyType);
|
return konMapper.findPerformanceApplyCount(surveyType);
|
||||||
@@ -414,6 +460,20 @@ public class PerformanceService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PerformanceFullDto toFullDto(TPerformanceEntity performance, PerformanceFullLookup lookup) {
|
||||||
|
Integer performanceId = performance.getId();
|
||||||
|
|
||||||
|
return PerformanceFullDto.from(
|
||||||
|
performance,
|
||||||
|
lookup.performanceDetailMap().getOrDefault(performanceId, Collections.emptyMap()),
|
||||||
|
lookup.performanceStaffMap().getOrDefault(performanceId, Collections.emptyList()),
|
||||||
|
lookup.performanceMonitoringScheduleMap().get(performanceId),
|
||||||
|
lookup.performanceAssignMap().getOrDefault(performanceId, Collections.emptyList()),
|
||||||
|
lookup.performanceMonitoringVisitMap().getOrDefault(performanceId, Collections.emptyMap()),
|
||||||
|
lookup.performanceReviewMap().getOrDefault(performanceId, Collections.emptyMap())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private PerformanceCompactDto toCompactDto(TPerformanceEntity performance) {
|
private PerformanceCompactDto toCompactDto(TPerformanceEntity performance) {
|
||||||
Integer performanceId = performance.getId();
|
Integer performanceId = performance.getId();
|
||||||
|
|
||||||
@@ -426,20 +486,126 @@ public class PerformanceService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PerformanceCompactDto toCompactDto(
|
||||||
|
TPerformanceEntity performance,
|
||||||
|
PerformanceCompactLookup lookup
|
||||||
|
) {
|
||||||
|
Integer performanceId = performance.getId();
|
||||||
|
|
||||||
|
return PerformanceCompactDto.from(
|
||||||
|
performance,
|
||||||
|
lookup.performanceDetailMap().getOrDefault(performanceId, Collections.emptyMap()),
|
||||||
|
lookup.performanceStaffMap().getOrDefault(performanceId, Collections.emptyList()),
|
||||||
|
lookup.performanceMonitoringScheduleMap().get(performanceId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PerformanceFullLookup buildPerformanceFullLookup() {
|
||||||
|
PerformanceCompactLookup compactLookup = buildPerformanceCompactLookup();
|
||||||
|
Map<Integer, List<PerformanceAssignDto>> assignMap = performanceAssignRepository.findAll()
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
TPerformanceAssignEntity::getPerformanceId,
|
||||||
|
Collectors.mapping(PerformanceAssignDto::from, Collectors.toList())
|
||||||
|
));
|
||||||
|
Map<Integer, Map<String, List<PerformanceMonitoringVisitDto>>> visitMap =
|
||||||
|
performanceMonitoringVisitRepository.findAll()
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
TPerformanceMonitoringVisitEntity::getPerformanceId,
|
||||||
|
Collectors.groupingBy(
|
||||||
|
TPerformanceMonitoringVisitEntity::getRegUser,
|
||||||
|
Collectors.mapping(PerformanceMonitoringVisitDto::from, Collectors.toList())
|
||||||
|
)
|
||||||
|
));
|
||||||
|
Map<Integer, Map<String, List<PerformanceReviewDto>>> reviewMap =
|
||||||
|
performanceReviewRepository.findAll()
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
TPerformanceReviewEntity::getPerformanceId,
|
||||||
|
Collectors.groupingBy(
|
||||||
|
TPerformanceReviewEntity::getRegUser,
|
||||||
|
Collectors.mapping(PerformanceReviewDto::from, Collectors.toList())
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
return new PerformanceFullLookup(
|
||||||
|
compactLookup.performanceDetailMap(),
|
||||||
|
compactLookup.performanceStaffMap(),
|
||||||
|
compactLookup.performanceMonitoringScheduleMap(),
|
||||||
|
assignMap,
|
||||||
|
visitMap,
|
||||||
|
reviewMap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PerformanceCompactLookup buildPerformanceCompactLookup() {
|
||||||
|
Map<Integer, Map<String, String>> detailMap = performanceDetailRepository.findAll()
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
TPerformanceDetailEntity::getPerformanceId,
|
||||||
|
toMap(
|
||||||
|
TPerformanceDetailEntity::getPerformanceDetailKey,
|
||||||
|
TPerformanceDetailEntity::getPerformanceDetailValue,
|
||||||
|
(left, right) -> right,
|
||||||
|
LinkedHashMap::new
|
||||||
|
)
|
||||||
|
));
|
||||||
|
Map<Integer, List<PerformanceStaffDto>> staffMap = performanceStaffRepository.findAll()
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
TPerformanceStaffEntity::getPerformanceId,
|
||||||
|
Collectors.mapping(PerformanceStaffDto::from, Collectors.toList())
|
||||||
|
));
|
||||||
|
Map<Integer, PerformanceMonitoringScheduleDto> scheduleMap =
|
||||||
|
performanceMonitoringScheduleRepository.findAll()
|
||||||
|
.stream()
|
||||||
|
.collect(toMap(
|
||||||
|
TPerformanceMonitoringScheduleEntity::getPerformanceId,
|
||||||
|
PerformanceMonitoringScheduleDto::from,
|
||||||
|
(first, ignored) -> first
|
||||||
|
));
|
||||||
|
|
||||||
|
return new PerformanceCompactLookup(detailMap, staffMap, scheduleMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private record PerformanceCompactLookup(
|
||||||
|
Map<Integer, Map<String, String>> performanceDetailMap,
|
||||||
|
Map<Integer, List<PerformanceStaffDto>> performanceStaffMap,
|
||||||
|
Map<Integer, PerformanceMonitoringScheduleDto> performanceMonitoringScheduleMap
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private record PerformanceFullLookup(
|
||||||
|
Map<Integer, Map<String, String>> performanceDetailMap,
|
||||||
|
Map<Integer, List<PerformanceStaffDto>> performanceStaffMap,
|
||||||
|
Map<Integer, PerformanceMonitoringScheduleDto> performanceMonitoringScheduleMap,
|
||||||
|
Map<Integer, List<PerformanceAssignDto>> performanceAssignMap,
|
||||||
|
Map<Integer, Map<String, List<PerformanceMonitoringVisitDto>>> performanceMonitoringVisitMap,
|
||||||
|
Map<Integer, Map<String, List<PerformanceReviewDto>>> performanceReviewMap
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
private List<ExcelErrorDto> validatePerformanceUploadRow(
|
private List<ExcelErrorDto> validatePerformanceUploadRow(
|
||||||
PerformanceUploadDto row,
|
PerformanceUploadDto row,
|
||||||
int rowNumber,
|
int rowNumber,
|
||||||
List<CodeDto> businessTypeList,
|
List<CodeDto> businessTypeList,
|
||||||
List<CodeDto> genreList,
|
List<CodeDto> genreList,
|
||||||
List<CodeDto> areaList,
|
List<CodeDto> areaList,
|
||||||
List<CodeDto> ticketReservationStatusList
|
List<CodeDto> ticketReservationStatusList,
|
||||||
|
Set<Integer> existingPerformanceIds
|
||||||
) {
|
) {
|
||||||
List<ExcelErrorDto> errors = new ArrayList<>();
|
List<ExcelErrorDto> errors = new ArrayList<>();
|
||||||
|
|
||||||
|
Integer performanceNo = NumericUtil.parseOnlyInteger(row.getPerformanceNo());
|
||||||
|
if (performanceNo == null) {
|
||||||
|
errors.add(ExcelErrorDto.of(rowNumber, "No", "No는 숫자여야 합니다."));
|
||||||
|
}
|
||||||
|
|
||||||
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
||||||
if (performanceId == null) {
|
if (performanceId == null) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "연번", "연번은 숫자여야 합니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "연번", "연번은 숫자여야 합니다."));
|
||||||
} else if (performanceRepository.existsById(performanceId)) {
|
} else if (existingPerformanceIds.contains(performanceId)) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "연번", "이미 등록된 공연 ID입니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "연번", "이미 등록된 공연 ID입니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,20 +621,25 @@ public class PerformanceService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Integer performanceStartMonth = NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth());
|
Integer performanceStartMonth = NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth());
|
||||||
if (performanceStartMonth == null || performanceStartMonth < 1 || performanceStartMonth > 12) {
|
if(performanceStartMonth == null){
|
||||||
|
performanceStartMonth = 0;
|
||||||
|
}
|
||||||
|
else if (performanceStartMonth < 1 || performanceStartMonth > 12) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "사업 수행 월", "사업 수행 월은 1~12 사이 숫자여야 합니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "사업 수행 월", "사업 수행 월은 1~12 사이 숫자여야 합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
String md = row.getMonitoringDate();
|
String monitoringDate = row.getMonitoringDate();
|
||||||
if (DateTimeUtil.parseLocalDate(row.getMonitoringDate()) == null) {
|
if (!StringUtil.isNullOrBlank(monitoringDate) && DateTimeUtil.parseLocalDate(monitoringDate) == null) {
|
||||||
errors.add(ExcelErrorDto.of(rowNumber, "모니터링 일정", "모니터링 일정은 yyyy-MM-dd 형식이어야 합니다."));
|
errors.add(ExcelErrorDto.of(rowNumber, "모니터링 일정", "모니터링 일정은 yyyy-MM-dd 형식이어야 합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String timeTreeCheckDt = row.getTimeTreeCheckDt();
|
||||||
|
if (!StringUtil.isNullOrBlank(timeTreeCheckDt) && DateTimeUtil.parseLocalDate(timeTreeCheckDt) == null) {
|
||||||
|
errors.add(ExcelErrorDto.of(rowNumber, "타임트리 확인일시", "타임트리 확인일시는 yyyy-MM-dd 형식이어야 합니다."));
|
||||||
|
}
|
||||||
|
|
||||||
validateRequired(errors, rowNumber, "단체(인) 명", row.getArtistName());
|
validateRequired(errors, rowNumber, "단체(인) 명", row.getArtistName());
|
||||||
validateRequired(errors, rowNumber, "사업 명", row.getPerformanceName());
|
validateRequired(errors, rowNumber, "사업 명", row.getPerformanceName());
|
||||||
validateRequired(errors, rowNumber, "사업 일정", row.getPerformanceDtInfo());
|
|
||||||
validateRequired(errors, rowNumber, "운영 시간", row.getPerformanceTimeInfo());
|
|
||||||
validateRequired(errors, rowNumber, "모니터링 시간", row.getMonitoringTimeInfo());
|
|
||||||
validateRequired(errors, rowNumber, "모니터링 방문 장소", row.getMonitoringAddress());
|
validateRequired(errors, rowNumber, "모니터링 방문 장소", row.getMonitoringAddress());
|
||||||
|
|
||||||
validateStaff(errors, rowNumber, "대표자", row.getOwnStaffName(),
|
validateStaff(errors, rowNumber, "대표자", row.getOwnStaffName(),
|
||||||
@@ -486,6 +657,11 @@ public class PerformanceService {
|
|||||||
) {
|
) {
|
||||||
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
||||||
|
|
||||||
|
Integer performanceStartMonth = NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth());
|
||||||
|
if(performanceStartMonth == null){
|
||||||
|
performanceStartMonth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
TPerformanceEntity performance = TPerformanceEntity.builder()
|
TPerformanceEntity performance = TPerformanceEntity.builder()
|
||||||
.id(performanceId)
|
.id(performanceId)
|
||||||
.businessType(NumericUtil.parseOnlyInteger(row.getBusinessType()))
|
.businessType(NumericUtil.parseOnlyInteger(row.getBusinessType()))
|
||||||
@@ -493,7 +669,7 @@ public class PerformanceService {
|
|||||||
.performanceArea(NumericUtil.parseOnlyInteger(row.getPerformanceArea()))
|
.performanceArea(NumericUtil.parseOnlyInteger(row.getPerformanceArea()))
|
||||||
.artistName(Objects.toString(StringUtil.normalizeBlank(row.getArtistName()), ""))
|
.artistName(Objects.toString(StringUtil.normalizeBlank(row.getArtistName()), ""))
|
||||||
.performanceName(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceName()), ""))
|
.performanceName(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceName()), ""))
|
||||||
.performanceStartMonth(NumericUtil.parseOnlyInteger(row.getPerformanceStartMonth()))
|
.performanceStartMonth(performanceStartMonth)
|
||||||
.performanceDtInfo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceDtInfo()), ""))
|
.performanceDtInfo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceDtInfo()), ""))
|
||||||
.performanceTimeInfo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceTimeInfo()), ""))
|
.performanceTimeInfo(Objects.toString(StringUtil.normalizeBlank(row.getPerformanceTimeInfo()), ""))
|
||||||
.ticketReservationStatus(NumericUtil.parseOnlyInteger(row.getTicketReservationStatus()))
|
.ticketReservationStatus(NumericUtil.parseOnlyInteger(row.getTicketReservationStatus()))
|
||||||
@@ -518,6 +694,15 @@ public class PerformanceService {
|
|||||||
Map<String, String> detail = new LinkedHashMap<>();
|
Map<String, String> detail = new LinkedHashMap<>();
|
||||||
detail.put("monitoringPaymentDate", Objects.toString(StringUtil.normalizeBlank(row.getMonitoringPaymentDate()), ""));
|
detail.put("monitoringPaymentDate", Objects.toString(StringUtil.normalizeBlank(row.getMonitoringPaymentDate()), ""));
|
||||||
|
|
||||||
|
detail.put("performanceNo", Objects.toString(StringUtil.normalizeBlank(row.getPerformanceNo()), ""));
|
||||||
|
detail.put("performanceAreaDetail", Objects.toString(StringUtil.normalizeBlank(row.getPerformanceAreaDetail()), ""));
|
||||||
|
detail.put("needMonitoring", Objects.toString(StringUtil.normalizeBlank(row.getNeedMonitoring()), ""));
|
||||||
|
detail.put("needWrittenReview", Objects.toString(StringUtil.normalizeBlank(row.getNeedWrittenReview()), ""));
|
||||||
|
detail.put("checkDeliver", Objects.toString(StringUtil.normalizeBlank(row.getCheckDeliver()), ""));
|
||||||
|
detail.put("timeTreeCheckDt", Objects.toString(StringUtil.normalizeBlank(row.getTimeTreeCheckDt()), ""));
|
||||||
|
detail.put("checkReport", Objects.toString(StringUtil.normalizeBlank(row.getCheckReport()), ""));
|
||||||
|
|
||||||
|
|
||||||
List<TPerformanceDetailEntity> detailEntities = detail.entrySet().stream()
|
List<TPerformanceDetailEntity> detailEntities = detail.entrySet().stream()
|
||||||
.map(entry -> TPerformanceDetailEntity.update(
|
.map(entry -> TPerformanceDetailEntity.update(
|
||||||
performanceId,
|
performanceId,
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.PathResource;
|
import org.springframework.core.io.PathResource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -19,6 +23,9 @@ public class ReviewTemplateService extends AbstractFileService {
|
|||||||
|
|
||||||
private final FileStorageProperties fileStorageProperties;
|
private final FileStorageProperties fileStorageProperties;
|
||||||
|
|
||||||
|
@Value("${kri.file.pdf-converter-command:soffice}")
|
||||||
|
private String pdfConverterCommand;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Path getBaseDir() {
|
protected Path getBaseDir() {
|
||||||
return Path.of(fileStorageProperties.getReviewTemplateBaseDir())
|
return Path.of(fileStorageProperties.getReviewTemplateBaseDir())
|
||||||
@@ -26,36 +33,50 @@ public class ReviewTemplateService extends AbstractFileService {
|
|||||||
.normalize();
|
.normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uploadReviewTemplate(Integer reviewType, MultipartFile file) {
|
public String uploadReviewTemplate(Integer reviewType, Integer classification, MultipartFile file) {
|
||||||
validateReviewTemplateType(reviewType);
|
validateReviewTemplateType(reviewType);
|
||||||
|
validateReviewTemplateClassification(classification);
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
|
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileName = sanitizeFileName(file.getOriginalFilename());
|
String fileName = sanitizeFileName(file.getOriginalFilename());
|
||||||
Path dir = templateDir(reviewType);
|
Path dir = templateDir(reviewType, classification);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deleteExistingFiles(dir);
|
deleteExistingFiles(dir);
|
||||||
saveFile(dir, file, fileName);
|
saveFile(dir, file, fileName);
|
||||||
|
Path uploadPath = dir.resolve(fileName).normalize();
|
||||||
|
convertToPdfIfPossible(uploadPath, dir);
|
||||||
return fileName;
|
return fileName;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw BusinessException.internalError("REVIEW_TEMPLATE_SAVE_FAILED", "평가양식 파일 저장 중 오류가 발생했습니다.");
|
throw BusinessException.internalError("REVIEW_TEMPLATE_SAVE_FAILED", "평가양식 파일 저장 중 오류가 발생했습니다.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathResource getReviewTemplateResource(Integer reviewType) {
|
public PathResource getReviewTemplateResource(Integer reviewType, Integer classification) {
|
||||||
Path file = findReviewTemplateFile(reviewType);
|
Path file = findReviewTemplateFile(reviewType, classification, false);
|
||||||
return new PathResource(file);
|
return new PathResource(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReviewTemplateFileName(Integer reviewType) {
|
public String getReviewTemplateFileName(Integer reviewType, Integer classification) {
|
||||||
return findReviewTemplateFile(reviewType).getFileName().toString();
|
return findReviewTemplateFile(reviewType, classification, false).getFileName().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path findReviewTemplateFile(Integer reviewType) {
|
public PathResource getReviewTemplatePdfResource(Integer reviewType, Integer classification) {
|
||||||
|
Path file = findReviewTemplateFile(reviewType, classification, true);
|
||||||
|
return new PathResource(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReviewTemplatePdfFileName(Integer reviewType, Integer classification) {
|
||||||
|
return findReviewTemplateFile(reviewType, classification, true).getFileName().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path findReviewTemplateFile(Integer reviewType, Integer classification, boolean pdf) {
|
||||||
validateReviewTemplateType(reviewType);
|
validateReviewTemplateType(reviewType);
|
||||||
Path dir = templateDir(reviewType);
|
validateReviewTemplateClassification(classification);
|
||||||
|
|
||||||
|
Path dir = templateDir(reviewType, classification);
|
||||||
if (!Files.isDirectory(dir)) {
|
if (!Files.isDirectory(dir)) {
|
||||||
throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
||||||
.with("reviewType", reviewType);
|
.with("reviewType", reviewType);
|
||||||
@@ -64,6 +85,7 @@ public class ReviewTemplateService extends AbstractFileService {
|
|||||||
try (var files = Files.list(dir)) {
|
try (var files = Files.list(dir)) {
|
||||||
return files
|
return files
|
||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
|
.filter(path -> pdf == isPdf(path.getFileName().toString()))
|
||||||
.sorted(Comparator.comparing(path -> path.getFileName().toString()))
|
.sorted(Comparator.comparing(path -> path.getFileName().toString()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow(() -> BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
.orElseThrow(() -> BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
||||||
@@ -85,9 +107,51 @@ public class ReviewTemplateService extends AbstractFileService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path templateDir(Integer reviewType) {
|
private String convertToPdfIfPossible(Path source, Path dir) {
|
||||||
|
String extension = extractExtension(source.getFileName().toString()).toLowerCase();
|
||||||
|
Set<String> targets = new HashSet<>(Set.of(".docx", ".hwpx", ".hwp", ".pptx", ".xlsx"));
|
||||||
|
if (isPdf(source.getFileName().toString()) || !targets.contains(extension)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Process process = new ProcessBuilder(
|
||||||
|
pdfConverterCommand,
|
||||||
|
"--headless",
|
||||||
|
"--convert-to",
|
||||||
|
"pdf",
|
||||||
|
"--outdir",
|
||||||
|
dir.toString(),
|
||||||
|
source.toString()
|
||||||
|
).redirectErrorStream(true).start();
|
||||||
|
|
||||||
|
boolean finished = process.waitFor(60, TimeUnit.SECONDS);
|
||||||
|
if (!finished || process.exitValue() != 0) {
|
||||||
|
process.destroyForcibly();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String baseName = stripExtension(source.getFileName().toString());
|
||||||
|
Path pdf = dir.resolve(baseName + ".pdf").normalize();
|
||||||
|
return Files.exists(pdf) ? pdf.getFileName().toString() : "";
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String stripExtension(String fileName) {
|
||||||
|
int dot = fileName.lastIndexOf('.');
|
||||||
|
return dot > 0 ? fileName.substring(0, dot) : fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPdf(String fileName) {
|
||||||
|
return ".pdf".equalsIgnoreCase(extractExtension(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path templateDir(Integer reviewType, Integer classification) {
|
||||||
return getBaseDir()
|
return getBaseDir()
|
||||||
.resolve(String.valueOf(reviewType))
|
.resolve(String.valueOf(reviewType))
|
||||||
|
.resolve(String.valueOf(classification))
|
||||||
.toAbsolutePath()
|
.toAbsolutePath()
|
||||||
.normalize();
|
.normalize();
|
||||||
}
|
}
|
||||||
@@ -99,6 +163,13 @@ public class ReviewTemplateService extends AbstractFileService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateReviewTemplateClassification(Integer classification) {
|
||||||
|
if (!Integer.valueOf(1).equals(classification) && !Integer.valueOf(5).equals(classification)) {
|
||||||
|
throw BusinessException.badRequest("INVALID_REVIEW_TEMPLATE_CLASSIFICATION", "유효하지 않은 평가양식 분류입니다.")
|
||||||
|
.with("classification", classification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String sanitizeFileName(String originalFileName) {
|
private String sanitizeFileName(String originalFileName) {
|
||||||
if (StringUtil.isNullOrBlank(originalFileName)) {
|
if (StringUtil.isNullOrBlank(originalFileName)) {
|
||||||
return "review-template";
|
return "review-template";
|
||||||
|
|||||||
Reference in New Issue
Block a user