package com.kamco.cd.kamcoback.gukyuin; import com.kamco.cd.kamcoback.config.api.ApiResponseDto; import com.kamco.cd.kamcoback.config.api.ApiResponseDto.ResponseObj; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectContDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChnDetectMastReqDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.ChngDetectMastSearchDto; import com.kamco.cd.kamcoback.gukyuin.dto.ChngDetectMastDto.LabelSendDto; import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.Basic; import com.kamco.cd.kamcoback.gukyuin.dto.DetectMastDto.DetectMastReq; import com.kamco.cd.kamcoback.gukyuin.dto.GukYuinDto.GukYuinLinkableRes; import com.kamco.cd.kamcoback.gukyuin.service.GukYuinApiService; import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiLabelJobService; import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiPnuJobService; import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiStatusJobService; import com.kamco.cd.kamcoback.scheduler.service.GukYuinApiStbltJobService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.time.LocalDate; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "국유in 연동 API", description = "국유in 연동 API") @RestController @RequiredArgsConstructor @RequestMapping("/api/gukyuin/") public class GukYuinApiController { private final GukYuinApiService gukYuinApiService; private final GukYuinApiPnuJobService gukYuinApiPnuJobService; private final GukYuinApiStatusJobService gukYuinApiStatusJobService; private final GukYuinApiLabelJobService gukYuinApiLabelJobService; private final GukYuinApiStbltJobService gukYuinApiStbltJobService; /** 탐지결과 등록 */ @Operation(summary = "탐지결과 등록", description = "탐지결과 등록") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = DetectMastReq.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/chn/mast/regist") public ApiResponseDto regist( @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { return ApiResponseDto.ok(gukYuinApiService.regist(chnDetectMastReq)); } @Operation(summary = "탐지결과 삭제", description = "탐지결과 삭제") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = ChnDetectMastReqDto.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/chn/mast/remove") public ApiResponseDto remove( @RequestBody @Valid ChngDetectMastDto.ChnDetectMastReqDto chnDetectMastReq) { return ApiResponseDto.ok(gukYuinApiService.remove(chnDetectMastReq)); } @Operation(summary = "탐지결과 등록목록 조회(년도,차수 조회)", description = "탐지결과 등록목록 조회") @GetMapping("/chn/mast") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto selectChangeDetectionList( @RequestParam(required = false) String cprsYr, @RequestParam(required = false) String crtrYr, @RequestParam(required = false) String chnDtctSno) { ChngDetectMastSearchDto searchDto = new ChngDetectMastSearchDto(); searchDto.setCprsYr(cprsYr); searchDto.setCrtrYr(crtrYr); searchDto.setChnDtctSno(chnDtctSno); return ApiResponseDto.ok(gukYuinApiService.listYearStage(searchDto)); } @Operation(summary = "탐지결과 등록목록 조회(회차uid)", description = "탐지결과 등록목록 조회") @GetMapping("/chn/mast/{chnDtctId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto selectChangeDetectionDtctIdList( @RequestParam(required = false) String chnDtctId) { return ApiResponseDto.ok(gukYuinApiService.listChnDtctId(chnDtctId)); } @Operation(summary = "탐지결과 등록목록 조회(1건 조회)", description = "탐지결과 등록목록 조회") @GetMapping("/chn/mast/list/{chnDtctMstId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto selectChangeDetectionDetail( @PathVariable String chnDtctMstId) { return ApiResponseDto.ok(gukYuinApiService.detail(chnDtctMstId)); } @Operation(summary = "국유in연동 가능여부 확인", description = "국유in연동 가능여부 확인") @GetMapping("/is-link/{uuid}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema( implementation = GukYuinLinkableRes.class, description = "TRUE:연동가능, FALSE:연동 불가능"))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto getIsLinkGukYuin( @Parameter(description = "uuid", example = "5799eb21-4780-48b0-a82e-e58dcbb8806b") @PathVariable UUID uuid) { return ApiResponseDto.ok(gukYuinApiService.getIsLinkGukYuin(uuid)); } @Operation(summary = "탐지객체 조회 (탐지객체)", description = "탐지객체 조회 (탐지객체)") @GetMapping("/chn/cont/{chnDtctId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto findChnContList( @PathVariable String chnDtctId, @RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize) { return ApiResponseDto.ok(gukYuinApiService.findChnContList(chnDtctId, pageIndex, pageSize)); } @Operation(summary = "탐지객체 조회 (탐지객체 1건 조회)", description = "탐지객체 조회 (탐지객체 1건 조회)") @GetMapping("/chn/cont/{chnDtctId}/objt/{chnDtctObjtId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto findChnPnuToContObject( @PathVariable String chnDtctId, @PathVariable String chnDtctObjtId, @RequestParam(defaultValue = "0") Integer pageIndex, @RequestParam(defaultValue = "10") Integer pageSize) { return ApiResponseDto.ok( gukYuinApiService.findChnPnuToContObject(chnDtctId, chnDtctObjtId, pageIndex, pageSize)); } @Operation(summary = "탐지객체 조회 (PNU에 해당하는 탐지객체)", description = "탐지객체 조회 (PNU에 해당하는 탐지객체)") @GetMapping("/chn/cont/{chnDtctId}/pnu/{pnu}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto findChnPnuToContList( @PathVariable String chnDtctId, @PathVariable String pnu) { return ApiResponseDto.ok(gukYuinApiService.findChnPnuToContList(chnDtctId, pnu)); } @Operation(summary = "탐지객체 조회 (탐지객체와 교차하는 PNU)", description = "탐지객체 조회 (탐지객체와 교차하는 PNU)") @GetMapping("/chn/pnu/{chnDtctId}/objt/{chnDtctObjtId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto findPnuObjMgmtList( @PathVariable String chnDtctId, @PathVariable String chnDtctObjtId) { return ApiResponseDto.ok(gukYuinApiService.findPnuObjMgmtList(chnDtctId, chnDtctObjtId)); } @Operation(summary = "라벨여부 수정", description = "라벨여부 수정") @ApiResponses( value = { @ApiResponse( responseCode = "201", description = "등록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = DetectMastReq.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) @PostMapping("/rlb/objt/{chnDtctObjtId}/lbl/{lblYn}") public ApiResponseDto updateChnDtctObjtLabelingYn( @PathVariable String chnDtctObjtId, @PathVariable String lblYn) { return ApiResponseDto.ok(gukYuinApiService.updateChnDtctObjtLabelingYn(chnDtctObjtId, lblYn)); } @Operation(summary = "국유in연동 등록", description = "국유in연동 등록") @PostMapping("/mast/reg/{uuid}") public ApiResponseDto connectChnMastRegist( @Parameter(description = "uuid", example = "7a593d0e-76a8-4b50-8978-9af1fbe871af") @PathVariable UUID uuid) { return ApiResponseDto.okObject(gukYuinApiService.connectChnMastRegist(uuid)); } @Operation(summary = "라벨 전송 완료 리스트", description = "라벨 전송 완료 리스트") @GetMapping("/label/send-list") public ApiResponseDto> findLabelingCompleteSendList( @Parameter(description = "어제 날짜", example = "2026-01-29") LocalDate yesterday) { return ApiResponseDto.ok(gukYuinApiService.findLabelingCompleteSendList(yesterday)); } @Operation(summary = "탐지객체 적합여부 조회 (리스트조회)", description = "탐지객체 적합여부 조회 (리스트조회)") @GetMapping("/rlb/dtct/{chnDtctId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto findRlbDtctList( @PathVariable String chnDtctId, @Parameter(description = "날짜(기본은 어제 날짜)") @RequestParam(defaultValue = "20260205") String yyyymmdd) { return ApiResponseDto.ok(gukYuinApiService.findRlbDtctList(chnDtctId, yyyymmdd)); } @Operation(summary = "탐지객체 적합여부 조회 (객체별 조회)", description = "탐지객체 적합여부 조회 (객체별 조회)") @GetMapping("/rlb/objt/{chnDtctObjtId}") @ApiResponses( value = { @ApiResponse( responseCode = "200", description = "목록 성공", content = @Content( mediaType = "application/json", schema = @Schema(implementation = Basic.class))), @ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content), @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content) }) public ApiResponseDto findRlbDtctObject( @PathVariable String chnDtctObjtId) { return ApiResponseDto.ok(gukYuinApiService.findRlbDtctObject(chnDtctObjtId)); } @Operation(summary = "job test pnu", description = "job test pnu") @GetMapping("/job-test/pnu") public ApiResponseDto findGukYuinContListPnuUpdate() { gukYuinApiPnuJobService.findGukYuinContListPnuUpdate(); return ApiResponseDto.ok(null); } @Operation(summary = "job test status", description = "job test status") @GetMapping("/job-test/status") public ApiResponseDto findGukYuinMastCompleteYn() { gukYuinApiStatusJobService.findGukYuinMastCompleteYn(); return ApiResponseDto.ok(null); } @Operation(summary = "job test label", description = "job test label") @GetMapping("/job-test/label") public ApiResponseDto findLabelingCompleteSend() { gukYuinApiLabelJobService.findLabelingCompleteSend(); return ApiResponseDto.ok(null); } @Operation(summary = "job test stblt", description = "job test stblt") @GetMapping("/job-test/stblt") public ApiResponseDto findGukYuinEligibleForSurvey() { gukYuinApiStbltJobService.findGukYuinEligibleForSurvey(); return ApiResponseDto.ok(null); } }