From 0cacdb59282dc7d46dc849075c1c757a4514e614 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 22:33:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/dao/DeviceChannelMapper.java | 3 + .../service/IDeviceChannelService.java | 3 + .../impl/DeviceChannelServiceImpl.java | 10 ++ .../cmd/BroadcastResponseMessageHandler.java | 2 + .../iot/vmp/service/IRecordPlanService.java | 23 +++++ .../iot/vmp/service/bean/RecordPlan.java | 25 +++-- .../iot/vmp/service/bean/RecordPlanItem.java | 25 +++++ .../service/impl/RecordPlanServiceImpl.java | 79 ++++++++++++++++ .../vmp/storager/dao/RecordPlanMapper.java | 40 ++++++++ .../recordPlan/RecordPlanController.java | 93 +++++++++++++++++-- .../recordPlan/bean/RecordPlanParam.java | 22 +++++ src/main/resources/index.html | 10 ++ 数据库/2.7.3/初始化-mysql-2.7.3.sql | 20 ++++ .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 20 ++++ 14 files changed, 356 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java create mode 100644 src/main/resources/index.html 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 a5263235..75131ca6 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,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") + List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 81d9f9af..4f0ee8e1 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -122,4 +122,7 @@ public interface IDeviceChannelService { DeviceChannel getOneBySourceId(int deviceDbId, String channelId); + List queryChaneListByDeviceDbId(Integer deviceDbId); + + List queryChaneIdListByDeviceDbId(Integer deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 654648fe..cd30f214 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -350,6 +350,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return channelMapper.queryChannelsByDeviceDbId(device.getId()); } + @Override + public List queryChaneListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChannelsByDeviceDbId(deviceDbId); + } + + @Override + public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + } + @Override public void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition) { if (userSetting.getSavePositionHistory()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java index 97748222..2567b762 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java @@ -94,4 +94,6 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i public void handForPlatform(RequestEvent evt, Platform parentPlatform, Element element) { } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java new file mode 100644 index 00000000..641ddb18 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -0,0 +1,23 @@ +package com.genersoft.iot.vmp.service; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import com.github.pagehelper.PageInfo; + +import java.util.List; + +public interface IRecordPlanService { + + + RecordPlan get(Integer planId); + + void update(RecordPlan plan); + + void delete(Integer planId); + + PageInfo query(Integer page, Integer count, String query); + + void add(RecordPlan plan); + + void linke(List channelIds, Integer planId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java index 0ed21513..5333b2c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.service.bean; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Data @Schema(description = "录制计划") public class RecordPlan { @@ -10,18 +12,21 @@ public class RecordPlan { @Schema(description = "计划数据库ID") private int id; - @Schema(description = "计划关联的通道ID") - private Integer channelId; + @Schema(description = "计划名称") + private String name; - @Schema(description = "计划开始时间") - private Long startTime; - - @Schema(description = "计划结束时间") - private Long stopTime; - - @Schema(description = "计划周几执行") - private Integer weekDay; + @Schema(description = "计划关联通道数量") + private int channelCount; @Schema(description = "是否开启定时截图") private Boolean snap; + + @Schema(description = "创建时间") + private String createTime; + + @Schema(description = "更新时间") + private String updateTime; + + @Schema(description = "计划内容") + private List planItemList; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java new file mode 100644 index 00000000..14383cb1 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java @@ -0,0 +1,25 @@ +package com.genersoft.iot.vmp.service.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "录制计划项") +public class RecordPlanItem { + + @Schema(description = "计划项数据库ID") + private int id; + + @Schema(description = "计划开始时间") + private Long startTime; + + @Schema(description = "计划结束时间") + private Long stopTime; + + @Schema(description = "计划周几执行") + private Integer weekDay; + + @Schema(description = "所属计划ID") + private Integer planId; + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java new file mode 100644 index 00000000..661bea1b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -0,0 +1,79 @@ +package com.genersoft.iot.vmp.service.impl; + +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; +import com.genersoft.iot.vmp.service.IRecordPlanService; +import com.genersoft.iot.vmp.service.bean.CloudRecordItem; +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import com.genersoft.iot.vmp.storager.dao.RecordPlanMapper; +import com.genersoft.iot.vmp.utils.DateUtil; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Slf4j +public class RecordPlanServiceImpl implements IRecordPlanService { + + @Autowired + private RecordPlanMapper recordPlanMapper; + + @Autowired + private CommonGBChannelMapper channelMapper; + + @Override + @Transactional + public void add(RecordPlan plan) { + plan.setCreateTime(DateUtil.getNow()); + plan.setUpdateTime(DateUtil.getNow()); + recordPlanMapper.add(plan); + if (plan.getId() > 0) { + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + } + + @Override + public RecordPlan get(Integer planId) { + return recordPlanMapper.get(planId); + } + + @Override + public void update(RecordPlan plan) { + plan.setUpdateTime(DateUtil.getNow()); + recordPlanMapper.update(plan); + } + + @Override + public void delete(Integer planId) { + recordPlanMapper.delete(planId); + } + + @Override + public PageInfo query(Integer page, Integer count, String query) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = recordPlanMapper.query(query); + return new PageInfo<>(all); + } + + @Override + public void linke(List channelIds, Integer planId) { + if (planId == null) { + log.info("[录制计划] 移除通道关联的计划"); + channelMapper.removeRecordPlan(channelIds); + }else { + channelMapper.addRecordPlan(channelIds, planId); + } + + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java new file mode 100644 index 00000000..cd4f3173 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -0,0 +1,40 @@ +package com.genersoft.iot.vmp.storager.dao; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; + +import java.util.List; + +@Mapper +public interface RecordPlanMapper { + + @Insert(" ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void add(RecordPlan plan); + + RecordPlan get(Integer planId); + + List query(String query); + + void update(RecordPlan plan); + + void delete(Integer planId); + + + void batchAddItem(int planId, List planItemList); + +} 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 index 2a269836..6f3fdfa3 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -2,15 +2,22 @@ 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.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.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; @Tag(name = "录制计划") @@ -19,20 +26,88 @@ import java.util.List; @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 = "channelId", description = "通道ID", required = true) - @Parameter(name = "deviceDbId", description = "国标设备ID", required = true) - @Parameter(name = "planList", description = "录制计划, 为空则清空计划", required = false) - public void openRtpServer(@RequestParam(required = false) Integer channelId, @RequestParam(required = false) Integer deviceDbId, @RequestParam(required = false) List planList + @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); + } - ) { - if (channelId == null && deviceDbId == null) { + @ResponseBody + @PostMapping("/linke") + @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "param", description = "通道关联录制计划", required = false) + public void linke(@RequestBody RecordPlanParam param) { + if (param.getChannelId() == null && param.getDeviceDbId() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } - - - + List channelIds = new ArrayList<>(); + if (param.getChannelId() != null) { + channelIds.add(param.getChannelId()); + }else { + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + if (chanelIdList == null || chanelIdList.isEmpty()) { + channelIds = chanelIdList; + } + } + recordPlanService.linke(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); + } + + @ResponseBody + @PostMapping("/edit") + @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "plan", description = "计划", required = true) + public void edit(@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 00000000..11cc1a0a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -0,0 +1,22 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan.bean; + +import com.genersoft.iot.vmp.service.bean.RecordPlan; +import com.genersoft.iot.vmp.service.bean.RecordPlanItem; +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 Integer channelId; + + @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") + private Integer deviceDbId; + + @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 00000000..9d2fdca2 --- /dev/null +++ b/src/main/resources/index.html @@ -0,0 +1,10 @@ + + + + + Title + + +111 + + \ No newline at end of file diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 705eb301..faada9cd 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -428,3 +428,23 @@ CREATE TABLE wvp_common_region constraint uk_common_region_device_id unique (device_id) ); +create table wvp_record_plan +( + id serial primary key, + snap bool default false, + name varchar(255) NOT NULL, + create_time character varying(50), + update_time character varying(50) +); + +create table wvp_record_plan_item +( + id serial primary key, + start_time bigint, + stop_time bigint, + week_day int, + plan_id int, + create_time character varying(50), + update_time character varying(50) +); + diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index f589329e..9ef3e926 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -445,3 +445,23 @@ CREATE TABLE wvp_common_region constraint uk_common_region_device_id unique (device_id) ); +create table wvp_record_plan +( + id serial primary key, + snap bool default false, + name varchar(255) NOT NULL, + create_time character varying(50), + update_time character varying(50) +); + +create table wvp_record_plan_item +( + id serial primary key, + start_time int8, + stop_time int8, + week_day int, + plan_id int, + create_time character varying(50), + update_time character varying(50) +); +