AlarmSnapMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gyee.wisdom.alarm.sharding.mapper.AlarmSnapMapper">
  4. <select id="queryAll" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  5. select * from ALARMSNAP a
  6. <where>
  7. 1=1
  8. <if test="starttime !=null and endtime !=null">
  9. and lastupdatetime &gt;= #{starttime,jdbcType=DATE} and lastupdatetime &lt;= #{endtime,jdbcType=DATE}
  10. </if>
  11. <if test="stid !=null and stid !=''">
  12. and a.stationid=#{stid}
  13. </if>
  14. <if test="wtid !=null and wtid !=''">
  15. and a.windturbineid=#{wtid}
  16. </if>
  17. <if test="category1 !=null and category1 !=''">
  18. and a.category1=#{category1}
  19. </if>
  20. <if test="category2 !=null and category2 !=''">
  21. and a.category2=#{category2}
  22. </if>
  23. <if test="rank !=null and rank !=''">
  24. and a.rank=#{rank}
  25. </if>
  26. <if test="modelid !=null and modelid !=''">
  27. and a.modelid=#{modelid}
  28. </if>
  29. <if test="isopened !=null ">
  30. and a.isopened=#{isopened}
  31. </if>
  32. <if test="keyword !=null and keyword !=''">
  33. and a.alerttext like #{keyword}
  34. </if>
  35. </where>
  36. order by a.lastupdatetime desc
  37. </select>
  38. <select id="pageQueryAll" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  39. select * from ALARMSNAP a
  40. <where>
  41. 1=1
  42. <if test="starttime !=null and endtime !=null">
  43. and lastupdatetime &gt;= #{starttime,jdbcType=DATE} and lastupdatetime &lt;= #{endtime,jdbcType=DATE}
  44. </if>
  45. <if test="stid !=null and stid !=''">
  46. and a.stationid=#{stid}
  47. </if>
  48. <if test="wtid !=null and wtid !=''">
  49. and a.windturbineid=#{wtid}
  50. </if>
  51. <if test="category1 !=null and category1 !=''">
  52. and a.category1=#{category1}
  53. </if>
  54. <if test="category2 !=null and category2 !=''">
  55. and a.category2=#{category2}
  56. </if>
  57. <if test="rank !=null and rank !=''">
  58. and a.rank=#{rank}
  59. </if>
  60. <if test="modelid !=null and modelid !=''">
  61. and a.modelid=#{modelid}
  62. </if>
  63. <if test="isopened !=null ">
  64. and a.isopened=#{isopened}
  65. </if>
  66. <if test="keyword !=null and keyword !=''">
  67. and a.alerttext like #{keyword}
  68. </if>
  69. </where>
  70. order by a.lastupdatetime desc
  71. </select>
  72. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">
  73. insert into alarmsnap ( ID, STATIONID, PROJECTID, LINEID, WINDTURBINEID, ALERTVALUE, CATEGORY1, CATEGORY2, CATEGORY3, RANK, ISOPENED, LASTUPDATETIME, STATIONNAME, PROJECTNAME, LINENAME, WINDTURBINENAME, ALERTTEXT, MODELID, TESTINGPOINTKEY, DATAINFO )
  74. <foreach collection="list" item="item" index="index" separator="union all" >
  75. ( select
  76. #{item.id},#{item.stationId},#{item.projectId},#{item.lineId},#{item.windturbineId},
  77. #{item.alertValue},#{item.category1},#{item.category2},#{item.category3},#{item.rank},
  78. #{item.isOpened},#{item.lastUpdateTime},#{item.stationName},#{item.projectName},
  79. #{item.lineName},#{item.windturbineName},#{item.alertText},#{item.modelId},
  80. #{item.testingpointKey},#{item.dataInfo}
  81. from dual )
  82. </foreach>
  83. </insert>
  84. <!--<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false">-->
  85. <!--INSERT ALL-->
  86. <!--<foreach item="item" index="index" collection="list">-->
  87. <!--into alarmsnap ( ID, STATIONID, PROJECTID, LINEID, WINDTURBINEID, ALERTVALUE, CATEGORY1, CATEGORY2, CATEGORY3, RANK, ISOPENED, LASTUPDATETIME, STATIONNAME, PROJECTNAME, LINENAME, WINDTURBINENAME, ALERTTEXT, MODELID, TESTINGPOINTKEY, DATAINFO )-->
  88. <!--values-->
  89. <!--( #{item.id},#{item.stationId},#{item.projectId},#{item.lineId},#{item.windturbineId},-->
  90. <!--#{item.alertValue},#{item.category1},#{item.category2},#{item.category3},#{item.rank},-->
  91. <!--#{item.isOpened},#{item.lastUpdateTime},#{item.stationName},#{item.projectName},-->
  92. <!--#{item.lineName},#{item.windturbineName},#{item.alertText},#{item.modelId},-->
  93. <!--#{item.testingpointKey},#{item.dataInfo} )-->
  94. <!--</foreach>-->
  95. <!--SELECT 1 FROM DUAL-->
  96. <!--</insert>-->
  97. <update id="batchUpdate" parameterType="java.util.List">
  98. <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
  99. UPDATE alarmsnap
  100. <set>
  101. ISOPENED = #{item.isOpened},
  102. LASTUPDATETIME = #{item.lastUpdateTime},
  103. CATEGORY3=#{item.category3},
  104. DATAINFO = #{item.dataInfo}
  105. </set>
  106. where id = #{item.id}
  107. </foreach>
  108. </update>
  109. <select id="findByStationIdAndAlertValue" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  110. select * from ALARMSNAP a
  111. <where>
  112. a.stationid=#{stationid} and a.alertvalue = #{alertvalue} and rownum = 1
  113. </where>
  114. </select>
  115. <select id="findByWindturbineIdAndAlertValue" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  116. select * from ALARMSNAP a
  117. <where>
  118. a.windturbineid=#{windturbineid} and a.alertvalue = #{alertvalue} and rownum = 1
  119. </where>
  120. </select>
  121. <select id="findByTestingpointkey" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  122. select * from ALARMSNAP a
  123. <where>
  124. a.testingpointkey=#{testingpointkey} and rownum = 1
  125. </where>
  126. </select>
  127. <select id="getTopNumAlarm" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  128. select * from ( select * from alarmsnap h order by h.lastupdatetime desc)
  129. where category1 = #{category1} and rownum &lt;= #{topnum}
  130. </select>
  131. <select id="getRecentAlarm" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.AlarmSnap">
  132. SELECT * FROM alarmsnap
  133. WHERE category1 = #{category1} and lastupdatetime >= #{lastupdatetime}
  134. order by lastupdatetime desc
  135. </select>
  136. </mapper>