Commit 8d763929 by huangjy

fix: 改成十分钟同步一次

parent 14312720
......@@ -10,6 +10,7 @@ import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum;
import com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum;
import com.makeit.module.iot.enums.DeviceInfoContentFallEnum;
import com.makeit.module.iot.enums.DeviceInfoContentSpaceEnum;
import com.makeit.module.iot.enums.DeviceState;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.fall.DeviceInfoContentFall;
......@@ -131,6 +132,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (platDevice == null) {
return null;
}
if (!platDevice.getStatus().equals(DeviceState.online.getValue())) {
return null;
}
DeviceInfoContentBreathe deviceInfoContentBreathe = iotProductDeviceService.getLastDeviceLogBreathe(platDevice.getOriDeviceId(), 10);
......@@ -343,8 +347,8 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
int brRange = RandomUtils.nextInt(1, 7) - 3;
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate + hrRange);
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate + brRange);
platElderRealTimeHeartRespiratoryVO.setHeartRate(Math.max(heartRate + hrRange,0));
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(Math.max(respiratoryRate + brRange,0));
}
redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO));
}
......@@ -433,49 +437,47 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
List<PlatDevice> deviceListFall = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceListSpace) && CollectionUtils.isNotEmpty(deviceListFall)) {
return voList;
}
deviceListSpace.forEach(e -> {
DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
if (CollectionUtils.isNotEmpty(deviceListSpace)) {
deviceListSpace.forEach(e -> {
DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
// vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
voList.add(vo);
voList.add(vo);
});
deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
});
}
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
if (CollectionUtils.isNotEmpty(deviceListFall)) {
deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
vo.setTrack(i.getProperties().getTrack());
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
voList.add(vo);
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
});
vo.setTrack(i.getProperties().getTrack());
voList.add(vo);
});
}
return voList;
}
......
......@@ -14,6 +14,7 @@ import com.makeit.module.iot.vo.DeviceState;
import com.makeit.module.system.service.SysDictionaryCategoryService;
import com.makeit.module.system.vo.DictionaryVo;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.service.platform.elder.PlatElderSleepService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil;
......@@ -47,13 +48,15 @@ public class IotSyncTask {
private DeviceCacheUtil deviceCacheUtil;
@Autowired
private PlatElderSleepService platElderSleepService;
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
/**
* 一小时同步一次
* 启用状态的租户才同步
* 新增和更新平台端设备表
*/
@Scheduled(cron = "0 0 */1 * * ?")
@Scheduled(cron = "0 0/10 * * * *")
public void syncEquipmentInfo() {
savePlatDevice();
}
......@@ -158,4 +161,13 @@ public class IotSyncTask {
log.info("定时分析长者睡眠质量结束");
}
/* @Scheduled(cron = "0 0 1 * * ?")
@TenantIdIgnore
public void elderCoordinateListAnalysisTask() {
log.info("开始定时分析24小时热力图");
platElderDayReportDayService.elderCoordinateListAnalysisTask();
log.info("定时分析长者24小时热力图");
}*/
}
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