From d2ffc867e6b90e4bd66fdb3631c26e15384347fe Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Wed, 15 Oct 2025 18:59:12 +0800 Subject: [PATCH] =?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 --- .../gb28181/controller/GroupController.java | 7 ++++++ .../vmp/gb28181/service/IGroupService.java | 2 ++ .../service/impl/GroupServiceImpl.java | 25 ++++++++++++++++++- .../vmp/web/custom/service/SyServiceImpl.java | 12 +-------- web/src/api/group.js | 6 +++++ web/src/store/modules/group.js | 12 ++++++++- web/src/views/common/GroupTree.vue | 22 ++++++++++++++-- 7 files changed, 71 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java index 4f9c3bc6a..7a4578a69 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java @@ -89,6 +89,13 @@ public class GroupController { return groupService.getPath(deviceId, businessGroup); } + @Operation(summary = "从第三方同步组织结构") + @ResponseBody + @GetMapping("/sync") + public void sync(){ + groupService.sync(); + } + // @Operation(summary = "根据分组Id查询分组") // @Parameter(name = "groupDeviceId", description = "分组节点编号", required = true) // @ResponseBody diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java index c22caee1e..7b5825632 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java @@ -29,4 +29,6 @@ public interface IGroupService { Group queryGroupByAlias(String groupAlias); + void sync(); + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java index c813bd57a..e78b37fdd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.service.impl; +import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; @@ -15,6 +16,8 @@ import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; @@ -27,7 +30,7 @@ import java.util.*; */ @Service @Slf4j -public class GroupServiceImpl implements IGroupService { +public class GroupServiceImpl implements IGroupService, CommandLineRunner { @Autowired private GroupMapper groupManager; @@ -41,6 +44,17 @@ public class GroupServiceImpl implements IGroupService { @Autowired private EventPublisher eventPublisher; + @Autowired + private RedisTemplate redisTemplate; + + // 启动后请求组织结构同步 + @Override + public void run(String... args) throws Exception { + String key = VideoManagerConstants.VM_MSG_GROUP_LIST_REQUEST; + log.info("[redis发送通知] 发送 同步组织结构请求 {}", key); + redisTemplate.convertAndSend(key, ""); + } + @Override public void add(Group group) { Assert.notNull(group, "参数不可为NULL"); @@ -308,4 +322,13 @@ public class GroupServiceImpl implements IGroupService { public Group queryGroupByAlias(String groupAlias) { return groupManager.queryGroupByAlias(groupAlias); } + + @Override + public void sync() { + try { + this.run(); + }catch (Exception e) { + throw new ControllerException(ErrorCode.ERROR100.getCode(), "同步失败: " + e.getMessage()); + } + } } diff --git a/src/main/java/com/genersoft/iot/vmp/web/custom/service/SyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/web/custom/service/SyServiceImpl.java index d25ec8daa..11fc91a28 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/custom/service/SyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/web/custom/service/SyServiceImpl.java @@ -2,12 +2,10 @@ package com.genersoft.iot.vmp.web.custom.service; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.service.IMapService; import com.genersoft.iot.vmp.vmanager.bean.MapConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -19,19 +17,11 @@ import java.util.List; */ @Slf4j @Service -public class SyServiceImpl implements IMapService, CommandLineRunner { +public class SyServiceImpl implements IMapService { @Autowired private RedisTemplate redisTemplate; - // 启动后请求组织结构同步 - @Override - public void run(String... args) throws Exception { - String key = VideoManagerConstants.VM_MSG_GROUP_LIST_REQUEST; - log.info("[redis发送通知] 发送 同步组织结构请求 {}", key); - redisTemplate.convertAndSend(key, ""); - } - @Override public List getConfig() { List configList = new ArrayList<>(); diff --git a/web/src/api/group.js b/web/src/api/group.js index 13d4118f9..06b20b5bf 100644 --- a/web/src/api/group.js +++ b/web/src/api/group.js @@ -60,3 +60,9 @@ export function queryTree(params) { } }) } +export function sync() { + return request({ + method: 'get', + url: `/api/group/sync`, + }) +} diff --git a/web/src/store/modules/group.js b/web/src/store/modules/group.js index 6fec46003..e57a6d7e7 100644 --- a/web/src/store/modules/group.js +++ b/web/src/store/modules/group.js @@ -1,7 +1,7 @@ import { getTreeList, update, - add, deleteGroup, getPath, queryTree + add, deleteGroup, getPath, queryTree, sync } from '@/api/group' const actions = { @@ -64,6 +64,16 @@ const actions = { reject(error) }) }) + }, + sync({ commit }) { + return new Promise((resolve, reject) => { + sync().then(response => { + const { data } = response + resolve(data) + }).catch(error => { + reject(error) + }) + }) } } diff --git a/web/src/views/common/GroupTree.vue b/web/src/views/common/GroupTree.vue index f520489a2..d7328d12a 100755 --- a/web/src/views/common/GroupTree.vue +++ b/web/src/views/common/GroupTree.vue @@ -16,8 +16,9 @@ type="info" style="text-align: left" /> -
+
显示编号: + 同步
{ + this.$message.success({ + showClose: true, + message: '同步消息已经发送, 3秒后自动刷新' + }) + setTimeout(() => { + this.refresh('') + }, 3000) + }).finally(() => { + this.groupSyncLoading = false + }) } } }