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 99aff973..2f636a4d 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 @@ -459,4 +459,93 @@ public interface CommonGBChannelMapper { @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 75131ca6..13f1976a 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,8 +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); + @Select("select id from wvp_device_channel where device_db_id in " + + " #{item} ") + List queryChaneIdListByDeviceDbIds(List deviceDbIds); @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 4f0ee8e1..bb21e321 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 @@ -124,5 +124,5 @@ public interface IDeviceChannelService { List queryChaneListByDeviceDbId(Integer deviceDbId); - List queryChaneIdListByDeviceDbId(Integer deviceDbId); + List queryChaneIdListByDeviceDbIds(List 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 cd30f214..4b9cfad0 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 @@ -356,8 +356,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } @Override - public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { - return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + public List queryChaneIdListByDeviceDbIds(List deviceDbIds) { + return channelMapper.queryChaneIdListByDeviceDbIds(deviceDbIds); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 71ca0988..2f768f10 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -55,6 +55,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer platformId, Boolean hasShare) { PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } List all = platformChannelMapper.queryForPlatformForWebList(platformId, query, channelType, online, hasShare); return new PageInfo<>(all); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java index 641ddb18..359e0072 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -1,7 +1,8 @@ package com.genersoft.iot.vmp.service; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; 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; @@ -19,5 +20,11 @@ public interface IRecordPlanService { void add(RecordPlan plan); - void linke(List channelIds, Integer planId); + void link(List channelIds, Integer planId); + + PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink); + + void linkAll(Integer planId); + + void cleanAll(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 index aa6d922d..f8f7e9c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -1,6 +1,8 @@ package com.genersoft.iot.vmp.service.impl; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.CloudRecordItem; @@ -8,6 +10,7 @@ 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.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -33,9 +36,13 @@ public class RecordPlanServiceImpl implements IRecordPlanService { plan.setCreateTime(DateUtil.getNow()); plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.add(plan); - if (plan.getId() > 0) { + if (plan.getId() > 0 && !plan.getPlanItemList().isEmpty()) { + for (RecordPlanItem recordPlanItem : plan.getPlanItemList()) { + recordPlanItem.setPlanId(plan.getId()); + } recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); } + // TODO 更新录像队列 } @Override @@ -52,14 +59,30 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override + @Transactional public void update(RecordPlan plan) { plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.update(plan); + recordPlanMapper.cleanItems(plan.getId()); + if (plan.getPlanItemList() != null){ + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + // TODO 更新录像队列 + } @Override + @Transactional public void delete(Integer planId) { + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "录制计划不存在"); + } + // 清理关联的通道 + channelMapper.removeRecordPlanByPlanId(recordPlan.getId()); + recordPlanMapper.cleanItems(planId); recordPlanMapper.delete(planId); + // TODO 更新录像队列 } @Override @@ -75,13 +98,35 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override - public void linke(List channelIds, Integer planId) { + public void link(List channelIds, Integer planId) { if (planId == null) { log.info("[录制计划] 移除通道关联的计划"); channelMapper.removeRecordPlan(channelIds); }else { channelMapper.addRecordPlan(channelIds, planId); } + // TODO 更新录像队列 + } + @Override + public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = channelMapper.queryForRecordPlanForWebList(planId, query, channelType, online, hasLink); + return new PageInfo<>(all); + } + + @Override + public void linkAll(Integer planId) { + channelMapper.addRecordPlanForAll(planId); + } + + @Override + public void cleanAll(Integer planId) { + channelMapper.removeRecordPlanByPlanId(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 index 9fb4d588..705e59aa 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -10,7 +10,7 @@ import java.util.List; public interface RecordPlanMapper { @Insert(" ") void batchAddItem(@Param("planId") int planId, List planItemList); @@ -42,7 +41,8 @@ public interface RecordPlanMapper { RecordPlan get(@Param("planId") Integer planId); @Select(" ") List query(@Param("query") String query); @@ -50,9 +50,12 @@ public interface RecordPlanMapper { @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=#{id}") + @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); - List getItemList(Integer planId); + @Delete("DELETE FROM wvp_record_plan_item WHERE plan_id = #{planId}") + void cleanItems(@Param("planId") Integer planId); } 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 6f3fdfa3..3675acbb 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,6 +2,8 @@ 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.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.RecordPlan; @@ -15,6 +17,7 @@ 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; @@ -45,23 +48,31 @@ public class RecordPlanController { } @ResponseBody - @PostMapping("/linke") + @PostMapping("/link") @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) { + public void link(@RequestBody RecordPlanParam param) { + if (param.getChannelIds() == null && param.getDeviceDbIds() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } + if (param.getAll() != null) { + if (param.getAll()) { + recordPlanService.linkAll(param.getPlanId()); + }else { + recordPlanService.cleanAll(param.getPlanId()); + } + return; + } List channelIds = new ArrayList<>(); - if (param.getChannelId() != null) { - channelIds.add(param.getChannelId()); + if (param.getChannelIds() != null) { + channelIds.addAll(param.getChannelIds()); }else { - List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbIds(param.getDeviceDbIds()); if (chanelIdList == null || chanelIdList.isEmpty()) { channelIds = chanelIdList; } } - recordPlanService.linke(channelIds, param.getPlanId()); + recordPlanService.link(channelIds, param.getPlanId()); } @ResponseBody @@ -88,11 +99,36 @@ public class RecordPlanController { 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 - @PostMapping("/edit") - @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + 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 edit(@RequestBody RecordPlan plan) { + public void update(@RequestBody RecordPlan plan) { if (plan == null || plan.getId() == 0) { throw new ControllerException(ErrorCode.ERROR400); } 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 index 11cc1a0a..e7431409 100644 --- 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 @@ -12,10 +12,13 @@ import java.util.List; public class RecordPlanParam { @Schema(description = "关联的通道ID") - private Integer channelId; + private List channelIds; @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") - private Integer deviceDbId; + private List deviceDbIds; + + @Schema(description = "全部关联/全部取消关联") + private Boolean all; @Schema(description = "录制计划ID, ID为空是删除关联的计划") private Integer planId; diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index bba30ea4..4e649fa5 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -9,82 +9,30 @@ 搜索: - - 在线状态: - - - - - - 录制计划: - - - - - - 类型: - - - - - - - 按国标设备添加 + 添加 - - 按国标设备移除 - - + - - + - + - + - - + + + - - - - - - - - - @@ -99,37 +47,31 @@ :total="total"> + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 7f12794f..3772c490 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -10,8 +10,13 @@ @close="close()" >
- + + + + + +
保存 @@ -38,67 +43,111 @@ export default { return { options: [], loading: false, + edit: false, + planName: null, + id: null, showDialog: false, - channel: "", - deviceDbId: "", endCallback: "", byteTime: "", - planList: [], }; }, methods: { - openDialog: function (channel, deviceDbId, endCallback) { - this.channel = channel; - this.deviceDbId = deviceDbId; + openDialog: function (recordPlan, endCallback) { + console.log(recordPlan); this.endCallback = endCallback; this.showDialog = true; this.byteTime= ""; - if (channel.recordPlanId) { - // 请求plan信息 + if (recordPlan) { + this.edit = true + this.planName = recordPlan.name + this.id = recordPlan.id + this.$axios({ + method: 'get', + url: "/api/record/plan/get", + params: { + planId: recordPlan.id, + } + }).then((res) => { + if (res.data.code === 0) { + this.byteTime = this.plan2Byte(res.data.data.planItemList) + } + }).catch((error) => { + console.error(error) + }); } }, onSubmit: function () { let planList = this.byteTime2PlanList(); - console.log(planList) - this.$axios({ - method: 'post', - url: "/api/record/plan/add", - params: { - channelId: this.channel?this.channel.id:null, - deviceDbId: this.deviceDbId, - planList: planList - } - }).then((res) => { - if (res.data.code === 0) { - this.$message({ - showClose: true, - message: '添加成功', - type: 'success', - }); - this.showDialog = false; - this.endCallback() - } else { - this.$message({ - showClose: true, - message: res.data.msg, - type: 'error' - }); - } - }).catch((error) => { - console.error(error) - }); + if (!this.edit) { + this.$axios({ + method: 'post', + url: "/api/record/plan/add", + data: { + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '添加成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + }else { + this.$axios({ + method: 'post', + url: "/api/record/plan/update", + data: { + id: this.id, + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '更新成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + } + }, close: function () { - this.channel = ""; - this.deviceDbId = ""; this.showDialog = false; + this.id = null + this.planName = null + this.byteTime = "" + this.endCallback = "" if(this.endCallback) { this.endCallback(); } }, byteTime2PlanList() { - this.planList = [] if (this.byteTime.length === 0) { return; } @@ -114,8 +163,8 @@ export default { continue } for (let j = 0; j < planArray.length; j++) { - console.log(planArray[j]) planList.push({ + id: this.id, startTime: planArray[j].startTime, stopTime: planArray[j].stopTime, weekDay: week @@ -149,6 +198,27 @@ export default { } } return result; + }, + plan2Byte(planList) { + console.log(planList); + let byte = "" + let indexArray = {} + for (let i = 0; i < planList.length; i++) { + let index = planList[i].startTime/1000/60/30 + let endIndex = planList[i].stopTime/1000/60/30 + for (let j = index; j <= endIndex; j++) { + indexArray[j + (planList[i].weekDay - 1 )*48] = j + i*48 + } + } + console.log(indexArray) + for (let i = 0; i < 336; i++) { + if (indexArray[i]){ + byte += "1" + }else { + byte += "0" + } + } + return byte } }, }; diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue new file mode 100755 index 00000000..173b5008 --- /dev/null +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -0,0 +1,500 @@ + + + + +