ProphaseAnemometryDataMapper.java 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.jiayue.biz.mapper;
  2. import cn.hutool.db.Entity;
  3. import com.baomidou.dynamic.datasource.annotation.DS;
  4. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5. import com.jiayue.biz.domain.ProphaseAnemometryData;
  6. import org.apache.ibatis.annotations.Insert;
  7. import org.apache.ibatis.annotations.Param;
  8. import org.apache.ibatis.annotations.Select;
  9. import java.sql.Timestamp;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * ProphaseAnemometryDataMapper
  14. *
  15. * @author L.ym
  16. * @date 2023-03-14
  17. **/
  18. @DS("tdengine")
  19. public interface ProphaseAnemometryDataMapper extends BaseMapper<ProphaseAnemometryData> {
  20. //单条插入
  21. @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})")
  22. int insertOneWithNew(ProphaseAnemometryData one);
  23. //批量插入
  24. @Insert("<script>" +
  25. "insert into anemometry_${equipmentId}_${layerHeight} USING prophase_anemometry_data TAGS(#{equipmentId}, #{layerHeight}) values " +
  26. "<foreach collection='prophaseAnemometryData' item='p' separator=','> " +
  27. "(#{p.ts},#{p.wsInst},#{p.wsMax},#{p.wsMin},#{p.wsAve},#{p.wsGust},#{p.wsSta},#{p.wdInst},#{p.wdMax},#{p.wdMin},#{p.wdAve},#{p.wdSta}) " +
  28. "</foreach> " +
  29. "</script>")
  30. int insertSplice(@Param("prophaseAnemometryData") List<ProphaseAnemometryData> prophaseAnemometryData,@Param("equipmentId") String equipmentId,@Param("layerHeight") String layerHeight);
  31. //所有层高风速风向平均值
  32. @Select("SELECT * FROM prophase_anemometry_data t1 where t1.equipment_id = #{equipmentId} and t1.ts >= #{startTime} and t1.ts <= #{endTime}")
  33. List<ProphaseAnemometryData> selectAll(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
  34. //所有层高风速风向平均值
  35. @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}")
  36. List<ProphaseAnemometryData> selectAve(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
  37. //查询所有层高风速以及风速标差
  38. @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}")
  39. List<ProphaseAnemometryData> selectAveAndSta(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
  40. //查询所有层高风速
  41. @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}")
  42. List<ProphaseAnemometryData> selectWsAve(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
  43. //根据层高和设备编号查询风速
  44. @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}")
  45. List<ProphaseAnemometryData> selectWsAveForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height);
  46. //根据层高和设备编号查询风向
  47. @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}")
  48. List<ProphaseAnemometryData> selectWdAveForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height);
  49. //根据层高和设备编号查询风向、风速、标差
  50. @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}")
  51. List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsStaForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height);
  52. //查询设备编号查询所有层高风向 风速 风速标差
  53. @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}")
  54. List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsSta(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
  55. @Select("delete from anemometry_${equipmentId}_${height} where ts >= #{startTime} and ts <= #{endTime}")
  56. void deleteByLayerHeightAndEquipmentId(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height);
  57. @Select("drop table if exists anemometry_${equipmentId}_${height}")
  58. void deleteTable(@Param("equipmentId") String equipmentId,@Param("height") String height);
  59. }