1、中南院MQTT推送,时间到毫秒
This commit is contained in:
parent
d53d2510df
commit
108bf78bfe
@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@ -25,6 +26,8 @@ import java.util.List;
|
||||
@EnableScheduling
|
||||
public class ZNYMQTTForwarder extends Forwarder {
|
||||
static final String FORWARDER_NAME = "中南院MQTT";
|
||||
final DateTimeFormatter formatterMs = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
static byte[] key = new byte[] { (byte) 0x8c, (byte) 0xc7, 0x2b, 0x05, 0x70, 0x5d, 0x5c, 0x46, (byte) 0xf4, 0x12, (byte) 0xaf, (byte) 0x8c, (byte) 0xbe,
|
||||
(byte) 0xd5, 0x5a, (byte) 0xad, (byte) 0x8c, (byte) 0xc7, 0x2b, 0x05, 0x70, 0x5d, 0x5c, 0x46 };
|
||||
static byte[] iv = new byte[] { 0x66, 0x7b, 0x02, (byte) 0xa8, 0x5c, 0x61, (byte) 0xc7, (byte) 0x86 };
|
||||
@ -66,7 +69,7 @@ public class ZNYMQTTForwarder extends Forwarder {
|
||||
|
||||
for (GnssCalcData locationRecord : records) {
|
||||
ZNYMQTTData tranData = new ZNYMQTTData();
|
||||
tranData.setTimestamp(locationRecord.getCreatetime().format(formatter));
|
||||
tranData.setTimestamp(locationRecord.getCreatetime().format(formatterMs));
|
||||
double n = NumberUtils.scale(locationRecord.getRposn(), 2);
|
||||
double e = NumberUtils.scale(locationRecord.getRpose(), 2);
|
||||
double d = NumberUtils.scale(locationRecord.getRposd(), 2);
|
||||
@ -75,7 +78,7 @@ public class ZNYMQTTForwarder extends Forwarder {
|
||||
tranData.setRposu(d);
|
||||
String json = GsonUtil.toJson(tranData);
|
||||
String cryptJson = Des3Utils.encrypt(json,key,iv);
|
||||
logger.info("forward to ZNY mqtt: {}, {}",json, cryptJson);
|
||||
logger.debug("forward to ZNY mqtt: {}, {}",json, cryptJson);
|
||||
String topic = "/GnssData/"+locationRecord.getDeviceid()+"/Increment";
|
||||
try {
|
||||
if(!mqttClient.publish(topic, cryptJson)) break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user