From 4912ce16ec715d45aa9b97aa730f0c568621edf4 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Mon, 8 Jul 2024 17:44:35 +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
---
.../gb28181/dao/CommonGBChannelMapper.java | 345 +++++++++++++-----
.../service/impl/GbChannelServiceImpl.java | 59 ++-
.../vmp/service/impl/PlatformServiceImpl.java | 7 -
.../impl/VideoManagerStorageImpl.java | 3 -
.../service/impl/StreamProxyServiceImpl.java | 14 +-
.../controller/StreamPushController.java | 2 +-
.../enent/StreamPushUploadFileHandler.java | 2 +-
数据库/2.7.2-重构/初始化-mysql-2.7.2.sql | 8 +-
8 files changed, 317 insertions(+), 123 deletions(-)
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 e1755f31..c100e9ab 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
@@ -203,101 +203,276 @@ public interface CommonGBChannelMapper {
" where id = #{gbId}")
CommonGBChannel queryById(@Param("gbId") int gbId);
- @Delete("delete from wvp_device_channel where id = #{gbId} ")
+ @Delete(value = {"delete from wvp_device_channel where id = #{gbId} "})
void delete(int gbId);
@Update(value = {" "})
int update(CommonGBChannel commonGBChannel);
- int updateStatus(@Param("gbId") int gbId, @Param("status") int status);
+ @Update(value = {" "})
+ int updateStatusById(@Param("gbId") int gbId, @Param("status") int status);
- int updateStatusForList(List commonGBChannels, @Param("status") int status);
+ @Update("")
+ int updateStatusForListById(List commonGBChannels, @Param("status") int status);
+ @Select(value = {" "})
List queryInListByStatus(List commonGBChannelList, @Param("status") int status);
+
+
+ @Insert(" ")
+ int batchAdd(List commonGBChannels);
+
+ @Update("")
+ int updateStatus(List commonGBChannels);
+
+ @Select(value = {"select\n" +
+ " wdc.id as gb_id,\n" +
+ " wdc.device_db_id,\n" +
+ " wdc.create_time,\n" +
+ " wdc.update_time,\n" +
+ " wdc.sub_count,\n" +
+ " wdc.stream_id,\n" +
+ " wdc.has_audio,\n" +
+ " wdc.gps_time,\n" +
+ " wdc.stream_identification,\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.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" +
+ " coalesce(wdc.gb_block, wdc.block) as gb_block,\n" +
+ " coalesce(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.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" +
+ "from wvp_device_channel wdc left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id\n" +
+ "where wpgc.platform_id = #{platformId}"})
+ List queryByPlatformId(@Param("platformId") Integer platformId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
index ec7a7f94..6e0d671f 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
@@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.Collections;
import java.util.List;
@Slf4j
@@ -72,7 +71,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
log.warn("[通道离线] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId());
return 0;
}
- int result = commonGBChannelMapper.updateStatus(commonGBChannel.getGbId(), 0);
+ int result = commonGBChannelMapper.updateStatusById(commonGBChannel.getGbId(), 0);
if (result > 0) {
try {
// 发送通知
@@ -104,10 +103,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (i + limitCount > onlineChannelList.size()) {
toIndex = onlineChannelList.size();
}
- result += commonGBChannelMapper.updateStatusForList(onlineChannelList.subList(i, toIndex), 0);
+ result += commonGBChannelMapper.updateStatusForListById(onlineChannelList.subList(i, toIndex), 0);
}
}else {
- result += commonGBChannelMapper.updateStatusForList(onlineChannelList, 0);
+ result += commonGBChannelMapper.updateStatusForListById(onlineChannelList, 0);
}
if (result > 0) {
try {
@@ -126,7 +125,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
log.warn("[通道上线] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId());
return 0;
}
- int result = commonGBChannelMapper.updateStatus(commonGBChannel.getGbId(), 1);
+ int result = commonGBChannelMapper.updateStatusById(commonGBChannel.getGbId(), 1);
if (result > 0) {
try {
// 发送通知
@@ -159,10 +158,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (i + limitCount > offlineChannelList.size()) {
toIndex = offlineChannelList.size();
}
- result += commonGBChannelMapper.updateStatusForList(offlineChannelList.subList(i, toIndex), 1);
+ result += commonGBChannelMapper.updateStatusForListById(offlineChannelList.subList(i, toIndex), 1);
}
}else {
- result += commonGBChannelMapper.updateStatusForList(offlineChannelList, 1);
+ result += commonGBChannelMapper.updateStatusForListById(offlineChannelList, 1);
}
if (result > 0) {
try {
@@ -177,29 +176,55 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
+ @Transactional
public void batchAdd(List commonGBChannels) {
-
+ if (commonGBChannels.isEmpty()) {
+ log.warn("[新增多个通道] 通道数量为0,更新失败");
+ return;
+ }
+ // 批量保存
+ int limitCount = 1000;
+ int result = 0;
+ if (commonGBChannels.size() > limitCount) {
+ for (int i = 0; i < commonGBChannels.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > commonGBChannels.size()) {
+ toIndex = commonGBChannels.size();
+ }
+ result += commonGBChannelMapper.batchAdd(commonGBChannels.subList(i, toIndex));
+ }
+ }else {
+ result += commonGBChannelMapper.batchAdd(commonGBChannels);
+ }
+ log.warn("[新增多个通道] 通道数量为{},成功保存:{}", commonGBChannels.size(), result);
}
@Override
@Transactional
- public void updateStatus(List channelList) {
- if (channelList.isEmpty()) {
+ public void updateStatus(List commonGBChannels) {
+ if (commonGBChannels.isEmpty()) {
log.warn("[更新多个通道状态] 通道数量为0,更新失败");
return;
}
- for (CommonGBChannel channel : channelList) {
- if (channel.getGbStatus() == 1) {
- online(channel);
- }else {
- offline(channel);
+ int limitCount = 1000;
+ int result = 0;
+ if (commonGBChannels.size() > limitCount) {
+ for (int i = 0; i < commonGBChannels.size(); i += limitCount) {
+ int toIndex = i + limitCount;
+ if (i + limitCount > commonGBChannels.size()) {
+ toIndex = commonGBChannels.size();
+ }
+ result += commonGBChannelMapper.updateStatus(commonGBChannels.subList(i, toIndex));
}
-
+ }else {
+ result += commonGBChannelMapper.updateStatus(commonGBChannels);
}
+ log.warn("[更新多个通道状态] 通道数量为{},成功保存:{}", commonGBChannels.size(), result);
}
@Override
public List queryByPlatformId(Integer platformId) {
- return Collections.emptyList();
+
+ return commonGBChannelMapper.queryByPlatformId(platformId);
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
index 6af3c1f2..7cca6d95 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -165,10 +165,6 @@ public class PlatformServiceImpl implements IPlatformService {
// 每次发送目录的数量默认为1
parentPlatform.setCatalogGroup(1);
}
- if (parentPlatform.getAdministrativeDivision() == null) {
- // 行政区划默认去编号的前6位
- parentPlatform.setAdministrativeDivision(parentPlatform.getServerGBId().substring(0,6));
- }
parentPlatform.setCatalogId(parentPlatform.getDeviceGBId());
int result = platformMapper.addParentPlatform(parentPlatform);
// 添加缓存
@@ -221,9 +217,6 @@ public class PlatformServiceImpl implements IPlatformService {
if (parentPlatform.getCatalogGroup() == 0) {
parentPlatform.setCatalogGroup(1);
}
- if (parentPlatform.getAdministrativeDivision() == null) {
- parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision());
- }
platformMapper.updateParentPlatform(parentPlatform);
// 更新redis
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 4f991985..980d1588 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
@@ -203,9 +203,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
if (parentPlatform.getCatalogGroup() == 0) {
parentPlatform.setCatalogGroup(1);
}
- if (parentPlatform.getAdministrativeDivision() == null) {
- parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision());
- }
ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
if (parentPlatform.getId() == null ) {
if (parentPlatform.getCatalogId() == null) {
diff --git a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java
index 4a0360d7..9b2e84ca 100755
--- a/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/streamProxy/service/impl/StreamProxyServiceImpl.java
@@ -317,8 +317,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|| streamInfo.getOriginType() == OriginType.FFMPEG_PULL.ordinal() ) {
if (streamProxyMapForDb.get(key) != null) {
redisCatchStorage.addStream(mediaServer, "pull", streamInfo.getApp(), streamInfo.getStream(), streamInfo.getMediaInfo());
- if (!streamProxy.getGbStatus() && streamProxy.getGbId() > 0) {
- streamProxy.setGbStatus(true);
+ if (streamProxy.getGbStatus() == 1 && streamProxy.getGbId() > 0) {
+ streamProxy.setGbStatus(1);
channelListForOnline.add(streamProxy.getCommonGBChannel());
}
streamProxyMapForDb.remove(key);
@@ -333,8 +333,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
List streamProxiesForRemove = new ArrayList<>();
if (!streamProxyMapForDb.isEmpty()) {
for (StreamProxy streamProxy : streamProxyMapForDb.values()) {
- if (streamProxy.getGbStatus() && streamProxy.getGbId() > 0) {
- streamProxy.setGbStatus(false);
+ if (streamProxy.getGbStatus() == 0 && streamProxy.getGbId() > 0) {
+ streamProxy.setGbStatus(0);
channelListForOffline.add(streamProxy.getCommonGBChannel());
}
// 移除开启了无人观看自动移除的流
@@ -375,13 +375,13 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
List channelListForOffline = new ArrayList<>();
for (StreamProxy streamProxy : streamProxies) {
- if (streamProxy.getGbId() > 0 && streamProxy.getGbStatus()) {
+ if (streamProxy.getGbId() > 0 && streamProxy.getGbStatus() == 1) {
channelListForOffline.add(streamProxy.getCommonGBChannel());
}
if (streamProxy.getGbId() == 0 && streamProxy.isEnableRemoveNoneReader()) {
streamProxiesForRemove.add(streamProxy);
}
- if (streamProxy.getGbStatus()) {
+ if (streamProxy.getGbStatus() == 1) {
streamProxiesForSendMessage.add(streamProxy);
}
}
@@ -411,7 +411,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
if (streamProxyItem == null) {
return 0;
}
- streamProxyItem.setGbStatus(status);
+ streamProxyItem.setGbStatus(status?1:0);
if (streamProxyItem.getGbId() > 0) {
if (status) {
gbChannelService.online(streamProxyItem.getCommonGBChannel());
diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java
index 68a4a064..094fdf4c 100755
--- a/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java
+++ b/src/main/java/com/genersoft/iot/vmp/streamPush/controller/StreamPushController.java
@@ -239,7 +239,7 @@ public class StreamPushController {
if (ObjectUtils.isEmpty(stream.getApp()) && ObjectUtils.isEmpty(stream.getStream())) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "app或stream不可为空");
}
- stream.setGbStatus(false);
+ stream.setGbStatus(0);
stream.setPushIng(false);
if (!streamPushService.add(stream)) {
throw new ControllerException(ErrorCode.ERROR100);
diff --git a/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java b/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java
index fda694ba..09ac285d 100755
--- a/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/streamPush/enent/StreamPushUploadFileHandler.java
@@ -104,7 +104,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener