From abed3ecbec4b71a48fcc84dd3588bd221bd8a960 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 15 Aug 2024 17:45:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genersoft/iot/vmp/VManageBootstrap.java | 12 +- .../iot/vmp/conf/GlobalResponseAdvice.java | 12 +- .../iot/vmp/conf/SipPlatformRunner.java | 2 +- .../iot/vmp/gb28181/bean/CommonGBChannel.java | 2 +- .../iot/vmp/gb28181/bean/Platform.java | 10 +- .../iot/vmp/gb28181/bean/PlatformCatch.java | 2 +- .../controller/PlatformController.java | 63 +- .../gb28181/dao/CommonGBChannelMapper.java | 120 ++-- .../iot/vmp/gb28181/dao/PlatformMapper.java | 112 ++-- .../vmp/gb28181/service/IPlatformService.java | 3 +- .../service/impl/PlatformServiceImpl.java | 244 ++++---- .../cmd/SIPRequestHeaderPlarformProvider.java | 12 +- .../request/SIPRequestProcessorParent.java | 4 +- .../request/impl/InviteRequestProcessor.java | 2 +- .../impl/RegisterResponseProcessor.java | 2 +- .../impl/VideoManagerStorageImpl.java | 10 +- web_src/src/components/CloudRecord.vue | 4 +- web_src/src/components/DeviceList.vue | 4 +- web_src/src/components/PlatformEdit.vue | 167 +++--- web_src/src/components/PlatformList.vue | 29 +- web_src/src/components/StreamProxyList.vue | 4 +- web_src/src/components/StreamPushList.vue | 4 +- web_src/src/components/UserApiKeyManager.vue | 4 +- web_src/src/components/UserManager.vue | 4 +- web_src/src/components/channelList.vue | 4 +- .../src/components/dialog/GbDeviceSelect.vue | 4 +- .../components/dialog/chooseChannelForGb.vue | 4 +- .../dialog/chooseChannelForStream.vue | 4 +- .../src/components/dialog/platformEdit.vue | 543 ------------------ web_src/src/components/group.vue | 4 +- web_src/src/components/region.vue | 4 +- 数据库/2.7.2-重构/初始化-mysql-2.7.2.sql | 44 +- 32 files changed, 472 insertions(+), 971 deletions(-) delete mode 100755 web_src/src/components/dialog/platformEdit.vue diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java index e56eeedd0..e838cc8eb 100644 --- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java +++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java @@ -33,10 +33,14 @@ public class VManageBootstrap extends SpringBootServletInitializer { public static void main(String[] args) { VManageBootstrap.args = args; VManageBootstrap.context = SpringApplication.run(VManageBootstrap.class, args); - GitUtil gitUtil1 = SpringBeanFactory.getBean("gitUtil"); - log.info("构建版本: {}", gitUtil1.getBuildVersion()); - log.info("构建时间: {}", gitUtil1.getBuildDate()); - log.info("GIT最后提交时间: {}", gitUtil1.getCommitTime()); + GitUtil gitUtil = SpringBeanFactory.getBean("gitUtil"); + if (gitUtil == null) { + log.info("获取版本信息失败"); + }else { + log.info("构建版本: {}", gitUtil.getBuildVersion()); + log.info("构建时间: {}", gitUtil.getBuildDate()); + log.info("GIT最后提交时间: {}", gitUtil.getCommitTime()); + } } // 项目重启 public static void restart() { diff --git a/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java b/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java index 33fdd23df..af12ecabd 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/GlobalResponseAdvice.java @@ -1,12 +1,9 @@ package com.genersoft.iot.vmp.conf; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.jetbrains.annotations.NotNull; -import org.springframework.boot.autoconfigure.http.HttpMessageConverters; -import org.springframework.context.annotation.Bean; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; @@ -15,6 +12,8 @@ import org.springframework.http.server.ServerHttpResponse; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; +import java.util.LinkedHashMap; + /** * 全局统一返回结果 * @author lin @@ -52,6 +51,13 @@ public class GlobalResponseAdvice implements ResponseBodyAdvice { return JSON.toJSONString(WVPResult.success(body)); } + if (body instanceof LinkedHashMap) { + LinkedHashMap bodyMap = (LinkedHashMap) body; + if (bodyMap.get("status") != null && (Integer)bodyMap.get("status") != 200) { + return body; + } + } + return WVPResult.success(body); } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java index 65024114f..b3e86271d 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java @@ -46,7 +46,7 @@ public class SipPlatformRunner implements CommandLineRunner { // 更新缓存 PlatformCatch parentPlatformCatch = new PlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); + parentPlatformCatch.setPlatform(parentPlatform); parentPlatformCatch.setId(parentPlatform.getServerGBId()); redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); if (parentPlatformCatchOld != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java index 9ab88cd5c..5d82ae52b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java @@ -352,7 +352,7 @@ public class CommonGBChannel { commonGBChannel.setGbAddress(platform.getAddress()); commonGBChannel.setGbRegisterWay(platform.getRegisterWay()); commonGBChannel.setGbSecrecy(platform.getSecrecy()); - commonGBChannel.setGbStatus(platform.getStatus()); + commonGBChannel.setGbStatus(platform.isStatus()?"ON":"OFF"); return commonGBChannel; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Platform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Platform.java index 8ccc59e06..790d24267 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Platform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Platform.java @@ -26,7 +26,7 @@ public class Platform { private String serverGBDomain; @Schema(description = "SIP服务IP") - private String serverIP; + private String serverIp; @Schema(description = "SIP服务端口") private int serverPort; @@ -67,7 +67,7 @@ public class Platform { @Schema(description = "在线状态") private boolean status; - @Schema(description = "在线状态") + @Schema(description = "通道数量") private int channelCount; @Schema(description = "已被订阅目录信息") @@ -94,9 +94,6 @@ public class Platform { @Schema(description = "点播回复200OK使用的IP") private String sendStreamIp; - @Schema(description = "是否使用自定义业务分组") - private Boolean customGroup; - @Schema(description = "是否自动推送通道变化") private Boolean autoPushChannel; @@ -130,7 +127,4 @@ public class Platform { @Schema(description = "保密属性(必选)缺省为0;0-不涉密,1-涉密") private int secrecy = 0; - - @Schema(description = "在线状态") - private String Status = "ON"; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatch.java index ded3291ca..db7ab9805 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatch.java @@ -17,7 +17,7 @@ public class PlatformCatch { private String callId; - private Platform parentPlatform; + private Platform platform; private SipTransactionInfo sipTransactionInfo; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java index 91fbd0aba..7164c5d4b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java @@ -29,6 +29,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; @@ -122,7 +123,7 @@ public class PlatformController { @Parameter(name = "count", description = "每页条数", required = true) public PageInfo platforms(@PathVariable int page, @PathVariable int count) { - PageInfo parentPlatformPageInfo = platformService.queryParentPlatformList(page, count); + PageInfo parentPlatformPageInfo = platformService.queryPlatformList(page, count); if (parentPlatformPageInfo.getList().size() > 0) { for (Platform platform : parentPlatformPageInfo.getList()) { platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); @@ -135,45 +136,53 @@ public class PlatformController { /** * 添加上级平台信息 * - * @param parentPlatform + * @param platform * @return */ @Operation(summary = "添加上级平台信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @PostMapping("/add") @ResponseBody - public void addPlatform(@RequestBody Platform parentPlatform) { + public void addPlatform(@RequestBody Platform platform) { if (log.isDebugEnabled()) { log.debug("保存上级平台信息API调用"); } - if (ObjectUtils.isEmpty(parentPlatform.getName()) - || ObjectUtils.isEmpty(parentPlatform.getServerGBId()) - || ObjectUtils.isEmpty(parentPlatform.getServerGBDomain()) - || ObjectUtils.isEmpty(parentPlatform.getServerIP()) - || ObjectUtils.isEmpty(parentPlatform.getServerPort()) - || ObjectUtils.isEmpty(parentPlatform.getDeviceGBId()) - || ObjectUtils.isEmpty(parentPlatform.getExpires()) - || ObjectUtils.isEmpty(parentPlatform.getKeepTimeout()) - || ObjectUtils.isEmpty(parentPlatform.getTransport()) - || ObjectUtils.isEmpty(parentPlatform.getCharacterSet()) - ) { - throw new ControllerException(ErrorCode.ERROR400); - } - if (parentPlatform.getServerPort() < 0 || parentPlatform.getServerPort() > 65535) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "error severPort"); + Assert.notNull(platform.getName(), "平台名称不可为空"); + Assert.notNull(platform.getServerGBId(), "上级平台国标编号不可为空"); + Assert.notNull(platform.getServerIp(), "上级平台IP不可为空"); + Assert.isTrue(platform.getServerPort() > 0 && platform.getServerPort() < 65535, "上级平台端口异常"); + Assert.notNull(platform.getDeviceGBId(), "本平台国标编号不可为空"); + + if (ObjectUtils.isEmpty(platform.getServerGBDomain())) { + platform.setServerGBDomain(platform.getServerGBId().substring(0, 6)); } + if (platform.getExpires() <= 0) { + platform.setExpires(3600); + } - Platform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); + if (platform.getKeepTimeout() <= 0) { + platform.setKeepTimeout(60); + } + + if (ObjectUtils.isEmpty(platform.getTransport())) { + platform.setTransport("UDP"); + } + + if (ObjectUtils.isEmpty(platform.getCharacterSet())) { + platform.setCharacterSet("GB2312"); + } + + Platform parentPlatformOld = platformService.queryPlatformByServerGBId(platform.getServerGBId()); if (parentPlatformOld != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台 " + parentPlatform.getServerGBId() + " 已存在"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台 " + platform.getServerGBId() + " 已存在"); } - parentPlatform.setCreateTime(DateUtil.getNow()); - parentPlatform.setUpdateTime(DateUtil.getNow()); - boolean updateResult = platformService.add(parentPlatform); + platform.setCreateTime(DateUtil.getNow()); + platform.setUpdateTime(DateUtil.getNow()); + boolean updateResult = platformService.add(platform); if (!updateResult) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"写入数据库失败"); + throw new ControllerException(ErrorCode.ERROR100); } } @@ -184,9 +193,9 @@ public class PlatformController { * @return */ @Operation(summary = "保存上级平台信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) - @PostMapping("/save") + @PostMapping("/update") @ResponseBody - public void savePlatform(@RequestBody Platform parentPlatform) { + public void updatePlatform(@RequestBody Platform parentPlatform) { if (log.isDebugEnabled()) { log.debug("保存上级平台信息API调用"); @@ -194,7 +203,7 @@ public class PlatformController { if (ObjectUtils.isEmpty(parentPlatform.getName()) || ObjectUtils.isEmpty(parentPlatform.getServerGBId()) || ObjectUtils.isEmpty(parentPlatform.getServerGBDomain()) - || ObjectUtils.isEmpty(parentPlatform.getServerIP()) + || ObjectUtils.isEmpty(parentPlatform.getServerIp()) || ObjectUtils.isEmpty(parentPlatform.getServerPort()) || ObjectUtils.isEmpty(parentPlatform.getDeviceGBId()) || ObjectUtils.isEmpty(parentPlatform.getExpires()) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 35df9b7ab..f487bb70f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -466,40 +466,40 @@ public interface CommonGBChannelMapper { " wdc.update_time,\n" + " coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + " coalesce(wpgc.name, wdc.gb_name, wdc.name) as gb_name,\n" + - " coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" + - " coalesce(wdc.gb_model, wdc.model) as gb_model,\n" + - " coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" + + " coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" + + " coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" + + " coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" + " coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" + - " coalesce(wdc.gb_block, wdc.block) as gb_block,\n" + - " coalesce(wdc.gb_address, wdc.address) as gb_address,\n" + - " coalesce(wdc.gb_parental, wdc.parental) as gb_parental,\n" + + " coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" + + " coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" + + " coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" + " coalesce(wpgc.parent_id, wdc.gb_parent_id, wdc.parent_id) as gb_parent_id,\n" + - " coalesce(wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" + - " coalesce(wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" + - " coalesce(wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" + - " coalesce(wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" + - " coalesce(wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" + - " coalesce(wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" + - " coalesce(wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" + - " coalesce(wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" + - " coalesce(wdc.gb_port, wdc.port) as gb_port,\n" + - " coalesce(wdc.gb_password, wdc.password) as gb_password,\n" + - " coalesce(wdc.gb_status, wdc.status) as gb_status,\n" + - " coalesce(wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" + - " coalesce(wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" + - " coalesce(wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" + - " coalesce(wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" + - " coalesce(wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" + - " coalesce(wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" + - " coalesce(wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" + - " coalesce(wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" + - " coalesce(wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" + + " coalesce(wpgc.safety_way, wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" + + " coalesce(wpgc.register_way, wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" + + " coalesce(wpgc.cert_num, wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" + + " coalesce(wpgc.certifiable, wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" + + " coalesce(wpgc.err_code, wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" + + " coalesce(wpgc.end_time, wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" + + " coalesce(wpgc.secrecy, wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" + + " coalesce(wpgc.ip_address, wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" + + " coalesce(wpgc.port, wdc.gb_port, wdc.port) as gb_port,\n" + + " coalesce(wpgc.password, wdc.gb_password, wdc.password) as gb_password,\n" + + " coalesce(wpgc.status, wdc.gb_status, wdc.status) as gb_status,\n" + + " coalesce(wpgc.longitude, wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" + + " coalesce(wpgc.latitude, wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" + + " coalesce(wpgc.ptz_type, wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" + + " coalesce(wpgc.position_type, wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" + + " coalesce(wpgc.room_type, wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" + + " coalesce(wpgc.use_type, wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" + + " coalesce(wpgc.supply_light_type, wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" + + " coalesce(wpgc.direction_type, wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" + + " coalesce(wpgc.resolution, wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" + " coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" + - " coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" + - " coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + - " coalesce(wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + + " coalesce(wpgc.download_speed, wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" + + " coalesce(wpgc.svc_space_support_mod, wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + + " coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel wdc" + - " left jon wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" + + " left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" + " where wpgc.platform_id = #{platformId}" ) @@ -514,40 +514,40 @@ public interface CommonGBChannelMapper { " wdc.update_time,\n" + " coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" + " coalesce(wpgc.name, wdc.gb_name, wdc.name) as gb_name,\n" + - " coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" + - " coalesce(wdc.gb_model, wdc.model) as gb_model,\n" + - " coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" + + " coalesce(wpgc.manufacturer, wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" + + " coalesce(wpgc.model, wdc.gb_model, wdc.model) as gb_model,\n" + + " coalesce(wpgc.owner, wdc.gb_owner, wdc.owner) as gb_owner,\n" + " coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code),\n" + - " coalesce(wdc.gb_block, wdc.block) as gb_block,\n" + - " coalesce(wdc.gb_address, wdc.address) as gb_address,\n" + - " coalesce(wdc.gb_parental, wdc.parental) as gb_parental,\n" + + " coalesce(wpgc.block, wdc.gb_block, wdc.block) as gb_block,\n" + + " coalesce(wpgc.address, wdc.gb_address, wdc.address) as gb_address,\n" + + " coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" + " coalesce(wpgc.parent_id, wdc.gb_parent_id, wdc.parent_id) as gb_parent_id,\n" + - " coalesce(wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" + - " coalesce(wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" + - " coalesce(wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" + - " coalesce(wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" + - " coalesce(wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" + - " coalesce(wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" + - " coalesce(wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" + - " coalesce(wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" + - " coalesce(wdc.gb_port, wdc.port) as gb_port,\n" + - " coalesce(wdc.gb_password, wdc.password) as gb_password,\n" + - " coalesce(wdc.gb_status, wdc.status) as gb_status,\n" + - " coalesce(wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" + - " coalesce(wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" + - " coalesce(wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" + - " coalesce(wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" + - " coalesce(wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" + - " coalesce(wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" + - " coalesce(wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" + - " coalesce(wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" + - " coalesce(wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" + + " coalesce(wpgc.safety_way, wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" + + " coalesce(wpgc.register_way, wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" + + " coalesce(wpgc.cert_num, wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" + + " coalesce(wpgc.certifiable, wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" + + " coalesce(wpgc.err_code, wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" + + " coalesce(wpgc.end_time, wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" + + " coalesce(wpgc.secrecy, wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" + + " coalesce(wpgc.ip_address, wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" + + " coalesce(wpgc.port, wdc.gb_port, wdc.port) as gb_port,\n" + + " coalesce(wpgc.password, wdc.gb_password, wdc.password) as gb_password,\n" + + " coalesce(wpgc.status, wdc.gb_status, wdc.status) as gb_status,\n" + + " coalesce(wpgc.longitude, wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" + + " coalesce(wpgc.latitude, wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" + + " coalesce(wpgc.ptz_type, wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" + + " coalesce(wpgc.position_type, wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" + + " coalesce(wpgc.room_type, wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" + + " coalesce(wpgc.use_type, wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" + + " coalesce(wpgc.supply_light_type, wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" + + " coalesce(wpgc.direction_type, wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" + + " coalesce(wpgc.resolution, wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" + " coalesce(wpgc.business_group_id, wdc.gb_business_group_id, wdc.business_group_id) as gb_business_group_id,\n" + - " coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" + - " coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + - " coalesce(wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + + " coalesce(wpgc.download_speed, wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" + + " coalesce(wpgc.svc_space_support_mod, wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + + " coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel wdc" + - " left jon wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" + + " left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" + " where wpgc.platform_id = #{platformId} and coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) = #{channelDeviceId}" ) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java index fc33eec18..2399ea293 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java @@ -1,9 +1,7 @@ package com.genersoft.iot.vmp.gb28181.dao; import com.genersoft.iot.vmp.gb28181.bean.Platform; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import org.apache.ibatis.annotations.*; -import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import java.util.List; @@ -16,59 +14,59 @@ import java.util.List; public interface PlatformMapper { @Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+ - "device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,as_message_channel,auto_push_channel,"+ - "status,catalog_id,administrative_division,catalog_group,create_time,update_time,send_stream_ip) " + - " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIP}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " + - " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{asMessageChannel}, #{autoPushChannel}, " + - " #{status}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{sendStreamIp})") - int addParentPlatform(Platform parentPlatform); + " device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,status,catalog_group, update_time," + + " create_time, as_message_channel, send_stream_ip, auto_push_channel, catalog_with_platform,catalog_with_group,catalog_with_region, "+ + " civil_code,manufacturer,model,address,register_way,secrecy) " + + " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIp}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " + + " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{status}, #{catalogGroup},#{updateTime}," + + " #{createTime}, #{asMessageChannel}, #{sendStreamIp}, #{autoPushChannel}, #{catalogWithPlatform}, #{catalogWithGroup},#{catalogWithRegion}, " + + " #{civilCode}, #{manufacturer}, #{model}, #{address}, #{registerWay}, #{secrecy})") + int add(Platform parentPlatform); @Update("UPDATE wvp_platform " + - "SET enable=#{enable}, " + - "name=#{name}," + - "device_gb_id=#{deviceGBId}," + - "server_gb_id=#{serverGBId}, " + - "server_gb_domain=#{serverGBDomain}, " + - "server_ip=#{serverIP}," + - "server_port=#{serverPort}, " + - "device_ip=#{deviceIp}, " + - "device_port=#{devicePort}, " + - "username=#{username}, " + - "password=#{password}, " + - "expires=#{expires}, " + - "keep_timeout=#{keepTimeout}, " + - "transport=#{transport}, " + - "character_set=#{characterSet}, " + - "ptz=#{ptz}, " + - "rtcp=#{rtcp}, " + - "as_message_channel=#{asMessageChannel}, " + - "auto_push_channel=#{autoPushChannel}, " + - "status=#{status}, " + - "catalog_group=#{catalogGroup}, " + - "administrative_division=#{administrativeDivision}, " + - "create_time=#{createTime}, " + - "update_time=#{updateTime}, " + - "send_stream_ip=#{sendStreamIp}, " + - "catalog_id=#{catalogId} " + + "SET update_time = #{updateTime}," + + " enable=#{enable}, " + + " name=#{name}," + + " server_gb_id=#{serverGBId}, " + + " server_gb_domain=#{serverGBDomain}, " + + " server_ip=#{serverIp}," + + " server_port=#{serverPort}, " + + " device_gb_id=#{deviceGBId}," + + " device_ip=#{deviceIp}, " + + " device_port=#{devicePort}, " + + " username=#{username}, " + + " password=#{password}, " + + " expires=#{expires}, " + + " keep_timeout=#{keepTimeout}, " + + " transport=#{transport}, " + + " character_set=#{characterSet}, " + + " ptz=#{ptz}, " + + " rtcp=#{rtcp}, " + + " status=#{status}, " + + " catalog_group=#{catalogGroup}, " + + " as_message_channel=#{asMessageChannel}, " + + " send_stream_ip=#{sendStreamIp}, " + + " auto_push_channel=#{autoPushChannel}, " + + " catalog_with_platform=#{catalogWithPlatform}, " + + " catalog_with_group=#{catalogWithGroup}, " + + " catalog_with_region=#{catalogWithRegion}, " + + " civil_code=#{civilCode}, " + + " manufacturer=#{manufacturer}, " + + " model=#{model}, " + + " address=#{address}, " + + " register_way=#{registerWay}, " + + " secrecy=#{secrecy} " + "WHERE id=#{id}") - int updateParentPlatform(Platform parentPlatform); + int update(Platform parentPlatform); @Delete("DELETE FROM wvp_platform WHERE server_gb_id=#{serverGBId}") int delParentPlatform(Platform parentPlatform); - @Select("SELECT *, ((SELECT count(0)\n" + - " FROM wvp_platform_gb_channel pc\n" + - " WHERE pc.platform_id = pp.server_gb_id)\n" + - " +\n" + - " (SELECT count(0)\n" + - " FROM wvp_platform_gb_stream pgs\n" + - " WHERE pgs.platform_id = pp.server_gb_id)\n" + - " +\n" + - " (SELECT count(0)\n" + - " FROM wvp_platform_catalog pgc\n" + - " WHERE pgc.platform_id = pp.server_gb_id)) as channel_count\n" + - "FROM wvp_platform pp ") - List getParentPlatformList(); + @Select(" SELECT pp.*, " + + " (SELECT count(0) FROM wvp_platform_gb_channel pc WHERE pc.platform_id = pp.id ) as channel_count" + + " FROM wvp_platform pp " + ) + List queryList(); @Select("SELECT * FROM wvp_platform WHERE enable=#{enable} ") List getEnableParentPlatformList(boolean enable); @@ -80,23 +78,9 @@ public interface PlatformMapper { Platform getParentPlatByServerGBId(String platformGbId); @Select("SELECT * FROM wvp_platform WHERE id=#{id}") - Platform getParentPlatById(int id); - - @Update("UPDATE wvp_platform SET status=false" ) - int outlineForAllParentPlatform(); + Platform query(int id); @Update("UPDATE wvp_platform SET status=#{online} WHERE server_gb_id=#{platformGbID}" ) - int updateParentPlatformStatus(@Param("platformGbID") String platformGbID, @Param("online") boolean online); + int updateStatus(@Param("platformGbID") String platformGbID, @Param("online") boolean online); - @Update(value = {" "}) - int setDefaultCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId, @Param("updateTime") String updateTime); - - @Select("select 'channel' as name, count(pgc.platform_id) count from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id where pgc.platform_id=#{platform_id} and dc.channel_id =#{gbId} " + - "union " + - "select 'stream' as name, count(pgs.platform_id) count from wvp_platform_gb_stream pgs left join wvp_gb_stream gs on pgs.gb_stream_id = gs.gb_stream_id where pgs.platform_id=#{platform_id} and gs.gb_id =#{gbId}") - List getChannelSource(@Param("platform_id") String platform_id, @Param("gbId") String gbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java index 423734416..dafaea1ed 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.media.event.hook.HookSubscribe; @@ -28,7 +27,7 @@ public interface IPlatformService { * @param count * @return */ - PageInfo queryParentPlatformList(int page, int count); + PageInfo queryPlatformList(int page, int count); /** * 添加级联平台 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java index 2cf3dc4a0..47c148295 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformServiceImpl.java @@ -36,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; import javax.sdp.*; import javax.sip.InvalidArgumentException; @@ -130,14 +131,14 @@ public class PlatformServiceImpl implements IPlatformService { List sendRtpItems = redisCatchStorage.querySendRTPServerByStream(event.getStream()); if (sendRtpItems != null && !sendRtpItems.isEmpty()) { for (SendRtpItem sendRtpItem : sendRtpItems) { - Platform parentPlatform = platformMapper.getParentPlatByServerGBId(sendRtpItem.getPlatformId()); + Platform platform = platformMapper.getParentPlatByServerGBId(sendRtpItem.getPlatformId()); ssrcFactory.releaseSsrc(sendRtpItem.getMediaServerId(), sendRtpItem.getSsrc()); try { - commanderForPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); + commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); } catch (SipException | InvalidArgumentException | ParseException e) { log.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); } - redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), + redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), sendRtpItem.getChannelId(), sendRtpItem.getCallId(), sendRtpItem.getStream()); } } @@ -150,32 +151,31 @@ public class PlatformServiceImpl implements IPlatformService { } @Override - public PageInfo queryParentPlatformList(int page, int count) { + public PageInfo queryPlatformList(int page, int count) { PageHelper.startPage(page, count); - List all = platformMapper.getParentPlatformList(); + List all = platformMapper.queryList(); return new PageInfo<>(all); } @Override - public boolean add(Platform parentPlatform) { - - if (parentPlatform.getCatalogGroup() == 0) { + public boolean add(Platform platform) { + log.info("[国标级联]添加平台 {}", platform.getDeviceGBId()); + if (platform.getCatalogGroup() == 0) { // 每次发送目录的数量默认为1 - parentPlatform.setCatalogGroup(1); + platform.setCatalogGroup(1); } - int result = platformMapper.addParentPlatform(parentPlatform); + int result = platformMapper.add(platform); // 添加缓存 - PlatformCatch parentPlatformCatch = new PlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - parentPlatformCatch.setParentPlatform(parentPlatform); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - if (parentPlatform.isEnable()) { + PlatformCatch platformCatch = new PlatformCatch(); + platformCatch.setPlatform(platform); + platformCatch.setId(platform.getServerGBId()); + redisCatchStorage.updatePlatformCatchInfo(platformCatch); + if (platform.isEnable()) { // 保存时启用就发送注册 // 注册成功时由程序直接调用了online方法 try { - commanderForPlatform.register(parentPlatform, eventResult -> { - log.info("[国标级联] {},添加向上级注册失败,请确定上级平台可用时重新保存", parentPlatform.getServerGBId()); + commanderForPlatform.register(platform, eventResult -> { + log.info("[国标级联] {}({}),添加向上级注册失败,请确定上级平台可用时重新保存", platform.getName(), platform.getServerGBId()); }, null); } catch (InvalidArgumentException | ParseException | SipException e) { log.error("[命令发送失败] 国标级联: {}", e.getMessage()); @@ -185,25 +185,26 @@ public class PlatformServiceImpl implements IPlatformService { } @Override - public boolean update(Platform parentPlatform) { - log.info("[国标级联]更新平台 {}", parentPlatform.getDeviceGBId()); - parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase()); - Platform parentPlatformOld = platformMapper.getParentPlatById(parentPlatform.getId()); - PlatformCatch parentPlatformCatchOld = redisCatchStorage.queryPlatformCatchInfo(parentPlatformOld.getServerGBId()); - parentPlatform.setUpdateTime(DateUtil.getNow()); + public boolean update(Platform platform) { + Assert.isTrue(platform.getId() > 0, "ID必须存在"); + log.info("[国标级联] 更新平台 {}({})", platform.getName(), platform.getDeviceGBId()); + platform.setCharacterSet(platform.getCharacterSet().toUpperCase()); + Platform platformInDb = platformMapper.query(platform.getId()); + PlatformCatch platformCatchOld = redisCatchStorage.queryPlatformCatchInfo(platformInDb.getServerGBId()); + platform.setUpdateTime(DateUtil.getNow()); // 停止心跳定时 - final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatformOld.getServerGBId(); + final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + platformInDb.getServerGBId(); dynamicTask.stop(keepaliveTaskKey); // 停止注册定时 - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatformOld.getServerGBId(); + final String registerTaskKey = REGISTER_KEY_PREFIX + platformInDb.getServerGBId(); dynamicTask.stop(registerTaskKey); // 注销旧的 try { - if (parentPlatformOld.isStatus() && parentPlatformCatchOld != null) { - log.info("保存平台{}时发现旧平台在线,发送注销命令", parentPlatformOld.getServerGBId()); - commanderForPlatform.unregister(parentPlatformOld, parentPlatformCatchOld.getSipTransactionInfo(), null, eventResult -> { - log.info("[国标级联] 注销成功, 平台:{}", parentPlatformOld.getServerGBId()); + if (platformInDb.isStatus() && platformCatchOld != null) { + log.info("保存平台{}时发现旧平台在线,发送注销命令", platformInDb.getServerGBId()); + commanderForPlatform.unregister(platformInDb, platformCatchOld.getSipTransactionInfo(), null, eventResult -> { + log.info("[国标级联] 注销成功, 平台:{}", platformInDb.getServerGBId()); }); } } catch (InvalidArgumentException | ParseException | SipException e) { @@ -211,98 +212,97 @@ public class PlatformServiceImpl implements IPlatformService { } // 更新数据库 - if (parentPlatform.getCatalogGroup() == 0) { - parentPlatform.setCatalogGroup(1); + if (platform.getCatalogGroup() == 0) { + platform.setCatalogGroup(1); } - platformMapper.updateParentPlatform(parentPlatform); + platformMapper.update(platform); // 更新redis - redisCatchStorage.delPlatformCatchInfo(parentPlatformOld.getServerGBId()); - PlatformCatch parentPlatformCatch = new PlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); + redisCatchStorage.delPlatformCatchInfo(platformInDb.getServerGBId()); + PlatformCatch platformCatch = new PlatformCatch(); + platformCatch.setPlatform(platform); + platformCatch.setId(platform.getServerGBId()); + redisCatchStorage.updatePlatformCatchInfo(platformCatch); // 注册 - if (parentPlatform.isEnable()) { + if (platform.isEnable()) { // 保存时启用就发送注册 // 注册成功时由程序直接调用了online方法 try { - log.info("[国标级联] 平台注册 {}", parentPlatform.getDeviceGBId()); - commanderForPlatform.register(parentPlatform, eventResult -> { - log.info("[国标级联] {},添加向上级注册失败,请确定上级平台可用时重新保存", parentPlatform.getServerGBId()); + log.info("[国标级联] 平台注册 {}", platform.getDeviceGBId()); + commanderForPlatform.register(platform, eventResult -> { + log.info("[国标级联] {},添加向上级注册失败,请确定上级平台可用时重新保存", platform.getServerGBId()); }, null); } catch (InvalidArgumentException | ParseException | SipException e) { log.error("[命令发送失败] 国标级联: {}", e.getMessage()); } } - return false; } @Override - public void online(Platform parentPlatform, SipTransactionInfo sipTransactionInfo) { - log.info("[国标级联]:{}, 平台上线", parentPlatform.getServerGBId()); - final String registerFailAgainTaskKey = REGISTER_FAIL_AGAIN_KEY_PREFIX + parentPlatform.getServerGBId(); + public void online(Platform platform, SipTransactionInfo sipTransactionInfo) { + log.info("[国标级联]:{}, 平台上线", platform.getServerGBId()); + final String registerFailAgainTaskKey = REGISTER_FAIL_AGAIN_KEY_PREFIX + platform.getServerGBId(); dynamicTask.stop(registerFailAgainTaskKey); - platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), true); - PlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - if (parentPlatformCatch == null) { - parentPlatformCatch = new PlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - parentPlatform.setStatus(true); - parentPlatformCatch.setParentPlatform(parentPlatform); + platformMapper.updateStatus(platform.getServerGBId(), true); + PlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(platform.getServerGBId()); + if (platformCatch == null) { + platformCatch = new PlatformCatch(); + platformCatch.setPlatform(platform); + platformCatch.setId(platform.getServerGBId()); + platform.setStatus(true); + platformCatch.setPlatform(platform); } - parentPlatformCatch.getParentPlatform().setStatus(true); - parentPlatformCatch.setSipTransactionInfo(sipTransactionInfo); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); + platformCatch.getPlatform().setStatus(true); + platformCatch.setSipTransactionInfo(sipTransactionInfo); + redisCatchStorage.updatePlatformCatchInfo(platformCatch); - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); + final String registerTaskKey = REGISTER_KEY_PREFIX + platform.getServerGBId(); if (!dynamicTask.isAlive(registerTaskKey)) { - log.info("[国标级联]:{}, 添加定时注册任务", parentPlatform.getServerGBId()); + log.info("[国标级联]:{}, 添加定时注册任务", platform.getServerGBId()); // 添加注册任务 dynamicTask.startCron(registerTaskKey, // 注册失败(注册成功时由程序直接调用了online方法) - ()-> registerTask(parentPlatform, sipTransactionInfo), - parentPlatform.getExpires() * 1000); + ()-> registerTask(platform, sipTransactionInfo), + platform.getExpires() * 1000); } - final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); + final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + platform.getServerGBId(); if (!dynamicTask.contains(keepaliveTaskKey)) { - log.info("[国标级联]:{}, 添加定时心跳任务", parentPlatform.getServerGBId()); + log.info("[国标级联]:{}, 添加定时心跳任务", platform.getServerGBId()); // 添加心跳任务 dynamicTask.startCron(keepaliveTaskKey, ()-> { try { - commanderForPlatform.keepalive(parentPlatform, eventResult -> { + commanderForPlatform.keepalive(platform, eventResult -> { // 心跳失败 if (eventResult.type != SipSubscribe.EventResultType.timeout) { log.warn("[国标级联]发送心跳收到错误,code: {}, msg: {}", eventResult.statusCode, eventResult.msg); } // 心跳失败 - PlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); + PlatformCatch platformCatchForNow = redisCatchStorage.queryPlatformCatchInfo(platform.getServerGBId()); // 此时是第三次心跳超时, 平台离线 - if (platformCatch.getKeepAliveReply() == 2) { + if (platformCatchForNow.getKeepAliveReply() == 2) { // 设置平台离线,并重新注册 - log.info("[国标级联] 三次心跳失败, 平台{}({})离线", parentPlatform.getName(), parentPlatform.getServerGBId()); - offline(parentPlatform, false); + log.info("[国标级联] 三次心跳失败, 平台{}({})离线", platform.getName(), platform.getServerGBId()); + offline(platform, false); }else { - platformCatch.setKeepAliveReply(platformCatch.getKeepAliveReply() + 1); - redisCatchStorage.updatePlatformCatchInfo(platformCatch); + platformCatchForNow.setKeepAliveReply(platformCatchForNow.getKeepAliveReply() + 1); + redisCatchStorage.updatePlatformCatchInfo(platformCatchForNow); } }, eventResult -> { // 心跳成功 // 清空之前的心跳超时计数 - PlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - if (platformCatch != null && platformCatch.getKeepAliveReply() > 0) { - platformCatch.setKeepAliveReply(0); - redisCatchStorage.updatePlatformCatchInfo(platformCatch); + PlatformCatch platformCatchForNow = redisCatchStorage.queryPlatformCatchInfo(platform.getServerGBId()); + if (platformCatchForNow != null && platformCatchForNow.getKeepAliveReply() > 0) { + platformCatchForNow.setKeepAliveReply(0); + redisCatchStorage.updatePlatformCatchInfo(platformCatchForNow); } log.info("[发送心跳] 国标级联 发送心跳, code: {}, msg: {}", eventResult.statusCode, eventResult.msg); }); @@ -310,37 +310,37 @@ public class PlatformServiceImpl implements IPlatformService { log.error("[命令发送失败] 国标级联 发送心跳: {}", e.getMessage()); } }, - (parentPlatform.getKeepTimeout())*1000); + (platform.getKeepTimeout())*1000); } - if (parentPlatform.getAutoPushChannel() != null && parentPlatform.getAutoPushChannel()) { - if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) { - log.info("[国标级联]:{}, 添加自动通道推送模拟订阅信息", parentPlatform.getServerGBId()); - addSimulatedSubscribeInfo(parentPlatform); + if (platform.getAutoPushChannel() != null && platform.getAutoPushChannel()) { + if (subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) == null) { + log.info("[国标级联]:{}, 添加自动通道推送模拟订阅信息", platform.getServerGBId()); + addSimulatedSubscribeInfo(platform); } }else { - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()); + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); if (catalogSubscribe != null && catalogSubscribe.getExpires() == -1) { - subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId()); + subscribeHolder.removeCatalogSubscribe(platform.getServerGBId()); } } } @Override - public void addSimulatedSubscribeInfo(Platform parentPlatform) { + public void addSimulatedSubscribeInfo(Platform platform) { // 自动添加一条模拟的订阅信息 SubscribeInfo subscribeInfo = new SubscribeInfo(); - subscribeInfo.setId(parentPlatform.getServerGBId()); + subscribeInfo.setId(platform.getServerGBId()); subscribeInfo.setExpires(-1); subscribeInfo.setEventType("Catalog"); int random = (int) Math.floor(Math.random() * 10000); subscribeInfo.setEventId(random + ""); - subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + parentPlatform.getServerIP()); + subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + platform.getServerIp()); subscribeInfo.setSimulatedFromTag(UUID.randomUUID().toString().replace("-", "")); subscribeInfo.setSimulatedToTag(UUID.randomUUID().toString().replace("-", "")); - subscribeHolder.putCatalogSubscribe(parentPlatform.getServerGBId(), subscribeInfo); + subscribeHolder.putCatalogSubscribe(platform.getServerGBId(), subscribeInfo); } - private void registerTask(Platform parentPlatform, SipTransactionInfo sipTransactionInfo){ + private void registerTask(Platform platform, SipTransactionInfo sipTransactionInfo){ try { // 不在同一个会话中续订则每次全新注册 if (!userSetting.isRegisterKeepIntDialog()) { @@ -348,15 +348,15 @@ public class PlatformServiceImpl implements IPlatformService { } if (sipTransactionInfo == null) { - log.info("[国标级联] 平台:{}注册即将到期,开始重新注册", parentPlatform.getServerGBId()); + log.info("[国标级联] 平台:{}注册即将到期,开始重新注册", platform.getServerGBId()); }else { - log.info("[国标级联] 平台:{}注册即将到期,开始续订", parentPlatform.getServerGBId()); + log.info("[国标级联] 平台:{}注册即将到期,开始续订", platform.getServerGBId()); } - commanderForPlatform.register(parentPlatform, sipTransactionInfo, eventResult -> { - log.info("[国标级联] 平台:{}注册失败,{}:{}", parentPlatform.getServerGBId(), + commanderForPlatform.register(platform, sipTransactionInfo, eventResult -> { + log.info("[国标级联] 平台:{}注册失败,{}:{}", platform.getServerGBId(), eventResult.statusCode, eventResult.msg); - offline(parentPlatform, false); + offline(platform, false); }, null); } catch (Exception e) { log.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage()); @@ -364,52 +364,52 @@ public class PlatformServiceImpl implements IPlatformService { } @Override - public void offline(Platform parentPlatform, boolean stopRegister) { - log.info("[平台离线]:{}", parentPlatform.getServerGBId()); - PlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - parentPlatformCatch.setKeepAliveReply(0); - parentPlatformCatch.setRegisterAliveReply(0); - Platform parentPlatformInCatch = parentPlatformCatch.getParentPlatform(); - parentPlatformInCatch.setStatus(false); - parentPlatformCatch.setParentPlatform(parentPlatformInCatch); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), false); + public void offline(Platform platform, boolean stopRegister) { + log.info("[平台离线]:{}", platform.getServerGBId()); + PlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(platform.getServerGBId()); + platformCatch.setKeepAliveReply(0); + platformCatch.setRegisterAliveReply(0); + Platform catchPlatform = platformCatch.getPlatform(); + catchPlatform.setStatus(false); + platformCatch.setPlatform(catchPlatform); + redisCatchStorage.updatePlatformCatchInfo(platformCatch); + platformMapper.updateStatus(platform.getServerGBId(), false); // 停止所有推流 - log.info("[平台离线] {}, 停止所有推流", parentPlatform.getServerGBId()); - stopAllPush(parentPlatform.getServerGBId()); + log.info("[平台离线] {}, 停止所有推流", platform.getServerGBId()); + stopAllPush(platform.getServerGBId()); // 清除注册定时 - log.info("[平台离线] {}, 停止定时注册任务", parentPlatform.getServerGBId()); - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); + log.info("[平台离线] {}, 停止定时注册任务", platform.getServerGBId()); + final String registerTaskKey = REGISTER_KEY_PREFIX + platform.getServerGBId(); if (dynamicTask.contains(registerTaskKey)) { dynamicTask.stop(registerTaskKey); } // 清除心跳定时 - log.info("[平台离线] {}, 停止定时发送心跳任务", parentPlatform.getServerGBId()); - final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); + log.info("[平台离线] {}, 停止定时发送心跳任务", platform.getServerGBId()); + final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + platform.getServerGBId(); if (dynamicTask.contains(keepaliveTaskKey)) { // 清除心跳任务 dynamicTask.stop(keepaliveTaskKey); } // 停止订阅回复 - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()); + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); if (catalogSubscribe != null) { if (catalogSubscribe.getExpires() > 0) { - log.info("[平台离线] {}, 停止目录订阅回复", parentPlatform.getServerGBId()); - subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId()); + log.info("[平台离线] {}, 停止目录订阅回复", platform.getServerGBId()); + subscribeHolder.removeCatalogSubscribe(platform.getServerGBId()); } } - log.info("[平台离线] {}, 停止移动位置订阅回复", parentPlatform.getServerGBId()); - subscribeHolder.removeMobilePositionSubscribe(parentPlatform.getServerGBId()); + log.info("[平台离线] {}, 停止移动位置订阅回复", platform.getServerGBId()); + subscribeHolder.removeMobilePositionSubscribe(platform.getServerGBId()); // 发起定时自动重新注册 if (!stopRegister) { // 设置为60秒自动尝试重新注册 - final String registerFailAgainTaskKey = REGISTER_FAIL_AGAIN_KEY_PREFIX + parentPlatform.getServerGBId(); - Platform platform = platformMapper.getParentPlatById(parentPlatform.getId()); - if (platform.isEnable()) { + final String registerFailAgainTaskKey = REGISTER_FAIL_AGAIN_KEY_PREFIX + platform.getServerGBId(); + Platform platformInDb = platformMapper.query(platform.getId()); + if (platformInDb.isEnable()) { dynamicTask.startCron(registerFailAgainTaskKey, - ()-> registerTask(platform, null), + ()-> registerTask(platformInDb, null), userSetting.getRegisterAgainAfterTime() * 1000); } } @@ -428,15 +428,15 @@ public class PlatformServiceImpl implements IPlatformService { } @Override - public void login(Platform parentPlatform) { - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); + public void login(Platform platform) { + final String registerTaskKey = REGISTER_KEY_PREFIX + platform.getServerGBId(); try { - commanderForPlatform.register(parentPlatform, eventResult1 -> { - log.info("[国标级联] {},开始定时发起注册,间隔为1分钟", parentPlatform.getServerGBId()); + commanderForPlatform.register(platform, eventResult1 -> { + log.info("[国标级联] {},开始定时发起注册,间隔为1分钟", platform.getServerGBId()); // 添加注册任务 dynamicTask.startCron(registerTaskKey, // 注册失败(注册成功时由程序直接调用了online方法) - ()-> log.info("[国标级联] {},平台离线后持续发起注册,失败", parentPlatform.getServerGBId()), + ()-> log.info("[国标级联] {},平台离线后持续发起注册,失败", platform.getServerGBId()), 60*1000); }, null); } catch (InvalidArgumentException | ParseException | SipException e) { @@ -807,6 +807,6 @@ public class PlatformServiceImpl implements IPlatformService { @Override public Platform queryOne(Integer platformId) { - return platformMapper.getParentPlatById(platformId); + return platformMapper.query(platformId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java index 87f574e27..427e00b31 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java @@ -52,7 +52,7 @@ public class SIPRequestHeaderPlarformProvider { String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); //请求行 SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), - parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); + parentPlatform.getServerIp() + ":" + parentPlatform.getServerPort()); //via ArrayList viaHeaders = new ArrayList(); ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), @@ -93,7 +93,7 @@ public class SIPRequestHeaderPlarformProvider { Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, toTag, callIdHeader, expires); - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); + SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIp() + ":" + parentPlatform.getServerPort()); if (www == null) { AuthorizationHeader authorizationHeader = SipFactory.getInstance().createHeaderFactory().createAuthorizationHeader("Digest"); String username = parentPlatform.getUsername(); @@ -178,7 +178,7 @@ public class SIPRequestHeaderPlarformProvider { public Request createMessageRequest(Platform parentPlatform, String content, String fromTag, String viaTag, String toTag, CallIdHeader callIdHeader) throws PeerUnavailableException, ParseException, InvalidArgumentException { Request request = null; - String serverAddress = parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort(); + String serverAddress = parentPlatform.getServerIp()+ ":" + parentPlatform.getServerPort(); // sipuri SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); // via @@ -217,7 +217,7 @@ public class SIPRequestHeaderPlarformProvider { public SIPRequest createNotifyRequest(Platform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException { SIPRequest request = null; // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); + SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIp()+ ":" + parentPlatform.getServerPort()); // via ArrayList viaHeaders = new ArrayList<>(); ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), parentPlatform.getDevicePort(), @@ -277,7 +277,7 @@ public class SIPRequestHeaderPlarformProvider { SIPRequest request = null; // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); + SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIp()+ ":" + platform.getServerPort()); // via ArrayList viaHeaders = new ArrayList<>(); ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(platform.getDeviceIp(), platform.getDevicePort(), @@ -318,7 +318,7 @@ public class SIPRequestHeaderPlarformProvider { public Request createInviteRequest(Platform platform, String channelId, String content, String viaTag, String fromTag, String ssrc, CallIdHeader callIdHeader) throws PeerUnavailableException, ParseException, InvalidArgumentException { Request request = null; //请求行 - String platformHostAddress = platform.getServerIP() + ":" + platform.getServerPort(); + String platformHostAddress = platform.getServerIp() + ":" + platform.getServerPort(); String localHostAddress = sipLayer.getLocalIp(platform.getDeviceIp())+":"+ platform.getDevicePort(); SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, platformHostAddress); //via diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index 3615619ad..990e788b9 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -134,7 +134,7 @@ public abstract class SIPRequestProcessorParent { // 兼容国标中的使用编码@域名作为RequestURI的情况 SipURI sipURI = (SipURI)request.getRequestURI(); if (sipURI.getPort() == -1) { - sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+":"+platform.getServerPort()); + sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIp()+":"+platform.getServerPort()); } ResponseAckExtraParam responseAckExtraParam = new ResponseAckExtraParam(); responseAckExtraParam.contentTypeHeader = contentTypeHeader; @@ -155,7 +155,7 @@ public abstract class SIPRequestProcessorParent { SipURI sipURI = (SipURI)request.getRequestURI(); if (sipURI.getPort() == -1) { - sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+":"+platform.getServerPort()); + sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIp()+":"+platform.getServerPort()); } ResponseAckExtraParam responseAckExtraParam = new ResponseAckExtraParam(); responseAckExtraParam.contentTypeHeader = contentTypeHeader; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index c6e2bacea..7a303bcb0 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -1217,7 +1217,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements content.append("f=v/////a/1/8/1\r\n"); Platform parentPlatform = new Platform(); - parentPlatform.setServerIP(device.getIp()); + parentPlatform.setServerIp(device.getIp()); parentPlatform.setServerPort(device.getPort()); parentPlatform.setServerGBId(device.getDeviceId()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java index 302a7789f..3564e86c5 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java @@ -73,7 +73,7 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { String action = platformRegisterInfo.isRegister() ? "注册" : "注销"; log.info(String.format("[国标级联]%s %S响应,%s ", action, response.getStatusCode(), platformRegisterInfo.getPlatformId() )); - Platform parentPlatform = parentPlatformCatch.getParentPlatform(); + Platform parentPlatform = parentPlatformCatch.getPlatform(); if (parentPlatform == null) { log.warn(String.format("[国标级联]收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformRegisterInfo.getPlatformId(), action, response.getStatusCode())); return; diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 873708b7b..acda619da 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -64,25 +64,25 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } PlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); if (parentPlatform.getId() == null ) { - result = platformMapper.addParentPlatform(parentPlatform); + result = platformMapper.add(parentPlatform); if (parentPlatformCatch == null) { parentPlatformCatch = new PlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); + parentPlatformCatch.setPlatform(parentPlatform); parentPlatformCatch.setId(parentPlatform.getServerGBId()); } }else { if (parentPlatformCatch == null) { // serverGBId 已变化 - Platform parentPlatById = platformMapper.getParentPlatById(parentPlatform.getId()); + Platform parentPlatById = platformMapper.query(parentPlatform.getId()); // 使用旧的查出缓存ID parentPlatformCatch = new PlatformCatch(); parentPlatformCatch.setId(parentPlatform.getServerGBId()); redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); } - result = platformMapper.updateParentPlatform(parentPlatform); + result = platformMapper.update(parentPlatform); } // 更新缓存 - parentPlatformCatch.setParentPlatform(parentPlatform); + parentPlatformCatch.setPlatform(parentPlatform); redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); return result > 0; diff --git a/web_src/src/components/CloudRecord.vue b/web_src/src/components/CloudRecord.vue index 944097659..a9d1d0ffe 100755 --- a/web_src/src/components/CloudRecord.vue +++ b/web_src/src/components/CloudRecord.vue @@ -42,7 +42,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -88,7 +88,7 @@ - + @@ -25,8 +25,8 @@ - - + + @@ -47,16 +47,7 @@ - - - - - - - - - - + @@ -69,6 +60,13 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -108,10 +124,9 @@ - - - - + + +
@@ -134,7 +149,7 @@ export default { name: "platformEdit", - props: [ 'value', 'closeEdit'], + props: [ 'value', 'closeEdit', 'deviceIps'], components: { }, created() { @@ -164,35 +179,7 @@ export default { showDialog: false, isLoging: false, onSubmit_text: "立即创建", - saveUrl: "/api/platform/save", - platform: { - id: null, - enable: true, - ptz: true, - rtcp: false, - asMessageChannel: false, - autoPushChannel: false, - name: null, - serverGBId: null, - serverGBDomain: null, - serverIP: null, - serverPort: null, - deviceGBId: null, - deviceIp: null, - devicePort: null, - username: null, - password: null, - expires: 3600, - keepTimeout: 60, - transport: "UDP", - characterSet: "GB2312", - startOfflinePush: false, - catalogGroup: 1, - administrativeDivision: "", - sendStreamIp: null, - }, - deviceIps: [], // 存储用户设备IP数组 rules: { name: [{required: true, message: "请输入平台名称", trigger: "blur"}], serverGBId: [ @@ -201,7 +188,7 @@ export default { serverGBDomain: [ {required: true, message: "请输入SIP服务国标域", trigger: "blur"}, ], - serverIP: [{required: true, message: "请输入SIP服务IP", trigger: "blur"}], + serverIp: [{required: true, message: "请输入SIP服务IP", trigger: "blur"}], serverPort: [{required: true, message: "请输入SIP服务端口", trigger: "blur"}], deviceGBId: [{validator: deviceGBIdRules, trigger: "blur"}], username: [{required: false, message: "请输入SIP认证用户名", trigger: "blur"}], @@ -218,53 +205,73 @@ export default { }, methods: { onSubmit: function () { - console.log(typeof this.streamProxy.noneReader) this.saveLoading = true; - - this.noneReaderHandler(); - if (this.streamProxy.id) { + if (this.value.id) { this.$axios({ method: 'post', - url:`/api/proxy/update`, - data: this.streamProxy - }).then((res)=> { + url: "/api/platform/update", + data: this.value + }).then((res) => { this.saveLoading = false; - if (typeof (res.data.code) != "undefined" && res.data.code === 0) { - this.$message.success("保存成功"); - console.log(res.data.data) - this.streamProxy = res.data.data - }else { - this.$message.error(res.data.msg); + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: "保存成功", + type: "success", + }); + this.showDialog = false; + if (this.closeEdit) { + this.closeEdit(); + } + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: "error", + }); } + }).catch((error) => { this.saveLoading = false; - }).catch((error) =>{ - this.$message.error(error); - this.saveLoading = false; - }).finally(()=>{ - console.log("finally==finally") - this.saveLoading = false; - }) + console.log(error); + }); }else { this.$axios({ method: 'post', - url:`/api/proxy/add`, - data: this.streamProxy - }).then((res)=> { + url: "/api/platform/add", + data: this.value + }).then((res) => { this.saveLoading = false; - if (typeof (res.data.code) != "undefined" && res.data.code === 0) { - this.$message.success("保存成功"); - this.streamProxy = res.data.data - }else { - this.$message.error(res.data.msg); + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: "保存成功", + type: "success", + }); + if (this.closeEdit) { + this.closeEdit(); + } + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: "error", + }); } - }).catch((error) =>{ - this.$message.error(res.data.error); + }).catch((error) => { this.saveLoading = false; - }).finally(()=>{ - this.saveLoading = false; - }) + console.log(error); + }); } + + }, + serverGBIdChange: function () { + if (this.value.serverGBId.length > 10) { + this.value.serverGBDomain = this.value.serverGBId.substr(0, 10); + } + }, + deviceGBIdChange: function () { + this.value.username = this.value.deviceGBId; }, checkExpires: function () { if (this.value.enable && this.value.expires === "0") { diff --git a/web_src/src/components/PlatformList.vue b/web_src/src/components/PlatformList.vue index f07087bf4..9f6614a66 100755 --- a/web_src/src/components/PlatformList.vue +++ b/web_src/src/components/PlatformList.vue @@ -10,7 +10,7 @@ - + @@ -32,7 +32,7 @@ @@ -53,13 +53,13 @@ - + @@ -118,8 +118,7 @@ export default { this.platform = this.defaultPlatform; }, editPlatform: function(platform) { - console.log(platform) - this.$refs.platformEdit.openDialog(platform, this.initData) + this.platform = platform; }, closeEdit: function() { this.platform = null; @@ -154,8 +153,8 @@ export default { }); }, chooseChannel: function(platform) { - console.log("platform.name: " + platform.name) - this.$refs.chooseChannelDialog.openDialog(platform.serverGBId,platform.deviceGBId, platform.name, platform.catalogId, this.initData) + console.log("platform.name: " + platform.name) + this.$refs.chooseChannelDialog.openDialog(platform.serverGBId,platform.deviceGBId, platform.name, platform.catalogId, this.initData) }, initData: function() { this.$axios({ @@ -174,7 +173,7 @@ export default { name: null, serverGBId: null, serverGBDomain: null, - serverIP: null, + serverIp: null, serverPort: null, deviceGBId: res.data.data.username, deviceIp: this.deviceIps[0], @@ -186,8 +185,16 @@ export default { transport: "UDP", characterSet: "GB2312", startOfflinePush: false, + customGroup: false, + catalogWithPlatform: false, + catalogWithGroup: false, + catalogWithRegion: false, + manufacturer: null, + model: null, + address: null, + secrecy: 1, catalogGroup: 1, - administrativeDivision: res.data.data.username.substr(0, 6), + civilCode: null, sendStreamIp: res.data.data.sendStreamIp, } } diff --git a/web_src/src/components/StreamProxyList.vue b/web_src/src/components/StreamProxyList.vue index d1c4b888c..dbdd8a83f 100755 --- a/web_src/src/components/StreamProxyList.vue +++ b/web_src/src/components/StreamProxyList.vue @@ -32,7 +32,7 @@ - + @@ -89,7 +89,7 @@ - @@ -85,7 +85,7 @@ - @@ -64,7 +64,7 @@ - @@ -35,7 +35,7 @@ - @@ -150,7 +150,7 @@ - + @@ -56,7 +56,7 @@ 全部移除 - + @@ -51,7 +51,7 @@ - + diff --git a/web_src/src/components/dialog/chooseChannelForStream.vue b/web_src/src/components/dialog/chooseChannelForStream.vue index fd57421a5..71209fcfb 100755 --- a/web_src/src/components/dialog/chooseChannelForStream.vue +++ b/web_src/src/components/dialog/chooseChannelForStream.vue @@ -27,7 +27,7 @@ 全部添加 全部移除 - + @@ -55,7 +55,7 @@ - + diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue deleted file mode 100755 index 0a7522229..000000000 --- a/web_src/src/components/dialog/platformEdit.vue +++ /dev/null @@ -1,543 +0,0 @@ - - - - - diff --git a/web_src/src/components/group.vue b/web_src/src/components/group.vue index 375b8b5fa..5e503546d 100755 --- a/web_src/src/components/group.vue +++ b/web_src/src/components/group.vue @@ -37,7 +37,7 @@ - @@ -74,7 +74,7 @@ - @@ -74,7 +74,7 @@