Commit ef58f29cfc501828d7a4cfc514c298aa9377e692
1 parent
964d5543
perf(catlog): 优化同步通道时通道名称的处理
通道名称为空时,默认使用通道编码作为通道名称,避免级联时因通道名称为空导致上级接收通道失败
Showing
1 changed file
with
5 additions
and
1 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 8 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | 8 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 9 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; | 9 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 10 | import com.genersoft.iot.vmp.utils.DateUtil; | 10 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 11 | +import org.apache.commons.lang3.StringUtils; | ||
| 11 | import org.apache.commons.lang3.math.NumberUtils; | 12 | import org.apache.commons.lang3.math.NumberUtils; |
| 12 | import org.dom4j.Attribute; | 13 | import org.dom4j.Attribute; |
| 13 | import org.dom4j.Document; | 14 | import org.dom4j.Document; |
| @@ -214,8 +215,11 @@ public class XmlUtil { | @@ -214,8 +215,11 @@ public class XmlUtil { | ||
| 214 | return deviceChannel; | 215 | return deviceChannel; |
| 215 | } | 216 | } |
| 216 | Element nameElement = itemDevice.element("Name"); | 217 | Element nameElement = itemDevice.element("Name"); |
| 217 | - if (nameElement != null) { | 218 | + // 当通道名称为空时,设置通道名称为通道编码,避免级联时因通道名称为空导致上级接收通道失败 |
| 219 | + if (nameElement != null && StringUtils.isNotBlank(nameElement.getText())) { | ||
| 218 | deviceChannel.setName(nameElement.getText()); | 220 | deviceChannel.setName(nameElement.getText()); |
| 221 | + } else { | ||
| 222 | + deviceChannel.setName(channelId); | ||
| 219 | } | 223 | } |
| 220 | if(channelId.length() <= 8) { | 224 | if(channelId.length() <= 8) { |
| 221 | deviceChannel.setHasAudio(false); | 225 | deviceChannel.setHasAudio(false); |