diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java index 3c481cdc..8a941d3c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/ChannelProvider.java @@ -17,7 +17,7 @@ public class ChannelProvider { " stream_proxy_id,\n" + " create_time,\n" + " update_time,\n" + - " record_plan,\n" + + " record_plan_id,\n" + " coalesce(gb_device_id, device_id) as gb_device_id,\n" + " coalesce(gb_name, name) as gb_name,\n" + " coalesce(gb_manufacturer, manufacturer) as gb_manufacturer,\n" + @@ -198,8 +198,8 @@ public class ChannelProvider { if (params.get("online") != null && !(Boolean)params.get("online")) { sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'"); } - if (params.get("hasRecordPlan") != null && !(Boolean)params.get("hasRecordPlan")) { - sqlBuild.append(" AND record_plan == 0"); + if (params.get("hasRecordPlan") != null && (Boolean)params.get("hasRecordPlan")) { + sqlBuild.append(" AND record_plan_id > 0"); } if (params.get("channelType") != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java index 9c8b4687..2a269836 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -1,9 +1,17 @@ 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.service.bean.RecordPlan; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +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.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; @Tag(name = "录制计划") @Slf4j @@ -11,5 +19,20 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/api/record/plan") public class RecordPlanController { + @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 planList + ) { + if (channelId == null && deviceDbId == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); + } + + + + } } diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index a31917ce..bba30ea4 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -76,7 +76,7 @@ diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 3b54b1b6..7f12794f 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -11,9 +11,9 @@ >
- + -
+
保存 取消
@@ -36,7 +36,6 @@ export default { }, data() { return { - value:"", options: [], loading: false, showDialog: false, @@ -44,6 +43,7 @@ export default { deviceDbId: "", endCallback: "", byteTime: "", + planList: [], }; }, methods: { @@ -52,15 +52,22 @@ export default { this.deviceDbId = deviceDbId; this.endCallback = endCallback; this.showDialog = true; + this.byteTime= ""; + if (channel.recordPlanId) { + // 请求plan信息 + + } }, onSubmit: function () { + let planList = this.byteTime2PlanList(); + console.log(planList) this.$axios({ method: 'post', - url: "/api/user/add", + url: "/api/record/plan/add", params: { - username: this.username, - password: this.password, - roleId: this.roleId + channelId: this.channel?this.channel.id:null, + deviceDbId: this.deviceDbId, + planList: planList } }).then((res) => { if (res.data.code === 0) { @@ -68,11 +75,9 @@ export default { showClose: true, message: '添加成功', type: 'success', - }); this.showDialog = false; - this.listChangeCallback() - + this.endCallback() } else { this.$message({ showClose: true, @@ -85,7 +90,6 @@ export default { }); }, close: function () { - console.log(this.byteTime) this.channel = ""; this.deviceDbId = ""; this.showDialog = false; @@ -93,6 +97,59 @@ export default { this.endCallback(); } }, + byteTime2PlanList() { + this.planList = [] + if (this.byteTime.length === 0) { + return; + } + const DayTimes = 24 * 2; + let planList = [] + let week = 1; + // 把 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 + } + for (let j = 0; j < planArray.length; j++) { + console.log(planArray[j]) + planList.push({ + startTime: planArray[j].startTime, + stopTime: planArray[j].stopTime, + weekDay: week + }) + } + week ++; + } + return planList + }, + byteTime2Plan(weekItem){ + let startTime = 0; + let endTime = 0; + 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 + } + } else { + if (endTime !== 0){ + result.push({ + startTime: startTime * 60 * 1000, + stopTime: endTime * 60 * 1000, + }) + startTime = 0 + endTime = 0 + } + } + } + return result; + } }, }; diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 0d9322a5..705eb301 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -147,7 +147,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, - record_plan integer, + record_plan_id integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index 223d80ab..f589329e 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -163,7 +163,7 @@ create table wvp_device_channel gb_download_speed character varying(255), gb_svc_space_support_mod integer, gb_svc_time_support_mode integer, - record_plan integer, + record_plan_id integer, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id),