Commit e85d853a authored by wujiang's avatar wujiang

修改大屏消息

parent 76edcf40
...@@ -38,6 +38,8 @@ import java.util.*; ...@@ -38,6 +38,8 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -72,16 +74,17 @@ public class LargeScreenImpl { ...@@ -72,16 +74,17 @@ public class LargeScreenImpl {
* 全国 * 全国
*/ */
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ?")
@PostConstruct
public Map<String, Double> getqg() { public Map<String, Double> getqg() {
Map<String, Double> mapdta = new HashMap<>(); Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d); mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d); mapdta.put("ZFS", 0d);
mapdta.put("ZFSLJ", 0d); mapdta.put("ZFSLJ", 0d);
mapdta.put("RSD", 0d); // mapdta.put("RSD", 0d);
mapdta.put("YFD", 0d); // mapdta.put("YFD", 0d);
mapdta.put("NFD", 0d); // mapdta.put("NFD", 0d);
mapdta.put("YJHWC", 0d); // mapdta.put("YJHWC", 0d);
mapdta.put("NJHWC", 0d); // mapdta.put("NJHWC", 0d);
//平均数 //平均数
List<String> value = new ArrayList<>(); List<String> value = new ArrayList<>();
value.add(SS); value.add(SS);
...@@ -113,37 +116,37 @@ public class LargeScreenImpl { ...@@ -113,37 +116,37 @@ public class LargeScreenImpl {
} }
} }
} }
//日发电量 // //日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0); // AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量 // //月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0); // AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量 // //年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0); // AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
for (StationCacheInfoDto stationCacheInfoDto : stationCacheInfoDtos) { // for (StationCacheInfoDto stationCacheInfoDto : stationCacheInfoDtos) {
//
if ("FDZ".equals(stationCacheInfoDto.getStationType())) { // if ("FDZ".equals(stationCacheInfoDto.getStationType())) {
Map<String, List<String>> queryCondtion = new HashMap<>(); // Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量")); // queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId())); // queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); // List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量"))); // dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量"))); // monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量"))); // annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else { // } else {
Map<String, List<String>> queryCondtion = new HashMap<>(); // Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator); // queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId())); // queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); // List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay))); // dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth))); // monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear))); // annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
} // }
//
} // }
//
mapdta.put("RSD", keepFourdecimalPlaces(dailyPower.get())); // mapdta.put("RSD", keepFourdecimalPlaces(dailyPower.get()));
mapdta.put("YFD", keepFourdecimalPlaces(monthlyPower.get())); // mapdta.put("YFD", keepFourdecimalPlaces(monthlyPower.get()));
mapdta.put("NFD", keepFourdecimalPlaces(annualPower.get())); // mapdta.put("NFD", keepFourdecimalPlaces(annualPower.get()));
//总和 //总和
// value.clear(); // value.clear();
...@@ -172,28 +175,28 @@ public class LargeScreenImpl { ...@@ -172,28 +175,28 @@ public class LargeScreenImpl {
// } // }
// } // }
// } // }
//计算月完成百分比 // //计算月完成百分比
//当前月份 获取 // //当前月份 获取
LocalDate currentDate = LocalDate.now(); // LocalDate currentDate = LocalDate.now();
int month = currentDate.getMonthValue(); // int month = currentDate.getMonthValue();
//
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>(); // QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select("ifnull(sum(value), 0) as sum_value"); // wrapper.select("ifnull(sum(value), 0) as sum_value");
wrapper.eq("monthly", month); // wrapper.eq("monthly", month);
List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper); // List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0; // Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0;
//计算年完成百分比 // //计算年完成百分比
Double ybfb = sumValue > 0 ? mapdta.get("YFD") / sumValue * 100 : 0; // Double ybfb = sumValue > 0 ? mapdta.get("YFD") / sumValue * 100 : 0;
ybfb = new BigDecimal(ybfb).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); // ybfb = new BigDecimal(ybfb).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
//
mapdta.put("YJHWC", ybfb); // mapdta.put("YJHWC", ybfb);
QueryWrapper<StationPlan> wrapper1 = new QueryWrapper<>(); // QueryWrapper<StationPlan> wrapper1 = new QueryWrapper<>();
wrapper1.select("ifnull(sum(value), 0) as sum_value"); // wrapper1.select("ifnull(sum(value), 0) as sum_value");
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper1); // List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper1);
Double sumValuen = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("sum_value") : 0; // Double sumValuen = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("sum_value") : 0;
Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValue * 100 : 0; // Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValue * 100 : 0;
ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); // ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
mapdta.put("NJHWC", ybfbn); // mapdta.put("NJHWC", ybfbn);
try { try {
emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(),0,true); emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(),0,true);
} catch (MqttException e) { } catch (MqttException e) {
......
...@@ -570,46 +570,45 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -570,46 +570,45 @@ public class MonitorServiceImpl implements MonitorService {
* *
* @return 返回一个包含各种指标数据的map,其中键为指标名称,值为指标数值。 * @return 返回一个包含各种指标数据的map,其中键为指标名称,值为指标数值。
*/ */
public Map<String, Double> getqg() { // public Map<String, Double> getqg() {
//
// 初始化存储数据的map,设置默认值为0 // // 初始化存储数据的map,设置默认值为0
Map<String, Double> mapdta = new HashMap<>(); // Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d); // mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d); // mapdta.put("ZFS", 0d);
mapdta.put("ZFSLJ", 0d); // mapdta.put("ZFSLJ", 0d);
mapdta.put("RSD", 0d); // mapdta.put("RSD", 0d);
mapdta.put("YFD", 0d); // mapdta.put("YFD", 0d);
mapdta.put("NFD", 0d); // mapdta.put("NFD", 0d);
mapdta.put("YJHWC", 0d); // mapdta.put("YJHWC", 0d);
mapdta.put("NJHWC", 0d); // mapdta.put("NJHWC", 0d);
// 获取核心数值数据 // // 获取核心数值数据
List<CoreValuesDto> coreValuesDtos = new ArrayList<>(); // List<CoreValuesDto> coreValuesDtos = new ArrayList<>();
coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null); // coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
// 构建请求URL并发起HTTP GET请求,获取相关数据 // // 构建请求URL并发起HTTP GET请求,获取相关数据
String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url; // String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url;
List<BuDunGenDto> buDunGenDtos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BuDunGenDto.class); // List<BuDunGenDto> buDunGenDtos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BuDunGenDto.class);
// 如果有获取到数据,则更新map中的相应数据 // // 如果有获取到数据,则更新map中的相应数据
if (buDunGenDtos.size() > 0) { // if (buDunGenDtos.size() > 0) {
BuDunGenDto buDunGenDto = buDunGenDtos.get(0); // BuDunGenDto buDunGenDto = buDunGenDtos.get(0);
mapdta.put("RSD", keepFourdecimalPlaces(buDunGenDto.getDay())); // mapdta.put("RSD", keepFourdecimalPlaces(buDunGenDto.getDay()));
mapdta.put("YFD", keepFourdecimalPlaces(buDunGenDto.getMonth())); // mapdta.put("YFD", keepFourdecimalPlaces(buDunGenDto.getMonth()));
mapdta.put("NFD", keepFourdecimalPlaces(buDunGenDto.getYear())); // mapdta.put("NFD", keepFourdecimalPlaces(buDunGenDto.getYear()));
mapdta.put("YJHWC", keepTwodecimalPlaces(buDunGenDto.getMonth_complete())); // mapdta.put("YJHWC", keepTwodecimalPlaces(buDunGenDto.getMonth_complete()));
mapdta.put("NJHWC", keepTwodecimalPlaces(buDunGenDto.getYear_complete())); // mapdta.put("NJHWC", keepTwodecimalPlaces(buDunGenDto.getYear_complete()));
} // }
// 更新map中剩余的数据项 // // 更新map中剩余的数据项
mapdta.put("SS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.WIND_SPEED_THIRTY_SECONDS))); // mapdta.put("SS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.WIND_SPEED_THIRTY_SECONDS)));
mapdta.put("ZFS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION))); // mapdta.put("ZFS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION)));
mapdta.put("ZFSLJ", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION_SUM))); // mapdta.put("ZFSLJ", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION_SUM)));
// 将数据发布到MQTT主题 // // 将数据发布到MQTT主题
try { // try {
emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(), 0, true); // emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(), 0, true);
} catch (MqttException e) { // } catch (MqttException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return mapdta; // return mapdta;
// }
}
@Scheduled(cron = "0/10 * * * * ?") @Scheduled(cron = "0/10 * * * * ?")
private void sendQYYXZBMqtt() { private void sendQYYXZBMqtt() {
......
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