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 4995d923..d9d2e0c4 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 @@ -211,6 +211,14 @@ public class CommonGBChannel { @Schema(description = "关联的拉流代理Id(流来源是拉流代理时有效)") private Integer streamProxyId; + @Schema(description = "创建时间") + private String createTime; + + @Schema(description = "更新时间") + private String updateTime; + + + public String encode(){ return encode(null); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index 1a4ed985..e01c40bd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -171,12 +171,6 @@ public class DeviceChannel extends CommonGBChannel { @Schema(description = "云台类型描述字符串") private String ptzTypeText; - @Schema(description = "创建时间") - private String createTime; - - @Schema(description = "更新时间") - private String updateTime; - @Schema(description = "子设备数") private int subCount; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java index 303c5acd..167e05cc 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java @@ -15,9 +15,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -66,4 +64,18 @@ public class CommonChannelController { public List getNetworkIdentificationTypeList(){ return channelService.getNetworkIdentificationTypeList(); } + + @Operation(summary = "更新通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @ResponseBody + @PostMapping("/update") + public void update(@RequestBody CommonGBChannel channel){ + channelService.update(channel); + } + + @Operation(summary = "重置国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @ResponseBody + @PostMapping("/reset") + public void reset(Integer id){ + channelService.reset(id); + } } 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 42910594..529f0432 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 @@ -155,17 +155,11 @@ public interface CommonGBChannelMapper { @Select(" select\n" + " id as gb_id,\n" + - " device_db_id,\n" + + " device_db_id as gb_device_db_id,\n" + " stream_push_id,\n" + " stream_proxy_id,\n" + " create_time,\n" + " update_time,\n" + - " sub_count,\n" + - " stream_id,\n" + - " has_audio,\n" + - " gps_time,\n" + - " stream_identification,\n" + - " device_db_id as gb_device_db_id,\n" + " coalesce(gb_device_id, device_id) as gb_device_id,\n" + " coalesce(gb_name, name) as gb_name,\n" + " coalesce(gb_manufacturer, manufacturer) as gb_manufacturer,\n" + @@ -210,20 +204,6 @@ public interface CommonGBChannelMapper { @Update(value = {" "}) + void reset(@Param("id") int id, @Param("gbDeviceDbId") int gbDeviceDbId, @Param("updateTime") String updateTime); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index 266e9507..fc921b62 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -38,4 +38,6 @@ public interface IGbChannelService { List getDeviceTypeList(); List getNetworkIdentificationTypeList(); + + void reset(int id); } 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 cb12b46d..b9da0445 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 @@ -1,10 +1,13 @@ package com.genersoft.iot.vmp.gb28181.service.impl; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; +import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -51,6 +54,7 @@ public class GbChannelServiceImpl implements IGbChannelService { @Override public int update(CommonGBChannel commonGBChannel) { + log.warn("[更新通道] 通道ID: {}, ", commonGBChannel.getGbId()); if (commonGBChannel.getGbId() <= 0) { log.warn("[更新通道] 未找到数据库ID,更新失败, {}", commonGBChannel.getGbDeviceDbId()); return 0; @@ -267,4 +271,20 @@ public class GbChannelServiceImpl implements IGbChannelService { Collections.sort(result); return result; } + + @Override + public void reset(int id) { + log.info("[重置国标通道] id: {}", id); + CommonGBChannel channel = getOne(id); + if (channel == null ) { + log.warn("[重置国标通道] 未找到对应Id的通道: id: {}", id); + throw new ControllerException(ErrorCode.ERROR400); + } + if (channel.getGbDeviceDbId() <= 0) { + log.warn("[重置国标通道] 非国标下级通道无法重置: id: {}", id); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "非国标下级通道无法重置"); + } + // 这个多加一个参数,为了防止将非国标的通道通过此方法清空内容,导致意外发生 + commonGBChannelMapper.reset(id, channel.getGbDeviceDbId(), DateUtil.getNow()); + } } diff --git a/web_src/src/components/ChannelEdit.vue b/web_src/src/components/ChannelEdit.vue index e4517ac5..fafdff6a 100644 --- a/web_src/src/components/ChannelEdit.vue +++ b/web_src/src/components/ChannelEdit.vue @@ -1,14 +1,14 @@