|
|
|
@ -1,13 +1,10 @@
|
|
|
|
package com.rehome.mqttclienttemperature.service.impl;
|
|
|
|
package com.rehome.mqttclienttemperature.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.rehome.mqttclienttemperature.dao.TemperatureEspRepository;
|
|
|
|
import com.rehome.mqttclienttemperature.dao.TemperatureEspRepository;
|
|
|
|
import com.rehome.mqttclienttemperature.dao.TemperatureRepository;
|
|
|
|
|
|
|
|
import com.rehome.mqttclienttemperature.entity.Temperature;
|
|
|
|
|
|
|
|
import com.rehome.mqttclienttemperature.entity.TemperatureEsp;
|
|
|
|
import com.rehome.mqttclienttemperature.entity.TemperatureEsp;
|
|
|
|
import com.rehome.mqttclienttemperature.service.TemperatureEspService;
|
|
|
|
import com.rehome.mqttclienttemperature.service.TemperatureEspService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
@ -27,39 +24,37 @@ public class TemperatureEspServiceImpl implements TemperatureEspService {
|
|
|
|
SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
|
SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
|
SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
SimpleDateFormat sdfSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
SimpleDateFormat sdfSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
String nowDate = sdf.format(now);
|
|
|
|
String nowDate = sdf.format(now);
|
|
|
|
String nowHour = sdfHour.format(now);
|
|
|
|
String nowHour = sdfHour.format(now);
|
|
|
|
String dataMinute = sdfMinute.format(now);
|
|
|
|
String dataMinute = sdfMinute.format(now);
|
|
|
|
String dataSecond = sdfSecond.format(now);
|
|
|
|
sdfSecond.format(now);
|
|
|
|
TemperatureEsp temperatureEsp = new TemperatureEsp();
|
|
|
|
TemperatureEsp temperatureEsp = new TemperatureEsp();
|
|
|
|
temperatureEsp.setCreateDate(now);
|
|
|
|
temperatureEsp.setCreateDate(now);
|
|
|
|
temperatureEsp.setDataDate(nowDate);
|
|
|
|
temperatureEsp.setDataDate(nowDate);
|
|
|
|
temperatureEsp.setDataHour(nowHour);
|
|
|
|
temperatureEsp.setDataHour(nowHour);
|
|
|
|
temperatureEsp.setDataMinute(dataMinute);
|
|
|
|
temperatureEsp.setDataMinute(dataMinute);
|
|
|
|
temperatureEsp.setSource("http");
|
|
|
|
temperatureEsp.setSource("http");
|
|
|
|
|
|
|
|
|
|
|
|
String topic = "/device/esp8266/001";
|
|
|
|
String topic = "/device/esp8266/001";
|
|
|
|
if (topic != null) {
|
|
|
|
if (topic != null) {
|
|
|
|
temperatureEsp.setTopic(topic);
|
|
|
|
temperatureEsp.setTopic(topic);
|
|
|
|
if (topic.equals("/device/esp8266/001")) {
|
|
|
|
if (topic.equals("/device/esp8266/001")) {
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市高新区唐家湾镇南方软件园B2栋4楼珠海瑞洪智能系统工程有限公司");
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市高新区唐家湾镇南方软件园B2栋4楼珠海瑞洪智能系统工程有限公司");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (topic.equals("WifiSHT/7C87CE9F5CBF/SHT20")) {
|
|
|
|
if (topic.equals("WifiSHT/7C87CE9F5CBF/SHT20")) {
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市金湾区三灶镇百川路1号1栋1单元1508房");
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市金湾区三灶镇百川路1号1栋1单元1508房");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (topic.equals("WifiSHT/4CEBD686B6AA/SHT20")) {
|
|
|
|
if (topic.equals("WifiSHT/4CEBD686B6AA/SHT20")) {
|
|
|
|
temperatureEsp.setLocationDesc("广西壮族自治区崇左市天等县天等镇荣华村弄在屯113号");
|
|
|
|
temperatureEsp.setLocationDesc("广西壮族自治区崇左市天等县天等镇荣华村弄在屯113号");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
temperatureEsp.setHumidity(humidityValue);
|
|
|
|
temperatureEsp.setHumidity(humidityValue);
|
|
|
|
temperatureEsp.setTemperature(temperatureValue);
|
|
|
|
temperatureEsp.setTemperature(temperatureValue);
|
|
|
|
|
|
|
|
|
|
|
|
//mysql
|
|
|
|
|
|
|
|
this.temperatureEspRepository.save(temperatureEsp);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
} catch (Exception var14) {
|
|
|
|
e.printStackTrace();
|
|
|
|
var14.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -72,38 +67,42 @@ public class TemperatureEspServiceImpl implements TemperatureEspService {
|
|
|
|
SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
|
SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
|
SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
SimpleDateFormat sdfSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
SimpleDateFormat sdfSecond = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
String nowDate = sdf.format(now);
|
|
|
|
String nowDate = sdf.format(now);
|
|
|
|
String nowHour = sdfHour.format(now);
|
|
|
|
String nowHour = sdfHour.format(now);
|
|
|
|
String dataMinute = sdfMinute.format(now);
|
|
|
|
String dataMinute = sdfMinute.format(now);
|
|
|
|
String dataSecond = sdfSecond.format(now);
|
|
|
|
sdfSecond.format(now);
|
|
|
|
TemperatureEsp temperatureEsp = new TemperatureEsp();
|
|
|
|
TemperatureEsp temperatureEsp = new TemperatureEsp();
|
|
|
|
temperatureEsp.setCreateDate(now);
|
|
|
|
temperatureEsp.setCreateDate(now);
|
|
|
|
temperatureEsp.setDataDate(nowDate);
|
|
|
|
temperatureEsp.setDataDate(nowDate);
|
|
|
|
temperatureEsp.setDataHour(nowHour);
|
|
|
|
temperatureEsp.setDataHour(nowHour);
|
|
|
|
temperatureEsp.setDataMinute(dataMinute);
|
|
|
|
temperatureEsp.setDataMinute(dataMinute);
|
|
|
|
temperatureEsp.setSource("mqtt");
|
|
|
|
temperatureEsp.setSource("mqtt");
|
|
|
|
|
|
|
|
log.info("topic:{}",topic);
|
|
|
|
if (topic != null) {
|
|
|
|
if (topic != null) {
|
|
|
|
temperatureEsp.setTopic(topic);
|
|
|
|
temperatureEsp.setTopic(topic);
|
|
|
|
if (topic.equals("/device/esp8266/001")) {
|
|
|
|
if (topic.equals("/device/esp8266/001")) {
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市高新区唐家湾镇南方软件园B2栋4楼珠海瑞洪智能系统工程有限公司");
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市高新区唐家湾镇东岸村水风三街28号501");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(topic.equals("WifiSHT/7C87CE9F5CBF/SHT20")){
|
|
|
|
|
|
|
|
|
|
|
|
if (topic.equals("/device/esp8266/002")) {
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市金湾区三灶镇百川路1号1栋1单元1508房");
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市金湾区三灶镇百川路1号1栋1单元1508房");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(topic.equals("WifiSHT/4CEBD686B6AA/SHT20")){
|
|
|
|
|
|
|
|
temperatureEsp.setLocationDesc("广西壮族自治区崇左市天等县天等镇荣华村弄在屯113号");
|
|
|
|
if (topic.equals("/device/esp8266/003")) {
|
|
|
|
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市高新区唐家湾镇南方软件园B2栋4楼珠海瑞洪智能系统工程有限公司");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (topic.equals("/device/esp8266/004")) {
|
|
|
|
|
|
|
|
temperatureEsp.setLocationDesc("广东省珠海市高新区唐家湾镇东岸村水风三街28号501-01");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
temperatureEsp.setHumidity(humidityValue);
|
|
|
|
temperatureEsp.setHumidity(humidityValue);
|
|
|
|
temperatureEsp.setTemperature(temperatureValue);
|
|
|
|
temperatureEsp.setTemperature(temperatureValue);
|
|
|
|
|
|
|
|
|
|
|
|
//mysql
|
|
|
|
|
|
|
|
this.temperatureEspRepository.save(temperatureEsp);
|
|
|
|
this.temperatureEspRepository.save(temperatureEsp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
} catch (Exception var14) {
|
|
|
|
e.printStackTrace();
|
|
|
|
var14.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|