Commit 9bf87971e7dc6e0bccc0cf9a2301e9c89f9a0ba6
1 parent
53ffefe0
完成向上级联->启动时自动注册
Showing
5 changed files
with
82 additions
and
0 deletions
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.conf; | |
| 2 | + | |
| 3 | +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | |
| 4 | +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | |
| 6 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | |
| 7 | +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | |
| 8 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | +import org.springframework.boot.CommandLineRunner; | |
| 11 | +import org.springframework.core.annotation.Order; | |
| 12 | +import org.springframework.stereotype.Component; | |
| 13 | + | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * 系统启动时控制上级平台重新注册 | |
| 18 | + */ | |
| 19 | +@Component | |
| 20 | +@Order(value=3) | |
| 21 | +public class SipPlatformRunner implements CommandLineRunner { | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + private IVideoManagerStorager storager; | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + private IRedisCatchStorage redisCatchStorage; | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + private EventPublisher publisher; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void run(String... args) throws Exception { | |
| 34 | + // 设置所有平台离线 | |
| 35 | + storager.outlineForAllParentPlatform(); | |
| 36 | + | |
| 37 | + List<ParentPlatform> parentPlatforms = storager.queryEnableParentPlatformList(true); | |
| 38 | + | |
| 39 | + for (ParentPlatform parentPlatform : parentPlatforms) { | |
| 40 | + | |
| 41 | + redisCatchStorage.updatePlatformRegister(parentPlatform); | |
| 42 | + | |
| 43 | + redisCatchStorage.updatePlatformKeepalive(parentPlatform); | |
| 44 | + | |
| 45 | + ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch(); | |
| 46 | + | |
| 47 | + parentPlatformCatch.setParentPlatform(parentPlatform); | |
| 48 | + parentPlatformCatch.setId(parentPlatform.getDeviceGBId()); | |
| 49 | + redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); | |
| 50 | + | |
| 51 | + // 发送平台未注册消息 | |
| 52 | + publisher.platformNotRegisterEventPublish(parentPlatform.getDeviceGBId()); | |
| 53 | + } | |
| 54 | + } | |
| 55 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
| ... | ... | @@ -169,9 +169,20 @@ public interface IVideoManagerStorager { |
| 169 | 169 | PageInfo<ParentPlatform> queryParentPlatformList(int page, int count); |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | + * 获取所有已启用的平台 | |
| 173 | + * @return | |
| 174 | + */ | |
| 175 | + List<ParentPlatform> queryEnableParentPlatformList(boolean enable); | |
| 176 | + | |
| 177 | + /** | |
| 172 | 178 | * 获取上级平台 |
| 173 | 179 | * @param platformGbId |
| 174 | 180 | * @return |
| 175 | 181 | */ |
| 176 | 182 | ParentPlatform queryParentPlatById(String platformGbId); |
| 183 | + | |
| 184 | + /** | |
| 185 | + * 所有平台离线 | |
| 186 | + */ | |
| 187 | + void outlineForAllParentPlatform(); | |
| 177 | 188 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java
| ... | ... | @@ -49,6 +49,12 @@ public interface ParentPlatformMapper { |
| 49 | 49 | @Select("SELECT * FROM parent_platform") |
| 50 | 50 | List<ParentPlatform> getParentPlatformList(); |
| 51 | 51 | |
| 52 | + @Select("SELECT * FROM parent_platform WHERE enable=#{enable}") | |
| 53 | + List<ParentPlatform> getEnableParentPlatformList(boolean enable); | |
| 54 | + | |
| 52 | 55 | @Select("SELECT * FROM parent_platform WHERE deviceGBId=#{platformGbId}") |
| 53 | 56 | ParentPlatform getParentPlatById(String platformGbId); |
| 57 | + | |
| 58 | + @Update("UPDATE parent_platform SET status=false" ) | |
| 59 | + void outlineForAllParentPlatform(); | |
| 54 | 60 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| ... | ... | @@ -33,6 +33,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 33 | 33 | |
| 34 | 34 | @Autowired |
| 35 | 35 | private ParentPlatformMapper platformMapper; |
| 36 | + | |
| 36 | 37 | @Autowired |
| 37 | 38 | private IRedisCatchStorage redisCatchStorage; |
| 38 | 39 | |
| ... | ... | @@ -252,5 +253,13 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 252 | 253 | return platformMapper.getParentPlatById(platformGbId); |
| 253 | 254 | } |
| 254 | 255 | |
| 256 | + @Override | |
| 257 | + public List<ParentPlatform> queryEnableParentPlatformList(boolean enable) { | |
| 258 | + return platformMapper.getEnableParentPlatformList(enable); | |
| 259 | + } | |
| 255 | 260 | |
| 261 | + @Override | |
| 262 | + public void outlineForAllParentPlatform() { | |
| 263 | + platformMapper.outlineForAllParentPlatform(); | |
| 264 | + } | |
| 256 | 265 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java