RecordDeviceKeepsDao.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  2. <mapper namespace="cn.ourwill.module.house.dao.dm.RecordDeviceKeepsDao">
  3. <resultMap type="cn.ourwill.module.house.entity.dm.RecordDeviceKeeps" id="baseMap">
  4. <result column="id" property="id"/>
  5. <result column="uuid" property="uuid"/>
  6. <result column="model_uuid" property="modelUuid"/>
  7. <result column="grain_id" property="grainId"/>
  8. <result column="keep_time_start" property="keepTimeStart"/>
  9. <result column="keep_time_end" property="keepTimeEnd"/>
  10. <result column="keeper" property="keeper"/>
  11. <result column="c_id" property="cId"/>
  12. <result column="c_time" property="cTime"/>
  13. </resultMap>
  14. <resultMap type="cn.ourwill.module.house.entity.dm.RecordDeviceKeeps" id="mapOfFind" extends="baseMap">
  15. <result column="name" property="grainName"/>
  16. <result column="device_name" property="deviceName"/>
  17. <result column="device_model" property="deviceModel"/>
  18. <result column="device_manager" property="deviceManager"/>
  19. </resultMap>
  20. <sql id="columns">
  21. a.id ,
  22. a.uuid ,
  23. a.model_uuid ,
  24. a.grain_id ,
  25. a.keep_time_start ,
  26. a.keep_time_end ,
  27. a.keeper ,
  28. a.c_id ,
  29. a.c_time
  30. </sql>
  31. <sql id="columnsOfFind">
  32. sg.name ,
  33. ddm.device_name ,
  34. ddm.device_model ,
  35. ddm.device_manager ,
  36. </sql>
  37. <sql id="joinCols">
  38. </sql>
  39. <select id="get" resultMap="baseMap">
  40. SELECT
  41. <include refid="columns"/>
  42. FROM record_device_keeps a
  43. <include refid="joinCols"/>
  44. WHERE a.id = #{id}
  45. </select>
  46. <select id="getByUuid" resultMap="baseMap">
  47. SELECT
  48. <include refid="columns"/>
  49. FROM record_device_keeps a
  50. <include refid="joinCols"/>
  51. WHERE a.uuid = #{uuid}
  52. </select>
  53. <select id="findList" resultMap="mapOfFind">
  54. SELECT
  55. <include refid="columnsOfFind"/>
  56. <include refid="columns"/>
  57. FROM record_device_keeps a
  58. left join dm_device_model ddm on a.model_uuid = ddm.uuid
  59. left join sys_grain sg on sg.id = a.grain_id
  60. <include refid="joinCols"/>
  61. <where>
  62. <if test="id !=null">
  63. and a.id = #{id}
  64. </if>
  65. <if test="uuid !=null">
  66. and a.uuid = #{uuid}
  67. </if>
  68. <if test="modelUuid !=null">
  69. and a.model_uuid = #{modelUuid}
  70. </if>
  71. <if test="grainId !=null">
  72. and a.grain_id = #{grainId}
  73. </if>
  74. <if test="cityId !=null">
  75. and sg.parentId = #{cityId}
  76. </if>
  77. <if test="grainName !=null">
  78. and sg.name = #{grainName}
  79. </if>
  80. <if test="deviceName !=null and deviceName !=''">
  81. and ddm.device_name = #{deviceName}
  82. </if>
  83. <if test="deviceModel !=null and deviceModel !=''">
  84. and ddm.device_model = #{deviceModel}
  85. </if>
  86. <if test="keepTimeStart !=null">
  87. and a.keep_time_start = #{keepTimeStart}
  88. </if>
  89. <if test="keepTimeEnd !=null">
  90. and a.keep_time_end = #{keepTimeEnd}
  91. </if>
  92. <if test="keeper !=null">
  93. and a.keeper = #{keeper}
  94. </if>
  95. <if test="cId !=null">
  96. and a.c_id = #{cId}
  97. </if>
  98. <if test="cTime !=null">
  99. and a.c_time = #{cTime}
  100. </if>
  101. </where>
  102. <choose>
  103. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  104. ORDER BY ${page.orderBy}
  105. </when>
  106. <otherwise>
  107. </otherwise>
  108. </choose>
  109. </select>
  110. <select id="findAllList" resultMap="mapOfFind">
  111. SELECT
  112. <include refid="columnsOfFind"/>
  113. <include refid="columns"/>
  114. FROM record_device_keeps a
  115. left join dm_device_model ddm on a.model_uuid = ddm.uuid
  116. left join sys_grain sg on sg.id = a.grain_id
  117. <include refid="joinCols"/>
  118. <where>
  119. <if test="id !=null">
  120. and a.id = #{id}
  121. </if>
  122. <if test="uuid !=null">
  123. and a.uuid = #{uuid}
  124. </if>
  125. <if test="modelUuid !=null">
  126. and a.model_uuid = #{modelUuid}
  127. </if>
  128. <if test="grainId !=null">
  129. and a.grain_id = #{grainId}
  130. </if>
  131. <if test="grainName !=null">
  132. and sg.name = #{grainName}
  133. </if>
  134. <if test="deviceName !=null and deviceName !=''">
  135. and ddm.device_name = #{deviceName}
  136. </if>
  137. <if test="deviceModel !=null and deviceModel !=''">
  138. and ddm.device_model = #{deviceModel}
  139. </if>
  140. <if test="keepTimeStart !=null">
  141. and a.keep_time_start = #{keepTimeStart}
  142. </if>
  143. <if test="keepTimeEnd !=null">
  144. and a.keep_time_end = #{keepTimeEnd}
  145. </if>
  146. <if test="keeper !=null">
  147. and a.keeper = #{keeper}
  148. </if>
  149. <if test="cId !=null">
  150. and a.c_id = #{cId}
  151. </if>
  152. <if test="cTime !=null">
  153. and a.c_time = #{cTime}
  154. </if>
  155. </where>
  156. <choose>
  157. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  158. ORDER BY ${page.orderBy}
  159. </when>
  160. <otherwise>
  161. </otherwise>
  162. </choose>
  163. </select>
  164. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  165. parameterType="cn.ourwill.module.house.entity.dm.RecordDeviceKeeps">
  166. INSERT INTO record_device_keeps
  167. <trim prefix="(" suffix=")" suffixOverrides=",">
  168. <if test=" id != null">
  169. id,
  170. </if>
  171. <if test=" uuid != null">
  172. uuid,
  173. </if>
  174. <if test=" modelUuid != null">
  175. model_uuid,
  176. </if>
  177. <if test=" grainId != null">
  178. grain_id,
  179. </if>
  180. <if test=" keepTimeStart != null">
  181. keep_time_start,
  182. </if>
  183. <if test=" keepTimeEnd != null">
  184. keep_time_end,
  185. </if>
  186. <if test=" keeper != null">
  187. keeper,
  188. </if>
  189. <if test=" cId != null">
  190. c_id,
  191. </if>
  192. <if test=" cTime != null">
  193. c_time
  194. </if>
  195. </trim>
  196. <trim prefix="values (" suffix=")" suffixOverrides=",">
  197. <if test=" id != null">
  198. #{id},
  199. </if>
  200. <if test=" uuid != null">
  201. #{uuid},
  202. </if>
  203. <if test=" modelUuid != null">
  204. #{modelUuid},
  205. </if>
  206. <if test=" grainId != null">
  207. #{grainId},
  208. </if>
  209. <if test=" keepTimeStart != null">
  210. #{keepTimeStart},
  211. </if>
  212. <if test=" keepTimeEnd != null">
  213. #{keepTimeEnd},
  214. </if>
  215. <if test=" keeper != null">
  216. #{keeper},
  217. </if>
  218. <if test=" cId != null">
  219. #{cId},
  220. </if>
  221. <if test=" cTime != null">
  222. #{cTime}
  223. </if>
  224. </trim>
  225. </insert>
  226. <update id="update" parameterType="cn.ourwill.module.house.entity.dm.RecordDeviceKeeps">
  227. UPDATE record_device_keeps
  228. <set>
  229. <if test="id != null">
  230. id= #{id} ,
  231. </if>
  232. <if test="uuid != null">
  233. uuid= #{uuid} ,
  234. </if>
  235. <if test="modelUuid != null">
  236. model_uuid= #{modelUuid} ,
  237. </if>
  238. <if test="grainId != null">
  239. grain_id= #{grainId} ,
  240. </if>
  241. <if test="keepTimeStart != null">
  242. keep_time_start= #{keepTimeStart} ,
  243. </if>
  244. <if test="keepTimeEnd != null">
  245. keep_time_end= #{keepTimeEnd} ,
  246. </if>
  247. <if test="keeper != null">
  248. keeper= #{keeper} ,
  249. </if>
  250. <if test="cId != null">
  251. c_id= #{cId} ,
  252. </if>
  253. <if test="cTime != null">
  254. c_time= #{cTime}
  255. </if>
  256. </set>
  257. WHERE id = #{id}
  258. </update>
  259. <delete id="deleteById" parameterType="java.lang.Long">
  260. DELETE FROM record_device_keeps WHERE id = #{id}
  261. </delete>
  262. <delete id="deleteByIds" parameterType="java.util.List">
  263. DELETE FROM record_device_keeps WHERE id IN
  264. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  265. #{item}
  266. </foreach>
  267. </delete>
  268. </mapper>