Commit 8463cf1c authored by chenzhao's avatar chenzhao

开关优化为消息接口

parent 97659aed
...@@ -424,15 +424,20 @@ public class MonitorFanIdxController extends BaseController { ...@@ -424,15 +424,20 @@ public class MonitorFanIdxController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "开关图片API") @ApiOperation(value = "开关图片API/消息")
@GetMapping("/switchUrl") @GetMapping("/switchUrl")
public ResponseModel<Map<String,Object>> getElectricQuantityList( public ResponseModel<Map<String,Object>> getElectricQuantityList(
@RequestParam(value = "stationId") String stationId, @RequestParam(value = "stationId") String stationId
@RequestParam(value = "equipName") String equipName
) { ) {
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
for (StationBasic stationBasic : stationBasics) {
String gatewayId = stationBasic.getBoosterGatewayId(); String gatewayId = stationBasic.getBoosterGatewayId();
return ResponseHelper.buildResponse(monitorFanIndicatorImpl.getSwitchUrl(gatewayId,equipName)); monitorFanIndicatorImpl.getSwitchUrlAll(gatewayId);
}
return CommonResponseUtil.success();
} }
} }
...@@ -974,8 +974,23 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -974,8 +974,23 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
} }
public void getSwitchUrlAll(String gatewayId){
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and displayName =~/合位$/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
Set<String> names = new HashSet<>();
for (IndicatorsDto listDatum : listData) {
names.add(listDatum.getFrontModule());
}
for (String name : names) {
getSwitchUrl(gatewayId,name);
}
}
public Map<String,Object> getSwitchUrl(String gatewayId,String equipName){
public void getSwitchUrl(String gatewayId,String equipName){
String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and frontModule =~ /"+equipName+"/ and displayName =~/合位$/"; String sql = "SELECT * FROM indicators_"+gatewayId+" WHERE systemType = '开关' and frontModule =~ /"+equipName+"/ and displayName =~/合位$/";
List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> listData = influxDButils.getListData(sql, IndicatorsDto.class);
Map<String, Object> photoUrls = new HashMap<>(); Map<String, Object> photoUrls = new HashMap<>();
...@@ -989,7 +1004,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -989,7 +1004,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
photoUrls.put(listDatum.getDisplayName().split("_")[0]+"url",url); photoUrls.put(listDatum.getDisplayName().split("_")[0]+"url",url);
} }
return photoUrls ;
try {
emqKeeper.getMqttClient().publish(gatewayId+"/switch",JSON.toJSONString(photoUrls).getBytes(),0,false);
} catch (MqttException e) {
e.printStackTrace();
log.error("开关消息发送失败");
}
} }
} }
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