临时提交

pull/1642/head
648540858 2024-08-06 16:55:33 +08:00
parent 9bbc3c44e0
commit d97accee4a
27 changed files with 417 additions and 499 deletions

View File

@ -35,10 +35,10 @@ public class GbCode {
code = code.trim();
GbCode gbCode = new GbCode();
gbCode.setCenterCode(code.substring(0, 8));
gbCode.setIndustryCode(code.substring(9, 10));
gbCode.setTypeCode(code.substring(11, 13));
gbCode.setNetCode(code.substring(14, 15));
gbCode.setSn(code.substring(15, 20));
gbCode.setIndustryCode(code.substring(8, 10));
gbCode.setTypeCode(code.substring(10, 13));
gbCode.setNetCode(code.substring(13, 14));
gbCode.setSn(code.substring(14));
return gbCode;
}

View File

@ -34,28 +34,18 @@ public class GroupTree {
@Schema(description = "父区域国标ID")
private String parentDeviceId;
/**
* ID
*/
@Schema(description = "父区域国标ID")
private String businessGroup;
@Schema(description = "是否有子节点")
private boolean isLeaf;
@Schema(description = "类型, 行政区划:0 摄像头: 1")
private int type;
public static GroupTree getInstance(Region region) {
GroupTree regionTree = new GroupTree();
regionTree.setId(region.getDeviceId());
regionTree.setLabel(region.getName());
regionTree.setParentDeviceId(region.getParentDeviceId());
regionTree.setType(0);
if (region.getDeviceId().length() < 8) {
regionTree.setLeaf(false);
}else {
regionTree.setLeaf(true);
}
return regionTree;
}
public static GroupTree getInstance(CommonGBChannel channel) {
GroupTree regionTree = new GroupTree();
regionTree.setId(channel.getGbDeviceId());

View File

@ -5,7 +5,9 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceType;
import com.genersoft.iot.vmp.gb28181.bean.IndustryCodeType;
import com.genersoft.iot.vmp.gb28181.bean.NetworkIdentificationType;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionBYGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToGroupByGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToGroupParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionByGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionParam;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.media.service.IMediaServerService;
@ -119,16 +121,54 @@ public class CommonChannelController {
@Operation(summary = "通道设置行政区划-根据国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/region/device/add")
public void addChannelToRegionBYGbDevice(@RequestBody ChannelToRegionBYGbDeviceParam param){
public void addChannelToRegionByGbDevice(@RequestBody ChannelToRegionByGbDeviceParam param){
Assert.notEmpty(param.getDeviceIds(),"参数异常");
Assert.hasLength(param.getCivilCode(),"未添加行政区划");
channelService.addChannelToRegionBYGbDevice(param.getCivilCode(), param.getDeviceIds());
channelService.addChannelToRegionByGbDevice(param.getCivilCode(), param.getDeviceIds());
}
@Operation(summary = "通道删除行政区划-根据国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/region/device/delete")
public void deleteChannelToRegionBYGbDevice(@RequestBody ChannelToRegionBYGbDeviceParam param){
public void deleteChannelToRegionByGbDevice(@RequestBody ChannelToRegionByGbDeviceParam param){
Assert.notEmpty(param.getDeviceIds(),"参数异常");
channelService.deleteChannelToRegionBYGbDevice(param.getDeviceIds());
channelService.deleteChannelToRegionByGbDevice(param.getDeviceIds());
}
@Operation(summary = "通道设置业务分组", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/group/add")
public void addChannelToGroup(@RequestBody ChannelToGroupParam param){
Assert.notEmpty(param.getChannelIds(),"通道ID不可为空");
Assert.hasLength(param.getParentId(),"未添加上级分组编号");
Assert.hasLength(param.getBusinessGroup(),"未添加业务分组");
channelService.addChannelToGroup(param.getParentId(), param.getBusinessGroup(), param.getChannelIds());
}
@Operation(summary = "通道删除业务分组", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/group/delete")
public void deleteChannelToGroup(@RequestBody ChannelToGroupParam param){
Assert.isTrue(!param.getChannelIds().isEmpty()
|| (!ObjectUtils.isEmpty(param.getParentId()) && !ObjectUtils.isEmpty(param.getBusinessGroup())),
"参数异常");
channelService.deleteChannelToGroup(param.getParentId(), param.getBusinessGroup(), param.getChannelIds());
}
@Operation(summary = "通道设置业务分组-根据国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/group/device/add")
public void addChannelToGroupByGbDevice(@RequestBody ChannelToGroupByGbDeviceParam param){
Assert.notEmpty(param.getDeviceIds(),"参数异常");
Assert.hasLength(param.getParentId(),"未添加上级分组编号");
Assert.hasLength(param.getBusinessGroup(),"未添加业务分组");
channelService.addChannelToGroupByGbDevice(param.getParentId(), param.getBusinessGroup(), param.getDeviceIds());
}
@Operation(summary = "通道删除业务分组-根据国标设备", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/group/device/delete")
public void deleteChannelToGroupByGbDevice(@RequestBody ChannelToGroupByGbDeviceParam param){
Assert.notEmpty(param.getDeviceIds(),"参数异常");
channelService.deleteChannelToGroupByGbDevice(param.getDeviceIds());
}
}

View File

@ -255,7 +255,7 @@ public class PlatformController {
}
boolean deleteResult = storager.deleteParentPlatform(parentPlatform);
storager.delCatalogByPlatformId(parentPlatform.getServerGBId());
// storager.delCatalogByPlatformId(parentPlatform.getServerGBId());
storager.delRelationByPlatformId(parentPlatform.getServerGBId());
// 停止发送位置订阅定时任务
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId();
@ -382,124 +382,6 @@ public class PlatformController {
}
}
/**
*
*
* @param platformId ID
* @param parentId ID
* @return
*/
@Operation(summary = "获取目录", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "platformId", description = "上级平台的国标编号", required = true)
@Parameter(name = "parentId", description = "父级目录的国标编号", required = true)
@GetMapping("/catalog")
@ResponseBody
public List<PlatformCatalog> getCatalogByPlatform(String platformId, String parentId) {
if (log.isDebugEnabled()) {
log.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId);
}
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
if (platform == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台未找到");
}
// if (platformId.equals(parentId)) {
// parentId = platform.getDeviceGBId();
// }
if (platformId.equals(platform.getDeviceGBId())) {
parentId = null;
}
return storager.getChildrenCatalogByPlatform(platformId, parentId);
}
/**
*
*
* @param platformCatalog
* @return
*/
@Operation(summary = "添加目录", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/catalog/add")
@ResponseBody
public void addCatalog(@RequestBody PlatformCatalog platformCatalog) {
if (log.isDebugEnabled()) {
log.debug("添加目录,{}", JSON.toJSONString(platformCatalog));
}
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId());
if (platformCatalogInStore != null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists");
}
int addResult = storager.addCatalog(platformCatalog);
if (addResult <= 0) {
throw new ControllerException(ErrorCode.ERROR100);
}
}
/**
*
*
* @param platformCatalog
* @return
*/
@Operation(summary = "编辑目录", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping("/catalog/edit")
@ResponseBody
public void editCatalog(@RequestBody PlatformCatalog platformCatalog) {
if (log.isDebugEnabled()) {
log.debug("编辑目录,{}", JSON.toJSONString(platformCatalog));
}
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId());
if (platformCatalogInStore == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists");
}
int addResult = storager.updateCatalog(platformCatalog);
if (addResult <= 0) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
}
}
/**
*
*
* @param id Id
* @param platformId Id
* @return
*/
@Operation(summary = "删除目录", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "id", description = "目录Id", required = true)
@Parameter(name = "platformId", description = "平台Id", required = true)
@DeleteMapping("/catalog/del")
@ResponseBody
public void delCatalog(String id, String platformId) {
if (log.isDebugEnabled()) {
log.debug("删除目录,{}", id);
}
if (ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(platformId)) {
throw new ControllerException(ErrorCode.ERROR400);
}
int delResult = storager.delCatalog(platformId, id);
// 如果删除的是默认目录则根目录设置为默认目录
PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId);
// 默认节点被移除
if (parentPlatform == null) {
storager.setDefaultCatalog(platformId, platformId);
}
if (delResult <= 0) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
}
}
/**
*
*
@ -522,29 +404,4 @@ public class PlatformController {
}
/**
*
*
* @param platformId Id
* @param catalogId Id
* @return
*/
@Operation(summary = "修改默认目录", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "catalogId", description = "目录Id", required = true)
@Parameter(name = "platformId", description = "平台Id", required = true)
@PostMapping("/catalog/default/update")
@ResponseBody
public void setDefaultCatalog(String platformId, String catalogId) {
if (log.isDebugEnabled()) {
log.debug("修改默认目录,{},{}", platformId, catalogId);
}
int updateResult = storager.setDefaultCatalog(platformId, catalogId);
if (updateResult <= 0) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
}
}
}

View File

@ -0,0 +1,12 @@
package com.genersoft.iot.vmp.gb28181.controller.bean;
import lombok.Data;
import java.util.List;
@Data
public class ChannelToGroupByGbDeviceParam {
private List<Integer> deviceIds;
private String parentId;
private String businessGroup;
}

View File

@ -0,0 +1,14 @@
package com.genersoft.iot.vmp.gb28181.controller.bean;
import lombok.Data;
import java.util.List;
@Data
public class ChannelToGroupParam {
private String parentId;
private String businessGroup;
private List<Integer> channelIds;
}

View File

@ -5,7 +5,7 @@ import lombok.Data;
import java.util.List;
@Data
public class ChannelToRegionBYGbDeviceParam {
public class ChannelToRegionByGbDeviceParam {
private List<Integer> deviceIds;
private String civilCode;
}

View File

@ -380,7 +380,7 @@ public interface CommonGBChannelMapper {
" WHERE id in "+
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
" </script>"})
void updateBusinessGroupByChannelList(@Param("businessGroup") String businessGroup, List<CommonGBChannel> channelList);
int updateBusinessGroupByChannelList(@Param("businessGroup") String businessGroup, List<CommonGBChannel> channelList);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
@ -388,5 +388,15 @@ public interface CommonGBChannelMapper {
" WHERE id in "+
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
" </script>"})
void updateParentIdByChannelList(@Param("parentId") String parentId, List<CommonGBChannel> channelList);
int updateParentIdByChannelList(@Param("parentId") String parentId, List<CommonGBChannel> channelList);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_parent_id = #{parentId}, gb_business_group_id = #{businessGroup}" +
" WHERE id in "+
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbId}</foreach>" +
" </script>"})
int updateGroup(@Param("parentId") String parentId, @Param("businessGroup") String businessGroup,
List<CommonGBChannel> channelList);
}

View File

@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
import org.apache.ibatis.annotations.*;
@ -16,6 +15,11 @@ public interface GroupMapper {
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
int add(Group group);
@Insert("INSERT INTO wvp_common_group (device_id, name, business_group, platform_id, create_time, update_time) " +
"VALUES (#{deviceId}, #{name}, #{businessGroup}, #{platformId}, #{createTime}, #{updateTime})")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
int addBusinessGroup(Group group);
@Delete("DELETE FROM wvp_common_group WHERE id=#{id}")
int delete(@Param("id") int id);
@ -61,11 +65,12 @@ public interface GroupMapper {
" device_id," +
" name, " +
" parent_device_id," +
" business_group," +
" create_time," +
" update_time) " +
" VALUES " +
" <foreach collection='groupList' index='index' item='item' separator=','> " +
" (#{item.deviceId}, #{item.name}, #{item.parentDeviceId},#{item.createTime},#{item.updateTime})" +
" (#{item.deviceId}, #{item.name}, #{item.parentDeviceId}, #{item.businessGroup},#{item.createTime},#{item.updateTime})" +
" </foreach> " +
" </script>")
int batchAdd(List<Group> groupList);
@ -75,20 +80,40 @@ public interface GroupMapper {
" device_id as id," +
" name as label, " +
" parent_device_id," +
" business_group," +
" id as db_id," +
" 0 as type," +
" false as is_leaf" +
" from wvp_common_group " +
" where " +
" <if test='parentId != null'> parent_device_id = #{parentId} </if> " +
" <if test='parentId == null'> parent_device_id is null </if> " +
" <if test='platformId != null'> platform_id = #{platformId} </if> " +
" <if test='platformId == null'> platform_id is null </if> " +
" where 1=1 " +
" <if test='parentId != null'> and parent_device_id = #{parentId} </if> " +
" <if test='parentId == null'> and parent_device_id is null </if> " +
" <if test='platformId != null'> and platform_id = #{platformId} </if> " +
" <if test='platformId == null'> and platform_id is null </if> " +
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
" </script>")
List<GroupTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId,
@Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT " +
" device_id as id," +
" name as label, " +
" parent_device_id," +
" business_group," +
" id as db_id," +
" 0 as type," +
" false as is_leaf" +
" from wvp_common_group " +
" where parent_device_id is null and business_group = #{businessGroup} and device_id != #{businessGroup}" +
" <if test='platformId != null'> and platform_id = #{platformId} </if> " +
" <if test='platformId == null'> and platform_id is null </if> " +
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
" </script>")
List<GroupTree> queryForTreeByBusinessGroup(@Param("query") String query,
@Param("businessGroup") String businessGroup,
@Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT " +
" device_id as id," +
@ -123,5 +148,8 @@ public interface GroupMapper {
@Delete("DELETE FROM wvp_common_group WHERE business_group = #{businessGroup}")
int deleteByBusinessGroup(@Param("businessGroup") String businessGroup);
@Update(" UPDATE wvp_common_group " +
" SET parent_device_id=#{group.deviceId}, business_group = #{group.businessGroup}" +
" WHERE parent_device_id = #{oldDeviceId}")
int updateChild(@Param("oldDeviceId") String oldDeviceId, Group group);
}

View File

@ -118,5 +118,5 @@ public interface PlatformChannelMapper {
List<Device> queryDeviceInfoByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
@Select("SELECT pgc.platform_id from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.device_id=#{channelId}")
List<String> queryParentPlatformByChannelId(@Param("channelId") String channelId);
List<Integer> queryParentPlatformByChannelId(@Param("channelId") String channelId);
}

View File

@ -208,7 +208,7 @@ public class ChannelProvider {
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(getBaseSelectSql());
sqlBuild.append(" gb_business_group_id in ( ");
sqlBuild.append(" where gb_business_group_id in ( ");
Collection<Group> ids = (Collection<Group>)params.get("groupList");
boolean first = true;
for (Group group : ids) {

View File

@ -52,7 +52,7 @@ public class EventPublisher {
}
public void catalogEventPublish(String platformId, CommonGBChannel deviceChannel, String type) {
public void catalogEventPublish(Integer platformId, CommonGBChannel deviceChannel, String type) {
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
deviceChannelList.add(deviceChannel);
catalogEventPublish(platformId, deviceChannelList, type);
@ -72,7 +72,7 @@ public class EventPublisher {
* @param deviceChannels
* @param type
*/
public void catalogEventPublish(String platformId, List<CommonGBChannel> deviceChannels, String type) {
public void catalogEventPublish(Integer platformId, List<CommonGBChannel> deviceChannels, String type) {
CatalogEvent outEvent = new CatalogEvent(this);
List<CommonGBChannel> channels = new ArrayList<>();
if (deviceChannels.size() > 1) {

View File

@ -58,6 +58,6 @@ public class CatalogEvent extends ApplicationEvent {
@Setter
@Getter
private String platformId;
private Integer platformId;
}

View File

@ -1,17 +1,16 @@
package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
@ -31,15 +30,15 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
@Autowired
private IVideoManagerStorage storager;
@Autowired
private IPlatformService platformService;
@Autowired
private ISIPCommanderForPlatform sipCommanderFroPlatform;
@Autowired
private SubscribeHolder subscribeHolder;
@Autowired
private UserSetting userSetting;
@Override
public void onApplicationEvent(CatalogEvent event) {
SubscribeInfo subscribe = null;
@ -47,13 +46,13 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
Map<String, CommonGBChannel> channelMap = new HashMap<>();
if (!ObjectUtils.isEmpty(event.getPlatformId())) {
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
if (subscribe == null) {
if (event.getPlatformId() != null) {
parentPlatform = platformService.queryOne(event.getPlatformId());
if (parentPlatform == null) {
return;
}
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
if (parentPlatform != null && !parentPlatform.isStatus()) {
subscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId());
if (subscribe == null) {
return;
}
@ -61,7 +60,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
// 获取所用订阅
List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform();
if (event.getChannels() != null) {
if (platforms.size() > 0) {
if (!platforms.isEmpty()) {
for (CommonGBChannel deviceChannel : event.getChannels()) {
List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(deviceChannel.getGbDeviceId(), platforms);
parentPlatformMap.put(deviceChannel.getGbDeviceId(), parentPlatformsForGB);
@ -75,13 +74,13 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
case CatalogEvent.OFF:
case CatalogEvent.DEL:
if (parentPlatform != null || subscribe != null) {
if (parentPlatform != null) {
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
if (event.getChannels() != null) {
deviceChannelList.addAll(event.getChannels());
}
if (deviceChannelList.size() > 0) {
log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size());
if (!deviceChannelList.isEmpty()) {
log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), parentPlatform.getServerGBId(), deviceChannelList.size());
try {
sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe, null);
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
@ -89,10 +88,10 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
log.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage());
}
}
}else if (parentPlatformMap.keySet().size() > 0) {
}else if (!parentPlatformMap.keySet().isEmpty()) {
for (String gbId : parentPlatformMap.keySet()) {
List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId);
if (parentPlatforms != null && parentPlatforms.size() > 0) {
if (parentPlatforms != null && !parentPlatforms.isEmpty()) {
for (ParentPlatform platform : parentPlatforms) {
SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
if (subscribeInfo == null) {
@ -120,13 +119,13 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
break;
case CatalogEvent.ADD:
case CatalogEvent.UPDATE:
if (parentPlatform != null || subscribe != null) {
if (parentPlatform != null) {
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
if (event.getChannels() != null) {
deviceChannelList.addAll(event.getChannels());
}
if (!deviceChannelList.isEmpty()) {
log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size());
log.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), parentPlatform.getServerGBId(), deviceChannelList.size());
try {
sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe, null);
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |

View File

@ -54,9 +54,9 @@ public interface IGbChannelService {
void deleteChannelToRegionByChannelIds(List<Integer> channelIds);
void addChannelToRegionBYGbDevice(String civilCode, List<Integer> deviceIds);
void addChannelToRegionByGbDevice(String civilCode, List<Integer> deviceIds);
void deleteChannelToRegionBYGbDevice(List<Integer> deviceIds);
void deleteChannelToRegionByGbDevice(List<Integer> deviceIds);
void removeParentIdByBusinessGroup(String businessGroup);
@ -65,4 +65,12 @@ public interface IGbChannelService {
void updateBusinessGroup(String oldBusinessGroup, String newBusinessGroup);
void updateParentIdGroup(String oldParentId, String newParentId);
void addChannelToGroup(String parentId, String businessGroup, List<Integer> channelIds);
void deleteChannelToGroup(String parentId, String businessGroup, List<Integer> channelIds);
void addChannelToGroupByGbDevice(String parentId, String businessGroup, List<Integer> deviceIds);
void deleteChannelToGroupByGbDevice(List<Integer> deviceIds);
}

View File

@ -82,4 +82,6 @@ public interface IPlatformService {
void stopBroadcast(ParentPlatform platform, DeviceChannel channel, String stream,boolean sendBye, MediaServer mediaServerItem);
void addSimulatedSubscribeInfo(ParentPlatform parentPlatform);
ParentPlatform queryOne(Integer platformId);
}

View File

@ -457,9 +457,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
deviceChannel.setHasAudio(channelInDb.isHasAudio());
deviceChannel.setId(channelInDb.getId());
if (channelInDb.getStatus().equalsIgnoreCase(deviceChannel.getStatus())){
List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId());
if (!CollectionUtils.isEmpty(strings)){
strings.forEach(platformId->{
List<Integer> ids = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getDeviceId());
if (!CollectionUtils.isEmpty(ids)){
ids.forEach(platformId->{
eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.getStatus().equals("ON")? CatalogEvent.ON:CatalogEvent.OFF);
});
}

View File

@ -342,6 +342,9 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
for (CommonGBChannel channel : channelList) {
channel.setGbCivilCode(civilCode);
}
int result = commonGBChannelMapper.updateRegion(civilCode, channelList);
// 发送通知
if (result > 0) {
@ -402,11 +405,14 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
public void addChannelToRegionBYGbDevice(String civilCode, List<Integer> deviceIds) {
public void addChannelToRegionByGbDevice(String civilCode, List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
for (CommonGBChannel channel : channelList) {
channel.setGbCivilCode(civilCode);
}
int result = commonGBChannelMapper.updateRegion(civilCode, channelList);
// 发送通知
if (result > 0) {
@ -420,7 +426,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
public void deleteChannelToRegionBYGbDevice(List<Integer> deviceIds) {
public void deleteChannelToRegionByGbDevice(List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
@ -431,7 +437,9 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public void removeParentIdByBusinessGroup(String businessGroup) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByBusinessGroup(businessGroup);
Assert.notEmpty(channelList, "所有业务分组的通道不存在");
if (channelList.isEmpty()) {
return;
}
int result = commonGBChannelMapper.removeParentIdByChannels(channelList);
}
@ -439,8 +447,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
@Override
public void removeParentIdByGroupList(List<Group> groupList) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGroupList(groupList);
Assert.notEmpty(channelList, "所有业务分组的通道不存在");
int result = commonGBChannelMapper.removeParentIdByChannels(channelList);
if (channelList.isEmpty()) {
return;
}
commonGBChannelMapper.removeParentIdByChannels(channelList);
}
@Override
@ -448,32 +458,95 @@ public class GbChannelServiceImpl implements IGbChannelService {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByBusinessGroup(oldBusinessGroup);
Assert.notEmpty(channelList, "旧的业务分组的通道不存在");
commonGBChannelMapper.updateBusinessGroupByChannelList(newBusinessGroup, channelList);
for (CommonGBChannel channel : channelList) {
channel.setGbBusinessGroupId(newBusinessGroup);
}
// 发送catalog
try {
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[多个通道业务分组] 发送失败,数量:{}", channelList.size(), e);
int result = commonGBChannelMapper.updateBusinessGroupByChannelList(newBusinessGroup, channelList);
if (result > 0) {
for (CommonGBChannel channel : channelList) {
channel.setGbBusinessGroupId(newBusinessGroup);
}
// 发送catalog
try {
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[多个通道业务分组] 发送失败,数量:{}", channelList.size(), e);
}
}
}
@Override
public void updateParentIdGroup(String oldParentId, String newParentId) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByParentId(oldParentId);
Assert.notEmpty(channelList, "旧的虚拟组织的通道不存在");
commonGBChannelMapper.updateParentIdByChannelList(newParentId, channelList);
for (CommonGBChannel channel : channelList) {
channel.setGbParentId(newParentId);
if (channelList.isEmpty()) {
return;
}
// 发送catalog
try {
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[多个通道业务分组] 发送失败,数量:{}", channelList.size(), e);
int result = commonGBChannelMapper.updateParentIdByChannelList(newParentId, channelList);
if (result > 0) {
for (CommonGBChannel channel : channelList) {
channel.setGbParentId(newParentId);
}
// 发送catalog
try {
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[多个通道业务分组] 发送失败,数量:{}", channelList.size(), e);
}
}
}
@Override
public void addChannelToGroup(String parentId, String businessGroup, List<Integer> channelIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByIds(channelIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
int result = commonGBChannelMapper.updateGroup(parentId, businessGroup, channelList);
// 发送通知
if (result > 0) {
for (CommonGBChannel channel : channelList) {
channel.setGbBusinessGroupId(businessGroup);
channel.setGbParentId(parentId);
}
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[多个通道添加行政区划] 发送失败,数量:{}", channelList.size(), e);
}
}
}
@Override
public void deleteChannelToGroup(String parentId, String businessGroup, List<Integer> channelIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(channelIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
int result = commonGBChannelMapper.removeParentIdByChannels(channelList);
}
@Override
public void addChannelToGroupByGbDevice(String parentId, String businessGroup, List<Integer> deviceIds) {
List<CommonGBChannel> channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
for (CommonGBChannel channel : channelList) {
channel.setGbCivilCode(civilCode);
}
int result = commonGBChannelMapper.updateRegion(civilCode, channelList);
// 发送通知
if (result > 0) {
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[多个通道添加行政区划] 发送失败,数量:{}", channelList.size(), e);
}
}
}
@Override
public void deleteChannelToGroupByGbDevice(List<Integer> deviceIds) {
}
}

View File

@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
/**
@ -44,43 +45,55 @@ public class GroupServiceImpl implements IGroupService {
Assert.notNull(group, "参数不可为NULL");
Assert.notNull(group.getDeviceId(), "设备编号不可为NULL");
Assert.isTrue(group.getDeviceId().trim().length() == 20, "设备编号必须为20位");
Assert.isTrue(group.getParentDeviceId().trim().length() == 20, "父级编号错误");
Assert.notNull(group.getName(), "设备编号不可为NULL");
GbCode gbCode = GbCode.decode(group.getDeviceId());
Assert.notNull(gbCode, "设备编号不满足国标定义");
// 根据字段判断此处应使用什么规则校验
if (ObjectUtils.isEmpty(group.getParentDeviceId())) {
if (ObjectUtils.isEmpty(group.getBusinessGroup())) {
// 如果是建立业务分组那么编号必须20位且10-13必须为215,
Assert.isTrue("215".equals(gbCode.getTypeCode()), "创建业务分组时设备编号11-13位应使用215");
group.setBusinessGroup(group.getDeviceId());
}else {
// 建立第一个虚拟组织
Assert.isTrue("216".equals(gbCode.getTypeCode()), "创建虚拟组织时设备编号11-13位应使用216");
}
if ("215".equals(gbCode.getTypeCode())){
// 添加业务分组
addBusinessGroup(group);
}else {
// 建立第一个虚拟组织
Assert.isTrue("216".equals(gbCode.getTypeCode()), "创建虚拟组织时设备编号11-13位应使用216");
// 添加虚拟组织
addGroup(group);
}
if (!ObjectUtils.isEmpty(group.getBusinessGroup())) {
// 校验业务分组是否存在
Group businessGroup = groupManager.queryBusinessGroup(group.getBusinessGroup());
Assert.notNull(businessGroup, "所属的业务分组分组不存在");
}
}
private void addGroup(Group group) {
// 建立虚拟组织
Assert.notNull(group.getBusinessGroup(), "所属的业务分组分组不存在");
Group businessGroup = groupManager.queryBusinessGroup(group.getBusinessGroup());
Assert.notNull(businessGroup, "所属的业务分组分组不存在");
if (!ObjectUtils.isEmpty(group.getParentDeviceId())) {
Group parentGroup = groupManager.queryOneByDeviceId(group.getParentDeviceId(), group.getBusinessGroup());
Assert.notNull(parentGroup, "所属的上级分组分组不存在");
}else {
group.setParentDeviceId(null);
}
group.setCreateTime(DateUtil.getNow());
group.setUpdateTime(DateUtil.getNow());
groupManager.add(group);
// 添加新的虚拟组织需要发起同志
if (gbCode.getTypeCode().equals("216")) {
if (group.getPlatformId() != null) {
CommonGBChannel channel = CommonGBChannel.build(group);
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channel, CatalogEvent.ADD);
eventPublisher.catalogEventPublish(group.getPlatformId(), channel, CatalogEvent.ADD);
}catch (Exception e) {
log.warn("[添加虚拟组织] 发送失败, {}-{}", channel.getGbName(), channel.getGbDeviceDbId(), e);
}
}
}
private void addBusinessGroup(Group group) {
group.setBusinessGroup(group.getDeviceId());
group.setCreateTime(DateUtil.getNow());
group.setUpdateTime(DateUtil.getNow());
groupManager.addBusinessGroup(group);
if (group.getPlatformId() != null) {
CommonGBChannel channel = CommonGBChannel.build(group);
try {
// 发送catalog
eventPublisher.catalogEventPublish(group.getPlatformId(), channel, CatalogEvent.ADD);
}catch (Exception e) {
log.warn("[添加虚拟组织] 发送失败, {}-{}", channel.getGbName(), channel.getGbDeviceDbId(), e);
}
@ -110,7 +123,28 @@ public class GroupServiceImpl implements IGroupService {
group.setName(group.getName());
group.setUpdateTime(DateUtil.getNow());
groupManager.update(group);
// 修改他的子节点
if (!group.getDeviceId().equals(groupInDb.getDeviceId())
|| !group.getBusinessGroup().equals(groupInDb.getBusinessGroup())) {
List<Group> groupList = queryAllChildren(groupInDb.getDeviceId(), groupInDb.getPlatformId());
if (!groupList.isEmpty()) {
int result = groupManager.updateChild(groupInDb.getDeviceId(), group);
if (result > 0) {
for (Group chjildGroup : groupList) {
chjildGroup.setParentDeviceId(group.getDeviceId());
chjildGroup.setBusinessGroup(group.getBusinessGroup());
// 将变化信息发送通知
CommonGBChannel channel = CommonGBChannel.build(chjildGroup);
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channel, CatalogEvent.UPDATE);
}catch (Exception e) {
log.warn("[业务分组/虚拟组织变化] 发送失败,{}", group.getDeviceId(), e);
}
}
}
}
}
// 将变化信息发送通知
CommonGBChannel channel = CommonGBChannel.build(group);
try {
@ -144,7 +178,13 @@ public class GroupServiceImpl implements IGroupService {
// 查询所有业务分组
return groupManager.queryBusinessGroupForTree(query, platformId);
}else {
return groupManager.queryForTree(query, parent, platformId);
GbCode gbCode = GbCode.decode(parent);
if (gbCode.getTypeCode().equals("215")) {
return groupManager.queryForTreeByBusinessGroup(query, parent, platformId);
}else {
return groupManager.queryForTree(query, parent, platformId);
}
}
}
@ -158,24 +198,33 @@ public class GroupServiceImpl implements IGroupService {
public boolean delete(int id) {
Group group = groupManager.queryOne(id);
Assert.notNull(group, "分组不存在");
groupManager.delete(id);
List<Group> groupListForDelete = new ArrayList<>();
GbCode gbCode = GbCode.decode(group.getDeviceId());
if (gbCode.getTypeCode().equals("215")) {
List<Group> groupList = groupManager.queryByBusinessGroup(group.getDeviceId());
if (!groupList.isEmpty()) {
groupListForDelete.addAll(groupList);
}
// 业务分组
gbChannelService.removeParentIdByBusinessGroup(gbCode.getTypeCode());
gbChannelService.removeParentIdByBusinessGroup(group.getDeviceId());
}else {
List<Group> groups = queryAllChildren(group.getDeviceId(), group.getPlatformId());
groups.add(group);
gbChannelService.removeParentIdByGroupList(groups);
List<Group> groupList = queryAllChildren(group.getDeviceId(), group.getPlatformId());
if (!groupList.isEmpty()) {
groupListForDelete.addAll(groupList);
}
groupListForDelete.add(group);
gbChannelService.removeParentIdByGroupList(groupListForDelete);
}
// 发送分组移除通知
// 将变化信息发送通知
CommonGBChannel channel = CommonGBChannel.build(group);
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channel, CatalogEvent.DEL);
}catch (Exception e) {
log.warn("[业务分组/虚拟组织删除] 发送失败,{}", group.getDeviceId(), e);
groupManager.batchDelete(groupListForDelete);
for (Group groupForDelete : groupListForDelete) {
// 将变化信息发送通知
CommonGBChannel channel = CommonGBChannel.build(groupForDelete);
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channel, CatalogEvent.DEL);
}catch (Exception e) {
log.warn("[业务分组/虚拟组织删除] 发送失败,{}", groupForDelete.getDeviceId(), e);
}
}
return true;
}

View File

@ -114,7 +114,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
if (catalogSubscribe != null) {
List<CommonGBChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform);
if (deviceChannelList != null) {
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
eventPublisher.catalogEventPublish(platform.getId(), deviceChannelList, CatalogEvent.ADD);
}
}
log.info("[关联通道]国标通道 平台:{}, 存入数据库成功", platformId);
@ -166,7 +166,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
}
List<CommonGBChannel> deviceChannels = platformChannelMapper.queryAllChannelInCatalog(platformId, catalogId);
eventPublisher.catalogEventPublish(platformId, deviceChannels, CatalogEvent.DEL);
eventPublisher.catalogEventPublish(platform.getId(), deviceChannels, CatalogEvent.DEL);
return platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId);
}

View File

@ -795,4 +795,9 @@ public class PlatformServiceImpl implements IPlatformService {
streamSession.remove(platform.getServerGBId(), channel.getDeviceId(), stream);
}
}
@Override
public ParentPlatform queryOne(Integer platformId) {
return platformMapper.getParentPlatById(platformId);
}
}

View File

@ -193,7 +193,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
// 查询平台下是否有该通道
DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
PlatformCatalog catalog = storager.getCatalog(requesterId, channelId);
// PlatformCatalog catalog = storager.getCatalog(requesterId, channelId);
MediaServer mediaServerItem = null;
StreamPush streamPushItem = null;
@ -258,14 +258,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] invite CALL_IS_BEING_FORWARDED: {}", e.getMessage());
}
} else if (catalog != null) {
try {
// 目录不支持点播
responseAck(request, Response.BAD_REQUEST, "catalog channel can not play");
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] invite 目录不支持点播: {}", e.getMessage());
}
return;
// }
// else if (catalog != null) {
// try {
// // 目录不支持点播
// responseAck(request, Response.BAD_REQUEST, "catalog channel can not play");
// } catch (SipException | InvalidArgumentException | ParseException e) {
// log.error("[命令发送失败] invite 目录不支持点播: {}", e.getMessage());
// }
// return;
} else {
log.info("通道不存在返回404: {}", channelId);
try {

View File

@ -91,36 +91,14 @@ public interface IVideoManagerStorage {
*/
Device queryVideoDeviceByChannelId(String channelId);
/**
*
* @param platformId
* @param parentId
* @return
*/
List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId);
int addCatalog(PlatformCatalog platformCatalog);
PlatformCatalog getCatalog(String platformId, String id);
int delCatalog(String platformId, String id);
int updateCatalog(PlatformCatalog platformCatalog);
int setDefaultCatalog(String platformId, String catalogId);
int delRelation(PlatformCatalog platformCatalog);
int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo);
List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms);
void delCatalogByPlatformId(String serverGBId);
void delRelationByPlatformId(String serverGBId);
PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
List<ParentPlatform> queryEnablePlatformListWithAsMessageChannel();

View File

@ -3,16 +3,14 @@ package com.genersoft.iot.vmp.storager.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import com.genersoft.iot.vmp.gb28181.dao.*;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelReduce;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
@ -34,6 +32,7 @@ import java.util.List;
@DS("master")
public class VideoManagerStorageImpl implements IVideoManagerStorage {
@Autowired
EventPublisher eventPublisher;
@ -162,7 +161,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
deviceChannel.setGbDeviceId(channelReduce.getChannelId());
deviceChannelList.add(deviceChannel);
}
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
// eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
return result;
}
@ -241,175 +240,12 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return result;
}
@Override
public List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId) {
return catalogMapper.selectByParentId(platformId, parentId);
}
@Override
public int addCatalog(PlatformCatalog platformCatalog) {
ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformCatalog.getPlatformId());
if (platform == null) {
return 0;
}
if (platformCatalog.getId().length() <= 8) {
platformCatalog.setCivilCode(platformCatalog.getParentId());
}else {
if (platformCatalog.getId().length() != 20) {
return 0;
}
if (platformCatalog.getParentId() != null) {
switch (Integer.parseInt(platformCatalog.getId().substring(10, 13))){
case 200:
case 215:
if (platformCatalog.getParentId().length() <= 8) {
platformCatalog.setCivilCode(platformCatalog.getParentId());
}else {
PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(), platformCatalog.getParentId());
if (catalog != null) {
platformCatalog.setCivilCode(catalog.getCivilCode());
}
}
break;
case 216:
if (platformCatalog.getParentId().length() <= 8) {
platformCatalog.setCivilCode(platformCatalog.getParentId());
}else {
PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(),platformCatalog.getParentId());
if (catalog == null) {
log.warn("[添加目录] 无法获取目录{}的CivilCode和BusinessGroupId", platformCatalog.getPlatformId());
break;
}
platformCatalog.setCivilCode(catalog.getCivilCode());
if (Integer.parseInt(platformCatalog.getParentId().substring(10, 13)) == 215) {
platformCatalog.setBusinessGroupId(platformCatalog.getParentId());
}else {
if (Integer.parseInt(platformCatalog.getParentId().substring(10, 13)) == 216) {
platformCatalog.setBusinessGroupId(catalog.getBusinessGroupId());
}
}
}
break;
default:
break;
}
}
}
int result = catalogMapper.add(platformCatalog);
if (result > 0) {
DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog);
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.ADD);
}
return result;
}
private PlatformCatalog getTopCatalog(String id, String platformId) {
PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformId, id);
if (catalog.getParentId().equals(platformId)) {
return catalog;
}else {
return getTopCatalog(catalog.getParentId(), platformId);
}
}
@Override
public PlatformCatalog getCatalog(String platformId, String id) {
return catalogMapper.selectByPlatFormAndCatalogId(platformId, id);
}
@Override
public int delCatalog(String platformId, String id) {
return delCatalogExecute(id, platformId);
}
private int delCatalogExecute(String id, String platformId) {
int delresult = catalogMapper.del(platformId, id);
DeviceChannel deviceChannelForCatalog = new DeviceChannel();
if (delresult > 0){
deviceChannelForCatalog.setDeviceId(id);
eventPublisher.catalogEventPublish(platformId, deviceChannelForCatalog, CatalogEvent.DEL);
}
List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
if (!gbStreams.isEmpty()){
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
for (GbStream gbStream : gbStreams) {
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(gbStream.getGbId());
deviceChannelList.add(deviceChannel);
}
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
}
int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id);
List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
if (!platformCatalogs.isEmpty()){
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
for (PlatformCatalog platformCatalog : platformCatalogs) {
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(platformCatalog.getId());
deviceChannelList.add(deviceChannel);
}
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
}
int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
// 查看是否存在子目录,如果存在一并删除
List<String> allChildCatalog = getAllChildCatalog(id, platformId);
if (!allChildCatalog.isEmpty()) {
int limitCount = 50;
if (allChildCatalog.size() > limitCount) {
for (int i = 0; i < allChildCatalog.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > allChildCatalog.size()) {
toIndex = allChildCatalog.size();
}
delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex));
}
}else {
delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog);
}
}
return delresult + delChannelresult + delStreamresult;
}
private List<String> getAllChildCatalog(String id, String platformId) {
List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
List<String> catalogListChild = new ArrayList<>();
if (catalogList != null && !catalogList.isEmpty()) {
for (String childId : catalogList) {
List<String> allChildCatalog = getAllChildCatalog(childId, platformId);
if (allChildCatalog != null && !allChildCatalog.isEmpty()) {
catalogListChild.addAll(allChildCatalog);
}
}
}
if (!catalogListChild.isEmpty()) {
catalogList.addAll(catalogListChild);
}
return catalogList;
}
@Override
public int updateCatalog(PlatformCatalog platformCatalog) {
int result = catalogMapper.update(platformCatalog);
if (result > 0) {
DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog);
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.UPDATE);
}
return result;
}
@Override
public int setDefaultCatalog(String platformId, String catalogId) {
return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow());
}
@Override
public int delRelation(PlatformCatalog platformCatalog) {
if (platformCatalog.getType() == 1) {
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(platformCatalog.getId());
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
// eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
return platformChannelMapper.delByCatalogIdAndChannelIdAndPlatformId(platformCatalog);
}else if (platformCatalog.getType() == 2) {
List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformCatalog.getPlatformId(), platformCatalog.getParentId());
@ -417,7 +253,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
if (gbStream.getGbId().equals(platformCatalog.getId())) {
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(gbStream.getGbId());
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
// eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
}
}
@ -456,21 +292,12 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return platformChannelMapper.queryPlatFormListForGBWithGBId(channelId, platforms);
}
@Override
public void delCatalogByPlatformId(String serverGBId) {
catalogMapper.delByPlatformId(serverGBId);
}
@Override
public void delRelationByPlatformId(String serverGBId) {
platformGbStreamMapper.delByPlatformId(serverGBId);
platformChannelMapper.delByPlatformId(serverGBId);
}
@Override
public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) {
return catalogMapper.selectDefaultByPlatFormId(platformId);
}
@Override
public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) {

View File

@ -27,7 +27,7 @@
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span @click.stop >
<el-radio v-if="node.data.type === 0 && node.level !== 1 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange" :label="node.data.id">{{''}}</el-radio>
<el-radio v-if="node.data.type === 0 && node.level > 2 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange" :label="node.data.id">{{''}}</el-radio>
</span>
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-shexiangtou2"></span>
@ -74,7 +74,7 @@ export default {
isLeaf: false,
type: 0
}]);
} else if (node.data.id.length <= 8) {
} else {
this.$axios({
method: 'get',
url: `/api/group/tree/list`,
@ -90,8 +90,6 @@ export default {
}).catch(function (error) {
console.log(error);
});
} else {
resolve([]);
}
},
reset: function () {
@ -145,7 +143,7 @@ export default {
}
},
{
label: node.level === 1?"新建业务分组":"新建虚拟组织",
label: "新建节点",
icon: "el-icon-plus",
disabled: false,
onClick: () => {
@ -153,11 +151,11 @@ export default {
}
},
{
label: "重命名",
label: "编辑节点",
icon: "el-icon-edit",
disabled: node.level === 1,
onClick: () => {
this.editCatalog(data, node);
this.editGroup(data, node);
}
},
{
@ -180,7 +178,7 @@ export default {
{
label: "添加设备",
icon: "el-icon-plus",
disabled: node.level === 1,
disabled: node.level <= 2,
onClick: () => {
this.addChannelFormDevice(data.id, node)
}
@ -188,7 +186,7 @@ export default {
{
label: "移除设备",
icon: "el-icon-delete",
disabled: node.level === 1,
disabled: node.level <= 2,
onClick: () => {
this.removeChannelFormDevice(data.id, node)
}
@ -227,7 +225,7 @@ export default {
method: "delete",
url: `/api/group/delete`,
params: {
deviceId: id,
id: node.data.dbId,
}
}).then((res) => {
if (res.data.code === 0) {
@ -312,12 +310,29 @@ export default {
},
addGroup: function (id, node) {
this.$refs.groupEdit.openDialog({
id: null
id: 0,
name: "",
deviceId: "",
parentDeviceId: node.level > 2 ? node.data.id:"",
businessGroup: node.level > 2 ? node.data.businessGroup: node.data.id,
},form => {
node.loaded = false
node.expand();
}, id);
},
editGroup: function (id, node) {
console.log(node)
this.$refs.groupEdit.openDialog({
id: node.data.dbId,
name: node.data.label,
deviceId: node.data.id,
parentDeviceId: node.data.parentDeviceId,
businessGroup: node.data.businessGroup,
},form => {
node.parent.loaded = false
node.parent.expand();
}, id);
},
nodeClickHandler: function (data, node, tree) {
console.log(data)
console.log(node)

View File

@ -1,7 +1,7 @@
<template>
<div id="addUser" v-loading="getDeviceListLoading">
<el-dialog
title="添加国标设备通道到行政区划"
title="添加国标设备通道"
width="60%"
top="2rem"
:close-on-click-modal="false"
@ -34,6 +34,8 @@
</el-table-column>
<el-table-column prop="deviceId" label="设备编号" min-width="200" >
</el-table-column>
<el-table-column prop="channelCount" label="通道数" min-width="120" >
</el-table-column>
<el-table-column prop="manufacturer" label="厂家" min-width="120" >
</el-table-column>
<el-table-column label="地址" min-width="160" >

View File

@ -11,7 +11,7 @@
@close="close()"
>
<div id="shared" style="margin-top: 1rem;margin-right: 100px;">
<el-form ref="form" :rules="rules" :model="group" label-width="140px" >
<el-form ref="form" :model="group" label-width="140px" >
<el-form-item label="节点编号" prop="id" >
<el-input v-model="group.deviceId" placeholder="请输入编码">
<el-button slot="append" @click="buildDeviceIdCode(group.deviceId)"></el-button>
@ -50,13 +50,23 @@ export default {
showDialog: false,
loading: false,
level: 0,
group: {},
group: {
id: 0,
deviceId: "",
name: "",
parentDeviceId: "",
businessGroup: "",
platformId: "",
},
};
},
methods: {
openDialog: function (group, callback) {
console.log(group)
this.group = group;
if (group) {
this.group = group;
}
this.showDialog = true;
this.submitCallback = callback;
},
@ -64,7 +74,7 @@ export default {
this.$axios({
method:"post",
url: this.group.id ? '/api/group/add':'/api/group/update',
url: this.group.id ? '/api/group/update':'/api/group/add',
data: this.group
}).then((res)=> {
if (res.data.code === 0) {
@ -88,13 +98,11 @@ export default {
});
},
buildDeviceIdCode: function (deviceId){
console.log(this.group)
let lockContent = this.group.businessGroup ? "216":"215"
this.$refs.channelCode.openDialog(code=>{
console.log(this.form)
console.log("code===> " + code)
this.group.deviceId = code;
console.log("code22===> " + code)
}, deviceId);
}, deviceId, 5 , lockContent);
},
close: function () {
this.showDialog = false;