临时提交
parent
24c3c45565
commit
cc56ed3355
|
@ -10,11 +10,11 @@ public class RecordPlanItem {
|
||||||
@Schema(description = "计划项数据库ID")
|
@Schema(description = "计划项数据库ID")
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@Schema(description = "计划开始时间")
|
@Schema(description = "计划开始时间的序号, 从0点开始,每半个小时增加1")
|
||||||
private Long startTime;
|
private Integer start;
|
||||||
|
|
||||||
@Schema(description = "计划结束时间")
|
@Schema(description = "计划结束时间的序号, 从0点开始,每半个小时增加1")
|
||||||
private Long stopTime;
|
private Integer stop;
|
||||||
|
|
||||||
@Schema(description = "计划周几执行")
|
@Schema(description = "计划周几执行")
|
||||||
private Integer weekDay;
|
private Integer weekDay;
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package com.genersoft.iot.vmp.service.impl;
|
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.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.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.IRecordPlanService;
|
||||||
import com.genersoft.iot.vmp.service.bean.RecordPlan;
|
import com.genersoft.iot.vmp.service.bean.RecordPlan;
|
||||||
import com.genersoft.iot.vmp.service.bean.RecordPlanItem;
|
import com.genersoft.iot.vmp.service.bean.RecordPlanItem;
|
||||||
|
@ -13,9 +19,15 @@ import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.sip.InvalidArgumentException;
|
||||||
|
import javax.sip.SipException;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -28,6 +40,43 @@ public class RecordPlanServiceImpl implements IRecordPlanService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CommonGBChannelMapper channelMapper;
|
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
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void add(RecordPlan plan) {
|
public void add(RecordPlan plan) {
|
||||||
|
@ -61,8 +110,8 @@ public class RecordPlanServiceImpl implements IRecordPlanService {
|
||||||
public void update(RecordPlan plan) {
|
public void update(RecordPlan plan) {
|
||||||
plan.setUpdateTime(DateUtil.getNow());
|
plan.setUpdateTime(DateUtil.getNow());
|
||||||
recordPlanMapper.update(plan);
|
recordPlanMapper.update(plan);
|
||||||
recordPlanMapper.cleanItems(plan.getId());
|
if (plan.getPlanItemList() != null && !plan.getPlanItemList().isEmpty()){
|
||||||
if (plan.getPlanItemList() != null){
|
recordPlanMapper.cleanItems(plan.getId());
|
||||||
recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList());
|
recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList());
|
||||||
}
|
}
|
||||||
// TODO 更新录像队列
|
// TODO 更新录像队列
|
||||||
|
|
|
@ -26,13 +26,13 @@ public interface RecordPlanMapper {
|
||||||
|
|
||||||
@Insert(" <script>" +
|
@Insert(" <script>" +
|
||||||
"INSERT INTO wvp_record_plan_item (" +
|
"INSERT INTO wvp_record_plan_item (" +
|
||||||
"start_time," +
|
"start," +
|
||||||
"stop_time, " +
|
"stop, " +
|
||||||
"week_day," +
|
"week_day," +
|
||||||
"plan_id) " +
|
"plan_id) " +
|
||||||
"VALUES" +
|
"VALUES" +
|
||||||
"<foreach collection='planItemList' index='index' item='item' separator=','> " +
|
"<foreach collection='planItemList' index='index' item='item' separator=','> " +
|
||||||
"(#{item.startTime}, #{item.stopTime}, #{item.weekDay},#{planId})" +
|
"(#{item.start}, #{item.stop}, #{item.weekDay},#{planId})" +
|
||||||
"</foreach> " +
|
"</foreach> " +
|
||||||
" </script>")
|
" </script>")
|
||||||
void batchAddItem(@Param("planId") int planId, List<RecordPlanItem> planItemList);
|
void batchAddItem(@Param("planId") int planId, List<RecordPlanItem> planItemList);
|
||||||
|
|
|
@ -157,7 +157,6 @@ export default {
|
||||||
// 把 336长度的 list 分成 7 组,每组 48 个
|
// 把 336长度的 list 分成 7 组,每组 48 个
|
||||||
for (let i = 0; i < this.byteTime.length; i += DayTimes) {
|
for (let i = 0; i < this.byteTime.length; i += DayTimes) {
|
||||||
let planArray = this.byteTime2Plan(this.byteTime.slice(i, i + DayTimes));
|
let planArray = this.byteTime2Plan(this.byteTime.slice(i, i + DayTimes));
|
||||||
console.log(planArray)
|
|
||||||
if(!planArray || planArray.length === 0) {
|
if(!planArray || planArray.length === 0) {
|
||||||
week ++;
|
week ++;
|
||||||
continue
|
continue
|
||||||
|
@ -165,8 +164,8 @@ export default {
|
||||||
for (let j = 0; j < planArray.length; j++) {
|
for (let j = 0; j < planArray.length; j++) {
|
||||||
planList.push({
|
planList.push({
|
||||||
id: this.id,
|
id: this.id,
|
||||||
startTime: planArray[j].startTime,
|
start: planArray[j].start,
|
||||||
stopTime: planArray[j].stopTime,
|
stop: planArray[j].stop,
|
||||||
weekDay: week
|
weekDay: week
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -175,44 +174,52 @@ export default {
|
||||||
return planList
|
return planList
|
||||||
},
|
},
|
||||||
byteTime2Plan(weekItem){
|
byteTime2Plan(weekItem){
|
||||||
let startTime = 0;
|
let start = null;
|
||||||
let endTime = 0;
|
let stop = null;
|
||||||
let result = []
|
let result = []
|
||||||
|
|
||||||
for (let i = 0; i < weekItem.length; i++) {
|
for (let i = 0; i < weekItem.length; i++) {
|
||||||
let item = weekItem[i]
|
let item = weekItem[i]
|
||||||
if (item === '1') {
|
if (item === '1') { // 表示选中
|
||||||
endTime = 30*i
|
stop = i
|
||||||
if (startTime === 0 ) {
|
if (start === null ) {
|
||||||
startTime = 30*i
|
start = i
|
||||||
|
}
|
||||||
|
if (i === weekItem.length - 1) {
|
||||||
|
result.push({
|
||||||
|
start: start,
|
||||||
|
stop: stop,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (endTime !== 0){
|
if (stop !== 0){
|
||||||
result.push({
|
result.push({
|
||||||
startTime: startTime * 60 * 1000,
|
start: start,
|
||||||
stopTime: endTime * 60 * 1000,
|
stop: stop,
|
||||||
})
|
})
|
||||||
startTime = 0
|
start = 0
|
||||||
endTime = 0
|
stop = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
plan2Byte(planList) {
|
plan2Byte(planList) {
|
||||||
console.log(planList);
|
|
||||||
let byte = ""
|
let byte = ""
|
||||||
let indexArray = {}
|
let indexArray = {}
|
||||||
for (let i = 0; i < planList.length; i++) {
|
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++) {
|
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++) {
|
for (let i = 0; i < 336; i++) {
|
||||||
if (indexArray[i]){
|
if (indexArray["key_" + i]){
|
||||||
byte += "1"
|
byte += "1"
|
||||||
}else {
|
}else {
|
||||||
byte += "0"
|
byte += "0"
|
||||||
|
|
|
@ -440,10 +440,10 @@ create table wvp_record_plan
|
||||||
create table wvp_record_plan_item
|
create table wvp_record_plan_item
|
||||||
(
|
(
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
start_time bigint,
|
start int,
|
||||||
stop_time bigint,
|
stop int,
|
||||||
week_day int,
|
week_day int,
|
||||||
plan_id int,
|
plan_id int,
|
||||||
create_time character varying(50),
|
create_time character varying(50),
|
||||||
update_time character varying(50)
|
update_time character varying(50)
|
||||||
);
|
);
|
||||||
|
|
|
@ -457,8 +457,8 @@ create table wvp_record_plan
|
||||||
create table wvp_record_plan_item
|
create table wvp_record_plan_item
|
||||||
(
|
(
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
start_time int8,
|
start int,
|
||||||
stop_time int8,
|
stop int,
|
||||||
week_day int,
|
week_day int,
|
||||||
plan_id int,
|
plan_id int,
|
||||||
create_time character varying(50),
|
create_time character varying(50),
|
||||||
|
|
Loading…
Reference in New Issue