DeviceInputDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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="cn.ourwill.module.house.dao.dm.DeviceInputDao">
  4. <resultMap type="cn.ourwill.module.house.entity.dm.DeviceInput" id="baseMap">
  5. <result column="id" property="id"/>
  6. <result column="type" property="type"/>
  7. <result column="subType" property="subType"/>
  8. <result column="number" property="number"/>
  9. <result column="name" property="name"/>
  10. <result column="model" property="model"/>
  11. <result column="count" property="count"/>
  12. <result column="inputTime" property="inputTime"/>
  13. <result column="houseId" property="houseId"/>
  14. <result column="cId" property="cId"/>
  15. <result column="uId" property="uId"/>
  16. <result column="cTime" property="cTime"/>
  17. <result column="uTime" property="uTime"/>
  18. <result column="version" property="version"/>
  19. <result column="uuid" property="uuid"/>
  20. <result column="provinceId" property="provinceId"/>
  21. <result column="cityId" property="cityId"/>
  22. <result column="grainId" property="grainId"/>
  23. <result column="threshold" property="threshold"/>
  24. <result column="warnTime" property="warnTime"/>
  25. </resultMap>
  26. <sql id="columns">
  27. id ,
  28. `type` ,
  29. subType ,
  30. `number` ,
  31. `name` ,
  32. model ,
  33. `count` ,
  34. inputTime ,
  35. houseId ,
  36. cId ,
  37. uId ,
  38. cTime ,
  39. uTime ,
  40. version ,
  41. uuid,
  42. provinceId,
  43. cityId,
  44. grainId,
  45. threshold,
  46. warnTime
  47. </sql>
  48. <sql id="joinCols">
  49. </sql>
  50. <select id="get" resultMap="baseMap">
  51. SELECT
  52. <include refid="columns"/>
  53. FROM dm_device_input a
  54. <include refid="joinCols"/>
  55. WHERE a.id = #{id}
  56. </select>
  57. <select id="findList" resultMap="baseMap">
  58. SELECT
  59. <include refid="columns"/>
  60. FROM dm_device_input a
  61. <include refid="joinCols"/>
  62. <where>
  63. <if test="id !=null">
  64. and id = #{id}
  65. </if>
  66. <if test="type !=null">
  67. and `type` = #{type}
  68. </if>
  69. <if test="subType !=null">
  70. and subType = #{subType}
  71. </if>
  72. <if test="number !=null">
  73. and `number` = #{number}
  74. </if>
  75. <if test="name !=null">
  76. and `name` like CONCAT('%',#{name},'%')
  77. </if>
  78. <if test="model !=null">
  79. and model = #{model}
  80. </if>
  81. <if test="count !=null">
  82. and `count` = #{count}
  83. </if>
  84. <if test="inputTime !=null">
  85. and inputTime = #{inputTime}
  86. </if>
  87. <if test="houseId !=null">
  88. and houseId = #{houseId}
  89. </if>
  90. <if test="cId !=null">
  91. and cId = #{cId}
  92. </if>
  93. <if test="uId !=null">
  94. and uId = #{uId}
  95. </if>
  96. <if test="cTime !=null">
  97. and cTime = #{cTime}
  98. </if>
  99. <if test="uTime !=null">
  100. and uTime = #{uTime}
  101. </if>
  102. <if test="version !=null">
  103. and version = #{version}
  104. </if>
  105. <if test="uuid !=null">
  106. and uuid = #{uuid}
  107. </if>
  108. <if test="provinceId !=null">
  109. and provinceId = #{provinceId}
  110. </if>
  111. <if test="cityId !=null">
  112. and cityId = #{cityId}
  113. </if>
  114. <if test="grainId !=null">
  115. and grainId = #{grainId}
  116. </if>
  117. </where>
  118. <choose>
  119. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  120. ORDER BY ${page.orderBy}
  121. </when>
  122. <otherwise>
  123. </otherwise>
  124. </choose>
  125. </select>
  126. <select id="findAllList" resultMap="baseMap">
  127. SELECT
  128. <include refid="columns"/>
  129. FROM dm_device_input a
  130. <include refid="joinCols"/>
  131. <where>
  132. <if test="id !=null">
  133. and id = #{id}
  134. </if>
  135. <if test="type !=null">
  136. and `type` = #{type}
  137. </if>
  138. <if test="subType !=null">
  139. and subType = #{subType}
  140. </if>
  141. <if test="number !=null">
  142. and `number` = #{number}
  143. </if>
  144. <if test="name !=null">
  145. and `name` = #{name}
  146. </if>
  147. <if test="model !=null">
  148. and model = #{model}
  149. </if>
  150. <if test="count !=null">
  151. and `count` = #{count}
  152. </if>
  153. <if test="inputTime !=null">
  154. and inputTime = #{inputTime}
  155. </if>
  156. <if test="houseId !=null">
  157. and houseId = #{houseId}
  158. </if>
  159. <if test="cId !=null">
  160. and cId = #{cId}
  161. </if>
  162. <if test="uId !=null">
  163. and uId = #{uId}
  164. </if>
  165. <if test="cTime !=null">
  166. and cTime = #{cTime}
  167. </if>
  168. <if test="uTime !=null">
  169. and uTime = #{uTime}
  170. </if>
  171. <if test="version !=null">
  172. and version = #{version}
  173. </if>
  174. <if test="uuid !=null">
  175. and uuid = #{uuid}
  176. </if>
  177. <if test="provinceId !=null">
  178. and provinceId = #{provinceId}
  179. </if>
  180. <if test="cityId !=null">
  181. and cityId = #{cityId}
  182. </if>
  183. <if test="grainId !=null">
  184. and grainId = #{grainId}
  185. </if>
  186. </where>
  187. <choose>
  188. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  189. ORDER BY ${page.orderBy}
  190. </when>
  191. <otherwise>
  192. </otherwise>
  193. </choose>
  194. </select>
  195. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  196. parameterType="cn.ourwill.module.house.entity.dm.DeviceInput">
  197. INSERT INTO dm_device_input
  198. <trim prefix="(" suffix=")" suffixOverrides=",">
  199. <if test=" id != null">
  200. id,
  201. </if>
  202. <if test=" type != null">
  203. `type`,
  204. </if>
  205. <if test=" subType != null">
  206. subType,
  207. </if>
  208. <if test=" number != null">
  209. `number`,
  210. </if>
  211. <if test=" name != null">
  212. `name`,
  213. </if>
  214. <if test=" model != null">
  215. model,
  216. </if>
  217. <if test=" count != null">
  218. `count`,
  219. </if>
  220. <if test=" inputTime != null">
  221. inputTime,
  222. </if>
  223. <if test=" houseId != null">
  224. houseId,
  225. </if>
  226. <if test=" cId != null">
  227. cId,
  228. </if>
  229. <if test=" uId != null">
  230. uId,
  231. </if>
  232. <if test=" cTime != null">
  233. cTime,
  234. </if>
  235. <if test=" uTime != null">
  236. uTime,
  237. </if>
  238. <if test=" version != null">
  239. version,
  240. </if>
  241. <if test=" uuid != null">
  242. uuid,
  243. </if>
  244. <if test="provinceId !=null">
  245. provinceId,
  246. </if>
  247. <if test="cityId !=null">
  248. cityId,
  249. </if>
  250. <if test="grainId !=null">
  251. grainId,
  252. </if>
  253. <if test="threshold !=null">
  254. threshold,
  255. </if>
  256. <if test="warnTime !=null">
  257. warnTime,
  258. </if>
  259. </trim>
  260. <trim prefix="values (" suffix=")" suffixOverrides=",">
  261. <if test=" id != null">
  262. #{id}, </if>
  263. <if test=" type != null">
  264. #{type}, </if>
  265. <if test=" subType != null">
  266. #{subType}, </if>
  267. <if test=" number != null">
  268. #{number}, </if>
  269. <if test=" name != null">
  270. #{name}, </if>
  271. <if test=" model != null">
  272. #{model}, </if>
  273. <if test=" count != null">
  274. #{count}, </if>
  275. <if test=" inputTime != null">
  276. #{inputTime}, </if>
  277. <if test=" houseId != null">
  278. #{houseId}, </if>
  279. <if test=" cId != null">
  280. #{cId}, </if>
  281. <if test=" uId != null">
  282. #{uId}, </if>
  283. <if test=" cTime != null">
  284. #{cTime}, </if>
  285. <if test=" uTime != null">
  286. #{uTime}, </if>
  287. <if test=" version != null">
  288. #{version}, </if>
  289. <if test=" uuid != null">
  290. #{uuid}, </if>
  291. <if test=" provinceId != null">
  292. #{provinceId}, </if>
  293. <if test=" cityId != null">
  294. #{cityId}, </if>
  295. <if test=" grainId != null">
  296. #{grainId}, </if>
  297. <if test=" threshold != null">
  298. #{threshold}, </if>
  299. <if test=" warnTime != null">
  300. #{warnTime} </if>
  301. </trim>
  302. </insert>
  303. <update id="update" parameterType="cn.ourwill.module.house.entity.dm.DeviceInput">
  304. UPDATE dm_device_input <set>
  305. <if test="id != null">
  306. id= #{id} ,
  307. </if>
  308. <if test="type != null">
  309. `type`= #{type} ,
  310. </if>
  311. <if test="subType != null">
  312. subType= #{subType} ,
  313. </if>
  314. <if test="number != null">
  315. `number`= #{number} ,
  316. </if>
  317. <if test="name != null">
  318. `name`= #{name} ,
  319. </if>
  320. <if test="model != null">
  321. model= #{model} ,
  322. </if>
  323. <if test="count != null">
  324. `count`= #{count} ,
  325. </if>
  326. <if test="inputTime != null">
  327. inputTime= #{inputTime} ,
  328. </if>
  329. <if test="houseId != null">
  330. houseId= #{houseId} ,
  331. </if>
  332. <if test="cId != null">
  333. cId= #{cId} ,
  334. </if>
  335. <if test="uId != null">
  336. uId= #{uId} ,
  337. </if>
  338. <if test="cTime != null">
  339. cTime= #{cTime} ,
  340. </if>
  341. <if test="uTime != null">
  342. uTime= #{uTime} ,
  343. </if>
  344. <if test="version != null">
  345. version= #{version} ,
  346. </if>
  347. <if test="uuid != null">
  348. uuid= #{uuid},
  349. </if>
  350. <if test="provinceId != null">
  351. provinceId= #{provinceId},
  352. </if>
  353. <if test="cityId != null">
  354. cityId= #{cityId},
  355. </if>
  356. <if test="grainId != null">
  357. grainId= #{grainId},
  358. </if>
  359. <if test="threshold != null">
  360. threshold= #{threshold},
  361. </if>
  362. <if test="warnTime != null">
  363. warnTime= #{warnTime}
  364. </if>
  365. </set>
  366. WHERE id = #{id}
  367. </update>
  368. <delete id="deleteById" parameterType="java.lang.Long">
  369. DELETE FROM dm_device_input WHERE id = #{id}
  370. </delete>
  371. <delete id="deleteByIds" parameterType="java.util.List">
  372. DELETE FROM dm_device_input WHERE id IN
  373. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  374. #{item}
  375. </foreach>
  376. </delete>
  377. <!--获取型号信息-->
  378. <select id="getModelList" resultMap="baseMap">
  379. SELECT
  380. DISTINCT(model) as model
  381. FROM dm_device_input a
  382. where subType=#{subType}
  383. order by model asc
  384. </select>
  385. <!--获取编号信息-->
  386. <select id="getNumberList" resultMap="baseMap">
  387. SELECT
  388. DISTINCT(number) as number
  389. FROM dm_device_input a
  390. where subType=#{subType} and model=#{model}
  391. order by number asc
  392. </select>
  393. </mapper>