Commit 563155ee authored by zhangsen's avatar zhangsen

模拟量消息开发

parent 53375ff4
......@@ -95,7 +95,7 @@
`gateway_id` as gatewayId,
`booster_name` as text,
booster_name as boosterName,
<!-- `booster_code` as value,-->
`booster_code` as boosterCode,
`sort` as value
from booster_station_info
<where>
......
......@@ -19,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
import org.elasticsearch.index.Index;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -361,5 +362,18 @@ public class MonitorFanIdxController extends BaseController {
return ResponseHelper.buildResponse(resultsData);
}
@Scheduled(cron = "0/10 * * * * ? ")
@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.getFanGatewayId();
monitorFanIndicator.getAnalogQuantityInfo(gatewayId, stationBasic.getSequenceNbr().toString());
}
return CommonResponseUtil.success();
}
}
......@@ -26,6 +26,7 @@ public class IndicatorsDto {
private String distinct;
private String time;
private String displayName;
private String title;
public String getTime() {
......
......@@ -711,5 +711,28 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData;
}
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()));
}
});
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