From d2f9102ff07faec5ec9d5554c07114fb6db462a5 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 18 Nov 2024 18:00:21 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BD=95=E5=88=B6?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/bean/RecordPlan.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java new file mode 100644 index 00000000..0ed21513 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java @@ -0,0 +1,27 @@ +package com.genersoft.iot.vmp.service.bean; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "录制计划") +public class RecordPlan { + + @Schema(description = "计划数据库ID") + private int id; + + @Schema(description = "计划关联的通道ID") + private Integer channelId; + + @Schema(description = "计划开始时间") + private Long startTime; + + @Schema(description = "计划结束时间") + private Long stopTime; + + @Schema(description = "计划周几执行") + private Integer weekDay; + + @Schema(description = "是否开启定时截图") + private Boolean snap; +} From ea2751e29b538dfb1c9d2f09b8f90333578a5590 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Nov 2024 16:42:11 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=88=B6?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=9A=84=E9=A1=B5=E9=9D=A2=E4=B8=8E=E9=80=9A?= =?UTF-8?q?=E9=81=93=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/gb28181/bean/CommonGBChannel.java | 3 + .../controller/CommonChannelController.java | 21 ++ .../gb28181/dao/CommonGBChannelMapper.java | 2 + .../gb28181/dao/provider/ChannelProvider.java | 32 +++ .../gb28181/service/IGbChannelService.java | 3 + .../service/impl/GbChannelServiceImpl.java | 12 + .../recordPlan/RecordPlanController.java | 15 ++ web_src/src/components/RecordPLan.vue | 241 ++++++++++++++++++ web_src/src/layout/UiHeader.vue | 1 + web_src/src/router/index.js | 5 + 数据库/2.7.3/初始化-mysql-2.7.3.sql | 1 + .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 1 + 12 files changed, 337 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java create mode 100755 web_src/src/components/RecordPLan.vue diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java index 6327688b..ea606692 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java @@ -126,6 +126,9 @@ public class CommonGBChannel { @Schema(description = "关联的国标设备数据库ID") private Integer gbDeviceDbId; + @Schema(description = "二进制保存的录制计划, 每一位表示每个小时的前半个小时") + private Long recordPLan; + @Schema(description = "关联的推流Id(流来源是推流时有效)") private Integer streamPushId; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java index 6f5295da..48ced143 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/CommonChannelController.java @@ -101,11 +101,31 @@ public class CommonChannelController { return channel; } + @Operation(summary = "获取通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页查询数量", required = true) + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasRecordPlan", description = "是否已设置录制计划") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @GetMapping("/list") + public PageInfo queryList(int page, int count, + @RequestParam(required = false) String query, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasRecordPlan, + @RequestParam(required = false) Integer channelType){ + if (ObjectUtils.isEmpty(query)){ + query = null; + } + return channelService.queryList(page, count, query, online, hasRecordPlan, channelType); + } + @Operation(summary = "获取关联行政区划通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "page", description = "当前页", required = true) @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") @Parameter(name = "civilCode", description = "行政区划") @GetMapping("/civilcode/list") public PageInfo queryListByCivilCode(int page, int count, @@ -124,6 +144,7 @@ public class CommonChannelController { @Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "query", description = "查询内容") @Parameter(name = "online", description = "是否在线") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") @Parameter(name = "groupDeviceId", description = "业务分组下的父节点ID") @GetMapping("/parent/list") public PageInfo queryListByParentId(int page, int count, diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 664329e4..99aff973 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -457,4 +457,6 @@ public interface CommonGBChannelMapper { " "}) void updateGpsByDeviceIdForStreamPush(List channels); + @SelectProvider(type = ChannelProvider.class, method = "queryList") + List queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); } 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 092c90dc..3c481cdc 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,6 +17,7 @@ public class ChannelProvider { " stream_proxy_id,\n" + " create_time,\n" + " update_time,\n" + + " record_plan,\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" + @@ -182,6 +183,37 @@ public class ChannelProvider { return sqlBuild.toString(); } + public String queryList(Map params ){ + StringBuilder sqlBuild = new StringBuilder(); + sqlBuild.append(BASE_SQL); + sqlBuild.append(" where channel_type = 0 "); + if (params.get("query") != null) { + sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') escape '/'" + + " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') escape '/' )") + ; + } + if (params.get("online") != null && (Boolean)params.get("online")) { + sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'"); + } + 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("channelType") != null) { + if ((Integer)params.get("channelType") == 0) { + sqlBuild.append(" AND device_db_id is not null"); + }else if ((Integer)params.get("channelType") == 1) { + sqlBuild.append(" AND stream_push_id is not null"); + }else if ((Integer)params.get("channelType") == 2) { + sqlBuild.append(" AND stream_proxy_id is not null"); + } + } + return sqlBuild.toString(); + } + public String queryInListByStatus(Map params ){ StringBuilder sqlBuild = new StringBuilder(); sqlBuild.append(BASE_SQL); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java index 2d8f9531..8dc67df2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGbChannelService.java @@ -84,4 +84,7 @@ public interface IGbChannelService { List queryListByStreamPushList(List streamPushList); void updateGpsByDeviceIdForStreamPush(List channels); + + PageInfo queryList(int page, int count, String query, Boolean online, Boolean hasRecordPlan, Integer channelType); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index f19f4f9c..792fd88b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -714,4 +714,16 @@ public class GbChannelServiceImpl implements IGbChannelService { public void updateGpsByDeviceIdForStreamPush(List channels) { commonGBChannelMapper.updateGpsByDeviceIdForStreamPush(channels); } + + @Override + public PageInfo queryList(int page, int count, String query, Boolean online, Boolean hasRecordPlan, Integer channelType) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = commonGBChannelMapper.queryList(query, online, hasRecordPlan, channelType); + return new PageInfo<>(all); + } } 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 new file mode 100644 index 00000000..9c8b4687 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/RecordPlanController.java @@ -0,0 +1,15 @@ +package com.genersoft.iot.vmp.vmanager.recordPlan; + +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; + +@Tag(name = "录制计划") +@Slf4j +@RestController +@RequestMapping("/api/record/plan") +public class RecordPlanController { + + +} diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue new file mode 100755 index 00000000..ed4215fd --- /dev/null +++ b/web_src/src/components/RecordPLan.vue @@ -0,0 +1,241 @@ + + + + + diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index 0561bea7..dda1a8ea 100755 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -15,6 +15,7 @@ 行政区划 业务分组 + 录制计划 云端录像 节点管理 国标级联 diff --git a/web_src/src/router/index.js b/web_src/src/router/index.js index f85c5a5a..5d609c4e 100755 --- a/web_src/src/router/index.js +++ b/web_src/src/router/index.js @@ -26,6 +26,7 @@ import rtcPlayer from '../components/dialog/rtcPlayer.vue' import region from '../components/region.vue' import group from '../components/group.vue' import operations from '../components/operations.vue' +import recordPLan from '../components/RecordPLan.vue' const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { @@ -148,6 +149,10 @@ export default new VueRouter({ path: '/operations', component: operations, }, + { + path: '/recordPLan', + component: recordPLan, + }, ] }, { diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index d572843d..0d9322a5 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -147,6 +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, 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 cb06d2ee..223d80ab 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -163,6 +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, stream_push_id integer, stream_proxy_id integer, constraint uk_wvp_device_channel_unique_device_channel unique (device_db_id, device_id), From 8b88a5e0344fa90ea37698f6ea399847a22d7b54 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Nov 2024 18:03:43 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=95=E5=88=B6?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/package.json | 1 + web_src/src/components/RecordPLan.vue | 14 +++ .../src/components/dialog/editRecordPlan.vue | 98 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 web_src/src/components/dialog/editRecordPlan.vue diff --git a/web_src/package.json b/web_src/package.json index c314b9ba..78582b87 100644 --- a/web_src/package.json +++ b/web_src/package.json @@ -15,6 +15,7 @@ "@liveqing/liveplayer": "^2.7.10", "@wchbrad/vue-easy-tree": "^1.0.12", "axios": "^0.24.0", + "byte-weektime-picker": "^1.1.1", "core-js": "^2.6.5", "echarts": "^4.9.0", "element-ui": "^2.15.14", diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index ed4215fd..a31917ce 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -81,6 +81,12 @@ + + + + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue new file mode 100644 index 00000000..3b54b1b6 --- /dev/null +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -0,0 +1,98 @@ + + + From 2dcbee74b048b58a52689dd7b12ca4d8e2f5e531 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 18:37:39 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E8=AE=A1=E5=88=92=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/provider/ChannelProvider.java | 6 +- .../recordPlan/RecordPlanController.java | 27 ++++++- web_src/src/components/RecordPLan.vue | 2 +- .../src/components/dialog/editRecordPlan.vue | 79 ++++++++++++++++--- 数据库/2.7.3/初始化-mysql-2.7.3.sql | 2 +- .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 2 +- 6 files changed, 99 insertions(+), 19 deletions(-) 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), From 0cacdb59282dc7d46dc849075c1c757a4514e614 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 20 Nov 2024 22:33:21 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=93=E6=9E=84=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vmp/gb28181/dao/DeviceChannelMapper.java | 3 + .../service/IDeviceChannelService.java | 3 + .../impl/DeviceChannelServiceImpl.java | 10 ++ .../cmd/BroadcastResponseMessageHandler.java | 2 + .../iot/vmp/service/IRecordPlanService.java | 23 +++++ .../iot/vmp/service/bean/RecordPlan.java | 25 +++-- .../iot/vmp/service/bean/RecordPlanItem.java | 25 +++++ .../service/impl/RecordPlanServiceImpl.java | 79 ++++++++++++++++ .../vmp/storager/dao/RecordPlanMapper.java | 40 ++++++++ .../recordPlan/RecordPlanController.java | 93 +++++++++++++++++-- .../recordPlan/bean/RecordPlanParam.java | 22 +++++ src/main/resources/index.html | 10 ++ 数据库/2.7.3/初始化-mysql-2.7.3.sql | 20 ++++ .../2.7.3/初始化-postgresql-kingbase-2.7.3.sql | 20 ++++ 14 files changed, 356 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java create mode 100644 src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java create mode 100644 src/main/resources/index.html diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index a5263235..75131ca6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -93,6 +93,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") + List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 81d9f9af..4f0ee8e1 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -122,4 +122,7 @@ public interface IDeviceChannelService { DeviceChannel getOneBySourceId(int deviceDbId, String channelId); + List queryChaneListByDeviceDbId(Integer deviceDbId); + + List queryChaneIdListByDeviceDbId(Integer deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index 654648fe..cd30f214 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -350,6 +350,16 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { return channelMapper.queryChannelsByDeviceDbId(device.getId()); } + @Override + public List queryChaneListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChannelsByDeviceDbId(deviceDbId); + } + + @Override + public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { + return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + } + @Override public void updateChannelGPS(Device device, DeviceChannel deviceChannel, MobilePosition mobilePosition) { if (userSetting.getSavePositionHistory()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java index 97748222..2567b762 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java @@ -94,4 +94,6 @@ public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent i public void handForPlatform(RequestEvent evt, Platform parentPlatform, Element element) { } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java new file mode 100644 index 00000000..641ddb18 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -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 query(Integer page, Integer count, String query); + + void add(RecordPlan plan); + + void linke(List channelIds, Integer planId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java index 0ed21513..5333b2c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlan.java @@ -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 planItemList; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java new file mode 100644 index 00000000..14383cb1 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/RecordPlanItem.java @@ -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; + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java new file mode 100644 index 00000000..661bea1b --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -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 query(Integer page, Integer count, String query) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = recordPlanMapper.query(query); + return new PageInfo<>(all); + } + + @Override + public void linke(List channelIds, Integer planId) { + if (planId == null) { + log.info("[录制计划] 移除通道关联的计划"); + channelMapper.removeRecordPlan(channelIds); + }else { + channelMapper.addRecordPlan(channelIds, planId); + } + + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java new file mode 100644 index 00000000..cd4f3173 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -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(" ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void add(RecordPlan plan); + + RecordPlan get(Integer planId); + + List query(String query); + + void update(RecordPlan plan); + + void delete(Integer planId); + + + void batchAddItem(int planId, List planItemList); + +} 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 2a269836..6f3fdfa3 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 @@ -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 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 channelIds = new ArrayList<>(); + if (param.getChannelId() != null) { + channelIds.add(param.getChannelId()); + }else { + List 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 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); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java new file mode 100644 index 00000000..11cc1a0a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -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; +} diff --git a/src/main/resources/index.html b/src/main/resources/index.html new file mode 100644 index 00000000..9d2fdca2 --- /dev/null +++ b/src/main/resources/index.html @@ -0,0 +1,10 @@ + + + + + Title + + +111 + + \ No newline at end of file diff --git a/数据库/2.7.3/初始化-mysql-2.7.3.sql b/数据库/2.7.3/初始化-mysql-2.7.3.sql index 705eb301..faada9cd 100644 --- a/数据库/2.7.3/初始化-mysql-2.7.3.sql +++ b/数据库/2.7.3/初始化-mysql-2.7.3.sql @@ -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) +); + diff --git a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql index f589329e..9ef3e926 100644 --- a/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql +++ b/数据库/2.7.3/初始化-postgresql-kingbase-2.7.3.sql @@ -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) +); + From 4b694954d4285fd324f5d78b0d4ed6ba42cb5d3b Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 21 Nov 2024 20:50:22 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RecordPlanServiceImpl.java | 10 +++++- .../vmp/storager/dao/RecordPlanMapper.java | 34 ++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index 661bea1b..aa6d922d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -40,7 +40,15 @@ public class RecordPlanServiceImpl implements IRecordPlanService { @Override public RecordPlan get(Integer planId) { - return recordPlanMapper.get(planId); + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + return null; + } + List recordPlanItemList = recordPlanMapper.getItemList(planId); + if (!recordPlanItemList.isEmpty()) { + recordPlan.setPlanItemList(recordPlanItemList); + } + return recordPlan; } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java index cd4f3173..9fb4d588 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -2,9 +2,7 @@ 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 org.apache.ibatis.annotations.*; import java.util.List; @@ -26,15 +24,35 @@ public interface RecordPlanMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void add(RecordPlan plan); - RecordPlan get(Integer planId); + @Insert(" ") + void batchAddItem(@Param("planId") int planId, List planItemList); - List query(String query); + @Select("select * from wvp_record_plan where id = #{planId}") + RecordPlan get(@Param("planId") Integer planId); + @Select(" ") + List query(@Param("query") String query); + + @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") void update(RecordPlan plan); - void delete(Integer planId); + @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}") + void delete(@Param("planId") Integer planId); - void batchAddItem(int planId, List planItemList); - + List getItemList(Integer planId); } From 1567f2e3e76967fad7d88c0239a16a5a33b434cc Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 21 Nov 2024 23:20:56 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E9=81=93?= =?UTF-8?q?=E5=85=B3=E8=81=94=E4=BB=A5=E5=8F=8A=E5=BD=95=E5=88=B6=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/dao/CommonGBChannelMapper.java | 89 ++++ .../vmp/gb28181/dao/DeviceChannelMapper.java | 5 +- .../service/IDeviceChannelService.java | 2 +- .../impl/DeviceChannelServiceImpl.java | 4 +- .../impl/PlatformChannelServiceImpl.java | 5 + .../iot/vmp/service/IRecordPlanService.java | 11 +- .../service/impl/RecordPlanServiceImpl.java | 49 +- .../vmp/storager/dao/RecordPlanMapper.java | 21 +- .../recordPlan/RecordPlanController.java | 56 +- .../recordPlan/bean/RecordPlanParam.java | 7 +- web_src/src/components/RecordPLan.vue | 157 +++--- .../src/components/dialog/editRecordPlan.vue | 152 ++++-- .../components/dialog/linkChannelRecord.vue | 500 ++++++++++++++++++ 13 files changed, 899 insertions(+), 159 deletions(-) create mode 100755 web_src/src/components/dialog/linkChannelRecord.vue diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 99aff973..2f636a4d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -459,4 +459,93 @@ public interface CommonGBChannelMapper { @SelectProvider(type = ChannelProvider.class, method = "queryList") List queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasRecordPlan") Boolean hasRecordPlan, @Param("channelType") Integer channelType); + + @Update(value = {" "}) + void removeRecordPlan(List channelIds); + + @Update(value = {" "}) + void addRecordPlan(List channelIds, @Param("planId") Integer planId); + + @Update(value = {" "}) + void addRecordPlanForAll(@Param("planId") Integer planId); + + @Update(value = {" "}) + void removeRecordPlanByPlanId( @Param("planId") Integer planId); + + + @Select("") + List queryForRecordPlanForWebList(@Param("planId") Integer planId, @Param("query") String query, + @Param("channelType") Integer channelType, @Param("online") Boolean online, + @Param("hasLink") Boolean hasLink); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 75131ca6..13f1976a 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -93,8 +93,9 @@ public interface DeviceChannelMapper { @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId") List queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId); - @Select("select id from wvp_device_channel where device_db_id = #{deviceDbId}") - List queryChaneIdListByDeviceDbId(@Param("deviceDbId") int deviceDbId); + @Select("select id from wvp_device_channel where device_db_id in " + + " #{item} ") + List queryChaneIdListByDeviceDbIds(List deviceDbIds); @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") int cleanChannelsByDeviceId(@Param("deviceId") int deviceId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java index 4f0ee8e1..bb21e321 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java @@ -124,5 +124,5 @@ public interface IDeviceChannelService { List queryChaneListByDeviceDbId(Integer deviceDbId); - List queryChaneIdListByDeviceDbId(Integer deviceDbId); + List queryChaneIdListByDeviceDbIds(List deviceDbId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java index cd30f214..4b9cfad0 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java @@ -356,8 +356,8 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { } @Override - public List queryChaneIdListByDeviceDbId(Integer deviceDbId) { - return channelMapper.queryChaneIdListByDeviceDbId(deviceDbId); + public List queryChaneIdListByDeviceDbIds(List deviceDbIds) { + return channelMapper.queryChaneIdListByDeviceDbIds(deviceDbIds); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 71ca0988..2f768f10 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -55,6 +55,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer platformId, Boolean hasShare) { PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } List all = platformChannelMapper.queryForPlatformForWebList(platformId, query, channelType, online, hasShare); return new PageInfo<>(all); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java index 641ddb18..359e0072 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IRecordPlanService.java @@ -1,7 +1,8 @@ package com.genersoft.iot.vmp.service; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; 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; @@ -19,5 +20,11 @@ public interface IRecordPlanService { void add(RecordPlan plan); - void linke(List channelIds, Integer planId); + void link(List channelIds, Integer planId); + + PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink); + + void linkAll(Integer planId); + + void cleanAll(Integer planId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java index aa6d922d..f8f7e9c3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RecordPlanServiceImpl.java @@ -1,6 +1,8 @@ package com.genersoft.iot.vmp.service.impl; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.CloudRecordItem; @@ -8,6 +10,7 @@ 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.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -33,9 +36,13 @@ public class RecordPlanServiceImpl implements IRecordPlanService { plan.setCreateTime(DateUtil.getNow()); plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.add(plan); - if (plan.getId() > 0) { + if (plan.getId() > 0 && !plan.getPlanItemList().isEmpty()) { + for (RecordPlanItem recordPlanItem : plan.getPlanItemList()) { + recordPlanItem.setPlanId(plan.getId()); + } recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); } + // TODO 更新录像队列 } @Override @@ -52,14 +59,30 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override + @Transactional public void update(RecordPlan plan) { plan.setUpdateTime(DateUtil.getNow()); recordPlanMapper.update(plan); + recordPlanMapper.cleanItems(plan.getId()); + if (plan.getPlanItemList() != null){ + recordPlanMapper.batchAddItem(plan.getId(), plan.getPlanItemList()); + } + // TODO 更新录像队列 + } @Override + @Transactional public void delete(Integer planId) { + RecordPlan recordPlan = recordPlanMapper.get(planId); + if (recordPlan == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "录制计划不存在"); + } + // 清理关联的通道 + channelMapper.removeRecordPlanByPlanId(recordPlan.getId()); + recordPlanMapper.cleanItems(planId); recordPlanMapper.delete(planId); + // TODO 更新录像队列 } @Override @@ -75,13 +98,35 @@ public class RecordPlanServiceImpl implements IRecordPlanService { } @Override - public void linke(List channelIds, Integer planId) { + public void link(List channelIds, Integer planId) { if (planId == null) { log.info("[录制计划] 移除通道关联的计划"); channelMapper.removeRecordPlan(channelIds); }else { channelMapper.addRecordPlan(channelIds, planId); } + // TODO 更新录像队列 + } + @Override + public PageInfo queryChannelList(int page, int count, String query, Integer channelType, Boolean online, Integer planId, Boolean hasLink) { + PageHelper.startPage(page, count); + if (query != null) { + query = query.replaceAll("/", "//") + .replaceAll("%", "/%") + .replaceAll("_", "/_"); + } + List all = channelMapper.queryForRecordPlanForWebList(planId, query, channelType, online, hasLink); + return new PageInfo<>(all); + } + + @Override + public void linkAll(Integer planId) { + channelMapper.addRecordPlanForAll(planId); + } + + @Override + public void cleanAll(Integer planId) { + channelMapper.removeRecordPlanByPlanId(planId); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java index 9fb4d588..705e59aa 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/RecordPlanMapper.java @@ -10,7 +10,7 @@ import java.util.List; public interface RecordPlanMapper { @Insert(" ") void batchAddItem(@Param("planId") int planId, List planItemList); @@ -42,7 +41,8 @@ public interface RecordPlanMapper { RecordPlan get(@Param("planId") Integer planId); @Select(" ") List query(@Param("query") String query); @@ -50,9 +50,12 @@ public interface RecordPlanMapper { @Update("UPDATE wvp_record_plan SET update_time=#{updateTime}, name=#{name}, snap=#{snap} WHERE id=#{id}") void update(RecordPlan plan); - @Delete("DELETE FROM wvp_record_plan WHERE id=#{id}") + @Delete("DELETE FROM wvp_record_plan WHERE id=#{planId}") void delete(@Param("planId") Integer planId); + @Select("select * from wvp_record_plan_item where plan_id = #{planId}") + List getItemList(@Param("planId") Integer planId); - List getItemList(Integer planId); + @Delete("DELETE FROM wvp_record_plan_item WHERE plan_id = #{planId}") + void cleanItems(@Param("planId") Integer planId); } 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 6f3fdfa3..3675acbb 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 @@ -2,6 +2,8 @@ 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.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IRecordPlanService; import com.genersoft.iot.vmp.service.bean.RecordPlan; @@ -15,6 +17,7 @@ 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.util.Assert; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -45,23 +48,31 @@ public class RecordPlanController { } @ResponseBody - @PostMapping("/linke") + @PostMapping("/link") @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) { + public void link(@RequestBody RecordPlanParam param) { + if (param.getChannelIds() == null && param.getDeviceDbIds() == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); } + if (param.getAll() != null) { + if (param.getAll()) { + recordPlanService.linkAll(param.getPlanId()); + }else { + recordPlanService.cleanAll(param.getPlanId()); + } + return; + } List channelIds = new ArrayList<>(); - if (param.getChannelId() != null) { - channelIds.add(param.getChannelId()); + if (param.getChannelIds() != null) { + channelIds.addAll(param.getChannelIds()); }else { - List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbId(param.getDeviceDbId()); + List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbIds(param.getDeviceDbIds()); if (chanelIdList == null || chanelIdList.isEmpty()) { channelIds = chanelIdList; } } - recordPlanService.linke(channelIds, param.getPlanId()); + recordPlanService.link(channelIds, param.getPlanId()); } @ResponseBody @@ -88,11 +99,36 @@ public class RecordPlanController { return recordPlanService.query(page, count, query); } + @Operation(summary = "分页查询级联平台的所有所有通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) + @Parameter(name = "page", description = "当前页", required = true) + @Parameter(name = "count", description = "每页条数", required = true) + @Parameter(name = "planId", description = "录制计划ID") + @Parameter(name = "channelType", description = "通道类型, 0:国标设备,1:推流设备,2:拉流代理") + @Parameter(name = "query", description = "查询内容") + @Parameter(name = "online", description = "是否在线") + @Parameter(name = "hasLink", description = "是否已经关联") + @GetMapping("/channel/list") @ResponseBody - @PostMapping("/edit") - @Operation(summary = "编辑录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) + public PageInfo queryChannelList(int page, int count, + @RequestParam(required = false) Integer planId, + @RequestParam(required = false) String query, + @RequestParam(required = false) Integer channelType, + @RequestParam(required = false) Boolean online, + @RequestParam(required = false) Boolean hasLink) { + + Assert.notNull(planId, "录制计划ID不可为NULL"); + if (org.springframework.util.ObjectUtils.isEmpty(query)) { + query = null; + } + + return recordPlanService.queryChannelList(page, count, query, channelType, online, planId, hasLink); + } + + @ResponseBody + @PostMapping("/update") + @Operation(summary = "更新录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Parameter(name = "plan", description = "计划", required = true) - public void edit(@RequestBody RecordPlan plan) { + public void update(@RequestBody RecordPlan plan) { if (plan == null || plan.getId() == 0) { throw new ControllerException(ErrorCode.ERROR400); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java index 11cc1a0a..e7431409 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/recordPlan/bean/RecordPlanParam.java @@ -12,10 +12,13 @@ import java.util.List; public class RecordPlanParam { @Schema(description = "关联的通道ID") - private Integer channelId; + private List channelIds; @Schema(description = "关联的设备ID,会为设备下的所有通道关联此录制计划,channelId存在是此项不生效,") - private Integer deviceDbId; + private List deviceDbIds; + + @Schema(description = "全部关联/全部取消关联") + private Boolean all; @Schema(description = "录制计划ID, ID为空是删除关联的计划") private Integer planId; diff --git a/web_src/src/components/RecordPLan.vue b/web_src/src/components/RecordPLan.vue index bba30ea4..4e649fa5 100755 --- a/web_src/src/components/RecordPLan.vue +++ b/web_src/src/components/RecordPLan.vue @@ -9,82 +9,30 @@ 搜索: - - 在线状态: - - - - - - 录制计划: - - - - - - 类型: - - - - - - - 按国标设备添加 + 添加 - - 按国标设备移除 - - +
- - + - + - + - - + + + - - - - - - - - - @@ -99,37 +47,31 @@ :total="total"> + diff --git a/web_src/src/components/dialog/editRecordPlan.vue b/web_src/src/components/dialog/editRecordPlan.vue index 7f12794f..3772c490 100644 --- a/web_src/src/components/dialog/editRecordPlan.vue +++ b/web_src/src/components/dialog/editRecordPlan.vue @@ -10,8 +10,13 @@ @close="close()" >
- + + + + + +
保存 @@ -38,67 +43,111 @@ export default { return { options: [], loading: false, + edit: false, + planName: null, + id: null, showDialog: false, - channel: "", - deviceDbId: "", endCallback: "", byteTime: "", - planList: [], }; }, methods: { - openDialog: function (channel, deviceDbId, endCallback) { - this.channel = channel; - this.deviceDbId = deviceDbId; + openDialog: function (recordPlan, endCallback) { + console.log(recordPlan); this.endCallback = endCallback; this.showDialog = true; this.byteTime= ""; - if (channel.recordPlanId) { - // 请求plan信息 + if (recordPlan) { + this.edit = true + this.planName = recordPlan.name + this.id = recordPlan.id + this.$axios({ + method: 'get', + url: "/api/record/plan/get", + params: { + planId: recordPlan.id, + } + }).then((res) => { + if (res.data.code === 0) { + this.byteTime = this.plan2Byte(res.data.data.planItemList) + } + }).catch((error) => { + console.error(error) + }); } }, onSubmit: function () { let planList = this.byteTime2PlanList(); - console.log(planList) - this.$axios({ - method: 'post', - url: "/api/record/plan/add", - params: { - channelId: this.channel?this.channel.id:null, - deviceDbId: this.deviceDbId, - planList: planList - } - }).then((res) => { - if (res.data.code === 0) { - this.$message({ - showClose: true, - message: '添加成功', - type: 'success', - }); - this.showDialog = false; - this.endCallback() - } else { - this.$message({ - showClose: true, - message: res.data.msg, - type: 'error' - }); - } - }).catch((error) => { - console.error(error) - }); + if (!this.edit) { + this.$axios({ + method: 'post', + url: "/api/record/plan/add", + data: { + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '添加成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + }else { + this.$axios({ + method: 'post', + url: "/api/record/plan/update", + data: { + id: this.id, + name: this.planName, + planItemList: planList + } + }).then((res) => { + if (res.data.code === 0) { + this.$message({ + showClose: true, + message: '更新成功', + type: 'success', + }); + this.showDialog = false; + this.endCallback() + } else { + this.$message({ + showClose: true, + message: res.data.msg, + type: 'error' + }); + } + }).catch((error) => { + console.error(error) + }); + } + }, close: function () { - this.channel = ""; - this.deviceDbId = ""; this.showDialog = false; + this.id = null + this.planName = null + this.byteTime = "" + this.endCallback = "" if(this.endCallback) { this.endCallback(); } }, byteTime2PlanList() { - this.planList = [] if (this.byteTime.length === 0) { return; } @@ -114,8 +163,8 @@ export default { continue } for (let j = 0; j < planArray.length; j++) { - console.log(planArray[j]) planList.push({ + id: this.id, startTime: planArray[j].startTime, stopTime: planArray[j].stopTime, weekDay: week @@ -149,6 +198,27 @@ export default { } } 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 + for (let j = index; j <= endIndex; j++) { + indexArray[j + (planList[i].weekDay - 1 )*48] = j + i*48 + } + } + console.log(indexArray) + for (let i = 0; i < 336; i++) { + if (indexArray[i]){ + byte += "1" + }else { + byte += "0" + } + } + return byte } }, }; diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue new file mode 100755 index 00000000..173b5008 --- /dev/null +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -0,0 +1,500 @@ + + + + + From b168eefecb44a5c27c6aa5c4839a81786206f817 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 23 Nov 2024 14:51:13 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/dialog/linkChannelRecord.vue | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue index 173b5008..6f2a299a 100755 --- a/web_src/src/components/dialog/linkChannelRecord.vue +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -1,6 +1,6 @@