Commit 5d400804683866d57136331d257b6e282f280cb7
1 parent
d8493524
优化部分sql实现
Showing
26 changed files
with
191 additions
and
115 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
| ... | ... | @@ -172,7 +172,7 @@ public class DeviceChannel { |
| 172 | 172 | * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF |
| 173 | 173 | */ |
| 174 | 174 | @Schema(description = "在线/离线, 1在线,0离线") |
| 175 | - private int status; | |
| 175 | + private boolean status; | |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * 经度 |
| ... | ... | @@ -455,11 +455,11 @@ public class DeviceChannel { |
| 455 | 455 | this.PTZTypeText = PTZTypeText; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - public int getStatus() { | |
| 458 | + public boolean isStatus() { | |
| 459 | 459 | return status; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - public void setStatus(int status) { | |
| 462 | + public void setStatus(boolean status) { | |
| 463 | 463 | this.status = status; |
| 464 | 464 | } |
| 465 | 465 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
| ... | ... | @@ -66,7 +66,7 @@ public interface ISIPCommanderForPlatform { |
| 66 | 66 | * @param fromTag |
| 67 | 67 | * @return |
| 68 | 68 | */ |
| 69 | - void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException; | |
| 69 | + void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,boolean status) throws SipException, InvalidArgumentException, ParseException; | |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * 向上级回复移动位置订阅消息 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| ... | ... | @@ -221,7 +221,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 221 | 221 | if (!channel.getChannelId().equals(parentPlatform.getDeviceGBId())) { |
| 222 | 222 | catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); |
| 223 | 223 | if (channel.getParental() == 0) { |
| 224 | - catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); | |
| 224 | + catalogXml.append("<Status>" + (channel.isStatus() ? "ON" : "OFF") + "</Status>\r\n"); | |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | if (channel.getParental() == 0) { |
| ... | ... | @@ -250,7 +250,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 250 | 250 | catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n"); |
| 251 | 251 | catalogXml.append("<Password>" + channel.getPort() + "</Password>\r\n"); |
| 252 | 252 | catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n"); |
| 253 | - catalogXml.append("<Status>" + (channel.getStatus() == 1?"ON":"OFF") + "</Status>\r\n"); | |
| 253 | + catalogXml.append("<Status>" + (channel.isStatus() ? "ON":"OFF") + "</Status>\r\n"); | |
| 254 | 254 | catalogXml.append("<Longitude>" + |
| 255 | 255 | (channel.getLongitudeWgs84() != 0? channel.getLongitudeWgs84():channel.getLongitude()) |
| 256 | 256 | + "</Longitude>\r\n"); |
| ... | ... | @@ -377,11 +377,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 377 | 377 | * @return |
| 378 | 378 | */ |
| 379 | 379 | @Override |
| 380 | - public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException { | |
| 380 | + public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,boolean status) throws SipException, InvalidArgumentException, ParseException { | |
| 381 | 381 | if (parentPlatform == null) { |
| 382 | 382 | return ; |
| 383 | 383 | } |
| 384 | - String statusStr = (status==1)?"ONLINE":"OFFLINE"; | |
| 384 | + String statusStr = (status)?"ONLINE":"OFFLINE"; | |
| 385 | 385 | String characterSet = parentPlatform.getCharacterSet(); |
| 386 | 386 | StringBuffer deviceStatusXml = new StringBuffer(600); |
| 387 | 387 | deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n") |
| ... | ... | @@ -542,7 +542,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { |
| 542 | 542 | catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n") |
| 543 | 543 | .append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n") |
| 544 | 544 | .append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n") |
| 545 | - .append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); | |
| 545 | + .append("<Status>" + (channel.isStatus() ? "ON" : "OFF") + "</Status>\r\n"); | |
| 546 | 546 | |
| 547 | 547 | if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 |
| 548 | 548 | catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n") | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java
| ... | ... | @@ -77,7 +77,7 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i |
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | try { |
| 80 | - cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.getStatus()); | |
| 80 | + cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.isStatus()); | |
| 81 | 81 | } catch (SipException | InvalidArgumentException | ParseException e) { |
| 82 | 82 | logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); |
| 83 | 83 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| ... | ... | @@ -255,7 +255,7 @@ public class XmlUtil { |
| 255 | 255 | } |
| 256 | 256 | if (channelType.equals(ChannelType.CivilCode)) { |
| 257 | 257 | // 行政区划其他字段没必要识别了,默认在线即可 |
| 258 | - deviceChannel.setStatus(1); | |
| 258 | + deviceChannel.setStatus(true); | |
| 259 | 259 | deviceChannel.setParental(1); |
| 260 | 260 | deviceChannel.setCreateTime(DateUtil.getNow()); |
| 261 | 261 | deviceChannel.setUpdateTime(DateUtil.getNow()); |
| ... | ... | @@ -309,7 +309,7 @@ public class XmlUtil { |
| 309 | 309 | deviceChannel.setBusinessGroupId(businessGroupID); |
| 310 | 310 | if (channelType.equals(ChannelType.BusinessGroup) || channelType.equals(ChannelType.VirtualOrganization)) { |
| 311 | 311 | // 业务分组和虚拟组织 其他字段没必要识别了,默认在线即可 |
| 312 | - deviceChannel.setStatus(1); | |
| 312 | + deviceChannel.setStatus(true); | |
| 313 | 313 | deviceChannel.setParental(1); |
| 314 | 314 | deviceChannel.setCreateTime(DateUtil.getNow()); |
| 315 | 315 | deviceChannel.setUpdateTime(DateUtil.getNow()); |
| ... | ... | @@ -322,13 +322,13 @@ public class XmlUtil { |
| 322 | 322 | String status = statusElement.getTextTrim().trim(); |
| 323 | 323 | // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 |
| 324 | 324 | if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) { |
| 325 | - deviceChannel.setStatus(1); | |
| 325 | + deviceChannel.setStatus(true); | |
| 326 | 326 | } |
| 327 | 327 | if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { |
| 328 | - deviceChannel.setStatus(0); | |
| 328 | + deviceChannel.setStatus(false); | |
| 329 | 329 | } |
| 330 | 330 | }else { |
| 331 | - deviceChannel.setStatus(1); | |
| 331 | + deviceChannel.setStatus(true); | |
| 332 | 332 | } |
| 333 | 333 | // 识别自带的目录标识 |
| 334 | 334 | String parental = XmlUtil.getText(itemDevice, "Parental"); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java
| ... | ... | @@ -2,7 +2,7 @@ package com.genersoft.iot.vmp.service; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 5 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 5 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 6 | 6 | import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; |
| 7 | 7 | |
| 8 | 8 | import java.util.List; |
| ... | ... | @@ -38,7 +38,7 @@ public interface IDeviceChannelService { |
| 38 | 38 | * 获取统计信息 |
| 39 | 39 | * @return |
| 40 | 40 | */ |
| 41 | - ResourceBaceInfo getOverview(); | |
| 41 | + ResourceBaseInfo getOverview(); | |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * 查询所有未分配的通道 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java
| ... | ... | @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; |
| 6 | 6 | import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; |
| 7 | 7 | import com.genersoft.iot.vmp.vmanager.bean.BaseTree; |
| 8 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 8 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 9 | 9 | |
| 10 | 10 | import java.util.List; |
| 11 | 11 | |
| ... | ... | @@ -162,7 +162,7 @@ public interface IDeviceService { |
| 162 | 162 | * 获取统计信息 |
| 163 | 163 | * @return |
| 164 | 164 | */ |
| 165 | - ResourceBaceInfo getOverview(); | |
| 165 | + ResourceBaseInfo getOverview(); | |
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * 获取所有设备 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
| ... | ... | @@ -4,7 +4,7 @@ import com.alibaba.fastjson2.JSONObject; |
| 4 | 4 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 7 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 7 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 8 | 8 | import com.github.pagehelper.PageInfo; |
| 9 | 9 | |
| 10 | 10 | public interface IStreamProxyService { |
| ... | ... | @@ -108,6 +108,6 @@ public interface IStreamProxyService { |
| 108 | 108 | * 获取统计信息 |
| 109 | 109 | * @return |
| 110 | 110 | */ |
| 111 | - ResourceBaceInfo getOverview(); | |
| 111 | + ResourceBaseInfo getOverview(); | |
| 112 | 112 | |
| 113 | 113 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
| ... | ... | @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 6 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 7 | 7 | import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; |
| 8 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 8 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 9 | 9 | import com.github.pagehelper.PageInfo; |
| 10 | 10 | |
| 11 | 11 | import java.util.List; |
| ... | ... | @@ -113,5 +113,5 @@ public interface IStreamPushService { |
| 113 | 113 | * 获取统计信息 |
| 114 | 114 | * @return |
| 115 | 115 | */ |
| 116 | - ResourceBaceInfo getOverview(); | |
| 116 | + ResourceBaseInfo getOverview(); | |
| 117 | 117 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java
| ... | ... | @@ -11,7 +11,7 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 11 | 11 | import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; |
| 12 | 12 | import com.genersoft.iot.vmp.storager.dao.DeviceMapper; |
| 13 | 13 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 14 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 14 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 15 | 15 | import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; |
| 16 | 16 | import org.slf4j.Logger; |
| 17 | 17 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -175,8 +175,12 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService { |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | @Override |
| 178 | - public ResourceBaceInfo getOverview() { | |
| 179 | - return channelMapper.getOverview(); | |
| 178 | + public ResourceBaseInfo getOverview() { | |
| 179 | + | |
| 180 | + int online = channelMapper.getOnlineCount(); | |
| 181 | + int total = channelMapper.getAllChannelCount(); | |
| 182 | + | |
| 183 | + return new ResourceBaseInfo(total, online); | |
| 180 | 184 | } |
| 181 | 185 | |
| 182 | 186 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
| ... | ... | @@ -20,7 +20,7 @@ import com.genersoft.iot.vmp.storager.dao.DeviceMapper; |
| 20 | 20 | import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; |
| 21 | 21 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 22 | 22 | import com.genersoft.iot.vmp.vmanager.bean.BaseTree; |
| 23 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 23 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 24 | 24 | import org.slf4j.Logger; |
| 25 | 25 | import org.slf4j.LoggerFactory; |
| 26 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -652,8 +652,10 @@ public class DeviceServiceImpl implements IDeviceService { |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | @Override |
| 655 | - public ResourceBaceInfo getOverview() { | |
| 656 | - return deviceMapper.getOverview(); | |
| 655 | + public ResourceBaseInfo getOverview() { | |
| 656 | + List<Device> onlineDevices = deviceMapper.getOnlineDevices(); | |
| 657 | + List<Device> all = deviceMapper.getAll(); | |
| 658 | + return new ResourceBaseInfo(all.size(), onlineDevices.size()); | |
| 657 | 659 | } |
| 658 | 660 | |
| 659 | 661 | @Override | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| ... | ... | @@ -110,7 +110,7 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 110 | 110 | deviceChannel.setLatitude(gbStream.getLatitude()); |
| 111 | 111 | deviceChannel.setDeviceId(platform.getDeviceGBId()); |
| 112 | 112 | deviceChannel.setManufacture("wvp-pro"); |
| 113 | - deviceChannel.setStatus(gbStream.isStatus()?1:0); | |
| 113 | + deviceChannel.setStatus(gbStream.isStatus()); | |
| 114 | 114 | |
| 115 | 115 | deviceChannel.setRegisterWay(1); |
| 116 | 116 | deviceChannel.setCivilCode(platform.getAdministrativeDivision()); |
| ... | ... | @@ -218,7 +218,7 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 218 | 218 | }else { |
| 219 | 219 | status = gbStreamMapper.selectStatusForPush(gbStream.getApp(), gbStream.getStream()); |
| 220 | 220 | } |
| 221 | - deviceChannel.setStatus((status != null && status )?1:0); | |
| 221 | + deviceChannel.setStatus(status != null && status); | |
| 222 | 222 | |
| 223 | 223 | deviceChannel.setRegisterWay(1); |
| 224 | 224 | deviceChannel.setCivilCode(platform.getAdministrativeDivision()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| ... | ... | @@ -685,7 +685,7 @@ public class MediaServerServiceImpl implements IMediaServerService { |
| 685 | 685 | // 缓存不存在,从数据库查询,如果数据库不存在则是错误的 |
| 686 | 686 | mediaServerItem = getOneFromDatabase(mediaServerId); |
| 687 | 687 | if (mediaServerItem == null) { |
| 688 | - logger.warn("[更新ZLM 保活信息]失败,未找到流媒体信息"); | |
| 688 | + logger.warn("[更新ZLM 保活信息] 流媒体{}尚未加入使用,请检查节点中是否含有此流媒体 ", mediaServerId); | |
| 689 | 689 | return; |
| 690 | 690 | } |
| 691 | 691 | // zlm连接重试 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| ... | ... | @@ -23,7 +23,7 @@ import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; |
| 23 | 23 | import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; |
| 24 | 24 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 25 | 25 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 26 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 26 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 27 | 27 | import com.github.pagehelper.PageInfo; |
| 28 | 28 | import org.slf4j.Logger; |
| 29 | 29 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -438,7 +438,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService { |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | @Override |
| 441 | - public ResourceBaceInfo getOverview() { | |
| 442 | - return streamProxyMapper.getOverview(); | |
| 441 | + public ResourceBaseInfo getOverview() { | |
| 442 | + | |
| 443 | + int total = streamProxyMapper.getAllCount(); | |
| 444 | + int online = streamProxyMapper.getOnline(); | |
| 445 | + | |
| 446 | + return new ResourceBaseInfo(total, online); | |
| 443 | 447 | } |
| 444 | 448 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| ... | ... | @@ -20,7 +20,7 @@ import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; |
| 20 | 20 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 21 | 21 | import com.genersoft.iot.vmp.storager.dao.*; |
| 22 | 22 | import com.genersoft.iot.vmp.utils.DateUtil; |
| 23 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 23 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 24 | 24 | import com.github.pagehelper.PageHelper; |
| 25 | 25 | import com.github.pagehelper.PageInfo; |
| 26 | 26 | import org.slf4j.Logger; |
| ... | ... | @@ -531,7 +531,10 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | @Override |
| 534 | - public ResourceBaceInfo getOverview() { | |
| 535 | - return streamPushMapper.getOverview(userSetting.isUsePushingAsStatus()); | |
| 534 | + public ResourceBaseInfo getOverview() { | |
| 535 | + int total = streamPushMapper.getAllCount(); | |
| 536 | + int online = streamPushMapper.getAllOnline(userSetting.isUsePushingAsStatus()); | |
| 537 | + | |
| 538 | + return new ResourceBaseInfo(total, online); | |
| 536 | 539 | } |
| 537 | 540 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
| ... | ... | @@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; |
| 9 | 9 | import com.google.common.collect.BiMap; |
| 10 | 10 | import com.google.common.collect.HashBiMap; |
| 11 | 11 | import org.springframework.util.ObjectUtils; |
| 12 | -import org.springframework.util.StringUtils; | |
| 13 | 12 | |
| 14 | 13 | import java.util.*; |
| 15 | 14 | |
| ... | ... | @@ -33,38 +32,43 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 33 | 32 | /** |
| 34 | 33 | * 用于存储不加过滤的所有数据 |
| 35 | 34 | */ |
| 36 | - private List<StreamPushItem> streamPushItems = new ArrayList<>(); | |
| 35 | + private final List<StreamPushItem> streamPushItems = new ArrayList<>(); | |
| 37 | 36 | |
| 38 | 37 | /** |
| 39 | 38 | * 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表 |
| 40 | 39 | */ |
| 41 | - private Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>(); | |
| 40 | + private final Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>(); | |
| 42 | 41 | |
| 43 | 42 | /** |
| 44 | 43 | * 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表 |
| 45 | 44 | */ |
| 46 | - private Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>(); | |
| 45 | + private final Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>(); | |
| 47 | 46 | |
| 48 | 47 | /** |
| 49 | 48 | * 用于判断文件是否存在重复的app+Stream+平台ID |
| 50 | 49 | */ |
| 51 | - private Set<String> streamPushStreamSet = new HashSet<>(); | |
| 50 | + private final Set<String> streamPushStreamSet = new HashSet<>(); | |
| 52 | 51 | |
| 53 | 52 | /** |
| 54 | 53 | * 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应,全局判断APP+Stream->国标ID是否存在不对应 |
| 55 | 54 | */ |
| 56 | - private BiMap<String,String> gBMap = HashBiMap.create(); | |
| 55 | + private final BiMap<String,String> gBMap = HashBiMap.create(); | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 用于存储APP+Stream-> 在数据库中的数据 | |
| 59 | + */ | |
| 60 | + private final BiMap<String,String> pushMapInDb = HashBiMap.create(); | |
| 57 | 61 | |
| 58 | 62 | /** |
| 59 | 63 | * 记录错误的APP+Stream |
| 60 | 64 | */ |
| 61 | - private List<String> errorStreamList = new ArrayList<>(); | |
| 65 | + private final List<String> errorStreamList = new ArrayList<>(); | |
| 62 | 66 | |
| 63 | 67 | |
| 64 | 68 | /** |
| 65 | 69 | * 记录错误的国标ID |
| 66 | 70 | */ |
| 67 | - private List<String> errorGBList = new ArrayList<>(); | |
| 71 | + private final List<String> errorInfoList = new ArrayList<>(); | |
| 68 | 72 | |
| 69 | 73 | /** |
| 70 | 74 | * 读取数量计数器 |
| ... | ... | @@ -75,6 +79,13 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 75 | 79 | this.pushService = pushService; |
| 76 | 80 | this.defaultMediaServerId = defaultMediaServerId; |
| 77 | 81 | this.errorDataHandler = errorDataHandler; |
| 82 | + // 获取数据库已有的数据,已经存在的则忽略 | |
| 83 | + List<String> allAppAndStreams = pushService.getAllAppAndStream(); | |
| 84 | + if (allAppAndStreams.size() > 0) { | |
| 85 | + for (String allAppAndStream : allAppAndStreams) { | |
| 86 | + pushMapInDb.put(allAppAndStream, allAppAndStream); | |
| 87 | + } | |
| 88 | + } | |
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | public interface ErrorDataHandler{ |
| ... | ... | @@ -88,26 +99,30 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 88 | 99 | || ObjectUtils.isEmpty(streamPushExcelDto.getGbId())) { |
| 89 | 100 | return; |
| 90 | 101 | } |
| 102 | + Integer rowIndex = analysisContext.readRowHolder().getRowIndex(); | |
| 91 | 103 | |
| 92 | 104 | if (gBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()) == null) { |
| 93 | 105 | try { |
| 94 | 106 | gBMap.put(streamPushExcelDto.getApp() + streamPushExcelDto.getStream(), streamPushExcelDto.getGbId()); |
| 95 | 107 | }catch (IllegalArgumentException e) { |
| 96 | - errorGBList.add(streamPushExcelDto.getGbId() + "(不同的app+stream使用了相同的国标ID)"); | |
| 108 | + errorInfoList.add("行:" + rowIndex + ", " + streamPushExcelDto.getGbId() + " 国标ID重复使用"); | |
| 97 | 109 | return; |
| 98 | 110 | } |
| 99 | 111 | }else { |
| 100 | 112 | if (!gBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()).equals(streamPushExcelDto.getGbId())) { |
| 101 | - errorGBList.add(streamPushExcelDto.getGbId() + "(同一组app+stream使用了不同的国标ID)"); | |
| 113 | + errorInfoList.add("行:" + rowIndex + ", " + streamPushExcelDto.getGbId() + " 同样的应用名和流ID使用了不同的国标ID"); | |
| 102 | 114 | return; |
| 103 | 115 | } |
| 104 | 116 | } |
| 105 | 117 | |
| 106 | 118 | if (streamPushStreamSet.contains(streamPushExcelDto.getApp() + streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId())) { |
| 107 | - errorStreamList.add(streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ "/" + | |
| 108 | - streamPushExcelDto.getPlatformId() + "(同一组app+stream添加在了同一个平台下)"); | |
| 119 | + errorStreamList.add("行:" + rowIndex + ", " + streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ " 平台信息重复"); | |
| 109 | 120 | return; |
| 110 | 121 | }else { |
| 122 | + if (pushMapInDb.get(streamPushExcelDto.getApp()+streamPushExcelDto.getStream()) != null) { | |
| 123 | + errorStreamList.add("行:" + rowIndex + ", " + streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ " 数据已存在"); | |
| 124 | + return; | |
| 125 | + } | |
| 111 | 126 | streamPushStreamSet.add(streamPushExcelDto.getApp()+streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId()); |
| 112 | 127 | } |
| 113 | 128 | |
| ... | ... | @@ -165,7 +180,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 165 | 180 | gBMap.clear(); |
| 166 | 181 | streamPushStreamSet.clear(); |
| 167 | 182 | streamPushItemsForPlatform.clear(); |
| 168 | - errorDataHandler.handle(errorStreamList, errorGBList); | |
| 183 | + errorDataHandler.handle(errorStreamList, errorInfoList); | |
| 169 | 184 | } |
| 170 | 185 | |
| 171 | 186 | private void saveData(){ | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| ... | ... | @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.storager.dao; |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; |
| 6 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 7 | 6 | import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; |
| 8 | 7 | import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; |
| 9 | 8 | import org.apache.ibatis.annotations.*; |
| ... | ... | @@ -74,8 +73,8 @@ public interface DeviceChannelMapper { |
| 74 | 73 | "dc.device_id = #{deviceId} " + |
| 75 | 74 | " <if test='query != null'> AND (dc.channel_id LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " + |
| 76 | 75 | " <if test='parentChannelId != null'> AND (dc.parent_id=#{parentChannelId} OR dc.civil_code = #{parentChannelId}) </if> " + |
| 77 | - " <if test='online == true' > AND dc.status=1</if>" + | |
| 78 | - " <if test='online == false' > AND dc.status=0</if>" + | |
| 76 | + " <if test='online == true' > AND dc.status= true</if>" + | |
| 77 | + " <if test='online == false' > AND dc.status= false</if>" + | |
| 79 | 78 | " <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" + |
| 80 | 79 | " <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" + |
| 81 | 80 | "<if test='channelIds != null'> AND dc.channel_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" + |
| ... | ... | @@ -97,8 +96,8 @@ public interface DeviceChannelMapper { |
| 97 | 96 | " <if test='device_id != null'> AND dc.device_id = #{deviceId} </if> " + |
| 98 | 97 | " <if test='query != null'> AND (dc.channel_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + |
| 99 | 98 | " <if test='parentChannelId != null'> AND dc.parent_id=#{parentChannelId} </if> " + |
| 100 | - " <if test='online == true' > AND dc.status=1</if>" + | |
| 101 | - " <if test='online == false' > AND dc.status=0</if>" + | |
| 99 | + " <if test='online == true' > AND dc.status=true</if>" + | |
| 100 | + " <if test='online == false' > AND dc.status=false</if>" + | |
| 102 | 101 | " <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" + |
| 103 | 102 | " <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" + |
| 104 | 103 | "<if test='channelIds != null'> AND dc.channel_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" + |
| ... | ... | @@ -121,8 +120,8 @@ public interface DeviceChannelMapper { |
| 121 | 120 | " <if test='deviceId != null'> AND dc.device_id = #{deviceId} </if> " + |
| 122 | 121 | " <if test='query != null'> AND (dc.channel_id LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + |
| 123 | 122 | " <if test='parentChannelId != null'> AND dc.parent_id=#{parentChannelId} </if> " + |
| 124 | - " <if test='online == true' > AND dc.status=1</if>" + | |
| 125 | - " <if test='online == false' > AND dc.status=0</if>" + | |
| 123 | + " <if test='online == true' > AND dc.status=true</if>" + | |
| 124 | + " <if test='online == false' > AND dc.status=false</if>" + | |
| 126 | 125 | " <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" + |
| 127 | 126 | " <if test='hasSubChannel == false' > AND dc.sub_count = 0 </if>" + |
| 128 | 127 | "<if test='channelIds != null'> AND dc.channel_id in <foreach item='item' index='index' collection='channelIds' open='(' separator=',' close=')'>" + |
| ... | ... | @@ -165,8 +164,8 @@ public interface DeviceChannelMapper { |
| 165 | 164 | " LEFT JOIN wvp_platform_gb_channel pgc on pgc.device_channel_id = dc.id " + |
| 166 | 165 | " WHERE 1=1 " + |
| 167 | 166 | " <if test='query != null'> AND (dc.channel_id LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%') OR dc.name LIKE concat('%',#{query},'%'))</if> " + |
| 168 | - " <if test='online == true' > AND dc.status=1</if> " + | |
| 169 | - " <if test='online == false' > AND dc.status=0</if> " + | |
| 167 | + " <if test='online == true' > AND dc.status=true</if> " + | |
| 168 | + " <if test='online == false' > AND dc.status=false</if> " + | |
| 170 | 169 | " <if test='hasSubChannel!= null and has_sub_channel == true' > AND dc.sub_count > 0</if> " + |
| 171 | 170 | " <if test='hasSubChannel!= null and has_sub_channel == false' > AND dc.sub_count = 0</if> " + |
| 172 | 171 | " <if test='catalogId == null ' > AND dc.id not in (select device_channel_id from wvp_platform_gb_channel where platform_id=#{platformId} ) </if> " + |
| ... | ... | @@ -191,10 +190,10 @@ public interface DeviceChannelMapper { |
| 191 | 190 | @Select("SELECT * FROM wvp_device_channel WHERE channel_id=#{channelId}") |
| 192 | 191 | List<DeviceChannel> queryChannelByChannelId( String channelId); |
| 193 | 192 | |
| 194 | - @Update(value = {"UPDATE wvp_device_channel SET status=0 WHERE device_id=#{deviceId} AND channel_id=#{channelId}"}) | |
| 193 | + @Update(value = {"UPDATE wvp_device_channel SET status=false WHERE device_id=#{deviceId} AND channel_id=#{channelId}"}) | |
| 195 | 194 | void offline(String deviceId, String channelId); |
| 196 | 195 | |
| 197 | - @Update(value = {"UPDATE wvp_device_channel SET status=0 WHERE device_id=#{deviceId}"}) | |
| 196 | + @Update(value = {"UPDATE wvp_device_channel SET status=fasle WHERE device_id=#{deviceId}"}) | |
| 198 | 197 | void offlineByDeviceId(String deviceId); |
| 199 | 198 | |
| 200 | 199 | @Insert("<script> " + |
| ... | ... | @@ -271,7 +270,7 @@ public interface DeviceChannelMapper { |
| 271 | 270 | "</script>") |
| 272 | 271 | int batchAddOrUpdate(List<DeviceChannel> addChannels); |
| 273 | 272 | |
| 274 | - @Update(value = {"UPDATE wvp_device_channel SET status=1 WHERE device_id=#{deviceId} AND channel_id=#{channelId}"}) | |
| 273 | + @Update(value = {"UPDATE wvp_device_channel SET status=true WHERE device_id=#{deviceId} AND channel_id=#{channelId}"}) | |
| 275 | 274 | void online(String deviceId, String channelId); |
| 276 | 275 | |
| 277 | 276 | @Update({"<script>" + |
| ... | ... | @@ -283,7 +282,7 @@ public interface DeviceChannelMapper { |
| 283 | 282 | "<if test='item.manufacture != null'>, manufacture=#{item.manufacture}</if>" + |
| 284 | 283 | "<if test='item.model != null'>, model=#{item.model}</if>" + |
| 285 | 284 | "<if test='item.owner != null'>, owner=#{item.owner}</if>" + |
| 286 | - "<if test='item.civil_code != null'>, civil_code=#{item.civilCode}</if>" + | |
| 285 | + "<if test='item.civilCode != null'>, civil_code=#{item.civilCode}</if>" + | |
| 287 | 286 | "<if test='item.block != null'>, block=#{item.block}</if>" + |
| 288 | 287 | "<if test='item.subCount != null'>, sub_count=#{item.subCount}</if>" + |
| 289 | 288 | "<if test='item.address != null'>, address=#{item.address}</if>" + |
| ... | ... | @@ -317,7 +316,7 @@ public interface DeviceChannelMapper { |
| 317 | 316 | int batchUpdate(List<DeviceChannel> updateChannels); |
| 318 | 317 | |
| 319 | 318 | |
| 320 | - @Select("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND status=1") | |
| 319 | + @Select("SELECT * FROM wvp_device_channel WHERE device_id=#{deviceId} AND status=true") | |
| 321 | 320 | List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); |
| 322 | 321 | |
| 323 | 322 | @Delete(value = {" <script>" + |
| ... | ... | @@ -406,9 +405,6 @@ public interface DeviceChannelMapper { |
| 406 | 405 | List<DeviceChannel> queryAllChannels(String deviceId); |
| 407 | 406 | |
| 408 | 407 | |
| 409 | - @Select("select count(1) as total, sum(status) as online from wvp_device_channel") | |
| 410 | - ResourceBaceInfo getOverview(); | |
| 411 | - | |
| 412 | 408 | @Select("select channelId" + |
| 413 | 409 | ", device_id" + |
| 414 | 410 | ", latitude" + |
| ... | ... | @@ -420,7 +416,7 @@ public interface DeviceChannelMapper { |
| 420 | 416 | "from wvp_device_channel where device_id = #{deviceId} " + |
| 421 | 417 | "and latitude != 0 " + |
| 422 | 418 | "and longitude != 0 " + |
| 423 | - "and(latitude_gcj02=0orlatitude_wgs84=0orlongitude_wgs84= 0 or longitude_gcj02 = 0)") | |
| 419 | + "and(latitude_gcj02=0 or latitude_wgs84=0 or longitude_wgs84= 0 or longitude_gcj02 = 0)") | |
| 424 | 420 | List<DeviceChannel> getChannelsWithoutTransform(String deviceId); |
| 425 | 421 | |
| 426 | 422 | @Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.channel_id=#{channelId}") |
| ... | ... | @@ -436,15 +432,22 @@ public interface DeviceChannelMapper { |
| 436 | 432 | |
| 437 | 433 | @Update({"<script>" + |
| 438 | 434 | "<foreach collection='channels' item='item' separator=';'>" + |
| 439 | - "UPDATE wvp_device_channel SET status=1 WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" + | |
| 435 | + "UPDATE wvp_device_channel SET status=true WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" + | |
| 440 | 436 | "</foreach>" + |
| 441 | 437 | "</script>"}) |
| 442 | 438 | int batchOnline(List<DeviceChannel> channels); |
| 443 | 439 | |
| 444 | 440 | @Update({"<script>" + |
| 445 | 441 | "<foreach collection='channels' item='item' separator=';'>" + |
| 446 | - "UPDATE wvp_device_channel SET status=0 WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" + | |
| 442 | + "UPDATE wvp_device_channel SET status= false WHERE device_id=#{item.deviceId} AND channel_id=#{item.channelId}" + | |
| 447 | 443 | "</foreach>" + |
| 448 | 444 | "</script>"}) |
| 449 | 445 | int batchOffline(List<DeviceChannel> channels); |
| 446 | + | |
| 447 | + | |
| 448 | + @Select("select count(1) from wvp_device_channel where status = true") | |
| 449 | + int getOnlineCount(); | |
| 450 | + | |
| 451 | + @Select("select count(1) from wvp_device_channel") | |
| 452 | + int getAllChannelCount(); | |
| 450 | 453 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
| 1 | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 4 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 5 | 4 | import org.apache.ibatis.annotations.*; |
| 6 | 5 | import org.springframework.stereotype.Repository; |
| 7 | 6 | |
| ... | ... | @@ -162,8 +161,10 @@ public interface DeviceMapper { |
| 162 | 161 | "tree_type,"+ |
| 163 | 162 | "online,"+ |
| 164 | 163 | "media_server_id,"+ |
| 165 | - "(SELECT count(0) FROM wvp_device_channel WHERE device_id=de.device_id) as channel_count FROM wvp_device de" + | |
| 164 | + "(SELECT count(0) FROM wvp_device_channel WHERE device_id=de.device_id) as channel_count " + | |
| 165 | + "FROM wvp_device de" + | |
| 166 | 166 | "<if test=\"online != null\"> where online=${online}</if>"+ |
| 167 | + " order by create_time desc "+ | |
| 167 | 168 | " </script>" |
| 168 | 169 | ) |
| 169 | 170 | List<Device> getDevices(Boolean online); |
| ... | ... | @@ -288,9 +289,6 @@ public interface DeviceMapper { |
| 288 | 289 | ")") |
| 289 | 290 | void addCustomDevice(Device device); |
| 290 | 291 | |
| 291 | - @Select("select count(1) as total, sum(online) as online FROM wvp_device") | |
| 292 | - ResourceBaceInfo getOverview(); | |
| 293 | - | |
| 294 | 292 | @Select("select * FROM wvp_device") |
| 295 | 293 | List<Device> getAll(); |
| 296 | 294 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
| ... | ... | @@ -117,7 +117,7 @@ public interface GbStreamMapper { |
| 117 | 117 | void batchDelForGbStream(List<GbStream> gbStreams); |
| 118 | 118 | |
| 119 | 119 | @Insert("<script> " + |
| 120 | - "INSERT IGNORE into wvp_gb_stream " + | |
| 120 | + "INSERT into wvp_gb_stream " + | |
| 121 | 121 | "(app, stream, gb_id, name, " + |
| 122 | 122 | "longitude, latitude, stream_type,media_server_id,create_time)" + |
| 123 | 123 | "values " + |
| ... | ... | @@ -127,7 +127,7 @@ public interface GbStreamMapper { |
| 127 | 127 | "#{item.mediaServerId}, #{item.createTime}) "+ |
| 128 | 128 | "</foreach> " + |
| 129 | 129 | "</script>") |
| 130 | - @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") | |
| 130 | + @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gb_stream_id") | |
| 131 | 131 | void batchAdd(List<StreamPushItem> subList); |
| 132 | 132 | |
| 133 | 133 | @Update({"<script>" + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java
| 1 | 1 | package com.genersoft.iot.vmp.storager.dao; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| 4 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 4 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 5 | 5 | import org.apache.ibatis.annotations.*; |
| 6 | 6 | import org.springframework.stereotype.Repository; |
| 7 | 7 | |
| ... | ... | @@ -78,5 +78,12 @@ public interface StreamProxyMapper { |
| 78 | 78 | List<StreamProxyItem> selectAutoRemoveItemByMediaServerId(String mediaServerId); |
| 79 | 79 | |
| 80 | 80 | @Select("select count(1) as total, sum(status) as online from wvp_stream_proxy") |
| 81 | - ResourceBaceInfo getOverview(); | |
| 81 | + ResourceBaseInfo getOverview(); | |
| 82 | + | |
| 83 | + @Select("select count(1) from wvp_stream_proxy") | |
| 84 | + | |
| 85 | + int getAllCount(); | |
| 86 | + | |
| 87 | + @Select("select count(1) from wvp_stream_proxy where status = true") | |
| 88 | + int getOnline(); | |
| 82 | 89 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
| ... | ... | @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.storager.dao; |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 4 | 4 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 5 | 5 | import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; |
| 6 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 7 | 6 | import org.apache.ibatis.annotations.*; |
| 8 | 7 | import org.springframework.stereotype.Repository; |
| 9 | 8 | |
| ... | ... | @@ -89,7 +88,7 @@ public interface StreamPushMapper { |
| 89 | 88 | StreamPushItem selectOne(String app, String stream); |
| 90 | 89 | |
| 91 | 90 | @Insert("<script>" + |
| 92 | - "Insert IGNORE INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, " + | |
| 91 | + "Insert INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, " + | |
| 93 | 92 | "create_time, alive_second, media_server_id, status, push_ing) " + |
| 94 | 93 | "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" + |
| 95 | 94 | "( #{item.app}, #{item.stream}, #{item.totalReaderCount}, #{item.originType}, " + |
| ... | ... | @@ -171,9 +170,20 @@ public interface StreamPushMapper { |
| 171 | 170 | @Select("SELECT CONCAT(app,stream) from wvp_gb_stream") |
| 172 | 171 | List<String> getAllAppAndStream(); |
| 173 | 172 | |
| 173 | + @Select("select count(1) from wvp_stream_push ") | |
| 174 | + int getAllCount(); | |
| 175 | + | |
| 174 | 176 | @Select(value = {" <script>" + |
| 175 | - " <if test='pushIngAsOnline == true'> select count(1) as total, sum(push_ing) as online from wvp_stream_push </if>" + | |
| 176 | - " <if test='pushIngAsOnline == false'> select count(1) as total, sum(status) as online from wvp_stream_push </if>" + | |
| 177 | + " <if test='pushIngAsOnline == true'> select count(1) from wvp_stream_push where push_ing = true </if>" + | |
| 178 | + " <if test='pushIngAsOnline == false'> select count(1)from wvp_stream_push where status = true </if>" + | |
| 177 | 179 | " </script>"}) |
| 178 | - ResourceBaceInfo getOverview(boolean pushIngAsOnline); | |
| 180 | + int getAllOnline(Boolean usePushingAsStatus); | |
| 181 | + | |
| 182 | + @Select("<script> " + | |
| 183 | + "select app, stream from wvp_stream_push where (app, stream) in " + | |
| 184 | + "<foreach collection='streamPushItems' item='item' separator=','>" + | |
| 185 | + "(#{item.app}, #{item.stream}) " + | |
| 186 | + "</foreach>" + | |
| 187 | + "</script>") | |
| 188 | + List<StreamPushItem> getListIn(List<StreamPushItem> streamPushItems); | |
| 179 | 189 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| ... | ... | @@ -123,6 +123,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 123 | 123 | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| 124 | 124 | // 数据去重 |
| 125 | 125 | List<DeviceChannel> channels = new ArrayList<>(); |
| 126 | + | |
| 127 | + List<DeviceChannel> updateChannels = new ArrayList<>(); | |
| 128 | + List<DeviceChannel> addChannels = new ArrayList<>(); | |
| 126 | 129 | StringBuilder stringBuilder = new StringBuilder(); |
| 127 | 130 | Map<String, Integer> subContMap = new HashMap<>(); |
| 128 | 131 | if (deviceChannelList.size() > 0) { |
| ... | ... | @@ -131,18 +134,22 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 131 | 134 | for (DeviceChannel deviceChannel : deviceChannelList) { |
| 132 | 135 | if (!gbIdSet.contains(deviceChannel.getChannelId())) { |
| 133 | 136 | gbIdSet.add(deviceChannel.getChannelId()); |
| 137 | + deviceChannel.setUpdateTime(DateUtil.getNow()); | |
| 134 | 138 | if (allChannelMap.containsKey(deviceChannel.getChannelId())) { |
| 135 | 139 | deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId()); |
| 136 | 140 | deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).isHasAudio()); |
| 137 | - if (allChannelMap.get(deviceChannel.getChannelId()).getStatus() !=deviceChannel.getStatus()){ | |
| 141 | + if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){ | |
| 138 | 142 | List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); |
| 139 | 143 | if (!CollectionUtils.isEmpty(strings)){ |
| 140 | 144 | strings.forEach(platformId->{ |
| 141 | - eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.getStatus()==1?CatalogEvent.ON:CatalogEvent.OFF); | |
| 145 | + eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF); | |
| 142 | 146 | }); |
| 143 | 147 | } |
| 144 | - | |
| 145 | 148 | } |
| 149 | + updateChannels.add(deviceChannel); | |
| 150 | + }else { | |
| 151 | + deviceChannel.setCreateTime(DateUtil.getNow()); | |
| 152 | + addChannels.add(deviceChannel); | |
| 146 | 153 | } |
| 147 | 154 | channels.add(deviceChannel); |
| 148 | 155 | if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { |
| ... | ... | @@ -175,21 +182,36 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 175 | 182 | } |
| 176 | 183 | try { |
| 177 | 184 | int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); |
| 185 | + | |
| 178 | 186 | int limitCount = 300; |
| 179 | 187 | boolean result = cleanChannelsResult < 0; |
| 180 | - if (!result && channels.size() > 0) { | |
| 181 | - if (channels.size() > limitCount) { | |
| 182 | - for (int i = 0; i < channels.size(); i += limitCount) { | |
| 188 | + if (!result && addChannels.size() > 0) { | |
| 189 | + if (addChannels.size() > limitCount) { | |
| 190 | + for (int i = 0; i < addChannels.size(); i += limitCount) { | |
| 191 | + int toIndex = i + limitCount; | |
| 192 | + if (i + limitCount > addChannels.size()) { | |
| 193 | + toIndex = addChannels.size(); | |
| 194 | + } | |
| 195 | + result = result || deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0; | |
| 196 | + } | |
| 197 | + }else { | |
| 198 | + result = result || deviceChannelMapper.batchAdd(addChannels) < 0; | |
| 199 | + } | |
| 200 | + } | |
| 201 | + if (!result && updateChannels.size() > 0) { | |
| 202 | + if (updateChannels.size() > limitCount) { | |
| 203 | + for (int i = 0; i < updateChannels.size(); i += limitCount) { | |
| 183 | 204 | int toIndex = i + limitCount; |
| 184 | - if (i + limitCount > channels.size()) { | |
| 185 | - toIndex = channels.size(); | |
| 205 | + if (i + limitCount > updateChannels.size()) { | |
| 206 | + toIndex = updateChannels.size(); | |
| 186 | 207 | } |
| 187 | - result = result || deviceChannelMapper.batchAddOrUpdate(channels.subList(i, toIndex)) < 0; | |
| 208 | + result = result || deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0; | |
| 188 | 209 | } |
| 189 | 210 | }else { |
| 190 | - result = result || deviceChannelMapper.batchAddOrUpdate(channels) < 0; | |
| 211 | + result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0; | |
| 191 | 212 | } |
| 192 | 213 | } |
| 214 | + | |
| 193 | 215 | if (result) { |
| 194 | 216 | //事务回滚 |
| 195 | 217 | dataSourceTransactionManager.rollback(transactionStatus); |
| ... | ... | @@ -919,7 +941,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 919 | 941 | deviceChannel.setLatitude(0.0); |
| 920 | 942 | deviceChannel.setDeviceId(platform.getDeviceGBId()); |
| 921 | 943 | deviceChannel.setManufacture("wvp-pro"); |
| 922 | - deviceChannel.setStatus(1); | |
| 944 | + deviceChannel.setStatus(true); | |
| 923 | 945 | deviceChannel.setParental(1); |
| 924 | 946 | |
| 925 | 947 | deviceChannel.setRegisterWay(1); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaceInfo.java renamed to src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaseInfo.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.bean; |
| 2 | 2 | |
| 3 | -public class ResourceBaceInfo { | |
| 3 | +public class ResourceBaseInfo { | |
| 4 | 4 | private int total; |
| 5 | 5 | private int online; |
| 6 | 6 | |
| 7 | + public ResourceBaseInfo() { | |
| 8 | + } | |
| 9 | + | |
| 10 | + public ResourceBaseInfo(int total, int online) { | |
| 11 | + this.total = total; | |
| 12 | + this.online = online; | |
| 13 | + } | |
| 14 | + | |
| 7 | 15 | public int getTotal() { |
| 8 | 16 | return total; |
| 9 | 17 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java
| ... | ... | @@ -2,40 +2,40 @@ package com.genersoft.iot.vmp.vmanager.bean; |
| 2 | 2 | |
| 3 | 3 | public class ResourceInfo { |
| 4 | 4 | |
| 5 | - private ResourceBaceInfo device; | |
| 6 | - private ResourceBaceInfo channel; | |
| 7 | - private ResourceBaceInfo push; | |
| 8 | - private ResourceBaceInfo proxy; | |
| 5 | + private ResourceBaseInfo device; | |
| 6 | + private ResourceBaseInfo channel; | |
| 7 | + private ResourceBaseInfo push; | |
| 8 | + private ResourceBaseInfo proxy; | |
| 9 | 9 | |
| 10 | - public ResourceBaceInfo getDevice() { | |
| 10 | + public ResourceBaseInfo getDevice() { | |
| 11 | 11 | return device; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public void setDevice(ResourceBaceInfo device) { | |
| 14 | + public void setDevice(ResourceBaseInfo device) { | |
| 15 | 15 | this.device = device; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public ResourceBaceInfo getChannel() { | |
| 18 | + public ResourceBaseInfo getChannel() { | |
| 19 | 19 | return channel; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public void setChannel(ResourceBaceInfo channel) { | |
| 22 | + public void setChannel(ResourceBaseInfo channel) { | |
| 23 | 23 | this.channel = channel; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public ResourceBaceInfo getPush() { | |
| 26 | + public ResourceBaseInfo getPush() { | |
| 27 | 27 | return push; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public void setPush(ResourceBaceInfo push) { | |
| 30 | + public void setPush(ResourceBaseInfo push) { | |
| 31 | 31 | this.push = push; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public ResourceBaceInfo getProxy() { | |
| 34 | + public ResourceBaseInfo getProxy() { | |
| 35 | 35 | return proxy; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public void setProxy(ResourceBaceInfo proxy) { | |
| 38 | + public void setProxy(ResourceBaseInfo proxy) { | |
| 39 | 39 | this.proxy = proxy; |
| 40 | 40 | } |
| 41 | 41 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java
| ... | ... | @@ -15,7 +15,7 @@ import com.genersoft.iot.vmp.service.*; |
| 15 | 15 | import com.genersoft.iot.vmp.service.bean.MediaServerLoad; |
| 16 | 16 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 17 | 17 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 18 | -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; | |
| 18 | +import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; | |
| 19 | 19 | import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo; |
| 20 | 20 | import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo; |
| 21 | 21 | import io.swagger.v3.oas.annotations.Operation; |
| ... | ... | @@ -251,13 +251,13 @@ public class ServerController { |
| 251 | 251 | @Operation(summary = "获取负载信息") |
| 252 | 252 | public ResourceInfo getResourceInfo() { |
| 253 | 253 | ResourceInfo result = new ResourceInfo(); |
| 254 | - ResourceBaceInfo deviceInfo = deviceService.getOverview(); | |
| 254 | + ResourceBaseInfo deviceInfo = deviceService.getOverview(); | |
| 255 | 255 | result.setDevice(deviceInfo); |
| 256 | - ResourceBaceInfo channelInfo = channelService.getOverview(); | |
| 256 | + ResourceBaseInfo channelInfo = channelService.getOverview(); | |
| 257 | 257 | result.setChannel(channelInfo); |
| 258 | - ResourceBaceInfo pushInfo = pushService.getOverview(); | |
| 258 | + ResourceBaseInfo pushInfo = pushService.getOverview(); | |
| 259 | 259 | result.setPush(pushInfo); |
| 260 | - ResourceBaceInfo proxyInfo = proxyService.getOverview(); | |
| 260 | + ResourceBaseInfo proxyInfo = proxyService.getOverview(); | |
| 261 | 261 | result.setProxy(proxyInfo); |
| 262 | 262 | |
| 263 | 263 | return result; | ... | ... |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
| ... | ... | @@ -113,7 +113,7 @@ public class ApiStreamController { |
| 113 | 113 | result.put("error","channel[ " + code + " ]未找到"); |
| 114 | 114 | resultDeferredResult.setResult(result); |
| 115 | 115 | return resultDeferredResult; |
| 116 | - }else if (deviceChannel.getStatus() == 0) { | |
| 116 | + }else if (!deviceChannel.isStatus()) { | |
| 117 | 117 | JSONObject result = new JSONObject(); |
| 118 | 118 | result.put("error","channel[ " + code + " ]offline"); |
| 119 | 119 | resultDeferredResult.setResult(result); | ... | ... |