<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.devplatform.equipment.modules.alarms.dao.AlarmsOpinionDao">
  <!-- Result Map -->
  <resultMap id="BaseResultMap" type="com.devplatform.equipment.modules.alarms.bean.AlarmsOpinion">
    <result column="id" property="id"/>
    <result column="alarms_id" property="alarmsId"/>
    <result column="content" property="content"/>
    <result column="plan_id" property="planId"/>
    <result column="create_user_id" property="createUserId"/>
    <result column="create_time" property="createTime"/>
    <result column="byx1" property="byx1"/>
    <result column="byx2" property="byx2"/>
    <result column="byx3" property="byx3"/>
    <result column="sys_sign" property="sysSign"/>
  </resultMap>

  <!-- alarms_opinion table all fields -->
  <sql id="Base_Column_List">
		id,alarms_id,content,plan_id,create_user_id,create_time,byx1,byx2,byx3,sys_sign
	</sql>

  <!-- 公共查询条件 -->
  <sql id="Example_Where_Clause">
    where deleted=0
    <if test="id!=null and id!=''">and id = #{id}</if>
    <if test="alarmsId!=null and alarmsId!=''">and alarms_id = #{alarmsId}</if>
    <if test="content!=null and content!=''">and content = #{content}</if>
    <if test="planId!=null and planId!=''">and plan_id = #{planId}</if>
    <if test="createUserId!=null and createUserId!=''">and create_user_id = #{createUserId}</if>
    <if test="createTime!=null ">and create_time = #{createTime}</if>
    <if test="byx1!=null and byx1!=''">and byx1 = #{byx1}</if>
    <if test="byx2!=null and byx2!=''">and byx2 = #{byx2}</if>
    <if test="byx3!=null and byx3!=''">and byx3 = #{byx3}</if>
    <if test="sysSign!=null and sysSign!=''">and sys_sign = #{sysSign}</if>
  </sql>

  <!--根据alarmsId查询报警信息-->
  <select id="getAlarmsId" parameterType="java.lang.String" resultMap="BaseResultMap">
		SELECT
			a.id,
			a.alarms_id,
			a.content,
			DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i') as opinionTime,
			s.`name`
		FROM
			alarms_opinion a
			LEFT JOIN sys_user s ON a.create_user_id = s.user_id
			WHERE a.alarms_id = #{alarmsId}
		ORDER BY
			a.create_time
	</select>


</mapper>


