Commit b1d2260a by 朱淼
parents a8912075 6b0cf2fd
...@@ -10,6 +10,7 @@ import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum; ...@@ -10,6 +10,7 @@ import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum;
import com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum; import com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum;
import com.makeit.module.iot.enums.DeviceInfoContentFallEnum; import com.makeit.module.iot.enums.DeviceInfoContentFallEnum;
import com.makeit.module.iot.enums.DeviceInfoContentSpaceEnum; 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.service.IotProductDeviceService;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe; import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.fall.DeviceInfoContentFall; import com.makeit.module.iot.vo.fall.DeviceInfoContentFall;
...@@ -131,6 +132,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -131,6 +132,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (platDevice == null) { if (platDevice == null) {
return null; return null;
} }
if (!platDevice.getStatus().equals(DeviceState.online.getValue())) {
return null;
}
DeviceInfoContentBreathe deviceInfoContentBreathe = iotProductDeviceService.getLastDeviceLogBreathe(platDevice.getOriDeviceId(), 10); DeviceInfoContentBreathe deviceInfoContentBreathe = iotProductDeviceService.getLastDeviceLogBreathe(platDevice.getOriDeviceId(), 10);
...@@ -341,10 +345,19 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -341,10 +345,19 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate); platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate);
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate); platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate);
} else { } else {
if (heartRate == 0) {
platElderRealTimeHeartRespiratoryVO.setHeartRate(0);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5; int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeHeartRespiratoryVO.setHeartRate(Math.max(heartRate + hrRange,0));
}
if (respiratoryRate == 0) {
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(0);
} else {
int brRange = RandomUtils.nextInt(1, 7) - 3; int brRange = RandomUtils.nextInt(1, 7) - 3;
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate + hrRange); platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(Math.max(respiratoryRate + brRange,0));
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate + brRange); }
} }
redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO)); redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO));
} }
...@@ -380,9 +393,14 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -380,9 +393,14 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (i ==0) { if (i ==0) {
platElderRealTimeBodyVO.setBodyMovementIndex(body); platElderRealTimeBodyVO.setBodyMovementIndex(body);
} else { } else {
if (body == 0) {
platElderRealTimeBodyVO.setBodyMovementIndex(0);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5; int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeBodyVO.setBodyMovementIndex(Math.max(body + hrRange,0)); platElderRealTimeBodyVO.setBodyMovementIndex(Math.max(body + hrRange,0));
} }
}
redisTemplate.opsForList().leftPush(ELDER_MOVE + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeBodyVO)); redisTemplate.opsForList().leftPush(ELDER_MOVE + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeBodyVO));
} }
return JSON.parseObject(redisTemplate.opsForList().rightPop(ELDER_MOVE + platElderIdDTO.getElderId()),PlatElderRealTimeBodyVO.class); return JSON.parseObject(redisTemplate.opsForList().rightPop(ELDER_MOVE + platElderIdDTO.getElderId()),PlatElderRealTimeBodyVO.class);
...@@ -433,10 +451,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -433,10 +451,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
List<PlatDevice> deviceListFall = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId()); List<PlatDevice> deviceListFall = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceListSpace) && CollectionUtils.isNotEmpty(deviceListFall)) { if (CollectionUtils.isNotEmpty(deviceListSpace)) {
return voList;
}
deviceListSpace.forEach(e -> { deviceListSpace.forEach(e -> {
DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10); DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10);
if (i == null) { if (i == null) {
...@@ -457,7 +472,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -457,7 +472,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
voList.add(vo); voList.add(vo);
}); });
}
if (CollectionUtils.isNotEmpty(deviceListFall)) {
deviceListFall.forEach(e -> { deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10); DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) { if (i == null) {
...@@ -474,8 +491,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -474,8 +491,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
voList.add(vo); voList.add(vo);
}); });
}
return voList; return voList;
} }
......
...@@ -892,6 +892,9 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -892,6 +892,9 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
public List<PlatDevice> getSpaceDevice(String id) { public List<PlatDevice> getSpaceDevice(String id) {
PlatElder platElder = getById(id); PlatElder platElder = getById(id);
if (platElder == null) {
return null;
}
if (StringUtils.isBlank(platElder.getBedId())) { if (StringUtils.isBlank(platElder.getBedId())) {
return null; return null;
} }
......
...@@ -14,6 +14,7 @@ import com.makeit.module.iot.vo.DeviceState; ...@@ -14,6 +14,7 @@ import com.makeit.module.iot.vo.DeviceState;
import com.makeit.module.system.service.SysDictionaryCategoryService; import com.makeit.module.system.service.SysDictionaryCategoryService;
import com.makeit.module.system.vo.DictionaryVo; import com.makeit.module.system.vo.DictionaryVo;
import com.makeit.service.platform.device.PlatDeviceService; 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.platform.elder.PlatElderSleepService;
import com.makeit.service.saas.PlatTenantService; import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil; import com.makeit.utils.DeviceCacheUtil;
...@@ -47,13 +48,15 @@ public class IotSyncTask { ...@@ -47,13 +48,15 @@ public class IotSyncTask {
private DeviceCacheUtil deviceCacheUtil; private DeviceCacheUtil deviceCacheUtil;
@Autowired @Autowired
private PlatElderSleepService platElderSleepService; private PlatElderSleepService platElderSleepService;
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
/** /**
* 一小时同步一次 * 一小时同步一次
* 启用状态的租户才同步 * 启用状态的租户才同步
* 新增和更新平台端设备表 * 新增和更新平台端设备表
*/ */
@Scheduled(cron = "0 0 */1 * * ?") @Scheduled(cron = "0 0/10 * * * *")
public void syncEquipmentInfo() { public void syncEquipmentInfo() {
savePlatDevice(); savePlatDevice();
} }
...@@ -158,4 +161,13 @@ public class IotSyncTask { ...@@ -158,4 +161,13 @@ public class IotSyncTask {
log.info("定时分析长者睡眠质量结束"); 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