123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?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.zoniot.ccrc.dao.WarningMessageMapper">
- <resultMap id="BaseResultMap" type="com.zoniot.ccrc.entity.WarningMessage">
- <!--@mbg.generated-->
- <!--@Table sc_warning_message-->
- <id column="id" property="id" />
- <result column="warning_log_id" property="warningLogId" />
- <result column="content" property="content" />
- <result column="status" property="status" />
- <result column="create_by" property="createBy" />
- <result column="date_create" property="dateCreate" />
- <result column="update_by" property="updateBy" />
- <result column="date_update" property="dateUpdate" />
- </resultMap>
- <sql id="Base_Column_List">
- <!--@mbg.generated-->
- id, warning_log_id, content, `status`, create_by, date_create, update_by, date_update
- </sql>
- <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zoniot.ccrc.entity.WarningMessage" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_warning_message
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="warningLogId != null">
- warning_log_id,
- </if>
- <if test="content != null">
- content,
- </if>
- <if test="status != null">
- `status`,
- </if>
- <if test="createBy != null">
- create_by,
- </if>
- <if test="dateCreate != null">
- date_create,
- </if>
- <if test="updateBy != null">
- update_by,
- </if>
- <if test="dateUpdate != null">
- date_update,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="warningLogId != null">
- #{warningLogId},
- </if>
- <if test="content != null">
- #{content},
- </if>
- <if test="status != null">
- #{status},
- </if>
- <if test="createBy != null">
- #{createBy},
- </if>
- <if test="dateCreate != null">
- #{dateCreate},
- </if>
- <if test="updateBy != null">
- #{updateBy},
- </if>
- <if test="dateUpdate != null">
- #{dateUpdate},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="com.zoniot.ccrc.entity.WarningMessage">
- <!--@mbg.generated-->
- update sc_warning_message
- <set>
- <if test="warningLogId != null">
- warning_log_id = #{warningLogId},
- </if>
- <if test="content != null">
- content = #{content},
- </if>
- <if test="status != null">
- `status` = #{status},
- </if>
- <if test="createBy != null">
- create_by = #{createBy},
- </if>
- <if test="dateCreate != null">
- date_create = #{dateCreate},
- </if>
- <if test="updateBy != null">
- update_by = #{updateBy},
- </if>
- <if test="dateUpdate != null">
- date_update = #{dateUpdate},
- </if>
- </set>
- where id = #{id}
- </update>
- <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into sc_warning_message
- (warning_log_id, content, `status`, create_by, date_create, update_by, date_update
- )
- values
- <foreach collection="list" item="item" separator=",">
- (#{item.warningLogId}, #{item.content}, #{item.status}, #{item.createBy}, #{item.dateCreate},
- #{item.updateBy}, #{item.dateUpdate})
- </foreach>
- </insert>
- <select id="findById" resultMap="BaseResultMap">
- select <include refid="Base_Column_List" /> from sc_warning_message where status = 1 and id = #{id}
- </select>
- <select id="getList" resultType="com.zoniot.ccrc.dto.WarningMessageDto">
- SELECT
- swm.*,
- swl.warning_type,
- swl.feedback_status,
- swl.feedback_content
- FROM sc_warning_message swm
- LEFT JOIN sc_warning_log swl on(swl.id = swm.warning_log_id)
- WHERE swm.`status` = 1 and swl.status = 1 and swl.device_id = #{deviceId}
- <if test="date != null"> and date_format(swm.date_create, '%Y%m%d') = #{date}</if>
- order by swm.date_create desc
- </select>
- <select id="getDateStatus" resultType="com.zoniot.ccrc.dto.WarningMessageStatusDto">
- SELECT
- date_format(swm.date_create, '%Y%m%d') as days,
- if(SUM(if(swl.feedback_status=0,1,0))>0,0,1) as feedback_status
- FROM sc_warning_message swm
- LEFT JOIN sc_warning_log swl on(swl.id = swm.warning_log_id)
- WHERE swm.`status` = 1 and swl.status = 1 and swl.device_id = #{deviceId}
- and date_format(swm.date_create, '%Y%m') = #{date}
- GROUP BY days
- order by days asc
- </select>
- </mapper>
|