增加通道关联以及录制计划接口完善

This commit is contained in:
648540858
2024-11-21 23:20:56 +08:00
parent 4b694954d4
commit 1567f2e3e7
13 changed files with 899 additions and 159 deletions

View File

@@ -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<Integer> channelIds, Integer planId);
void link(List<Integer> channelIds, Integer planId);
PageInfo<CommonGBChannel> queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink);
void linkAll(Integer planId);
void cleanAll(Integer planId);
}

View File

@@ -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<Integer> channelIds, Integer planId) {
public void link(List<Integer> channelIds, Integer planId) {
if (planId == null) {
log.info("[录制计划] 移除通道关联的计划");
channelMapper.removeRecordPlan(channelIds);
}else {
channelMapper.addRecordPlan(channelIds, planId);
}
// TODO 更新录像队列
}
@Override
public PageInfo<CommonGBChannel> 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<CommonGBChannel> 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);
}
}