Commit b82139da authored by zhangsen's avatar zhangsen

升压站弹窗页面 模拟量消息代码优化

parent d7f71bf4
......@@ -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();
}
......
......@@ -1063,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();
}
}
}
}
}
......
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