Commit 57a5a358 authored by duanruiming's avatar duanruiming

[add] 灯态推送易购优化;

parent fb71083d
...@@ -273,9 +273,18 @@ public class SignalStatusServiceImpl implements SignalStatusService { ...@@ -273,9 +273,18 @@ public class SignalStatusServiceImpl implements SignalStatusService {
log.error("海信灯态推送百度失败:{}", e.getMessage()); log.error("海信灯态推送百度失败:{}", e.getMessage());
} }
try { try {
OkHttpClientUtil.jsonPost(yiGouUrl, jackson.writeValueAsString(hisenseLightStatusPojos)); HisenseLightStatusPojo hisenseLightStatusPojo = hisenseLightStatusPojos.get(0);
String bodyStr = hisenseLightStatusPojo.getBody();
List<HisenseLightStatusPojo.Body> bodies = jackson.readValue(bodyStr, new TypeReference<List<HisenseLightStatusPojo.Body>>() {});
for (HisenseLightStatusPojo.Body body : bodies) {
HisenseLightStatusPojo.ContentBody content = body.getContent();
String crossId = content.getCrossId();
if (StringUtils.equalsIgnoreCase("255136", crossId)) {
OkHttpClientUtil.jsonPost(yiGouUrl, jackson.writeValueAsString(hisenseLightStatusPojos));
}
}
} catch (Exception e) { } catch (Exception e) {
log.error("海信灯态推送易购失败:{}", e.getMessage()); log.error("海信灯态推送易购失败:{}", e);
} }
} }
......
...@@ -6,6 +6,7 @@ import net.wanji.common.utils.tool.StringUtils; ...@@ -6,6 +6,7 @@ import net.wanji.common.utils.tool.StringUtils;
import okhttp3.*; import okhttp3.*;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.TimeUnit;
/** /**
* @ClassName OkHttpClient * @ClassName OkHttpClient
...@@ -48,7 +49,10 @@ public class OkHttpClientUtil { ...@@ -48,7 +49,10 @@ public class OkHttpClientUtil {
return null; return null;
} }
// 创建 OkHttpClient 实例 // 创建 OkHttpClient 实例
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
// 创建请求体 // 创建请求体
RequestBody body = RequestBody.create(json, MediaType.get("application/json; charset=utf-8")); RequestBody body = RequestBody.create(json, MediaType.get("application/json; charset=utf-8"));
// 创建请求 // 创建请求
...@@ -66,7 +70,7 @@ public class OkHttpClientUtil { ...@@ -66,7 +70,7 @@ public class OkHttpClientUtil {
} }
} catch (Exception e) { } catch (Exception e) {
log.error("OkHttpClientUtil远程服务url:{}, 调用异常:{}", url, e.getMessage()); log.error("OkHttpClientUtil远程服务url:{}, 调用异常:{}", url, e.getMessage());
throw new Exception(); throw new Exception(e);
} }
return null; return null;
} }
......
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