[集群] 支持国标级联更新
parent
7fb07848ab
commit
b0b3f32e03
|
@ -26,6 +26,7 @@ import com.genersoft.iot.vmp.media.event.mediaServer.MediaSendRtpStoppedEvent;
|
|||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.*;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
@ -87,6 +88,9 @@ public class PlatformServiceImpl implements IPlatformService {
|
|||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private IRedisRpcService redisRpcService;
|
||||
|
||||
@Autowired
|
||||
private SipConfig sipConfig;
|
||||
|
||||
|
@ -286,6 +290,11 @@ public class PlatformServiceImpl implements IPlatformService {
|
|||
log.info("[国标级联] 更新平台 {}({})", platform.getName(), platform.getDeviceGBId());
|
||||
platform.setCharacterSet(platform.getCharacterSet().toUpperCase());
|
||||
Platform platformInDb = platformMapper.query(platform.getId());
|
||||
Assert.notNull(platformInDb, "平台不存在");
|
||||
if (!userSetting.getServerId().equals(platformInDb.getServerId())) {
|
||||
return redisRpcService.updatePlatform(platformInDb.getServerId(), platform);
|
||||
}
|
||||
|
||||
PlatformCatch platformCatchOld = redisCatchStorage.queryPlatformCatchInfo(platformInDb.getServerGBId());
|
||||
platform.setUpdateTime(DateUtil.getNow());
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service.redisMsg;
|
|||
|
||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
|
||||
|
@ -28,4 +29,5 @@ public interface IRedisRpcService {
|
|||
|
||||
void subscribeMobilePosition(int id, int cycle, int interval);
|
||||
|
||||
boolean updatePlatform(String serverId, Platform platform);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.genersoft.iot.vmp.service.redisMsg.control;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RpcController;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RedisRpcController("platform")
|
||||
public class RedisRpcPlatformController extends RpcController {
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
|
||||
|
||||
private void sendResponse(RedisRpcResponse response){
|
||||
log.info("[redis-rpc] >> {}", response);
|
||||
response.setToId(userSetting.getServerId());
|
||||
RedisRpcMessage message = new RedisRpcMessage();
|
||||
message.setResponse(response);
|
||||
redisTemplate.convertAndSend(RedisRpcConfig.REDIS_REQUEST_CHANNEL_KEY, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
@RedisRpcMapping("update")
|
||||
public RedisRpcResponse play(RedisRpcRequest request) {
|
||||
Platform platform = JSONObject.parseObject(request.getParam().toString(), Platform.class);
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
boolean update = platformService.update(platform);
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
response.setBody(Boolean.toString(update));
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.conf.UserSetting;
|
|||
import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.session.SSRCFactory;
|
||||
import com.genersoft.iot.vmp.media.event.hook.Hook;
|
||||
|
@ -15,8 +16,6 @@ import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
|||
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.ISendRtpServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
|
@ -223,4 +222,11 @@ public class RedisRpcServiceImpl implements IRedisRpcService {
|
|||
RedisRpcRequest request = buildRequest("device/subscribeMobilePosition", jsonObject);
|
||||
redisRpcConfig.request(request, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePlatform(String serverId, Platform platform) {
|
||||
RedisRpcRequest request = buildRequest("platform/update", platform);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, 40);
|
||||
return Boolean.parseBoolean(response.getBody().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ export default {
|
|||
listChangeCallback: null,
|
||||
showDialog: false,
|
||||
isLoging: false,
|
||||
onSubmit_text: "立即创建",
|
||||
onSubmit_text: "保存",
|
||||
|
||||
rules: {
|
||||
name: [{required: true, message: "请输入平台名称", trigger: "blur"}],
|
||||
|
|
|
@ -149,7 +149,7 @@ export default {
|
|||
showDialog: false,
|
||||
isLoging: false,
|
||||
dialogLoading: false,
|
||||
onSubmit_text: "立即创建",
|
||||
onSubmit_text: "保存",
|
||||
platformList: [],
|
||||
mediaServer: new MediaServer(),
|
||||
proxyParam: {
|
||||
|
|
Loading…
Reference in New Issue