Commit b82139da authored by zhangsen's avatar zhangsen

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

parent d7f71bf4
...@@ -445,13 +445,10 @@ public class MonitorFanIdxController extends BaseController { ...@@ -445,13 +445,10 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模拟量列表消息") @ApiOperation(value = "模拟量列表消息")
@GetMapping("/getAnalogQuantityInfo") @GetMapping("/getAnalogQuantityInfo")
public ResponseModel getAnalogQuantityInfo() { public ResponseModel getAnalogQuantityInfo(@RequestParam(value = "stationId") String stationId, @RequestParam(value = "routeName")String routeName) {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>(); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper); String gatewayId = stationBasic.getBoosterGatewayId();
for (StationBasic stationBasic : stationBasics) { monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString(), routeName);
String gatewayId = stationBasic.getBoosterGatewayId();
monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString());
}
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -1063,70 +1063,63 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1063,70 +1063,63 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return resultsData; return resultsData;
} }
public void getAnalogQuantityInfo(String gatewayId, String stationId) { public void getAnalogQuantityInfo(String gatewayId, String stationId, String routeName) {
if (StringUtils.isNotEmpty(gatewayId)) { if (StringUtils.isNotEmpty(gatewayId)) {
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(gatewayId); Map<String, String> map = monitorFanIndicatorregionMapper.getMajorBoosterStationInfoBySort(gatewayId, routeName);
List<Map<String, String>> zbList = new ArrayList<>();
// 主变高压侧
Map<String, String> zbGYC = new HashMap<>();
for (Map<String, String> map : boosterStationInfo) {
String sql = String.format("SELECT equipmentIndexName, value, frontModule, unit, displayName FROM \"indicators_%s\" WHERE systemType = '%s' and frontModule =~/%s/ ", gatewayId, "模拟量", map.get("boosterName")); 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")) || "1主变低压侧".equals(map.get("boosterName"))) {
if ("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, "模拟量");
zbGYC = listData.stream().collect(Collectors.toMap(IndicatorsDto::getDisplayName, IndicatorsDto::getValue)); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
continue; // 主变高压侧
} Map<String, String> zbGYC = listData.stream().filter(t -> t.getFrontModule().contains("1主变高压侧")).collect(Collectors.toMap(IndicatorsDto::getDisplayName, IndicatorsDto::getValue));
if ("1主变低压侧".equals(map.get("boosterName"))) { List<Map<String, String>> zbList = new ArrayList<>();
listData.forEach(item -> {
listData.stream().filter(t -> t.getFrontModule().contains("1主变低压侧")).forEach(item -> {
HashMap<String, String> zbMap = new HashMap<>(); HashMap<String, String> zbMap = new HashMap<>();
zbMap.put("title", item.getDisplayName()); zbMap.put("title", item.getDisplayName());
zbMap.put("grade1", item.getValue()); zbMap.put("grade1", item.getValue());
zbMap.put("grade2", zbGYC.getOrDefault(item.getDisplayName(), "0.0"));
if (StringUtils.isNotEmpty(item.getUnit())) { if (StringUtils.isNotEmpty(item.getUnit())) {
zbMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit())); zbMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
} }
zbMap.put("titleYuanShi", item.getDisplayName());
zbList.add(zbMap); zbList.add(zbMap);
}); });
continue; IPage<Map<String, String>> zbResult = new Page<>();
} zbResult.setRecords(zbList);
ArrayList<Map<String, String>> resultList = new ArrayList<>(); zbResult.setCurrent(1);
listData.forEach(item -> { zbResult.setTotal(zbList.size());
HashMap<String, String> stringStringHashMap = new HashMap<>(); try {
stringStringHashMap.put("title", item.getDisplayName()); log.info("主变消息内容:{}", JSON.toJSONString(zbResult));
stringStringHashMap.put("value", item.getValue()); emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(zbResult).getBytes(), 2, false);
if (StringUtils.isNotEmpty(item.getUnit())) { } catch (MqttException e) {
stringStringHashMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit())); 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<>(); IPage<Map<String, String>> result = new Page<>();
result.setRecords(resultList); result.setRecords(resultList);
result.setCurrent(1); result.setCurrent(1);
result.setTotal(resultList.size()); result.setTotal(resultList.size());
try { try {
log.info("消息内容:{}", JSON.toJSONString(result)); log.info("消息内容:{}", JSON.toJSONString(result));
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, map.get("value"), "mnl"), JSON.toJSONString(result).getBytes(),2,false); emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(result).getBytes(),2,false);
} catch (MqttException e) { } catch (MqttException e) {
log.info("消息发送失败"); log.info("消息发送失败");
e.printStackTrace(); 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();
} }
}
} }
} }
......
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