DeviceMachineUseNewDao.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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.new_dao.DeviceMachineUseNewDao" >
  4. <resultMap type="cn.ourwill.module.house.entity.new_entity.DeviceMachineUseNew" id="baseMap" >
  5. <id column="id" property="id" />
  6. <result column="grain_id" property="grainId" />
  7. <result column="create_time" property="createTime" />
  8. <result column="remark" property="remark" />
  9. <result column="is_inout" property="isInout" />
  10. <result column="c_id" property="cId" />
  11. <result column="c_time" property="cTime" />
  12. <result column="u_id" property="uId"/>
  13. <result column="u_time" property="uTime" />
  14. <result column="uuid" property="uuid" />
  15. <result column="device_id" property="deviceId" />
  16. <result column="model_uuid" property="modelUuid" />
  17. <result column="get_uuid" property="getUuid" />
  18. <result column="collator" property="collator" />
  19. <result column="handler" property="handler" />
  20. <result column="bookkeeper" property="bookkeeper" />
  21. </resultMap>
  22. <sql id="columns">
  23. a.id,
  24. a.grain_id,
  25. a.create_time,
  26. a.remark,
  27. a.is_inout,
  28. a.c_id,
  29. a.c_time,
  30. a.u_id,
  31. a.u_time,
  32. a.device_id,
  33. a.model_uuid,
  34. a.uuid,
  35. a.bookkeeper,
  36. a.handler,
  37. a.collator,
  38. a.get_uuid
  39. </sql>
  40. <sql id = "columsOfFindd">
  41. sg.name AS grainName,
  42. ddm.device_name,
  43. ddm.device_model,
  44. ddm.device_manager ,
  45. </sql>
  46. <sql id = "columsOfFi">
  47. dd.asset_number,
  48. dd.place_of_origin,
  49. dd.device_unit,
  50. dd.price,
  51. dd.voucher_type,
  52. dd.voucher_number,
  53. </sql>
  54. <sql id="joinCols">
  55. </sql>
  56. <select id="get" resultMap="baseMap">
  57. SELECT
  58. dd.device_no,
  59. <include refid="columsOfFindd"/>
  60. <include refid="columsOfFi"/>
  61. <include refid="columns"/>
  62. FROM device_machine_use_new a
  63. LEFT JOIN dm_device_model ddm ON a.model_uuid = ddm.uuid
  64. LEFT JOIN dm_device dd ON a.device_id = dd.id
  65. LEFT JOIN sys_grain sg ON sg.id = a.grain_id
  66. <include refid="joinCols"/>
  67. WHERE a.id = #{id}
  68. </select>
  69. <select id="getByDeviceNo" resultMap="baseMap">
  70. SELECT
  71. dd.device_no,
  72. <include refid="columsOfFindd"/>
  73. <include refid="columsOfFi"/>
  74. <include refid="columns"/>
  75. FROM device_machine_use_new a
  76. LEFT JOIN dm_device_model ddm ON a.model_uuid = ddm.uuid
  77. LEFT JOIN dm_device dd ON a.device_id = dd.id
  78. LEFT JOIN sys_grain sg ON sg.id = a.grain_id
  79. <include refid="joinCols"/>
  80. WHERE dd.device_no = #{deviceNo} AND a.create_time LIKE #{createTime}
  81. ORDER BY a.id
  82. </select>
  83. <select id="findListByDeviceNo" resultMap="baseMap">
  84. SELECT
  85. dd.device_no,
  86. <include refid="columsOfFindd"/>
  87. <include refid="columsOfFi"/>
  88. <include refid="columns"/>
  89. FROM device_machine_use_new a
  90. LEFT JOIN dm_device_model ddm ON a.model_uuid = ddm.uuid
  91. LEFT JOIN dm_device dd ON a.device_id = dd.id
  92. /*LEFT JOIN record_device_get rdg ON a.get_uuid = rdg.uuid*/
  93. LEFT JOIN sys_grain sg ON sg.id = a.grain_id
  94. <include refid="joinCols"/>
  95. <where>
  96. <if test="id !=null">
  97. and a.id = #{id}
  98. </if>
  99. <if test="grainId !=null">
  100. and a.grain_id = #{grainId}
  101. </if>
  102. <if test="bookkeeper !=null">
  103. and a.bookkeeper = #{bookkeeper}
  104. </if>
  105. <if test="handler !=null">
  106. and a.handler = #{handler}
  107. </if>
  108. <if test="collator !=null">
  109. and a.collator = #{collator}
  110. </if>
  111. <if test="grainName !=null">
  112. and sg.name = #{grainName}
  113. </if>
  114. <if test="deviceName !=null">
  115. and ddm.device_name = #{deviceName}
  116. </if>
  117. <if test="deviceModel !=null">
  118. and ddm.device_model = #{deviceModel}
  119. </if>
  120. <if test="assetNumber !=null">
  121. and dd.asset_number = #{assetNumber}
  122. </if>
  123. <if test="deviceNo !=null">
  124. and dd.device_no = #{deviceNo}
  125. </if>
  126. <if test="createTime !=null">
  127. and a.create_time = #{createTime}
  128. </if>
  129. <if test="remark !=null">
  130. and a.remark = #{remark}
  131. </if>
  132. <if test="isInout !=null">
  133. and a.is_inout = #{isInout}
  134. </if>
  135. <if test="price !=null">
  136. and dd.price = #{price}
  137. </if>
  138. <if test="deviceUnit !=null">
  139. and dd.device_unit = #{deviceUnit}
  140. </if>
  141. <if test="uuid !=null">
  142. and a.uuid = #{uuid}
  143. </if>
  144. <if test="modelUuid !=null">
  145. and a.model_uuid = #{modelUuid}
  146. </if>
  147. <if test="deviceId !=null">
  148. and a.device_id = #{deviceId}
  149. </if>
  150. <if test="cId !=null">
  151. and a.c_id = #{cId}
  152. </if>
  153. <if test="cTime !=null">
  154. and a.c_time = #{cTime}
  155. </if>
  156. <if test="uId !=null">
  157. and a.u_id = #{uId}
  158. </if>
  159. <if test="uTime !=null">
  160. and a.u_time = #{uTime}
  161. </if>
  162. </where>
  163. <choose>
  164. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  165. ORDER BY ${page.orderBy}
  166. </when>
  167. <otherwise>
  168. </otherwise>
  169. </choose>
  170. </select>
  171. <select id="findList" resultMap="baseMap">
  172. SELECT
  173. DISTINCT dd.device_no,
  174. <include refid="columsOfFindd"/>
  175. <include refid="columsOfFi"/>
  176. <include refid="columns"/>
  177. FROM device_machine_use_new a
  178. LEFT JOIN dm_device_model ddm ON a.model_uuid = ddm.uuid
  179. LEFT JOIN dm_device dd ON a.device_id = dd.id
  180. /*LEFT JOIN record_device_get rdg ON a.get_uuid = rdg.uuid*/
  181. LEFT JOIN sys_grain sg ON sg.id = a.grain_id
  182. <include refid="joinCols"/>
  183. <where>
  184. <if test="id !=null">
  185. and a.id = #{id}
  186. </if>
  187. <if test="cityId !=null and cityId !=''">
  188. and sg.parentId = #{cityId}
  189. </if>
  190. <if test="bookkeeper !=null">
  191. and a.bookkeeper = #{bookkeeper}
  192. </if>
  193. <if test="handler !=null">
  194. and a.handler = #{handler}
  195. </if>
  196. <if test="collator !=null">
  197. and a.collator = #{collator}
  198. </if>
  199. <if test="grainId !=null">
  200. and a.grain_id = #{grainId}
  201. </if>
  202. <if test="grainName !=null">
  203. and sg.name = #{grainName}
  204. </if>
  205. <if test="deviceName !=null">
  206. and ddm.device_name = #{deviceName}
  207. </if>
  208. <if test="deviceModel !=null">
  209. and ddm.device_model = #{deviceModel}
  210. </if>
  211. <if test="assetNumber !=null">
  212. and dd.asset_number = #{assetNumber}
  213. </if>
  214. <if test="deviceNo !=null">
  215. and dd.device_no = #{deviceNo}
  216. </if>
  217. <if test="createTime !=null">
  218. and a.create_time = #{createTime}
  219. </if>
  220. <if test="remark !=null">
  221. and a.remark = #{remark}
  222. </if>
  223. <if test="isInout !=null">
  224. and a.is_inout = #{isInout}
  225. </if>
  226. <if test="price !=null">
  227. and dd.price = #{price}
  228. </if>
  229. <if test="deviceUnit !=null">
  230. and dd.device_unit = #{deviceUnit}
  231. </if>
  232. <if test="uuid !=null">
  233. and a.uuid = #{uuid}
  234. </if>
  235. <if test="modelUuid !=null">
  236. and a.model_uuid = #{modelUuid}
  237. </if>
  238. <if test="deviceId !=null">
  239. and a.device_id = #{deviceId}
  240. </if>
  241. <if test="cId !=null">
  242. and a.c_id = #{cId}
  243. </if>
  244. <if test="cTime !=null">
  245. and a.c_time = #{cTime}
  246. </if>
  247. <if test="uId !=null">
  248. and a.u_id = #{uId}
  249. </if>
  250. <if test="uTime !=null">
  251. and a.u_time = #{uTime}
  252. </if>
  253. </where>
  254. GROUP BY dd.device_no
  255. <choose>
  256. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  257. ORDER BY ${page.orderBy}
  258. </when>
  259. <otherwise>
  260. </otherwise>
  261. </choose>
  262. </select>
  263. <select id="getborrowList" resultMap="baseMap">
  264. SELECT
  265. hf.house_name,
  266. dd.device_no,
  267. a.other_house,
  268. sg.name ,
  269. ddm.device_name ,
  270. ddm.device_model ,
  271. ddm.device_kind,
  272. a.id ,
  273. a.uuid ,
  274. a.grain_id ,
  275. a.house_id ,
  276. a.get_man ,
  277. a.get_number ,
  278. a.back_number ,
  279. a.bookkeeper ,
  280. a.handler ,
  281. a.`number` ,
  282. a.unit ,
  283. a.collator ,
  284. a.get_time ,
  285. a.device_describe ,
  286. a.remark ,
  287. a.c_id ,
  288. a.c_time ,
  289. a.u_id ,
  290. a.u_time ,
  291. a.model_uuid,
  292. a.grain_get_id,
  293. a.other_house,
  294. a.device_id_of,
  295. a.workingStatus,
  296. a.grain_type,
  297. a.pro_num,
  298. a.department_head,
  299. a.leaders_in_charge
  300. FROM record_device_get a
  301. left join dm_device_model ddm on a.model_uuid = ddm.uuid
  302. left join sys_grain sg on sg.id = a.grain_id
  303. left join house_info hf on a.house_id=hf.id
  304. left join device_get_log dgl on dgl.get_uuid=a.uuid
  305. left JOIN dm_device dd on dd.uuid=dgl.device_uuid
  306. <include refid="joinCols"/>
  307. WHERE a.id = #{id}
  308. </select>
  309. <select id="getReturnList" resultMap="baseMap">
  310. SELECT
  311. hf.house_name,
  312. rdb.get_uuid,
  313. rdb.collator,
  314. rdb.bookkeeper,
  315. rdb.return_time,
  316. rdb.status_repair,
  317. rdb.device_no,
  318. a.other_house,
  319. sg.name ,
  320. ddm.device_name ,
  321. ddm.device_model ,
  322. ddm.device_kind,
  323. a.id ,
  324. a.uuid ,
  325. a.grain_id ,
  326. a.house_id ,
  327. a.get_man ,
  328. a.get_number ,
  329. a.back_number ,
  330. a.bookkeeper ,
  331. a.handler ,
  332. a.`number` ,
  333. a.unit ,
  334. a.collator ,
  335. a.get_time ,
  336. a.device_describe ,
  337. a.remark ,
  338. a.c_id ,
  339. a.c_time ,
  340. a.u_id ,
  341. a.u_time ,
  342. a.model_uuid,
  343. a.grain_get_id,
  344. a.other_house,
  345. a.device_id_of,
  346. a.workingStatus,
  347. a.grain_type,
  348. a.pro_num,
  349. a.department_head,
  350. a.leaders_in_charge
  351. FROM
  352. record_device_get a
  353. LEFT JOIN sys_grain sg ON sg.id = a.grain_id
  354. LEFT JOIN house_info hf ON a.house_id = hf.id
  355. LEFT JOIN dm_device_model ddm ON a.model_uuid = ddm.uuid
  356. LEFT JOIN record_device_back rdb ON rdb.get_uuid = a.uuid
  357. WHERE a.id = #{id} and a.back_number<![CDATA[ <> ]]>'0'
  358. </select>
  359. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  360. parameterType="cn.ourwill.module.house.entity.new_entity.DeviceMachineUseNew">
  361. INSERT INTO device_machine_use_new
  362. <trim prefix="(" suffix=")" suffixOverrides=",">
  363. <if test=" id != null">
  364. id,
  365. </if>
  366. <if test="bookkeeper !=null">
  367. bookkeeper ,
  368. </if>
  369. <if test="handler !=null">
  370. handler ,
  371. </if>
  372. <if test="collator !=null">
  373. collator,
  374. </if>
  375. <if test="grainId !=null">
  376. grain_id ,
  377. </if>
  378. <if test="createTime !=null">
  379. create_time ,
  380. </if>
  381. <if test="remark !=null">
  382. remark ,
  383. </if>
  384. <if test="isInout !=null">
  385. is_inout ,
  386. </if>
  387. <if test="uuid !=null">
  388. uuid ,
  389. </if>
  390. <if test="cId !=null">
  391. c_id ,
  392. </if>
  393. <if test="cTime !=null">
  394. c_time ,
  395. </if>
  396. <if test="uId !=null">
  397. u_id ,
  398. </if>
  399. <if test="uTime !=null">
  400. u_time ,
  401. </if>
  402. <if test="modelUuid !=null">
  403. model_uuid,
  404. </if>
  405. <if test="deviceId !=null">
  406. device_id,
  407. </if>
  408. <if test="getUuid !=null">
  409. get_uuid
  410. </if>
  411. </trim>
  412. <trim prefix="values (" suffix=")" suffixOverrides=",">
  413. <if test=" id != null">
  414. #{id}, </if>
  415. <if test="bookkeeper !=null">
  416. #{bookkeeper},
  417. </if>
  418. <if test="handler !=null">
  419. #{handler},
  420. </if>
  421. <if test="collator !=null">
  422. #{collator},
  423. </if>
  424. <if test="grainId !=null">
  425. #{grainId},
  426. </if>
  427. <if test="createTime !=null">
  428. #{createTime},
  429. </if>
  430. <if test="remark !=null">
  431. #{remark},
  432. </if>
  433. <if test="isInout !=null">
  434. #{isInout},
  435. </if>
  436. <if test="uuid !=null">
  437. #{uuid},
  438. </if>
  439. <if test="cId !=null">
  440. #{cId},
  441. </if>
  442. <if test="cTime !=null">
  443. #{cTime},
  444. </if>
  445. <if test="uId !=null">
  446. #{uId},
  447. </if>
  448. <if test="uTime !=null">
  449. #{uTime},
  450. </if>
  451. <if test="modelUuid !=null">
  452. #{modelUuid},
  453. </if>
  454. <if test="deviceId !=null">
  455. #{deviceId},
  456. </if>
  457. <if test="getUuid !=null">
  458. #{getUuid}
  459. </if>
  460. </trim>
  461. </insert>
  462. <update id="update" parameterType="cn.ourwill.module.house.entity.new_entity.DeviceMachineUseNew">
  463. UPDATE record_device_machine_new <set>
  464. <if test="id != null">
  465. id= #{id} ,
  466. </if>
  467. <if test="bookkeeper !=null">
  468. bookkeeper = #{bookkeeper},
  469. </if>
  470. <if test="handler !=null">
  471. handler = #{handler},
  472. </if>
  473. <if test="collator !=null">
  474. collator = #{collator},
  475. </if>
  476. <if test="grainId !=null">
  477. grain_id = #{grainId},
  478. </if>
  479. <if test="createTime !=null">
  480. create_time = #{createTime},
  481. </if>
  482. <if test="remark !=null">
  483. remark = #{remark},
  484. </if>
  485. <if test="isInout !=null">
  486. is_inout = #{isInout},
  487. </if>
  488. <if test="deviceId !=null">
  489. device_id = #{deviceId},
  490. </if>
  491. <if test="uuid !=null">
  492. uuid = #{uuid},
  493. </if>
  494. <if test="cId !=null">
  495. c_id = #{cId},
  496. </if>
  497. <if test="cTime !=null">
  498. c_time = #{cTime},
  499. </if>
  500. <if test="uId !=null">
  501. u_id = #{uId},
  502. </if>
  503. <if test="uTime !=null">
  504. u_time = #{uTime},
  505. </if>
  506. <if test="modelUuid !=null">
  507. model_uuid = #{modelUuid},
  508. </if>
  509. <if test="getUuid !=null">
  510. get_uuid = #{getUuid}
  511. </if>
  512. </set>
  513. WHERE id = #{id}
  514. </update>
  515. <delete id="deleteById" parameterType="java.lang.Long">
  516. DELETE FROM device_machine_use_new WHERE id = #{id}
  517. </delete>
  518. <delete id="deleteByIds" parameterType="java.util.List">
  519. DELETE FROM device_machine_use_new WHERE id IN
  520. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  521. #{item}
  522. </foreach>
  523. </delete>
  524. </mapper>