Commit e5c3e16d by huangjy

fix:上报时间先取当作时间戳

parent 195740c6
...@@ -836,11 +836,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -836,11 +836,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
public void active(BaseIdDTO dto) { public void active(BaseIdDTO dto) {
PlatDevice platDevice = getById(dto.getId()); PlatDevice platDevice = getById(dto.getId());
Map<String, Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
resMap.put("appid",shengwangProperties.getAppId()); /* resMap.put("appid",shengwangProperties.getAppId());
String AttrResult = devicePropertiesOperateService.deviceWriteAttr(platDevice.getOriDeviceId(), resMap); String AttrResult = devicePropertiesOperateService.deviceWriteAttr(platDevice.getOriDeviceId(), resMap);
if (StringUtils.isNotEmpty(AttrResult)) { if (StringUtils.isNotEmpty(AttrResult)) {
throw new RuntimeException(AttrResult); throw new RuntimeException(AttrResult);
} }*/
SaasPidManage saasPidManage = saasPidManageService.getOne(new QueryWrapper<SaasPidManage>().lambda() SaasPidManage saasPidManage = saasPidManageService.getOne(new QueryWrapper<SaasPidManage>().lambda()
.eq(SaasPidManage::getStatus, "1") .eq(SaasPidManage::getStatus, "1")
.orderByAsc(BaseEntity::getCreateDate) .orderByAsc(BaseEntity::getCreateDate)
......
...@@ -232,7 +232,6 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -232,7 +232,6 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
boolean spaceNoPersonFlag = false; boolean spaceNoPersonFlag = false;
for (PlatDevice device : spaceDeviceList) { for (PlatDevice device : spaceDeviceList) {
// 无人
Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_SPACE_TEMP_DATA + platDevice.getOriDeviceId(), currentSecond - 10, currentSecond); Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_SPACE_TEMP_DATA + platDevice.getOriDeviceId(), currentSecond - 10, currentSecond);
if (CollectionUtils.isEmpty(dataSet)) { if (CollectionUtils.isEmpty(dataSet)) {
log.info("空间设备当前没有上报数据直接返回"); log.info("空间设备当前没有上报数据直接返回");
...@@ -279,7 +278,6 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -279,7 +278,6 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
} }
boolean fallNoPersonFlag = false; boolean fallNoPersonFlag = false;
for (PlatDevice device : fallDeviceList) { for (PlatDevice device : fallDeviceList) {
// 无人
Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_FALL_TEMP_DATA + platDevice.getOriDeviceId(), currentSecond - 10, currentSecond); Set<String> dataSet = redisTemplate.opsForZSet().rangeByScore(DEVICE_FALL_TEMP_DATA + platDevice.getOriDeviceId(), currentSecond - 10, currentSecond);
if (CollectionUtils.isEmpty(dataSet)) { if (CollectionUtils.isEmpty(dataSet)) {
log.info("跌倒设备当前没有上报数据直接返回"); log.info("跌倒设备当前没有上报数据直接返回");
......
...@@ -153,7 +153,7 @@ public class PushCallback implements MqttCallback { ...@@ -153,7 +153,7 @@ public class PushCallback implements MqttCallback {
List<HeaderInfo.Bind> bindings = headers.getBindings(); List<HeaderInfo.Bind> bindings = headers.getBindings();
Long timestamp = device.getTimestamp(); Long timestamp = device.getTimestamp();
long currentSecond = timestamp / 1000; long currentSecond = System.currentTimeMillis() / 1000;
// 先通过产品名称判断 // 先通过产品名称判断
if (REPORT_PROPERTY.equals(device.getMessageType()) && headers.getProductName().contains("呼吸")) { if (REPORT_PROPERTY.equals(device.getMessageType()) && headers.getProductName().contains("呼吸")) {
cacheBrDeviceData(device, currentSecond); cacheBrDeviceData(device, currentSecond);
...@@ -235,7 +235,7 @@ public class PushCallback implements MqttCallback { ...@@ -235,7 +235,7 @@ public class PushCallback implements MqttCallback {
long maxSize = 10L; long maxSize = 10L;
String key = deviceSpaceTempData + device.getDeviceId(); String key = deviceSpaceTempData + device.getDeviceId();
redisTemplate.opsForZSet().add(key,JSON.toJSONString(device),currentSecond); redisTemplate.opsForZSet().add(key,JSON.toJSONString(device),currentSecond);
redisTemplate.expire(key,maxSize + 1,TimeUnit.MINUTES); redisTemplate.expire(key,60,TimeUnit.SECONDS);
} }
private void cacheBrDeviceData(DeviceInfo device, long currentSecond) { private void cacheBrDeviceData(DeviceInfo device, long currentSecond) {
...@@ -243,7 +243,7 @@ public class PushCallback implements MqttCallback { ...@@ -243,7 +243,7 @@ public class PushCallback implements MqttCallback {
String key = DEVICE_BR_ANALYSIS + device.getDeviceId(); String key = DEVICE_BR_ANALYSIS + device.getDeviceId();
long duration = getSleepTimeActionDuration(); long duration = getSleepTimeActionDuration();
redisTemplate.opsForZSet().add(key,JSON.toJSONString(device),currentSecond); redisTemplate.opsForZSet().add(key,JSON.toJSONString(device),currentSecond);
redisTemplate.expire(key,duration + 3,TimeUnit.MINUTES); redisTemplate.expire(key,duration + 180,TimeUnit.SECONDS);
} }
private Long getSleepTimeActionDuration() { private Long getSleepTimeActionDuration() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment