260707_01_ENH: 출발 도착 삭제 가능기능 추가 #5
@@ -30,7 +30,7 @@ repositories {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation "com.kri.common:starter:beta.1.1.29"
|
||||
implementation "com.kri.common:starter:beta.1.1.33"
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
|
||||
@@ -11,6 +11,14 @@ public final class GwcfConstant {
|
||||
public static final Integer MONITORING_USER_ROLE = 9003;
|
||||
public static final Short REJECT_ASSIGN_ORDER = 9999;
|
||||
|
||||
public static final Integer MONITORING_REVIEW_TYPE = 1;
|
||||
public static final Integer MONITORING_VISIT_DEPARTURE_STATUS = 2;
|
||||
public static final Integer MONITORING_VISIT_ARRIVAL_STATUS = 3;
|
||||
|
||||
public static final List<Integer> REVIEW_TYPE = List.of(1, 3);
|
||||
public static final List<Integer> REVIEW_CLASSIFICATION = List.of(1, 5, 99);
|
||||
public static final List<Integer> MONITORING_VISIT_RESETTABLE_REVIEW_STATUS = List.of(
|
||||
MONITORING_VISIT_DEPARTURE_STATUS,
|
||||
MONITORING_VISIT_ARRIVAL_STATUS
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public enum SystemEventType implements CodeEnum<Short> {
|
||||
|
||||
VISIT_START((short) 2011), //모니터링 출발
|
||||
VISIT_END((short) 2012), //모니터링 도착
|
||||
VISIT_RESET((short) 2099), //모니터링 출발.도착 초기화
|
||||
|
||||
UPLOAD_MONITORING_REVIEW((short) 2041), //모니터링 결과보고서 업로드
|
||||
UPLOAD_LOCAL_GOV_REVIEW((short) 2042), //지자체 결과보고서 업로드
|
||||
|
||||
@@ -16,6 +16,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -79,6 +80,25 @@ public class MonitoringVisitController {
|
||||
return visitService.findEvidence(performanceId, userId);
|
||||
}
|
||||
|
||||
@Operation(summary = "모니터링 방문 초기화")
|
||||
@DeleteMapping("/reset/{performanceId}/{userId}")
|
||||
public void reset(
|
||||
@PathVariable Integer performanceId,
|
||||
@PathVariable String userId,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
visitService.reset(performanceId, userId);
|
||||
|
||||
systemEventLogService.writeVisitResetLog(
|
||||
ctx.getUserId(),
|
||||
now,
|
||||
ctx.getClientIp(),
|
||||
performanceId,
|
||||
userId
|
||||
);
|
||||
}
|
||||
|
||||
@Operation(summary = "증빙 사진 ZIP 다운로드")
|
||||
@GetMapping("/evidence/zip/{performanceId}/{userId}")
|
||||
public ResponseEntity<byte[]> downloadEvidenceZip(
|
||||
|
||||
@@ -16,4 +16,9 @@ public interface PerformanceMonitoringVisitRepository extends JpaRepository<TPer
|
||||
Integer performanceId,
|
||||
String regUser
|
||||
);
|
||||
|
||||
void deleteByPerformanceIdAndRegUser(
|
||||
Integer performanceId,
|
||||
String regUser
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,13 @@ public interface PerformanceReviewRepository extends JpaRepository<TPerformanceR
|
||||
String regUser
|
||||
);
|
||||
|
||||
Optional<TPerformanceReviewEntity> findByIdPerformanceIdAndIdReviewTypeAndIdRegUserAndReviewStatusIn(
|
||||
Integer performanceId,
|
||||
Integer reviewType,
|
||||
String regUser,
|
||||
List<Integer> reviewStatuses
|
||||
);
|
||||
|
||||
boolean existsByIdPerformanceIdAndIdReviewTypeAndIdRegUser(
|
||||
Integer performanceId,
|
||||
Integer reviewType,
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
package com.kri.gwcf.review.back.service;
|
||||
|
||||
import static com.kri.gwcf.review.back.common.consts.GwcfConstant.MONITORING_REVIEW_TYPE;
|
||||
import static com.kri.gwcf.review.back.common.consts.GwcfConstant.MONITORING_VISIT_ARRIVAL_STATUS;
|
||||
import static com.kri.gwcf.review.back.common.consts.GwcfConstant.MONITORING_VISIT_DEPARTURE_STATUS;
|
||||
import static com.kri.gwcf.review.back.common.consts.GwcfConstant.MONITORING_VISIT_RESETTABLE_REVIEW_STATUS;
|
||||
|
||||
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.entity.TPerformanceReviewEntity;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceMonitoringVisitRepository;
|
||||
import com.kri.gwcf.review.back.persistence.repository.PerformanceReviewRepository;
|
||||
import com.kri.gwcf.review.back.service.file.AbstractFileService;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -29,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public class VisitService extends AbstractFileService {
|
||||
|
||||
private final PerformanceMonitoringVisitRepository performanceMonitoringVisitRepository;
|
||||
private final PerformanceReviewRepository performanceReviewRepository;
|
||||
private final FileStorageProperties fileStorageProperties;
|
||||
private final ReviewService reviewService;
|
||||
|
||||
@@ -65,13 +73,13 @@ public class VisitService extends AbstractFileService {
|
||||
//validateGps(gps);
|
||||
TPerformanceMonitoringVisitEntity entity = saveVisit(
|
||||
performanceId,
|
||||
2,
|
||||
MONITORING_VISIT_DEPARTURE_STATUS,
|
||||
"",
|
||||
gps,
|
||||
regUser,
|
||||
regDt
|
||||
);
|
||||
reviewService.saveMonitoringReviewStatus(performanceId, 2, regUser, regDt);
|
||||
reviewService.saveMonitoringReviewStatus(performanceId, MONITORING_VISIT_DEPARTURE_STATUS, regUser, regDt);
|
||||
return PerformanceMonitoringVisitDto.from(entity);
|
||||
}
|
||||
|
||||
@@ -88,16 +96,36 @@ public class VisitService extends AbstractFileService {
|
||||
|
||||
TPerformanceMonitoringVisitEntity entity = saveVisit(
|
||||
performanceId,
|
||||
3,
|
||||
MONITORING_VISIT_ARRIVAL_STATUS,
|
||||
evidenceImg,
|
||||
gps,
|
||||
regUser,
|
||||
regDt
|
||||
);
|
||||
reviewService.saveMonitoringReviewStatus(performanceId, 3, regUser, regDt);
|
||||
reviewService.saveMonitoringReviewStatus(performanceId, MONITORING_VISIT_ARRIVAL_STATUS, regUser, regDt);
|
||||
return PerformanceMonitoringVisitDto.from(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void reset(Integer performanceId, String userId) {
|
||||
TPerformanceReviewEntity review = performanceReviewRepository
|
||||
.findByIdPerformanceIdAndIdReviewTypeAndIdRegUserAndReviewStatusIn(
|
||||
performanceId,
|
||||
MONITORING_REVIEW_TYPE,
|
||||
userId,
|
||||
MONITORING_VISIT_RESETTABLE_REVIEW_STATUS
|
||||
)
|
||||
.orElseThrow(() -> BusinessException.badRequest(
|
||||
"MONITORING_VISIT_RESET_NOT_ALLOWED",
|
||||
"출발 또는 도착 상태의 모니터링 방문만 초기화할 수 있습니다."
|
||||
)
|
||||
.with("performanceId", performanceId)
|
||||
.with("userId", userId));
|
||||
|
||||
performanceMonitoringVisitRepository.deleteByPerformanceIdAndRegUser(performanceId, userId);
|
||||
performanceReviewRepository.delete(review);
|
||||
}
|
||||
|
||||
public List<PerformanceMonitoringVisitDto> findEvidence(Integer performanceId, String userId) {
|
||||
return performanceMonitoringVisitRepository.findByPerformanceIdAndRegUser(performanceId, userId)
|
||||
.stream()
|
||||
|
||||
@@ -175,6 +175,26 @@ public class SystemEventLogService {
|
||||
);
|
||||
}
|
||||
|
||||
public void writeVisitResetLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
String clientIp,
|
||||
Integer performanceId,
|
||||
String userId
|
||||
) {
|
||||
saveLog(
|
||||
SystemEventType.VISIT_RESET,
|
||||
"Visit Reset",
|
||||
regId,
|
||||
regDt,
|
||||
clientIp,
|
||||
Map.of(
|
||||
"performanceId", performanceId,
|
||||
"userId", userId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void writeStartWrittenReviewLog(
|
||||
String regId,
|
||||
LocalDateTime regDt,
|
||||
|
||||
Reference in New Issue
Block a user