Skip to content

Commit

Permalink
Merge pull request #280 from kookmin-sw/BugFix/279
Browse files Browse the repository at this point in the history
fix :  스탭돌아가는 버그수정 및 알고리즘 수정#279
  • Loading branch information
ancy0 authored May 26, 2024
2 parents 486408a + 775333d commit 09114bc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public interface SearchHistoryRepository extends JpaRepository<SearchHistoryEnti

SearchHistoryEntity findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtAsc(Long missingPeopleEntityId, Step step);

SearchHistoryEntity findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtDesc(Long missingPeopleEntityId, Step step);

SearchHistoryEntity findFirstByMissingPeopleEntityIdOrderByCreatedAtAsc(Long missingPeopleEntityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ public class DetectService {
//수정 완료.
public FirstDetectionDataDto callFirstDetectAPI(Long id) throws CustomException {
try {

//과정1 : 실종자 id가 db에 있는지 확인합니다. (이건 수정해야될듯 (불필요한 db요청이 너무 많아지는거 같기도 함) todo : 리팩토링. 현재 너무 과도하게 데이터를 불러오고있음.
MissingPeopleEntity missingPeople = missingPeopleRepository.findById(id)
.orElseThrow(() -> new NoSuchElementException("Missing person not found with ID: " + id));
//해당 Id의 가장 최신 탐색기록을 가져와 요청 보낼 dto생성
SearchHistoryEntity searchHistoryEntity = searchHistoryRepository.findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtAsc(id, Step.fromValue("first"));
SearchHistoryEntity searchHistoryEntity = searchHistoryRepository.findFirstByMissingPeopleEntityIdAndStepOrderByCreatedAtDesc(id, Step.fromValue("first"));
//과정2 : ai server요청에 쓸 dto를생성합니다
FirstDetectionRequestDto firstDetectionRequestDto = FirstDetectionRequestDto.fromEntity(missingPeople, searchHistoryEntity);
firstDetectionRequestDto.setCctvId(cctvService.findCCTVsNearbyLocationWithinDistance(searchHistoryEntity.getLongitude(), searchHistoryEntity.getLatitude(), searchHistoryEntity.getSearchRadius()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public Long createSearchHistory(SearchRequestDto searchRequestDto, Long missingP
SearchHistoryEntity searchHistoryEntity = searchRequestDto.toSearchHistoryEntity();
searchHistoryEntity.setMissingPeopleEntity(missingPeopleEntity);
searchHistoryEntity.setStep(step);
//실종자 step을 First로 설정
missingPeopleEntity.setStep(step);
return searchHistoryRepository.save(searchHistoryEntity).getId();
}

Expand Down

0 comments on commit 09114bc

Please sign in to comment.