|
|
@@ -44,7 +44,7 @@ public class MqttServiceImpl implements MqttService {
|
|
|
public void pubMqttData(String mqttStr) {
|
|
|
JSONObject jsonObject = new JSONObject(mqttStr);
|
|
|
Long deviceId = Long.valueOf((String) jsonObject.get("deviceId"));
|
|
|
- SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss");
|
|
|
+ SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Date date = new Date(System.currentTimeMillis());
|
|
|
jsonObject.put("created_time",formatter.format(date));
|
|
|
MqttObj mqttObj = new MqttObj();
|
|
|
@@ -57,10 +57,10 @@ public class MqttServiceImpl implements MqttService {
|
|
|
mqttConnect.createMqttClient(obj.getServerAddress(),obj.getUuid(),obj.getAccount(),obj.getPassword(),new Callback());
|
|
|
if(topicObj != null){
|
|
|
String topic = topicObj.get("name").toString().replace("#","");
|
|
|
- mqttConnect.pub(topic,mqttStr,Integer.valueOf((String) topicObj.get("qos")));
|
|
|
+ mqttConnect.pub(topic,jsonObject.toString(),Integer.valueOf((String) topicObj.get("qos")));
|
|
|
}else{
|
|
|
String topic = "sensor/modbustcp/"+deviceId;
|
|
|
- mqttConnect.pub(topic,mqttStr,0);
|
|
|
+ mqttConnect.pub(topic,jsonObject.toString(),0);
|
|
|
}
|
|
|
TblRecord tblRecord = new TblRecord();
|
|
|
tblRecord.setEquipmentId(deviceId);
|