Commit 1d18956b by 杨林龙

1.50.0 开发1.50.0需求版本

1 parent f6ed55de
...@@ -387,33 +387,31 @@ public class RiskAssessmentService { ...@@ -387,33 +387,31 @@ public class RiskAssessmentService {
// 通过车辆ID获取设备主有线设备 // 通过车辆ID获取设备主有线设备
List<BasicDeviceDTO> basicDeviceDTOList = vehicleDeviceMapper.selectBindDeviceByVehicleIdOrderByCreatedDate(vehicleId); List<BasicDeviceDTO> basicDeviceDTOList = vehicleDeviceMapper.selectBindDeviceByVehicleIdOrderByCreatedDate(vehicleId);
Optional<BasicDeviceDTO> basicDeviceDTO = basicDeviceDTOList.stream().filter(dto -> TypeConverseEnum.SourceEnum.HAS_SOURCE.getSourceType().equals(dto.getSource())).findFirst(); Optional<BasicDeviceDTO> basicDeviceDTO = basicDeviceDTOList.stream().filter(dto -> TypeConverseEnum.SourceEnum.HAS_SOURCE.getSourceType().equals(dto.getSource())).findFirst();
basicDeviceDTO.orElseGet(() -> {
log.warn("该车辆绑定的主设备不存在");
throw new AdminException("该车辆绑定的主设备不存在");
});
// 获取主设备
String sn = basicDeviceDTO.get().getSn();
UserBehaviorInformationVO userBehaviorInformationVO = new UserBehaviorInformationVO(); UserBehaviorInformationVO userBehaviorInformationVO = new UserBehaviorInformationVO();
List<UserBehaviorWeekDTO> userBehaviorWeekDTOList = deviceJourneyMapper.statisticsDeviceJourneyWithWeek(sn); if (basicDeviceDTO.isPresent()) {
// 获取最大的周数 // 获取主设备
Integer maxWeekNum = userBehaviorWeekDTOList.stream().map(UserBehaviorWeekDTO::getWeekNum).max(Integer::compareTo).orElse(0); String sn = basicDeviceDTO.get().getSn();
// 获取最小的周数 List<UserBehaviorWeekDTO> userBehaviorWeekDTOList = deviceJourneyMapper.statisticsDeviceJourneyWithWeek(sn);
Integer minWeekNum = userBehaviorWeekDTOList.stream().map(UserBehaviorWeekDTO::getWeekNum).min(Integer::compareTo).orElse(0); // 获取最大的周数
// 如果数据不满一周 则按照每日数量进行统计 Integer maxWeekNum = userBehaviorWeekDTOList.stream().map(UserBehaviorWeekDTO::getWeekNum).max(Integer::compareTo).orElse(0);
if (Objects.equals(maxWeekNum, minWeekNum)) { // 获取最小的周数
userBehaviorInformationVO.setStatisticsType(2); Integer minWeekNum = userBehaviorWeekDTOList.stream().map(UserBehaviorWeekDTO::getWeekNum).min(Integer::compareTo).orElse(0);
List<UserBehaviorDayDTO> userBehaviorDayDTOList = deviceJourneyMapper.statisticsDeviceJourneyWithDay(sn); // 如果数据不满一周 则按照每日数量进行统计
userBehaviorInformationVO.setUserBehaviorDayDTOList(userBehaviorDayDTOList); if (Objects.equals(maxWeekNum, minWeekNum)) {
return userBehaviorInformationVO; userBehaviorInformationVO.setStatisticsType(2);
} List<UserBehaviorDayDTO> userBehaviorDayDTOList = deviceJourneyMapper.statisticsDeviceJourneyWithDay(sn);
userBehaviorInformationVO.setUserBehaviorDayDTOList(userBehaviorDayDTOList);
return userBehaviorInformationVO;
}
// 如果最多的周数减去18周 和最小的周进行对比 // 如果最多的周数减去18周 和最小的周进行对比
userBehaviorInformationVO.setStatisticsType(2); userBehaviorInformationVO.setStatisticsType(2);
int num = maxWeekNum - 18; int num = maxWeekNum - 18;
if (num < minWeekNum) { if (num < minWeekNum) {
userBehaviorInformationVO.setUserBehaviorWeekDTOList(userBehaviorWeekDTOList); userBehaviorInformationVO.setUserBehaviorWeekDTOList(userBehaviorWeekDTOList);
} else { } else {
userBehaviorInformationVO.setUserBehaviorWeekDTOList(userBehaviorWeekDTOList.stream().filter(vo -> vo.getWeekNum() >= num).collect(Collectors.toList())); userBehaviorInformationVO.setUserBehaviorWeekDTOList(userBehaviorWeekDTOList.stream().filter(vo -> vo.getWeekNum() >= num).collect(Collectors.toList()));
}
} }
return userBehaviorInformationVO; return userBehaviorInformationVO;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!