12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package com.jiayue.biz.service.impl;
- import cn.hutool.core.util.StrUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.jiayue.biz.domain.ProphaseAnemometryData;
- import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
- import com.jiayue.biz.service.ProphaseAnemometryDataService;
- import lombok.AllArgsConstructor;
- import org.apache.ibatis.annotations.Param;
- import org.apache.ibatis.annotations.Select;
- import org.springframework.stereotype.Service;
- import java.sql.Timestamp;
- import java.util.Date;
- import java.util.List;
- import java.util.stream.Collectors;
- @Service
- @AllArgsConstructor
- public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemometryDataMapper, ProphaseAnemometryData> implements ProphaseAnemometryDataService {
- //查询风时间段内所有数据
- public List<ProphaseAnemometryData> selectWsAndWdForTime(String equipmentId, Date startTime, Date endTime) {
- return list(this.lambdaQueryWrapper(equipmentId, startTime, endTime));
- }
- private LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper(String equipmentId, Date startTime, Date endTime) {
- LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper = Wrappers.lambdaQuery();
- if (StrUtil.isNotBlank(equipmentId)) {
- lambdaQueryWrapper.eq(ProphaseAnemometryData::getEquipmentId, equipmentId);
- }
- if (startTime != null && endTime != null) {
- lambdaQueryWrapper.ge(ProphaseAnemometryData::getTs, new Timestamp(startTime.getTime()));
- lambdaQueryWrapper.le(ProphaseAnemometryData::getTs, new Timestamp(endTime.getTime()));
- }
- return lambdaQueryWrapper;
- }
- //单条插入
- public int insertOneWithNew(ProphaseAnemometryData one) {
- return baseMapper.insertOneWithNew(one);
- }
- //查询所有数据
- public List<ProphaseAnemometryData> selectAll(String equipmentId, Timestamp startTime, Timestamp endTime) {
- return baseMapper.selectAll(equipmentId, startTime, endTime);
- }
- //所有层高风速风向平均值
- public List<ProphaseAnemometryData> selectAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
- return baseMapper.selectAve(equipmentId, startTime, endTime);
- }
- //查询所有层高风速以及风速标差
- public List<ProphaseAnemometryData> selectAveAndSta(String equipmentId, Timestamp startTime, Timestamp endTime) {
- return this.filterData(baseMapper.selectAveAndSta(equipmentId, startTime, endTime));
- }
- //查询所有层高风速
- public List<ProphaseAnemometryData> selectWsAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
- return this.filterData(baseMapper.selectWsAve(equipmentId, startTime, endTime));
- }
- //根据层高和设备编号查询风速
- public List<ProphaseAnemometryData> selectWsAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
- return this.filterData(baseMapper.selectWsAveForHeight(equipmentId, startTime, endTime, height));
- }
- //根据层高和设备编号查询风向
- public List<ProphaseAnemometryData> selectWdAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
- return baseMapper.selectWdAveForHeight(equipmentId, startTime, endTime, height);
- }
- //根据层高和设备编号查询风向、风速、标差
- public List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsStaForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
- return this.filterData(baseMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, startTime, endTime, height));
- }
- //查询设备编号查询所有层高风向 风速 风速标差
- public List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsSta(String equipmentId, Timestamp startTime, Timestamp endTime) {
- return this.filterData(baseMapper.selectWdAveAndWdAveAndWsSta(equipmentId, startTime, endTime));
- }
- //过滤
- public List<ProphaseAnemometryData> filterData(List<ProphaseAnemometryData> prophaseAnemometryData) {
- return prophaseAnemometryData.stream().filter(p -> p.getWsAve() != null && p.getWsAve() < 50 && p.getWsSta() != null && p.getWsSta() < 10).collect(Collectors.toList());
- }
- }
|