增加数据库结构以及接口
parent
c7e33f655e
commit
988845f246
|
@ -93,6 +93,9 @@ public interface DeviceChannelMapper {
|
|||
@SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId")
|
||||
List<DeviceChannel> queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId);
|
||||
|
||||
@Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}")
|
||||
List<Integer> queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId);
|
||||
|
||||
@Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}")
|
||||
int cleanChannelsByDeviceId(@Param("deviceId") int deviceId);
|
||||
|
||||
|
|
|
@ -122,4 +122,7 @@ public interface IDeviceChannelService {
|
|||
|
||||
DeviceChannel getOneBySourceId(int deviceDbId, String channelId);
|
||||
|
||||
List<DeviceChannel> queryChaneListByDeviceDbId(Integer deviceDbId);
|
||||
|
||||
List<Integer> queryChaneIdListByDeviceDbId(Integer deviceDbId);
|
||||
}
|
||||
|
|
|
@ -348,6 +348,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
|||
return channelMapper.queryChannelsByDeviceDbId(device.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceChannel> queryChaneListByDeviceDbId(Integer deviceDbId) {
|
||||
return channelMapper.queryChannelsByDeviceDbId(deviceDbId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> queryChaneIdListByDeviceDbId(Integer deviceDbId) {
|
||||
return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition) {
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
|
|
|
@ -94,4 +94,6 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i
|
|||
public void handForPlatform(RequestEvent evt, Platform parentPlatform, Element element) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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(" <script>" +
|
||||
"INSERT INTO wvp_cloud_record (" +
|
||||
" name," +
|
||||
" snap," +
|
||||
" create_time," +
|
||||
" update_time) " +
|
||||
"VALUES (" +
|
||||
" #{name}," +
|
||||
" #{snap}," +
|
||||
" #{createTime}," +
|
||||
" #{updateTime})" +
|
||||
" </script>")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
void add(RecordPlan plan);
|
||||
|
||||
RecordPlan get(Integer planId);
|
||||
|
||||
List<RecordPlan> query(String query);
|
||||
|
||||
void update(RecordPlan plan);
|
||||
|
||||
void delete(Integer planId);
|
||||
|
||||
|
||||
void batchAddItem(int planId, List<RecordPlanItem> planItemList);
|
||||
|
||||
}
|
|
@ -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<RecordPlan> 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<Integer> channelIds = new ArrayList<>();
|
||||
if (param.getChannelId() != null) {
|
||||
channelIds.add(param.getChannelId());
|
||||
}else {
|
||||
List<Integer> 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<RecordPlan> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
111
|
||||
</body>
|
||||
</html>
|
|
@ -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)
|
||||
);
|
||||
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue