Commit 02d7f9db by 黄强

解析json 模板比你且複製,還差變量替換

parent 79e275e8
...@@ -2,7 +2,6 @@ package com.jln.system.web.action.mqtt; ...@@ -2,7 +2,6 @@ package com.jln.system.web.action.mqtt;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jln.common.utils.EmptyUtil; import com.jln.common.utils.EmptyUtil;
import com.jln.system.web.action.mqtt.pojo.dto.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -11,7 +10,6 @@ import org.springframework.data.mongodb.core.MongoTemplate; ...@@ -11,7 +10,6 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.lang.reflect.Field;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
...@@ -146,7 +144,7 @@ public class Base64decrypt { ...@@ -146,7 +144,7 @@ public class Base64decrypt {
mongoMap.putAll(objectMap); mongoMap.putAll(objectMap);
mongoMap.remove("_id"); mongoMap.remove("_id");
mongoMap.remove("time"); mongoMap.remove("time");
millis = Calendar.getInstance().getTimeInMillis();
//处理实体类在每个字段加上时间 //处理实体类在每个字段加上时间
List<Map<String, Object>> allDto = new ArrayList<>(); List<Map<String, Object>> allDto = new ArrayList<>();
for (Map.Entry<String,Object> entry : mongoMap.entrySet()) { for (Map.Entry<String,Object> entry : mongoMap.entrySet()) {
...@@ -154,13 +152,13 @@ public class Base64decrypt { ...@@ -154,13 +152,13 @@ public class Base64decrypt {
try { try {
sites.put(entry.getKey(), entry.getValue()); sites.put(entry.getKey(), entry.getValue());
sites.put("ts", String.valueOf(millis)); sites.put("ts", millis);
allDto.add(sites); allDto.add(sites);
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); System.out.println(e);
Map<String, Object> site = new HashMap<>(); Map<String, Object> site = new HashMap<>();
site.put("Status", "2"); site.put("Status", "2");
site.put("ts", String.valueOf(millis)); site.put("ts", millis);
allDto.add(site); allDto.add(site);
reportDto.put("reported", allDto); reportDto.put("reported", allDto);
reportDto.put("edgeTime", millis); reportDto.put("edgeTime", millis);
......
...@@ -158,7 +158,8 @@ public class MqttStartClient { ...@@ -158,7 +158,8 @@ public class MqttStartClient {
*/ */
public void jqr( JsonDataDto jsonDataDto, XBMqttDataUtil xbMqttDataUtil) { public void jqr( JsonDataDto jsonDataDto, XBMqttDataUtil xbMqttDataUtil) {
try { try {
long millis = Calendar.getInstance().getTimeInMillis();
long millis = System.currentTimeMillis() / 1000;
//解析sk证书信息 //解析sk证书信息
Integer version= resolveSk(jsonDataDto.getSkurl()); Integer version= resolveSk(jsonDataDto.getSkurl());
//reportDto.put("productKey", "PaintRobot"); //reportDto.put("productKey", "PaintRobot");
......
...@@ -43,7 +43,7 @@ public class InitHander implements CommandLineRunner { ...@@ -43,7 +43,7 @@ public class InitHander implements CommandLineRunner {
List<JSONObject> mongdbTableList= JSONObject.parseObject(j.getJSONObject("reported").getJSONArray("singleField").toString(), List.class); List<JSONObject> mongdbTableList= JSONObject.parseObject(j.getJSONObject("reported").getJSONArray("singleField").toString(), List.class);
jsonDataDto.setCmdId(j.get("cmdId").toString()); jsonDataDto.setCmdId(j.get("cmdId").toString());
jsonDataDto.setMongdbTableb(j.get("mongdbTableb").toString()); jsonDataDto.setMongdbTableb(j.get("mongdbTableb").toString());
jsonDataDto.setSequenceId(j.get("sequenceId").toString()); jsonDataDto.setSequenceId(Integer.parseInt(j.get("sequenceId").toString()));
jsonDataDto.setProductKey(j.get("productKey").toString()); jsonDataDto.setProductKey(j.get("productKey").toString());
jsonDataDto.setSkurl(j.get("skurl").toString()); jsonDataDto.setSkurl(j.get("skurl").toString());
jsonDataDto.setTxtFileUrl(j.get("txtFileUrl").toString()); jsonDataDto.setTxtFileUrl(j.get("txtFileUrl").toString());
......
...@@ -36,7 +36,7 @@ public class JsonDataDto { ...@@ -36,7 +36,7 @@ public class JsonDataDto {
private String productKey; private String productKey;
@JsonProperty("sequenceId") @JsonProperty("sequenceId")
private String sequenceId; private Integer sequenceId;
@JsonProperty("clientUuid") @JsonProperty("clientUuid")
private String clientUuid; private String clientUuid;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论