Commit ac4f08c5 authored by zhangsen's avatar zhangsen

模拟量消息开发 xiugai

parent 83e0cd3e
......@@ -332,7 +332,7 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取升压站信息 通过排序等")
@GetMapping("/getBoosterStationInfo")
public ResponseModel<List<Map<String, String>>> getBoosterStationInfo(@RequestParam(value = "stationId", required = false) String stationId) {
......@@ -362,7 +362,7 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(resultsData);
}
@Scheduled(cron = "0/10 * * * * ? ")
// @Scheduled(cron = "0/10 * * * * ? ")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "模拟量列表消息")
@GetMapping("/getAnalogQuantityInfo")
......@@ -370,7 +370,7 @@ public class MonitorFanIdxController extends BaseController {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getFanGatewayId();
String gatewayId = stationBasic.getBoosterGatewayId();
monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString());
}
return CommonResponseUtil.success();
......
......@@ -671,7 +671,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public List<Map<String, String>> getBoosterStationInfo(String stationId) {
StationBasic stationBasic = getOneByStationNumber(stationId);
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getFanGatewayId());
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(stationBasic.getBoosterGatewayId());
return boosterStationInfo;
}
......@@ -713,24 +713,33 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public void getAnalogQuantityInfo(String gatewayId, String stationId) {
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(gatewayId);
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"));
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
listData.forEach(item -> {
if (StringUtils.isNotEmpty(item.getUnit())) {
item.setDisplayName(String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
if (StringUtils.isNotEmpty(gatewayId)) {
List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo(gatewayId);
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"));
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("boosterCode"), "mnl"), JSON.toJSONString(result).getBytes(),0,false);
} catch (MqttException e) {
log.info("消息发送失败");
e.printStackTrace();
}
});
IPage<IndicatorsDto> result = new Page<>();
result.setRecords(listData);
result.setCurrent(1);
result.setTotal(listData.size());
try {
emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, map.get("boosterCode"), "mnl"), JSON.toJSONString(result).getBytes(),0,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