wenhua.zhou 2 years ago
parent 3b57322ef5
commit c50afa36b0

@ -27,7 +27,7 @@ public class MqttServiceImpl {
try { try {
processOneTable(tableName); processOneTable(tableName);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); log.error("processOneTable exception:",e);
} }
} }
} }
@ -69,6 +69,7 @@ public class MqttServiceImpl {
String devIdSQL = sqlExecuting.replace("%%DEVID%%", String.valueOf(deviceID)); String devIdSQL = sqlExecuting.replace("%%DEVID%%", String.valueOf(deviceID));
String newSQL = devIdSQL.replace("%%KEYVALUE%%", "'" + time + "'"); String newSQL = devIdSQL.replace("%%KEYVALUE%%", "'" + time + "'");
List<Map<String, Object>> dataOfoneDeviceID = operationDBMapper.getData(newSQL); List<Map<String, Object>> dataOfoneDeviceID = operationDBMapper.getData(newSQL);
if(!dataOfoneDeviceID.isEmpty()){
String jsonStringData = FormatUtil.mqttFormatTransform(dataOfoneDeviceID, fieldMap); String jsonStringData = FormatUtil.mqttFormatTransform(dataOfoneDeviceID, fieldMap);
try { try {
if (mqttUtil.publish2MQTT(jsonStringData)) { if (mqttUtil.publish2MQTT(jsonStringData)) {
@ -86,6 +87,8 @@ public class MqttServiceImpl {
} }
} }
}
} }

@ -25,7 +25,7 @@ mqtt:
clientid: publish_client clientid: publish_client
subscribe: subscribe:
clientid: subscribe_client clientid: subscribe_client
broker: tcp://192.168.50.115:1883 broker: tcp://192.168.50.200:1883
topic: mqtt/test topic: mqtt/test
username: test username: test
password: AliOS%1688 password: AliOS%1688

Loading…
Cancel
Save