ProphaseAnemometryDataServiceImpl.java 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package com.jiayue.biz.service.impl;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.jiayue.biz.domain.ProphaseAnemometryData;
  7. import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
  8. import com.jiayue.biz.service.ProphaseAnemometryDataService;
  9. import lombok.AllArgsConstructor;
  10. import org.apache.ibatis.annotations.Param;
  11. import org.apache.ibatis.annotations.Select;
  12. import org.springframework.stereotype.Service;
  13. import java.sql.Timestamp;
  14. import java.util.Date;
  15. import java.util.List;
  16. import java.util.stream.Collectors;
  17. @Service
  18. @AllArgsConstructor
  19. public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemometryDataMapper, ProphaseAnemometryData> implements ProphaseAnemometryDataService {
  20. //查询风时间段内所有数据
  21. public List<ProphaseAnemometryData> selectWsAndWdForTime(String equipmentId, Date startTime, Date endTime) {
  22. return list(this.lambdaQueryWrapper(equipmentId, startTime, endTime));
  23. }
  24. private LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper(String equipmentId, Date startTime, Date endTime) {
  25. LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper = Wrappers.lambdaQuery();
  26. if (StrUtil.isNotBlank(equipmentId)) {
  27. lambdaQueryWrapper.eq(ProphaseAnemometryData::getEquipmentId, equipmentId);
  28. }
  29. if (startTime != null && endTime != null) {
  30. lambdaQueryWrapper.ge(ProphaseAnemometryData::getTs, new Timestamp(startTime.getTime()));
  31. lambdaQueryWrapper.le(ProphaseAnemometryData::getTs, new Timestamp(endTime.getTime()));
  32. }
  33. return lambdaQueryWrapper;
  34. }
  35. //单条插入
  36. public int insertOneWithNew(ProphaseAnemometryData one) {
  37. return baseMapper.insertOneWithNew(one);
  38. }
  39. //查询所有数据
  40. public List<ProphaseAnemometryData> selectAll(String equipmentId, Timestamp startTime, Timestamp endTime) {
  41. return baseMapper.selectAll(equipmentId, startTime, endTime);
  42. }
  43. //所有层高风速风向平均值
  44. public List<ProphaseAnemometryData> selectAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
  45. return baseMapper.selectAve(equipmentId, startTime, endTime);
  46. }
  47. //查询所有层高风速以及风速标差
  48. public List<ProphaseAnemometryData> selectAveAndSta(String equipmentId, Timestamp startTime, Timestamp endTime) {
  49. return this.filterData(baseMapper.selectAveAndSta(equipmentId, startTime, endTime));
  50. }
  51. //查询所有层高风速
  52. public List<ProphaseAnemometryData> selectWsAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
  53. return this.filterData(baseMapper.selectWsAve(equipmentId, startTime, endTime));
  54. }
  55. //根据层高和设备编号查询风速
  56. public List<ProphaseAnemometryData> selectWsAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
  57. return this.filterData(baseMapper.selectWsAveForHeight(equipmentId, startTime, endTime, height));
  58. }
  59. //根据层高和设备编号查询风向
  60. public List<ProphaseAnemometryData> selectWdAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
  61. return baseMapper.selectWdAveForHeight(equipmentId, startTime, endTime, height);
  62. }
  63. //根据层高和设备编号查询风向、风速、标差
  64. public List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsStaForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
  65. return this.filterData(baseMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, startTime, endTime, height));
  66. }
  67. //查询设备编号查询所有层高风向 风速 风速标差
  68. public List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsSta(String equipmentId, Timestamp startTime, Timestamp endTime) {
  69. return this.filterData(baseMapper.selectWdAveAndWdAveAndWsSta(equipmentId, startTime, endTime));
  70. }
  71. //过滤
  72. public List<ProphaseAnemometryData> filterData(List<ProphaseAnemometryData> prophaseAnemometryData) {
  73. return prophaseAnemometryData.stream().filter(p -> p.getWsAve() != null && p.getWsAve() < 50 && p.getWsSta() != null && p.getWsSta() < 10).collect(Collectors.toList());
  74. }
  75. }