Alertrule2Mapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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.Alertrule2Mapper">
  4. <resultMap id="BaseResultMap" type="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  5. <!--
  6. WARNING - @mbg.generated
  7. This element is automatically generated by MyBatis Generator, do not modify.
  8. -->
  9. <id column="id" property="id" />
  10. <result column="name" property="name" />
  11. <result column="description" property="description" />
  12. <result column="expression" property="expression" />
  13. <result column="rank" property="rank" />
  14. <result column="rank" property="rank" />
  15. <result column="enabled" property="enabled" />
  16. <result column="modelId" property="modelId" />
  17. <result column="ednaValue" property="ednaValue" />
  18. <result column="category" property="category" />
  19. <result column="range" property="range" />
  20. <result column="station" property="station" />
  21. <result column="windturbine" property="windturbine" />
  22. <result column="line" property="line" />
  23. <result column="project" property="project" />
  24. <result column="electrical" property="electrical" />
  25. <result column="taskstart" property="taskstart" />
  26. <result column="relatedParts" property="relatedParts" />
  27. </resultMap>
  28. <resultMap type="Alertrule2" id="Alertrule2Result">
  29. <result property="id" column="id" />
  30. <result property="name" column="name" />
  31. <result property="station" column="station" />
  32. <result property="relatedParts" column="relatedParts" />
  33. <association property="windPowerStation" column="station" javaType="WindPowerStation" select="com.gyee.wisdom.alarm.sharding.mapper.WindPowerStationMapper.selectByid"/>
  34. <association property="datadictionary" column="relatedParts" javaType="Datadictionary" select="com.gyee.wisdom.alarm.sharding.mapper.DatadictionaryMapper.selectBycode"/>
  35. </resultMap>
  36. <select id="pageQueryAll" parameterType="java.util.Map" resultMap="Alertrule2Result">
  37. select a.* from ALERTRULE2 a
  38. left join windpowerstation w on w.id = a.station
  39. <where>
  40. 1=1
  41. <if test="name !=null and name !=''">
  42. and a.name like '%${name}%'
  43. </if>
  44. <if test="station !=null and station !=''">
  45. and a.station like '%${station}%'
  46. </if>
  47. <if test="modelId !=null and modelId !=''">
  48. and a.modelid like '%${modelId}%'
  49. </if>
  50. <if test="rank !=null and rank !=''">
  51. and a.rank = #{rank}
  52. </if>
  53. <if test="category !=null and category !=''">
  54. and a.category = #{category}
  55. </if>
  56. <if test="enabled !=null and enabled !=''">
  57. and a.enabled = #{enabled}
  58. </if>
  59. <!-- and a.range = 0-->
  60. </where>
  61. order by a.createtime desc
  62. </select>
  63. <select id="getMaxEdnaValue" parameterType="java.util.Map" resultType="java.lang.Integer">
  64. select max(a.ednavalue) from ALERTRULE2 a
  65. </select>
  66. <select id="getAllByStationIdAndModelId" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  67. select * from ALERTRULE2 a
  68. <where>
  69. 1=1
  70. <if test="idString !=null and idString !=''">
  71. and a.id like '%${idString}%'
  72. </if>
  73. </where>
  74. </select>
  75. <select id="getById" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  76. select * from ALERTRULE2 a
  77. <where>
  78. 1=1
  79. <if test="idString !=null and idString !=''">
  80. and a.id = #{idString}
  81. </if>
  82. </where>
  83. </select>
  84. <select id="quertByrelatedParts" resultType="java.util.HashMap">
  85. select a.name from ALERTRULE2 a
  86. where a.relatedparts = #{relatedParts}
  87. group by a.name
  88. </select>
  89. <select id="queryTree" resultMap="Alertrule2Result" >
  90. select distinct a.relatedparts,a.name,d.name from alertrule2 a
  91. left join DATADICTIONARY d
  92. on d.code = a.relatedparts
  93. where
  94. relatedparts is not null
  95. </select>
  96. <select id="queryMap" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  97. select t.relatedparts,d.name from
  98. (select a.relatedparts from alertrule2 a
  99. where relatedparts is not null
  100. group by a.relatedparts) t
  101. left join DATADICTIONARY d
  102. on d.code = t.relatedparts
  103. </select>
  104. <insert id="insertAlerture2" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2" useGeneratedKeys="true" keyProperty="id">
  105. insert into alertrule2
  106. <trim prefix="(" suffix=")" suffixOverrides=",">
  107. <if test="id != null">id,</if>
  108. <if test="name != null">Name,</if>
  109. <if test="description != null">description,</if>
  110. <if test="expression != null">expression,</if>
  111. <if test="tag != null">tag,</if>
  112. <if test="rank != null">rank,</if>
  113. <if test="enabled != null">enabled,</if>
  114. <if test="modelId != null">modelId,</if>
  115. <if test="ednaValue != null">ednaValue,</if>
  116. <if test="category != null">category,</if>
  117. <if test="range != null">`range`,</if>
  118. <if test="station != null">station,</if>
  119. <if test="windturbine != null">windturbine,</if>
  120. <if test="line != null">line,</if>
  121. <if test="project != null">project,</if>
  122. <if test="electrical != null">electrical,</if>
  123. <if test="taskstart != null">taskstart,</if>
  124. <if test="relatedParts != null">relatedParts,</if>
  125. <if test="createtime != null">createtime</if>
  126. </trim>
  127. <trim prefix="values (" suffix=")" suffixOverrides=",">
  128. <if test="id != null">#{id},</if>
  129. <if test="name != null">#{name},</if>
  130. <if test="description != null">#{description},</if>
  131. <if test="expression != null">#{expression},</if>
  132. <if test="tag != null">#{tag},</if>
  133. <if test="rank != null">#{rank},</if>
  134. <if test="enabled != null">#{enabled},</if>
  135. <if test="modelId != null">#{modelId},</if>
  136. <if test="ednaValue != null">#{ednaValue},</if>
  137. <if test="category != null">#{category},</if>
  138. <if test="range != null">#{range},</if>
  139. <if test="station != null">#{station},</if>
  140. <if test="windturbine != null">#{windturbine},</if>
  141. <if test="line != null">#{line},</if>
  142. <if test="project != null">#{project},</if>
  143. <if test="electrical != null">#{electrical},</if>
  144. <if test="taskstart != null">#{taskstart},</if>
  145. <if test="relatedParts != null">#{relatedParts},</if>
  146. <if test="createtime != null">#{createtime}</if>
  147. </trim>
  148. </insert>
  149. <update id="updateByAlertrule2Id" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  150. update alertrule2 a
  151. <set >
  152. <if test="name != null">a.name = #{name},</if>
  153. <if test="description != null">a.description = #{description},</if>
  154. <if test="expression != null">a.expression = #{expression},</if>
  155. <if test="tag != null">a.tag = #{tag},</if>
  156. <if test="rank != null">a.rank = #{rank},</if>
  157. <if test="enabled != null">a.enabled = #{enabled},</if>
  158. <if test="modelId != null">a.modelId = #{modelId},</if>
  159. <if test="ednaValue != null and ednaValue!=0">a.ednaValue = #{ednaValue},</if>
  160. <if test="category != null">a.category = #{category},</if>
  161. <if test="range != null">a.range = #{range},</if>
  162. <if test="station != null">a.station = #{station},</if>
  163. <if test="windturbine != null">a.windturbine = #{windturbine},</if>
  164. <if test="line != null">a.line = #{line},</if>
  165. <if test="project != null">a.project = #{project},</if>
  166. <if test="electrical != null">a.electrical = #{electrical},</if>
  167. <if test="taskstart != null">a.taskstart = #{taskstart},</if>
  168. <if test="relatedParts != null">a.relatedParts = #{relatedParts},</if>
  169. <if test="createtime != null">a.createtime = #{createtime}</if>
  170. </set>
  171. where a.id = #{id}
  172. </update>
  173. <select id="selectByAlertrule2Id" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  174. select * from alertrule2 a where a.id=#{id}
  175. </select>
  176. <select id="selectByNameAndSataionAndModelid" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  177. select * from alertrule2 a
  178. <where>
  179. 1=1
  180. <if test="name !=null and name !=''">
  181. and a.name = #{name}
  182. </if>
  183. <if test="station !=null and station !=''">
  184. and a.station = #{station}
  185. </if>
  186. <if test="modelid !=null and modelid !=''">
  187. and a.modelid = #{modelid}
  188. </if>
  189. </where>
  190. </select>
  191. <select id="selectByExample" parameterType="com.gyee.wisdom.alarm.sharding.model.Alertrule2Example" resultMap="BaseResultMap">
  192. <!--
  193. WARNING - @mbg.generated
  194. This element is automatically generated by MyBatis Generator, do not modify.
  195. -->
  196. select
  197. <if test="distinct">
  198. distinct
  199. </if>
  200. *
  201. <!-- <include refid="Base_Column_List" />-->
  202. from ALERTRULE2
  203. <if test="_parameter != null">
  204. <include refid="Example_Where_Clause" />
  205. </if>
  206. <if test="orderByClause != null">
  207. order by ${orderByClause}
  208. </if>
  209. </select>
  210. <sql id="Base_Column_List">
  211. <!--
  212. WARNING - @mbg.generated
  213. This element is automatically generated by MyBatis Generator, do not modify.
  214. -->
  215. id, name, description, expression, tag, rank, enabled, modelid, ednavalue, category,
  216. range, station, windturbine, line, project, electrical, taskstart, relatedparts
  217. </sql>
  218. <sql id="Example_Where_Clause">
  219. <!--
  220. WARNING - @mbg.generated
  221. This element is automatically generated by MyBatis Generator, do not modify.
  222. -->
  223. <where>
  224. <foreach collection="oredCriteria" item="criteria" separator="or">
  225. <if test="criteria.valid">
  226. <trim prefix="(" prefixOverrides="and" suffix=")">
  227. <foreach collection="criteria.criteria" item="criterion">
  228. <choose>
  229. <when test="criterion.noValue">
  230. and ${criterion.condition}
  231. </when>
  232. <when test="criterion.singleValue">
  233. and ${criterion.condition} #{criterion.value}
  234. </when>
  235. <when test="criterion.betweenValue">
  236. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  237. </when>
  238. <when test="criterion.listValue">
  239. and ${criterion.condition}
  240. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  241. #{listItem}
  242. </foreach>
  243. </when>
  244. </choose>
  245. </foreach>
  246. </trim>
  247. </if>
  248. </foreach>
  249. </where>
  250. </sql>
  251. </mapper>