From 0fef3344ec187f7a41faca329634f6c136101ffc Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Mon, 9 May 2022 09:31:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=89=80=E6=9C=89=E7=BB=84?= =?UTF-8?q?=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitormanage/controller/Controller.java | 73 ++++++++++++++++++- .../mapper/CameraOrgenMapper.java | 6 ++ .../monitormanage/service/MonitorService.java | 62 ++++++++++++++++ .../MonitorManageApplicationTests.java | 8 ++ 4 files changed, 145 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index 9414e5d..8810086 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -4,10 +4,7 @@ import com.hisense.monitormanage.dto.ChannelLabelDto; import com.hisense.monitormanage.dto.ChengguanDto; import com.hisense.monitormanage.dto.ScenicCameraDto; import com.hisense.monitormanage.entity.*; -import com.hisense.monitormanage.mapper.CameraChannelMapper; -import com.hisense.monitormanage.mapper.CameraMapper; -import com.hisense.monitormanage.mapper.ProjectMapper; -import com.hisense.monitormanage.mapper.ScenicMapper; +import com.hisense.monitormanage.mapper.*; import com.hisense.monitormanage.service.MonitorService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; @@ -39,6 +36,9 @@ public class Controller { @Autowired private CameraChannelMapper cameraChannelMapper; + @Autowired + private CameraOrgenMapper cameraOrgenMapper; + @RequestMapping("all") public Object all(){ List projects = projectMapper.selectList(null); @@ -131,6 +131,11 @@ public class Controller { return success; } + /** + * 查询所有标签 + * @param label + * @return + */ @RequestMapping("selectAllLabel") public Result selectAllLabel(Label label ){ @@ -141,6 +146,66 @@ public class Controller { return success; } + /** + * 查询所有组织 + * @param cameraOrgan + * @return + */ + @RequestMapping("selectAllOrgan") + public Result selectAllOrgan(CameraOrgan cameraOrgan){ + List organs = cameraOrgenMapper.selectAllOrgan(cameraOrgan); + + Result success = Result.success(organs); + + return success; + } + + + //根据用户已输入的文字请求输入建议信息 + //text:用户输入的文字信息,必填 + //maxSuggestions:最大建议数量,0~10,默认2 + @RequestMapping("suggest") + public Result suggest( + @RequestParam(value ="text") String text, + @RequestParam(value = "maxSuggestions",required = false,defaultValue = "2") Integer maxSuggestions + ){ + Map map = new HashMap<>(); + map.put("text",text); + map.put("maxSuggestions",maxSuggestions); + return monitorService.suggest(map); + } + + //根据用户已输入的文字请求匹配的地址信息 + //singleLine:用户输入的文字性地名地址信息,必填 + //maxSuggestions:最大建议数量,0~10,默认2 + //magicKey:地名地址唯一ID,Suggest操作返回的JSON数组中包含的magicKey + //outSR:坐标系信息,包含"wkid"属性,是表示空间参考的ID,示例:{ "wkid":4490 } + @RequestMapping("geocode") + public Result geocode( + @RequestParam(value="singleLine") String singleLine, + @RequestParam(value = "maxSuggestions",required = false,defaultValue = "2") Integer maxSuggestions, + @RequestParam(value = "magicKey",required = false,defaultValue = "") String magicKey, + @RequestParam(value = "outSR",required = false,defaultValue = "") String outSR + ){ + Map map = new HashMap<>(); + map.put("SingleLine",singleLine); + map.put("maxSuggestions",maxSuggestions); + map.put("magicKey",magicKey); + map.put("outSR",outSR); + return monitorService.geocode(map); + } + + //根据用户已输入的坐标请求附近的地址信息 + //location:坐标,必填,请注意编码,示例:{"x":120.40632244540544,"y":36.08136665300961,"spatialReference":{"wkid":4490,"latestWkid":4490}} + @RequestMapping("reverseGeocode") + public Result reverseGeocode( + @RequestParam(value="location") String location + ){ + Map map = new HashMap<>(); + map.put("location",location); + return monitorService.reverseGeocode(map); + } + //查询视频点播巡检结果,只取异常的 @RequestMapping("listChannelPlayStates") public Result listChannelPlayStates( diff --git a/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java index 112facb..f5679a7 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/CameraOrgenMapper.java @@ -2,6 +2,12 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.entity.CameraOrgan; +import org.apache.ibatis.annotations.Select; + +import java.util.List; public interface CameraOrgenMapper extends BaseMapper { + + @Select("select * from t_camera_organ") + List selectAllOrgan(CameraOrgan cameraOrgan); } diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 0e855d2..c0e016d 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -359,6 +359,68 @@ public class MonitorService { } } + //地名地址搜索服务的Suggest操作 + public Result suggest(Map map){ + String url = "http://q3d.qd.gov.cn:8195/portalproxy/qcserver/rest/services/qcgd/GeocodeServer/suggest?"+"text={text}&key={key}"; + map.put("key",key); + + ResponseEntity responseEntity; + try{ + responseEntity = restTemplate.getForEntity(url, String.class,map); + HttpStatus statusCode = responseEntity.getStatusCode(); + if(statusCode.is2xxSuccessful()){ + return Result.success(responseEntity.getBody()); + }else{ + return Result.error(String.valueOf(statusCode.value())); + } + } catch (Exception e){ + log.info("[suggest] exception:{}",e.getMessage()); + return Result.error(e.getMessage()); + } + } + + //地名地址搜索服务的Geocode操作 + public Result geocode(Map map){ + String url = "http://q3d.qd.gov.cn:8195/portalproxy/qcserver/rest/services/qcgd/GeocodeServer/findAddressCandidates?" + +"SingleLine={SingleLine}&key={key}"; + map.put("key",key); + + ResponseEntity responseEntity; + try{ + responseEntity = restTemplate.getForEntity(url, String.class,map); + HttpStatus statusCode = responseEntity.getStatusCode(); + if(statusCode.is2xxSuccessful()){ + return Result.success(responseEntity.getBody()); + }else{ + return Result.error(String.valueOf(statusCode.value())); + } + } catch (Exception e){ + log.info("[geocode] exception:{}",e.getMessage()); + return Result.error(e.getMessage()); + } + } + + //地名地址搜索服务的reverseGeocode操作 + public Result reverseGeocode(Map map){ + String url = "http://q3d.qd.gov.cn:8195/portalproxy/qcserver/rest/services/qcgd/GeocodeServer/reverseGeocode?" + +"location={location}&key={key}"; + map.put("key",key); + + ResponseEntity responseEntity; + try { + responseEntity = restTemplate.getForEntity(url, String.class, map); + HttpStatus statusCode = responseEntity.getStatusCode(); + if(statusCode.is2xxSuccessful()){ + return Result.success(responseEntity.getBody()); + }else{ + return Result.error(String.valueOf(statusCode.value())); + } + }catch (HttpClientErrorException e){ + log.info("[reverseGeocode] exception:{}",e.getMessage()); + return Result.error(e.getMessage()); + } + } + //查询视频点播巡检结果 public void listChannelPlayStates(Map map){ String url = monitorDomain + "/nms/api/channel/play/list"; diff --git a/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java b/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java index ba9ddfc..80a0e47 100644 --- a/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java +++ b/src/test/java/com/hisense/monitormanage/MonitorManageApplicationTests.java @@ -30,4 +30,12 @@ class MonitorManageApplicationTests { } + + @Test + public void reverseGeocodeTest(){ + String location = "location"; + Map map = new HashMap<>(); + map.put("location",location); + monitorService.reverseGeocode(map); + } }