shjung пре 3 година
родитељ
комит
bedb7c691e

+ 82 - 0
src/main/java/com/its/api/op/controller/management/GisSearchController.java

@@ -0,0 +1,82 @@
+package com.its.api.op.controller.management;
+
+import com.its.api.op.model.dto.ifsc.TbIfscDto;
+import com.its.api.op.model.dto.link.TbLinkDto;
+import com.its.api.op.model.dto.node.TbNodeDto;
+import com.its.api.op.model.dto.road.TbRoadDto;
+import com.its.api.op.service.ifsc.TbIfscService;
+import com.its.api.op.service.link.TbLinkService;
+import com.its.api.op.service.node.TbNodeService;
+import com.its.api.op.service.road.TbRoadService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+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;
+
+import java.util.List;
+
+@Api(tags = "00.교통상황관리-0.메인-9.지도검색")
+@Validated
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/api/manage/gis/search")
+public class GisSearchController {
+
+    private final TbNodeService nodeService;
+    private final TbLinkService linkService;
+    private final TbIfscService ifscService;
+    private final TbRoadService roadService;
+
+    @ApiOperation(value = "노드검색(TB_NODE)", response = TbNodeDto.class)
+    @GetMapping(value = "/node/{filter}", produces = {"application/json; charset=utf8"})
+    public List<TbNodeDto> findNodeByFilter(
+            @ApiParam(name = "filter", value = "노드명/아이디", example = "교차로", required = false)
+            @PathVariable final String filter) {
+        return this.nodeService.findByFilter(filter);
+    }
+
+    @ApiOperation(value = "링크검색(TB_LINK)", response = TbLinkDto.class)
+    @GetMapping(value = "/link/{filter}", produces = {"application/json; charset=utf8"})
+    public List<TbLinkDto> findLinkByFilter(
+            @ApiParam(name = "filter", value = "도로명/아이디", example = "지방도333호선", required = false)
+            @PathVariable final String filter) {
+        return this.linkService.findByFilter(filter);
+    }
+
+    @ApiOperation(value = "정보제공구간검색(TB_IFSC)", response = TbLinkDto.class)
+    @GetMapping(value = "/ifsc/{filter}", produces = {"application/json; charset=utf8"})
+    public List<TbIfscDto> findIfscByFilter(
+            @ApiParam(name = "filter", value = "구간명/아이디", example = "신갈우회도로", required = false)
+            @PathVariable final String filter) {
+        return this.ifscService.findByFilter(filter);
+    }
+
+    @ApiOperation(value = "도로검색(TB_ROAD)", response = TbLinkDto.class)
+    @GetMapping(value = "/road/{filter}", produces = {"application/json; charset=utf8"})
+    public List<TbRoadDto> findRoadByFilter(
+            @ApiParam(name = "filter", value = "도로명/아이디", example = "신수로", required = false)
+            @PathVariable final String filter) {
+        return this.roadService.findByFilter(filter);
+    }
+
+    /**
+     * 데이터베이스-노드관리의 노드정보개별조회와 동일함
+     * 위의 링크/정보제공구간/도로 조회후 지도 이동시에 이동할 좌표를 구하기 위해 지도검색 컨트롤러에 기능을 추가함.
+     * 시작 또는 종료노드 아이디로 해당 노드의 위치정보를 조회한 후에 지도로 이동한다.
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "노드정보 개별조회-위치이동(TB_NODE)", response = TbNodeDto.class)
+    @GetMapping(value = "/pos/{id}", produces = {"application/json; charset=utf8"})
+    public TbNodeDto findNodeById(
+            @ApiParam(name = "id", value = "노드아이디", example = "2280022000", required = true)
+            @PathVariable final Long id) {
+        return this.nodeService.findById(id);
+    }
+
+}

+ 23 - 0
src/main/java/com/its/api/op/service/ifsc/TbIfscService.java

@@ -116,4 +116,27 @@ public class TbIfscService {
         this.repo.save(entity);
         return entity.toDto();
     }
+
+    /**
+     * 지도검색
+     * @param filter
+     * @return
+     */
+    public List<TbIfscDto> findByFilter(String filter) {
+        List<TbIfscDto> result = new ArrayList<>();
+        List<TbIfsc> data = this.repo.findAll();
+        data.forEach(obj -> {
+            if (obj.getDelYn().equals("Y")) {
+                return;
+            }
+            if (filter == null || filter.isEmpty()) {
+                result.add(obj.toDto());
+            } else {
+                if ((obj.getIfscNm() != null && obj.getIfscNm().contains(filter)) || String.valueOf(obj.getIfscId()).contains(filter)) {
+                    result.add(obj.toDto());
+                }
+            }
+        });
+        return result;
+    }
 }

+ 23 - 0
src/main/java/com/its/api/op/service/link/TbLinkService.java

@@ -132,4 +132,27 @@ public class TbLinkService {
         }
         return result;
     }
+
+    /**
+     * 지도검색
+     * @param filter
+     * @return
+     */
+    public List<TbLinkDto> findByFilter(String filter) {
+        List<TbLinkDto> result = new ArrayList<>();
+        List<TbLink> data = this.repo.findAll();
+        data.forEach(obj -> {
+            if (obj.getDelYn().equals("Y")) {
+                return;
+            }
+            if (filter == null || filter.isEmpty()) {
+                result.add(obj.toDto());
+            } else {
+                if ((obj.getRoadName() != null && obj.getRoadName().contains(filter)) || String.valueOf(obj.getLinkId()).contains(filter)) {
+                    result.add(obj.toDto());
+                }
+            }
+        });
+        return result;
+    }
 }

+ 20 - 0
src/main/java/com/its/api/op/service/node/TbNodeService.java

@@ -104,4 +104,24 @@ public class TbNodeService {
         return result;
     }
 
+    /**
+     * 지도검색
+     * @param filter
+     * @return
+     */
+    public List<TbNodeDto> findByFilter(String filter) {
+        List<TbNodeDto> result = new ArrayList<>();
+        List<TbNode> data = this.repo.findAll();
+        data.forEach(obj -> {
+            if (filter == null || filter.isEmpty()) {
+                result.add(obj.toDto());
+            }
+            else {
+                if ((obj.getNodeName() != null && obj.getNodeName().contains(filter)) || String.valueOf(obj.getNodeId()).contains(filter)) {
+                    result.add(obj.toDto());
+                }
+            }
+        });
+        return result;
+    }
 }

+ 23 - 0
src/main/java/com/its/api/op/service/road/TbRoadService.java

@@ -116,4 +116,27 @@ public class TbRoadService {
         this.repo.save(entity);
         return entity.toDto();
     }
+
+    /**
+     * 지도검색
+     * @param filter
+     * @return
+     */
+    public List<TbRoadDto> findByFilter(String filter) {
+        List<TbRoadDto> result = new ArrayList<>();
+        List<TbRoad> data = this.repo.findAll();
+        data.forEach(obj -> {
+            if (obj.getDelYn().equals("Y")) {
+                return;
+            }
+            if (filter == null || filter.isEmpty()) {
+                result.add(obj.toDto());
+            } else {
+                if ((obj.getRoadName() != null && obj.getRoadName().contains(filter)) || String.valueOf(obj.getRoadId()).contains(filter)) {
+                    result.add(obj.toDto());
+                }
+            }
+        });
+        return result;
+    }
 }