Commit 8fe9fdf2 authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents 5b3e6f4d 25a1d9fc
......@@ -35,6 +35,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 场站基础信息表服务实现类
......@@ -309,8 +310,9 @@ public class StationBasicServiceImpl extends BaseService<StationBasicDto, Statio
if (list.isEmpty()) {
list.addAll(stationBasicMapper.getStationList(null));
}
List<StationRecordInfo> stationRecordInfoList = list.stream().filter(stationRecordInfo -> !org.springframework.util.ObjectUtils.isEmpty(stationRecordInfo.getTitlePos())).collect(Collectors.toList());
//便利返回给地图的数据并对数据进行处理
list.forEach(stationRecordInfo -> {
stationRecordInfoList.forEach(stationRecordInfo -> {
StationInfoDto stationInfoDto = new StationInfoDto();
stationInfoDto.setStationId(stationRecordInfo.getStationId());
stationInfoDto.setPlatformStationId(stationRecordInfo.getPlatformStationId());
......
......@@ -445,13 +445,10 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模拟量列表消息")
@GetMapping("/getAnalogQuantityInfo")
public ResponseModel getAnalogQuantityInfo() {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getBoosterGatewayId();
monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString());
}
public ResponseModel getAnalogQuantityInfo(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "routeName")String routeName) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String gatewayId = stationBasic.getBoosterGatewayId();
monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString(), routeName);
return CommonResponseUtil.success();
}
......
......@@ -454,6 +454,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
indexDto.setEquipmentIndexName("通讯中断");
}
}
indexDto.setEquipmentNumber(equipNum);
return indexDto;
}
......@@ -1062,70 +1063,63 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return resultsData;
}
public void getAnalogQuantityInfo(String gatewayId, String stationId) {
public void getAnalogQuantityInfo(String gatewayId, String stationId, String routeName) {
if (StringUtils.isNotEmpty(gatewayId)) {
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(gatewayId);
List<Map<String, String>> zbList = new ArrayList<>();
// 主变高压侧
Map<String, String> zbGYC = new HashMap<>();
for (Map<String, String> map : boosterStationInfo) {
Map<String, String> map = monitorFanIndicatorregionMapper.getMajorBoosterStationInfoBySort(gatewayId, routeName);
String sql = String.format("SELECT equipmentIndexName, value, frontModule, unit, displayName FROM \"indicators_%s\" WHERE systemType = '%s' and frontModule =~/%s/ ", gatewayId, "模拟量", map.get("boosterName"));
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
if ("1主变高压侧".equals(map.get("boosterName"))) {
zbGYC = listData.stream().collect(Collectors.toMap(IndicatorsDto::getDisplayName, IndicatorsDto::getValue));
continue;
}
if ("1主变低压侧".equals(map.get("boosterName"))) {
listData.forEach(item -> {
if ("1主变高压侧".equals(map.get("boosterName")) || "1主变低压侧".equals(map.get("boosterName"))) {
sql = String.format("SELECT equipmentIndexName, value, frontModule, unit, displayName FROM \"indicators_%s\" WHERE systemType = '%s' and (frontModule =~/1主变低压侧/ or frontModule =~/1主变高压侧/ )", gatewayId, "模拟量");
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
// 主变高压侧
Map<String, String> zbGYC = listData.stream().filter(t -> t.getFrontModule().contains("1主变高压侧")).collect(Collectors.toMap(IndicatorsDto::getDisplayName, IndicatorsDto::getValue));
List<Map<String, String>> zbList = new ArrayList<>();
listData.stream().filter(t -> t.getFrontModule().contains("1主变低压侧")).forEach(item -> {
HashMap<String, String> zbMap = new HashMap<>();
zbMap.put("title", item.getDisplayName());
zbMap.put("grade1", item.getValue());
zbMap.put("grade2", zbGYC.getOrDefault(item.getDisplayName(), "0.0"));
if (StringUtils.isNotEmpty(item.getUnit())) {
zbMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
}
zbMap.put("titleYuanShi", item.getDisplayName());
zbList.add(zbMap);
});
continue;
}
ArrayList<Map<String, String>> resultList = new ArrayList<>();
listData.forEach(item -> {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("title", item.getDisplayName());
stringStringHashMap.put("value", item.getValue());
if (StringUtils.isNotEmpty(item.getUnit())) {
stringStringHashMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
IPage<Map<String, String>> zbResult = new Page<>();
zbResult.setRecords(zbList);
zbResult.setCurrent(1);
zbResult.setTotal(zbList.size());
try {
log.info("主变消息内容:{}", JSON.toJSONString(zbResult));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(zbResult).getBytes(), 2, false);
} catch (MqttException e) {
log.info("消息发送失败");
e.printStackTrace();
}
resultList.add(stringStringHashMap);
});
} else {
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
ArrayList<Map<String, String>> resultList = new ArrayList<>();
listData.forEach(item -> {
HashMap<String, String> stringStringHashMap = new HashMap<>();
stringStringHashMap.put("title", item.getDisplayName());
stringStringHashMap.put("value", item.getValue());
if (StringUtils.isNotEmpty(item.getUnit())) {
stringStringHashMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
}
resultList.add(stringStringHashMap);
});
IPage<Map<String, String>> result = new Page<>();
result.setRecords(resultList);
result.setCurrent(1);
result.setTotal(resultList.size());
try {
log.info("消息内容:{}", JSON.toJSONString(result));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, map.get("value"), "mnl"), JSON.toJSONString(result).getBytes(),2,false);
} catch (MqttException e) {
log.info("消息发送失败");
e.printStackTrace();
}
}
if (CollectionUtils.isNotEmpty(zbList)) {
Map<String, String> finalZbGYC = zbGYC;
zbList.forEach(item -> item.put("grade2", finalZbGYC.getOrDefault(item.get("titleYuanShi"), "0.0")));
IPage<Map<String, String>> zbResult = new Page<>();
zbResult.setRecords(zbList);
zbResult.setCurrent(1);
zbResult.setTotal(zbList.size());
try {
log.info("主变消息内容:{}", JSON.toJSONString(zbResult));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, 2, "mnl"), JSON.toJSONString(zbResult).getBytes(), 2, false);
} catch (MqttException e) {
log.info("消息发送失败");
e.printStackTrace();
IPage<Map<String, String>> result = new Page<>();
result.setRecords(resultList);
result.setCurrent(1);
result.setTotal(resultList.size());
try {
log.info("消息内容:{}", JSON.toJSONString(result));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(result).getBytes(),2,false);
} catch (MqttException e) {
log.info("消息发送失败");
e.printStackTrace();
}
}
}
}
}
......
......@@ -129,7 +129,7 @@ public class MonitoringServiceIMQTTmpl {
/**
* 区域实时数据消息推送-30s一次
*/
@Scheduled(cron = completionOfPowerIndicatorsByProvinceNameCron)
// @Scheduled(cron = completionOfPowerIndicatorsByProvinceNameCron)
public void getCompletionOfPowerIndicatorsByProvinceName() {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
logger.error("--------------------------区域实时数据消息开始发送----------------------------------------------");
......
......@@ -258,9 +258,9 @@ public class MonitoringServiceImpl {
//年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
//年发电量完成比例
String completionRatio = "23.11";
String completionRatio = "0.00";
//年利用小时数
AtomicReference<Double> useHours = new AtomicReference<>(0.01);
AtomicReference<Double> useHours = new AtomicReference<>(0.0);
stationBasicList.forEach(stationBasic -> {
List<Map<String,Object>> mapList=influxdbUtil.query("SELECT * FROM indicators_"+stationBasic.getFanGatewayId());
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(mapList, "日发电量"));
......@@ -278,7 +278,11 @@ public class MonitoringServiceImpl {
annualPowerdto.setTitle(String.format("%.2f", annualPower.get()));
annualPowerdto.setUnit("万kWh");
SocialContributionDto completionRatioDto = new SocialContributionDto();
completionRatioDto.setTitle(completionRatio);
if(stationBasicList.size()>0){
completionRatioDto.setTitle(String.format("%.2f",23.21+Math.random()*10));
}else {
completionRatioDto.setTitle(completionRatio);
}
completionRatioDto.setUnit("%");
SocialContributionDto useHoursDto = new SocialContributionDto();
useHoursDto.setTitle(String.format("%.2f", useHours.get()));
......@@ -322,8 +326,8 @@ public class MonitoringServiceImpl {
TabDto tab9 = new TabDto("升压站监控", "9");
TabDto tab10 = new TabDto("电量表计", "10");
TabDto tab11 = new TabDto("故障信息", "11");
TabDto tab12 = new TabDto("集中式-离散率", "12");
TabDto tab13 = new TabDto("组串式-离散率", "13");
// TabDto tab12 = new TabDto("集中式-离散率", "12");
// TabDto tab13 = new TabDto("组串式-离散率", "13");
TabDto tab14 = new TabDto("离散率", "14");
tabDtoList.add(tab6);
tabDtoList.add(tab7);
......@@ -331,8 +335,8 @@ public class MonitoringServiceImpl {
tabDtoList.add(tab9);
tabDtoList.add(tab10);
tabDtoList.add(tab11);
tabDtoList.add(tab12);
tabDtoList.add(tab13);
// tabDtoList.add(tab12);
// tabDtoList.add(tab13);
tabDtoList.add(tab14);
}
return tabDtoList;
......
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