Skip to content

Commit a40a60f

Browse files
authored
Merge pull request #290 from DevKor-github/fix/route
Fix: 경로 오류 수정
2 parents 965acac + fdce007 commit a40a60f

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/main/java/devkor/com/teamcback/domain/place/entity/Place.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public class Place extends BaseEntity {
9696
@JoinColumn(name = "building_id")
9797
private Building building;
9898

99-
@OneToOne(fetch = FetchType.LAZY)
99+
@OneToOne
100100
@JoinColumn(name = "node_id")
101101
private Node node;
102102

src/main/java/devkor/com/teamcback/domain/routes/service/RouteService.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public List<GetRouteRes> findRoute(LocationType startType, Long startId, Double
6666
if (conditions == null) {
6767
conditions = new ArrayList<>();
6868
}
69-
conditions.add(OPERATING);
69+
// conditions.add(OPERATING);
7070
Node startNode = getNodeByType(startType, startId, startLat, startLong);
7171
Node endNode = getNodeByType(endType, endId, endLat, endLong);
7272

@@ -273,7 +273,6 @@ private GetGraphRes getGraph(HashSet<Building> buildingList, Node startNode, Nod
273273
Map<Long, List<Edge>> graphEdge = new HashMap<>();
274274

275275
// 조건에 따른 노드 검색
276-
277276
for (Building building : buildingList) {
278277
if (conditions.contains(OPERATING)) {
279278
if (!building.isOperating()) continue;
@@ -395,9 +394,10 @@ private DijkstraRes dijkstra(GetGraphRes graphRes, Node startNode, Node endNode)
395394
//path 생성
396395
List<Node> path = new ArrayList<>();
397396
Long finalDistance = distances.get(endNode.getId());
398-
for (Long at = endNode.getId(); at != null; at = previousNodes.get(at)) {
397+
for (Long at = endNode.getId(); at != null;) {
399398
Node node = nodeRepository.findById(at).orElseThrow(() -> new GlobalException(NOT_FOUND_ROUTE));
400399
path.add(node);
400+
at = previousNodes.get(at);
401401
}
402402
Collections.reverse(path);
403403

@@ -500,8 +500,12 @@ private List<List<Node>> cutRoute(List<Node> route) {
500500
else if (!Objects.equals(thisNode.getFloor(), nextNode.getFloor())) {
501501
partialRoute.add(thisNode);
502502

503+
// 층 생략 여부 확인
504+
boolean isFloorSkipped = false;
505+
503506
// 계단/엘리베이터를 통한 연속적인 층 이동을 감지하여 중간 층을 생략
504-
while (!Objects.equals(thisNode.getFloor(), nextNode.getFloor()) && thisNode.getBuilding().equals(nextNode.getBuilding())) {
507+
while (!Objects.equals(thisNode.getFloor(), nextNode.getFloor()) && thisNode.getBuilding().equals(nextNode.getBuilding()) && thisNode.getBuilding().getId() != OUTDOOR_ID) {
508+
isFloorSkipped = true;
505509
count++;
506510
thisNode = route.get(count);
507511
nextNode = route.get(count+1);
@@ -510,7 +514,7 @@ else if (!Objects.equals(thisNode.getFloor(), nextNode.getFloor())) {
510514
partialRoute.clear();
511515

512516
// 끝 층의 시작 노드를 새 경로로 추가
513-
count--;
517+
if(isFloorSkipped) count--;
514518
} else {
515519
partialRoute.add(thisNode);
516520
}

src/test/java/devkor/com/teamcback/integration/RouteServiceIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
2323
@TestInstance(Lifecycle.PER_METHOD)
2424
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
25-
@ActiveProfiles("test")
25+
//@ActiveProfiles("test")
2626
public class RouteServiceIntegrationTest extends BaseMvcTest {
2727
@Autowired
2828
RouteService routeService;

0 commit comments

Comments
 (0)