Commit 11cc86f3 authored by hezhuozhi's avatar hezhuozhi

提交大屏平均辐照度和利用小时数

parent bbeb4a19
...@@ -86,6 +86,7 @@ public class Constants { ...@@ -86,6 +86,7 @@ public class Constants {
public static final String get_quota_complate_info="method=scene_screen.large_screen.get_quota_complate_info"; public static final String get_quota_complate_info="method=scene_screen.large_screen.get_quota_complate_info";
public static final String resovleRule_data = "data"; public static final String resovleRule_data = "data";
public static final String areaChinese="区域"; public static final String areaChinese="区域";
public static final String get_big_screen_point_url="http://iiet-jepcc.powerchina.cn:8088/core/datastorage/gateway/point/list?groupId=1827987484823289857&dataType=analog";
} }
...@@ -19,6 +19,10 @@ import java.util.stream.Collectors; ...@@ -19,6 +19,10 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
...@@ -26,9 +30,11 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms; ...@@ -26,9 +30,11 @@ import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.ParsedAvg; import org.elasticsearch.search.aggregations.metrics.ParsedAvg;
import org.elasticsearch.search.aggregations.metrics.ParsedSum; import org.elasticsearch.search.aggregations.metrics.ParsedSum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -50,6 +56,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; ...@@ -50,6 +56,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil; import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
/** /**
* @description: * @description:
...@@ -58,6 +65,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil; ...@@ -58,6 +65,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil;
*/ */
@Service @Service
//@RequiredArgsConstructor //@RequiredArgsConstructor
@Slf4j
public class LargeScreenImpl { public class LargeScreenImpl {
@Autowired @Autowired
CommonServiceImpl commonServiceImpl; CommonServiceImpl commonServiceImpl;
...@@ -75,6 +83,10 @@ public class LargeScreenImpl { ...@@ -75,6 +83,10 @@ public class LargeScreenImpl {
SjglZsjZsbtzServiceImpl SjglZsjZsbtzServiceImpl; SjglZsjZsbtzServiceImpl SjglZsjZsbtzServiceImpl;
@Autowired @Autowired
private HttpRequestUtil httpRequestUtil; private HttpRequestUtil httpRequestUtil;
@Autowired
AmosRequestContext amosRequestContext;
@Autowired
RestTemplate restTemplate;
private final String SS = "瞬时风速"; private final String SS = "瞬时风速";
private final String ZFS = "WTX-801_25_WTX-801_总辐射"; private final String ZFS = "WTX-801_25_WTX-801_总辐射";
...@@ -149,10 +161,13 @@ public class LargeScreenImpl { ...@@ -149,10 +161,13 @@ public class LargeScreenImpl {
// Constants.REQUEST_GET, "", Constants.resovleRule_data); // Constants.REQUEST_GET, "", Constants.resovleRule_data);
// } // }
mapdta.put("SS", data.getDouble("average_wind_speed")); mapdta.put("SS", data.getDouble("average_wind_speed"));
mapdta.put("ZFS", data.getDouble("avg_irradiance")); // mapdta.put("ZFS", data.getDouble("avg_irradiance"));
mapdta.put("ZFSLJ", data.getDouble("sum_irradiance")); // mapdta.put("ZFSLJ", data.getDouble("sum_irradiance"));
} }
//平均辐照度和利用小时数采用合成测点的值
Map<String, Double> pointValue = getPointValue();
mapdta.put("ZFS", pointValue.get("ZFS"));
mapdta.put("ZFSLJ", pointValue.get("ZFSLJ"));
// //日发电量 // //日发电量
// AtomicReference<Double> dailyPower = new AtomicReference<>(0.0); // AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
// //月发电量 // //月发电量
...@@ -242,7 +257,62 @@ public class LargeScreenImpl { ...@@ -242,7 +257,62 @@ public class LargeScreenImpl {
return mapdta; return mapdta;
} }
/**
* 获取平均辐照度和利用小时数
* @return
*/
private Map<String,Double> getPointValue() {
Map<String,Double> resultMap=new HashMap();
JSONObject jsonObject = sendCoreGetRequest(Constants.get_big_screen_point_url);
if (!Objects.isNull(jsonObject)) {
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
JSONArray resultJsonArray = jsonObject.getJSONArray("result");
if (CollectionUtil.isNotEmpty(resultJsonArray)) {
for (Object o : resultJsonArray) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject result = new JSONObject(map);
String pointName = (String) map.get("pointName");
if ("大屏监控平均辐照度".equals(pointName)) {
resultMap.put("ZFS",result.getDouble("value"));
}
if ("大屏监控利用小时数".equals(pointName)) {
resultMap.put("ZFSLJ",result.getDouble("value"));
}
}
}
}
}
}
return resultMap;
}
/**
* 发送GET请求
* @param url
* @return
*/
private JSONObject sendCoreGetRequest(String url) {
HttpHeaders headers = new HttpHeaders();
headers.set("Token", amosRequestContext.getToken());
headers.set("Product", amosRequestContext.getProduct());
headers.set("Appkey", amosRequestContext.getAppKey());
HttpEntity entity = new HttpEntity<>(headers);
log.info("发送GET请求,请求地址{}", url);
try {
ResponseEntity<JSONObject> response = restTemplate.exchange(url, HttpMethod.GET, entity, JSONObject.class);
if (HttpStatus.OK == response.getStatusCode()) {
log.info("发送请求成功,请求返回体{}", response.getBody());
return response.getBody();
} else {
throw new BadRequest("返回接口异常,失败原因[" + response + "]");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BadRequest("发送GET请求失败,失败原因[" + e.getMessage() + "]");
}
}
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ?")
//@PostConstruct //@PostConstruct
private void sendQYYXZBMqtt() { private void sendQYYXZBMqtt() {
...@@ -440,8 +510,11 @@ public class LargeScreenImpl { ...@@ -440,8 +510,11 @@ public class LargeScreenImpl {
// "", Constants.resovleRule_data); // "", Constants.resovleRule_data);
// } // }
mapdta.put("SS", data.getString("average_wind_speed")); mapdta.put("SS", data.getString("average_wind_speed"));
mapdta.put("ZFS", data.getString("avg_irradiance")); // mapdta.put("ZFS", data.getString("avg_irradiance"));
mapdta.put("ZFSLJ", data.getString("sum_irradiance")); // mapdta.put("ZFSLJ", data.getString("sum_irradiance"));
Map<String, Double> pointValue = getPointValue();
mapdta.put("ZFS", String.valueOf(pointValue.get("ZFS")));
mapdta.put("ZFSLJ", String.valueOf(pointValue.get("ZFSLJ")));
try { try {
System.out.println(JSON.toJSONString(mapdta)); System.out.println(JSON.toJSONString(mapdta));
...@@ -634,7 +707,7 @@ public class LargeScreenImpl { ...@@ -634,7 +707,7 @@ public class LargeScreenImpl {
} }
//全国月发电量趋势 //全国月发电量趋势
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ?")
public Map<String, Object> gettimedateyfd() { public Map<String, Object> gettimedateyfd() {
......
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