|
@@ -3,6 +3,7 @@ package com.dji.sample.manage.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.dji.sample.common.smsp.CallSmsp;
|
|
import com.dji.sample.common.smsp.CallSmsp;
|
|
|
import com.dji.sample.common.util.DesUtil;
|
|
import com.dji.sample.common.util.DesUtil;
|
|
|
|
|
+import com.dji.sample.configuration.CustomConfiguration;
|
|
|
import com.dji.sample.manage.dao.IDevicePayloadMapper;
|
|
import com.dji.sample.manage.dao.IDevicePayloadMapper;
|
|
|
import com.dji.sample.manage.dao.IManageDeviceLivestreamUrlMapper;
|
|
import com.dji.sample.manage.dao.IManageDeviceLivestreamUrlMapper;
|
|
|
import com.dji.sample.manage.dao.IUserMapper;
|
|
import com.dji.sample.manage.dao.IUserMapper;
|
|
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -38,21 +40,17 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IManageDeviceLivestreamUrlMapper mapper;
|
|
private IManageDeviceLivestreamUrlMapper mapper;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private IDevicePayloadMapper payloadMapper;
|
|
|
|
|
-
|
|
|
|
|
- private final String clientId = "e534550a85d94faba73e8040e76514bc";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ManageDeviceLivestreamUrlDTO getUrl(ManageDeviceLivestreamUrlDTO deviceLivestreamUrlDTO) {
|
|
public ManageDeviceLivestreamUrlDTO getUrl(ManageDeviceLivestreamUrlDTO deviceLivestreamUrlDTO) {
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>();
|
|
QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>();
|
|
|
- userWrapper.lambda().eq(UserEntity::getUserType, UserTypeEnum.API.getVal()).eq(UserEntity::getClientId,clientId);
|
|
|
|
|
|
|
+ userWrapper.lambda().eq(UserEntity::getUserType, UserTypeEnum.API.getVal()).eq(UserEntity::getClientId, CustomConfiguration.clientId);
|
|
|
UserEntity userEntity = userMapper.selectOne(userWrapper);
|
|
UserEntity userEntity = userMapper.selectOne(userWrapper);
|
|
|
if (userEntity == null) {
|
|
if (userEntity == null) {
|
|
|
log.debug("The user is null.");
|
|
log.debug("The user is null.");
|
|
|
- return null;
|
|
|
|
|
|
|
+ throw new RuntimeException ("The user is null.");
|
|
|
}
|
|
}
|
|
|
//密码解密
|
|
//密码解密
|
|
|
String password = DesUtil.getDecryptData(userEntity.getPassword(),userEntity.getSalt());
|
|
String password = DesUtil.getDecryptData(userEntity.getPassword(),userEntity.getSalt());
|
|
@@ -75,6 +73,9 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
log.debug("The result is null.");
|
|
log.debug("The result is null.");
|
|
|
throw new RuntimeException (tokenMap.get("message"));
|
|
throw new RuntimeException (tokenMap.get("message"));
|
|
|
}
|
|
}
|
|
|
|
|
+ List<Integer> urlL = urlList.stream()
|
|
|
|
|
+ .map(ManageDeviceLivestreamUrlEntity::getChannelId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
//过滤payloadIndex
|
|
//过滤payloadIndex
|
|
|
List<ManageDeviceLivestreamUrlEntity> filterIndexList = urlList.stream().filter(channelData -> deviceLivestreamUrlDTO.getPayloadIndex().equals(channelData.getPayloadIndex()))
|
|
List<ManageDeviceLivestreamUrlEntity> filterIndexList = urlList.stream().filter(channelData -> deviceLivestreamUrlDTO.getPayloadIndex().equals(channelData.getPayloadIndex()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
@@ -83,45 +84,23 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
List<ManageDeviceLivestreamUrlDTO> channelList = rtmpList.stream().filter(channelData -> filterIndexList.get(0).getChannelId().equals(channelData.getChannelId()))
|
|
List<ManageDeviceLivestreamUrlDTO> channelList = rtmpList.stream().filter(channelData -> filterIndexList.get(0).getChannelId().equals(channelData.getChannelId()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
if (channelList.size() > 0) {
|
|
if (channelList.size() > 0) {
|
|
|
- //判断url是否一致
|
|
|
|
|
- for(ManageDeviceLivestreamUrlEntity url : filterIndexList) {
|
|
|
|
|
- if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
|
|
|
|
|
- if(!url.getUrl().equals(channelList.get(0).getRtmpUrl())) {
|
|
|
|
|
- url.setUrl(channelList.get(0).getRtmpUrl());
|
|
|
|
|
- mapper.updateById(url);}
|
|
|
|
|
- } else if(url.getUrlType().equals(LiveUrlTypeEnum.WEBRTC.getVal())) {
|
|
|
|
|
- if(!url.getUrl().equals(channelList.get(0).getWebRtcUrl())) {
|
|
|
|
|
- url.setUrl(channelList.get(0).getWebRtcUrl());
|
|
|
|
|
- mapper.updateById(url);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ update(filterIndexList,channelList);
|
|
|
rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
|
rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
|
} else {
|
|
} else {
|
|
|
if(rtmpList.size() > 0) {
|
|
if(rtmpList.size() > 0) {
|
|
|
//过滤channelId
|
|
//过滤channelId
|
|
|
- channelList = rtmpList.stream().filter(channelData -> !urlList.contains(channelData.getChannelId()))
|
|
|
|
|
|
|
+ channelList = rtmpList.stream().filter(channelData -> !urlL.contains(channelData.getChannelId()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
- for(ManageDeviceLivestreamUrlEntity url : filterIndexList) {
|
|
|
|
|
- url.setChannelId(channelList.get(0).getChannelId());
|
|
|
|
|
-
|
|
|
|
|
- if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
|
|
|
|
|
- url.setUrl(channelList.get(0).getRtmpUrl());
|
|
|
|
|
- mapper.updateById(url);
|
|
|
|
|
- } else if(url.getUrlType().equals(LiveUrlTypeEnum.WEBRTC.getVal())) {
|
|
|
|
|
- url.setUrl(channelList.get(0).getWebRtcUrl());
|
|
|
|
|
- mapper.updateById(url);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ update(filterIndexList,channelList);
|
|
|
rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
|
rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
|
} else {
|
|
} else {
|
|
|
for(ManageDeviceLivestreamUrlEntity url : filterIndexList) {
|
|
for(ManageDeviceLivestreamUrlEntity url : filterIndexList) {
|
|
|
if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
|
|
if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
|
|
|
- rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
|
|
|
|
|
+ rtmpDto.setRtmpUrl(url.getUrl());
|
|
|
} else if(url.getUrlType().equals(LiveUrlTypeEnum.WEBRTC.getVal())) {
|
|
} else if(url.getUrlType().equals(LiveUrlTypeEnum.WEBRTC.getVal())) {
|
|
|
- rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
|
|
|
|
|
+ rtmpDto.setWebRtcUrl(url.getUrl());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -129,8 +108,9 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
} else {
|
|
} else {
|
|
|
//过滤channelId
|
|
//过滤channelId
|
|
|
List<ManageDeviceLivestreamUrlDTO> channelList = rtmpList;
|
|
List<ManageDeviceLivestreamUrlDTO> channelList = rtmpList;
|
|
|
|
|
+
|
|
|
if(urlList.size() > 0) {
|
|
if(urlList.size() > 0) {
|
|
|
- channelList = rtmpList.stream().filter(channelData -> urlList.contains(channelData.getChannelId()))
|
|
|
|
|
|
|
+ channelList = rtmpList.stream().filter(channelData -> !urlL.contains(channelData.getChannelId()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
ManageDeviceLivestreamUrlEntity urlEntity = new ManageDeviceLivestreamUrlEntity();
|
|
ManageDeviceLivestreamUrlEntity urlEntity = new ManageDeviceLivestreamUrlEntity();
|
|
@@ -157,4 +137,19 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
}
|
|
}
|
|
|
return rtmpDto;
|
|
return rtmpDto;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private void update(List<ManageDeviceLivestreamUrlEntity> entitys,List<ManageDeviceLivestreamUrlDTO> dtos) {
|
|
|
|
|
+ for(ManageDeviceLivestreamUrlEntity url : entitys) {
|
|
|
|
|
+ url.setChannelId(dtos.get(0).getChannelId());
|
|
|
|
|
+ if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
|
|
|
|
|
+ url.setUrl(dtos.get(0).getRtmpUrl());
|
|
|
|
|
+ mapper.updateById(url);
|
|
|
|
|
+ } else if(url.getUrlType().equals(LiveUrlTypeEnum.WEBRTC.getVal())) {
|
|
|
|
|
+ url.setUrl(dtos.get(0).getWebRtcUrl());
|
|
|
|
|
+ mapper.updateById(url);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|