Alertrule2Mapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 type="Alertrule2" id="Alertrule2Result">
  5. <result property="id" column="id" />
  6. <result property="name" column="name" />
  7. <result property="station" column="station" />
  8. <result property="relatedParts" column="relatedParts" />
  9. <association property="windPowerStation" column="station" javaType="WindPowerStation" select="com.gyee.wisdom.alarm.sharding.mapper.WindPowerStationMapper.selectByid"/>
  10. <association property="datadictionary" column="relatedParts" javaType="Datadictionary" select="com.gyee.wisdom.alarm.sharding.mapper.DatadictionaryMapper.selectBycode"/>
  11. </resultMap>
  12. <select id="pageQueryAll" parameterType="java.util.Map" resultMap="Alertrule2Result">
  13. select a.* from ALERTRULE2 a
  14. left join windpowerstation w on w.id = a.station
  15. <where>
  16. 1=1
  17. <if test="name !=null and name !=''">
  18. and a.name like '%${name}%'
  19. </if>
  20. <if test="station !=null and station !=''">
  21. and a.station like '%${station}%'
  22. </if>
  23. <if test="modelId !=null and modelId !=''">
  24. and a.modelid like '%${modelId}%'
  25. </if>
  26. <if test="rank !=null and rank !=''">
  27. and a.rank = #{rank}
  28. </if>
  29. /* and a.range = 0*/
  30. </where>
  31. order by a.createtime desc
  32. </select>
  33. <select id="getMaxEdnaValue" parameterType="java.util.Map" resultType="java.lang.Integer">
  34. select max(a.ednavalue) from ALERTRULE2 a
  35. </select>
  36. <select id="getAllByStationIdAndModelId" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  37. select * from ALERTRULE2 a
  38. <where>
  39. 1=1
  40. <if test="idString !=null and idString !=''">
  41. and a.id like '%${idString}%'
  42. </if>
  43. </where>
  44. </select>
  45. <select id="getById" parameterType="java.util.Map" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  46. select * from ALERTRULE2 a
  47. <where>
  48. 1=1
  49. <if test="idString !=null and idString !=''">
  50. and a.id = #{idString}
  51. </if>
  52. </where>
  53. </select>
  54. <select id="quertByrelatedParts" resultType="java.util.HashMap">
  55. select a.name from ALERTRULE2 a
  56. where a.relatedparts = #{relatedParts}
  57. group by a.name
  58. </select>
  59. <select id="queryTree" resultMap="Alertrule2Result" >
  60. select distinct a.relatedparts,a.name,d.name from alertrule2 a
  61. left join DATADICTIONARY d
  62. on d.code = a.relatedparts
  63. where
  64. relatedparts is not null
  65. </select>
  66. <select id="queryMap" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  67. select t.relatedparts,d.name from
  68. (select a.relatedparts from alertrule2 a
  69. where relatedparts is not null
  70. group by a.relatedparts) t
  71. left join DATADICTIONARY d
  72. on d.code = t.relatedparts
  73. </select>
  74. <insert id="insertAlertrule2" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2" useGeneratedKeys="true">
  75. insert into alertrule2(name, description, expression, tag, rank, enabled,
  76. modelId,ednaValue,category,range,station,
  77. windturbine,line,project,electrical,taskstart,relatedParts,createtime)
  78. values (#{name}, #{description}, #{expression},
  79. #{tag}, #{rank}, #{enabled},#{modelId}, #{ednaValue}, #{category},#{range},#{station},
  80. #{windturbine}, #{line},#{project}, #{electrical}, #{taskstart},#{relatedParts},#{createtime})
  81. </insert>
  82. <update id="updateByAlertrule2Id" parameterType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  83. update alertrule2 a
  84. <set >
  85. <if test="name != null">a.name = #{name},</if>
  86. <if test="description != null">a.description = #{description},</if>
  87. <if test="expression != null">a.expression = #{expression},</if>
  88. <if test="tag != null">a.tag = #{tag},</if>
  89. <if test="rank != null">a.rank = #{rank},</if>
  90. <if test="enabled != null">a.enabled = #{enabled},</if>
  91. <if test="modelId != null">a.modelId = #{modelId},</if>
  92. <if test="ednaValue != null">a.ednaValue = #{ednaValue},</if>
  93. <if test="category != null">a.category = #{category},</if>
  94. <if test="range != null">a.range = #{range},</if>
  95. <if test="station != null">a.station = #{station},</if>
  96. <if test="windturbine != null">a.windturbine = #{windturbine},</if>
  97. <if test="line != null">a.line = #{line},</if>
  98. <if test="project != null">a.project = #{project},</if>
  99. <if test="electrical != null">a.electrical = #{electrical},</if>
  100. <if test="taskstart != null">a.taskstart = #{taskstart},</if>
  101. <if test="relatedParts != null">a.relatedParts = #{relatedParts},</if>
  102. <if test="createtime != null">a.createtime = #{createtime}</if>
  103. </set>
  104. where a.id = #{id}
  105. </update>
  106. <select id="selectByAlertrule2Id" resultType="com.gyee.wisdom.alarm.sharding.entity.Alertrule2">
  107. select * from alertrule2 a where a.id=#{id}
  108. </select>
  109. </mapper>