修复WVP作为下级平台接收DeviceInfo指令固定响应的问题

pull/729/head
gaofw189 2023-01-17 17:22:38 +08:00
parent 26cd7dbaf9
commit 141b228267
6 changed files with 53 additions and 11 deletions

View File

@ -51,11 +51,11 @@ public interface ISIPCommanderForPlatform {
/** /**
* DeviceInfo * DeviceInfo
* @param parentPlatform * @param parentPlatform
* @param sn * @param sn SN
* @param fromTag * @param fromTag FROMtag
* @return * @return
*/ */
void deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException;
/** /**
* DeviceStatus * DeviceStatus

View File

@ -255,7 +255,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
* @return * @return
*/ */
@Override @Override
public void deviceInfoResponse(ParentPlatform parentPlatform, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { public void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException {
if (parentPlatform == null) { if (parentPlatform == null) {
return; return;
} }
@ -265,11 +265,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
deviceInfoXml.append("<Response>\r\n"); deviceInfoXml.append("<Response>\r\n");
deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n"); deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n");
deviceInfoXml.append("<SN>" +sn + "</SN>\r\n"); deviceInfoXml.append("<SN>" +sn + "</SN>\r\n");
deviceInfoXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); deviceInfoXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
deviceInfoXml.append("<DeviceName>" + parentPlatform.getName() + "</DeviceName>\r\n"); deviceInfoXml.append("<DeviceName>" + device.getName() + "</DeviceName>\r\n");
deviceInfoXml.append("<Manufacturer>wvp</Manufacturer>\r\n"); deviceInfoXml.append("<Manufacturer>" + device.getManufacturer() + "</Manufacturer>\r\n");
deviceInfoXml.append("<Model>wvp-28181-2.0</Model>\r\n"); deviceInfoXml.append("<Model>" + device.getModel() + "</Model>\r\n");
deviceInfoXml.append("<Firmware>2.0.202107</Firmware>\r\n"); deviceInfoXml.append("<Firmware>" + device.getFirmware() + "</Firmware>\r\n");
deviceInfoXml.append("<Result>OK</Result>\r\n"); deviceInfoXml.append("<Result>OK</Result>\r\n");
deviceInfoXml.append("</Response>\r\n"); deviceInfoXml.append("</Response>\r\n");

View File

@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPRequest;
import org.dom4j.Element; import org.dom4j.Element;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -21,6 +22,8 @@ import javax.sip.header.FromHeader;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.text.ParseException; import java.text.ParseException;
import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
@Component @Component
public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
@ -32,6 +35,8 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
@Autowired @Autowired
private SIPCommanderFroPlatform cmderFroPlatform; private SIPCommanderFroPlatform cmderFroPlatform;
@Autowired
private IVideoManagerStorage storager;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
@ -52,10 +57,20 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
responseAck((SIPRequest) evt.getRequest(), Response.OK); responseAck((SIPRequest) evt.getRequest(), Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage());
return;
} }
String sn = rootElement.element("SN").getText(); String sn = rootElement.element("SN").getText();
/*WVP
NVR/IPCNVR/IPC使
使*/
String channelId = getText(rootElement, "DeviceID");
Device device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
if (device ==null){
logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId);
return;
}
try { try {
cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag()); cmderFroPlatform.deviceInfoResponse(parentPlatform,device, sn, fromHeader.getTag());
} catch (SipException | InvalidArgumentException | ParseException e) { } catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage());
} }

View File

@ -186,7 +186,13 @@ public interface IVideoManagerStorage {
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
/**
* deviceinfo
* @param platformId id
* @param channelId id
* @return
*/
Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId);
/** /**
* Mobile Position * Mobile Position
* @param mobilePosition * @param mobilePosition

View File

@ -107,4 +107,11 @@ public interface PlatformChannelMapper {
"DELETE FROM platform_gb_channel WHERE platformId=#{platformId} and catalogId=#{catalogId}" + "DELETE FROM platform_gb_channel WHERE platformId=#{platformId} and catalogId=#{catalogId}" +
"</script>") "</script>")
int delChannelForGBByCatalogId(String platformId, String catalogId); int delChannelForGBByCatalogId(String platformId, String catalogId);
@Select("select dc.channelId deviceId,dc.name,d.manufacturer,d.model,d.firmware\n" +
"from platform_gb_channel pgc\n" +
" left join device_channel dc on dc.id = pgc.deviceChannelId\n" +
" left join device d on dc.deviceId = d.deviceId\n" +
"where dc.channelId = #{channelId} and pgc.platformId=#{platformId}")
List<Device> queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId);
} }

View File

@ -471,6 +471,20 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
} }
@Override
public Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId) {
List<Device> devices = platformChannelMapper.queryDeviceInfoByPlatformIdAndChannelId(platformId, channelId);
if (devices.size() > 1) {
// 出现长度大于0的时候肯定是国标通道的ID重复了
logger.warn("国标ID存在重复{}", channelId);
}
if (devices.size() == 0) {
return null;
}else {
return devices.get(0);
}
}
/** /**
* *
* @param deviceId * @param deviceId