|
|
@@ -2,6 +2,7 @@ package com.usky.cdi.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.usky.cdi.domain.*;
|
|
|
@@ -387,7 +388,7 @@ public class IotDataTransferService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 发送人员统计情况(703)
|
|
|
+ * 发送人员统计情况(703)-掩蔽人数
|
|
|
*
|
|
|
* @return 推送结果,包含成功数和失败数
|
|
|
**/
|
|
|
@@ -425,8 +426,14 @@ public class IotDataTransferService {
|
|
|
headcountVO.setEngineeringID(transferVO.getEngineeringId());
|
|
|
headcountVO.setSensorValue(peopleCount);
|
|
|
// headcountVO.setSensorID(buildUnit.getId());
|
|
|
- headcountVO.setDataEndTime(now.minusMinutes(ThreadLocalRandom.current().nextInt(1, 2)));
|
|
|
- headcountVO.setPublishTime(now);
|
|
|
+
|
|
|
+ // 为每条数据生成秒级微差的时间
|
|
|
+ int secondsOffset = ThreadLocalRandom.current().nextInt(0, 60);
|
|
|
+ LocalDateTime dataEndTimeWithOffset = now.minusMinutes(ThreadLocalRandom.current().nextInt(1, 3)).plusSeconds(secondsOffset);
|
|
|
+ LocalDateTime publishTimeWithOffset = now.plusSeconds(ThreadLocalRandom.current().nextInt(0, 30));
|
|
|
+
|
|
|
+ headcountVO.setDataEndTime(dataEndTimeWithOffset);
|
|
|
+ headcountVO.setPublishTime(publishTimeWithOffset);
|
|
|
headcountVO.setUnitName(buildUnit.getUnitName());
|
|
|
headcountVO.setFloor(buildUnit.getFloor());
|
|
|
|
|
|
@@ -437,6 +444,8 @@ public class IotDataTransferService {
|
|
|
MqttTopics.IotInfo.PERSON.getDesc(),
|
|
|
transferVO.getUsername()
|
|
|
);
|
|
|
+ // 添加2S延时
|
|
|
+ Thread.sleep(2000);
|
|
|
result.put("successCount", result.get("successCount") + 1);
|
|
|
log.info("【人员统计】推送成功,单元:{},人数:{}", buildUnit.getUnitName(), peopleCount);
|
|
|
} catch (Exception e) {
|
|
|
@@ -1229,6 +1238,9 @@ public class IotDataTransferService {
|
|
|
case 716:
|
|
|
result = sendWaterLevel(transferVO);
|
|
|
break;
|
|
|
+ case 719:
|
|
|
+ result = sendPersonCount(transferVO);
|
|
|
+ break;
|
|
|
default:
|
|
|
log.debug("不支持的设备类型:{}", deviceType);
|
|
|
continue;
|
|
|
@@ -1346,7 +1358,10 @@ public class IotDataTransferService {
|
|
|
} else if (raw instanceof Number) {
|
|
|
dataTime = ((Number) raw).longValue();
|
|
|
} else if (raw instanceof String) {
|
|
|
- try { dataTime = Long.parseLong((String) raw); } catch (Exception ignored) {}
|
|
|
+ try {
|
|
|
+ dataTime = Long.parseLong((String) raw);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
}
|
|
|
if (dataTime == null) return null;
|
|
|
return LocalDateTime.ofInstant(Instant.ofEpochMilli(dataTime), ZoneId.systemDefault());
|
|
|
@@ -1406,7 +1421,8 @@ public class IotDataTransferService {
|
|
|
log.warn("平面图文件为空,FileID: {}", vo.getFloorFileID());
|
|
|
}
|
|
|
|
|
|
- return jsonObject.toJSONString();
|
|
|
+ Gson gson = new Gson();
|
|
|
+ return gson.toJson(jsonObject);
|
|
|
}
|
|
|
|
|
|
public void allData(Long engineeringId, String username, String password) {
|