Commit b1d2260a by 朱淼
parents a8912075 6b0cf2fd
......@@ -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);
......@@ -341,10 +345,19 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate);
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
int brRange = RandomUtils.nextInt(1, 7) - 3;
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate + hrRange);
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate + brRange);
if (heartRate == 0) {
platElderRealTimeHeartRespiratoryVO.setHeartRate(0);
} else {
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;
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(Math.max(respiratoryRate + brRange,0));
}
}
redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO));
}
......@@ -380,8 +393,13 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (i ==0) {
platElderRealTimeBodyVO.setBodyMovementIndex(body);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeBodyVO.setBodyMovementIndex(Math.max(body + hrRange,0));
if (body == 0) {
platElderRealTimeBodyVO.setBodyMovementIndex(0);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeBodyVO.setBodyMovementIndex(Math.max(body + hrRange,0));
}
}
redisTemplate.opsForList().leftPush(ELDER_MOVE + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeBodyVO));
}
......@@ -433,49 +451,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());
voList.add(vo);
});
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
voList.add(vo);
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;
}
......
......@@ -892,6 +892,9 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
public List<PlatDevice> getSpaceDevice(String id) {
PlatElder platElder = getById(id);
if (platElder == null) {
return null;
}
if (StringUtils.isBlank(platElder.getBedId())) {
return null;
}
......
......@@ -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