Commit 626d1558 by 杨伟程

坐标定位和轨迹更新

parents d7046ca6 baa834f9
...@@ -55,9 +55,10 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte ...@@ -55,9 +55,10 @@ public class DataScopeInterceptor extends JsqlParserSupport implements InnerInte
} }
String[] orgIds = dataScope.split(Const.COMMON_SPLIT); String[] orgIds = dataScope.split(Const.COMMON_SPLIT);
List<String> orgIdList = Arrays.asList(orgIds); List<String> orgIdList = Arrays.asList(orgIds);
if(orgIdList.contains(tenantId)){ //2023年10月10日 如果是租户级别的组织,也只能看到本层
return; // if(orgIdList.contains(tenantId)){
} // return;
// }
String tableName = ((Table) ((PlainSelect) select.getSelectBody()).getFromItem()).getName(); String tableName = ((Table) ((PlainSelect) select.getSelectBody()).getFromItem()).getName();
//没有org_id 表字段跳过 //没有org_id 表字段跳过
List<TableFieldInfo> fieldInfoList = TableInfoHelper.getTableInfo(tableName).getFieldList(); List<TableFieldInfo> fieldInfoList = TableInfoHelper.getTableInfo(tableName).getFieldList();
......
...@@ -129,15 +129,14 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -129,15 +129,14 @@ public class IotProductDeviceService extends IotCommonService {
if (deviceOperationLogEntity == null) { if (deviceOperationLogEntity == null) {
return null; return null;
} }
DeviceInfoContentBreathe breathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class); DeviceInfoContentBreathe breathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class);
return breathe;
/* LocalDateTime time = LongTimestampUtil.toLocalDateTime(breathe.getTimestamp()); /* LocalDateTime time = LongTimestampUtil.toLocalDateTime(breathe.getTimestamp());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) { if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null; return null;
}*/ }*/
return breathe;
} }
...@@ -253,9 +252,13 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -253,9 +252,13 @@ public class IotProductDeviceService extends IotCommonService {
public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) { public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime)); List<DeviceInfoContentSpace> deviceInfoContentSpaceList = Lists.newArrayList();
int count = pageSize / 10000;
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentSpace.class)); for (int i = 0; i < count + 1; i++) {
List<DeviceOperationLogEntity> deviceOperationLogList = getDeviceLogByTimeRange(deviceId, REPORT_PROPERTY, 10000, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentSpace> tempDeviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentSpace.class));
deviceInfoContentSpaceList.addAll(tempDeviceInfoContentSpaceList);
}
return deviceInfoContentSpaceList; return deviceInfoContentSpaceList;
} }
......
...@@ -5,11 +5,13 @@ import com.makeit.common.page.PageVO; ...@@ -5,11 +5,13 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO; import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.dto.platform.space.PlatBedQueryDTO; import com.makeit.dto.platform.space.PlatBedQueryDTO;
import com.makeit.module.system.entity.ChinaArea; import com.makeit.module.system.entity.ChinaArea;
import com.makeit.service.platform.dataScreen.DataScreenService; import com.makeit.service.platform.dataScreen.DataScreenService;
import com.makeit.utils.area.ChinaAreaVO; import com.makeit.utils.area.ChinaAreaVO;
import com.makeit.vo.platform.dataScreen.*; import com.makeit.vo.platform.dataScreen.*;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.space.PlatBedVo; import com.makeit.vo.platform.space.PlatBedVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -83,4 +85,10 @@ public class DataScreenController { ...@@ -83,4 +85,10 @@ public class DataScreenController {
return ApiResponseUtils.success(dataScreenService.mapList(dto)); return ApiResponseUtils.success(dataScreenService.mapList(dto));
} }
@ApiOperation("设备分页列表")
@PostMapping("devicePage")
public ApiResponseEntity<PageVO<PlatDeviceListVO>> devicePage(@RequestBody PageReqDTO<PlatDataScreenQueryDTO> pageReqDTO) {
return ApiResponseUtils.success(dataScreenService.devicePage(pageReqDTO));
}
} }
...@@ -31,4 +31,7 @@ public class PlatDataScreenQueryDTO { ...@@ -31,4 +31,7 @@ public class PlatDataScreenQueryDTO {
@ApiModelProperty("类型 1-居家 2-机构") @ApiModelProperty("类型 1-居家 2-机构")
private String type; private String type;
@ApiModelProperty("设备状态")
private String deviceStatus;
} }
...@@ -268,7 +268,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -268,7 +268,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Transactional @Transactional
@Override @Override
public void edit(PlatUserDTOVO dto) { public void edit(PlatUserDTOVO dto) {
dto.setAccount(null); //dto.setAccount(null);
check(dto); check(dto);
PlatUser user = BeanDtoVoUtils.convert(dto, PlatUser.class); PlatUser user = BeanDtoVoUtils.convert(dto, PlatUser.class);
user.setIsTenant(CommonEnum.YES.getValue()); user.setIsTenant(CommonEnum.YES.getValue());
...@@ -909,6 +909,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -909,6 +909,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
fillDept(Arrays.asList(userVO)); fillDept(Arrays.asList(userVO));
getRoleList(userVO); getRoleList(userVO);
PlatTenant platTenant = platTenantService.getById(userVO.getTenantId());
userVO.setPlatTenant(platTenant);
return userVO; return userVO;
} }
......
...@@ -3,8 +3,10 @@ package com.makeit.service.platform.dataScreen; ...@@ -3,8 +3,10 @@ package com.makeit.service.platform.dataScreen;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO; import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.utils.area.ChinaAreaVO; import com.makeit.utils.area.ChinaAreaVO;
import com.makeit.vo.platform.dataScreen.*; import com.makeit.vo.platform.dataScreen.*;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import java.util.List; import java.util.List;
...@@ -30,4 +32,6 @@ public interface DataScreenService { ...@@ -30,4 +32,6 @@ public interface DataScreenService {
List<ChinaAreaVO> mapList(PlatDataScreenQueryDTO dto); List<ChinaAreaVO> mapList(PlatDataScreenQueryDTO dto);
PageVO<PlatAlarmStatisticsListVo> alarmPage(PageReqDTO<PlatDataScreenQueryDTO> page); PageVO<PlatAlarmStatisticsListVo> alarmPage(PageReqDTO<PlatDataScreenQueryDTO> page);
PageVO<PlatDeviceListVO> devicePage(PageReqDTO<PlatDataScreenQueryDTO> pageReqDTO);
} }
package com.makeit.service.platform.dataScreen.impl; package com.makeit.service.platform.dataScreen.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO; import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO; import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO; import com.makeit.dto.platform.dataScreen.PlatDataScreenQueryDTO;
import com.makeit.dto.platform.device.PlatDeviceQueryDTO;
import com.makeit.entity.platform.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.auth.PlatOrg; import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatUser; import com.makeit.entity.platform.auth.PlatUser;
...@@ -32,8 +35,10 @@ import com.makeit.utils.area.ChinaAreaVO; ...@@ -32,8 +35,10 @@ import com.makeit.utils.area.ChinaAreaVO;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil; import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.sql.join.JoinUtil; import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.dataScreen.*; import com.makeit.vo.platform.dataScreen.*;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.elder.PlatElderListVO; import com.makeit.vo.platform.elder.PlatElderListVO;
import jodd.util.StringUtil; import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -470,6 +475,52 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -470,6 +475,52 @@ public class DataScreenServiceImpl implements DataScreenService {
return PageUtil.toPageVO(list, pages); return PageUtil.toPageVO(list, pages);
} }
@Override
public PageVO<PlatDeviceListVO> devicePage(PageReqDTO<PlatDataScreenQueryDTO> pageReqDTO) {
PlatDataScreenQueryDTO dto = pageReqDTO.getData();
if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织
List<PlatOrg> orgs = belongToScopeList(dto.getType());
if(orgs.isEmpty()){
return new PageVO<>();
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIds);
}else {
//根据类型过滤数据
List<PlatOrg> platOrgs = platOrgService.list(new QueryWrapper<PlatOrg>().lambda()
.in(PlatOrg::getId, dto.getOrgIds())
.eq(PlatOrg::getType, dto.getType()));
if(platOrgs.isEmpty()){
return new PageVO<>();
}
List<String> orgIdList = platOrgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
dto.setOrgIds(orgIdList);
}
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<PlatDevice>()
.eq(StringUtils.isNotBlank(dto.getDeviceStatus()), PlatDevice::getStatus, dto.getDeviceStatus())
.in(PlatDevice::getOrgId, dto.getOrgIds())
.orderByDesc(BaseEntity::getUpdateDate);
Page<PlatDevice> page = platDeviceService.page(p, queryWrapper);
List<PlatDeviceListVO> voList = BeanDtoVoUtils.listVo(page.getRecords(), PlatDeviceListVO.class);
JoinUtil.join(voList, platOrgService, PlatDeviceListVO::getOrgId, PlatOrg::getId, (d, o) -> {
d.setOrgName(o.getName());
});
JoinUtil.joinSplit(voList, platOrgService, PlatDeviceListVO::getOrgPath, PlatOrg::getId, (d, o) -> {
d.setOrgPathName(StreamUtil.join(o, PlatOrg::getName));
});
return PageUtil.toPageVO(voList, page);
}
private List<PlatOrg> getAncestorsOrgList(List<PlatOrg> orgs, Set<String> parentOrgIds) { private List<PlatOrg> getAncestorsOrgList(List<PlatOrg> orgs, Set<String> parentOrgIds) {
orgs = orgs.stream().filter(t->parentOrgIds.contains(t.getId())).collect(Collectors.toList()); orgs = orgs.stream().filter(t->parentOrgIds.contains(t.getId())).collect(Collectors.toList());
Set<String> ancestorsOrgIdList = new HashSet<>(); Set<String> ancestorsOrgIdList = new HashSet<>();
......
...@@ -35,6 +35,7 @@ import com.makeit.service.platform.space.PlatRegionSettingService; ...@@ -35,6 +35,7 @@ import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.saas.PlatTenantService; import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil; import com.makeit.utils.DeviceCacheUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils; import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.data.convert.PageUtil; import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil; import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils; import com.makeit.utils.old.StringUtils;
...@@ -210,12 +211,16 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -210,12 +211,16 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
platDeviceOtherService.saveOrUpdate(other); platDeviceOtherService.saveOrUpdate(other);
if(StringUtils.isNotEmpty(other.getAttribute())){
PlatDeviceAttrWechatDTO deviceAttrWechatDTO = JsonUtil.toObj(other.getAttribute(),PlatDeviceAttrWechatDTO.class);
//更新区域设置设备安装方式 //更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda() platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, other.getInstallation()) .set(PlatRegionSetting::getInstallType, deviceAttrWechatDTO.getRadarMount())
.eq(PlatRegionSetting::getDeviceId, other.getDeviceId())); .eq(PlatRegionSetting::getDeviceId, other.getDeviceId()));
} }
}
@Override @Override
public PageVO<PlatDeviceListVO> pageSaas(PageReqDTO<PlatDevice> pageReqDTO) { public PageVO<PlatDeviceListVO> pageSaas(PageReqDTO<PlatDevice> pageReqDTO) {
PlatDevice param = pageReqDTO.getData(); PlatDevice param = pageReqDTO.getData();
...@@ -292,6 +297,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -292,6 +297,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
public void editDeviceProperties(PlatDeviceAttrWechatDTO dto) { public void editDeviceProperties(PlatDeviceAttrWechatDTO dto) {
devicePropertiesOperateService.deviceWrite(dto.getDeviceId(),dto.getRadarMount(),dto.getRadarMode(),dto.getRadarHight()); devicePropertiesOperateService.deviceWrite(dto.getDeviceId(),dto.getRadarMount(),dto.getRadarMode(),dto.getRadarHight());
//更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, dto.getRadarMount())
.eq(PlatRegionSetting::getDeviceId, dto.getDeviceId()));
} }
@Override @Override
......
...@@ -49,4 +49,5 @@ public interface PlatElderDayReportDayService { ...@@ -49,4 +49,5 @@ public interface PlatElderDayReportDayService {
List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO); List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO);
void elderCoordinateListAnalysisTask();
} }
...@@ -13,7 +13,6 @@ import com.makeit.module.iot.enums.DeviceInfoContentFallEnum; ...@@ -13,7 +13,6 @@ import com.makeit.module.iot.enums.DeviceInfoContentFallEnum;
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;
import com.makeit.module.iot.vo.space.DeviceInfoContentSpace;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.alarm.PlatDayDurationRecordService; import com.makeit.service.platform.alarm.PlatDayDurationRecordService;
import com.makeit.service.platform.elder.*; import com.makeit.service.platform.elder.*;
...@@ -26,11 +25,11 @@ import com.makeit.utils.time.LocalDateTimeUtils; ...@@ -26,11 +25,11 @@ import com.makeit.utils.time.LocalDateTimeUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*; import com.makeit.vo.platform.elder.report.day.*;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
...@@ -353,7 +352,45 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -353,7 +352,45 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
} }
@Override @Override
public void elderCoordinateListAnalysisTask() {
}
@Override
public List<PlatElderCoordinateVO> coordinateList(String elderId, String deviceId, LocalDateTime start, LocalDateTime end) { public List<PlatElderCoordinateVO> coordinateList(String elderId, String deviceId, LocalDateTime start, LocalDateTime end) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
// TODO 暂时为假数据
int count = 20;
for (PlatDevice platDevice : platDeviceList) {
for (int i = 0; i < count; i++) {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
int distance = RandomUtils.nextInt(1, 1000);
int angle = RandomUtils.nextInt(1,180) -120;
// vo.setX(new BigDecimal(distance).multiply(new BigDecimal(Math.cos(angle) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(distance).multiply(new BigDecimal(Math.sin(angle) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setDistance(distance);
vo.setAngle(angle);
vo.setDeviceId(platDevice.getId());
vo.setOriDeviceId(platDevice.getOriDeviceId());
voList.add(vo);
}
}
return voList;
/*
List<PlatDevice> platDeviceListSpace = platElderRealTimeService.getSpaceDevice(elderId, deviceId); List<PlatDevice> platDeviceListSpace = platElderRealTimeService.getSpaceDevice(elderId, deviceId);
List<PlatDevice> platDeviceListFall = platElderRealTimeService.getFallDevice(elderId, deviceId); List<PlatDevice> platDeviceListFall = platElderRealTimeService.getFallDevice(elderId, deviceId);
...@@ -365,7 +402,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -365,7 +402,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
List<PlatElderCoordinateVO> voList = new ArrayList<>(10); List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
platDeviceListSpace.forEach(e -> { platDeviceListSpace.forEach(e -> {
List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 2 * 24 * 3600, start, end); List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 24 * 3600, start, end);
voList.addAll(StreamUtil.map(spaceList, i -> { voList.addAll(StreamUtil.map(spaceList, i -> {
...@@ -407,6 +444,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -407,6 +444,7 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
}); });
return voList; return voList;
*/
} }
@Override @Override
......
...@@ -150,9 +150,13 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -150,9 +150,13 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
public PlatElderComprehensiveEvaluationVO comprehensiveEvaluationInternal(PlatElderSleepEvaluationVO platElderSleepEvaluationVO, PlatElderHeartRespiratoryEvaluationVO platElderHeartRespiratoryEvaluationVO) { public PlatElderComprehensiveEvaluationVO comprehensiveEvaluationInternal(PlatElderSleepEvaluationVO platElderSleepEvaluationVO, PlatElderHeartRespiratoryEvaluationVO platElderHeartRespiratoryEvaluationVO) {
PlatElderComprehensiveEvaluationVO platElderComprehensiveEvaluationVO = new PlatElderComprehensiveEvaluationVO(); PlatElderComprehensiveEvaluationVO platElderComprehensiveEvaluationVO = new PlatElderComprehensiveEvaluationVO();
platElderComprehensiveEvaluationVO.setScore((platElderSleepEvaluationVO.getScore() + platElderHeartRespiratoryEvaluationVO.getScore()) / 2); int sleepScore = 0;
if (platElderSleepEvaluationVO != null) {
sleepScore = platElderSleepEvaluationVO.getScore();
}
platElderComprehensiveEvaluationVO.setScore((sleepScore + platElderHeartRespiratoryEvaluationVO.getScore()) / 2);
EvaluateReportVO evaluateReportVO = saasElderReportConfigService.getByScore(platElderSleepEvaluationVO.getScore()); EvaluateReportVO evaluateReportVO = saasElderReportConfigService.getByScore(sleepScore);
if (evaluateReportVO != null) { if (evaluateReportVO != null) {
platElderComprehensiveEvaluationVO.setEvaluation(evaluateReportVO.getEvaluate()); platElderComprehensiveEvaluationVO.setEvaluation(evaluateReportVO.getEvaluate());
} }
......
...@@ -6,7 +6,6 @@ import com.makeit.common.entity.BaseEntity; ...@@ -6,7 +6,6 @@ import com.makeit.common.entity.BaseEntity;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel; import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport;
import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum; 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;
...@@ -29,8 +28,9 @@ import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; ...@@ -29,8 +28,9 @@ import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import io.swagger.models.auth.In; import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -58,6 +58,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -58,6 +58,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
public static final String ELDER_STATUS = "plat:elder:status:"; public static final String ELDER_STATUS = "plat:elder:status:";
public static final String ELDER_BR_HR = "plat:elder:brHr:";
public static final String ELDER_MOVE = "plat:elder:move:";
@Autowired @Autowired
private PlatElderService platElderService; private PlatElderService platElderService;
...@@ -72,6 +75,8 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -72,6 +75,8 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Autowired @Autowired
private SaasSleepAnalysisModelService saasSleepAnalysisModelService; private SaasSleepAnalysisModelService saasSleepAnalysisModelService;
@Autowired
private StringRedisTemplate redisTemplate;
@Override @Override
public PlatDevice getBreathDevice(String elderId, String deviceId) { public PlatDevice getBreathDevice(String elderId, String deviceId) {
...@@ -317,35 +322,77 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -317,35 +322,77 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Override @Override
public PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO) { public PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId()); String result = redisTemplate.opsForList().rightPop(ELDER_BR_HR + platElderIdDTO.getElderId());
if (result != null) {
return JSON.parseObject(result,PlatElderRealTimeHeartRespiratoryVO.class);
}
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (deviceInfoContentBreathe == null) {
return new PlatElderRealTimeHeartRespiratoryVO();
}
int count = 10;
int heartRate = deviceInfoContentBreathe.getProperties().getHr();
int respiratoryRate = deviceInfoContentBreathe.getProperties().getBr();
for (int i = 0; i < count; i++) {
PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO();
platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now().plusSeconds(i));
if (i ==0) {
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);
}
redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO));
}
return JSON.parseObject(redisTemplate.opsForList().rightPop(ELDER_BR_HR + platElderIdDTO.getElderId()),PlatElderRealTimeHeartRespiratoryVO.class);
/*
PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO(); PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO();
platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now()); platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now());
if (deviceInfoContentBreathe == null) {
return platElderRealTimeHeartRespiratoryVO;
}
platElderRealTimeHeartRespiratoryVO.setHeartRate(deviceInfoContentBreathe.getProperties().getHr()); platElderRealTimeHeartRespiratoryVO.setHeartRate(deviceInfoContentBreathe.getProperties().getHr());
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr()); platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr());*/
return platElderRealTimeHeartRespiratoryVO; //return platElderRealTimeHeartRespiratoryVO;
} }
@Override @Override
public PlatElderRealTimeBodyVO body(PlatElderIdDTO platElderIdDTO) { public PlatElderRealTimeBodyVO body(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId()); String result = redisTemplate.opsForList().rightPop(ELDER_MOVE + platElderIdDTO.getElderId());
if (result != null) {
return JSON.parseObject(result,PlatElderRealTimeBodyVO.class);
}
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (deviceInfoContentBreathe == null) {
return new PlatElderRealTimeBodyVO();
}
int count = 10;
int body = deviceInfoContentBreathe.getProperties().getBodymove();
for (int i = 0; i < count; i++) {
PlatElderRealTimeBodyVO platElderRealTimeBodyVO = new PlatElderRealTimeBodyVO(); PlatElderRealTimeBodyVO platElderRealTimeBodyVO = new PlatElderRealTimeBodyVO();
platElderRealTimeBodyVO.setTime(LocalDateTime.now().plusSeconds(i));
if (i ==0) {
platElderRealTimeBodyVO.setBodyMovementIndex(body);
} 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));
}
return JSON.parseObject(redisTemplate.opsForList().rightPop(ELDER_MOVE + platElderIdDTO.getElderId()),PlatElderRealTimeBodyVO.class);
/*PlatElderRealTimeBodyVO platElderRealTimeBodyVO = new PlatElderRealTimeBodyVO();
platElderRealTimeBodyVO.setTime(LocalDateTime.now()); platElderRealTimeBodyVO.setTime(LocalDateTime.now());
if (deviceInfoContentBreathe == null) {
return platElderRealTimeBodyVO;
}
platElderRealTimeBodyVO.setBodyMovementIndex(deviceInfoContentBreathe.getProperties().getBodymove()); platElderRealTimeBodyVO.setBodyMovementIndex(deviceInfoContentBreathe.getProperties().getBodymove());
return platElderRealTimeBodyVO; return platElderRealTimeBodyVO;*/
} }
......
...@@ -3,7 +3,8 @@ package com.makeit.vo.platform.auth; ...@@ -3,7 +3,8 @@ package com.makeit.vo.platform.auth;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.makeit.common.dto.BaseIdDTO; import com.makeit.common.dto.BaseTenantDTO;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.module.admin.dto.plat.PlatRoleDTOVO; import com.makeit.module.admin.dto.plat.PlatRoleDTOVO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -17,7 +18,7 @@ import java.util.List; ...@@ -17,7 +18,7 @@ import java.util.List;
@ApiModel("租户账号 新增 编辑 详情") @ApiModel("租户账号 新增 编辑 详情")
@Data @Data
public class PlatPersonDTOVO extends BaseIdDTO { public class PlatPersonDTOVO extends BaseTenantDTO {
@NotBlank(message = "用户名不能为空") @NotBlank(message = "用户名不能为空")
@Size(max = 64, message = "用户名最长为64字符") @Size(max = 64, message = "用户名最长为64字符")
...@@ -92,6 +93,9 @@ public class PlatPersonDTOVO extends BaseIdDTO { ...@@ -92,6 +93,9 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "角色名称,逗号拼接") @ApiModelProperty(value = "角色名称,逗号拼接")
private String roleNameJoin; private String roleNameJoin;
@ApiModelProperty(value = "租户信息")
private PlatTenant platTenant;
} }
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