DeviceCommandTaskMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.bz.smart_city.dao.DeviceCommandTaskMapper">
  4. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.DeviceCommandTask">
  5. <!--@mbg.generated-->
  6. <!--@Table sc_device_command_task-->
  7. <id column="id" property="id" />
  8. <result column="device_command_id" property="deviceCommandId" />
  9. <result column="name" property="name" />
  10. <result column="status" property="status" />
  11. <result column="date_create" property="dateCreate" />
  12. <result column="date_update" property="dateUpdate" />
  13. <result column="create_by" property="createBy" />
  14. <result column="update_by" property="updateBy" />
  15. </resultMap>
  16. <sql id="Base_Column_List">
  17. <!--@mbg.generated-->
  18. id, device_command_id, `name`, `status`, date_create, date_update, create_by, update_by
  19. </sql>
  20. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.DeviceCommandTask" useGeneratedKeys="true">
  21. <!--@mbg.generated-->
  22. insert into sc_device_command_task
  23. <trim prefix="(" suffix=")" suffixOverrides=",">
  24. <if test="deviceCommandId != null">
  25. device_command_id,
  26. </if>
  27. <if test="name != null">
  28. `name`,
  29. </if>
  30. <if test="status != null">
  31. `status`,
  32. </if>
  33. <if test="dateCreate != null">
  34. date_create,
  35. </if>
  36. <if test="dateUpdate != null">
  37. date_update,
  38. </if>
  39. <if test="createBy != null">
  40. create_by,
  41. </if>
  42. <if test="updateBy != null">
  43. update_by,
  44. </if>
  45. </trim>
  46. <trim prefix="values (" suffix=")" suffixOverrides=",">
  47. <if test="deviceCommandId != null">
  48. #{deviceCommandId},
  49. </if>
  50. <if test="name != null">
  51. #{name},
  52. </if>
  53. <if test="status != null">
  54. #{status},
  55. </if>
  56. <if test="dateCreate != null">
  57. #{dateCreate},
  58. </if>
  59. <if test="dateUpdate != null">
  60. #{dateUpdate},
  61. </if>
  62. <if test="createBy != null">
  63. #{createBy},
  64. </if>
  65. <if test="updateBy != null">
  66. #{updateBy},
  67. </if>
  68. </trim>
  69. </insert>
  70. <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.DeviceCommandTask">
  71. <!--@mbg.generated-->
  72. update sc_device_command_task
  73. <set>
  74. <if test="deviceCommandId != null">
  75. device_command_id = #{deviceCommandId},
  76. </if>
  77. <if test="name != null">
  78. `name` = #{name},
  79. </if>
  80. <if test="status != null">
  81. `status` = #{status},
  82. </if>
  83. <if test="dateCreate != null">
  84. date_create = #{dateCreate},
  85. </if>
  86. <if test="dateUpdate != null">
  87. date_update = #{dateUpdate},
  88. </if>
  89. <if test="createBy != null">
  90. create_by = #{createBy},
  91. </if>
  92. <if test="updateBy != null">
  93. update_by = #{updateBy},
  94. </if>
  95. </set>
  96. where id = #{id}
  97. </update>
  98. <select id="getList" resultType="com.bz.smart_city.dto.DeviceCommandDto">
  99. select
  100. ct.name,c.
  101. *,
  102. sd.device_no,
  103. sdt.equipment_type,sdt.model,sdm.name manufacturer_name
  104. from sc_device_command_task ct
  105. left join sc_device_command c on(c.id = ct.device_command_id)
  106. left join sc_device sd on(sd.id = c.device_id)
  107. left join sc_device_type sdt on (sdt.id = sd.device_type)
  108. left join sc_device_manufacturer sdm on (sdm.id = sd.manufacturer_id)
  109. where ct.status = 1 and sd.status = 1
  110. <if test="siteId != null"> and c.site_id = #{siteId}</if>
  111. <if test="deviceNo != null and deviceNo != ''"> AND sd.device_no LIKE concat('%',#{deviceNo},'%')</if>
  112. <if test="name != null and name != ''"> AND ct.name LIKE concat('%',#{name},'%')</if>
  113. <if test="commandType != null"> and c.command_type = #{commandType}</if>
  114. <if test="commandStatus != null"> and c.command_status = #{commandStatus}</if>
  115. <if test="customerIds != null and customerIds.size() != 0">
  116. and sd.customer_id in <foreach collection="customerIds" item="item" open="(" separator="," close=")">#{item}</foreach>
  117. </if>
  118. order by ct.date_create desc
  119. </select>
  120. </mapper>