Commit ad8c4089 by liangkaiping

Merge branch 'hutao-替换保利威视配置' into 'master'

打日志 直播状态

See merge request fairylandcloudschool/cloud-live!2
parents 99652083 d446c542
...@@ -19,11 +19,7 @@ import java.util.*; ...@@ -19,11 +19,7 @@ import java.util.*;
@Component @Component
public class LiveUtil { public class LiveUtil {
private RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000) public static String sendHttpPost(String httpUrl, Map<String, String> maps) {
.setConnectionRequestTimeout(15000).build();
public String sendHttpPost(String httpUrl, Map<String, String> maps) {
HttpPost httpPost = new HttpPost(httpUrl); HttpPost httpPost = new HttpPost(httpUrl);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
...@@ -38,14 +34,14 @@ public class LiveUtil { ...@@ -38,14 +34,14 @@ public class LiveUtil {
return sendHttpPost(httpPost); return sendHttpPost(httpPost);
} }
private String sendHttpPost(HttpPost httpPost) { private static String sendHttpPost(HttpPost httpPost) {
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
HttpEntity entity = null; HttpEntity entity = null;
String responseContent = null; String responseContent = null;
try { try {
httpClient = HttpClients.createDefault(); httpClient = HttpClients.createDefault();
httpPost.setConfig(requestConfig); httpPost.setConfig(RequestConfig.custom().setSocketTimeout(15000).setConnectTimeout(15000).setConnectionRequestTimeout(15000).build());
response = httpClient.execute(httpPost); response = httpClient.execute(httpPost);
entity = response.getEntity(); entity = response.getEntity();
responseContent = EntityUtils.toString(entity, "UTF-8"); responseContent = EntityUtils.toString(entity, "UTF-8");
...@@ -66,16 +62,16 @@ public class LiveUtil { ...@@ -66,16 +62,16 @@ public class LiveUtil {
return responseContent; return responseContent;
} }
public String generateSign(Map<String, String> parray, String secretKey) { public static String generateSign(Map<String, String> parray, String secretKey) {
Map<String, String> params = this.paraFilter(parray); Map<String, String> params = paraFilter(parray);
String concatedStr = this.concatParams(params); String concatedStr = concatParams(params);
String plain = secretKey + concatedStr + secretKey; String plain = secretKey + concatedStr + secretKey;
String encrypted = MD5Utils.getMD5String(plain); String encrypted = MD5Utils.getMD5String(plain);
String upperCase = encrypted.toUpperCase(); String upperCase = encrypted.toUpperCase();
return upperCase; return upperCase;
} }
private Map<String, String> paraFilter(Map<String, String> sArray) { private static Map<String, String> paraFilter(Map<String, String> sArray) {
Map<String, String> result = new HashMap<String, String>(); Map<String, String> result = new HashMap<String, String>();
if (sArray == null || sArray.size() <= 0) { if (sArray == null || sArray.size() <= 0) {
return result; return result;
...@@ -91,7 +87,7 @@ public class LiveUtil { ...@@ -91,7 +87,7 @@ public class LiveUtil {
return result; return result;
} }
private String concatParams(Map<String, String> params) { private static String concatParams(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet()); List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys); Collections.sort(keys);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
......
...@@ -66,10 +66,12 @@ public class PolyvUtils { ...@@ -66,10 +66,12 @@ public class PolyvUtils {
public static LiveStatusV2 getLiveStatus(String channelId, Date startAt, Date endAt, Integer liveStatus) { public static LiveStatusV2 getLiveStatus(String channelId, Date startAt, Date endAt, Integer liveStatus) {
// 直播中 // 直播中
if (null != liveStatus && liveStatus.equals(LiveStatusEnum.LIVE.getCode())) { if (null != liveStatus && liveStatus.equals(LiveStatusEnum.LIVE.getCode())) {
logger.info("直播 channel:" + channelId+ "-----1");
return LiveStatusV2.RUNNING; return LiveStatusV2.RUNNING;
} }
if (LiveStatusV2.RUNNING.getCode().equals(getThirdLiveStatus(channelId))) { if (LiveStatusV2.RUNNING.getCode().equals(getThirdLiveStatus(channelId))) {
logger.info("直播 channel:" + channelId+ "-----2");
return LiveStatusV2.RUNNING; return LiveStatusV2.RUNNING;
} }
...@@ -77,15 +79,19 @@ public class PolyvUtils { ...@@ -77,15 +79,19 @@ public class PolyvUtils {
// 未开始 // 未开始
if (startAt.getTime() > currentTime) { if (startAt.getTime() > currentTime) {
logger.info("直播 channel:" + channelId+ "-----3");
return LiveStatusV2.UN_START; return LiveStatusV2.UN_START;
} }
Integer count = getCountByChannel(channelId, startAt, new Date(currentTime)); Integer count = getCountByChannel(channelId, startAt, new Date(currentTime));
if (count > 0) { if (count > 0) {
logger.info("直播 channel:" + channelId+ "-----4");
return LiveStatusV2.REPLAY; return LiveStatusV2.REPLAY;
} }
if (count <= 0 && currentTime > endAt.getTime()) { if (count <= 0 && currentTime > endAt.getTime()) {
logger.info("直播 channel:" + channelId+ "-----5");
return LiveStatusV2.END; return LiveStatusV2.END;
} }
logger.info("直播 channel:" + channelId+ "-----6");
return LiveStatusV2.UN_START; return LiveStatusV2.UN_START;
} }
......
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