Commit 5ba6c06d authored by caotao's avatar caotao

运行监盘-上下数据不同步问题修改处理

parent 556ddc02
...@@ -20,6 +20,7 @@ import org.slf4j.Logger; ...@@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
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.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
...@@ -169,7 +170,7 @@ public class MonitoringServiceImpl { ...@@ -169,7 +170,7 @@ public class MonitoringServiceImpl {
return regionNationWideDtoList; return regionNationWideDtoList;
} }
// @Scheduled(cron = "0/60 * * * * ? ")
public ResultsData getCompletionOfPowerIndicatorsByProvinceName(int current, int size, String provinceName) { public ResultsData getCompletionOfPowerIndicatorsByProvinceName(int current, int size, String provinceName) {
List<ColModel> colModels = new ArrayList<>(); List<ColModel> colModels = new ArrayList<>();
...@@ -190,6 +191,11 @@ public class MonitoringServiceImpl { ...@@ -190,6 +191,11 @@ public class MonitoringServiceImpl {
colModels.add(colModelAnnualPower); colModels.add(colModelAnnualPower);
List<StationCacheInfoDto> stationCacheInfoDtoList = commonServiceImpl.getListStationCacheInfoDto(); List<StationCacheInfoDto> stationCacheInfoDtoList = commonServiceImpl.getListStationCacheInfoDto();
List<StationCacheInfoDto> stationCacheInfoDtos = stationCacheInfoDtoList.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBelongProvince().equals(provinceName)).collect(Collectors.toList()); List<StationCacheInfoDto> stationCacheInfoDtos = stationCacheInfoDtoList.stream().filter(stationCacheInfoDto -> stationCacheInfoDto.getBelongProvince().equals(provinceName)).collect(Collectors.toList());
if(ObjectUtils.isEmpty(stationCacheInfoDtos)){
DataGridMock dataGridMock = new DataGridMock(current, 0, false, 1, null);
ResultsData resultsData = new ResultsData(dataGridMock, colModels);
return resultsData;
}
//日发电量 //日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0); AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量 //月发电量
...@@ -199,12 +205,14 @@ public class MonitoringServiceImpl { ...@@ -199,12 +205,14 @@ public class MonitoringServiceImpl {
//年发电量完成比例 //年发电量完成比例
String completionRatio = "0.00"; String completionRatio = "0.00";
//年利用小时数 //年利用小时数
List<StationPlan> fdzPlans = new ArrayList<>();
int year = Calendar.getInstance().get(Calendar.YEAR); int year = Calendar.getInstance().get(Calendar.YEAR);
List<String> fdz = stationCacheInfoDtos.stream().map(StationCacheInfoDto::getStationId).collect(Collectors.toList()); List<String> fdz = stationCacheInfoDtos.stream().map(StationCacheInfoDto::getStationId).collect(Collectors.toList());
LambdaQueryWrapper<StationPlan> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationPlan> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StationPlan::getYear, String.valueOf(year)); queryWrapper.eq(StationPlan::getYear, String.valueOf(year));
queryWrapper.in(StationPlan::getStationBasicId, fdz); queryWrapper.in(StationPlan::getStationBasicId, fdz);
List<StationPlan> fdzPlans = stationPlanMapper.selectList(queryWrapper);
fdzPlans = stationPlanMapper.selectList(queryWrapper);
double value = fdzPlans.stream().mapToDouble(StationPlan::getValue).sum(); double value = fdzPlans.stream().mapToDouble(StationPlan::getValue).sum();
AtomicReference<Double> useHours = new AtomicReference<>(0.0); AtomicReference<Double> useHours = new AtomicReference<>(0.0);
...@@ -298,18 +306,20 @@ public class MonitoringServiceImpl { ...@@ -298,18 +306,20 @@ public class MonitoringServiceImpl {
socialContributionDtoPage.setRecords(socialContributionDtoList); socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100); socialContributionDtoPage.setTotal(100);
socialContributionDtoPage.setCurrent(1); socialContributionDtoPage.setCurrent(1);
Integer allsize = completionOfPowerIndicatorsDtoList.size();
DataGridMock dataGridMock = new DataGridMock(current, allsize, false, allsize / size + 1, completionOfPowerIndicatorsDtoList);
ResultsData resultsData = new ResultsData(dataGridMock, colModels);
try { try {
emqKeeper.getMqttClient().publish("completion_of_powerindicator_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true); emqKeeper.getMqttClient().publish(provinceName + "_completion_of_powerindicator_list_topic", JSON.toJSON(resultsData).toString().getBytes("UTF-8"), 1, true);
emqKeeper.getMqttClient().publish(provinceName + "_completion_of_powerindicator_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true);
logger.info("-----------------发送区域实时生产数据消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage)); logger.info("-----------------发送区域实时生产数据消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage));
} catch (Exception exception) { } catch (Exception exception) {
logger.error("-----------------发送区域实时生产数据消息=================== 失败!"); logger.error("-----------------发送区域实时生产数据消息=================== 失败!");
} }
Integer allsize = completionOfPowerIndicatorsDtoList.size();
DataGridMock dataGridMock = new DataGridMock(current, allsize, false, allsize / size + 1, completionOfPowerIndicatorsDtoList);
ResultsData resultsData = new ResultsData(dataGridMock, colModels);
return resultsData; return resultsData;
} }
public void getCompletionOfPowerIndicatorsByCurrentData(List<StationCacheInfoDto> stationBasicList, String provinceName) { public void getCompletionOfPowerIndicatorsByCurrentData(List<StationCacheInfoDto> stationBasicList, String provinceName) {
String provinceNameTopic = ""; String provinceNameTopic = "";
if (provinceName.contains("黑龙江") || provinceName.contains("内蒙古")) { if (provinceName.contains("黑龙江") || provinceName.contains("内蒙古")) {
...@@ -320,7 +330,7 @@ public class MonitoringServiceImpl { ...@@ -320,7 +330,7 @@ public class MonitoringServiceImpl {
HashMap<String, String> stringHashMap = new HashMap<>(); HashMap<String, String> stringHashMap = new HashMap<>();
stringHashMap.put("title", provinceNameTopic + "区域"); stringHashMap.put("title", provinceNameTopic + "区域");
try { try {
emqKeeper.getMqttClient().publish("proviceName_topic", JSON.toJSON(stringHashMap).toString().getBytes("UTF-8"), 1, true); emqKeeper.getMqttClient().publish(provinceName + "_proviceName_topic", JSON.toJSON(stringHashMap).toString().getBytes("UTF-8"), 1, true);
logger.info("----------------------------------推送省份名称消息成功败--------------------------------"); logger.info("----------------------------------推送省份名称消息成功败--------------------------------");
} catch (Exception e) { } catch (Exception e) {
logger.info("----------------------------------推送省份名称消息失败--------------------------------"); logger.info("----------------------------------推送省份名称消息失败--------------------------------");
...@@ -529,7 +539,6 @@ public class MonitoringServiceImpl { ...@@ -529,7 +539,6 @@ public class MonitoringServiceImpl {
homeMapStationInfoDto.setCurrentPower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(esEquipmentsList, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"))); homeMapStationInfoDto.setCurrentPower(String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(esEquipmentsList, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值")));
} else { } else {
// 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("有功功率"));
...@@ -883,14 +892,13 @@ public class MonitoringServiceImpl { ...@@ -883,14 +892,13 @@ public class MonitoringServiceImpl {
shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器"); shouldQueryCondtion.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, shouldQueryCondtion); List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, shouldQueryCondtion);
// total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay; // total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay;
if(finalIndicator.equals("日发电量")){ if (finalIndicator.equals("日发电量")) {
total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay; total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay;
}else{ } else {
total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor ; total = commonServiceImpl.getSumByEquipmentIndxName(result, finalIndicator) * CommonConstans.pvGenPoweActor;
} }
} else { } else {
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator)); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(finalIndicator));
...@@ -1310,13 +1318,13 @@ public class MonitoringServiceImpl { ...@@ -1310,13 +1318,13 @@ public class MonitoringServiceImpl {
} }
stationBasicListAll.forEach(stationBasic -> { stationBasicListAll.forEach(stationBasic -> {
if(stationBasic.getStationType().equals("FDZ")){ if (stationBasic.getStationType().equals("FDZ")) {
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId())); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
total.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(esEquipmentsList, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值")); total.updateAndGet(v -> v + commonServiceImpl.getSumByEquipmentIndxName(esEquipmentsList, "220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
}else { } else {
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId())); queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P")); queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P"));
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class); List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
......
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