|
@ -1,16 +1,16 @@ |
|
|
package com.genersoft.iot.vmp.gb28181.task.impl; |
|
|
package com.genersoft.iot.vmp.gb28181.task.impl; |
|
|
|
|
|
|
|
|
import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
|
|
import com.genersoft.iot.vmp.gb28181.bean.*; |
|
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
|
|
|
|
|
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; |
|
|
|
|
|
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; |
|
|
|
|
|
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
|
|
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; |
|
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
|
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
|
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
|
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
|
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
|
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
|
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
import javax.sip.DialogState; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -18,6 +18,8 @@ import java.util.List; |
|
|
*/ |
|
|
*/ |
|
|
public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { |
|
|
public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { |
|
|
|
|
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeHandlerTask.class); |
|
|
|
|
|
|
|
|
private IRedisCatchStorage redisCatchStorage; |
|
|
private IRedisCatchStorage redisCatchStorage; |
|
|
private IVideoManagerStorage storager; |
|
|
private IVideoManagerStorage storager; |
|
|
private ISIPCommanderForPlatform sipCommanderForPlatform; |
|
|
private ISIPCommanderForPlatform sipCommanderForPlatform; |
|
@ -26,8 +28,6 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { |
|
|
private String sn; |
|
|
private String sn; |
|
|
private String key; |
|
|
private String key; |
|
|
|
|
|
|
|
|
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
|
|
|
public MobilePositionSubscribeHandlerTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) { |
|
|
public MobilePositionSubscribeHandlerTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) { |
|
|
this.redisCatchStorage = redisCatchStorage; |
|
|
this.redisCatchStorage = redisCatchStorage; |
|
|
this.storager = storager; |
|
|
this.storager = storager; |
|
@ -38,40 +38,51 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { |
|
|
this.subscribeHolder = subscribeInfo; |
|
|
this.subscribeHolder = subscribeInfo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Async |
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
logger.info("执行MobilePositionSubscribeHandlerTask"); |
|
|
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platformId); |
|
|
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platformId); |
|
|
|
|
|
|
|
|
if (subscribe != null) { |
|
|
if (subscribe != null) { |
|
|
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); |
|
|
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); |
|
|
if (parentPlatform == null || parentPlatform.isStatus()) { |
|
|
if (parentPlatform == null ) { |
|
|
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
|
|
|
logger.info("发送订阅时未找到平台信息:{}", platformId); |
|
|
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platformId); |
|
|
return; |
|
|
if (gbStreams.size() > 0) { |
|
|
} |
|
|
for (GbStream gbStream : gbStreams) { |
|
|
if (!parentPlatform.isStatus()) { |
|
|
String gbId = gbStream.getGbId(); |
|
|
logger.info("发送订阅时发现平台已经离线:{}", platformId); |
|
|
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); |
|
|
return; |
|
|
if (gpsMsgInfo != null) { |
|
|
} |
|
|
// 发送GPS消息
|
|
|
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
|
|
|
sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); |
|
|
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platformId); |
|
|
}else { |
|
|
if (gbStreams.size() == 0) { |
|
|
// 没有在redis找到新的消息就使用数据库的消息
|
|
|
logger.info("发送订阅时发现平台已经没有关联的直播流:{}", platformId); |
|
|
gpsMsgInfo = new GPSMsgInfo(); |
|
|
return; |
|
|
gpsMsgInfo.setId(gbId); |
|
|
} |
|
|
gpsMsgInfo.setLat(gbStream.getLongitude()); |
|
|
for (GbStream gbStream : gbStreams) { |
|
|
gpsMsgInfo.setLng(gbStream.getLongitude()); |
|
|
String gbId = gbStream.getGbId(); |
|
|
// 发送GPS消息
|
|
|
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); |
|
|
sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); |
|
|
if (gpsMsgInfo != null) { // 无最新位置不发送
|
|
|
} |
|
|
// 经纬度都为0不发送
|
|
|
|
|
|
if (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0) { |
|
|
|
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
// 发送GPS消息
|
|
|
|
|
|
sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
logger.info("结束执行MobilePositionSubscribeHandlerTask"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void stop() { |
|
|
public void stop() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public DialogState getDialogState() { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|