RecordDeviceCustodyDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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.RecordDeviceCustodyDao">
  3. <resultMap type="cn.ourwill.module.house.entity.dm.RecordDeviceCustody" id="baseMap">
  4. <result column="id" property="id"/>
  5. <result column="grain_id" property="grainId"/>
  6. <result column="get_time" property="getTime"/>
  7. <result column="device_name" property="deviceName"/>
  8. <result column="device_model" property="deviceModel"/>
  9. <result column="remark" property="remark"/>
  10. <result column="device_count" property="deviceCount"/>
  11. <result column="number" property="number"/>
  12. <result column="store_count" property="storeCount"/>
  13. <result column="bookkeeper" property="bookkeeper"/>
  14. <result column="handler" property="handler"/>
  15. <result column="collator" property="collator"/>
  16. <result column="model_uuid" property="modelUuid"/>
  17. <result column="uuid" property="uuid"/>
  18. </resultMap>
  19. <resultMap type="cn.ourwill.module.house.entity.dm.RecordDeviceCustody" id="mapOfFind" extends="baseMap">
  20. <result column="id" property="id"/>
  21. <result column="get_time" property="getTime"/>
  22. <result column="device_name" property="deviceName"/>
  23. <result column="device_model" property="deviceModel"/>
  24. <result column="remark" property="remark"/>
  25. <result column="device_count" property="deviceCount"/>
  26. <result column="number" property="number"/>
  27. <result column="store_count" property="storeCount"/>
  28. <result column="bookkeeper" property="bookkeeper"/>
  29. <result column="handler" property="handler"/>
  30. <result column="collator" property="collator"/>
  31. <result column="model_uuid" property="modelUuid"/>
  32. <result column="uuid" property="uuid"/>
  33. </resultMap>
  34. <sql id="columns">
  35. a.id ,
  36. a.grain_id,
  37. a.get_time,
  38. a.device_name,
  39. a.device_model,
  40. a.remark,
  41. a.device_count,
  42. a.number,
  43. a.store_count,
  44. a.bookkeeper,
  45. a.`handler`,
  46. a.collator,
  47. a.model_uuid,
  48. a.uuid
  49. </sql>
  50. <!-- <sql id = "columsOfFind">
  51. sg.name,
  52. ddm.grain_id,
  53. ddm.device_name,
  54. ddm.device_model,
  55. ddm.device_manager ,
  56. </sql>-->
  57. <sql id="joinCols">
  58. </sql>
  59. <select id="get" resultMap="baseMap">
  60. SELECT
  61. <include refid="columns"/>
  62. FROM record_device_custody a
  63. <include refid="joinCols"/>
  64. WHERE a.id = #{id}
  65. </select>
  66. <select id="getByGrainIdList" resultMap="baseMap">
  67. SELECT
  68. <include refid="columns"/>
  69. FROM record_device_custody a
  70. <include refid="joinCols"/>
  71. WHERE a.grain_id = #{grainId}
  72. </select>
  73. <select id="findByGrainIdAndDeviceDC" resultType="java.lang.Integer">
  74. SELECT SUM(device_count) FROM record_device_custody a
  75. <include refid="joinCols"/>
  76. WHERE a.grain_id = #{gi} AND device_model=#{deviceModel} AND device_name=#{deviceName}
  77. </select>
  78. <select id="findByGrainIdAndDeviceSC" resultType="java.lang.Integer">
  79. SELECT SUM(number) FROM record_device_custody a
  80. <include refid="joinCols"/>
  81. WHERE a.grain_id = #{gi} AND device_model=#{deviceModel} AND device_name=#{deviceName}
  82. </select>
  83. <select id="getByUuid" resultMap="baseMap">
  84. SELECT
  85. <include refid="columns"/>
  86. FROM record_device_custody a
  87. <include refid="joinCols"/>
  88. WHERE a.uuid = #{uuid}
  89. </select>
  90. <select id="findList" resultMap="mapOfFind">
  91. SELECT
  92. <include refid="columns"/>
  93. FROM record_device_custody a
  94. LEFT JOIN sys_grain sg ON sg.id = a.grain_id
  95. <where>
  96. <if test="id !=null">
  97. and a.id = #{id}
  98. </if>
  99. <if test="cityId !=null and cityId !=''">
  100. and sg.parentId = #{cityId}
  101. </if>
  102. <if test="grainId !=null">
  103. and a.grain_id = #{grainId}
  104. </if>
  105. <if test="getTime !=null">
  106. and a.get_time like CONCAT('%',#{getTime},'%')
  107. </if>
  108. <if test="deviceName !=null and deviceName !=''">
  109. and a.device_name = #{deviceName}
  110. </if>
  111. <if test="deviceModel !=null and deviceModel !=''">
  112. and a.device_model = #{deviceModel}
  113. </if>
  114. <if test="remark !=null">
  115. and a.remark = #{remark}
  116. </if>
  117. <if test="deviceCount !=null">
  118. and a.device_count = #{deviceCount}
  119. </if>
  120. <if test="number !=null">
  121. and a.number = #{number}
  122. </if>
  123. <if test="storeCount !=null">
  124. and a.store_count = #{storeCount}
  125. </if>
  126. <if test="bookkeeper !=null">
  127. and a.bookkeeper = #{bookkeeper}
  128. </if>
  129. <if test="handler !=null">
  130. and a.handler = #{handler}
  131. </if>
  132. <if test="collator !=null">
  133. and a.collator = #{collator}
  134. </if>
  135. <if test="modelUuid !=null">
  136. and a.model_uuid = #{modelUuid}
  137. </if>
  138. <if test="uuid !=null">
  139. and a.uuid = #{uuid}
  140. </if>
  141. </where>
  142. <choose>
  143. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  144. ORDER BY ${page.orderBy}
  145. </when>
  146. <otherwise>
  147. </otherwise>
  148. </choose>
  149. </select>
  150. <select id="findListAll" resultMap="mapOfFind">
  151. SELECT
  152. *
  153. FROM record_device_custody a
  154. <include refid="joinCols"/>
  155. </select>
  156. <select id="findAllList" resultMap="mapOfFind">
  157. SELECT
  158. <include refid="columns"/>
  159. FROM record_device_custody a
  160. <where>
  161. <if test="id !=null">
  162. and a.id = #{id}
  163. </if>
  164. <if test="getTime !=null">
  165. and a.get_time = #{getTime}
  166. </if>
  167. <if test="deviceName !=null and deviceName !=''">
  168. and a.device_name = #{deviceName}
  169. </if>
  170. <if test="deviceModel !=null and deviceModel !=''">
  171. and a.device_model = #{deviceModel}
  172. </if>
  173. <if test="remark !=null">
  174. and a.remark = #{remark}
  175. </if>
  176. <if test="deviceCount !=null">
  177. and a.device_count = #{deviceCount}
  178. </if>
  179. <if test="number !=null">
  180. and a.number = #{number}
  181. </if>
  182. <if test="storeCount !=null">
  183. and a.store_count = #{storeCount}
  184. </if>
  185. <if test="bookkeeper !=null">
  186. and a.bookkeeper = #{bookkeeper}
  187. </if>
  188. <if test="handler !=null">
  189. and a.handler = #{handler}
  190. </if>
  191. <if test="collator !=null">
  192. and a.collator = #{collator}
  193. </if>
  194. <if test="modelUuid !=null">
  195. and a.model_uuid = #{modelUuid}
  196. </if>
  197. <if test="uuid !=null">
  198. and a.uuid = #{uuid}
  199. </if>
  200. </where>
  201. <choose>
  202. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  203. ORDER BY ${page.orderBy}
  204. </when>
  205. <otherwise>
  206. </otherwise>
  207. </choose>
  208. </select>
  209. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  210. parameterType="cn.ourwill.module.house.entity.dm.RecordDeviceCustody">
  211. INSERT INTO record_device_custody
  212. <trim prefix="(" suffix=")" suffixOverrides=",">
  213. <if test=" id != null">
  214. id,
  215. </if>
  216. <if test="grainId != null">
  217. grain_id,
  218. </if>
  219. <if test="getTime !=null">
  220. get_time ,
  221. </if>
  222. <if test="deviceName !=null and deviceName !=''">
  223. device_name ,
  224. </if>
  225. <if test="deviceModel !=null and deviceModel !=''">
  226. device_model ,
  227. </if>
  228. <if test="remark !=null">
  229. remark ,
  230. </if>
  231. <if test="deviceCount !=null">
  232. device_count ,
  233. </if>
  234. <if test="number !=null">
  235. `number`,
  236. </if>
  237. <if test="storeCount !=null">
  238. store_count,
  239. </if>
  240. <if test="bookkeeper !=null">
  241. bookkeeper ,
  242. </if>
  243. <if test="handler !=null">
  244. handler ,
  245. </if>
  246. <if test="collator !=null">
  247. collator ,
  248. </if>
  249. <if test="modelUuid !=null">
  250. model_uuid ,
  251. </if>
  252. <if test="uuid !=null">
  253. uuid
  254. </if>
  255. </trim>
  256. <trim prefix="values (" suffix=")" suffixOverrides=",">
  257. <if test=" id != null">
  258. #{id}, </if>
  259. <if test=" grainId != null">
  260. #{grainId}, </if>
  261. <if test="getTime !=null">
  262. #{getTime},
  263. </if>
  264. <if test="deviceName !=null and deviceName !=''">
  265. #{deviceName},
  266. </if>
  267. <if test="deviceModel !=null and deviceModel !=''">
  268. #{deviceModel},
  269. </if>
  270. <if test="remark !=null">
  271. #{remark},
  272. </if>
  273. <if test="deviceCount !=null">
  274. #{deviceCount},
  275. </if>
  276. <if test="number !=null">
  277. #{number},
  278. </if>
  279. <if test="storeCount !=null">
  280. #{storeCount},
  281. </if>
  282. <if test="bookkeeper !=null">
  283. #{bookkeeper},
  284. </if>
  285. <if test="handler !=null">
  286. #{handler},
  287. </if>
  288. <if test="collator !=null">
  289. #{collator},
  290. </if>
  291. <if test="modelUuid !=null">
  292. #{modelUuid},
  293. </if>
  294. <if test="uuid !=null">
  295. #{uuid}
  296. </if>
  297. </trim>
  298. </insert>
  299. <update id="update" parameterType="cn.ourwill.module.house.entity.dm.RecordDeviceCustody">
  300. UPDATE record_device_custody <set>
  301. <if test="id != null">
  302. id= #{id} ,
  303. </if>
  304. <if test="getTime !=null">
  305. get_time = #{getTime},
  306. </if>
  307. <if test="deviceName !=null and deviceName !=''">
  308. device_name = #{deviceName},
  309. </if>
  310. <if test="deviceModel !=null and deviceModel !=''">
  311. device_model = #{deviceModel},
  312. </if>
  313. <if test="remark !=null">
  314. remark = #{remark},
  315. </if>
  316. <if test="deviceCount !=null">
  317. device_count = #{deviceCount},
  318. </if>
  319. <if test="number !=null">
  320. number = #{number},
  321. </if>
  322. <if test="storeCount !=null">
  323. store_count = #{storeCount},
  324. </if>
  325. <if test="bookkeeper !=null">
  326. bookkeeper = #{bookkeeper},
  327. </if>
  328. <if test="handler !=null">
  329. handler = #{handler},
  330. </if>
  331. <if test="collator !=null">
  332. collator = #{collator},
  333. </if>
  334. <if test="modelUuid !=null">
  335. model_uuid = #{modelUuid},
  336. </if>
  337. <if test="uuid !=null">
  338. uuid = #{uuid}
  339. </if>
  340. </set>
  341. WHERE id = #{id}
  342. </update>
  343. <delete id="deleteById" parameterType="java.lang.Long">
  344. DELETE FROM record_device_custody WHERE id = #{id}
  345. </delete>
  346. <delete id="deleteByIds" parameterType="java.util.List">
  347. DELETE FROM record_device_custody WHERE id IN
  348. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  349. #{item}
  350. </foreach>
  351. </delete>
  352. </mapper>