|
@@ -121,18 +121,18 @@ public class DhServiceImpl implements IDhService {
|
|
|
*
|
|
|
* @param token
|
|
|
*/
|
|
|
- public void tokenKeepalive(String token) {
|
|
|
+ public void tokenKeepalive(String token, int duration) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.set("token", token);
|
|
|
- json.set("duration", 86400);
|
|
|
+ json.set("duration", duration);
|
|
|
String put = HttpRequest.put(keepaliveUrl).timeout(-1).body(json.toString()).execute().body();
|
|
|
JSONObject putJson = JSONUtil.parseObj(put);
|
|
|
if (putJson.getInt("code") == 200) {
|
|
|
// 存入redis缓存
|
|
|
- RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, 86400, TimeUnit.SECONDS);
|
|
|
+ RedisUtils.setCacheObject(Constants.CACHE_DH_TOKEN, token, duration, TimeUnit.SECONDS);
|
|
|
} else {
|
|
|
log.info("保活失败:{}。重新获取", putJson);
|
|
|
- authorize();
|
|
|
+// authorize();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -190,8 +190,8 @@ public class DhServiceImpl implements IDhService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> getVideoToken(String account) {
|
|
|
- Map<String, Object> token = RedisUtils.getCacheMap(Constants.CACHE_DH_VIDEO_TOKEN);
|
|
|
+ public Map<String, Object> getVideoToken(String account, String key) {
|
|
|
+ Map<String, Object> token = RedisUtils.getCacheMap(key);
|
|
|
if (token.isEmpty()) {
|
|
|
token = new HashMap<>();
|
|
|
// 从大华接口获取token
|
|
@@ -226,7 +226,7 @@ public class DhServiceImpl implements IDhService {
|
|
|
jsonOne.set("randomKey", randomKey);
|
|
|
jsonOne.set("encryptType", encryptType);
|
|
|
jsonOne.set("pid", 2548);
|
|
|
- jsonOne.set("expiredTime", 86400);
|
|
|
+ jsonOne.set("expiredTime", 120);
|
|
|
String postTwo = HttpUtil.post(dhAuthorizeUrl, jsonOne.toString());
|
|
|
JSONObject postTwoJson = JSONUtil.parseObj(postTwo);
|
|
|
if (postTwoJson.containsKey("token")) {
|
|
@@ -242,8 +242,8 @@ public class DhServiceImpl implements IDhService {
|
|
|
duration = 120;
|
|
|
}
|
|
|
// 存入redis缓存
|
|
|
- RedisUtils.setCacheMap(Constants.CACHE_DH_VIDEO_TOKEN, token);
|
|
|
- RedisUtils.expire(Constants.CACHE_DH_VIDEO_TOKEN, Convert.toInt(duration), TimeUnit.SECONDS);
|
|
|
+ RedisUtils.setCacheMap(key, token);
|
|
|
+ RedisUtils.expire(key, Convert.toInt(duration), TimeUnit.SECONDS);
|
|
|
} else {
|
|
|
log.error("【视频】大华,账号:{}第二次创建会话失败:{}", account, postTwoJson);
|
|
|
if ("user is repeated landing".equals(postTwoJson.getStr("message"))) {
|
|
@@ -258,8 +258,8 @@ public class DhServiceImpl implements IDhService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void offlineVideoToken() {
|
|
|
- RedisUtils.deleteObject(Constants.CACHE_DH_VIDEO_TOKEN);
|
|
|
+ public void offlineVideoToken(String key) {
|
|
|
+ RedisUtils.deleteObject(key);
|
|
|
}
|
|
|
|
|
|
private JSONArray getList(Map<String, Object> param) {
|