Commit 41516a31 authored by wujiang's avatar wujiang

修改大屏卡片问题

parent 36938861
package com.yeejoin.amos.boot.module.jxiop.biz.initdata; package com.yeejoin.amos.boot.module.jxiop.biz.initdata;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion; import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region; import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
...@@ -12,16 +24,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto; ...@@ -12,16 +24,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component @Component
public class StationCacheDataInit implements CommandLineRunner { public class StationCacheDataInit implements CommandLineRunner {
...@@ -42,7 +44,7 @@ public class StationCacheDataInit implements CommandLineRunner { ...@@ -42,7 +44,7 @@ public class StationCacheDataInit implements CommandLineRunner {
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
redisTemplate.delete("station_info_cache_bigscreen"); redisTemplate.delete("station_info_cache_bigscreen");
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>(); List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("\"LEVEL\"", 1)); List<Region> regionList = regionMapper.selectList(new LambdaQueryWrapper<Region>().eq(Region::getLevel_, 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name")); List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id")); List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> { stationBasicList.forEach(stationBasic -> {
......
...@@ -131,29 +131,26 @@ public class LargeScreenImpl { ...@@ -131,29 +131,26 @@ public class LargeScreenImpl {
// } // }
// } // }
//改为部盾接口 // 改为部盾接口
String requestUrl = Constants.BASE_URL + "?" + Constants.get_quota_info; String requestUrl = Constants.BASE_URL + "?" + Constants.get_quota_info;
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter); String formattedDate = currentDate.format(formatter);
JSONObject data = httpRequestUtil.getResPonse(requestUrl+"&reporting_data="+formattedDate, Constants.REQUEST_GET, "", JSONObject data = httpRequestUtil.getResPonse(requestUrl + "&reporting_data=" + formattedDate,
Constants.resovleRule_data); Constants.REQUEST_GET, "", Constants.resovleRule_data);
if(data!=null) if (data != null) {
{ // 部盾每天十二点才填报,如果十二点前没有数据则获取前一天的数据
//部盾每天十二点才填报,如果十二点前没有数据则获取前一天的数据 if (data.getDouble("sum_irradiance") != null && data.getDouble("sum_irradiance") == 0) {
if(data.getDouble("sum_irradiance")==0) // 计算昨天日期
{ LocalDate yesterday = currentDate.minusDays(1);
// 计算昨天日期 formattedDate = yesterday.format(formatter);
LocalDate yesterday = currentDate.minusDays(1); data = httpRequestUtil.getResPonse(requestUrl + "&reporting_data=" + formattedDate,
formattedDate = yesterday.format(formatter); Constants.REQUEST_GET, "", Constants.resovleRule_data);
data = httpRequestUtil.getResPonse(requestUrl+"&reporting_data="+formattedDate, 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"));
} }
// //日发电量 // //日发电量
// AtomicReference<Double> dailyPower = new AtomicReference<>(0.0); // AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
...@@ -246,7 +243,7 @@ public class LargeScreenImpl { ...@@ -246,7 +243,7 @@ public class LargeScreenImpl {
} }
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ?")
@PostConstruct //@PostConstruct
private void sendQYYXZBMqtt() { private void sendQYYXZBMqtt() {
List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto(); List<StationCacheInfoDto> listStationCacheInfoDto = commonServiceImpl.getListStationCacheInfoDto();
Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream() Map<String, List<StationCacheInfoDto>> belongAreaList = listStationCacheInfoDto.stream()
...@@ -261,16 +258,16 @@ public class LargeScreenImpl { ...@@ -261,16 +258,16 @@ public class LargeScreenImpl {
/** /**
* 区域 * 区域
**/ **/
public Map<String, Double> getqy(List<StationCacheInfoDto> gatewayId, String s) { public Map<String, String> getqy(List<StationCacheInfoDto> gatewayId, String s) {
Map<String, Double> mapdta = new HashMap<>(); Map<String, String> mapdta = new HashMap<>();
mapdta.put("SS", 0d); mapdta.put("SS", "0");
mapdta.put("ZFS", 0d); mapdta.put("ZFS", "0");
mapdta.put("ZFSLJ", 0d); mapdta.put("ZFSLJ", "0");
mapdta.put("RSD", 0d); mapdta.put("RSD", "0");
mapdta.put("YFD", 0d); mapdta.put("YFD", "0");
mapdta.put("NFD", 0d); mapdta.put("NFD", "0");
mapdta.put("YJHWC", 0d); mapdta.put("YJHWC", "0");
mapdta.put("NJHWC", 0d); mapdta.put("NJHWC", "0");
// // 平均数 // // 平均数
// List<String> value = new ArrayList<>(); // List<String> value = new ArrayList<>();
// List<String> ids = new ArrayList<>(); // List<String> ids = new ArrayList<>();
...@@ -404,35 +401,46 @@ public class LargeScreenImpl { ...@@ -404,35 +401,46 @@ public class LargeScreenImpl {
// Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValuen * 100 : 0; // Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValuen * 100 : 0;
// ybfbn = new BigDecimal(ybfbn).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); // ybfbn = new BigDecimal(ybfbn).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// mapdta.put("NJHWC", ybfbn); // mapdta.put("NJHWC", ybfbn);
//改为部盾接口 // 改为部盾接口
String requestUrl = Constants.BASE_URL + "?" + Constants.get_quota_info; String requestUrl = Constants.BASE_URL + "?" + Constants.get_quota_info;
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = currentDate.format(formatter); String formattedDate = currentDate.format(formatter);
JSONObject data = httpRequestUtil.getResPonse(requestUrl+"&reporting_data="+formattedDate, Constants.REQUEST_GET, "", JSONObject data = httpRequestUtil.getResPonse(requestUrl + "&reporting_data=" + formattedDate + "&code=" + s,
Constants.resovleRule_data); Constants.REQUEST_GET, "", Constants.resovleRule_data);
mapdta.put("Day", data.getDouble("day_generating_capacity")); DecimalFormat df = new DecimalFormat("#.0000");
mapdta.put("Moon", data.getDouble("month_generating_capacity")); if (data.getDouble("day_generating_capacity") != null) {
mapdta.put("Year", data.getDouble("year_generating_capacity")); mapdta.put("Day", df.format(Double.valueOf(data.getDouble("day_generating_capacity"))));
mapdta.put("YJHWC", Double.valueOf(data.getString("month_quota_rate").replace("%", ""))); mapdta.put("RSD", df.format(Double.valueOf(data.getDouble("day_generating_capacity"))));
mapdta.put("NJHWC", Double.valueOf(data.getString("year_quota_rate").replace("%", ""))); }
if (data.getDouble("month_generating_capacity") != null) {
//部盾每天十二点才填报,如果十二点前没有数据则获取前一天的数据 mapdta.put("Moon", df.format(Double.valueOf(data.getDouble("month_generating_capacity"))));
if(data.getDouble("sum_irradiance")==0) mapdta.put("YFD", df.format(Double.valueOf(data.getDouble("day_generating_capacity"))));
{ }
// 计算昨天日期 if (data.getDouble("year_generating_capacity") != null) {
LocalDate yesterday = currentDate.minusDays(1); mapdta.put("Year", df.format(Double.valueOf(data.getDouble("year_generating_capacity"))));
formattedDate = yesterday.format(formatter); mapdta.put("NFD", df.format(Double.valueOf(data.getDouble("day_generating_capacity"))));
data = httpRequestUtil.getResPonse(requestUrl+"&reporting_data="+formattedDate, Constants.REQUEST_GET, "", }
Constants.resovleRule_data); if (data.getString("month_quota_rate") != null) {
} mapdta.put("YJHWC", data.getString("month_quota_rate").replace("%", ""));
mapdta.put("SS", data.getDouble("average_wind_speed")); }
mapdta.put("ZFS", data.getDouble("avg_irradiance")); if (data.getString("year_quota_rate") != null) {
mapdta.put("ZFSLJ", data.getDouble("sum_irradiance")); mapdta.put("NJHWC", data.getString("year_quota_rate").replace("%", ""));
}
// 部盾每天十二点才填报,如果十二点前没有数据则获取前一天的数据
if (data.getDouble("sum_irradiance") != null && data.getDouble("sum_irradiance") == 0) {
// 计算昨天日期
LocalDate yesterday = currentDate.minusDays(1);
formattedDate = yesterday.format(formatter);
data = httpRequestUtil.getResPonse(requestUrl + "&reporting_data=" + formattedDate, Constants.REQUEST_GET,
"", Constants.resovleRule_data);
}
mapdta.put("SS", data.getString("average_wind_speed"));
mapdta.put("ZFS", data.getString("avg_irradiance"));
mapdta.put("ZFSLJ", data.getString("sum_irradiance"));
try { try {
System.out.println(JSON.toJSONString(mapdta)); System.out.println(JSON.toJSONString(mapdta));
emqKeeper.getMqttClient().publish("qyyxzb/" + s, JSON.toJSONString(mapdta).getBytes(), 1, true); emqKeeper.getMqttClient().publish("qyyxzb/" + s, JSON.toJSONString(mapdta).getBytes(), 1, true);
......
...@@ -28,6 +28,7 @@ import org.springframework.util.ObjectUtils; ...@@ -28,6 +28,7 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -1112,11 +1113,23 @@ public class MonitoringServiceImpl { ...@@ -1112,11 +1113,23 @@ public class MonitoringServiceImpl {
String formattedDate = currentDate.format(formatter); String formattedDate = currentDate.format(formatter);
JSONObject data = httpRequestUtil.getResPonse(requestUrl+"&reporting_data="+formattedDate, Constants.REQUEST_GET, "", JSONObject data = httpRequestUtil.getResPonse(requestUrl+"&reporting_data="+formattedDate, Constants.REQUEST_GET, "",
Constants.resovleRule_data); Constants.resovleRule_data);
resultMap.put("Day", data.getString("day_generating_capacity")); DecimalFormat df = new DecimalFormat("#.0000");
resultMap.put("Moon", data.getString("month_generating_capacity")); if (data.getDouble("day_generating_capacity") != null) {
resultMap.put("Year", data.getString("year_generating_capacity")); resultMap.put("Day", df.format(Double.valueOf(data.getDouble("day_generating_capacity"))));
resultMap.put("YJHWC", data.getString("month_quota_rate").replace("%", "")); }
resultMap.put("NJHWC", data.getString("year_quota_rate").replace("%", "")); if (data.getDouble("month_generating_capacity") != null) {
resultMap.put("Moon", df.format(Double.valueOf(data.getDouble("month_generating_capacity"))));
}
if (data.getDouble("year_generating_capacity") != null) {
resultMap.put("Year", df.format(Double.valueOf(data.getDouble("year_generating_capacity"))));
}
if (data.getString("month_quota_rate") != null) {
resultMap.put("YJHWC", data.getString("month_quota_rate").replace("%", ""));
}
if (data.getString("year_quota_rate") != null) {
resultMap.put("NJHWC", data.getString("year_quota_rate").replace("%", ""));
}
try { try {
emqKeeper.getMqttClient().publish("bigscreen_zjrl_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1, emqKeeper.getMqttClient().publish("bigscreen_zjrl_topic", JSON.toJSON(page).toString().getBytes("UTF-8"), 1,
true); true);
......
...@@ -148,4 +148,5 @@ pictureUrl=upload/jxiop/syz/ ...@@ -148,4 +148,5 @@ pictureUrl=upload/jxiop/syz/
# Ԥ # Ԥ
idx.predict.serviceUrl=http://10.20.1.157:8095/jxdj/predict-data idx.predict.serviceUrl=http://10.20.1.157:8095/jxdj/predict-data
forecast.url= forecast.url=
\ No newline at end of file logic=
\ No newline at end of file
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