Alertrule2Mapper.xml 13 KB

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