临时提交

pull/1719/head
648540858 2024-11-27 22:44:22 +08:00
parent 24c3c45565
commit cc56ed3355
6 changed files with 91 additions and 35 deletions

View File

@ -10,11 +10,11 @@ public class RecordPlanItem {
@Schema(description = "计划项数据库ID")
private int id;
@Schema(description = "计划开始时间")
private Long startTime;
@Schema(description = "计划开始时间的序号, 从0点开始每半个小时增加1")
private Integer start;
@Schema(description = "计划结束时间")
private Long stopTime;
@Schema(description = "计划结束时间的序号, 从0点开始每半个小时增加1")
private Integer stop;
@Schema(description = "计划周几执行")
private Integer weekDay;

View File

@ -1,8 +1,14 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.InviteInfo;
import com.genersoft.iot.vmp.common.InviteSessionStatus;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.service.IRecordPlanService;
import com.genersoft.iot.vmp.service.bean.RecordPlan;
import com.genersoft.iot.vmp.service.bean.RecordPlanItem;
@ -13,9 +19,15 @@ 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.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.util.List;
@Service
@ -28,6 +40,43 @@ public class RecordPlanServiceImpl implements IRecordPlanService {
@Autowired
private CommonGBChannelMapper channelMapper;
@Autowired
private IGbChannelService channelService;
/**
*
*/
@Async("taskExecutor")
@org.springframework.context.event.EventListener
public void onApplicationEvent(MediaArrivalEvent event) {
}
/**
*
*/
@Async("taskExecutor")
@EventListener
public void onApplicationEvent(MediaDepartureEvent event) {
// 流断开,检查是否还处于录像状态, 如果是则继续录像
}
@Scheduled(cron = "0 */30 * * * *")
public void execution() {
// 执行计划
// 查询startTime等于现在的 开始录像
// 查询stopTime等于现在的结束录像
// 查询处于中间的,验证录像是否正在进行
// TODO 无人观看要确保处于录像状态的通道不被移除
}
// 系统启动时
@Override
@Transactional
public void add(RecordPlan plan) {
@ -61,8 +110,8 @@ public class RecordPlanServiceImpl implements IRecordPlanService {
public void update(RecordPlan plan) {
plan.setUpdateTime(DateUtil.getNow());
recordPlanMapper.update(plan);
recordPlanMapper.cleanItems(plan.getId());
if (plan.getPlanItemList() != null){
if (plan.getPlanItemList() != null && !plan.getPlanItemList().isEmpty()){
recordPlanMapper.cleanItems(plan.getId());
recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList());
}
// TODO 更新录像队列

View File

@ -26,13 +26,13 @@ public interface RecordPlanMapper {
@Insert(" <script>" +
"INSERT INTO wvp_record_plan_item (" +
"start_time," +
"stop_time, " +
"start," +
"stop, " +
"week_day," +
"plan_id) " +
"VALUES" +
"<foreach collection='planItemList' index='index' item='item' separator=','> " +
"(#{item.startTime}, #{item.stopTime}, #{item.weekDay},#{planId})" +
"(#{item.start}, #{item.stop}, #{item.weekDay},#{planId})" +
"</foreach> " +
" </script>")
void batchAddItem(@Param("planId") int planId, List<RecordPlanItem> planItemList);

View File

@ -157,7 +157,6 @@ export default {
// 336 list 7 48
for (let i = 0; i < this.byteTime.length; i += DayTimes) {
let planArray = this.byteTime2Plan(this.byteTime.slice(i, i + DayTimes));
console.log(planArray)
if(!planArray || planArray.length === 0) {
week ++;
continue
@ -165,8 +164,8 @@ export default {
for (let j = 0; j < planArray.length; j++) {
planList.push({
id: this.id,
startTime: planArray[j].startTime,
stopTime: planArray[j].stopTime,
start: planArray[j].start,
stop: planArray[j].stop,
weekDay: week
})
}
@ -175,44 +174,52 @@ export default {
return planList
},
byteTime2Plan(weekItem){
let startTime = 0;
let endTime = 0;
let start = null;
let stop = null;
let result = []
for (let i = 0; i < weekItem.length; i++) {
let item = weekItem[i]
if (item === '1') {
endTime = 30*i
if (startTime === 0 ) {
startTime = 30*i
if (item === '1') { //
stop = i
if (start === null ) {
start = i
}
if (i === weekItem.length - 1) {
result.push({
start: start,
stop: stop,
})
}
} else {
if (endTime !== 0){
if (stop !== 0){
result.push({
startTime: startTime * 60 * 1000,
stopTime: endTime * 60 * 1000,
start: start,
stop: stop,
})
startTime = 0
endTime = 0
start = 0
stop = 0
}
}
}
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
let weekDay = planList[i].weekDay
let index = planList[i].start
let endIndex = planList[i].stop
console.log(index + "===" + endIndex)
for (let j = index; j <= endIndex; j++) {
indexArray[j + (planList[i].weekDay - 1 )*48] = j + i*48
indexArray["key_" + (j + (weekDay - 1 )*48)] = 1
console.log("key_" + (j + (weekDay - 1 )*48))
}
}
console.log(indexArray)
for (let i = 0; i < 336; i++) {
if (indexArray[i]){
if (indexArray["key_" + i]){
byte += "1"
}else {
byte += "0"

View File

@ -440,10 +440,10 @@ create table wvp_record_plan
create table wvp_record_plan_item
(
id serial primary key,
start_time bigint,
stop_time bigint,
start int,
stop int,
week_day int,
plan_id int,
plan_id int,
create_time character varying(50),
update_time character varying(50)
);

View File

@ -457,8 +457,8 @@ create table wvp_record_plan
create table wvp_record_plan_item
(
id serial primary key,
start_time int8,
stop_time int8,
start int,
stop int,
week_day int,
plan_id int,
create_time character varying(50),