Commit aae26323 authored by 刘凡's avatar 刘凡

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents 98220b51 e72fcf0c
......@@ -41,56 +41,59 @@ public class CylinderUnitVideoServiceImpl extends BaseService<CylinderUnitVideoD
private static final String CODE_20001 = "20001";
@Override
public List<String> getUnitVideoUrl(Long unitSeq) {
List<String> result = new ArrayList<String>();
LambdaQueryWrapper<CylinderUnitVideo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CylinderUnitVideo::getUnitSeq,unitSeq);
CylinderUnitVideo cylinderUnitVideo = this.getBaseMapper().selectOne(wrapper);
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("appKey",cylinderUnitVideo.getAppKey());
requestInfo.put("appSecret",cylinderUnitVideo.getAppSecret());
List<String> result = new ArrayList<String>();
try {
String accessTokenData = HttpUtil.post(cylinderUnitVideo.getTokenUrl(),requestInfo);
JSONObject jsonObject = JSON.parseObject(accessTokenData);
String msg = jsonObject.get("msg").toString();
String code = jsonObject.get("code").toString();
if(CODE_10001.equals(code) || CODE_10005.equals(code) || CODE_10017.equals(code) || CODE_10030.equals(code) || CODE_49999.equals(code)){
String errorMsg = "code:"+code+"msg:"+msg+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret();
logger.info("视频token获取失败errorMsg",errorMsg);
return result;
}
if(CODE_200.equals(code)){
String data = jsonObject.get("data").toString();
JSONObject objTokenJson = JSON.parseObject(data);
String accessToken = objTokenJson.get("accessToken").toString();
System.out.println(accessToken);
String channelNos = cylinderUnitVideo.getChannelNo();
List<String> channelNoList = Arrays.asList(channelNos.split(","));
for (String channelNo : channelNoList) {
HashMap<String, Object> requestVideosInfo = new HashMap<>();
requestVideosInfo.put("accessToken",accessToken);
requestVideosInfo.put("deviceSerial",cylinderUnitVideo.getDeviceSerial());
requestVideosInfo.put("channelNo",channelNo);
requestVideosInfo.put("protocol",cylinderUnitVideo.getProtocol());
requestVideosInfo.put("expireTime",cylinderUnitVideo.getExpireTime());
String videoData = HttpUtil.post(cylinderUnitVideo.getUrl(),requestVideosInfo);
JSONObject videoJsonObject = JSON.parseObject(videoData);
String msgVideo = videoJsonObject.get("msg").toString();
String codeVideo = videoJsonObject.get("code").toString();
if(CODE_201.equals(codeVideo) || CODE_401.equals(codeVideo) || CODE_403.equals(codeVideo) || CODE_404.equals(codeVideo) || CODE_20001.equals(codeVideo)){
String errorMsg = "code:"+codeVideo+"msg:"+msgVideo+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret()+"accessToken:"+accessToken;
logger.info("视频地址获取失败errorMsg",errorMsg);
}
if(CODE_200.equals(codeVideo)){
String dataS = videoJsonObject.get("data").toString();
JSONObject dd = JSON.parseObject(dataS);
String url = dd.get("url").toString();
result.add(url);
if(null != cylinderUnitVideo){
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("appKey",cylinderUnitVideo.getAppKey());
requestInfo.put("appSecret",cylinderUnitVideo.getAppSecret());
try {
String accessTokenData = HttpUtil.post(cylinderUnitVideo.getTokenUrl(),requestInfo);
JSONObject jsonObject = JSON.parseObject(accessTokenData);
String msg = jsonObject.get("msg").toString();
String code = jsonObject.get("code").toString();
if(CODE_10001.equals(code) || CODE_10005.equals(code) || CODE_10017.equals(code) || CODE_10030.equals(code) || CODE_49999.equals(code)){
String errorMsg = "code:"+code+"msg:"+msg+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret();
logger.info("视频token获取失败errorMsg",errorMsg);
return result;
}
if(CODE_200.equals(code)){
String data = jsonObject.get("data").toString();
JSONObject objTokenJson = JSON.parseObject(data);
String accessToken = objTokenJson.get("accessToken").toString();
System.out.println(accessToken);
String channelNos = cylinderUnitVideo.getChannelNo();
List<String> channelNoList = Arrays.asList(channelNos.split(","));
for (String channelNo : channelNoList) {
HashMap<String, Object> requestVideosInfo = new HashMap<>();
requestVideosInfo.put("accessToken",accessToken);
requestVideosInfo.put("deviceSerial",cylinderUnitVideo.getDeviceSerial());
requestVideosInfo.put("channelNo",channelNo);
requestVideosInfo.put("protocol",cylinderUnitVideo.getProtocol());
requestVideosInfo.put("expireTime",cylinderUnitVideo.getExpireTime());
String videoData = HttpUtil.post(cylinderUnitVideo.getUrl(),requestVideosInfo);
JSONObject videoJsonObject = JSON.parseObject(videoData);
String msgVideo = videoJsonObject.get("msg").toString();
String codeVideo = videoJsonObject.get("code").toString();
if(CODE_201.equals(codeVideo) || CODE_401.equals(codeVideo) || CODE_403.equals(codeVideo) || CODE_404.equals(codeVideo) || CODE_20001.equals(codeVideo)){
String errorMsg = "code:"+codeVideo+"msg:"+msgVideo+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret()+"accessToken:"+accessToken;
logger.info("视频地址获取失败errorMsg",errorMsg);
}
if(CODE_200.equals(codeVideo)){
String dataS = videoJsonObject.get("data").toString();
JSONObject dd = JSON.parseObject(dataS);
String url = dd.get("url").toString();
result.add(url);
}
}
}
}catch (Exception e){
logger.error(e.getMessage());
e.printStackTrace();
}
}catch (Exception e){
logger.error(e.getMessage());
e.printStackTrace();
}
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment