package com.jiayue.biz.mapper; import cn.hutool.db.Entity; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.jiayue.biz.domain.ProphaseAnemometryData; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.sql.Timestamp; import java.util.List; import java.util.Map; /** * ProphaseAnemometryDataMapper * * @author L.ym * @date 2023-03-14 **/ @DS("tdengine") public interface ProphaseAnemometryDataMapper extends BaseMapper { //单条插入 @Insert("INSERT INTO anemometry_${equipmentId}_${layerHeight} USING prophase_anemometry_data TAGS(#{equipmentId}, #{layerHeight}) VALUES(#{ts}, #{wsInst}, #{wsMax}, #{wsMin}, #{wsAve}, #{wsGust}, #{wsSta}, #{wdInst}, #{wdMax}, #{wdMin}, #{wdAve}, #{wdSta})") int insertOneWithNew(ProphaseAnemometryData one); //批量插入 @Insert("") int insertSplice(@Param("prophaseAnemometryData") List prophaseAnemometryData,@Param("equipmentId") String equipmentId,@Param("layerHeight") String layerHeight); //所有层高风速风向平均值 @Select("SELECT * FROM prophase_anemometry_data t1 where t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectAll(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); //所有层高风速风向平均值 @Select("SELECT t1.ts,t1.ws_ave,t1.wd_ave,t1.layer_height FROM prophase_anemometry_data t1 where t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectAve(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); //查询所有层高风速以及风速标差 @Select("SELECT t1.ts,t1.ws_ave,t1.ws_sta,t1.layer_height FROM prophase_anemometry_data t1 where t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectAveAndSta(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); //查询所有层高风速 @Select("SELECT t1.ts,t1.ws_ave,t1.layer_height FROM prophase_anemometry_data t1 where t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectWsAve(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); //根据层高和设备编号查询风速 @Select("SELECT t1.ts,t1.ws_ave FROM prophase_anemometry_data t1 where t1.layer_height = #{height} and t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectWsAveForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height); //根据层高和设备编号查询风向 @Select("SELECT t1.ts,t1.wd_ave FROM prophase_anemometry_data t1 where t1.layer_height = #{height} and t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectWdAveForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height); //根据层高和设备编号查询风向、风速、标差 @Select("SELECT t1.ts,t1.ws_ave,t1.ws_sta,t1.wd_ave FROM prophase_anemometry_data t1 where t1.layer_height = #{height} and t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectWdAveAndWdAveAndWsStaForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height); //查询设备编号查询所有层高风向 风速 风速标差 @Select("SELECT t1.ts,t1.ws_ave,t1.ws_sta,t1.wd_ave,t1.layer_height FROM prophase_anemometry_data t1 where t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}") List selectWdAveAndWdAveAndWsSta(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); @Select("delete from anemometry_${equipmentId}_${height} where ts >= #{startTime} and ts <= #{endTime}") void deleteByLayerHeightAndEquipmentId(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height); @Select("drop table if exists anemometry_${equipmentId}_${height}") void deleteTable(@Param("equipmentId") String equipmentId,@Param("height") String height); }