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 ...@@ -41,56 +41,59 @@ public class CylinderUnitVideoServiceImpl extends BaseService<CylinderUnitVideoD
private static final String CODE_20001 = "20001"; private static final String CODE_20001 = "20001";
@Override @Override
public List<String> getUnitVideoUrl(Long unitSeq) { public List<String> getUnitVideoUrl(Long unitSeq) {
List<String> result = new ArrayList<String>();
LambdaQueryWrapper<CylinderUnitVideo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CylinderUnitVideo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CylinderUnitVideo::getUnitSeq,unitSeq); wrapper.eq(CylinderUnitVideo::getUnitSeq,unitSeq);
CylinderUnitVideo cylinderUnitVideo = this.getBaseMapper().selectOne(wrapper); CylinderUnitVideo cylinderUnitVideo = this.getBaseMapper().selectOne(wrapper);
HashMap<String, Object> requestInfo = new HashMap<>(); if(null != cylinderUnitVideo){
requestInfo.put("appKey",cylinderUnitVideo.getAppKey()); HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("appSecret",cylinderUnitVideo.getAppSecret()); requestInfo.put("appKey",cylinderUnitVideo.getAppKey());
List<String> result = new ArrayList<String>(); requestInfo.put("appSecret",cylinderUnitVideo.getAppSecret());
try {
String accessTokenData = HttpUtil.post(cylinderUnitVideo.getTokenUrl(),requestInfo); try {
JSONObject jsonObject = JSON.parseObject(accessTokenData); String accessTokenData = HttpUtil.post(cylinderUnitVideo.getTokenUrl(),requestInfo);
String msg = jsonObject.get("msg").toString(); JSONObject jsonObject = JSON.parseObject(accessTokenData);
String code = jsonObject.get("code").toString(); String msg = jsonObject.get("msg").toString();
if(CODE_10001.equals(code) || CODE_10005.equals(code) || CODE_10017.equals(code) || CODE_10030.equals(code) || CODE_49999.equals(code)){ String code = jsonObject.get("code").toString();
String errorMsg = "code:"+code+"msg:"+msg+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret(); if(CODE_10001.equals(code) || CODE_10005.equals(code) || CODE_10017.equals(code) || CODE_10030.equals(code) || CODE_49999.equals(code)){
logger.info("视频token获取失败errorMsg",errorMsg); String errorMsg = "code:"+code+"msg:"+msg+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret();
return result; logger.info("视频token获取失败errorMsg",errorMsg);
} return result;
if(CODE_200.equals(code)){ }
String data = jsonObject.get("data").toString(); if(CODE_200.equals(code)){
JSONObject objTokenJson = JSON.parseObject(data); String data = jsonObject.get("data").toString();
String accessToken = objTokenJson.get("accessToken").toString(); JSONObject objTokenJson = JSON.parseObject(data);
System.out.println(accessToken); String accessToken = objTokenJson.get("accessToken").toString();
String channelNos = cylinderUnitVideo.getChannelNo(); System.out.println(accessToken);
List<String> channelNoList = Arrays.asList(channelNos.split(",")); String channelNos = cylinderUnitVideo.getChannelNo();
for (String channelNo : channelNoList) { List<String> channelNoList = Arrays.asList(channelNos.split(","));
HashMap<String, Object> requestVideosInfo = new HashMap<>(); for (String channelNo : channelNoList) {
requestVideosInfo.put("accessToken",accessToken); HashMap<String, Object> requestVideosInfo = new HashMap<>();
requestVideosInfo.put("deviceSerial",cylinderUnitVideo.getDeviceSerial()); requestVideosInfo.put("accessToken",accessToken);
requestVideosInfo.put("channelNo",channelNo); requestVideosInfo.put("deviceSerial",cylinderUnitVideo.getDeviceSerial());
requestVideosInfo.put("protocol",cylinderUnitVideo.getProtocol()); requestVideosInfo.put("channelNo",channelNo);
requestVideosInfo.put("expireTime",cylinderUnitVideo.getExpireTime()); requestVideosInfo.put("protocol",cylinderUnitVideo.getProtocol());
String videoData = HttpUtil.post(cylinderUnitVideo.getUrl(),requestVideosInfo); requestVideosInfo.put("expireTime",cylinderUnitVideo.getExpireTime());
JSONObject videoJsonObject = JSON.parseObject(videoData); String videoData = HttpUtil.post(cylinderUnitVideo.getUrl(),requestVideosInfo);
String msgVideo = videoJsonObject.get("msg").toString(); JSONObject videoJsonObject = JSON.parseObject(videoData);
String codeVideo = videoJsonObject.get("code").toString(); String msgVideo = videoJsonObject.get("msg").toString();
if(CODE_201.equals(codeVideo) || CODE_401.equals(codeVideo) || CODE_403.equals(codeVideo) || CODE_404.equals(codeVideo) || CODE_20001.equals(codeVideo)){ String codeVideo = videoJsonObject.get("code").toString();
String errorMsg = "code:"+codeVideo+"msg:"+msgVideo+"appKey:"+cylinderUnitVideo.getAppKey()+"appSecret:"+cylinderUnitVideo.getAppSecret()+"accessToken:"+accessToken; if(CODE_201.equals(codeVideo) || CODE_401.equals(codeVideo) || CODE_403.equals(codeVideo) || CODE_404.equals(codeVideo) || CODE_20001.equals(codeVideo)){
logger.info("视频地址获取失败errorMsg",errorMsg); 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(); if(CODE_200.equals(codeVideo)){
JSONObject dd = JSON.parseObject(dataS); String dataS = videoJsonObject.get("data").toString();
String url = dd.get("url").toString(); JSONObject dd = JSON.parseObject(dataS);
result.add(url); 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; 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