diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java index 25407ed4..fb687b35 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java @@ -20,6 +20,7 @@ public class CatalogData { private Device device; private String errorMsg; private Set redisKeysForChannel = new HashSet<>(); + private Set errorChannel = new HashSet<>(); private Set redisKeysForRegion = new HashSet<>(); private Set redisKeysForGroup = new HashSet<>(); 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 13f1976a..99bb6e36 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,10 @@ 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 in " + - " #{item} ") + @Select(value = {" "}) List queryChaneIdListByDeviceDbIds(List deviceDbIds); @Delete("DELETE FROM wvp_device_channel WHERE device_db_id=#{deviceId}") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java index 049fc00e..9be9a519 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataManager.java @@ -283,7 +283,7 @@ public class CatalogDataManager implements CommandLineRunner { if (catalogData == null) { return 0; } - return catalogData.getRedisKeysForChannel().size(); + return catalogData.getRedisKeysForChannel().size() + catalogData.getErrorChannel().size(); } public int sumNum(String deviceId, int sn) { 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 f8f7e9c3..44b49ddd 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 @@ -2,10 +2,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; import com.genersoft.iot.vmp.service.bean.RecordPlan; import com.genersoft.iot.vmp.service.bean.RecordPlanItem; import com.genersoft.iot.vmp.storager.dao.RecordPlanMapper; @@ -99,8 +97,11 @@ public class RecordPlanServiceImpl implements IRecordPlanService { @Override public void link(List channelIds, Integer planId) { + if (channelIds == null || channelIds.isEmpty()) { + log.info("[录制计划] 关联/移除关联时, 通道编号必须存在"); + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道编号必须存在"); + } if (planId == null) { - log.info("[录制计划] 移除通道关联的计划"); channelMapper.removeRecordPlan(channelIds); }else { channelMapper.addRecordPlan(channelIds, 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 3675acbb..f01c11e5 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 @@ -3,7 +3,6 @@ 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; @@ -50,25 +49,27 @@ public class RecordPlanController { @ResponseBody @PostMapping("/link") @Operation(summary = "通道关联录制计划", security = @SecurityRequirement(name = JwtUtils.HEADER)) - @Parameter(name = "param", description = "通道关联录制计划", required = false) + @Parameter(name = "param", description = "通道关联录制计划", required = true) 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()) { + if (param.getAllLink() != null) { + if (param.getAllLink()) { recordPlanService.linkAll(param.getPlanId()); }else { recordPlanService.cleanAll(param.getPlanId()); } return; } + + if (param.getChannelIds() == null && param.getDeviceDbIds() == null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "通道ID和国标设备ID不可都为NULL"); + } + List channelIds = new ArrayList<>(); if (param.getChannelIds() != null) { channelIds.addAll(param.getChannelIds()); }else { List chanelIdList = deviceChannelService.queryChaneIdListByDeviceDbIds(param.getDeviceDbIds()); - if (chanelIdList == null || chanelIdList.isEmpty()) { + if (chanelIdList != null && !chanelIdList.isEmpty()) { channelIds = chanelIdList; } } 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 e7431409..9f56a0fb 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 @@ -1,7 +1,5 @@ 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; @@ -18,7 +16,7 @@ public class RecordPlanParam { private List deviceDbIds; @Schema(description = "全部关联/全部取消关联") - private Boolean all; + private Boolean allLink; @Schema(description = "录制计划ID, ID为空是删除关联的计划") private Integer planId; diff --git a/web_src/src/components/dialog/linkChannelRecord.vue b/web_src/src/components/dialog/linkChannelRecord.vue index 6f2a299a..2046c1eb 100755 --- a/web_src/src/components/dialog/linkChannelRecord.vue +++ b/web_src/src/components/dialog/linkChannelRecord.vue @@ -116,17 +116,19 @@ export default { }; }, - created() { - this.initData(); - }, + created() {}, destroyed() {}, methods: { openDialog(planId, closeCallback) { this.planId = planId this.showDialog = true this.closeCallback = closeCallback + this.initData() }, initData: function () { + this.currentPage= 1; + this.count= 15; + this.total= 0; this.getChannelList(); }, currentChange: function (val) { @@ -168,6 +170,36 @@ export default { handleSelectionChange: function (val){ this.multipleSelection = val; }, + + linkPlan: function (data){ + this.loading = true + return this.$axios({ + method: 'post', + url: `/api/record/plan/link`, + data: data + }).then((res)=> { + if (res.data.code === 0) { + this.$message.success({ + showClose: true, + message: "保存成功" + }) + this.getChannelList() + }else { + this.$message.error({ + showClose: true, + message: res.data.msg + }) + } + this.loading = false + }).catch((error)=> { + this.$message.error({ + showClose: true, + message: error + }) + this.loading = false + }) + }, + add: function (row) { let channels = [] for (let i = 0; i < this.multipleSelection.length; i++) { @@ -180,41 +212,10 @@ export default { }) return; } - this.loading = true this.linkPlan({ planId: this.planId, channelIds: channels - }).cache - - - this.$axios({ - method: 'post', - url: `/api/record/plan/link`, - data: { - planId: this.planId, - channelIds: channels - } - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.getChannelList() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - this.loading = false - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error - }) - this.loading = false - }); + }) }, addAll: function (row) { this.$confirm("确定全部添加?", '提示', { @@ -223,36 +224,11 @@ export default { cancelButtonText: '取消', type: 'warning' }).then(() => { - this.loading = true - this.$axios({ - method: 'post', - url: `/api/record/plan/link`, - data: { - planId: this.planId, - all: true - } - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.getChannelList() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - this.loading = false - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error - }) - this.loading = false - }); - }).catch(() => { + this.linkPlan({ + planId: this.planId, + allLink: true + }) + }).catch(() => { }); }, @@ -262,34 +238,10 @@ export default { for (let i = 0; i < rows.length; i++) { deviceIds.push(rows[i].id) } - this.$axios({ - method: 'post', - url: `/api/record/plan/link`, - data: { - planId: this.planId, - deviceDbIds: deviceIds - } - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.getChannelList() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - this.loading = false - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error - }) - this.loading = false - }); + this.linkPlan({ + planId: this.planId, + deviceDbIds: deviceIds + }) }) }, @@ -299,33 +251,9 @@ export default { for (let i = 0; i < rows.length; i++) { deviceIds.push(rows[i].id) } - this.$axios({ - method: 'post', - url: `/api/record/plan/link`, - data: { - deviceDbIds: deviceIds - } - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.getChannelList() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - this.loading = false - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error - }) - this.loading = false - }); + this.linkPlan({ + deviceDbIds: deviceIds + }) }) }, remove: function (row) { @@ -340,36 +268,10 @@ export default { }) return; } - this.loading = true - this.$axios({ - method: 'delete', - url: `/api/platform/channel/remove`, - data: { - platformId: this.platformId, - channelIds: channels - } - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.getChannelList() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - this.loading = false - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error - }) - this.loading = false - }); + this.linkPlan({ + channelIds: channels + }) }, removeAll: function (row) { @@ -379,62 +281,11 @@ export default { cancelButtonText: '取消', type: 'warning' }).then(() => { - this.loading = true - this.$axios({ - method: 'delete', - url: `/api/platform/channel/remove`, - data: { - platformId: this.platformId, - all: true - } - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.getChannelList() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - this.loading = false - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error - }) - this.loading = false - }); - }).catch(() => { - }); - - }, - saveCustom: function (row) { - this.$axios({ - method: 'post', - url: `/api/platform/channel/custom/update`, - data: row - }).then((res)=> { - if (res.data.code === 0) { - this.$message.success({ - showClose: true, - message: "保存成功" - }) - this.initData() - }else { - this.$message.error({ - showClose: true, - message: res.data.msg - }) - } - }).catch((error)=> { - this.$message.error({ - showClose: true, - message: error + this.linkPlan({ + planId: this.planId, + allLink: false }) + }).catch(() => { }); }, search: function () {