Merge pull request #729 from gaofuwang/wvp-28181-2.0

修复WVP作为下级平台接收DeviceInfo指令固定响应的问题
pull/276/head^2
648540858 2023-02-01 09:48:05 +08:00 committed by GitHub
commit df7171353b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 17 deletions

View File

@ -51,11 +51,11 @@ public interface ISIPCommanderForPlatform {
/**
* DeviceInfo
* @param parentPlatform
* @param sn
* @param fromTag
* @param sn SN
* @param fromTag FROMtag
* @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

View File

@ -293,23 +293,23 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
* @return
*/
@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) {
return;
}
String characterSet = parentPlatform.getCharacterSet();
StringBuffer deviceInfoXml = new StringBuffer(600);
deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
.append("<Response>\r\n")
.append("<CmdType>DeviceInfo</CmdType>\r\n")
.append("<SN>" +sn + "</SN>\r\n")
.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<DeviceName>" + parentPlatform.getName() + "</DeviceName>\r\n")
.append("<Manufacturer>wvp</Manufacturer>\r\n")
.append("<Model>wvp-28181-2.0</Model>\r\n")
.append("<Firmware>2.0.202107</Firmware>\r\n")
.append("<Result>OK</Result>\r\n")
.append("</Response>\r\n");
deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
deviceInfoXml.append("<Response>\r\n");
deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n");
deviceInfoXml.append("<SN>" +sn + "</SN>\r\n");
deviceInfoXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
deviceInfoXml.append("<DeviceName>" + device.getName() + "</DeviceName>\r\n");
deviceInfoXml.append("<Manufacturer>" + device.getManufacturer() + "</Manufacturer>\r\n");
deviceInfoXml.append("<Model>" + device.getModel() + "</Model>\r\n");
deviceInfoXml.append("<Firmware>" + device.getFirmware() + "</Firmware>\r\n");
deviceInfoXml.append("<Result>OK</Result>\r\n");
deviceInfoXml.append("</Response>\r\n");
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());

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.impl.message.IMessageHandler;
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 org.dom4j.Element;
import org.slf4j.Logger;
@ -21,6 +22,8 @@ import javax.sip.header.FromHeader;
import javax.sip.message.Response;
import java.text.ParseException;
import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText;
@Component
public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
@ -32,6 +35,8 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
@Autowired
private SIPCommanderFroPlatform cmderFroPlatform;
@Autowired
private IVideoManagerStorage storager;
@Override
public void afterPropertiesSet() throws Exception {
@ -52,10 +57,20 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp
responseAck((SIPRequest) evt.getRequest(), Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage());
return;
}
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 {
cmderFroPlatform.deviceInfoResponse(parentPlatform, sn, fromHeader.getTag());
cmderFroPlatform.deviceInfoResponse(parentPlatform,device, sn, fromHeader.getTag());
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage());
}

View File

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

View File

@ -107,4 +107,11 @@ public interface PlatformChannelMapper {
"DELETE FROM platform_gb_channel WHERE platformId=#{platformId} and catalogId=#{catalogId}" +
"</script>")
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

@ -584,6 +584,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