diff --git a/README.md b/README.md index 6f2621deb..1116581f7 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-yellow.svg)](https://github.com/xia-chu/ZLMediaKit/pulls) -WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网络视频平台,负责实现核心信令与设备管理后台部分,支持NAT穿透,支持海康、大华、宇视等品牌的IPC、NVR接入。支持国标级联,支持将不带国标功能的摄像机/直播流/直播推流转发到其他国标平台。 +WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网络视频平台,负责实现核心信令与设备管理后台部分,支持NAT穿透,支持海康、大华、宇视等品牌的IPC、NVR接入。支持国标级联,支持将不带国标功能的摄像机/直播流/直播推流转发到其他国标平台。 流媒体服务基于@夏楚 ZLMediaKit [https://github.com/ZLMediaKit/ZLMediaKit](https://github.com/ZLMediaKit/ZLMediaKit) 播放器使用@dexter jessibuca [https://github.com/langhuihui/jessibuca/tree/v3](https://github.com/langhuihui/jessibuca/tree/v3) -前端页面基于@Kyle MediaServerUI [https://gitee.com/kkkkk5G/MediaServerUI](https://gitee.com/kkkkk5G/MediaServerUI) 进行修改. +前端页面基于@Kyle MediaServerUI [https://gitee.com/kkkkk5G/MediaServerUI](https://gitee.com/kkkkk5G/MediaServerUI) 进行修改. # 应用场景: 支持浏览器无插件播放摄像头视频。 支持国标设备(摄像机、平台、NVR等)设备接入 -支持非国标(onvif, rtsp, rtmp,直播设备等等)设备接入,充分利旧。 +支持非国标(onvif, rtsp, rtmp,直播设备等等)设备接入,充分利旧。 支持国标级联。多平台级联。跨网视频预览。 支持跨网网闸平台互联。 @@ -43,10 +43,9 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git ![build_1](https://images.gitee.com/uploads/images/2022/0304/101919_ee5b8c79_1018729.png "2022-03-04_10-13.png") ![运维中心](doc/_media/log.jpg "log.jpg") -# 功能特性 +# 功能特性 - [X] 集成web界面 - [X] 兼容性良好 -- [X] 支持电子地图,支持接入WGS84和GCJ02两种坐标系,并且自动转化为合适的坐标系进行展示和分发 - [X] 接入设备 - [X] 视频预览 - [X] 支持主码流子码流切换 @@ -68,6 +67,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 支持播放H264和H265 - [X] 报警信息处理,支持向前端推送报警信息 - [X] 语音对讲 + - [X] 支持业务分组和行政区划树自定义展示以及级联推送 - [X] 支持订阅与通知方法 - [X] 移动位置订阅 - [X] 移动位置通知处理 @@ -84,6 +84,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 注册 - [X] 心跳保活 - [X] 通道选择 + - [X] 支持通道编号自定义, 支持每个平台使用不同的通道编号 - [X] 通道推送 - [X] 点播 - [X] 云台控制 @@ -95,10 +96,11 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 录像查看与播放 - [X] GPS订阅与通知(直播推流) - [X] 语音对讲 -- [X] 支持自动配置ZLM媒体服务, 减少因配置问题所出现的问题; + - [X] 支持同时级联到多个上级平台 +- [X] 支持自动配置ZLM媒体服务, 减少因配置问题所出现的问题; - [X] 多流媒体节点,自动选择负载最低的节点使用。 - [X] 支持启用udp多端口模式, 提高udp模式下媒体传输性能; -- [X] 支持公网部署; +- [X] 支持公网部署; - [X] 支持wvp与zlm分开部署,提升平台并发能力 - [X] 支持拉流RTSP/RTMP,分发为各种流格式,或者推送到其他国标平台 - [X] 支持推流RTSP/RTMP,分发为各种流格式,或者推送到其他国标平台 @@ -108,8 +110,9 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git - [X] 支持打包可执行jar和war - [X] 支持跨域请求,支持前后端分离部署 - [X] 支持Mysql,Postgresql,金仓等数据库 -- [X] 支持Onvif(目前在onvif分支,需要安装onvif服务,服务请在知识星球获取) - +- [X] 支持录制计划, 根据设定的时间对通道进行录制. 暂不支持将录制的内容转发到国标上级 +- [X] 支持Onvif, 目前付费提供, 永久免费试用包在知识星球获取 +- [X] 支持国标28181-2022协议, 目前付费提供, 永久免费试用包在知识星球获取 # 非开源的内容 @@ -120,7 +123,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git # 授权协议 本项目自有代码使用宽松的MIT协议,在保留版权信息的情况下可以自由应用于各自商用、非商业的项目。 但是本项目也零碎的使用了一些其他的开源代码,在商用的情况下请自行替代或剔除; 由于使用本项目而产生的商业纠纷或侵权行为一概与本项目及开发者无关,请自行承担法律风险。 在使用本项目代码时,也应该在授权协议中同时表明本项目依赖的第三方库的协议 -# 技术支持 +# 技术支持 [知识星球](https://t.zsxq.com/0d8VAD3Dm)专栏列表:, - [使用入门系列一:WVP-PRO能做什么](https://t.zsxq.com/0dLguVoSp) @@ -132,7 +135,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git 感谢作者[dexter langhuihui](https://github.com/langhuihui) 开源这么好用的WEB播放器。 感谢作者[Kyle](https://gitee.com/kkkkk5G) 开源了好用的前端页面 感谢各位大佬的赞助以及对项目的指正与帮助。包括但不限于代码贡献、问题反馈、资金捐赠等各种方式的支持!以下排名不分先后: -[lawrencehj](https://github.com/lawrencehj) [Smallwhitepig](https://github.com/Smallwhitepig) [swwhaha](https://github.com/swwheihei) +[lawrencehj](https://github.com/lawrencehj) [Smallwhitepig](https://github.com/Smallwhitepig) [swwhaha](https://github.com/swwheihei) [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen) [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb) [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java index 878e01c5d..28e68fb3d 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java @@ -15,6 +15,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; /** @@ -54,7 +55,7 @@ public class CivilCodeFileConf implements CommandLineRunner { inputStream = Files.newInputStream(civilCodeFile.toPath()); } - BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream)); + BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); int index = -1; String line; while ((line = inputStreamReader.readLine()) != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java index a56d4090b..a020fcb94 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java @@ -34,6 +34,7 @@ public class DynamicTask { threadPoolTaskScheduler.setPoolSize(300); threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true); threadPoolTaskScheduler.setAwaitTerminationSeconds(10); + threadPoolTaskScheduler.setThreadNamePrefix("dynamicTask-"); threadPoolTaskScheduler.initialize(); } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java index 432fafbb0..df88bcf3a 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java @@ -1,13 +1,18 @@ package com.genersoft.iot.vmp.conf; import org.apache.commons.lang3.concurrent.BasicThreadFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.config.ScheduledTaskRegistrar; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; +import static com.genersoft.iot.vmp.conf.ThreadPoolTaskConfig.cpuNum; + /** * "@Scheduled"是Spring框架提供的一种定时任务执行机制,默认情况下它是单线程的,在同时执行多个定时任务时可能会出现阻塞和性能问题。 * 为了解决这种单线程瓶颈问题,可以将定时任务的执行机制改为支持多线程 @@ -15,16 +20,21 @@ import java.util.concurrent.ThreadPoolExecutor; @Configuration public class ScheduleConfig implements SchedulingConfigurer { - public static final int cpuNum = Runtime.getRuntime().availableProcessors(); + /** + * 核心线程数(默认线程数) + */ + private static final int corePoolSize = Math.max(cpuNum, 20); - private static final int corePoolSize = cpuNum; - - private static final String threadNamePrefix = "scheduled-task-pool-%d"; + /** + * 线程池名前缀 + */ + private static final String threadNamePrefix = "schedule"; @Override public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { - taskRegistrar.setScheduler(new ScheduledThreadPoolExecutor(corePoolSize, + ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(corePoolSize, new BasicThreadFactory.Builder().namingPattern(threadNamePrefix).daemon(true).build(), - new ThreadPoolExecutor.CallerRunsPolicy())); + new ThreadPoolExecutor.CallerRunsPolicy()); + taskRegistrar.setScheduler(scheduledThreadPoolExecutor); } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java index c7532e38e..a549a053a 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java @@ -28,11 +28,11 @@ public class ThreadPoolTaskConfig { /** * 核心线程数(默认线程数) */ - private static final int corePoolSize = cpuNum; + private static final int corePoolSize = Math.max(cpuNum * 2, 16); /** * 最大线程数 */ - private static final int maxPoolSize = cpuNum*2; + private static final int maxPoolSize = corePoolSize * 10; /** * 允许线程空闲时间(单位:默认为秒) */ @@ -45,12 +45,9 @@ public class ThreadPoolTaskConfig { /** * 线程池名前缀 */ - private static final String threadNamePrefix = "wvp-"; + private static final String threadNamePrefix = "async-"; + - /** - * - * @return - */ @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名 public ThreadPoolTaskExecutor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index 604c8c56a..c64b4ba88 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -170,4 +170,9 @@ public class UserSetting { */ private int gbDeviceOnline = 1; + /** + * 登录超时时间(分钟), + */ + private long loginTimeout = 30; + } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java index b1eb792ad..61e019c60 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.conf.security; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.security.dto.JwtUser; import com.genersoft.iot.vmp.service.IUserApiKeyService; import com.genersoft.iot.vmp.service.IUserService; @@ -46,13 +47,15 @@ public class JwtUtils implements InitializingBean { /** * token过期时间(分钟) */ - public static final long EXPIRATION_TIME = 30 * 24 * 60; + public static final long EXPIRATION_TIME = 30; private static RsaJsonWebKey rsaJsonWebKey; private static IUserService userService; private static IUserApiKeyService userApiKeyService; + + private static UserSetting userSetting; public static String getApiKeyHeader() { return API_KEY_HEADER; @@ -68,6 +71,11 @@ public class JwtUtils implements InitializingBean { JwtUtils.userApiKeyService = userApiKeyService; } + @Resource + public void setUserSetting(UserSetting userSetting) { + JwtUtils.userSetting = userSetting; + } + @Override public void afterPropertiesSet() { try { @@ -153,7 +161,7 @@ public class JwtUtils implements InitializingBean { } public static String createToken(String username) { - return createToken(username, EXPIRATION_TIME); + return createToken(username, userSetting.getLoginTimeout()); } public static String getHeader() { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java index 25407ed4a..fb687b355 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java @@ -20,6 +20,7 @@ public class CatalogData { private Device device; private String errorMsg; private Set redisKeysForChannel = new HashSet<>(); + private Set errorChannel = new HashSet<>(); private Set redisKeysForRegion = new HashSet<>(); private Set redisKeysForGroup = new HashSet<>(); 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 58bb6631f..b9f37906e 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 @@ -126,6 +126,9 @@ public class CommonGBChannel { @Schema(description = "关联的国标设备数据库ID") private Integer gbDeviceDbId; + @Schema(description = "二进制保存的录制计划, 每一位表示每个小时的前半个小时") + private Long recordPLan; + @Schema(description = "关联的推流Id(流来源是推流时有效)") private Integer streamPushId; 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 44d11b0ba..3db52a437 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 @@ -101,11 +101,31 @@ public class CommonChannelController { return channel; } + @Operation(summary = "获取通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页查询数量", required = true) + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasRecordPlan", description = "是否已设置录制计划") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @GetMapping("/list") + public PageInfo queryList(int page, int count, + @RequestParam(required = false) String query, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasRecordPlan, + @RequestParam(required = false) Integer channelType){ + if (ObjectUtils.isEmpty(query)){ + query = null; + } + return channelService.queryList(page, count, query, online, hasRecordPlan, channelType); + } + @Operation(summary = "获取关联行政区划通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "page", description = "当前页", required = true) @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") @Parameter(name = "civilCode", description = "行政区划") @GetMapping("/civilcode/list") public PageInfo queryListByCivilCode(int page, int count, @@ -124,6 +144,7 @@ public class CommonChannelController { @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") @Parameter(name = "groupDeviceId", description = "业务分组下的父节点ID") @GetMapping("/parent/list") public PageInfo queryListByParentId(int page, int count, diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java index a63a3867a..5e9ee17e7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java @@ -269,7 +269,7 @@ public class DeviceQuery { @Operation(summary = "修改数据流传输模式", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "deviceId", description = "设备国标编号", required = true) @Parameter(name = "streamMode", description = "数据流传输模式, 取值:" + - "UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", required = true) + "UDP(udp传输),TCP-ACTIVE(tcp主动模式),TCP-PASSIVE(tcp被动模式)", required = true) @PostMapping("/transport/{deviceId}/{streamMode}") public void updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ Device device = deviceService.getDeviceByDeviceId(deviceId); 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 1d0143193..37ec6adee 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 @@ -460,4 +460,97 @@ public interface CommonGBChannelMapper { " "}) void updateGpsByDeviceIdForStreamPush(List channels); + @SelectProvider(type = ChannelProvider.class, method = "queryList") + List queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); + + @Update(value = {" "}) + void removeRecordPlan(List channelIds); + + @Update(value = {" "}) + void addRecordPlan(List channelIds, @Param("planId") Integer planId); + + @Update(value = {" "}) + void addRecordPlanForAll(@Param("planId") Integer planId); + + @Update(value = {" "}) + void removeRecordPlanByPlanId( @Param("planId") Integer planId); + + + @Select("") + List queryForRecordPlanForWebList(@Param("planId") Integer planId, @Param("query") String query, + @Param("channelType") Integer channelType, @Param("online") Boolean online, + @Param("hasLink") Boolean hasLink); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index a52632354..068eb4b79 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -93,6 +93,12 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select(value = {" "}) + List queryChaneIdListByDeviceDbIds(List deviceDbIds); + @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); @@ -407,6 +413,10 @@ public interface DeviceChannelMapper { "") void updateChannelStreamIdentification(DeviceChannel channel); + @Update("") + void updateAllChannelStreamIdentification(@Param("streamIdentification") String streamIdentification); @Update({"") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void add(RecordPlan plan); + + @Insert(" ") + void batchAddItem(@Param("planId") int planId, List planItemList); + + @Select("select * from wvp_record_plan where id = #{planId}") + RecordPlan get(@Param("planId") Integer planId); + + @Select(" ") + List query(@Param("query") String query); + + @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") + void update(RecordPlan plan); + + @Delete("DELETE FROM wvp_record_plan WHERE id=#{planId}") + void delete(@Param("planId") Integer planId); + + @Select("select * from wvp_record_plan_item where plan_id = #{planId}") + List getItemList(@Param("planId") Integer planId); + + @Delete("DELETE FROM wvp_record_plan_item WHERE plan_id = #{planId}") + void cleanItems(@Param("planId") Integer planId); + + @Select(" ") + List queryRecordIng(@Param("week") int week, @Param("index") int index); +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java new file mode 100644 index 000000000..f01c11e5f --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -0,0 +1,150 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan; + +import com.genersoft.iot.vmp.conf.exception.ControllerException; +import com.genersoft.iot.vmp.conf.security.JwtUtils; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.service.IRecordPlanService; +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.recordPlan.bean.RecordPlanParam; +import com.github.pagehelper.PageInfo; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +@Tag(name = "录制计划") +@Slf4j +@RestController +@RequestMapping("/api/record/plan") +public class RecordPlanController { + + @Autowired + private IRecordPlanService recordPlanService; + + @Autowired + private IDeviceChannelService deviceChannelService; + + + @ResponseBody + @PostMapping("/add") + @Operation(summary = "添加录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "plan", description = "计划", required = true) + public void add(@RequestBody RecordPlan plan) { + if (plan.getPlanItemList() == null || plan.getPlanItemList().isEmpty()) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "添加录制计划时,录制计划不可为空"); + } + recordPlanService.add(plan); + } + + @ResponseBody + @PostMapping("/link") + @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "param", description = "通道关联录制计划", required = true) + public void link(@RequestBody RecordPlanParam param) { + if (param.getAllLink() != null) { + if (param.getAllLink()) { + recordPlanService.linkAll(param.getPlanId()); + }else { + recordPlanService.cleanAll(param.getPlanId()); + } + return; + } + + if (param.getChannelIds() == null && param.getDeviceDbIds() == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); + } + + List channelIds = new ArrayList<>(); + if (param.getChannelIds() != null) { + channelIds.addAll(param.getChannelIds()); + }else { + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbIds(param.getDeviceDbIds()); + if (chanelIdList != null && !chanelIdList.isEmpty()) { + channelIds = chanelIdList; + } + } + recordPlanService.link(channelIds, param.getPlanId()); + } + + @ResponseBody + @GetMapping("/get") + @Operation(summary = "查询录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "planId", description = "计划ID", required = true) + public RecordPlan get(Integer planId) { + if (planId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "计划ID不可为NULL"); + } + return recordPlanService.get(planId); + } + + @ResponseBody + @GetMapping("/query") + @Operation(summary = "查询录制计划列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "query", description = "检索内容", required = false) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页查询数量", required = true) + public PageInfo query(@RequestParam(required = false) String query, @RequestParam Integer page, @RequestParam Integer count) { + if (query != null && ObjectUtils.isEmpty(query.trim())) { + query = null; + } + return recordPlanService.query(page, count, query); + } + + @Operation(summary = "分页查询级联平台的所有所有通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页条数", required = true) + @Parameter(name = "planId", description = "录制计划ID") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasLink", description = "是否已经关联") + @GetMapping("/channel/list") + @ResponseBody + public PageInfo queryChannelList(int page, int count, + @RequestParam(required = false) Integer planId, + @RequestParam(required = false) String query, + @RequestParam(required = false) Integer channelType, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasLink) { + + Assert.notNull(planId, "录制计划ID不可为NULL"); + if (org.springframework.util.ObjectUtils.isEmpty(query)) { + query = null; + } + + return recordPlanService.queryChannelList(page, count, query, channelType, online, planId, hasLink); + } + + @ResponseBody + @PostMapping("/update") + @Operation(summary = "更新录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "plan", description = "计划", required = true) + public void update(@RequestBody RecordPlan plan) { + if (plan == null || plan.getId() == 0) { + throw new ControllerException(ErrorCode.ERROR400); + } + recordPlanService.update(plan); + } + + @ResponseBody + @DeleteMapping("/delete") + @Operation(summary = "删除录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "planId", description = "计划ID", required = true) + public void delete(Integer planId) { + if (planId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "计划IDID不可为NULL"); + } + recordPlanService.delete(planId); + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java new file mode 100644 index 000000000..9f56a0fbb --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -0,0 +1,23 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +@Schema(description = "录制计划-添加/编辑参数") +public class RecordPlanParam { + + @Schema(description = "关联的通道ID") + private List channelIds; + + @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") + private List deviceDbIds; + + @Schema(description = "全部关联/全部取消关联") + private Boolean allLink; + + @Schema(description = "录制计划ID, ID为空是删除关联的计划") + private Integer planId; +} diff --git a/src/main/resources/index.html b/src/main/resources/index.html new file mode 100644 index 000000000..9d2fdca2a --- /dev/null +++ b/src/main/resources/index.html @@ -0,0 +1,10 @@ + + + + + Title + + +111 + + \ No newline at end of file diff --git a/src/main/resources/配置详情.yml b/src/main/resources/配置详情.yml index cef721516..e35f9771a 100644 --- a/src/main/resources/配置详情.yml +++ b/src/main/resources/配置详情.yml @@ -251,6 +251,8 @@ user-settings: # 0: 国标标准实现,设备离线后不回复心跳,直到设备重新注册上线, # 1(默认): 对于离线设备,收到心跳就把设备设置为上线,并更新注册时间为上次这次心跳的时间。防止过期时间判断异常 gb-device-online: 0 + # 登录超时时间(分钟), + login-timeout: 30 # 关闭在线文档(生产环境建议关闭) springdoc: diff --git a/web_src/package.json b/web_src/package.json index c314b9ba8..78582b871 100644 --- a/web_src/package.json +++ b/web_src/package.json @@ -15,6 +15,7 @@ "@liveqing/liveplayer": "^2.7.10", "@wchbrad/vue-easy-tree": "^1.0.12", "axios": "^0.24.0", + "byte-weektime-picker": "^1.1.1", "core-js": "^2.6.5", "echarts": "^4.9.0", "element-ui": "^2.15.14", diff --git a/web_src/src/components/GBRecordDetail.vue b/web_src/src/components/GBRecordDetail.vue index 4d58d7a89..288bfe193 100755 --- a/web_src/src/components/GBRecordDetail.vue +++ b/web_src/src/components/GBRecordDetail.vue @@ -58,8 +58,8 @@ - - + + 倍速 diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue new file mode 100755 index 000000000..4e649fa55 --- /dev/null +++ b/web_src/src/components/RecordPLan.vue @@ -0,0 +1,236 @@ + + + + + diff --git a/web_src/src/components/common/GroupTree.vue b/web_src/src/components/common/GroupTree.vue index aded33161..9e0993552 100755 --- a/web_src/src/components/common/GroupTree.vue +++ b/web_src/src/components/common/GroupTree.vue @@ -14,6 +14,7 @@
+ { if (res.data.code === 0) { + if (res.data.data.length > 0) { + this.showAlert = false + } resolve(res.data.data); } diff --git a/web_src/src/components/common/RegionTree.vue b/web_src/src/components/common/RegionTree.vue index 6dd38fb3a..f45bc8ba9 100755 --- a/web_src/src/components/common/RegionTree.vue +++ b/web_src/src/components/common/RegionTree.vue @@ -12,7 +12,8 @@
-
+
+ { if (res.data.code === 0) { + if (res.data.data.length > 0) { + this.showAlert = false + } resolve(res.data.data); } diff --git a/web_src/src/components/dialog/GbChannelSelect.vue b/web_src/src/components/dialog/GbChannelSelect.vue index 62a09066f..258e313ec 100644 --- a/web_src/src/components/dialog/GbChannelSelect.vue +++ b/web_src/src/components/dialog/GbChannelSelect.vue @@ -64,16 +64,22 @@ - - +
+
+ 未找到通道,可在国标设备/通道中选择编辑按钮, 选择{{dataType === 'civilCode'?'行政区划':'父节点编码'}} +
+ + +
+
diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue new file mode 100644 index 000000000..4d425779a --- /dev/null +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -0,0 +1,228 @@ + + + diff --git a/web_src/src/components/dialog/groupEdit.vue b/web_src/src/components/dialog/groupEdit.vue index 72795cb4d..1c77bc841 100755 --- a/web_src/src/components/dialog/groupEdit.vue +++ b/web_src/src/components/dialog/groupEdit.vue @@ -22,7 +22,7 @@ - 生成 + 选择 @@ -37,17 +37,17 @@
- + + + diff --git a/web_src/src/components/group.vue b/web_src/src/components/group.vue index bce8d9567..85fb134e0 100755 --- a/web_src/src/components/group.vue +++ b/web_src/src/components/group.vue @@ -8,9 +8,10 @@