WarningMessageMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.zoniot.ccrc.dao.WarningMessageMapper">
  4. <resultMap id="BaseResultMap" type="com.zoniot.ccrc.entity.WarningMessage">
  5. <!--@mbg.generated-->
  6. <!--@Table sc_warning_message-->
  7. <id column="id" property="id" />
  8. <result column="warning_log_id" property="warningLogId" />
  9. <result column="content" property="content" />
  10. <result column="status" property="status" />
  11. <result column="create_by" property="createBy" />
  12. <result column="date_create" property="dateCreate" />
  13. <result column="update_by" property="updateBy" />
  14. <result column="date_update" property="dateUpdate" />
  15. </resultMap>
  16. <sql id="Base_Column_List">
  17. <!--@mbg.generated-->
  18. id, warning_log_id, content, `status`, create_by, date_create, update_by, date_update
  19. </sql>
  20. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.zoniot.ccrc.entity.WarningMessage" useGeneratedKeys="true">
  21. <!--@mbg.generated-->
  22. insert into sc_warning_message
  23. <trim prefix="(" suffix=")" suffixOverrides=",">
  24. <if test="warningLogId != null">
  25. warning_log_id,
  26. </if>
  27. <if test="content != null">
  28. content,
  29. </if>
  30. <if test="status != null">
  31. `status`,
  32. </if>
  33. <if test="createBy != null">
  34. create_by,
  35. </if>
  36. <if test="dateCreate != null">
  37. date_create,
  38. </if>
  39. <if test="updateBy != null">
  40. update_by,
  41. </if>
  42. <if test="dateUpdate != null">
  43. date_update,
  44. </if>
  45. </trim>
  46. <trim prefix="values (" suffix=")" suffixOverrides=",">
  47. <if test="warningLogId != null">
  48. #{warningLogId},
  49. </if>
  50. <if test="content != null">
  51. #{content},
  52. </if>
  53. <if test="status != null">
  54. #{status},
  55. </if>
  56. <if test="createBy != null">
  57. #{createBy},
  58. </if>
  59. <if test="dateCreate != null">
  60. #{dateCreate},
  61. </if>
  62. <if test="updateBy != null">
  63. #{updateBy},
  64. </if>
  65. <if test="dateUpdate != null">
  66. #{dateUpdate},
  67. </if>
  68. </trim>
  69. </insert>
  70. <update id="updateByPrimaryKeySelective" parameterType="com.zoniot.ccrc.entity.WarningMessage">
  71. <!--@mbg.generated-->
  72. update sc_warning_message
  73. <set>
  74. <if test="warningLogId != null">
  75. warning_log_id = #{warningLogId},
  76. </if>
  77. <if test="content != null">
  78. content = #{content},
  79. </if>
  80. <if test="status != null">
  81. `status` = #{status},
  82. </if>
  83. <if test="createBy != null">
  84. create_by = #{createBy},
  85. </if>
  86. <if test="dateCreate != null">
  87. date_create = #{dateCreate},
  88. </if>
  89. <if test="updateBy != null">
  90. update_by = #{updateBy},
  91. </if>
  92. <if test="dateUpdate != null">
  93. date_update = #{dateUpdate},
  94. </if>
  95. </set>
  96. where id = #{id}
  97. </update>
  98. <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
  99. <!--@mbg.generated-->
  100. insert into sc_warning_message
  101. (warning_log_id, content, `status`, create_by, date_create, update_by, date_update
  102. )
  103. values
  104. <foreach collection="list" item="item" separator=",">
  105. (#{item.warningLogId}, #{item.content}, #{item.status}, #{item.createBy}, #{item.dateCreate},
  106. #{item.updateBy}, #{item.dateUpdate})
  107. </foreach>
  108. </insert>
  109. <select id="findById" resultMap="BaseResultMap">
  110. select <include refid="Base_Column_List" /> from sc_warning_message where status = 1 and id = #{id}
  111. </select>
  112. <select id="getList" resultType="com.zoniot.ccrc.dto.WarningMessageDto">
  113. SELECT
  114. swm.*,
  115. swl.warning_type,
  116. swl.feedback_status,
  117. swl.feedback_content
  118. FROM sc_warning_message swm
  119. LEFT JOIN sc_warning_log swl on(swl.id = swm.warning_log_id)
  120. WHERE swm.`status` = 1 and swl.status = 1 and swl.device_id = #{deviceId}
  121. <if test="date != null"> and date_format(swm.date_create, '%Y%m%d') = #{date}</if>
  122. order by swm.date_create desc
  123. </select>
  124. <select id="getDateStatus" resultType="com.zoniot.ccrc.dto.WarningMessageStatusDto">
  125. SELECT
  126. date_format(swm.date_create, '%Y%m%d') as days,
  127. if(SUM(if(swl.feedback_status=0,1,0))>0,0,1) as feedback_status
  128. FROM sc_warning_message swm
  129. LEFT JOIN sc_warning_log swl on(swl.id = swm.warning_log_id)
  130. WHERE swm.`status` = 1 and swl.status = 1 and swl.device_id = #{deviceId}
  131. and date_format(swm.date_create, '%Y%m') = #{date}
  132. GROUP BY days
  133. order by days asc
  134. </select>
  135. </mapper>