develop #1
@@ -27,13 +27,15 @@ public enum SystemEventType implements CodeEnum<Short> {
|
||||
ASSIGN_PERFORMANCE_CONFIRM((short) 1032), //공연 배정 승인
|
||||
ASSIGN_PERFORMANCE_REJECT((short) 1033), //공연 배정 거절
|
||||
ASSIGN_PERFORMANCE_FORCE((short) 1034), //강제 공연 배정
|
||||
UPLOAD_WRITTEN_ASSIGN((short) 1036),
|
||||
|
||||
VISIT_START((short) 2011), //모니터링 출발
|
||||
VISIT_END((short) 2012), //모니터링 도착
|
||||
|
||||
UPLOAD_MONITORING_REVIEW((short) 2041), //모니터링 결과보고서 업로드
|
||||
UPLOAD_LOCAL_GOV_REVIEW((short) 2042), //지자체 결과보고서 업로드
|
||||
UPDATE_WRITTEN_REVIEW((short) 2043), //지자체 결과보고서 업로드
|
||||
START_WRITTEN_REVIEW((short) 2044), // 서면 평가 시작
|
||||
END_WRITTEN_REVIEW((short) 2045), // 서면평가 종료
|
||||
|
||||
DUMMY((short) 9999);
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.kri.gwcf.review.back.common.util;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
public final class DownloadHeaderUtil {
|
||||
|
||||
public static String attachmentContentDisposition(String fileName) {
|
||||
return "attachment; filename*=UTF-8''" +
|
||||
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
public class FileStorageProperties {
|
||||
private String visitBaseDir;
|
||||
private String reviewBaseDir;
|
||||
}
|
||||
private String reviewTemplateBaseDir;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,34 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import static com.kri.gwcf.review.back.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.gwcf.review.back.dto.assign.AssignUserCountDto;
|
||||
import com.kri.gwcf.review.back.dto.assign.MonitoringAssignSaveRequestDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.gwcf.review.back.dto.kon.PerformanceApplyCountDto;
|
||||
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.systemlog.UploadContentDto;
|
||||
import com.kri.gwcf.review.back.service.AssignService;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/assign")
|
||||
@@ -18,14 +36,119 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Tag(name = "Assign", description = "배정 API")
|
||||
public class AssignController {
|
||||
|
||||
private final AssignService assignService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "참여 동의")
|
||||
@PostMapping("/confirm/{userId}")
|
||||
public boolean assignConfirm(@PathVariable String userId, RequestUserContext ctx) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
@Operation(summary = "사용자별 배정 건수 조회")
|
||||
@GetMapping("/users/count")
|
||||
public List<AssignUserCountDto> findAssignUserCounts() {
|
||||
return assignService.findAssignUserCounts();
|
||||
}
|
||||
|
||||
systemEventLogService.writeAssignConfirmLog(userId, now, ctx.getClientIp());
|
||||
return false;
|
||||
@Operation(summary = "모니터링 신청자 목록")
|
||||
@GetMapping("/monitoring/apply-users/{performanceId}")
|
||||
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(
|
||||
@PathVariable Integer performanceId
|
||||
) {
|
||||
return assignService.findMonitoringApplyUsers(performanceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "공연별 모니터링 신청자 수")
|
||||
@GetMapping("/monitoring/apply-users/count")
|
||||
public List<PerformanceApplyCountDto> findMonitoringApplyUsersCount() {
|
||||
return assignService.findMonitoringApplyUsersCount();
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "참여 동의")
|
||||
@PostMapping("/confirm/{performanceId}/{userId}")
|
||||
public String assignConfirm(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
String result = assignService.confirmMonitoringAssignByUser(performanceId, userId);
|
||||
systemEventLogService.writeAssignConfirmLog(userId, now, ctx.getClientIp(), String.valueOf(performanceId));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "모니터링 배정 저장")
|
||||
@PostMapping("/monitoring")
|
||||
public List<PerformanceAssignDto> saveMonitoringAssign(
|
||||
@RequestBody MonitoringAssignSaveRequestDto dto,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
List<PerformanceAssignDto> result =
|
||||
assignService.saveMonitoringAssign(dto.getPerformanceId(), dto.getUserIds(), ctx.getUserId(), now);
|
||||
systemEventLogService.writeAssignPerformanceRequestLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
dto.getPerformanceId(),
|
||||
dto.getUserIds()
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "서면평가위원 일괄 배정 양식 다운로드")
|
||||
@PostMapping("/written/excel/template")
|
||||
public ResponseEntity<byte[]> exportUserTemplate() {
|
||||
byte[] bytes = assignService.exportAssignTemplate();
|
||||
return buildExcelResponse("user_assign_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "서면평가위원 일괄 배정(엑셀 업로드)")
|
||||
@PostMapping(value = "/written/excel/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ExcelUploadResultDto createWrittenAssignsFromExcel(
|
||||
@RequestParam("file") MultipartFile file,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
ExcelUploadResultDto result = assignService.createWrittenAssignsFromExcel(file, ctx.getUserId(), now);
|
||||
systemEventLogService.writeUploadWrittenAssignLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
UploadContentDto.from(file)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "배정 확정")
|
||||
@PatchMapping("/confirm/{performanceId}/{userId}")
|
||||
public void confirmAssign(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
assignService.confirmAssign(performanceId, userId, true);
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
systemEventLogService.writeAssignConfirmByAdminLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
userId
|
||||
);
|
||||
}
|
||||
|
||||
@Operation(summary = "배정 취소")
|
||||
@PatchMapping("/cancel/{performanceId}/{userId}")
|
||||
public void cancelAssign(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
assignService.confirmAssign(performanceId, userId, false);
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
systemEventLogService.writeAssignCancelLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
userId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import com.kri.gwcf.review.back.dto.common.CodeDto;
|
||||
import com.kri.gwcf.review.back.service.CodeService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/code")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Code", description = "코드 API")
|
||||
public class CodeController {
|
||||
|
||||
private final CodeService codeService;
|
||||
|
||||
@Operation(summary = "코드 조회")
|
||||
@GetMapping("/{codeGroup}")
|
||||
public List<CodeDto> getCodeList(@PathVariable String codeGroup) {
|
||||
return codeService.findByCodeGroup(codeGroup);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import static com.kri.gwcf.review.back.common.util.DownloadHeaderUtil.attachmentContentDisposition;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.gwcf.review.back.dto.monitoring.MonitoringGpsRequestDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringVisitDto;
|
||||
import com.kri.gwcf.review.back.service.VisitService;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/monitoring/visit")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Monitoring Visit", description = "모니터링 방문 API")
|
||||
public class MonitoringVisitController {
|
||||
|
||||
private final VisitService visitService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "모니터링 출발 저장")
|
||||
@PostMapping("/departure/{performanceId}")
|
||||
public PerformanceMonitoringVisitDto saveDeparture(
|
||||
@PathVariable Integer performanceId,
|
||||
@RequestBody MonitoringGpsRequestDto gps,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
PerformanceMonitoringVisitDto result = visitService.saveDeparture(performanceId, gps, ctx.getUserId(), now);
|
||||
systemEventLogService.writeVisitStartLog(ctx.getUserId(), now, ctx.getClientIp(), performanceId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "모니터링 도착 저장 + 증빙 사진 업로드")
|
||||
@PostMapping(value = "/arrival/{performanceId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public PerformanceMonitoringVisitDto saveArrival(
|
||||
@PathVariable Integer performanceId,
|
||||
@RequestPart("gps") MonitoringGpsRequestDto gps,
|
||||
@RequestPart(value = "files", required = false) List<MultipartFile> files,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
PerformanceMonitoringVisitDto result = visitService.saveArrival(performanceId, gps, files, ctx.getUserId(), now);
|
||||
int evidenceFileCount = files == null ? 0 : (int) files.stream()
|
||||
.filter(file -> file != null && !file.isEmpty())
|
||||
.count();
|
||||
systemEventLogService.writeVisitEndLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
evidenceFileCount
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "증빙 사진 조회")
|
||||
@GetMapping("/evidence/{performanceId}/{userId}")
|
||||
public List<PerformanceMonitoringVisitDto> findEvidence(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId
|
||||
) {
|
||||
return visitService.findEvidence(performanceId, userId);
|
||||
}
|
||||
|
||||
@Operation(summary = "증빙 사진 ZIP 다운로드")
|
||||
@GetMapping("/evidence/zip/{performanceId}/{userId}")
|
||||
public ResponseEntity<byte[]> downloadEvidenceZip(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId
|
||||
) {
|
||||
byte[] bytes = visitService.downloadEvidenceZip(performanceId, userId);
|
||||
String fileName = "evidence_" + performanceId + "_" + userId + ".zip";
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, attachmentContentDisposition(fileName))
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(bytes);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,16 @@ public class PerformanceController {
|
||||
return buildExcelResponse("performance_upload_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "공연정보 엑셀 다운로드")
|
||||
@PostMapping("/excel/download")
|
||||
public ResponseEntity<byte[]> exportPerformance(
|
||||
@RequestBody String[] performanceIds
|
||||
) {
|
||||
byte[] bytes = performanceService.exportPerformance(performanceIds);
|
||||
|
||||
return buildExcelResponse("performance.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "공연 일괄 생성(엑셀 업로드)",
|
||||
description = "성공하면 JSON, 실패가 있으면 실패 내역 엑셀(xlsx) 반환"
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.kri.gwcf.review.back.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import static com.kri.gwcf.review.back.common.util.DownloadHeaderUtil.attachmentContentDisposition;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.gwcf.review.back.dto.systemlog.UploadContentDto;
|
||||
import com.kri.gwcf.review.back.service.ReviewService;
|
||||
import com.kri.gwcf.review.back.service.ReviewTemplateService;
|
||||
import com.kri.gwcf.review.back.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/review")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Review", description = "평가/모니터링 API")
|
||||
public class ReviewController {
|
||||
|
||||
private final ReviewService reviewService;
|
||||
private final ReviewTemplateService reviewTemplateService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "서면평가 시작 저장")
|
||||
@PostMapping("/start/{performanceId}/{userId}")
|
||||
public PerformanceReviewDto startWrittenReview(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
PerformanceReviewDto result = reviewService.saveWrittenReviewStatus(performanceId, 1, userId, now);
|
||||
systemEventLogService.writeStartWrittenReviewLog(userId, now, ctx.getClientIp(), performanceId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "서면평가 완료 저장")
|
||||
@PostMapping("/end/{performanceId}/{userId}")
|
||||
public PerformanceReviewDto endWrittenReview(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
PerformanceReviewDto result = reviewService.saveWrittenReviewStatus(performanceId, 10, userId, now);
|
||||
systemEventLogService.writeEndWrittenReviewLog(userId, now, ctx.getClientIp(), performanceId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "평가/모니터링 파일 업로드")
|
||||
@PostMapping(value = "/{performanceId}/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public PerformanceReviewDto uploadReviewFile(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable Integer reviewType,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
PerformanceReviewDto result = reviewService.uploadReviewFile(performanceId, reviewType, file, ctx.getUserId(), now);
|
||||
systemEventLogService.writeUploadReviewFileLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
reviewType,
|
||||
UploadContentDto.from(file)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "평가/모니터링 파일 조회")
|
||||
@GetMapping("/{performanceId}/{reviewType}/{userId}")
|
||||
public PerformanceReviewDto getReviewFile(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable Integer reviewType,
|
||||
@PathVariable String userId
|
||||
) {
|
||||
return reviewService.getReviewFile(performanceId, reviewType, userId);
|
||||
}
|
||||
|
||||
@Operation(summary = "평가/모니터링 원본 파일 다운로드")
|
||||
@GetMapping("/download/{performanceId}/{reviewType}/{userId}")
|
||||
public ResponseEntity<Resource> downloadOriginalFile(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable Integer reviewType,
|
||||
@PathVariable String userId
|
||||
) {
|
||||
return download(
|
||||
reviewService.getOriginalFileResource(performanceId, reviewType, userId),
|
||||
reviewService.getOriginalFileName(performanceId, reviewType, userId)
|
||||
);
|
||||
}
|
||||
|
||||
@Operation(summary = "PDF 변환 파일 조회/다운로드")
|
||||
@GetMapping("/pdf/{performanceId}/{reviewType}/{userId}")
|
||||
public ResponseEntity<Resource> downloadPdfOrOriginalFile(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable Integer reviewType,
|
||||
@PathVariable String userId
|
||||
) {
|
||||
return download(
|
||||
reviewService.getPdfOrOriginalFileResource(performanceId, reviewType, userId),
|
||||
reviewService.getPdfOrOriginalFileName(performanceId, reviewType, userId)
|
||||
);
|
||||
}
|
||||
|
||||
@Operation(summary = "평가양식 업로드")
|
||||
@PostMapping(value = "/template/upload/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public String uploadReviewTemplate(
|
||||
@PathVariable Integer reviewType,
|
||||
@RequestParam("file") MultipartFile file
|
||||
) {
|
||||
return reviewTemplateService.uploadReviewTemplate(reviewType, file);
|
||||
}
|
||||
|
||||
@Operation(summary = "평가양식 다운로드")
|
||||
@GetMapping("/template/download/{reviewType}")
|
||||
public ResponseEntity<Resource> downloadReviewTemplate(
|
||||
@PathVariable Integer reviewType
|
||||
) {
|
||||
return download(
|
||||
reviewTemplateService.getReviewTemplateResource(reviewType),
|
||||
reviewTemplateService.getReviewTemplateFileName(reviewType)
|
||||
);
|
||||
}
|
||||
|
||||
private ResponseEntity<Resource> download(Resource resource, String fileName) {
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, attachmentContentDisposition(fileName))
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(resource);
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,17 @@ public class UserController {
|
||||
return buildExcelResponse("user_upload_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "사용자 엑셀 다운로드")
|
||||
@PostMapping("/excel/download/{userRole}")
|
||||
public ResponseEntity<byte[]> exportUser(
|
||||
@PathVariable Integer userRole,
|
||||
@RequestBody String[] userIds
|
||||
) {
|
||||
byte[] bytes = userService.exportUser(userRole, userIds);
|
||||
|
||||
return buildExcelResponse("user.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "사용자 일괄 생성(엑셀 업로드)",
|
||||
description = "성공하면 JSON, 실패가 있으면 실패 내역 엑셀(xlsx) 반환"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.kri.gwcf.review.back.dto.assign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class AssignUserCountDto {
|
||||
|
||||
@Schema(description = "배정 사용자 ID")
|
||||
private String assignUser;
|
||||
|
||||
@Schema(description = "배정 건수")
|
||||
private Long assignCount;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.gwcf.review.back.dto.assign;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class MonitoringAssignSaveRequestDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private Integer performanceId;
|
||||
|
||||
@Schema(description = "모니터링 요원 사용자 ID 목록")
|
||||
private List<String> userIds;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.kri.gwcf.review.back.dto.excel.performance;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceDownloadDto extends PerformanceUploadDto {
|
||||
|
||||
@ExcelColumn(header = "지자체 평가자", order = 24, width = 16)
|
||||
@Schema(description = "지자체 평가자")
|
||||
private String localReviewUser;
|
||||
|
||||
@ExcelColumn(header = "지자체 평가 상태", order = 25, width = 16)
|
||||
@Schema(description = "지자체 평가 상태")
|
||||
private String localReviewStatus;
|
||||
|
||||
@ExcelColumn(header = "지자체 평가 일시", order = 26, width = 16)
|
||||
@Schema(description = "지자체 평가 일시")
|
||||
private String localReviewDt;
|
||||
|
||||
@ExcelColumn(header = "모니터링1 평가자", order = 27, width = 16)
|
||||
@Schema(description = "모니터링1 평가자")
|
||||
private String monitoringReviewUser1;
|
||||
|
||||
@ExcelColumn(header = "모니터링1 평가 상태", order = 28, width = 16)
|
||||
@Schema(description = "모니터링1 평가 상태")
|
||||
private String monitoringReviewStatus1;
|
||||
|
||||
@ExcelColumn(header = "모니터링1 평가 일시", order = 29, width = 16)
|
||||
@Schema(description = "모니터링1 평가 일시")
|
||||
private String monitoringReviewDt1;
|
||||
|
||||
@ExcelColumn(header = "모니터링2 평가자", order = 30, width = 16)
|
||||
@Schema(description = "모니터링2 평가자")
|
||||
private String monitoringReviewUser2;
|
||||
|
||||
@ExcelColumn(header = "모니터링2 평가 상태", order = 31, width = 16)
|
||||
@Schema(description = "모니터링2 평가 상태")
|
||||
private String monitoringReviewStatus2;
|
||||
|
||||
@ExcelColumn(header = "모니터링2 평가 일시", order = 32, width = 16)
|
||||
@Schema(description = "모니터링2 평가 일시")
|
||||
private String monitoringReviewDt2;
|
||||
|
||||
@ExcelColumn(header = "서면 평가 위원", order = 33, width = 16)
|
||||
@Schema(description = "서면 평가 위원")
|
||||
private String writtenReviewUser;
|
||||
|
||||
@ExcelColumn(header = "서면 평가 상태", order = 34, width = 16)
|
||||
@Schema(description = "서면 평가 상태")
|
||||
private String writtenReviewStatus;
|
||||
|
||||
@ExcelColumn(header = "서면 평가 일시", order = 35, width = 16)
|
||||
@Schema(description = "서면 평가 일시")
|
||||
private String writtenReviewDt;
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.kri.gwcf.review.back.dto.excel;
|
||||
package com.kri.gwcf.review.back.dto.excel.performance;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PerformanceUploadDto {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.kri.gwcf.review.back.dto.excel;
|
||||
package com.kri.gwcf.review.back.dto.excel.user;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.kri.gwcf.review.back.dto.excel;
|
||||
package com.kri.gwcf.review.back.dto.excel.user;
|
||||
|
||||
public interface UserUploadBaseDto {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.kri.gwcf.review.back.dto.excel.user;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WrittenUserAssignDto {
|
||||
|
||||
@ExcelColumn(header = "사용자 ID", order = 0, width = 11)
|
||||
@Schema(description = "사용자 ID")
|
||||
private String userId;
|
||||
|
||||
@ExcelColumn(header = "사업 연번", order = 1, width = 10)
|
||||
@Schema(description = "사업 연번")
|
||||
private String performanceId;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.kri.gwcf.review.back.dto.excel;
|
||||
package com.kri.gwcf.review.back.dto.excel.user;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.gwcf.review.back.dto.kon;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "KON 공연 신청 수")
|
||||
public class PerformanceApplyCountDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "신청 수")
|
||||
private Long applyCnt;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.kri.gwcf.review.back.dto.kon;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "KON 공연 신청 자")
|
||||
public class PerformanceApplyUserDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private String performanceId;
|
||||
|
||||
@Schema(description = "신청자 ID")
|
||||
private String userId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.kri.gwcf.review.back.dto.monitoring;
|
||||
|
||||
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
@Schema(description = "모니터링 신청자")
|
||||
public class MonitoringApplyUserDto {
|
||||
|
||||
@Schema(description = "공연 ID")
|
||||
private Integer performanceId;
|
||||
|
||||
@Schema(description = "신청자 ID")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "서비스 DB 사용자 정보")
|
||||
private UserCompactDto user;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.kri.gwcf.review.back.dto.monitoring;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "모니터링 GPS 정보")
|
||||
public class MonitoringGpsRequestDto {
|
||||
|
||||
@Schema(description = "GPS 위도")
|
||||
private BigDecimal gpsLatitude;
|
||||
|
||||
@Schema(description = "GPS 경도")
|
||||
private BigDecimal gpsLongitude;
|
||||
|
||||
@Schema(description = "GPS 신뢰 반경(m)")
|
||||
private BigDecimal gpsAccuracyM;
|
||||
|
||||
@Schema(description = "GPS Raw Data")
|
||||
private Map<String, Object> gpsRaw;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.kri.gwcf.review.back.dto.performance;
|
||||
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringVisitEntity;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -42,6 +43,12 @@ public class PerformanceMonitoringVisitDto {
|
||||
@Schema(description = "GPS Raw Data")
|
||||
private Map<String, Object> gpsRaw;
|
||||
|
||||
@Schema(description = "등록자")
|
||||
private String regUser;
|
||||
|
||||
@Schema(description = "등록일시")
|
||||
private LocalDateTime regDt;
|
||||
|
||||
public static PerformanceMonitoringVisitDto from(TPerformanceMonitoringVisitEntity entity) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
@@ -56,6 +63,8 @@ public class PerformanceMonitoringVisitDto {
|
||||
.gpsLongitude(entity.getGpsLongitude())
|
||||
.gpsAccuracyM(entity.getGpsAccuracyM())
|
||||
.gpsRaw(entity.getGpsRaw())
|
||||
.regUser(entity.getRegUser())
|
||||
.regDt(entity.getRegDt())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kri.gwcf.review.back.dto.performance;
|
||||
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@@ -22,6 +23,12 @@ public class PerformanceReviewDto {
|
||||
@Schema(description = "평가 타입")
|
||||
private Integer reviewType;
|
||||
|
||||
@Schema(description = "등록 사용자")
|
||||
private String regUser;
|
||||
|
||||
@Schema(description = "평가 일시")
|
||||
private LocalDateTime reviewDt;
|
||||
|
||||
@Schema(description = "평가 상태")
|
||||
private Integer reviewStatus;
|
||||
|
||||
@@ -39,9 +46,13 @@ public class PerformanceReviewDto {
|
||||
return null;
|
||||
}
|
||||
|
||||
LocalDateTime reviewDt = entity.getModDt() != null ? entity.getModDt() : entity.getRegDt();
|
||||
|
||||
return PerformanceReviewDto.builder()
|
||||
.performanceId(entity.getPerformanceId())
|
||||
.reviewType(entity.getReviewType())
|
||||
.regUser(entity.getRegUser())
|
||||
.reviewDt(reviewDt)
|
||||
.reviewStatus(entity.getReviewStatus())
|
||||
.uploadFileName(entity.getUploadFileName())
|
||||
.pdfConvert(entity.getPdfConvert())
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.kri.gwcf.review.back.dto.user;
|
||||
|
||||
import static com.kri.gwcf.review.back.common.util.MakeExtraFieldMap.toExtraFieldMap;
|
||||
|
||||
import com.kri.gwcf.review.back.dto.excel.UserUploadBaseDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.user.UserUploadBaseDto;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TUserEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -85,6 +85,8 @@ public class TPerformanceMonitoringVisitEntity {
|
||||
entity.setGpsLongitude(dto.getGpsLongitude());
|
||||
entity.setGpsAccuracyM(dto.getGpsAccuracyM());
|
||||
entity.setGpsRaw(dto.getGpsRaw());
|
||||
entity.setRegUser(dto.getRegUser());
|
||||
entity.setRegDt(dto.getRegDt());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ public class TPerformanceReviewEntity {
|
||||
@Column(name = "review_status", nullable = false)
|
||||
private Integer reviewStatus;
|
||||
|
||||
@Size(max = 512)
|
||||
@NotNull
|
||||
@Column(name = "upload_file_name", nullable = false, length = 512)
|
||||
private String uploadFileName;
|
||||
@@ -39,16 +38,10 @@ public class TPerformanceReviewEntity {
|
||||
@Column(name = "is_pdf_convert", nullable = false)
|
||||
private Boolean pdfConvert;
|
||||
|
||||
@Size(max = 512)
|
||||
@NotNull
|
||||
@Column(name = "pdf_file_name", nullable = false, length = 512)
|
||||
private String pdfFileName;
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
|
||||
private String regUser;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("CURRENT_TIMESTAMP")
|
||||
@Column(name = "reg_dt", nullable = false, updatable = false)
|
||||
@@ -69,6 +62,17 @@ public class TPerformanceReviewEntity {
|
||||
return id.getReviewType();
|
||||
}
|
||||
|
||||
public String getRegUser() {
|
||||
return id == null ? null : id.getRegUser();
|
||||
}
|
||||
|
||||
public void setRegUser(String regUser) {
|
||||
if (id == null) {
|
||||
id = new TPerformanceReviewEntityId();
|
||||
}
|
||||
id.setRegUser(regUser);
|
||||
}
|
||||
|
||||
public static TPerformanceReviewEntity from(PerformanceReviewDto dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
@@ -78,6 +82,7 @@ public class TPerformanceReviewEntity {
|
||||
entity.setId(TPerformanceReviewEntityId.builder()
|
||||
.performanceId(dto.getPerformanceId())
|
||||
.reviewType(dto.getReviewType())
|
||||
.regUser(dto.getRegUser())
|
||||
.build());
|
||||
entity.setReviewStatus(dto.getReviewStatus());
|
||||
entity.setUploadFileName(dto.getUploadFileName());
|
||||
|
||||
@@ -86,6 +86,8 @@ public class TUserDetailEntity {
|
||||
.userDetailKey(userDetailKey)
|
||||
.build())
|
||||
.userDetailValue(userDetailValue)
|
||||
.regUser(modUser)
|
||||
.regDt(modDt)
|
||||
.modUser(modUser)
|
||||
.modDt(modDt)
|
||||
.build();
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kri.gwcf.review.back.persistence.entity.id;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -27,5 +28,8 @@ public class TPerformanceReviewEntityId implements Serializable {
|
||||
@Column(name = "review_type", nullable = false, updatable = false)
|
||||
private Integer reviewType;
|
||||
|
||||
|
||||
@Size(max = 32)
|
||||
@NotNull
|
||||
@Column(name = "reg_user", nullable = false, length = 32, updatable = false)
|
||||
private String regUser;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.kri.gwcf.review.back.persistence.mapper.kon;
|
||||
|
||||
import com.kri.gwcf.review.back.dto.kon.PerformanceApplyCountDto;
|
||||
import com.kri.gwcf.review.back.dto.kon.PerformanceApplyUserDto;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface KonMapper {
|
||||
|
||||
List<PerformanceApplyCountDto> findPerformanceApplyCount(
|
||||
@Param("surveyType") String surveyType
|
||||
);
|
||||
|
||||
List<PerformanceApplyUserDto> findPerformanceApplyUser(
|
||||
@Param("surveyType") String surveyType,
|
||||
@Param("performanceId") String performanceId
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.kri.gwcf.review.back.persistence.repository;
|
||||
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
|
||||
import com.kri.gwcf.review.back.dto.assign.AssignUserCountDto;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface PerformanceAssignRepository extends JpaRepository<TPerformanceAssignEntity, Long> {
|
||||
|
||||
@@ -11,4 +13,42 @@ public interface PerformanceAssignRepository extends JpaRepository<TPerformanceA
|
||||
boolean existsByPerformanceId(Integer performanceId);
|
||||
|
||||
List<TPerformanceAssignEntity> findByPerformanceId(Integer performanceId);
|
||||
|
||||
boolean existsByPerformanceIdAndAssignUser(Integer performanceId, String assignUser);
|
||||
|
||||
boolean existsByAssignUserAndPerformanceIdNot(String assignUser, Integer performanceId);
|
||||
|
||||
long countByPerformanceIdAndAssignType(Integer performanceId, Integer assignType);
|
||||
|
||||
long countByPerformanceIdAndAssignTypeAndAssignConfirm(
|
||||
Integer performanceId,
|
||||
Integer assignType,
|
||||
Boolean assignConfirm
|
||||
);
|
||||
|
||||
List<TPerformanceAssignEntity> findByPerformanceIdAndAssignUser(
|
||||
Integer performanceId,
|
||||
String assignUser
|
||||
);
|
||||
|
||||
List<TPerformanceAssignEntity> findByPerformanceIdAndAssignUserAndAssignType(
|
||||
Integer performanceId,
|
||||
String assignUser,
|
||||
Integer assignType
|
||||
);
|
||||
|
||||
List<TPerformanceAssignEntity> findByPerformanceIdAndAssignType(
|
||||
Integer performanceId,
|
||||
Integer assignType
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select new com.kri.gwcf.review.back.dto.assign.AssignUserCountDto(
|
||||
assign.assignUser,
|
||||
count(assign)
|
||||
)
|
||||
from TPerformanceAssignEntity assign
|
||||
group by assign.assignUser
|
||||
""")
|
||||
List<AssignUserCountDto> countGroupByAssignUser();
|
||||
}
|
||||
|
||||
@@ -11,4 +11,9 @@ public interface PerformanceMonitoringVisitRepository extends JpaRepository<TPer
|
||||
boolean existsByPerformanceId(Integer performanceId);
|
||||
|
||||
List<TPerformanceMonitoringVisitEntity> findByPerformanceId(Integer performanceId);
|
||||
|
||||
List<TPerformanceMonitoringVisitEntity> findByPerformanceIdAndRegUser(
|
||||
Integer performanceId,
|
||||
String regUser
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,26 @@ package com.kri.gwcf.review.back.persistence.repository;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import com.kri.gwcf.review.back.persistence.entity.id.TPerformanceReviewEntityId;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PerformanceReviewRepository extends JpaRepository<TPerformanceReviewEntity, TPerformanceReviewEntityId> {
|
||||
|
||||
boolean existsByRegUserOrModUser(String regUser, String modUser);
|
||||
boolean existsByIdRegUserOrModUser(String regUser, String modUser);
|
||||
|
||||
boolean existsByIdPerformanceId(Integer performanceId);
|
||||
|
||||
List<TPerformanceReviewEntity> findByIdPerformanceId(Integer performanceId);
|
||||
|
||||
Optional<TPerformanceReviewEntity> findByIdPerformanceIdAndIdReviewTypeAndIdRegUser(
|
||||
Integer performanceId,
|
||||
Integer reviewType,
|
||||
String regUser
|
||||
);
|
||||
|
||||
boolean existsByIdPerformanceIdAndIdReviewTypeAndIdRegUser(
|
||||
Integer performanceId,
|
||||
Integer reviewType,
|
||||
String regUser
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,59 @@
|
||||
package com.kri.gwcf.review.back.service;
|
||||
|
||||
import com.kri.common.feature.excel.ExcelMapper;
|
||||
import com.kri.common.feature.util.NumericUtil;
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.gwcf.review.back.common.util.ExcelUploadResultUtil;
|
||||
import com.kri.gwcf.review.back.dto.assign.AssignUserCountDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelErrorDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.user.WrittenUserAssignDto;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.gwcf.review.back.dto.kon.PerformanceApplyCountDto;
|
||||
import com.kri.gwcf.review.back.dto.kon.PerformanceApplyUserDto;
|
||||
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.user.UserCompactDto;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceAssignEntity;
|
||||
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.mapper.kon.KonMapper;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceAssignRepository;
|
||||
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.UserDetailRepository;
|
||||
import com.kri.gwcf.review.back.persistence.repository.UserRepository;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AssignService {
|
||||
|
||||
private final PerformanceAssignRepository performanceAssignRepository;
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
private final KonMapper konMapper;
|
||||
private final PerformanceRepository performanceRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final UserDetailRepository userDetailRepository;
|
||||
|
||||
@Value("${kon.survey-type:LIST}")
|
||||
private String surveyType;
|
||||
|
||||
public boolean hasAssignWithUser(String userId) {
|
||||
return performanceAssignRepository.existsByAssignUser(userId);
|
||||
@@ -25,4 +68,375 @@ public class AssignService {
|
||||
.map(PerformanceAssignDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<AssignUserCountDto> findAssignUserCounts() {
|
||||
return performanceAssignRepository.countGroupByAssignUser();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
||||
public List<PerformanceApplyUserDto> findKonPerformanceApplyUser(Integer performanceId) {
|
||||
return konMapper.findPerformanceApplyUser(surveyType, String.valueOf(performanceId));
|
||||
}
|
||||
|
||||
public List<PerformanceApplyCountDto> findMonitoringApplyUsersCount() {
|
||||
return konMapper.findPerformanceApplyCount(surveyType);
|
||||
}
|
||||
|
||||
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(Integer performanceId) {
|
||||
List<PerformanceApplyUserDto> applyUsers = findKonPerformanceApplyUser(performanceId);
|
||||
List<String> userIds = applyUsers.stream()
|
||||
.map(PerformanceApplyUserDto::getUserId)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
Map<String, TUserEntity> userMap = userRepository.findAllById(userIds).stream()
|
||||
.collect(Collectors.toMap(TUserEntity::getUserId, Function.identity()));
|
||||
|
||||
Map<String, Map<String, String>> userDetailMap = userIds.stream()
|
||||
.collect(Collectors.toMap(
|
||||
Function.identity(),
|
||||
userId -> userDetailRepository.findByIdUserId(userId).stream()
|
||||
.collect(Collectors.toMap(
|
||||
TUserDetailEntity::getUserDetailKey,
|
||||
TUserDetailEntity::getUserDetailValue
|
||||
))
|
||||
));
|
||||
|
||||
return applyUsers.stream()
|
||||
.map(applyUser -> {
|
||||
TUserEntity user = userMap.get(applyUser.getUserId());
|
||||
return MonitoringApplyUserDto.builder()
|
||||
.performanceId(performanceId)
|
||||
.userId(applyUser.getUserId())
|
||||
.user(user == null
|
||||
? null
|
||||
: UserCompactDto.from(
|
||||
user,
|
||||
userDetailMap.getOrDefault(applyUser.getUserId(), Collections.emptyMap())
|
||||
))
|
||||
.build();
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceAssignDto saveMonitoringAssign(
|
||||
Integer performanceId,
|
||||
String assignUser,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
if (performanceAssignRepository.existsByAssignUser(assignUser)) {
|
||||
throw BusinessException.conflict("ASSIGN_ALREADY_EXISTS", "이미 배정된 사용자입니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("assignUser", assignUser);
|
||||
}
|
||||
|
||||
long currentCount = performanceAssignRepository.countByPerformanceIdAndAssignType(performanceId, 1);
|
||||
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
|
||||
entity.setPerformanceId(performanceId);
|
||||
entity.setAssignType(1);
|
||||
entity.setAssignOrder((short) (currentCount + 1));
|
||||
entity.setAssignUser(assignUser);
|
||||
entity.setAssignConfirm(false);
|
||||
entity.setRegUser(regUser);
|
||||
entity.setRegDt(regDt);
|
||||
|
||||
return PerformanceAssignDto.from(performanceAssignRepository.save(entity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<PerformanceAssignDto> saveMonitoringAssign(
|
||||
Integer performanceId,
|
||||
List<String> assignUsers,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
if (performanceId == null) {
|
||||
throw BusinessException.badRequest("EMPTY_PERFORMANCE_ID", "공연 ID가 없습니다.");
|
||||
}
|
||||
if (!performanceRepository.existsById(performanceId)) {
|
||||
throw BusinessException.notFound("PERFORMANCE_NOT_FOUND", "존재하지 않는 공연입니다.")
|
||||
.with("performanceId", performanceId);
|
||||
}
|
||||
|
||||
List<String> normalizedAssignUsers = normalizeUserIds(assignUsers);
|
||||
if (normalizedAssignUsers.size() > 2) {
|
||||
throw BusinessException.badRequest("MONITORING_ASSIGN_LIMIT", "모니터링 요원은 최대 2명까지 배정할 수 있습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("assignUsers", normalizedAssignUsers);
|
||||
}
|
||||
|
||||
for (String assignUser : normalizedAssignUsers) {
|
||||
validateAssignableUser(performanceId, assignUser);
|
||||
}
|
||||
|
||||
List<TPerformanceAssignEntity> currentAssigns =
|
||||
performanceAssignRepository.findByPerformanceIdAndAssignType(performanceId, 1);
|
||||
Set<String> requestedUserSet = Set.copyOf(normalizedAssignUsers);
|
||||
List<TPerformanceAssignEntity> deleteTargets = currentAssigns.stream()
|
||||
.filter(assign -> !requestedUserSet.contains(assign.getAssignUser()))
|
||||
.toList();
|
||||
|
||||
for (TPerformanceAssignEntity deleteTarget : deleteTargets) {
|
||||
validateNoReviewBeforeAssignRemove(deleteTarget);
|
||||
}
|
||||
performanceAssignRepository.deleteAll(deleteTargets);
|
||||
|
||||
Set<String> currentUserSet = currentAssigns.stream()
|
||||
.filter(assign -> requestedUserSet.contains(assign.getAssignUser()))
|
||||
.map(TPerformanceAssignEntity::getAssignUser)
|
||||
.collect(Collectors.toSet());
|
||||
Map<String, TPerformanceAssignEntity> currentAssignMap = currentAssigns.stream()
|
||||
.filter(assign -> requestedUserSet.contains(assign.getAssignUser()))
|
||||
.collect(Collectors.toMap(
|
||||
TPerformanceAssignEntity::getAssignUser,
|
||||
Function.identity(),
|
||||
(first, second) -> first
|
||||
));
|
||||
|
||||
short assignOrder = 1;
|
||||
for (String assignUser : normalizedAssignUsers) {
|
||||
if (!currentUserSet.contains(assignUser)) {
|
||||
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
|
||||
entity.setPerformanceId(performanceId);
|
||||
entity.setAssignType(1);
|
||||
entity.setAssignOrder(assignOrder);
|
||||
entity.setAssignUser(assignUser);
|
||||
entity.setAssignConfirm(false);
|
||||
entity.setRegUser(regUser);
|
||||
entity.setRegDt(regDt);
|
||||
performanceAssignRepository.save(entity);
|
||||
} else {
|
||||
currentAssignMap.get(assignUser).setAssignOrder(assignOrder);
|
||||
}
|
||||
assignOrder++;
|
||||
}
|
||||
|
||||
return performanceAssignRepository.findByPerformanceIdAndAssignType(performanceId, 1).stream()
|
||||
.map(PerformanceAssignDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public byte[] exportAssignTemplate() {
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(Collections.emptyList(), WrittenUserAssignDto.class);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("사용자 배정 템플릿 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ExcelUploadResultDto createWrittenAssignsFromExcel(
|
||||
MultipartFile file,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
|
||||
}
|
||||
|
||||
String fileName = file.getOriginalFilename();
|
||||
String errorFileName = fileName != null && fileName.endsWith(".xlsx")
|
||||
? fileName.substring(0, fileName.length() - 5) + "_error.xlsx"
|
||||
: fileName + "_error.xlsx";
|
||||
|
||||
List<WrittenUserAssignDto> rows;
|
||||
try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
|
||||
rows = ExcelMapper.readFromWorkbook(workbook, WrittenUserAssignDto.class);
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.badRequest("INVALID_EXCEL", "엑셀 파일을 읽는 중 오류가 발생했습니다.")
|
||||
.with("fileName", fileName);
|
||||
}
|
||||
|
||||
int totalCount = rows.size();
|
||||
int successCount = 0;
|
||||
List<ExcelErrorDto> errorList = new ArrayList<>();
|
||||
Set<Integer> uploadedPerformanceIds = new java.util.HashSet<>();
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
WrittenUserAssignDto row = rows.get(i);
|
||||
int rowNumber = i + 2;
|
||||
|
||||
List<ExcelErrorDto> rowErrors = validateWrittenAssignRow(row, rowNumber);
|
||||
if (!rowErrors.isEmpty()) {
|
||||
errorList.addAll(rowErrors);
|
||||
continue;
|
||||
}
|
||||
|
||||
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
||||
if (!uploadedPerformanceIds.add(performanceId)) {
|
||||
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "하나의 사업에는 서면평가위원을 1명만 배정할 수 있습니다."));
|
||||
continue;
|
||||
}
|
||||
|
||||
List<TPerformanceAssignEntity> currentAssigns =
|
||||
performanceAssignRepository.findByPerformanceIdAndAssignType(performanceId, 2);
|
||||
boolean sameAssignExists = currentAssigns.size() == 1
|
||||
&& Objects.equals(currentAssigns.get(0).getAssignUser(), row.getUserId());
|
||||
if (!sameAssignExists && currentAssigns.stream().anyMatch(this::hasReview)) {
|
||||
errorList.add(ExcelErrorDto.of(rowNumber, "사업 연번", "리뷰가 있는 배정은 변경할 수 없습니다."));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sameAssignExists) {
|
||||
successCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
performanceAssignRepository.deleteAll(currentAssigns);
|
||||
|
||||
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
|
||||
entity.setPerformanceId(performanceId);
|
||||
entity.setAssignType(2);
|
||||
entity.setAssignOrder((short) 1);
|
||||
entity.setAssignUser(row.getUserId());
|
||||
entity.setAssignConfirm(true);
|
||||
entity.setRegUser(regUser);
|
||||
entity.setRegDt(regDt);
|
||||
performanceAssignRepository.save(entity);
|
||||
successCount++;
|
||||
}
|
||||
|
||||
int failCount = errorList.stream()
|
||||
.map(ExcelErrorDto::getRowNumber)
|
||||
.distinct()
|
||||
.toList()
|
||||
.size();
|
||||
|
||||
return ExcelUploadResultUtil.buildUploadResult(
|
||||
totalCount,
|
||||
successCount,
|
||||
failCount,
|
||||
errorList,
|
||||
ExcelErrorDto.class,
|
||||
errorFileName
|
||||
);
|
||||
}
|
||||
|
||||
private List<ExcelErrorDto> validateWrittenAssignRow(
|
||||
WrittenUserAssignDto row,
|
||||
int rowNumber
|
||||
) {
|
||||
List<ExcelErrorDto> errors = new ArrayList<>();
|
||||
Integer performanceId = NumericUtil.parseOnlyInteger(row.getPerformanceId());
|
||||
String userId = row.getUserId();
|
||||
|
||||
if (performanceId == null) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "사업 연번", "사업 연번은 숫자여야 합니다."));
|
||||
} else if (!performanceRepository.existsById(performanceId)) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "사업 연번", "존재하지 않는 사업 연번입니다."));
|
||||
}
|
||||
|
||||
if (StringUtil.isNullOrBlank(userId)) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "사용자 ID", "사용자 ID가 비어 있습니다."));
|
||||
} else if (!userRepository.existsByUserId(userId)) {
|
||||
errors.add(ExcelErrorDto.of(rowNumber, "사용자 ID", "존재하지 않는 사용자 ID입니다."));
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
private List<String> normalizeUserIds(List<String> userIds) {
|
||||
if (userIds == null) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
return userIds.stream()
|
||||
.filter(StringUtil::hasText)
|
||||
.map(String::trim)
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
private void validateAssignableUser(Integer performanceId, String userId) {
|
||||
if (StringUtil.isNullOrBlank(userId)) {
|
||||
throw BusinessException.badRequest("EMPTY_USER_ID", "사용자 ID가 없습니다.");
|
||||
}
|
||||
if (!userRepository.existsByUserId(userId)) {
|
||||
throw BusinessException.notFound("USER_NOT_FOUND", "존재하지 않는 사용자 ID입니다.")
|
||||
.with("userId", userId);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasReview(TPerformanceAssignEntity assign) {
|
||||
return performanceReviewRepository.existsByIdPerformanceIdAndIdReviewTypeAndIdRegUser(
|
||||
assign.getPerformanceId(),
|
||||
assign.getAssignType(),
|
||||
assign.getAssignUser()
|
||||
);
|
||||
}
|
||||
|
||||
private void validateNoReviewBeforeAssignRemove(TPerformanceAssignEntity assign) {
|
||||
if (hasReview(assign)) {
|
||||
throw BusinessException.conflict("ASSIGN_HAS_REVIEW", "리뷰가 있는 배정은 해제하거나 삭제할 수 없습니다.")
|
||||
.with("performanceId", assign.getPerformanceId())
|
||||
.with("assignType", assign.getAssignType())
|
||||
.with("assignUser", assign.getAssignUser());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String confirmMonitoringAssignByUser(Integer performanceId, String assignUser) {
|
||||
List<TPerformanceAssignEntity> assigns =
|
||||
performanceAssignRepository.findByPerformanceIdAndAssignUserAndAssignType(
|
||||
performanceId,
|
||||
assignUser,
|
||||
1
|
||||
);
|
||||
|
||||
if (assigns.isEmpty()) {
|
||||
return "승인 가능한 내용이 없습니다.";
|
||||
}
|
||||
|
||||
boolean alreadyConfirmed = assigns.stream()
|
||||
.anyMatch(assign -> Boolean.TRUE.equals(assign.getAssignConfirm()));
|
||||
if (alreadyConfirmed) {
|
||||
return "이미 승인된 내용입니다.";
|
||||
}
|
||||
|
||||
long confirmedCount = performanceAssignRepository
|
||||
.countByPerformanceIdAndAssignTypeAndAssignConfirm(performanceId, 1, true);
|
||||
if (confirmedCount >= 2) {
|
||||
return "이미 배정이 종료된 공연입니다.";
|
||||
}
|
||||
|
||||
assigns.stream()
|
||||
.filter(assign -> Boolean.FALSE.equals(assign.getAssignConfirm()))
|
||||
.forEach(assign -> assign.setAssignConfirm(true));
|
||||
|
||||
return "승인 처리 됐습니다.";
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void confirmAssign(Integer performanceId, String assignUser, boolean confirm) {
|
||||
List<TPerformanceAssignEntity> assigns =
|
||||
performanceAssignRepository.findByPerformanceIdAndAssignUser(performanceId, assignUser);
|
||||
if (assigns.isEmpty()) {
|
||||
throw BusinessException.notFound("ASSIGN_NOT_FOUND", "배정 정보를 찾을 수 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("assignUser", assignUser);
|
||||
}
|
||||
|
||||
for (TPerformanceAssignEntity assign : assigns) {
|
||||
if (!confirm && hasReview(assign)) {
|
||||
throw BusinessException.conflict("ASSIGN_HAS_REVIEW", "리뷰가 있는 배정은 해제하거나 삭제할 수 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("assignType", assign.getAssignType())
|
||||
.with("assignUser", assignUser);
|
||||
}
|
||||
if (confirm && Boolean.FALSE.equals(assign.getAssignConfirm())) {
|
||||
long confirmedCount = performanceAssignRepository
|
||||
.countByPerformanceIdAndAssignTypeAndAssignConfirm(performanceId, assign.getAssignType(), true);
|
||||
if (assign.getAssignType() == 1 && confirmedCount >= 2) {
|
||||
throw BusinessException.conflict("MONITORING_ASSIGN_CONFIRM_LIMIT", "확정된 모니터링 요원은 최대 2명입니다.")
|
||||
.with("performanceId", performanceId);
|
||||
}
|
||||
}
|
||||
assign.setAssignConfirm(confirm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,21 +13,27 @@ import com.kri.gwcf.review.back.common.util.TelUtil;
|
||||
import com.kri.gwcf.review.back.dto.common.CodeDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelErrorDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.PerformanceUploadDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.performance.PerformanceDownloadDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.performance.PerformanceUploadDto;
|
||||
import com.kri.gwcf.review.back.dto.kon.PerformanceApplyCountDto;
|
||||
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.PerformanceFullDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringScheduleDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceStaffDto;
|
||||
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.TPerformanceMonitoringScheduleEntity;
|
||||
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.repository.PerformanceDetailRepository;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringScheduleRepository;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceRepository;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceStaffRepository;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -35,9 +41,12 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -46,6 +55,10 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
@RequiredArgsConstructor
|
||||
public class PerformanceService {
|
||||
|
||||
private static final DateTimeFormatter REVIEW_DT_FORMATTER =
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private final KonMapper konMapper;
|
||||
private final PerformanceRepository performanceRepository;
|
||||
private final PerformanceDetailRepository performanceDetailRepository;
|
||||
private final PerformanceStaffRepository performanceStaffRepository;
|
||||
@@ -55,6 +68,9 @@ public class PerformanceService {
|
||||
private final ReviewService reviewService;
|
||||
private final VisitService visitService;
|
||||
|
||||
@Value("${kon.survey-type:LIST}")
|
||||
private String surveyType;
|
||||
|
||||
public PerformanceFullDto getPerformance(Integer performanceId) {
|
||||
TPerformanceEntity performance = getPerformanceEntity(performanceId);
|
||||
return toFullDto(performance);
|
||||
@@ -200,6 +216,190 @@ public class PerformanceService {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] exportPerformance(String[] performanceIds) {
|
||||
Set<String> selectedPerformanceIds = performanceIds == null
|
||||
? Collections.emptySet()
|
||||
: Arrays.stream(performanceIds).collect(Collectors.toSet());
|
||||
List<PerformanceDownloadDto> performanceList = getPerformanceList().stream()
|
||||
.filter(performance -> selectedPerformanceIds.contains(String.valueOf(performance.getId())))
|
||||
.map(this::toPerformanceDownloadRow)
|
||||
.toList();
|
||||
|
||||
List<CodeDto> businessTypeList = codeService.findByCodeGroup("business_type");
|
||||
List<CodeDto> genreList = codeService.findByCodeGroup("genre");
|
||||
List<CodeDto> areaList = codeService.findByCodeGroup("area");
|
||||
List<CodeDto> ticketReservationStatusList =
|
||||
codeService.findByCodeGroup("ticket_reservation_status");
|
||||
List<CodeDto> reviewStatusList = codeService.findByCodeGroup("review_status");
|
||||
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(performanceList, PerformanceDownloadDto.class);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
|
||||
appendCodeSheet(workbook, businessTypeList, "사업유형");
|
||||
appendCodeSheet(workbook, genreList, "장르");
|
||||
appendCodeSheet(workbook, areaList, "지역");
|
||||
appendCodeSheet(workbook, ticketReservationStatusList, "티켓 예약");
|
||||
appendCodeSheet(workbook, reviewStatusList, "평가 상태");
|
||||
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("공연 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
private PerformanceDownloadDto toPerformanceDownloadRow(PerformanceFullDto performance) {
|
||||
Map<String, String> detail = performance.getPerformanceDetail() == null
|
||||
? Collections.emptyMap()
|
||||
: performance.getPerformanceDetail();
|
||||
PerformanceMonitoringScheduleDto schedule = performance.getPerformanceMonitoringSchedule();
|
||||
PerformanceStaffDto ownStaff = findStaff(performance, 1);
|
||||
PerformanceStaffDto contactStaff = findStaff(performance, 2);
|
||||
PerformanceAssignDto monitoringAssign1 = findAssign(performance, 1, (short) 1);
|
||||
PerformanceAssignDto monitoringAssign2 = findAssign(performance, 1, (short) 2);
|
||||
PerformanceAssignDto writtenAssign = findFirstAssign(performance, 2);
|
||||
|
||||
PerformanceReviewDto localReview = findFirstReview(performance, 3);
|
||||
PerformanceReviewDto monitoringReview1 = findReview(
|
||||
performance,
|
||||
1,
|
||||
monitoringAssign1 == null ? null : monitoringAssign1.getAssignUser()
|
||||
);
|
||||
PerformanceReviewDto monitoringReview2 = findReview(
|
||||
performance,
|
||||
1,
|
||||
monitoringAssign2 == null ? null : monitoringAssign2.getAssignUser()
|
||||
);
|
||||
PerformanceReviewDto writtenReview = findReview(
|
||||
performance,
|
||||
2,
|
||||
writtenAssign == null ? null : writtenAssign.getAssignUser()
|
||||
);
|
||||
|
||||
return PerformanceDownloadDto.builder()
|
||||
.performanceId(toStringValue(performance.getId()))
|
||||
.businessType(toStringValue(performance.getBusinessType()))
|
||||
.genre(toStringValue(performance.getPerformanceGenre()))
|
||||
.performanceArea(toStringValue(performance.getPerformanceArea()))
|
||||
.artistName(performance.getArtistName())
|
||||
.performanceName(performance.getPerformanceName())
|
||||
.performanceStartMonth(toStringValue(performance.getPerformanceStartMonth()))
|
||||
.performanceDtInfo(performance.getPerformanceDtInfo())
|
||||
.performanceTimeInfo(performance.getPerformanceTimeInfo())
|
||||
.ticketReservationStatus(toStringValue(performance.getTicketReservationStatus()))
|
||||
.ticketReservationMemo(performance.getTicketReservationMemo())
|
||||
.monitoringDate(schedule == null ? null : toStringValue(schedule.getMonitoringDate()))
|
||||
.monitoringTimeInfo(schedule == null ? null : schedule.getMonitoringTimeInfo())
|
||||
.monitoringAddress(schedule == null ? null : schedule.getMonitoringAddress())
|
||||
.ownStaffName(ownStaff == null ? null : ownStaff.getStaffName())
|
||||
.ownStaffTel1(ownStaff == null ? null : ownStaff.getStaffTel1())
|
||||
.ownStaffTel2(ownStaff == null ? null : ownStaff.getStaffTel2())
|
||||
.ownStaffEmail(ownStaff == null ? null : ownStaff.getStaffEmail())
|
||||
.contactStaffName(contactStaff == null ? null : contactStaff.getStaffName())
|
||||
.contactStaffTel1(contactStaff == null ? null : contactStaff.getStaffTel1())
|
||||
.contactStaffTel2(contactStaff == null ? null : contactStaff.getStaffTel2())
|
||||
.contactStaffEmail(contactStaff == null ? null : contactStaff.getStaffEmail())
|
||||
.performanceMemo(performance.getPerformanceMemo())
|
||||
.monitoringPaymentDate(detail.get("monitoringPaymentDate"))
|
||||
.localReviewUser(localReview == null ? null : localReview.getRegUser())
|
||||
.localReviewStatus(localReview == null ? null : toStringValue(localReview.getReviewStatus()))
|
||||
.localReviewDt(formatReviewDt(localReview))
|
||||
.monitoringReviewUser1(monitoringAssign1 == null ? null : monitoringAssign1.getAssignUser())
|
||||
.monitoringReviewStatus1(monitoringReview1 == null ? null : toStringValue(monitoringReview1.getReviewStatus()))
|
||||
.monitoringReviewDt1(formatReviewDt(monitoringReview1))
|
||||
.monitoringReviewUser2(monitoringAssign2 == null ? null : monitoringAssign2.getAssignUser())
|
||||
.monitoringReviewStatus2(monitoringReview2 == null ? null : toStringValue(monitoringReview2.getReviewStatus()))
|
||||
.monitoringReviewDt2(formatReviewDt(monitoringReview2))
|
||||
.writtenReviewUser(writtenAssign == null ? null : writtenAssign.getAssignUser())
|
||||
.writtenReviewStatus(writtenReview == null ? null : toStringValue(writtenReview.getReviewStatus()))
|
||||
.writtenReviewDt(formatReviewDt(writtenReview))
|
||||
.build();
|
||||
}
|
||||
|
||||
private PerformanceStaffDto findStaff(PerformanceFullDto performance, Integer staffType) {
|
||||
if (performance.getPerformanceStaff() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceStaff().stream()
|
||||
.filter(staff -> Objects.equals(staff.getStaffType(), staffType))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private PerformanceAssignDto findAssign(
|
||||
PerformanceFullDto performance,
|
||||
Integer assignType,
|
||||
Short assignOrder
|
||||
) {
|
||||
if (performance.getPerformanceAssignList() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceAssignList().stream()
|
||||
.filter(assign -> Objects.equals(assign.getAssignType(), assignType))
|
||||
.filter(assign -> Objects.equals(assign.getAssignOrder(), assignOrder))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private PerformanceAssignDto findFirstAssign(PerformanceFullDto performance, Integer assignType) {
|
||||
if (performance.getPerformanceAssignList() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceAssignList().stream()
|
||||
.filter(assign -> Objects.equals(assign.getAssignType(), assignType))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private PerformanceReviewDto findFirstReview(PerformanceFullDto performance, Integer reviewType) {
|
||||
if (performance.getPerformanceReviewMap() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceReviewMap().values().stream()
|
||||
.flatMap(List::stream)
|
||||
.filter(review -> Objects.equals(review.getReviewType(), reviewType))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private PerformanceReviewDto findReview(
|
||||
PerformanceFullDto performance,
|
||||
Integer reviewType,
|
||||
String regUser
|
||||
) {
|
||||
if (StringUtil.isNullOrBlank(regUser) || performance.getPerformanceReviewMap() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return performance.getPerformanceReviewMap()
|
||||
.getOrDefault(regUser, Collections.emptyList())
|
||||
.stream()
|
||||
.filter(review -> Objects.equals(review.getReviewType(), reviewType))
|
||||
.filter(review -> Objects.equals(review.getRegUser(), regUser))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private String formatReviewDt(PerformanceReviewDto review) {
|
||||
return review == null || review.getReviewDt() == null
|
||||
? null
|
||||
: review.getReviewDt().format(REVIEW_DT_FORMATTER);
|
||||
}
|
||||
|
||||
private String toStringValue(Object value) {
|
||||
return value == null ? null : String.valueOf(value);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
|
||||
public List<PerformanceApplyCountDto> findPerformanceApplyCount() {
|
||||
return konMapper.findPerformanceApplyCount(surveyType);
|
||||
}
|
||||
|
||||
private PerformanceFullDto toFullDto(TPerformanceEntity performance) {
|
||||
Integer performanceId = performance.getId();
|
||||
|
||||
|
||||
@@ -1,22 +1,49 @@
|
||||
package com.kri.gwcf.review.back.service;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.gwcf.review.back.config.FileStorageProperties;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceReviewDto;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceReviewEntity;
|
||||
import com.kri.gwcf.review.back.persistence.entity.id.TPerformanceReviewEntityId;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceReviewRepository;
|
||||
import com.kri.gwcf.review.back.service.file.AbstractFileService;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.PathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReviewService {
|
||||
public class ReviewService extends AbstractFileService {
|
||||
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
private final FileStorageProperties fileStorageProperties;
|
||||
|
||||
@Value("${kri.file.pdf-converter-command:soffice}")
|
||||
private String pdfConverterCommand;
|
||||
|
||||
@Override
|
||||
protected Path getBaseDir() {
|
||||
return Path.of(fileStorageProperties.getReviewBaseDir())
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
public boolean hasReviewWithUser(String userId) {
|
||||
return performanceReviewRepository.existsByRegUserOrModUser(userId, userId);
|
||||
return performanceReviewRepository.existsByIdRegUserOrModUser(userId, userId);
|
||||
}
|
||||
|
||||
public boolean hasReviewWithPerformance(Integer performanceId) {
|
||||
@@ -30,4 +57,223 @@ public class ReviewService {
|
||||
Collectors.mapping(PerformanceReviewDto::from, Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceReviewDto saveWrittenReviewStatus(
|
||||
Integer performanceId,
|
||||
Integer reviewStatus,
|
||||
String userId,
|
||||
LocalDateTime now
|
||||
) {
|
||||
TPerformanceReviewEntity entity = performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewTypeAndIdRegUser(performanceId, 2, userId)
|
||||
.orElseGet(() -> TPerformanceReviewEntity.builder()
|
||||
.id(TPerformanceReviewEntityId.builder()
|
||||
.performanceId(performanceId)
|
||||
.reviewType(2)
|
||||
.regUser(userId)
|
||||
.build())
|
||||
.uploadFileName("")
|
||||
.pdfConvert(false)
|
||||
.pdfFileName("")
|
||||
.regDt(now)
|
||||
.build());
|
||||
|
||||
entity.setReviewStatus(reviewStatus);
|
||||
if (entity.getRegUser() == null) {
|
||||
entity.setRegUser(userId);
|
||||
entity.setRegDt(now);
|
||||
} else {
|
||||
entity.setModUser(userId);
|
||||
entity.setModDt(now);
|
||||
}
|
||||
|
||||
return PerformanceReviewDto.from(performanceReviewRepository.save(entity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceReviewDto saveMonitoringReviewStatus(
|
||||
Integer performanceId,
|
||||
Integer reviewStatus,
|
||||
String userId,
|
||||
LocalDateTime now
|
||||
) {
|
||||
TPerformanceReviewEntity entity = performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewTypeAndIdRegUser(performanceId, 1, userId)
|
||||
.orElseGet(() -> TPerformanceReviewEntity.builder()
|
||||
.id(TPerformanceReviewEntityId.builder()
|
||||
.performanceId(performanceId)
|
||||
.reviewType(1)
|
||||
.regUser(userId)
|
||||
.build())
|
||||
.uploadFileName("")
|
||||
.pdfConvert(false)
|
||||
.pdfFileName("")
|
||||
.regDt(now)
|
||||
.build());
|
||||
|
||||
entity.setReviewStatus(reviewStatus);
|
||||
entity.setModUser(userId);
|
||||
entity.setModDt(now);
|
||||
|
||||
return PerformanceReviewDto.from(performanceReviewRepository.save(entity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceReviewDto uploadReviewFile(
|
||||
Integer performanceId,
|
||||
Integer reviewType,
|
||||
MultipartFile file,
|
||||
String userId,
|
||||
LocalDateTime now
|
||||
) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
||||
}
|
||||
|
||||
try {
|
||||
Path dir = reviewDir(performanceId, reviewType);
|
||||
String uploadFileName = buildFileNameWithTime(file, now);
|
||||
saveFile(dir, file, uploadFileName);
|
||||
Path uploadPath = dir.resolve(uploadFileName).normalize();
|
||||
|
||||
String pdfFileName = isPdf(uploadFileName)
|
||||
? uploadFileName
|
||||
: convertToPdfIfPossible(uploadPath, dir);
|
||||
boolean pdfConvert = StringUtil.hasText(pdfFileName);
|
||||
|
||||
TPerformanceReviewEntity entity = performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewTypeAndIdRegUser(performanceId, reviewType, userId)
|
||||
.orElseGet(() -> TPerformanceReviewEntity.builder()
|
||||
.id(TPerformanceReviewEntityId.builder()
|
||||
.performanceId(performanceId)
|
||||
.reviewType(reviewType)
|
||||
.regUser(userId)
|
||||
.build())
|
||||
.regDt(now)
|
||||
.build());
|
||||
|
||||
entity.setReviewStatus(10);
|
||||
entity.setUploadFileName(uploadFileName);
|
||||
entity.setPdfConvert(pdfConvert);
|
||||
entity.setPdfFileName(pdfFileName);
|
||||
if (entity.getRegUser() == null) {
|
||||
entity.setRegUser(userId);
|
||||
entity.setRegDt(now);
|
||||
} else {
|
||||
entity.setModUser(userId);
|
||||
entity.setModDt(now);
|
||||
}
|
||||
|
||||
return PerformanceReviewDto.from(performanceReviewRepository.save(entity));
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_FILE_SAVE_FAILED", "평가/모니터링 파일 저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public PerformanceReviewDto getReviewFile(Integer performanceId, Integer reviewType, String userId) {
|
||||
return PerformanceReviewDto.from(getReviewEntity(performanceId, reviewType, userId));
|
||||
}
|
||||
|
||||
public PathResource getOriginalFileResource(Integer performanceId, Integer reviewType, String userId) {
|
||||
TPerformanceReviewEntity entity = getReviewEntity(performanceId, reviewType, userId);
|
||||
return toResource(reviewDir(performanceId, reviewType).resolve(entity.getUploadFileName()));
|
||||
}
|
||||
|
||||
public String getOriginalFileName(Integer performanceId, Integer reviewType, String userId) {
|
||||
return removeTimestampPrefix(getReviewEntity(performanceId, reviewType, userId).getUploadFileName());
|
||||
}
|
||||
|
||||
public PathResource getPdfOrOriginalFileResource(Integer performanceId, Integer reviewType, String userId) {
|
||||
TPerformanceReviewEntity entity = getReviewEntity(performanceId, reviewType, userId);
|
||||
String fileName = StringUtil.isNullOrBlank(entity.getPdfFileName())
|
||||
? entity.getUploadFileName()
|
||||
: entity.getPdfFileName();
|
||||
return toResource(reviewDir(performanceId, reviewType).resolve(fileName));
|
||||
}
|
||||
|
||||
public String getPdfOrOriginalFileName(Integer performanceId, Integer reviewType, String userId) {
|
||||
TPerformanceReviewEntity entity = getReviewEntity(performanceId, reviewType, userId);
|
||||
String fileName = StringUtil.isNullOrBlank(entity.getPdfFileName())
|
||||
? entity.getUploadFileName()
|
||||
: entity.getPdfFileName();
|
||||
return removeTimestampPrefix(fileName);
|
||||
}
|
||||
|
||||
private TPerformanceReviewEntity getReviewEntity(Integer performanceId, Integer reviewType, String userId) {
|
||||
return performanceReviewRepository.findByIdPerformanceIdAndIdReviewTypeAndIdRegUser(
|
||||
performanceId,
|
||||
reviewType,
|
||||
userId
|
||||
)
|
||||
.orElseThrow(() -> BusinessException.notFound("REVIEW_FILE_NOT_FOUND", "평가/모니터링 파일이 없습니다.")
|
||||
.with("performanceId", performanceId)
|
||||
.with("reviewType", reviewType)
|
||||
.with("userId", userId));
|
||||
}
|
||||
|
||||
private PathResource toResource(Path path) {
|
||||
Path normalized = path.toAbsolutePath().normalize();
|
||||
if (!Files.exists(normalized)) {
|
||||
throw BusinessException.notFound("FILE_NOT_FOUND", "파일이 없습니다.");
|
||||
}
|
||||
return new PathResource(normalized);
|
||||
}
|
||||
|
||||
private Path reviewDir(Integer performanceId, Integer reviewType) {
|
||||
return getBaseDir()
|
||||
.resolve(String.valueOf(performanceId))
|
||||
.resolve(String.valueOf(reviewType))
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
private String convertToPdfIfPossible(Path source, Path dir) {
|
||||
String extension = extractExtension(source.getFileName().toString()).toLowerCase();
|
||||
Set<String> targets = new HashSet<>(Set.of(".docx", ".hwpx", ".pptx", ".xlsx"));
|
||||
if (!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 String removeTimestampPrefix(String fileName) {
|
||||
if (StringUtil.isNullOrBlank(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
return fileName.replaceFirst("^\\d{4}-\\d{2}-\\d{2}_\\d{6}_", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.kri.gwcf.review.back.service;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.gwcf.review.back.config.FileStorageProperties;
|
||||
import com.kri.gwcf.review.back.service.file.AbstractFileService;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.io.PathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ReviewTemplateService extends AbstractFileService {
|
||||
|
||||
private final FileStorageProperties fileStorageProperties;
|
||||
|
||||
@Override
|
||||
protected Path getBaseDir() {
|
||||
return Path.of(fileStorageProperties.getReviewTemplateBaseDir())
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
public String uploadReviewTemplate(Integer reviewType, MultipartFile file) {
|
||||
validateReviewTemplateType(reviewType);
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
|
||||
}
|
||||
|
||||
String fileName = sanitizeFileName(file.getOriginalFilename());
|
||||
Path dir = templateDir(reviewType);
|
||||
|
||||
try {
|
||||
deleteExistingFiles(dir);
|
||||
saveFile(dir, file, fileName);
|
||||
return fileName;
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_TEMPLATE_SAVE_FAILED", "평가양식 파일 저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public PathResource getReviewTemplateResource(Integer reviewType) {
|
||||
Path file = findReviewTemplateFile(reviewType);
|
||||
return new PathResource(file);
|
||||
}
|
||||
|
||||
public String getReviewTemplateFileName(Integer reviewType) {
|
||||
return findReviewTemplateFile(reviewType).getFileName().toString();
|
||||
}
|
||||
|
||||
private Path findReviewTemplateFile(Integer reviewType) {
|
||||
validateReviewTemplateType(reviewType);
|
||||
Path dir = templateDir(reviewType);
|
||||
if (!Files.isDirectory(dir)) {
|
||||
throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
||||
.with("reviewType", reviewType);
|
||||
}
|
||||
|
||||
try (var files = Files.list(dir)) {
|
||||
return files
|
||||
.filter(Files::isRegularFile)
|
||||
.sorted(Comparator.comparing(path -> path.getFileName().toString()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
|
||||
.with("reviewType", reviewType));
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("REVIEW_TEMPLATE_READ_FAILED", "평가양식 파일 조회 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteExistingFiles(Path dir) throws IOException {
|
||||
if (!Files.isDirectory(dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try (var files = Files.list(dir)) {
|
||||
for (Path file : files.filter(Files::isRegularFile).toList()) {
|
||||
Files.deleteIfExists(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Path templateDir(Integer reviewType) {
|
||||
return getBaseDir()
|
||||
.resolve(String.valueOf(reviewType))
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
private void validateReviewTemplateType(Integer reviewType) {
|
||||
if (!Integer.valueOf(1).equals(reviewType) && !Integer.valueOf(3).equals(reviewType)) {
|
||||
throw BusinessException.badRequest("INVALID_REVIEW_TEMPLATE_TYPE", "유효하지 않은 평가양식 타입입니다.")
|
||||
.with("reviewType", reviewType);
|
||||
}
|
||||
}
|
||||
|
||||
private String sanitizeFileName(String originalFileName) {
|
||||
if (StringUtil.isNullOrBlank(originalFileName)) {
|
||||
return "review-template";
|
||||
}
|
||||
|
||||
return Path.of(originalFileName).getFileName().toString();
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,9 @@ import com.kri.gwcf.review.back.dto.common.CodeDto;
|
||||
import com.kri.gwcf.review.back.dto.common.DataVerificationDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelErrorDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.MonitoringUserUploadDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.UserUploadBaseDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.WrittenUserUploadDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.user.MonitoringUserUploadDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.user.UserUploadBaseDto;
|
||||
import com.kri.gwcf.review.back.dto.excel.user.WrittenUserUploadDto;
|
||||
import com.kri.gwcf.review.back.dto.user.UserCompactDto;
|
||||
import com.kri.gwcf.review.back.dto.user.UserFullDto;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TUserDetailEntity;
|
||||
@@ -28,10 +28,12 @@ import com.kri.gwcf.review.back.persistence.repository.UserRepository;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -99,6 +101,11 @@ public class UserService {
|
||||
return exportUserTemplate(userRole, getUserUploadClass(userRole));
|
||||
}
|
||||
|
||||
public byte[] exportUser(Integer userRole, String[] userIds) {
|
||||
validateUserRole(userRole);
|
||||
return exportUser(userRole, getUserUploadClass(userRole), userIds);
|
||||
}
|
||||
|
||||
private Class<? extends UserUploadBaseDto> getUserUploadClass(Integer userRole) {
|
||||
if (Objects.equals(userRole, MONITORING_USER_ROLE)) {
|
||||
return MonitoringUserUploadDto.class;
|
||||
@@ -132,6 +139,77 @@ public class UserService {
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends UserUploadBaseDto> byte[] exportUser(Integer userRole, Class<T> clazz, String[] userIds) {
|
||||
Set<String> selectedUserIds = userIds == null
|
||||
? Collections.emptySet()
|
||||
: Arrays.stream(userIds).collect(Collectors.toSet());
|
||||
|
||||
List<UserFullDto> userList = getUserList(userRole).stream()
|
||||
.filter(user -> selectedUserIds.contains(user.getUserId()))
|
||||
.toList();
|
||||
List<T> exportRows = userList.stream()
|
||||
.map(user -> toUserUploadRow(clazz, user))
|
||||
.toList();
|
||||
|
||||
List<CodeDto> genreList = codeService.findByCodeGroup("genre");
|
||||
List<CodeDto> areaList = codeService.findByCodeGroup("area");
|
||||
List<CodeDto> genderList = codeService.findByCodeGroup("gender");
|
||||
List<CodeDto> hasCarList = codeService.findByCodeGroup("has_car");
|
||||
|
||||
try (Workbook workbook =
|
||||
ExcelMapper.writeToWorkbook(exportRows, clazz);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
|
||||
if (Objects.equals(userRole, MONITORING_USER_ROLE)) {
|
||||
appendCodeSheet(workbook, areaList, "지역");
|
||||
appendCodeSheet(workbook, genderList, "성별");
|
||||
appendCodeSheet(workbook, hasCarList, "자차유무");
|
||||
} else {
|
||||
appendCodeSheet(workbook, genreList, "장르");
|
||||
}
|
||||
|
||||
workbook.write(out);
|
||||
return out.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("사용자 엑셀 생성 중 오류");
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends UserUploadBaseDto> T toUserUploadRow(Class<T> clazz, UserFullDto user) {
|
||||
if (clazz == MonitoringUserUploadDto.class) {
|
||||
return clazz.cast(MonitoringUserUploadDto.builder()
|
||||
.userId(user.getUserId())
|
||||
.userPw(user.getUserPw())
|
||||
.userName(user.getUserName())
|
||||
.userArea(getUserDetailValue(user, "userArea"))
|
||||
.userGender(getUserDetailValue(user, "userGender"))
|
||||
.userAge(getUserDetailValue(user, "userAge"))
|
||||
.userTel(getUserDetailValue(user, "userTel"))
|
||||
.userEmail(getUserDetailValue(user, "userEmail"))
|
||||
.userHasCar(getUserDetailValue(user, "userHasCar"))
|
||||
.memo(user.getMemo())
|
||||
.build());
|
||||
}
|
||||
|
||||
if (clazz == WrittenUserUploadDto.class) {
|
||||
return clazz.cast(WrittenUserUploadDto.builder()
|
||||
.userId(user.getUserId())
|
||||
.userPw(user.getUserPw())
|
||||
.userName(user.getUserName())
|
||||
.userGenre(getUserDetailValue(user, "userGenre"))
|
||||
.userTel(getUserDetailValue(user, "userTel"))
|
||||
.userEmail(getUserDetailValue(user, "userEmail"))
|
||||
.memo(user.getMemo())
|
||||
.build());
|
||||
}
|
||||
|
||||
throw BusinessException.internalError("지원하지 않는 사용자 엑셀 형식입니다.");
|
||||
}
|
||||
|
||||
private String getUserDetailValue(UserFullDto user, String key) {
|
||||
return getUserDetail(user).get(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private <T extends UserUploadBaseDto> List<T> readUserUploadRows(
|
||||
|
||||
@@ -1,19 +1,43 @@
|
||||
package com.kri.gwcf.review.back.service;
|
||||
|
||||
import com.kri.common.feature.util.StringUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.gwcf.review.back.config.FileStorageProperties;
|
||||
import com.kri.gwcf.review.back.dto.monitoring.MonitoringGpsRequestDto;
|
||||
import com.kri.gwcf.review.back.dto.performance.PerformanceMonitoringVisitDto;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TPerformanceMonitoringVisitEntity;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringVisitRepository;
|
||||
import com.kri.gwcf.review.back.service.file.AbstractFileService;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VisitService {
|
||||
public class VisitService extends AbstractFileService {
|
||||
|
||||
private final PerformanceMonitoringVisitRepository performanceMonitoringVisitRepository;
|
||||
private final FileStorageProperties fileStorageProperties;
|
||||
private final ReviewService reviewService;
|
||||
|
||||
@Override
|
||||
protected Path getBaseDir() {
|
||||
return Path.of(fileStorageProperties.getVisitBaseDir())
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
public boolean hasVisitWithUser(String userId) {
|
||||
return performanceMonitoringVisitRepository.existsByRegUser(userId);
|
||||
@@ -30,4 +54,151 @@ public class VisitService {
|
||||
Collectors.mapping(PerformanceMonitoringVisitDto::from, Collectors.toList())
|
||||
));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceMonitoringVisitDto saveDeparture(
|
||||
Integer performanceId,
|
||||
MonitoringGpsRequestDto gps,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
//validateGps(gps);
|
||||
TPerformanceMonitoringVisitEntity entity = saveVisit(
|
||||
performanceId,
|
||||
2,
|
||||
"",
|
||||
gps,
|
||||
regUser,
|
||||
regDt
|
||||
);
|
||||
reviewService.saveMonitoringReviewStatus(performanceId, 2, regUser, regDt);
|
||||
return PerformanceMonitoringVisitDto.from(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public PerformanceMonitoringVisitDto saveArrival(
|
||||
Integer performanceId,
|
||||
MonitoringGpsRequestDto gps,
|
||||
List<MultipartFile> files,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
//validateGps(gps);
|
||||
String evidenceImg = String.join("|", saveEvidenceFiles(performanceId, regUser, files));
|
||||
|
||||
TPerformanceMonitoringVisitEntity entity = saveVisit(
|
||||
performanceId,
|
||||
3,
|
||||
evidenceImg,
|
||||
gps,
|
||||
regUser,
|
||||
regDt
|
||||
);
|
||||
reviewService.saveMonitoringReviewStatus(performanceId, 3, regUser, regDt);
|
||||
return PerformanceMonitoringVisitDto.from(entity);
|
||||
}
|
||||
|
||||
public List<PerformanceMonitoringVisitDto> findEvidence(Integer performanceId, String userId) {
|
||||
return performanceMonitoringVisitRepository.findByPerformanceIdAndRegUser(performanceId, userId)
|
||||
.stream()
|
||||
.map(PerformanceMonitoringVisitDto::from)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public byte[] downloadEvidenceZip(Integer performanceId, String userId) {
|
||||
List<String> fileNames = performanceMonitoringVisitRepository
|
||||
.findByPerformanceIdAndRegUser(performanceId, userId)
|
||||
.stream()
|
||||
.flatMap(visit -> List.of(visit.getEvidenceImg().split("\\|")).stream())
|
||||
.filter(StringUtil::hasText)
|
||||
.toList();
|
||||
|
||||
try (
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(out)
|
||||
) {
|
||||
Path dir = evidenceDir(performanceId, userId);
|
||||
for (String fileName : fileNames) {
|
||||
Path file = dir.resolve(fileName).normalize();
|
||||
if (!file.startsWith(dir) || !Files.exists(file)) {
|
||||
continue;
|
||||
}
|
||||
zip.putNextEntry(new ZipEntry(fileName));
|
||||
Files.copy(file, zip);
|
||||
zip.closeEntry();
|
||||
}
|
||||
zip.finish();
|
||||
return out.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("EVIDENCE_ZIP_FAILED", "증빙 사진 ZIP 생성 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private TPerformanceMonitoringVisitEntity saveVisit(
|
||||
Integer performanceId,
|
||||
Integer status,
|
||||
String evidenceImg,
|
||||
MonitoringGpsRequestDto gps,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
TPerformanceMonitoringVisitEntity entity = TPerformanceMonitoringVisitEntity.builder()
|
||||
.performanceId(performanceId)
|
||||
.monitoringVisitStatus(status)
|
||||
.evidenceImg(evidenceImg)
|
||||
.gpsLatitude(gps.getGpsLatitude())
|
||||
.gpsLongitude(gps.getGpsLongitude())
|
||||
.gpsAccuracyM(gps.getGpsAccuracyM())
|
||||
.gpsRaw(gps.getGpsRaw())
|
||||
.regUser(regUser)
|
||||
.regDt(regDt)
|
||||
.build();
|
||||
|
||||
return performanceMonitoringVisitRepository.save(entity);
|
||||
}
|
||||
|
||||
private List<String> saveEvidenceFiles(
|
||||
Integer performanceId,
|
||||
String userId,
|
||||
List<MultipartFile> files
|
||||
) {
|
||||
if (files == null || files.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
try {
|
||||
Path dir = evidenceDir(performanceId, userId);
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
for (MultipartFile file : files) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String fileName = saveFile(dir, file);
|
||||
fileNames.add(fileName);
|
||||
}
|
||||
return fileNames;
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("EVIDENCE_SAVE_FAILED", "증빙 사진 저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private Path evidenceDir(Integer performanceId, String userId) {
|
||||
return getBaseDir()
|
||||
.resolve(String.valueOf(performanceId))
|
||||
.resolve(userId)
|
||||
.toAbsolutePath()
|
||||
.normalize();
|
||||
}
|
||||
|
||||
private void validateGps(MonitoringGpsRequestDto gps) {
|
||||
// GPS 필수 정책을 해제해야 하면 아래 if 블록만 주석 처리.
|
||||
if (gps == null
|
||||
|| gps.getGpsLatitude() == null
|
||||
|| gps.getGpsLongitude() == null
|
||||
|| gps.getGpsAccuracyM() == null
|
||||
|| gps.getGpsRaw() == null
|
||||
|| gps.getGpsRaw().isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_GPS_INFO", "GPS 정보가 없습니다.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.kri.gwcf.review.back.dto.user.UserFullDto;
|
||||
import com.kri.gwcf.review.back.persistence.entity.TSysEventLogEntity;
|
||||
import com.kri.gwcf.review.back.persistence.repository.SysEventLogRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -118,15 +119,183 @@ public class SystemEventLogService {
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignConfirmLog(String userId, LocalDateTime regDt, String clientIp) {
|
||||
public void writeAssignConfirmLog(String userId, LocalDateTime regDt, String clientIp, String performanceId) {
|
||||
writeSystemLog(
|
||||
SystemEventType.ASSIGN_PERFORMANCE_CONFIRM,
|
||||
"Assign Confirm",
|
||||
userId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"userId",
|
||||
userId
|
||||
"performanceId",
|
||||
performanceId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeVisitStartLog(String regId, LocalDateTime regDt, String clientIp, Integer performanceId) {
|
||||
writeSystemLog(
|
||||
SystemEventType.VISIT_START,
|
||||
"Visit Start",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"performanceId",
|
||||
performanceId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeVisitEndLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId,
|
||||
Integer evidenceFileCount
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.VISIT_END,
|
||||
"Visit End",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"evidenceFileCount", evidenceFileCount
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void writeStartWrittenReviewLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId
|
||||
) {
|
||||
writeSystemLog(
|
||||
SystemEventType.START_WRITTEN_REVIEW,
|
||||
"Start Written Review",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"performanceId",
|
||||
performanceId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeEndWrittenReviewLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId
|
||||
) {
|
||||
writeSystemLog(
|
||||
SystemEventType.END_WRITTEN_REVIEW,
|
||||
"End Written Review",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
"performanceId",
|
||||
performanceId
|
||||
);
|
||||
}
|
||||
|
||||
public void writeUploadReviewFileLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId,
|
||||
Integer reviewType,
|
||||
UploadContentDto content
|
||||
) {
|
||||
SystemEventType eventType = Integer.valueOf(1).equals(reviewType)
|
||||
? SystemEventType.UPLOAD_MONITORING_REVIEW
|
||||
: SystemEventType.UPLOAD_LOCAL_GOV_REVIEW;
|
||||
|
||||
saveLog(
|
||||
eventType,
|
||||
"Upload Review File",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"reviewType", reviewType,
|
||||
"file", content
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignPerformanceRequestLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId,
|
||||
List<String> assignUsers
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.ASSIGN_PERFORMANCE_REQUEST,
|
||||
"Assign Performance Request",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"assignUsers", assignUsers
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignConfirmByAdminLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId,
|
||||
String assignUser
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.ASSIGN_PERFORMANCE_CONFIRM,
|
||||
"Assign Confirm",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"assignUser", assignUser
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void writeUploadWrittenAssignLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
UploadContentDto content
|
||||
) {
|
||||
writeSystemLog(
|
||||
SystemEventType.UPLOAD_WRITTEN_ASSIGN,
|
||||
"Upload Written Assign",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
content
|
||||
);
|
||||
}
|
||||
|
||||
public void writeAssignCancelLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId,
|
||||
String assignUser
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.ASSIGN_PERFORMANCE_REJECT,
|
||||
"Assign Cancel",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"assignUser", assignUser
|
||||
)
|
||||
);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Optional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -54,11 +56,20 @@ public abstract class AbstractFileService {
|
||||
String ext = extractExtension(original);
|
||||
|
||||
String timestamp = DateTimeUtil.nowKstLocalDateTime()
|
||||
.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
||||
.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
||||
|
||||
return prefix + "_" + timestamp + "_" + baseName + ext;
|
||||
}
|
||||
|
||||
protected String buildFileNameWithTime(MultipartFile file, LocalDateTime now) {
|
||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
||||
String baseName = extractBaseName(original);
|
||||
String ext = extractExtension(original);
|
||||
String timestamp = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd_hhmmss"));
|
||||
|
||||
return timestamp + "_" + baseName + ext;
|
||||
}
|
||||
|
||||
protected Path createDirectories(Path dir) throws IOException {
|
||||
return Files.createDirectories(dir.toAbsolutePath().normalize());
|
||||
}
|
||||
@@ -92,6 +103,7 @@ public abstract class AbstractFileService {
|
||||
throw BusinessException.internalError("WRONG_DIRECTORY","잘못된 파일 경로입니다.");
|
||||
}
|
||||
|
||||
Files.deleteIfExists(target);
|
||||
file.transferTo(target.toFile());
|
||||
}
|
||||
|
||||
|
||||
@@ -4,4 +4,11 @@ spring:
|
||||
url: jdbc:mysql://db-md87m.vpc-cdb.ntruss.com:3306/test_gwcf_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
|
||||
username: prjct_gwcf
|
||||
password: gwcf#260608
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
kon:
|
||||
survey-type: TEST
|
||||
|
||||
kri:
|
||||
file:
|
||||
pdf-converter-command: /usr/bin/soffice
|
||||
|
||||
@@ -22,4 +22,11 @@ logging:
|
||||
org.hibernate.SQL: DEBUG
|
||||
#org.hibernate.orm.jdbc.bind: TRACE
|
||||
#org.hibernate.orm.jdbc.extract: TRACE
|
||||
org.hibernate.engine.jdbc.batch.internal: DEBUG
|
||||
org.hibernate.engine.jdbc.batch.internal: DEBUG
|
||||
|
||||
kon:
|
||||
survey-type: TEST
|
||||
|
||||
kri:
|
||||
file:
|
||||
pdf-converter-command: "C:/Program Files/LibreOffice/program/soffice.exe"
|
||||
|
||||
@@ -4,4 +4,11 @@ spring:
|
||||
url: jdbc:mysql://db-md87m.vpc-cdb.ntruss.com:3306/prjct_gwcf_review?characterEncoding=UTF-8&rewriteBatchedStatements=true
|
||||
username: prjct_gwcf
|
||||
password: gwcf#260608
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
kon:
|
||||
survey-type: LIST
|
||||
|
||||
kri:
|
||||
file:
|
||||
pdf-converter-command: /usr/bin/soffice
|
||||
|
||||
@@ -52,8 +52,10 @@ kri:
|
||||
- /ping
|
||||
- /api/v1/auth/login
|
||||
- /api/v1/admin-cache/**
|
||||
- /api/v1/assign/confirm/*
|
||||
- /api/v1/assign/confirm/*/*
|
||||
- /api/v1/performance/list/compact
|
||||
- /api/v1/review/start/**
|
||||
- /api/v1/review/end/**
|
||||
|
||||
swagger:
|
||||
enabled: true
|
||||
@@ -67,6 +69,8 @@ kri:
|
||||
file:
|
||||
visit-base-dir: ./upload-file/visit
|
||||
review-base-dir: ./upload-file/review
|
||||
review-template-base-dir: ./upload-file/review-template
|
||||
pdf-converter-command: soffice
|
||||
|
||||
web:
|
||||
enabled: true # 공통 Web 구성 사용 여부 (기본 true)
|
||||
|
||||
42
src/main/resources/mybatis/mapper/kon/KonMapper.xml
Normal file
42
src/main/resources/mybatis/mapper/kon/KonMapper.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.kri.gwcf.review.back.persistence.mapper.kon.KonMapper">
|
||||
|
||||
<sql id="BaseDataSelect">
|
||||
SELECT DISTINCT
|
||||
JSON_VALUE(DJ.[VALUE], '$.SC') AS IDKEY,
|
||||
DV.[value] AS performance_id
|
||||
FROM [DATA] DA WITH(NOLOCK)
|
||||
CROSS APPLY OPENJSON([DATJSON]) DJ
|
||||
CROSS APPLY OPENJSON(DJ.[value]) DV
|
||||
WHERE PKEY = '2605013_B'
|
||||
AND [Status] = 10
|
||||
AND JSON_VALUE(DJ.[VALUE], '$.SC') IS NOT NULL
|
||||
AND JSON_VALUE(DJ.[VALUE], '$.SC') != ''
|
||||
AND DV.[KEY] LIKE 'Q1%'
|
||||
AND [SURVEY_TYPE] = #{surveyType}
|
||||
</sql>
|
||||
|
||||
<select id="findPerformanceApplyCount" resultType="PerformanceApplyCountDto">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
)
|
||||
SELECT performance_id, COUNT(1) AS apply_cnt
|
||||
FROM Base
|
||||
GROUP BY performance_id
|
||||
</select>
|
||||
|
||||
<select id="findPerformanceApplyUser" resultType="PerformanceApplyUserDto">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
)
|
||||
SELECT performance_id, IDKEY AS user_id
|
||||
FROM Base
|
||||
WHERE performance_id = #{performanceId}
|
||||
GROUP BY performance_id, IDKEY
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user