Commit dc8106e9 by 朱淼
parents d8216f22 b4f4d28d
......@@ -10,7 +10,6 @@ import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.entity.platform.space.PlatSpace;
......@@ -46,7 +45,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -436,8 +434,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
if (CollectionUtils.isEmpty(roleOrgList)) {
return new HashSet<>();
}
List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList()));
return roleList.stream().flatMap(vo -> Stream.of(Optional.ofNullable(vo.getDataScope()).orElse(new String()) .split(","))).collect(Collectors.toSet());
return roleOrgList.stream().map(PlatRoleOrg::getOrgId).collect(Collectors.toSet());
// List<PlatRole> roleList = platRoleService.listByIds(roleOrgList.stream().map(PlatRoleOrg::getRoleId).collect(Collectors.toList()));
// return roleList.stream().flatMap(vo -> Stream.of(Optional.ofNullable(vo.getDataScope()).orElse(new String()) .split(","))).collect(Collectors.toSet());
}
/**
* 租户权限的组织树
......
......@@ -9,6 +9,7 @@ import com.makeit.entity.platform.elder.PlatElderBreatheDayStat;
import com.makeit.entity.platform.elder.PlatElderSleep;
import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.report.SleepTypeEnum;
import com.makeit.module.iot.vo.analysis.EvaluateReportVO;
import com.makeit.service.platform.elder.*;
import com.makeit.service.saas.SaasDiseaseReportService;
......@@ -29,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.DayOfWeek;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
......@@ -36,6 +38,7 @@ import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
......@@ -207,6 +210,13 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
}
private long duration(DateTimeFormatter dateTimeFormatter, String start, String end) {//分钟
LocalDateTime s = LocalDateTime.parse(start, dateTimeFormatter);
LocalDateTime e = LocalDateTime.parse(end, dateTimeFormatter);
return Duration.between(s, e).toMinutes();
}
@Override
public PlatElderSleepDiagramWeekVO sleepDiagram(PlatElderReportDTO platElderIdDTO) {
......@@ -233,16 +243,20 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
List<LocalDate> dateList = LocalDateTimeUtils.getDateSeries(weekStartDate, weekEndDate);
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<PlatElderSleepDiagramWeekContentVO> sleep = StreamUtil.map(dateList, e -> {
PlatElderSleepDiagramWeekContentVO vo = new PlatElderSleepDiagramWeekContentVO();
vo.setDay(e);
// List<PlatElderSleep> list =
//
// vo.setSleepDeepDuration();
// vo.setSleepModerateDuration();
// vo.setSleepLightnessDuration();
// vo.setSoberDuration();
List<PlatElderSleep> list = Optional.ofNullable(sleepMap.get(1)).map(i -> i.get(dateTimeFormatter.format(e))).orElse(new ArrayList<>(10));
List<PlatSleepRangeVO> sleepRecord = list.stream().flatMap(i -> i.getSleepRecord().stream()).collect(Collectors.toList());
vo.setSleepDeepDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_DEEP.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepModerateDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_MODERATE.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepLightnessDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_LIGHTNESS.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSoberDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SOBER.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
PlatElderSleepAnalysis platElderSleepAnalysis = sleepAnalysisMap.get(dateTimeFormatter.format(e));
......
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