From b5de1fc8f0ed20bcdf9f05d1a332eb740f00ba38 Mon Sep 17 00:00:00 2001 From: XinYi Song <2037158277@qq.com> Date: Sat, 5 Mar 2022 17:56:39 +0800 Subject: [PATCH] Default Changelist --- .../com/xkrs/controller/CameraController.java | 76 +++- .../com/xkrs/controller/TestController.java | 60 ++-- .../com/xkrs/dao/DeviceManagementDao.java | 20 +- .../xkrs/model/entity/DeviceManagement.java | 324 ++++++++++-------- .../java/com/xkrs/service/CameraService.java | 11 +- .../xkrs/service/impl/CameraServiceImpl.java | 54 ++- .../java/com/xkrs/util/ManagementUtil.java | 7 +- src/main/java/com/xkrs/util/RequestUtil.java | 42 +++ 8 files changed, 375 insertions(+), 219 deletions(-) diff --git a/src/main/java/com/xkrs/controller/CameraController.java b/src/main/java/com/xkrs/controller/CameraController.java index 81e6e9b..8b0c93a 100644 --- a/src/main/java/com/xkrs/controller/CameraController.java +++ b/src/main/java/com/xkrs/controller/CameraController.java @@ -33,6 +33,7 @@ public class CameraController { @Resource private DeviceManagementDao deviceManagementDao; + @GetMapping("/getCameraInformation") public List getCameraInformation(){ @@ -49,8 +50,48 @@ public class CameraController { return false; } + } + /** + * 返回全部信息 + * @param + * @return + */ + @GetMapping("/findEquipment1") + public String Selectequipment(){ + + try + { + return cameraService.Selectequipment(); + } + + catch (Exception E) + { + return E.getMessage(); + + } + } + /** + * 查询实时视频连接 + * @return + */ + @GetMapping("/findVideoPath1") + public String selectVideotape(){ + try { + return cameraService.Videotape(); + } + + catch (Exception e){ + return e.getMessage(); + } + + } + + /** + * 添加设备信息 + * @return + */ @GetMapping("/SelectDeviceManagement") public String SelectDeviceManagement() { @@ -63,32 +104,31 @@ public class CameraController { contnetTotal+=s; } br.close(); - System.out.println(contnetTotal); - DA tempBran = JSON.parseObject(contnetTotal, DA.class); - List pageData = tempBran.getData().getPageData(); - List list1=new ArrayList<>(); for (DA.DataDTO.PageDataDTO item: pageData) { - ADD add=new ADD(); - add.deviceName=item.getDeviceName(); - add.deviCevode=item.getDeviceCode(); - add.deviceSn=item.getDeviceSn(); - add.deviceCategory=item.getDeviceCategory(); - add.deviceManufacture=item.getDeviceManufacturer(); - add.deviceType=item.getDeviceType(); - add.deviceModel=item.getDeviceModel(); - add.deviceLp=item.getDeviceIp(); - add.devicePort=item.getDevicePort(); - add.ownerCode=item.getOwnerCode(); - list1.add(add); + DeviceManagement add=new DeviceManagement(); + add.setDeviceName(item.getDeviceName()); + add.setDeviceCode(item.getDeviceCode()); + add.setDeviceSn(item.getDeviceSn()); + add.setDeviceCategory(item.getDeviceCategory()); + add.setDeviceManufacturer(item.getDeviceManufacturer()); + add.setDeviceType(item.getDeviceType()); + add.setDeviceModel(item.getDeviceModel()); + add.setDeviceIp(item.getDeviceIp()); + add.setDevicePort(item.getDevicePort()); + add.setOwnerCode(item.getOwnerCode()); + add.setLiveVideo("http://111.53.13.180:7086/live/cameraid/"+item.getDeviceCode()+ "%240/substream/1.m3u8"); + add.setIsOnline(item.getIsOnline()); + add.setUpdateTime(item.getOnlineUpdateTime()); + deviceManagementDao.save(add); } - cameraService.InsertPaging(list1); + System.out.println("111"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } - return "over"; + return "1"; } } diff --git a/src/main/java/com/xkrs/controller/TestController.java b/src/main/java/com/xkrs/controller/TestController.java index 85099ce..1c7fce3 100644 --- a/src/main/java/com/xkrs/controller/TestController.java +++ b/src/main/java/com/xkrs/controller/TestController.java @@ -134,36 +134,36 @@ public class TestController { public String getPaging( String para) { String forecastWeather = ManagementUtil.getPaging(para); - List> listObjectFir = (List>) JSONArray.parse(forecastWeather); - ObjectMapper objectMapper = new ObjectMapper(); - JsonNode jsonNode = null; - try { - jsonNode = objectMapper.readTree(forecastWeather); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - List item= new ArrayList<>(); - String method = jsonNode.get("method").asText(); - if("vms.alarm.msg".equals(method)){ - JsonNode info = jsonNode.get("info"); - DeviceManagement fire = new DeviceManagement(); - fire.setDeviceName(info.get("deviceName").asText()); - fire.setDeviceCode(info.get("deviceCode").asText()); - fire.setDeviceSn(info.get("deviceSn").asText()); - fire.setDeviceCategory(Integer.valueOf(info.get("deviceCategory").asText())); - fire.setDeviceType(Integer.valueOf(info.get("deviceType").asText())); - fire.setDeviceManufacturer(info.get("deviceManufacturer").asText()); - fire.setDeviceModel(info.get("deviceModel").asText()); - fire.setDeviceIp(info.get("deviceIp").asText()); - fire.setDevicePort(Integer.valueOf(info.get("devicePort").asText())); - fire.setOwnerCode(info.get("ownerCode").asText()); - //fire.setOwnerOrgName(Integer.valueOf(info.get("ownerOrgName").asText())); - fire.setIsOnline(Integer.valueOf(info.get("isOnline").asText())); - fire.setSubSystem(info.get("subSystem").asText()); - fire.setDevExt(info.get("devExt").asText()); - item.add(fire); - } +// List> listObjectFir = (List>) JSONArray.parse(forecastWeather); +// ObjectMapper objectMapper = new ObjectMapper(); +// JsonNode jsonNode = null; +// try { +// jsonNode = objectMapper.readTree(forecastWeather); +// } catch (JsonProcessingException e) { +// e.printStackTrace(); +// } +// List item= new ArrayList<>(); +// String method = jsonNode.get("method").asText(); +// if("vms.alarm.msg".equals(method)){ +// JsonNode info = jsonNode.get("info"); +// DeviceManagement fire = new DeviceManagement(); +// fire.setDeviceName(info.get("deviceName").asText()); +// fire.setDeviceCode(info.get("deviceCode").asText()); +// fire.setDeviceSn(info.get("deviceSn").asText()); +// fire.setDeviceCategory(Integer.valueOf(info.get("deviceCategory").asText())); +// fire.setDeviceType(Integer.valueOf(info.get("deviceType").asText())); +// fire.setDeviceManufacturer(info.get("deviceManufacturer").asText()); +// fire.setDeviceModel(info.get("deviceModel").asText()); +// fire.setDeviceIp(info.get("deviceIp").asText()); +// fire.setDevicePort(Integer.valueOf(info.get("devicePort").asText())); +// fire.setOwnerCode(info.get("ownerCode").asText()); +// //fire.setOwnerOrgName(Integer.valueOf(info.get("ownerOrgName").asText())); +//// fire.setIsOnline(Integer.valueOf(info.get("isOnline").asText())); +//// fire.setSubSystem(info.get("subSystem").asText()); +//// fire.setDevExt(info.get("devExt").asText()); +// item.add(fire); +// } - return "成功!"; + return forecastWeather; } } diff --git a/src/main/java/com/xkrs/dao/DeviceManagementDao.java b/src/main/java/com/xkrs/dao/DeviceManagementDao.java index 4b86c64..6287227 100644 --- a/src/main/java/com/xkrs/dao/DeviceManagementDao.java +++ b/src/main/java/com/xkrs/dao/DeviceManagementDao.java @@ -3,10 +3,12 @@ package com.xkrs.dao; import com.xkrs.model.entity.CameraInformation; import com.xkrs.model.entity.DeviceManagement; import com.xkrs.model.vo.ADD; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -15,11 +17,17 @@ import java.util.Map; */ public interface DeviceManagementDao extends JpaRepository { - /** - * 添加设备分页信息 - */ - @Query(value = "Insert device_management('device_name','device_code','device_sn','device_category','device_type','device_manufacture','device_model','device_lp','device_port','owner_code') " + - "VALUES('?1','?2','?3','?4','?5','?6','?7','?8','?9','?10');",nativeQuery = true) - String selectDeviceManagement(List deviceManagement); + /** + * 查询视频连接 + */ + /*,device_name,device_sn,device_type,device_manufacturer*/ + @Query(value = "SELECT device_code,live_video FROM device_management",nativeQuery = true) + List> Videotape(); + + /** + * 查询全部设备信息 + */ + @Query(value = "SELECT * FROM device_management",nativeQuery = true) + List> equipment(); } diff --git a/src/main/java/com/xkrs/model/entity/DeviceManagement.java b/src/main/java/com/xkrs/model/entity/DeviceManagement.java index 52cb675..1267a15 100644 --- a/src/main/java/com/xkrs/model/entity/DeviceManagement.java +++ b/src/main/java/com/xkrs/model/entity/DeviceManagement.java @@ -7,7 +7,7 @@ import javax.persistence.*; * @Date: 2022/3/4 8:23 */ @Entity -@Table(name = "DeviceManagement") +@Table(name = "device_management") public class DeviceManagement { /** * 主键id @@ -66,76 +66,88 @@ public class DeviceManagement { */ @Column(length = 32, columnDefinition = "varchar(32)") private String ownerCode; + + /** - * 添加方式 + * 设备端口 */ @Column(length = 32, columnDefinition = "varchar(32)") - private String loginType; + private String updateTime; /** - * 登录名称 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String loginName; - /** - * 登录密码 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String loginPassword; - /** - * 主动注册代理端口 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private int registProxyPort; - /** - * 主动注册服务器编码 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String registDeviceCode; - /** - * 通道描述 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String memo; - /** - * 在线状态 + * 设备所属组织 */ @Column(length = 32, columnDefinition = "varchar(32)") private int isOnline; - /** - * 光栅图 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private long mapId; - /** - * 经度 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String gpsX; - /** - * 纬度 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String gpsY; - /** - * 设备所属子系统 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String subSystem; - /** - * 设备扩展属性 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String devExt; - /** - * 通道序号 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String channelSeq; - /** - *通道名称 - */ - @Column(length = 32, columnDefinition = "varchar(32)") - private String channelName; +// /** +// * 添加方式 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String loginType; +// /** +// * 登录名称 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String loginName; +// /** +// * 登录密码 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String loginPassword; +// /** +// * 主动注册代理端口 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private int registProxyPort; +// /** +// * 主动注册服务器编码 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String registDeviceCode; +// /** +// * 通道描述 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String memo; +// /** +// * 在线状态 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private int isOnline; +// /** +// * 光栅图 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private long mapId; +// /** +// * 经度 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String gpsX; +// /** +// * 纬度 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String gpsY; +// /** +// * 设备所属子系统 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String subSystem; +// /** +// * 设备扩展属性 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String devExt; +// /** +// * 通道序号 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String channelSeq; +// /** +// *通道名称 +// */ +// @Column(length = 32, columnDefinition = "varchar(32)") +// private String channelName; /** * 实时视频 */ @@ -230,52 +242,116 @@ public class DeviceManagement { this.ownerCode = ownerCode; } - public String getLoginType() { - return loginType; +// public String getLoginType() { +// return loginType; +// } +// +// public void setLoginType(String loginType) { +// this.loginType = loginType; +// } +// +// public String getLoginName() { +// return loginName; +// } +// +// public void setLoginName(String loginName) { +// this.loginName = loginName; +// } +// +// public String getLoginPassword() { +// return loginPassword; +// } +// +// public void setLoginPassword(String loginPassword) { +// this.loginPassword = loginPassword; +// } +// +// public int getRegistProxyPort() { +// return registProxyPort; +// } +// +// public void setRegistProxyPort(int registProxyPort) { +// this.registProxyPort = registProxyPort; +// } +// +// public String getRegistDeviceCode() { +// return registDeviceCode; +// } +// +// public void setRegistDeviceCode(String registDeviceCode) { +// this.registDeviceCode = registDeviceCode; +// } +// +// public String getMemo() { +// return memo; +// } +// +// public void setMemo(String memo) { +// this.memo = memo; +// } +// +// public int getIsOnline() { +// return isOnline; +// } +// +// public void setIsOnline(int isOnline) { +// this.isOnline = isOnline; +// } +// +// public long getMapId() { +// return mapId; +// } +// +// public void setMapId(long mapId) { +// this.mapId = mapId; +// } +// +// public String getGpsX() { +// return gpsX; +// } +// +// public void setGpsX(String gpsX) { +// this.gpsX = gpsX; +// } +// +// public String getGpsY() { +// return gpsY; +// } +// +// public void setGpsY(String gpsY) { +// this.gpsY = gpsY; +// } +// +// public String getSubSystem() { +// return subSystem; +// } +// +// public void setSubSystem(String subSystem) { +// this.subSystem = subSystem; +// } +// +// public String getDevExt() { +// return devExt; +// } +// +// public void setDevExt(String devExt) { +// this.devExt = devExt; +// } + + public String getLiveVideo() { + return liveVideo; } - public void setLoginType(String loginType) { - this.loginType = loginType; + public void setLiveVideo(String liveVideo) { + this.liveVideo = liveVideo; } - public String getLoginName() { - return loginName; + public String getUpdateTime() { + return updateTime; } - public void setLoginName(String loginName) { - this.loginName = loginName; - } - - public String getLoginPassword() { - return loginPassword; - } - - public void setLoginPassword(String loginPassword) { - this.loginPassword = loginPassword; - } - - public int getRegistProxyPort() { - return registProxyPort; - } - - public void setRegistProxyPort(int registProxyPort) { - this.registProxyPort = registProxyPort; - } - - public String getRegistDeviceCode() { - return registDeviceCode; - } - - public void setRegistDeviceCode(String registDeviceCode) { - this.registDeviceCode = registDeviceCode; - } - - public String getMemo() { - return memo; - } - - public void setMemo(String memo) { - this.memo = memo; + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; } public int getIsOnline() { @@ -285,44 +361,4 @@ public class DeviceManagement { public void setIsOnline(int isOnline) { this.isOnline = isOnline; } - - public long getMapId() { - return mapId; - } - - public void setMapId(long mapId) { - this.mapId = mapId; - } - - public String getGpsX() { - return gpsX; - } - - public void setGpsX(String gpsX) { - this.gpsX = gpsX; - } - - public String getGpsY() { - return gpsY; - } - - public void setGpsY(String gpsY) { - this.gpsY = gpsY; - } - - public String getSubSystem() { - return subSystem; - } - - public void setSubSystem(String subSystem) { - this.subSystem = subSystem; - } - - public String getDevExt() { - return devExt; - } - - public void setDevExt(String devExt) { - this.devExt = devExt; - } } diff --git a/src/main/java/com/xkrs/service/CameraService.java b/src/main/java/com/xkrs/service/CameraService.java index 9987628..53f5312 100644 --- a/src/main/java/com/xkrs/service/CameraService.java +++ b/src/main/java/com/xkrs/service/CameraService.java @@ -26,9 +26,18 @@ public interface CameraService { * @return */ List SelectDevice(); + /** + * 查询摄像头信息; + * @return + */ + String Videotape(); + /** + * + */ + String Selectequipment(); /** * 添加设备分页信息 */ - String InsertPaging(List para); + String InsertPaging(List para); } diff --git a/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java b/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java index 1602187..10e7f3a 100644 --- a/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/CameraServiceImpl.java @@ -1,5 +1,6 @@ package com.xkrs.service.impl; +import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.dao.CameraDao; import com.xkrs.dao.DeviceManagementDao; import com.xkrs.dao.FireDao; @@ -8,10 +9,17 @@ import com.xkrs.model.entity.DeviceManagement; import com.xkrs.model.vo.ADD; import com.xkrs.service.CameraService; import com.xkrs.util.Query; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigInteger; +import java.util.HashMap; import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; /** * @Author: XinYi Song @@ -25,10 +33,12 @@ public class CameraServiceImpl implements CameraService { @Resource private DeviceManagementDao deviceManagementDao; + Locale locale = LocaleContextHolder.getLocale(); + @Override public List SelectCameraAll() { - List cameraInformations =cameraDao.findAll(); - if (cameraInformations==null) { + List cameraInformations = cameraDao.findAll(); + if (cameraInformations == null) { System.out.println("实现错误"); } return cameraInformations; @@ -39,35 +49,45 @@ public class CameraServiceImpl implements CameraService { try { cameraDao.save(cameraInformation); - return true; - } - catch (Exception e){ + return true; + } catch (Exception e) { return false; } - - } @Override public List SelectDevice() { - List deviceManagements =deviceManagementDao.findAll(); - if (deviceManagements==null) { + List deviceManagements = deviceManagementDao.findAll(); + if (deviceManagements == null) { System.out.println("实现错误"); } return deviceManagements; } @Override - public String InsertPaging(List para) - { - try { - deviceManagementDao.selectDeviceManagement(para); - return "成功添加!"; - } - catch (Exception e){ + public String Videotape() { + List> stringObjectMap = deviceManagementDao.Videotape(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,stringObjectMap,locale); - return "失败1"; + } + + @Override + public String Selectequipment() { + List> stringObjectMap = deviceManagementDao.equipment(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,stringObjectMap,locale); + } + + @Override + public String InsertPaging(List para) { + try { + + + DeviceManagement deviceManagement = new DeviceManagement(); + return "成功添加!"; + } catch (Exception e) { + + return e.getMessage(); } } } diff --git a/src/main/java/com/xkrs/util/ManagementUtil.java b/src/main/java/com/xkrs/util/ManagementUtil.java index 12d0de2..21040a7 100644 --- a/src/main/java/com/xkrs/util/ManagementUtil.java +++ b/src/main/java/com/xkrs/util/ManagementUtil.java @@ -14,15 +14,16 @@ import java.util.Map; */ public class ManagementUtil { public static JsonNode getManagement() { - String url = "https://111.53.13.180:4433/evo-apigw/evo-brm/1.0.0/device?deviceCode=100001"; + String url = "https://111.53.13.180:4433/evo-apigw/evo-brm/1.0.0/device?deviceCode=1001339"; Map map = new HashMap<>(3); JsonNode jsonNode = RequestUtil.doGetJsonNode(url, map); return jsonNode; } + //https://{{host}}/evo-apigw/evo-brm/{{version}}/device/1001339 public static String getPaging(String para) { - String url = "https://111.53.13.180:4433/evo-apigw/evo-brm/1.2.0/device/subsystem/page"; - String jsonNode = RequestUtil.doPostJson(url, para); + String url = "https://111.53.13.180:4433/evo-apigw/evo-brm/1.2.0/devic?deviceCode="+para; + String jsonNode = RequestUtil.getPost(url); return jsonNode; } diff --git a/src/main/java/com/xkrs/util/RequestUtil.java b/src/main/java/com/xkrs/util/RequestUtil.java index 3eee54e..e58af01 100644 --- a/src/main/java/com/xkrs/util/RequestUtil.java +++ b/src/main/java/com/xkrs/util/RequestUtil.java @@ -124,6 +124,48 @@ public class RequestUtil { return result; } + + /** + * get设备详细信息查询 + * @param url + * @return String + */ + public static String getPost(String url) { + // 创建Httpclient对象 + CloseableHttpClient httpclient = HttpClients.createDefault(); + + String resultString = ""; + CloseableHttpResponse response = null; + try { + + URI uri = new URI(url); + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); + ObjectMapper objectMapper = new ObjectMapper(); + //使用ObjectMapper对象对 User对象进行转换 + + + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + /** * 带参数的get请求 * @param url