临时提交
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface IGroupService {
|
||||
|
||||
Group queryGroupByAlias(String groupAlias);
|
||||
|
||||
void sync();
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Object, Object> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Object, Object> 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<MapConfig> getConfig() {
|
||||
List<MapConfig> configList = new ArrayList<>();
|
||||
|
||||
@@ -60,3 +60,9 @@ export function queryTree(params) {
|
||||
}
|
||||
})
|
||||
}
|
||||
export function sync() {
|
||||
return request({
|
||||
method: 'get',
|
||||
url: `/api/group/sync`,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
type="info"
|
||||
style="text-align: left"
|
||||
/>
|
||||
<div v-if="edit" style="margin-top: 18px;font-size: 14px;position: absolute;left: 309px;z-index: 100;" >
|
||||
<div v-if="edit" style="font-size: 14px;position: absolute;left: 270px;z-index: 100;" >
|
||||
显示编号: <el-checkbox v-model="showCode" />
|
||||
<el-button type="text" style="margin-left: 10px" :loading="groupSyncLoading" @click="groupSync">同步</el-button>
|
||||
</div>
|
||||
|
||||
<vue-easy-tree
|
||||
@@ -147,7 +148,8 @@ export default {
|
||||
count: this.defaultCount | 15,
|
||||
total: 0,
|
||||
groupList: [],
|
||||
channelList: []
|
||||
channelList: [],
|
||||
groupSyncLoading: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -454,6 +456,22 @@ export default {
|
||||
leaf: true,
|
||||
id: data.gbId
|
||||
})
|
||||
},
|
||||
groupSync: function() {
|
||||
|
||||
|
||||
this.groupSyncLoading = true
|
||||
this.$store.dispatch('group/sync').then(data => {
|
||||
this.$message.success({
|
||||
showClose: true,
|
||||
message: '同步消息已经发送, 3秒后自动刷新'
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.refresh('')
|
||||
}, 3000)
|
||||
}).finally(() => {
|
||||
this.groupSyncLoading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user