|
|
@@ -3,7 +3,9 @@ package com.yunfeiyun.agmp.iots.device.serviceImp;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
import com.yunfeiyun.agmp.common.log.LogCore;
|
|
|
+import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.spring.SpringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.devicetype.ServiceNameConst;
|
|
|
@@ -33,7 +35,10 @@ public class YbqCmbService extends HttpClient {
|
|
|
String getHostUrl() {
|
|
|
JSONObject jsonObject = getClientConfig();
|
|
|
String hostUrl = jsonObject.getString("hostUrl");
|
|
|
- log.info("获取到的hostUrl: {}", hostUrl);
|
|
|
+ log.info("获取到的hostUrl: {},jsonObject:{}", hostUrl, jsonObject);
|
|
|
+ if (StringUtils.isEmpty(hostUrl)) {
|
|
|
+ throw new IotBizException(ErrorCode.FAILURE.getCode(), "黄氏生物配置错误:没有hostUrl");
|
|
|
+ }
|
|
|
return hostUrl;
|
|
|
}
|
|
|
|
|
|
@@ -57,16 +62,17 @@ public class YbqCmbService extends HttpClient {
|
|
|
* @param token xxxx不可修改
|
|
|
* @param type 1:赤霉病,2:小麦白粉病,3:小麦白粉病,条锈病
|
|
|
*/
|
|
|
- public JSONArray getPredictedData(String devId, String startDate, String endDate, String type) {
|
|
|
+ public JSONArray getPredictedData(String devId, String startDate, String endDate, String type) {
|
|
|
StringBuffer url = new StringBuffer();
|
|
|
url.append(getHostUrl());
|
|
|
+ url.append("/");
|
|
|
url.append("external/data/predict?");
|
|
|
url.append("deviceId=").append(devId);
|
|
|
url.append("&startDate=").append(startDate);
|
|
|
url.append("&endDate=").append(endDate);
|
|
|
url.append("&token=").append(getToken());
|
|
|
url.append("&type=").append(type);
|
|
|
- log.info("【数据同步:{}】",url.toString());
|
|
|
+ log.info("【数据同步:{}】", url.toString());
|
|
|
String response = HttpUtil.createGet(url.toString()).execute().body();
|
|
|
YjjcResponse yjjcResponse = resolveData(response);
|
|
|
if (yjjcResponse.isSuccess()) {
|
|
|
@@ -75,6 +81,7 @@ public class YbqCmbService extends HttpClient {
|
|
|
throw new IotBizException(IotErrorCode.FAILURE.getCode(), yjjcResponse.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取上报数据
|
|
|
*
|
|
|
@@ -87,12 +94,13 @@ public class YbqCmbService extends HttpClient {
|
|
|
public JSONArray getReportData(String devId, String startDate, String endDate) {
|
|
|
StringBuffer url = new StringBuffer();
|
|
|
url.append(getHostUrl());
|
|
|
+ url.append("/");
|
|
|
url.append("external/data/yunfei/upload?");
|
|
|
url.append("deviceId=").append(devId);
|
|
|
url.append("&startDate=").append(startDate);
|
|
|
url.append("&endDate=").append(endDate);
|
|
|
url.append("&token=").append(getToken());
|
|
|
- log.info("【数据同步:{}】",url.toString());
|
|
|
+ log.info("【数据同步:{}】", url.toString());
|
|
|
String response = HttpUtil.createGet(url.toString()).execute().body();
|
|
|
YjjcResponse yjjcResponse = resolveData(response);
|
|
|
if (yjjcResponse.isSuccess()) {
|