GoafSensoralarmMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.goaf.mapper.GoafSensoralarmMapper">
  5. <resultMap id="GoafSensoralarmMapper" type="com.zhyc.xps.goaf.entity.GoafSensoralarm">
  6. <id column="goaf_sensor_alarm_id" property="goafSensorAlarmId" jdbcType="BIGINT"/>
  7. <result column="goaf_data_id" property="goafDataId" jdbcType="BIGINT"/>
  8. <result column="goaf_sensor_alarm_level" property="goafSensorAlarmLevel" jdbcType="BIGINT"/>
  9. <result column="goaf_sensor_alarm_type" property="goafSensorAlarmType" jdbcType="VARCHAR"/>
  10. </resultMap>
  11. <resultMap id="GoafSensoralarmDtoMapper" type="com.zhyc.xps.goaf.dto.GoafSensoralarmDto">
  12. <id column="goaf_sensor_alarm_id" property="goafSensorAlarmId" jdbcType="BIGINT"/>
  13. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  14. <result column="goaf_data_id" property="goafDataId" jdbcType="BIGINT"/>
  15. <result column="goaf_sensor_alarm_level" property="goafSensorAlarmLevel" jdbcType="BIGINT"/>
  16. <result column="goaf_sensor_alarm_type" property="goafSensorAlarmType" jdbcType="VARCHAR"/>
  17. <result column="goaf_sensor_id" property="goafSensorId" jdbcType="BIGINT"/>
  18. <result column="goaf_sensor_name" property="goafSensorName" jdbcType="VARCHAR"/>
  19. <result column="goaf_dev_name" property="goafDevName" jdbcType="VARCHAR"/>
  20. <result column="goaf_dev_typename" property="goafDevTypename" jdbcType="VARCHAR"/>
  21. <result column="frequency_x" property="frequencyX" jdbcType="BIGINT"/>
  22. <result column="frequency_y" property="frequencyY" jdbcType="BIGINT"/>
  23. <result column="frequency_z" property="frequencyZ" jdbcType="BIGINT"/>
  24. <result column="acc_x" property="accX" jdbcType="BIGINT"/>
  25. <result column="acc_y" property="accY" jdbcType="BIGINT"/>
  26. <result column="acc_z" property="accZ" jdbcType="BIGINT"/>
  27. <result column="vel_x" property="velX" jdbcType="BIGINT"/>
  28. <result column="vel_y" property="velY" jdbcType="BIGINT"/>
  29. <result column="vel_z" property="velZ" jdbcType="BIGINT"/>
  30. <result column="dis_x" property="disX" jdbcType="BIGINT"/>
  31. <result column="dis_y" property="disY" jdbcType="BIGINT"/>
  32. <result column="dis_z" property="disZ" jdbcType="BIGINT"/>
  33. <result column="sensor_temperature" property="sensorTemperature" jdbcType="BIGINT"/>
  34. <result column="ang_x" property="angX" jdbcType="BIGINT"/>
  35. <result column="ang_y" property="angY" jdbcType="BIGINT"/>
  36. <result column="ang_z" property="angZ" jdbcType="BIGINT"/>
  37. <result column="goaf_datareport_time" property="goafDatareportTime" jdbcType="TIMESTAMP"/>
  38. </resultMap>
  39. <select id="getByList" parameterType="java.util.Map" resultMap="GoafSensoralarmDtoMapper">
  40. SELECT A.*,
  41. B.oc_id,
  42. B.goaf_sensor_id,
  43. B.goaf_sensor_name,
  44. B.goaf_dev_name,
  45. B.goaf_dev_typename,
  46. B.frequency_x,
  47. B.frequency_y,
  48. B.frequency_z,
  49. B.acc_x,
  50. B.acc_y,
  51. B.acc_z,
  52. B.vel_x,
  53. B.vel_y,
  54. B.vel_z,
  55. B.dis_x,
  56. B.dis_y,
  57. B.dis_z,
  58. B.sensor_temperature,
  59. B.ang_x,
  60. B.ang_y,
  61. B.ang_z,
  62. B.f_alarm_temperature,
  63. B.goaf_datareport_time
  64. FROM goaf_sensoralarm AS A
  65. LEFT JOIN goaf_sensordata AS B ON A.goaf_data_id = B.goaf_data_id
  66. WHERE B.oc_id = #{ocId ,jdbcType=BIGINT}
  67. <if test="goafSensorAlarmLevel !=null">
  68. AND A.goaf_sensor_alarm_level = #{goafSensorAlarmLevel ,jdbcType=BIGINT}
  69. </if>
  70. <if test="goafSensorAlarmType !=null and goafSensorAlarmType != ''">
  71. AND A.goaf_sensor_alarm_type = like concat('%',#{goafSensorAlarmType ,jdbcType=VARCHAR}, '%')
  72. </if>
  73. <if test="goafSensorName !=null and goafSensorName != ''">
  74. AND B.goaf_sensor_name = #{goafSensorName ,jdbcType=VARCHAR}
  75. </if>
  76. <if test="goafDevName !=null and goafDevName != ''">
  77. AND B.goaf_dev_name = #{goafDevName ,jdbcType=VARCHAR}
  78. </if>
  79. <if test="goafDevTypename !=null and goafDevTypename != ''">
  80. AND B.goaf_dev_typename = #{goafDevTypename ,jdbcType=VARCHAR}
  81. </if>
  82. <if test="startDate != null and endDate != null">
  83. AND B.goaf_datareport_time BETWEEN #{startDate} AND #{endDate}
  84. </if>
  85. ORDER BY B.goaf_datareport_time DESC
  86. </select>
  87. <!--分页查询-->
  88. <select id="getByPage" parameterType="java.util.Map" resultMap="GoafSensoralarmDtoMapper">
  89. SELECT A.*,
  90. B.oc_id,
  91. B.goaf_sensor_id,
  92. B.goaf_sensor_name,
  93. B.goaf_dev_name,
  94. B.goaf_dev_typename,
  95. B.frequency_x,
  96. B.frequency_y,
  97. B.frequency_z,
  98. B.acc_x,
  99. B.acc_y,
  100. B.acc_z,
  101. B.vel_x,
  102. B.vel_y,
  103. B.vel_z,
  104. B.dis_x,
  105. B.dis_y,
  106. B.dis_z,
  107. B.sensor_temperature,
  108. B.ang_x,
  109. B.ang_y,
  110. B.ang_z,
  111. B.f_alarm_temperature,
  112. B.goaf_datareport_time
  113. FROM goaf_sensoralarm AS A
  114. LEFT JOIN goaf_sensordata AS B ON A.goaf_data_id = B.goaf_data_id
  115. WHERE B.oc_id = #{ocId ,jdbcType=BIGINT}
  116. <if test="goafSensorAlarmLevel !=null">
  117. AND A.goaf_sensor_alarm_level = #{goafSensorAlarmLevel ,jdbcType=BIGINT}
  118. </if>
  119. <if test="goafSensorAlarmType !=null and goafSensorAlarmType != ''">
  120. AND A.goaf_sensor_alarm_type = #{goafSensorAlarmType ,jdbcType=VARCHAR}
  121. </if>
  122. <if test="goafSensorName !=null and goafSensorName != ''">
  123. AND B.goaf_sensor_name = #{goafSensorName ,jdbcType=VARCHAR}
  124. </if>
  125. <if test="goafDevName !=null and goafDevName != ''">
  126. AND B.goaf_dev_name = #{goafDevName ,jdbcType=VARCHAR}
  127. </if>
  128. <if test="goafDevTypename !=null and goafDevTypename != ''">
  129. AND B.goaf_dev_typename = #{goafDevTypename ,jdbcType=VARCHAR}
  130. </if>
  131. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  132. AND B.goaf_datareport_time BETWEEN #{startDate} AND #{endDate}
  133. </if>
  134. ORDER BY B.goaf_datareport_time DESC
  135. </select>
  136. <!--传感器告警个数查询(按类别)-->
  137. <select id="getSensorAlarmNum" parameterType="java.util.Map" resultType="com.zhyc.xps.goaf.vo.SensorAlarmNumVo">
  138. SELECT SUM(CASE WHEN salarm.goaf_sensor_alarm_level = 0 THEN 1 ELSE 0 END) AS sensorGenAlarmNum,
  139. SUM(CASE WHEN salarm.goaf_sensor_alarm_level = 1 THEN 1 ELSE 0 END) AS sensorCriAlarmNum
  140. FROM goaf_sensoralarm AS salarm
  141. LEFT JOIN goaf_sensordata AS senn ON senn.goaf_data_id = salarm.goaf_data_id
  142. WHERE senn.oc_id = #{ocId ,jdbcType=BIGINT}
  143. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  144. AND senn.goaf_datareport_time BETWEEN #{startDate} and #{endDate}
  145. </if>
  146. </select>
  147. <!--传感器数据个数查询-->
  148. <select id="getsensorNormalNum" parameterType="java.util.Map" resultType="java.lang.Long">
  149. SELECT count(*) as sensorNormalNum
  150. FROM goaf_sensordata
  151. WHERE oc_id = #{ocId ,jdbcType=BIGINT}
  152. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  153. AND goaf_datareport_time BETWEEN #{startDate} and #{endDate}
  154. </if>
  155. </select>
  156. <insert id="create" parameterType="com.zhyc.xps.goaf.entity.GoafSensoralarm">
  157. insert into goaf_sensoralarm
  158. <trim prefix="(" suffix=")" suffixOverrides=",">
  159. <if test="goafSensorAlarmId != null">
  160. goaf_sensor_alarm_id,
  161. </if>
  162. <if test="goafDataId != null">
  163. goaf_data_id,
  164. </if>
  165. <if test="goafSensorAlarmLevel != null">
  166. goaf_sensor_alarm_level,
  167. </if>
  168. <if test="goafSensorAlarmType != null and goafSensorAlarmType != ''">
  169. goaf_sensor_alarm_type,
  170. </if>
  171. </trim>
  172. <trim prefix="values (" suffix=")" suffixOverrides=",">
  173. <if test="goafSensorAlarmId != null">
  174. #{goafSensorAlarmId, jdbcType=BIGINT},
  175. </if>
  176. <if test="goafDataId != null">
  177. #{goafDataId, jdbcType=BIGINT},
  178. </if>
  179. <if test="goafSensorAlarmLevel != null">
  180. #{goafSensorAlarmLevel, jdbcType=BIGINT},
  181. </if>
  182. <if test="goafSensorAlarmType != null and goafSensorAlarmType != ''">
  183. #{goafSensorAlarmType, jdbcType=VARCHAR},
  184. </if>
  185. </trim>
  186. </insert>
  187. </mapper>