Commit fc27a9b4 authored by 朱晨阳's avatar 朱晨阳

Merge remote-tracking branch 'origin/developer' into developer

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