|
@@ -0,0 +1,135 @@
|
|
|
+package com.gyee.alarm.mapper.auto;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
+import com.gyee.alarm.model.auto.AlarmTs;
|
|
|
+import com.gyee.alarm.model.vo.AlarmTsVo;
|
|
|
+import com.gyee.alarm.model.vo.AlarmVo;
|
|
|
+import org.apache.ibatis.annotations.Insert;
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
+import org.apache.ibatis.annotations.Select;
|
|
|
+import org.apache.ibatis.annotations.Update;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+@DS("slave")
|
|
|
+public interface AlarmTsMapper extends BaseMapper<AlarmTs> {
|
|
|
+
|
|
|
+
|
|
|
+ @Update("CREATE STABLE if not exists ${superTableName} (ts TIMESTAMP,val INT,oval INT,confirmed BOOL) " +
|
|
|
+ "TAGS (alarmid NCHAR(100),alarmtype NCHAR(50),characteristic NCHAR(50)," +
|
|
|
+ "components NCHAR(50),description NCHAR(500),deviceid NCHAR(50),devicename NCHAR(70)," +
|
|
|
+ "devicetype NCHAR(50),enabled BOOL,lineid NCHAR(50),linename NCHAR(70),modelId NCHAR(50),projectid NCHAR(50)," +
|
|
|
+ "projectname NCHAR(70),rank INT,resettable BOOL,stationid NCHAR(50),stationname NCHAR(70),subcomponents NCHAR(50)," +
|
|
|
+ "suffix NCHAR(50),tagid NCHAR(100),triggertype INT,uniformcode NCHAR(50));")
|
|
|
+ int createAlarmSuperTable(@Param("superTableName") String superTableName);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Update("create table if not exists ${tbName} using ${superTableName} tags( #{alarmid}, #{alarmtype}," +
|
|
|
+ "#{characteristic}, #{components}, #{description}, #{deviceid}, #{devicename}," +
|
|
|
+ "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
|
|
|
+ "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
|
|
|
+ "#{suffix}, #{tagid}, #{triggertype}, #{uniformcode}" +
|
|
|
+ ")")
|
|
|
+ int createTable(@Param("tbName") String tbName, @Param("alarmid") String alarmid, @Param("alarmtype") String alarmtype,
|
|
|
+ @Param("characteristic") String characteristic, @Param("components") String components,
|
|
|
+ @Param("description") String description,
|
|
|
+ @Param("deviceid") String deviceid, @Param("devicename") String devicename,
|
|
|
+ @Param("devicetype") String devicetype, @Param("enabled") Boolean enabled,
|
|
|
+ @Param("lineid") String lineid, @Param("linename") String linename,
|
|
|
+ @Param("modelId") String modelId, @Param("projectid") String projectid,
|
|
|
+ @Param("projectname") String projectname, @Param("rank") Integer rank,
|
|
|
+ @Param("resettable") Boolean resettable, @Param("stationid") String stationid,
|
|
|
+ @Param("stationname") String stationname, @Param("subcomponents") String subcomponents,
|
|
|
+ @Param("suffix") String suffix, @Param("tagid") String tagid,
|
|
|
+ @Param("triggertype") Integer triggertype, @Param("uniformcode") String uniformcode, @Param("superTableName") String superTableName
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Update("create table if not exists ${tbName} using ${superTableName} tags( #{alarmid}, #{alarmtype}," +
|
|
|
+ "#{characteristic}, #{components}, #{description}, #{deviceid}, #{devicename}," +
|
|
|
+ "#{devicetype}, #{enabled}, #{lineid}, #{linename}, #{modelId}, #{projectid}," +
|
|
|
+ "#{projectname}, #{rank}, #{resettable}, #{stationid}, #{stationname}, #{subcomponents}," +
|
|
|
+ "#{suffix}, #{tagid}, #{triggertype}, #{uniformcode}" +
|
|
|
+ ")")
|
|
|
+ int createTable(AlarmVo vo);
|
|
|
+
|
|
|
+ @Update("drop table if exists ${superTableName}")
|
|
|
+ void dropSuperTable(@Param("superTableName")String superTableName);
|
|
|
+
|
|
|
+ @Insert("insert into ${tbName} (ts, val,oval,confirmed) values(#{ts}, #{val}, #{oval}, #{confirmed})")
|
|
|
+ int insertOne(AlarmTs one);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Insert("${sql}")
|
|
|
+ int insertList(@Param("sql") String sql);
|
|
|
+
|
|
|
+ @Select("select last_row(*),alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
|
|
|
+ "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{stbaleName} group by tbname")
|
|
|
+ List<AlarmVo> findTags(@Param("stbaleName") String stbaleName);
|
|
|
+
|
|
|
+
|
|
|
+ @Select("select deviceid,description,count(*) as val from #{superTableName} where ts>=#{begin} and ts<=#{end} stationid=#{stationid} group by description,deviceid ")
|
|
|
+ List<AlarmTsVo> selectByWpGroup(@Param("superTableName") String superTableName, @Param("stationid") String stationid, @Param("begin")long begin, @Param("end") long end);
|
|
|
+
|
|
|
+
|
|
|
+ @Select("select ts,val,oval,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
|
|
|
+ "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{tbName} limit #{limit} , #{offset} ")
|
|
|
+ List<AlarmVo> selectByTbName(@Param("tbName") String tbName,@Param("limit") long limit,@Param("offset") long offset);
|
|
|
+
|
|
|
+ @Select("select alarmid,description,count(*) as val,max(rank),sum(timeLong) as timeLong) from #{superTableName} where ts>=#{begin} and ts<=#{end} deviceid=#{deviceid} group by description,alarmid ")
|
|
|
+ List<AlarmTsVo> selectByWtGroup(@Param("superTableName") String superTableName, @Param("deviceid") String deviceid, @Param("begin")long begin, @Param("end") long end);
|
|
|
+
|
|
|
+
|
|
|
+// @Select("select ts,val,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
|
|
|
+// "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{superTableName} " +
|
|
|
+// "#{whereSql} order by ts desc limit #{limit} offset #{offset} ")
|
|
|
+
|
|
|
+ @Select({"<script>",
|
|
|
+ "select ts,val,alarmid,alarmtype,characteristic,components,confirmed,description,deviceid,devicename,devicetype,enabled,lineid,linename," +
|
|
|
+ "modelId,projectid,projectname,rank,resettable,stationid,stationname,subcomponents,suffix,tagid,triggertype,uniformcode from #{superTableName} " ,
|
|
|
+ "<where>" ,
|
|
|
+ "<if test='modelId != null'>",
|
|
|
+ "and modelId= #{modelId}",
|
|
|
+ "</if>",
|
|
|
+ "<if test='description != null'>",
|
|
|
+ "and description like #{description}",
|
|
|
+ "</if>",
|
|
|
+ "<if test='deviceid != null'>",
|
|
|
+ "and deviceid = #{deviceid}",
|
|
|
+ "</if>",
|
|
|
+ "and stationid = #{stationid}",
|
|
|
+ "and ts >= #{begin}",
|
|
|
+ "and ts <= #{end}",
|
|
|
+ "</where>",
|
|
|
+ " order by ts desc limit #{limit},#{offset} ",
|
|
|
+ "</script>"})
|
|
|
+ List<AlarmVo> selectByWtLimit(@Param("begin")long begin,@Param("end")long end,@Param("modelId")String modelId,@Param("superTableName") String superTableName,@Param("alarmType")String alarmType,@Param("stationid")String stationid,@Param("deviceid")String deviceid,@Param("description")String description, @Param("limit")int limit, @Param("offset") int offset);
|
|
|
+
|
|
|
+ @Select({"<script>",
|
|
|
+ "select count(*) from #{superTableName} " ,
|
|
|
+ "<where>" ,
|
|
|
+ "<if test='modelId != null'>",
|
|
|
+ "and modelId= #{modelId}",
|
|
|
+ "</if>",
|
|
|
+ "<if test='description != null'>",
|
|
|
+ "and description like #{description}",
|
|
|
+ "</if>",
|
|
|
+ "<if test='deviceid != null'>",
|
|
|
+ "and deviceid = #{deviceid}",
|
|
|
+ "</if>",
|
|
|
+ "and stationid = #{stationid}",
|
|
|
+ "and ts >= #{begin}",
|
|
|
+ "and ts <= #{end}",
|
|
|
+ "</where>",
|
|
|
+
|
|
|
+ "</script>"})
|
|
|
+ Integer selectByWtCount(@Param("begin")long begin,@Param("end")long end,@Param("modelId")String modelId,@Param("superTableName") String superTableName,@Param("alarmType")String alarmType,@Param("stationid")String stationid,@Param("deviceid")String deviceid,@Param("description")String description);
|
|
|
+
|
|
|
+}
|