增加数据库结构以及接口
This commit is contained in:
@@ -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<RecordPlan> query(Integer page, Integer count, String query);
|
||||
|
||||
void add(RecordPlan plan);
|
||||
|
||||
void linke(List<Integer> channelIds, Integer planId);
|
||||
}
|
||||
@@ -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<RecordPlanItem> planItemList;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<RecordPlan> query(Integer page, Integer count, String query) {
|
||||
PageHelper.startPage(page, count);
|
||||
if (query != null) {
|
||||
query = query.replaceAll("/", "//")
|
||||
.replaceAll("%", "/%")
|
||||
.replaceAll("_", "/_");
|
||||
}
|
||||
List<RecordPlan> all = recordPlanMapper.query(query);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void linke(List<Integer> channelIds, Integer planId) {
|
||||
if (planId == null) {
|
||||
log.info("[录制计划] 移除通道关联的计划");
|
||||
channelMapper.removeRecordPlan(channelIds);
|
||||
}else {
|
||||
channelMapper.addRecordPlan(channelIds, planId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user