DeviceModelDao.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  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.DeviceModelDao">
  3. <resultMap type="cn.ourwill.module.house.entity.dm.DeviceModel" id="baseMap">
  4. <result column="id" property="id"/>
  5. <result column="uuid" property="uuid"/>
  6. <result column="grain_id" property="grainId"/>
  7. <result column="device_name" property="deviceName"/>
  8. <result column="device_model" property="deviceModel"/>
  9. <result column="device_manager" property="deviceManager"/>
  10. <result column="collator" property="collator"/>
  11. <result column="purchaser" property="purchaser"/>
  12. <result column="service_life" property="serviceLife"/>
  13. <result column="remark" property="remark"/>
  14. <result column="asset_number" property="assetNumber"/>
  15. <result column="device_document" property="device_document"/>
  16. <result column="position" property="position"/>
  17. <result column="storagerack" property="storagerack"/>
  18. <result column="storagerack_cell" property="storagerackCell"/>
  19. <result column="device_kind" property="device_kind"/>
  20. <result column="device_id_of" property="device_id_of"/>
  21. <result column="device_name_of" property="device_name_of"/>
  22. <result column="device_model_of" property="device_model_of"/>
  23. <result column="warning_num" property="warningNum"/>
  24. </resultMap>
  25. <resultMap type="cn.ourwill.module.house.entity.dm.DeviceModel" id="mapForStatistics" extends="baseMap">
  26. <result column="name" property="grainName"/>
  27. <result column="count" property="count"/>
  28. <result column="nearScrapCount" property="nearScrapCount"/>
  29. <result column="troubleCount" property="troubleCount"/>
  30. </resultMap>
  31. <sql id="columns">
  32. id ,
  33. uuid ,
  34. grain_id ,
  35. device_name ,
  36. device_model ,
  37. device_manager ,
  38. collator ,
  39. purchaser ,
  40. service_life ,
  41. remark,
  42. asset_number,
  43. device_document,
  44. position,
  45. storagerack,
  46. storagerack_cell,
  47. device_kind,
  48. device_id_of,
  49. device_name_of,
  50. device_model_of,
  51. warning_num
  52. </sql>
  53. <sql id="columns2">
  54. a.id ,
  55. a.uuid ,
  56. a.grain_id ,
  57. a.device_name ,
  58. a.device_model ,
  59. a.device_manager ,
  60. a.collator ,
  61. a.purchaser ,
  62. a.service_life ,
  63. a.remark,
  64. aa.asset_number,
  65. a.device_document,
  66. a.position,
  67. a.storagerack,
  68. a.storagerack_cell,
  69. a.device_kind,
  70. a.device_id_of,
  71. a.device_name_of,
  72. a.device_model_of,
  73. aa.device_no,
  74. aa.usage_document,
  75. aa.year_of_purchase,
  76. aa.net_asset_value,
  77. aa.status_repair,
  78. aa.producer,
  79. aa.place_of_origin,
  80. aa.status_repair
  81. </sql>
  82. <sql id="columns223">
  83. a.id ,
  84. a.uuid ,
  85. a.grain_id ,
  86. a.device_name ,
  87. a.device_model ,
  88. a.device_manager ,
  89. a.collator ,
  90. a.purchaser ,
  91. a.service_life ,
  92. a.remark,
  93. a.device_document,
  94. a.position,
  95. a.storagerack,
  96. a.storagerack_cell,
  97. a.device_kind,
  98. a.device_id_of,
  99. a.device_name_of,
  100. a.device_model_of
  101. </sql>
  102. <sql id="columns3">
  103. a.id ,
  104. a.uuid ,
  105. a.device_name ,
  106. a.device_model
  107. </sql>
  108. <sql id="joinCols">
  109. </sql>
  110. <select id="get" resultMap="baseMap">
  111. SELECT
  112. <include refid="columns"/>
  113. FROM dm_device_model a
  114. <include refid="joinCols"/>
  115. WHERE a.id = #{id}
  116. </select>
  117. <select id="getByUuid" resultMap="baseMap">
  118. SELECT
  119. <include refid="columns"/>
  120. FROM dm_device_model a
  121. <include refid="joinCols"/>
  122. WHERE a.uuid = #{uuid}
  123. </select>
  124. <!-- <select id="getPage" resultMap="baseMap">
  125. SELECT
  126. <include refid="columns"/>
  127. FROM dm_device_model a
  128. <include refid="joinCols"/>
  129. WHERE a.uuid = #{uuid}
  130. </select>-->
  131. <select id="getPag" resultMap="baseMap">
  132. SELECT
  133. <include refid="columns"/>
  134. FROM dm_device_model a
  135. <include refid="joinCols"/>
  136. WHERE a.uuid = #{uuid}
  137. </select>
  138. <select id="getInfoStatistics" resultMap="mapForStatistics">
  139. select
  140. ddm.uuid as uuid,
  141. sg.name as name,
  142. ddm.device_name as device_name,
  143. ddm.device_model as device_model,
  144. count(dd.id) as count,
  145. sum(case when dd.status=1 then 1 else 0 end) as nearScrapCount,
  146. sum(case when dd.status_repair = 2 then 1 else 0 end) as troubleCount,
  147. ddm.device_manager as device_manager
  148. from dm_device dd
  149. left join dm_device_model ddm on dd.model_uuid = ddm.uuid
  150. left join sys_grain sg on ddm.grain_id = sg.id
  151. <where>
  152. <if test="deviceName !=null and deviceName !=''">
  153. and ddm.device_name = #{deviceName}
  154. </if>
  155. <if test="deviceModel !=null and deviceModel !=''">
  156. and ddm.device_model = #{deviceModel}
  157. </if>
  158. <if test="grainId !=null and grainId !=''">
  159. and ddm.grain_id = #{grainId}
  160. </if>
  161. <if test="cityId !=null and cityId !=''">
  162. and sg.parentId = #{cityId}
  163. </if>
  164. </where>
  165. group by dd.model_uuid
  166. <choose>
  167. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  168. ORDER BY ${page.orderBy}
  169. </when>
  170. <otherwise>
  171. </otherwise>
  172. </choose>
  173. </select>
  174. <resultMap type="cn.ourwill.module.house.entity.dm.DeviceModel" id="storeMap" extends="baseMap">
  175. <result column="grainName" property="grainName"/>
  176. <result column="stock" property="stock"/>
  177. </resultMap>
  178. <select id="getList" resultMap="storeMap">
  179. SELECT
  180. ddm.id AS id,
  181. ddm.uuid AS uuid,
  182. sg. NAME AS grain_name,
  183. sg.id AS grainid,
  184. ddm.device_name AS device_name,
  185. ifnull(sum(dd.store_count), 0) AS stock,
  186. ddm.device_kind AS device_kind,
  187. ddm.device_model AS device_model,
  188. ddm.device_manager AS device_manager,
  189. ddm.collator AS collator
  190. FROM
  191. (
  192. SELECT
  193. id,
  194. uuid,
  195. device_model,
  196. device_name,
  197. device_manager,
  198. collator,
  199. grain_id,
  200. device_kind
  201. FROM
  202. dm_device_model
  203. ) ddm
  204. LEFT JOIN (
  205. SELECT
  206. dc.store_count,dc.model_uuid
  207. FROM
  208. dm_device dc
  209. WHERE
  210. dc.status IN (0, 1)
  211. AND dc.status_repair = '0'
  212. ) dd ON dd.model_uuid = ddm.uuid
  213. LEFT JOIN sys_grain sg ON ddm.grain_id = sg.id
  214. <where>
  215. <if test="deviceName !=null and deviceName !=''">
  216. and ddm.device_name like CONCAT('%','${deviceName}','%' )
  217. </if>
  218. <if test="deviceModel !=null and deviceModel !=''">
  219. and ddm.device_model = #{deviceModel}
  220. </if>
  221. <if test="grainId !=null and grainId !=''">
  222. and ddm.grain_id = #{grainId}
  223. </if>
  224. <if test="cityId !=null and cityId !=''">
  225. and sg.parentId = #{cityId}
  226. </if>
  227. <if test="device_kind !=null">
  228. and ddm.device_kind = #{device_kind}
  229. </if>
  230. <if test="uuid !=null">
  231. and ddm.uuid = #{uuid}
  232. </if>
  233. </where>
  234. GROUP BY ddm.id
  235. <choose>
  236. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  237. ORDER BY ${page.orderBy}
  238. </when>
  239. <otherwise>
  240. </otherwise>
  241. </choose>
  242. </select>
  243. <select id="getMaterialList" resultMap="storeMap">
  244. SELECT
  245. ddm.id AS id,
  246. ddm.uuid AS uuid,
  247. sg. NAME AS grain_name,
  248. sg.id AS grainid,
  249. ddm.device_name AS device_name,
  250. ifnull(sum(dd.store_count), 0) AS stock,
  251. ddm.device_kind AS device_kind,
  252. ddm.device_model AS device_model,
  253. ddm.device_manager AS device_manager,
  254. ddm.collator AS collator
  255. FROM
  256. (
  257. SELECT
  258. id,
  259. uuid,
  260. device_model,
  261. device_name,
  262. device_manager,
  263. collator,
  264. grain_id,
  265. device_kind
  266. FROM
  267. dm_device_model
  268. WHERE device_kind!='1'
  269. ) ddm
  270. LEFT JOIN (
  271. SELECT
  272. dc.store_count,dc.model_uuid
  273. FROM
  274. dm_device dc
  275. WHERE
  276. dc.status IN (0, 1)
  277. AND dc.status_repair = '0'
  278. ) dd ON dd.model_uuid = ddm.uuid
  279. LEFT JOIN sys_grain sg ON ddm.grain_id = sg.id
  280. <where>
  281. <if test="deviceName !=null and deviceName !=''">
  282. and ddm.device_name like CONCAT('%','${deviceName}','%' )
  283. </if>
  284. <if test="deviceModel !=null and deviceModel !=''">
  285. and ddm.device_model = #{deviceModel}
  286. </if>
  287. <if test="grainId !=null and grainId !=''">
  288. and ddm.grain_id = #{grainId}
  289. </if>
  290. <if test="cityId !=null and cityId !=''">
  291. and sg.parentId = #{cityId}
  292. </if>
  293. <if test="device_kind !=null">
  294. and ddm.device_kind = #{device_kind}
  295. </if>
  296. <if test="uuid !=null">
  297. and ddm.uuid = #{uuid}
  298. </if>
  299. </where>
  300. GROUP BY ddm.id
  301. <choose>
  302. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  303. ORDER BY ${page.orderBy}
  304. </when>
  305. <otherwise>
  306. </otherwise>
  307. </choose>
  308. </select>
  309. <select id="getDeviceList" resultMap="storeMap">
  310. SELECT
  311. ddm.id AS id,
  312. ddm.uuid AS uuid,
  313. sg. NAME AS grain_name,
  314. sg.id AS grainid,
  315. ddm.device_name AS device_name,
  316. ifnull(sum(dd.store_count), 0) AS stock,
  317. ddm.device_kind AS device_kind,
  318. ddm.device_model AS device_model,
  319. ddm.device_manager AS device_manager,
  320. ddm.collator AS collator
  321. FROM
  322. (
  323. SELECT
  324. id,
  325. uuid,
  326. device_model,
  327. device_name,
  328. device_manager,
  329. collator,
  330. grain_id,
  331. device_kind
  332. FROM
  333. dm_device_model
  334. WHERE device_kind ='1'
  335. ) ddm
  336. LEFT JOIN (
  337. SELECT
  338. dc.store_count,dc.model_uuid
  339. FROM
  340. dm_device dc
  341. WHERE
  342. dc.status IN (0, 1)
  343. AND dc.status_repair = '0'
  344. ) dd ON dd.model_uuid = ddm.uuid
  345. LEFT JOIN sys_grain sg ON ddm.grain_id = sg.id
  346. <where>
  347. <if test="deviceName !=null and deviceName !=''">
  348. and ddm.device_name like CONCAT('%','${deviceName}','%' )
  349. </if>
  350. <if test="deviceModel !=null and deviceModel !=''">
  351. and ddm.device_model = #{deviceModel}
  352. </if>
  353. <if test="grainId !=null and grainId !=''">
  354. and ddm.grain_id = #{grainId}
  355. </if>
  356. <if test="cityId !=null and cityId !=''">
  357. and sg.parentId = #{cityId}
  358. </if>
  359. <if test="device_kind !=null">
  360. and ddm.device_kind = #{device_kind}
  361. </if>
  362. <if test="uuid !=null">
  363. and ddm.uuid = #{uuid}
  364. </if>
  365. </where>
  366. GROUP BY ddm.id
  367. <choose>
  368. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  369. ORDER BY ${page.orderBy}
  370. </when>
  371. <otherwise>
  372. </otherwise>
  373. </choose>
  374. </select>
  375. <select id="findList" resultMap="baseMap">
  376. SELECT DISTINCT
  377. <include refid="columns2"/>
  378. FROM dm_device_model a
  379. LEFT JOIN dm_device aa on aa.model_uuid=a.uuid and aa.status_repair=2
  380. <include refid="joinCols"/>
  381. <where>
  382. <if test="id !=null">
  383. and a.id = #{id}
  384. </if>
  385. <if test="uuid !=null">
  386. and a.uuid = #{uuid}
  387. </if>
  388. <if test="grainId !=null">
  389. and a.grain_id = #{grainId}
  390. </if>
  391. <if test="deviceName !=null">
  392. and a.device_name = #{deviceName}
  393. </if>
  394. <if test="deviceModel !=null">
  395. and a.device_model = #{deviceModel}
  396. </if>
  397. <if test="deviceManager !=null">
  398. and a.device_manager = #{deviceManager}
  399. </if>
  400. <if test="collator !=null">
  401. and a.collator = #{collator}
  402. </if>
  403. <if test="purchaser !=null">
  404. and a.purchaser = #{purchaser}
  405. </if>
  406. <if test="serviceLife !=null">
  407. and a.service_life = #{serviceLife}
  408. </if>
  409. <if test="remark !=null">
  410. and a.remark = #{remark}
  411. </if>
  412. <if test="assetNumber !=null">
  413. and a.asset_number = #{assetNumber}
  414. </if>
  415. <if test="device_document !=null">
  416. and a.device_document = #{device_document}
  417. </if>
  418. <if test="position !=null">
  419. and a.position = #{position}
  420. </if>
  421. <if test="storagerack !=null">
  422. and a.storagerack = #{storagerack}
  423. </if>
  424. <if test="device_kind !=null">
  425. and a.device_kind = #{device_kind}
  426. </if>
  427. <if test="storagerackCell !=null">
  428. and a.storagerack_cell = #{storagerackCell}
  429. </if>
  430. <if test="device_id_of !=null">
  431. and a.device_id_of = #{device_id_of}
  432. </if>
  433. <if test="device_name_of !=null">
  434. and a.device_name_of = #{device_name_of}
  435. </if>
  436. <if test="device_model_of !=null">
  437. and a.device_model_of = #{device_model_of}
  438. </if>
  439. </where>
  440. <choose>
  441. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  442. ORDER BY ${page.orderBy}
  443. </when>
  444. <otherwise>
  445. </otherwise>
  446. </choose>
  447. </select>
  448. <select id="getMenuList" resultMap="baseMap">
  449. SELECT DISTINCT
  450. <include refid="columns2"/>
  451. FROM dm_device_model a
  452. LEFT JOIN dm_device aa on aa.model_uuid=a.uuid /*and aa.status_repair=0*/
  453. <include refid="joinCols"/>
  454. <where>
  455. <if test="id !=null">
  456. and a.id = #{id}
  457. </if>
  458. <if test="uuid !=null">
  459. and a.uuid = #{uuid}
  460. </if>
  461. <if test="grainId !=null">
  462. and a.grain_id = #{grainId}
  463. </if>
  464. <if test="deviceName !=null">
  465. and a.device_name = #{deviceName}
  466. </if>
  467. <if test="deviceModel !=null">
  468. and a.device_model = #{deviceModel}
  469. </if>
  470. <if test="deviceNo !=null">
  471. and aa.device_no = #{deviceNo}
  472. </if>
  473. <if test="deviceManager !=null">
  474. and a.device_manager = #{deviceManager}
  475. </if>
  476. <if test="collator !=null">
  477. and a.collator = #{collator}
  478. </if>
  479. <if test="purchaser !=null">
  480. and a.purchaser = #{purchaser}
  481. </if>
  482. <if test="serviceLife !=null">
  483. and a.service_life = #{serviceLife}
  484. </if>
  485. <if test="remark !=null">
  486. and a.remark = #{remark}
  487. </if>
  488. <if test="assetNumber !=null">
  489. and a.asset_number = #{assetNumber}
  490. </if>
  491. <if test="device_document !=null">
  492. and a.device_document = #{device_document}
  493. </if>
  494. <if test="position !=null">
  495. and a.position = #{position}
  496. </if>
  497. <if test="storagerack !=null">
  498. and a.storagerack = #{storagerack}
  499. </if>
  500. <if test="device_kind !=null">
  501. and a.device_kind = #{device_kind}
  502. </if>
  503. <if test="storagerackCell !=null">
  504. and a.storagerack_cell = #{storagerackCell}
  505. </if>
  506. <if test="device_id_of !=null">
  507. and a.device_id_of = #{device_id_of}
  508. </if>
  509. <if test="device_name_of !=null">
  510. and a.device_name_of = #{device_name_of}
  511. </if>
  512. <if test="device_model_of !=null">
  513. and a.device_model_of = #{device_model_of}
  514. </if>
  515. </where>
  516. <choose>
  517. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  518. ORDER BY ${page.orderBy}
  519. </when>
  520. <otherwise>
  521. </otherwise>
  522. </choose>
  523. </select>
  524. <select id="getMenuListwuLing" resultMap="baseMap">
  525. SELECT DISTINCT
  526. <include refid="columns223"/>
  527. FROM dm_device_model a
  528. <include refid="joinCols"/>
  529. <where>
  530. <if test="id !=null">
  531. and a.id = #{id}
  532. </if>
  533. <if test="uuid !=null">
  534. and a.uuid = #{uuid}
  535. </if>
  536. <if test="grainId !=null">
  537. and a.grain_id = #{grainId}
  538. </if>
  539. <if test="deviceName !=null">
  540. and a.device_name = #{deviceName}
  541. </if>
  542. <if test="deviceModel !=null">
  543. and a.device_model = #{deviceModel}
  544. </if>
  545. <if test="deviceNo !=null">
  546. and aa.device_no = #{deviceNo}
  547. </if>
  548. <if test="deviceManager !=null">
  549. and a.device_manager = #{deviceManager}
  550. </if>
  551. <if test="collator !=null">
  552. and a.collator = #{collator}
  553. </if>
  554. <if test="purchaser !=null">
  555. and a.purchaser = #{purchaser}
  556. </if>
  557. <if test="serviceLife !=null">
  558. and a.service_life = #{serviceLife}
  559. </if>
  560. <if test="remark !=null">
  561. and a.remark = #{remark}
  562. </if>
  563. <if test="assetNumber !=null">
  564. and a.asset_number = #{assetNumber}
  565. </if>
  566. <if test="device_document !=null">
  567. and a.device_document = #{device_document}
  568. </if>
  569. <if test="position !=null">
  570. and a.position = #{position}
  571. </if>
  572. <if test="storagerack !=null">
  573. and a.storagerack = #{storagerack}
  574. </if>
  575. <if test="device_kind !=null">
  576. and a.device_kind = #{device_kind}
  577. </if>
  578. <if test="storagerackCell !=null">
  579. and a.storagerack_cell = #{storagerackCell}
  580. </if>
  581. <if test="device_id_of !=null">
  582. and a.device_id_of = #{device_id_of}
  583. </if>
  584. <if test="device_name_of !=null">
  585. and a.device_name_of = #{device_name_of}
  586. </if>
  587. <if test="device_model_of !=null">
  588. and a.device_model_of = #{device_model_of}
  589. </if>
  590. </where>
  591. <choose>
  592. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  593. ORDER BY ${page.orderBy}
  594. </when>
  595. <otherwise>
  596. </otherwise>
  597. </choose>
  598. </select>
  599. <select id="getWarehouseMenuList" resultMap="baseMap">
  600. SELECT DISTINCT
  601. <include refid="columns2"/>
  602. FROM dm_device_model a
  603. LEFT JOIN dm_device aa on aa.model_uuid=a.uuid /*and aa.status_get=0*/
  604. <include refid="joinCols"/>
  605. <where>
  606. <if test="id !=null">
  607. and a.id = #{id}
  608. </if>
  609. <if test="uuid !=null">
  610. and a.uuid = #{uuid}
  611. </if>
  612. <if test="grainId !=null">
  613. and a.grain_id = #{grainId}
  614. </if>
  615. <if test="deviceName !=null">
  616. and a.device_name = #{deviceName}
  617. </if>
  618. <if test="deviceModel !=null">
  619. and a.device_model = #{deviceModel}
  620. </if>
  621. <if test="deviceNo !=null">
  622. and aa.device_no = #{deviceNo}
  623. </if>
  624. <if test="deviceManager !=null">
  625. and a.device_manager = #{deviceManager}
  626. </if>
  627. <if test="collator !=null">
  628. and a.collator = #{collator}
  629. </if>
  630. <if test="purchaser !=null">
  631. and a.purchaser = #{purchaser}
  632. </if>
  633. <if test="serviceLife !=null">
  634. and a.service_life = #{serviceLife}
  635. </if>
  636. <if test="remark !=null">
  637. and a.remark = #{remark}
  638. </if>
  639. <if test="assetNumber !=null">
  640. and a.asset_number = #{assetNumber}
  641. </if>
  642. <if test="device_document !=null">
  643. and a.device_document = #{device_document}
  644. </if>
  645. <if test="position !=null">
  646. and a.position = #{position}
  647. </if>
  648. <if test="storagerack !=null">
  649. and a.storagerack = #{storagerack}
  650. </if>
  651. <if test="device_kind !=null">
  652. and a.device_kind = #{device_kind}
  653. </if>
  654. <if test="storagerackCell !=null">
  655. and a.storagerack_cell = #{storagerackCell}
  656. </if>
  657. <if test="device_id_of !=null">
  658. and a.device_id_of = #{device_id_of}
  659. </if>
  660. <if test="device_name_of !=null">
  661. and a.device_name_of = #{device_name_of}
  662. </if>
  663. <if test="device_model_of !=null">
  664. and a.device_model_of = #{device_model_of}
  665. </if>
  666. </where>
  667. <choose>
  668. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  669. ORDER BY ${page.orderBy}
  670. </when>
  671. <otherwise>
  672. </otherwise>
  673. </choose>
  674. </select>
  675. <select id="getMenuLists" resultMap="baseMap">
  676. SELECT DISTINCT
  677. <include refid="columns3"/>
  678. FROM dm_device_model a
  679. <include refid="joinCols"/>
  680. <where>
  681. <if test="grainId !=null">
  682. and a.grain_id = #{grainId}
  683. </if>
  684. <if test="deviceName !=null">
  685. and a.device_name = #{deviceName}
  686. </if>
  687. <if test="device_kind !=null">
  688. and a.device_kind = #{device_kind}
  689. </if>
  690. </where>
  691. </select>
  692. <select id="findAllList" resultMap="baseMap">
  693. SELECT
  694. <include refid="columns"/>
  695. FROM dm_device_model a
  696. <include refid="joinCols"/>
  697. <where>
  698. <if test="id !=null">
  699. and id = #{id}
  700. </if>
  701. <if test="uuid !=null">
  702. and uuid = #{uuid}
  703. </if>
  704. <if test="grainId !=null">
  705. and grain_id = #{grainId}
  706. </if>
  707. <if test="deviceName !=null">
  708. and device_name = #{deviceName}
  709. </if>
  710. <if test="deviceModel !=null">
  711. and device_model = #{deviceModel}
  712. </if>
  713. <if test="deviceManager !=null">
  714. and device_manager = #{deviceManager}
  715. </if>
  716. <if test="collator !=null">
  717. and collator = #{collator}
  718. </if>
  719. <if test="purchaser !=null">
  720. and purchaser = #{purchaser}
  721. </if>
  722. <if test="serviceLife !=null">
  723. and service_life = #{serviceLife}
  724. </if>
  725. <if test="remark !=null">
  726. and remark = #{remark}
  727. </if>
  728. <if test="assetNumber !=null">
  729. and asset_number = #{assetNumber}
  730. </if>
  731. <if test="device_document !=null">
  732. and device_document = #{device_document}
  733. </if>
  734. <if test="position !=null">
  735. and position = #{position}
  736. </if>
  737. <if test="storagerack !=null">
  738. and storagerack = #{storagerack}
  739. </if>
  740. <if test="device_kind !=null">
  741. and device_kind = #{device_kind}
  742. </if>
  743. <if test="storagerackCell !=null">
  744. and storagerack_cell = #{storagerackCell}
  745. </if>
  746. <if test="device_id_of !=null">
  747. and device_id_of = #{device_id_of}
  748. </if>
  749. <if test="device_name_of !=null">
  750. and device_name_of = #{device_name_of}
  751. </if>
  752. <if test="device_model_of !=null">
  753. and device_model_of = #{device_model_of}
  754. </if>
  755. </where>
  756. <choose>
  757. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  758. ORDER BY ${page.orderBy}
  759. </when>
  760. <otherwise>
  761. </otherwise>
  762. </choose>
  763. </select>
  764. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  765. parameterType="cn.ourwill.module.house.entity.dm.DeviceModel">
  766. INSERT INTO dm_device_model
  767. <trim prefix="(" suffix=")" suffixOverrides=",">
  768. <if test=" id != null">
  769. id,
  770. </if>
  771. <if test="uuid !=null">
  772. uuid,
  773. </if>
  774. <if test=" grainId != null">
  775. grain_id,
  776. </if>
  777. <if test=" deviceName != null">
  778. device_name,
  779. </if>
  780. <if test=" deviceModel != null">
  781. device_model,
  782. </if>
  783. <if test=" deviceManager != null">
  784. device_manager,
  785. </if>
  786. <if test=" collator != null">
  787. collator,
  788. </if>
  789. <if test="purchaser !=null">
  790. purchaser,
  791. </if>
  792. <if test="serviceLife !=null">
  793. service_life,
  794. </if>
  795. <if test=" remark != null">
  796. remark,
  797. </if>
  798. <if test="assetNumber !=null">
  799. asset_number,
  800. </if>
  801. <if test="device_document !=null">
  802. device_document,
  803. </if>
  804. <if test="position !=null">
  805. position ,
  806. </if>
  807. <if test="storagerack !=null">
  808. storagerack,
  809. </if>
  810. <if test="device_kind !=null">
  811. device_kind,
  812. </if>
  813. <if test="storagerackCell !=null">
  814. storagerack_cell,
  815. </if>
  816. <if test="device_id_of !=null">
  817. device_id_of,
  818. </if>
  819. <if test="device_name_of !=null">
  820. device_name_of,
  821. </if>
  822. <if test="device_model_of !=null">
  823. device_model_of,
  824. </if>
  825. <if test="warningNum !=null">
  826. warning_num
  827. </if>
  828. </trim>
  829. <trim prefix="values (" suffix=")" suffixOverrides=",">
  830. <if test=" id != null">
  831. #{id}, </if>
  832. <if test="uuid !=null">
  833. #{uuid}, </if>
  834. <if test=" grainId != null">
  835. #{grainId}, </if>
  836. <if test=" deviceName != null">
  837. #{deviceName}, </if>
  838. <if test=" deviceModel != null">
  839. #{deviceModel}, </if>
  840. <if test=" deviceManager != null">
  841. #{deviceManager}, </if>
  842. <if test=" collator != null">
  843. #{collator}, </if>
  844. <if test="purchaser !=null">
  845. #{purchaser}, </if>
  846. <if test="serviceLife !=null">
  847. #{serviceLife}, </if>
  848. <if test=" remark != null">
  849. #{remark}, </if>
  850. <if test="assetNumber !=null">
  851. #{assetNumber},
  852. </if>
  853. <if test="device_document !=null">
  854. #{device_document},
  855. </if>
  856. <if test="position !=null">
  857. #{position},
  858. </if>
  859. <if test="storagerack !=null">
  860. #{storagerack},
  861. </if>
  862. <if test="device_kind !=null">
  863. #{device_kind},
  864. </if>
  865. <if test="storagerackCell !=null">
  866. #{storagerack_cell},
  867. </if>
  868. <if test="device_id_of !=null">
  869. #{device_id_of},
  870. </if>
  871. <if test="device_name_of !=null">
  872. #{device_name_of},
  873. </if>
  874. <if test="device_model_of !=null">
  875. #{device_model_of},
  876. </if>
  877. <if test="warningNum !=null">
  878. #{warningNum}
  879. </if>
  880. </trim>
  881. </insert>
  882. <update id="update" parameterType="cn.ourwill.module.house.entity.dm.DeviceModel">
  883. UPDATE dm_device_model <set>
  884. <if test="id != null">
  885. id= #{id} ,
  886. </if>
  887. <if test="uuid !=null">
  888. uuid = #{uuid} ,
  889. </if>
  890. <if test="grainId != null">
  891. grain_id= #{grainId} ,
  892. </if>
  893. <if test="deviceName != null">
  894. device_name= #{deviceName} ,
  895. </if>
  896. <if test="deviceModel != null">
  897. device_model= #{deviceModel} ,
  898. </if>
  899. <if test="deviceManager != null">
  900. device_manager= #{deviceManager} ,
  901. </if>
  902. <if test="collator != null">
  903. collator= #{collator} ,
  904. </if>
  905. <if test="purchaser !=null">
  906. purchaser = #{purchaser} ,
  907. </if>
  908. <if test="serviceLife !=null">
  909. service_life = #{serviceLife} ,
  910. </if>
  911. <if test="remark != null">
  912. remark= #{remark},
  913. </if>
  914. <if test="assetNumber !=null">
  915. asset_number = #{assetNumber},
  916. </if>
  917. <if test="device_document !=null">
  918. device_document = #{device_document},
  919. </if>
  920. <if test="position !=null">
  921. position = #{position},
  922. </if>
  923. <if test="storagerack !=null">
  924. storagerack = #{storagerack},
  925. </if>
  926. <if test="device_kind !=null">
  927. device_kind = #{device_kind},
  928. </if>
  929. <if test="storagerackCell !=null">
  930. storagerack_cell = #{storagerackCell},
  931. </if>
  932. <if test="device_id_of !=null">
  933. device_id_of = #{device_id_of},
  934. </if>
  935. <if test="device_name_of !=null">
  936. device_name_of = #{device_name_of},
  937. </if>
  938. <if test="device_model_of !=null">
  939. device_model_of = #{device_model_of},
  940. </if>
  941. <if test="warningNum !=null">
  942. warning_num = #{warningNum}
  943. </if>
  944. </set>
  945. WHERE id = #{id}
  946. </update>
  947. <update id="updateByUuid" parameterType="cn.ourwill.module.house.entity.dm.DeviceModel">
  948. UPDATE dm_device_model <set>
  949. <if test="uuid !=null">
  950. uuid = #{uuid} ,
  951. </if>
  952. <if test="grainId != null">
  953. grain_id= #{grainId} ,
  954. </if>
  955. <if test="deviceName != null">
  956. device_name= #{deviceName} ,
  957. </if>
  958. <if test="deviceModel != null">
  959. device_model= #{deviceModel} ,
  960. </if>
  961. <if test="deviceManager != null">
  962. device_manager= #{deviceManager} ,
  963. </if>
  964. <if test="collator != null">
  965. collator= #{collator} ,
  966. </if>
  967. <if test="purchaser !=null">
  968. purchaser = #{purchaser} ,
  969. </if>
  970. <if test="serviceLife !=null">
  971. service_life = #{serviceLife} ,
  972. </if>
  973. <if test="remark != null">
  974. remark= #{remark},
  975. </if>
  976. <if test="assetNumber !=null">
  977. asset_number = #{assetNumber},
  978. </if>
  979. <if test="device_document !=null">
  980. device_document = #{device_document},
  981. </if>
  982. <if test="position !=null">
  983. position = #{position},
  984. </if>
  985. <if test="storagerack !=null">
  986. storagerack = #{storagerack},
  987. </if>
  988. <if test="device_kind !=null">
  989. device_kind = #{device_kind},
  990. </if>
  991. <if test="storagerackCell !=null">
  992. storagerack_cell = #{storagerackCell},
  993. </if>
  994. <if test="device_id_of !=null">
  995. device_id_of = #{device_id_of},
  996. </if>
  997. <if test="device_name_of !=null">
  998. device_name_of = #{device_name_of},
  999. </if>
  1000. <if test="device_model_of !=null">
  1001. device_model_of = #{device_model_of}
  1002. </if>
  1003. <if test="warningNum !=null">
  1004. warning_num = #{warningNum}
  1005. </if>
  1006. </set>
  1007. WHERE uuid = #{uuid}
  1008. </update>
  1009. <delete id="deleteById" parameterType="java.lang.Long">
  1010. DELETE FROM dm_device_model WHERE id = #{id}
  1011. </delete>
  1012. <delete id="deleteByIds" parameterType="java.util.List">
  1013. DELETE FROM dm_device_model WHERE id IN
  1014. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  1015. #{item}
  1016. </foreach>
  1017. </delete>
  1018. <select id="getNumberByName" resultMap="baseMap">
  1019. SELECT a.id, a.device_name,dd.store_count
  1020. FROM dm_device_model a
  1021. LEFT JOIN sys_grain sg on sg.id = a.grain_id
  1022. LEFT JOIN dm_device dd ON dd.model_uuid = a.uuid
  1023. <where>
  1024. a.device_kind='2'
  1025. <if test="grainId !=null">
  1026. and a.grain_id = #{grainId}
  1027. </if>
  1028. <if test="cityId !=null">
  1029. and sg.parentId = #{cityId}
  1030. </if>
  1031. <if test="deviceName !=null">
  1032. and a.device_name = #{deviceName}
  1033. </if>
  1034. </where>
  1035. group by a.device_name ORDER by id ASC
  1036. </select>
  1037. <select id="getDeviceNameByKind" resultMap="baseMap">
  1038. SELECT a.id, a.device_name
  1039. FROM dm_device_model a
  1040. left join sys_grain sg on sg.id = a.grain_id
  1041. <where>
  1042. a.device_kind='2'
  1043. <if test="grainId !=null">
  1044. and a.grain_id = #{grainId}
  1045. </if>
  1046. <if test="cityId !=null">
  1047. and sg.parentId = #{cityId}
  1048. </if>
  1049. </where>
  1050. group by a.device_name
  1051. ORDER by id ASC
  1052. </select>
  1053. <!--获取设备-->
  1054. <select id="getEquipment" resultMap="baseMap">
  1055. SELECT
  1056. <include refid="columns"/>
  1057. FROM dm_device_model a
  1058. <include refid="joinCols"/>
  1059. <where>
  1060. device_kind = '1'
  1061. <if test="grainId !=null">
  1062. and grain_id = #{grainId}
  1063. </if>
  1064. </where>
  1065. </select>
  1066. <!--获取零配件-->
  1067. <select id="getUnit" resultMap="baseMap">
  1068. SELECT
  1069. <include refid="columns"/>
  1070. FROM dm_device_model a
  1071. <include refid="joinCols"/>
  1072. <where>
  1073. device_kind = '3'
  1074. <if test="grainId !=null">
  1075. and grain_id = #{grainId}
  1076. </if>
  1077. </where>
  1078. </select>
  1079. <select id="getDeviceUuidByDeviceNameAnddeviceModelName" resultMap="baseMap">
  1080. SELECT
  1081. <include refid="columns"/>
  1082. FROM dm_device_model
  1083. <include refid="joinCols"/>
  1084. <where>
  1085. <if test="deviceName">
  1086. and device_name=#{deviceName}
  1087. </if>
  1088. <if test="deviceModelName">
  1089. and device_model=#{deviceModelName}
  1090. </if>
  1091. </where>
  1092. </select>
  1093. <!-- 消息提醒 start-->
  1094. <resultMap type="cn.ourwill.module.house.entity.dm.DeviceModel" id="boxMap">
  1095. <result column="grain_name" property="grainName"/>
  1096. <result column="device_name" property="deviceName"/>
  1097. <result column="device_kind" property="device_kind"/>
  1098. <result column="id" property="id"/>
  1099. </resultMap>
  1100. <select id="getPromptBoxInfo" resultMap="boxMap">
  1101. select id,grain_name,device_model,device_name,device_kind from(SELECT
  1102. ddm.id AS id,
  1103. sg. NAME AS grain_name,
  1104. ddm.device_name AS device_name,
  1105. ifnull(sum(dd.store_count), 0) AS stock,
  1106. ddm.device_kind AS device_kind,
  1107. ddm.warning_num AS warningnum,
  1108. ddm.device_model AS device_model
  1109. FROM
  1110. (select id,uuid,device_model,device_name,grain_id,device_kind,warning_num from dm_device_model where device_kind in ('2','3') and grain_id=#{grainId}) ddm
  1111. LEFT JOIN dm_device dd ON dd.model_uuid = ddm.uuid
  1112. LEFT JOIN sys_grain sg ON ddm.grain_id = sg.id
  1113. GROUP BY
  1114. ddm.id)new where stock &lt;= warningnum
  1115. </select>
  1116. <!-- 消息提醒 end-->
  1117. <select id="getNameAndModel" resultMap="baseMap">
  1118. SELECT
  1119. <include refid="columns"/>
  1120. FROM dm_device_model a
  1121. <include refid="joinCols"/>
  1122. <where>
  1123. <if test="grainId !=null">
  1124. and grain_id = #{grainId}
  1125. </if>
  1126. <if test=" deviceName != null">
  1127. and device_name = #{deviceName}
  1128. </if>
  1129. </where>
  1130. </select>
  1131. <select id="getUuid" resultMap="baseMap">
  1132. SELECT
  1133. <include refid="columns"/>
  1134. FROM dm_device_model a
  1135. <include refid="joinCols"/>
  1136. <where>
  1137. <if test="grainId !=null">
  1138. and grain_id = #{grainId}
  1139. </if>
  1140. <if test=" deviceName != null">
  1141. and device_name = #{deviceName}
  1142. </if>
  1143. </where>
  1144. </select>
  1145. <insert id="insertDeviceModel" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  1146. parameterType="cn.ourwill.module.house.entity.dm.DeviceModel">
  1147. INSERT INTO dm_device_model
  1148. <trim prefix="(" suffix=")" suffixOverrides=",">
  1149. <if test=" id != null">
  1150. id,
  1151. </if>
  1152. <if test="uuid !=null">
  1153. uuid,
  1154. </if>
  1155. <if test=" grainId != null">
  1156. grain_id,
  1157. </if>
  1158. <if test=" deviceName != null">
  1159. device_name,
  1160. </if>
  1161. <if test=" deviceModel != null">
  1162. device_model,
  1163. </if>
  1164. <if test=" remark != null">
  1165. remark,
  1166. </if>
  1167. <if test="device_kind !=null">
  1168. device_kind,
  1169. </if>
  1170. </trim>
  1171. <trim prefix="values (" suffix=")" suffixOverrides=",">
  1172. <if test=" id != null">
  1173. #{id}, </if>
  1174. <if test="uuid !=null">
  1175. #{uuid}, </if>
  1176. <if test=" grainId != null">
  1177. #{grainId}, </if>
  1178. <if test=" deviceName != null">
  1179. #{deviceName}, </if>
  1180. <if test=" deviceModel != null">
  1181. #{deviceModel}, </if>
  1182. <if test=" remark != null">
  1183. #{remark}, </if>
  1184. <if test="device_kind !=null">
  1185. #{device_kind},
  1186. </if>
  1187. </trim>
  1188. </insert>
  1189. </mapper>