DeviceDao.xml 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  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.DeviceDao">
  3. <resultMap type="cn.ourwill.module.house.entity.dm.Device" id="baseMap">
  4. <result column="id" property="id"/>
  5. <result column="model_uuid" property="modelUuid"/>
  6. <result column="get_uuid" property="getUuid"/>
  7. <result column="asset_number" property="assetNumber"/>
  8. <result column="device_no" property="deviceNo"/>
  9. <result column="bookkeeper" property="bookkeeper"/>
  10. <result column="handler" property="handler"/>
  11. <result column="production_date" property="productionDate"/>
  12. <result column="input_date" property="inputDate"/>
  13. <result column="status" property="status"/>
  14. <result column="remark" property="remark"/>
  15. <result column="c_id" property="cId"/>
  16. <result column="c_time" property="cTime"/>
  17. <result column="uuid" property="uuid"/>
  18. <result column="status_keep" property="statusKeep"/>
  19. <result column="keep_lasttime_start" property="keepLasttimeStart"/>
  20. <result column="keep_lasttime_end" property="keepLasttimeEnd"/>
  21. <result column="status_repair" property="statusRepair"/>
  22. <result column="repair_time_start" property="repairTimeStart"/>
  23. <result column="repair_time_end" property="repairTimeEnd"/>
  24. <result column="repair_lasttime_start" property="repairLasttimeStart"/>
  25. <result column="repair_lasttime_end" property="repairLasttimeEnd"/>
  26. <result column="repairer" property="repairer"/>
  27. <result column="status_get" property="statusGet"/>
  28. <result column="repair_remarks" property="repairRemarks"/>
  29. <result column="keep_uuid" property="keepUuid"/>
  30. <!--二期新加字段-->
  31. <result column="device_count" property="deviceCount"/>
  32. <result column="store_count" property="storeCount"/>
  33. <result column="producer" property="producer"/>
  34. <result column="position" property="position"/>
  35. <result column="storagerack" property="storagerack"/>
  36. <result column="storagerack_cell" property="storagerackCell"/>
  37. <result column="unit_price" property="unitPrice"/>
  38. <result column="usage_document" property="usageDocument"/>
  39. <result column="place_of_origin" property="placeOfOrigin"/>
  40. <result column="year_of_purchase" property="yearOfPurchase"/>
  41. <result column="net_asset_value" property="netAssetValue"/>
  42. <result column="voucher_type" property="voucherType"/>
  43. <result column="voucher_number" property="voucherNumber"/>
  44. <result column="device_unit" property="deviceUnit"/>
  45. <result column="price" property="price"/>
  46. </resultMap>
  47. <resultMap type="cn.ourwill.module.house.entity.dm.Device" id="mapOfFind" extends="baseMap">
  48. <result column="name" property="grainName"/>
  49. <result column="device_name" property="deviceName"/>
  50. <result column="device_model" property="deviceModel"/>
  51. <result column="device_manager" property="deviceManager"/>
  52. </resultMap>
  53. <sql id="columns">
  54. a.id ,
  55. a.model_uuid ,
  56. a.get_uuid ,
  57. a.keep_uuid ,
  58. a.asset_number ,
  59. a.device_no ,
  60. a.bookkeeper ,
  61. a.handler ,
  62. a.production_date ,
  63. a.input_date ,
  64. a.status ,
  65. a.remark ,
  66. a.c_id ,
  67. a.c_time ,
  68. a.uuid ,
  69. a.status_keep ,
  70. a.keep_lasttime_start ,
  71. a.keep_lasttime_end ,
  72. a.status_repair ,
  73. a.repair_time_start ,
  74. a.repair_time_end ,
  75. a.repair_lasttime_start ,
  76. a.repair_lasttime_end ,
  77. a.repairer ,
  78. a.status_get ,
  79. a.repair_remarks,
  80. a.producer,
  81. a.device_count,
  82. a.store_count,
  83. a.position,
  84. a.storagerack,
  85. a.storagerack_cell,
  86. a.unit_price,
  87. a.usage_document,
  88. a.year_of_purchase,
  89. a.net_asset_value,
  90. a.device_unit,
  91. a.price,
  92. a.place_of_origin,
  93. a.voucher_type,
  94. a.voucher_number
  95. </sql>
  96. <sql id="columnss">
  97. a.id ,
  98. a.model_uuid ,
  99. a.get_uuid ,
  100. a.keep_uuid ,
  101. a.asset_number ,
  102. a.device_no ,
  103. a.bookkeeper ,
  104. a.handler ,
  105. a.production_date ,
  106. a.input_date as getTime,
  107. a.status ,
  108. a.remark ,
  109. a.c_id ,
  110. a.c_time ,
  111. a.uuid ,
  112. a.status_keep ,
  113. a.keep_lasttime_start ,
  114. a.keep_lasttime_end ,
  115. a.status_repair ,
  116. a.repair_time_start ,
  117. a.repair_time_end ,
  118. a.repair_lasttime_start ,
  119. a.repair_lasttime_end ,
  120. a.repairer ,
  121. a.status_get ,
  122. a.repair_remarks,
  123. a.producer,
  124. a.device_count,
  125. a.store_count,
  126. a.position,
  127. a.storagerack,
  128. a.storagerack_cell,
  129. a.unit_price,
  130. a.usage_document,
  131. a.year_of_purchase,
  132. a.net_asset_value,
  133. a.device_unit,
  134. a.price,
  135. a.place_of_origin,
  136. a.voucher_type,
  137. a.voucher_number
  138. </sql>
  139. <sql id = "columsOfFind">
  140. sg.name,
  141. ddm.grain_id,
  142. ddm.device_name,
  143. ddm.device_model,
  144. ddm.device_manager ,
  145. </sql>
  146. <sql id = "columsOfFindd">
  147. ddm.grain_id,
  148. ddm.device_name,
  149. ddm.device_model,
  150. ddm.device_manager ,
  151. ddm.collator
  152. </sql>
  153. <sql id="joinCols">
  154. </sql>
  155. <select id="get" resultMap="baseMap">
  156. SELECT
  157. <include refid="columns"/>
  158. FROM dm_device a
  159. <include refid="joinCols"/>
  160. WHERE a.id = #{id}
  161. </select>
  162. <select id="getByUuid" resultMap="baseMap">
  163. SELECT
  164. <include refid="columns"/>
  165. FROM dm_device a
  166. <include refid="joinCols"/>
  167. WHERE a.uuid = #{uuid}
  168. </select>
  169. <select id="getByModeluuid" resultMap="baseMap">
  170. SELECT
  171. <include refid="columns"/>
  172. FROM dm_device a
  173. <include refid="joinCols"/>
  174. WHERE a.model_uuid = #{modelUuid}
  175. ORDER BY id ASC LIMIT 1
  176. </select>
  177. <select id="getLastByUuid" resultMap="baseMap">
  178. SELECT
  179. <include refid="columns"/>
  180. FROM dm_device a
  181. <include refid="joinCols"/>
  182. WHERE a.model_uuid = #{uuid} ORDER BY c_time DESC LIMIT 0, 1;
  183. </select>
  184. <select id="findNoUuidList" resultMap="baseMap">
  185. SELECT
  186. <include refid="columns"/>
  187. FROM dm_device a
  188. <include refid="joinCols"/>
  189. WHERE a.uuid is null or trim(a.uuid) = '';
  190. </select>
  191. <select id="findGroupByPosition" resultMap="baseMap">
  192. SELECT
  193. <include refid="columns"/>
  194. FROM dm_device a
  195. <include refid="joinCols"/>
  196. WHERE a.position != ''
  197. AND a.model_uuid IN (SELECT dm_device_model.uuid FROM dm_device_model
  198. WHERE grain_id = (SELECT grain_id FROM dm_device_model
  199. WHERE uuid = #{deviceModelUuid}))
  200. <include refid="joinCols"/>
  201. GROUP BY position
  202. </select>
  203. <select id="findGroupByStoragerack" resultMap="baseMap">
  204. SELECT
  205. <include refid="columns"/>
  206. FROM dm_device a
  207. <include refid="joinCols"/>
  208. WHERE a.storagerack != '' AND a.position = #{positionId}
  209. AND a.model_uuid IN (SELECT dm_device_model.uuid FROM dm_device_model
  210. WHERE grain_id = (SELECT grain_id FROM dm_device_model
  211. WHERE uuid = #{deviceModelUuid}))
  212. <include refid="joinCols"/>
  213. GROUP BY storagerack
  214. </select>
  215. <select id="findGroupByStoragerackCell" resultMap="baseMap">
  216. SELECT
  217. <include refid="columns"/>
  218. FROM dm_device a
  219. <include refid="joinCols"/>
  220. WHERE a.storagerack_cell != '' AND a.storagerack = #{storagerackId}
  221. AND a.model_uuid IN (SELECT dm_device_model.uuid FROM dm_device_model
  222. WHERE grain_id = (SELECT grain_id FROM dm_device_model
  223. WHERE uuid = #{deviceModelUuid}))
  224. <include refid="joinCols"/>
  225. GROUP BY storagerack_cell
  226. </select>
  227. <select id="finNearScrapList" resultMap="baseMap">
  228. select
  229. <include refid="columns"/>
  230. from dm_device a
  231. left join dm_device_model ddm on ddm.uuid = a.model_uuid
  232. where a.status = '0'
  233. and (TIMESTAMPDIFF(MONTH,a.input_date,SYSDATE()) >(ddm.service_life*12-(select value from sys_threshold where id = 10 and type = '4')))
  234. </select>
  235. <select id="findrkList" resultMap="baseMap">
  236. SELECT
  237. <include refid="columns"/>,
  238. <include refid="columsOfFindd"/>
  239. FROM
  240. dm_device a
  241. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  242. WHERE a.model_uuid = #{modelUuid}
  243. ORDER BY id ASC LIMIT 1
  244. </select>
  245. <select id="finNearKeepList" resultMap="baseMap">
  246. SELECT
  247. <include refid="columns"/>
  248. FROM
  249. dm_device a
  250. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  251. where
  252. ddm.grain_id = #{grainId}
  253. and a.keep_lasttime_end IS NOT NULL
  254. and TIMESTAMPDIFF(MONTH,a.keep_lasttime_end,SYSDATE()) > 3
  255. union all
  256. SELECT
  257. <include refid="columns"/>
  258. FROM
  259. dm_device a
  260. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  261. WHERE
  262. ddm.grain_id = #{grainId}
  263. and a.keep_lasttime_end IS NULL
  264. and TIMESTAMPDIFF(MONTH,a.input_date,SYSDATE()) > 3
  265. </select>
  266. <resultMap type="cn.ourwill.module.house.entity.dm.Device" id="mapForStatistics" extends="baseMap">
  267. <result column="name" property="grainName"/>
  268. <result column="house_name" property="houseName"/>
  269. <result column="device_name" property="deviceName"/>
  270. <result column="device_model" property="deviceModel"/>
  271. <result column="device_manager" property="deviceManager"/>
  272. <result column="get_man" property="getMan"/>
  273. <result column="get_time" property="getTime"/>
  274. <result column="return_time" property="returnTime"/>
  275. <result column="service_life" property="serviceLife"/>
  276. <result column="purchaser" property="purchaser"/>
  277. </resultMap>
  278. <select id="getStatistics" resultMap="mapForStatistics">
  279. select
  280. sg.name as name,
  281. ddm.device_name as device_name,
  282. ddm.device_model as device_model,
  283. dm.device_no as device_no,
  284. hi.house_name as house_name,
  285. rdg.get_man as get_man,
  286. dm.status_get as status_get,
  287. dm.status_repair as status_repair,
  288. dm.status_keep as status_keep,
  289. rdg.get_time as get_time,
  290. rdb.return_time as return_time,
  291. dm.input_date as input_date,
  292. CAST((DATEDIFF(SYSDATE(),dm.input_date)/365) as decimal) as service_life,
  293. dm.status as status,
  294. ddm.purchaser as purchaser,
  295. dm.keep_lasttime_end as keep_lasttime_end,
  296. dm.remark as remark
  297. from dm_device dm
  298. left join dm_device_model ddm on ddm.uuid = dm.model_uuid
  299. left join sys_grain sg on sg.id = ddm.grain_id
  300. left join record_device_get rdg on rdg.uuid = dm.get_uuid
  301. left join record_device_back rdb on rdb.get_uuid = rdg.uuid
  302. left join house_info hi on hi.id = rdg.house_id
  303. <where>
  304. <if test="modelUuid !=null and modelUuid !=''">
  305. and dm.model_uuid = #{modelUuid}
  306. </if>
  307. <if test="serviceLifeStart !=null and serviceLifeStart !=''">
  308. and CAST((DATEDIFF(SYSDATE(),dm.input_date)/365) as decimal) >= #{serviceLifeStart}
  309. </if>
  310. <if test="serviceLifeEnd !=null and serviceLifeEnd !=''">
  311. and CAST((DATEDIFF(SYSDATE(),dm.input_date)/365) as decimal) >= #{serviceLifeEnd}
  312. </if>
  313. </where>
  314. <choose>
  315. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  316. ORDER BY ${page.orderBy}
  317. </when>
  318. <otherwise>
  319. </otherwise>
  320. </choose>
  321. </select>
  322. <select id="findList" resultMap="mapOfFind">
  323. SELECT
  324. <include refid="columsOfFind"/>
  325. <include refid="columns"/>
  326. FROM dm_device a
  327. left join dm_device_model ddm on model_uuid = ddm.uuid
  328. left join sys_grain sg on sg.id = ddm.grain_id
  329. <include refid="joinCols"/>
  330. <where>
  331. <if test="grainId !=null and grainId!=''">
  332. and ddm.grain_id = #{grainId}
  333. </if>
  334. <if test="cityId !=null and cityId!=''">
  335. and sg.parentId = #{cityId}
  336. </if>
  337. <if test="id !=null">
  338. and a.id = #{id}
  339. </if>
  340. <if test="modelUuid !=null">
  341. and a.model_uuid = #{modelUuid}
  342. </if>
  343. <if test="getUuid !=null">
  344. and a.get_uuid = #{getUuid}
  345. </if>
  346. <if test="keepUuid !=null">
  347. and a.keep_uuid = #{keepUuid}
  348. </if>
  349. <if test="grainName !=null">
  350. and sg.name = #{grainName}
  351. </if>
  352. <if test="deviceName !=null and deviceName !=''">
  353. and ddm.device_name = #{deviceName}
  354. </if>
  355. <if test="deviceModel !=null and deviceModel !=''">
  356. and ddm.device_model = #{deviceModel}
  357. </if>
  358. <if test="assetNumber !=null">
  359. and a.asset_number = #{assetNumber}
  360. </if>
  361. <if test="deviceNo !=null">
  362. and a.device_no = #{deviceNo}
  363. </if>
  364. <if test="bookkeeper !=null">
  365. and a.bookkeeper = #{bookkeeper}
  366. </if>
  367. <if test="handler !=null">
  368. and a.handler = #{handler}
  369. </if>
  370. <if test="productionDate !=null">
  371. and a.production_date = #{productionDate}
  372. </if>
  373. <if test="inputDate !=null">
  374. and a.input_date = #{inputDate}
  375. </if>
  376. <if test="status !=null">
  377. and a.status in (${status})
  378. </if>
  379. <if test="remark !=null">
  380. and a.remark = #{remark}
  381. </if>
  382. <if test="cId !=null">
  383. and a.c_id = #{cId}
  384. </if>
  385. <if test="cTime !=null">
  386. and a.c_time = #{cTime}
  387. </if>
  388. <if test="uuid !=null">
  389. and a.uuid = #{uuid}
  390. </if>
  391. <if test="statusKeep !=null">
  392. and a.status_keep = #{statusKeep}
  393. </if>
  394. <if test="keepLasttimeStart !=null">
  395. and a.keep_lasttime_start = #{keepLasttimeStart}
  396. </if>
  397. <if test="keepLasttimeEnd !=null">
  398. and a.keep_lasttime_end = #{keepLasttimeEnd}
  399. </if>
  400. <if test="statusRepair !=null and statusRepair != ''">
  401. and a.status_repair = #{statusRepair}
  402. </if>
  403. <if test="repairTimeStart !=null">
  404. and a.repair_time_start = #{repairTimeStart}
  405. </if>
  406. <if test="repairTimeEnd !=null">
  407. and a.repair_time_end = #{repairTimeEnd}
  408. </if>
  409. <if test="repairLasttimeStart !=null">
  410. and a.repair_lasttime_start = #{repairLasttimeStart}
  411. </if>
  412. <if test="repairLasttimeEnd !=null">
  413. and a.repair_lasttime_end = #{repairLasttimeEnd}
  414. </if>
  415. <if test="repairer !=null">
  416. and a.repairer = #{repairer}
  417. </if>
  418. <if test="statusGet !=null">
  419. and a.status_get = #{statusGet}
  420. </if>
  421. <if test="repairRemarks !=null">
  422. and a.repair_remarks = #{repairRemarks}
  423. </if>
  424. <if test="repairFlag !=null and repairFlag == 'true' ">
  425. and (a.repair_time_start is not null or a.status_repair = '2')
  426. </if>
  427. <if test="producer !=null">
  428. and a.producer = #{producer}
  429. </if>
  430. <if test="deviceCount !=null">
  431. and a.device_count = #{deviceCount}
  432. </if>
  433. <if test="storeCount !=null">
  434. and a.store_count = #{storeCount}
  435. </if>
  436. <if test="position !=null">
  437. and a.position = #{position}
  438. </if>
  439. <if test="storagerack !=null">
  440. and a.storagerack = #{storagerack}
  441. </if>
  442. <if test="storagerackCell !=null">
  443. and a.storagerack_cell = #{storagerackCell}
  444. </if>
  445. <if test="unitPrice !=null">
  446. and a.unit_price = #{unitPrice}
  447. </if>
  448. <if test="usageDocument !=null">
  449. and a.usage_document = #{usageDocument}
  450. </if>
  451. <if test="placeOfOrigin !=null">
  452. and a.place_of_origin = #{placeOfOrigin}
  453. </if>
  454. <if test="yearOfPurchase !=null">
  455. and a.year_of_purchase = #{yearOfPurchase}
  456. </if>
  457. <if test="netAssetValue !=null">
  458. and a.net_asset_value = #{netAssetValue}
  459. </if>
  460. <if test="voucherType !=null">
  461. and a.voucher_type = #{voucherType}
  462. </if>
  463. <if test="voucherNumber !=null">
  464. and a.voucher_number = #{voucherNumber}
  465. </if>
  466. </where>
  467. <choose>
  468. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  469. ORDER BY ${page.orderBy}
  470. </when>
  471. <otherwise>
  472. </otherwise>
  473. </choose>
  474. </select>
  475. <select id="findListAll" resultMap="mapOfFind">
  476. SELECT
  477. <include refid="columsOfFind"/>
  478. <include refid="columns"/>
  479. FROM dm_device a
  480. left join dm_device_model ddm on model_uuid = ddm.uuid
  481. left join sys_grain sg on sg.id = ddm.grain_id
  482. WHERE grain_id = (SELECT grain_id FROM dm_device_model
  483. WHERE uuid = #{deviceModelUuid})
  484. <include refid="joinCols"/>
  485. </select>
  486. <select id="findListAlluuid" resultMap="mapOfFind">
  487. SELECT
  488. <include refid="columsOfFind"/>
  489. <include refid="columns"/>
  490. FROM dm_device a
  491. left join dm_device_model ddm on model_uuid = ddm.uuid
  492. left join sys_grain sg on sg.id = ddm.grain_id
  493. WHERE grain_id = #{grainId}
  494. <include refid="joinCols"/>
  495. </select>
  496. <select id="findAllList" resultMap="mapOfFind">
  497. SELECT
  498. <include refid="columsOfFind"/>
  499. <include refid="columns"/>
  500. FROM dm_device a
  501. left join dm_device_model ddm on model_uuid = ddm.uuid
  502. left join sys_grain sg on sg.id = ddm.grain_id
  503. <include refid="joinCols"/>
  504. <where>
  505. <if test="id !=null">
  506. and a.id = #{id}
  507. </if>
  508. <if test="grainId !=null">
  509. and grain_id = #{grainId}
  510. </if>
  511. <if test="modelUuid !=null">
  512. and a.model_uuid = #{modelUuid}
  513. </if>
  514. <if test="getUuid !=null">
  515. and a.get_uuid = #{getUuid}
  516. </if>
  517. <if test="keepUuid !=null">
  518. and a.keep_uuid = #{keepUuid}
  519. </if>
  520. <if test="grainName !=null">
  521. and sg.name = #{grainName}
  522. </if>
  523. <if test="deviceName !=null">
  524. and ddm.device_name = #{deviceName}
  525. </if>
  526. <if test="deviceModel !=null">
  527. and ddm.device_model = #{deviceModel}
  528. </if>
  529. <if test="assetNumber !=null">
  530. and a.asset_number = #{assetNumber}
  531. </if>
  532. <if test="deviceNo !=null">
  533. and a.device_no = #{deviceNo}
  534. </if>
  535. <if test="bookkeeper !=null">
  536. and a.bookkeeper = #{bookkeeper}
  537. </if>
  538. <if test="handler !=null">
  539. and a.handler = #{handler}
  540. </if>
  541. <if test="productionDate !=null">
  542. and a.production_date = #{productionDate}
  543. </if>
  544. <if test="inputDate !=null">
  545. and a.input_date = #{inputDate}
  546. </if>
  547. <if test="status !=null">
  548. and a.status in (${status})
  549. </if>
  550. <if test="remark !=null">
  551. and a.remark = #{remark}
  552. </if>
  553. <if test="cId !=null">
  554. and a.c_id = #{cId}
  555. </if>
  556. <if test="cTime !=null">
  557. and a.c_time = #{cTime}
  558. </if>
  559. <if test="uuid !=null">
  560. and a.uuid = #{uuid}
  561. </if>
  562. <if test="statusKeep !=null">
  563. and a.status_keep = #{statusKeep}
  564. </if>
  565. <if test="keepLasttimeStart !=null">
  566. and a.keep_lasttime_start = #{keepLasttimeStart}
  567. </if>
  568. <if test="keepLasttimeEnd !=null">
  569. and a.keep_lasttime_end = #{keepLasttimeEnd}
  570. </if>
  571. <if test="statusRepair !=null">
  572. and a.status_repair = #{statusRepair}
  573. </if>
  574. <if test="repairTimeStart !=null">
  575. and a.repair_time_start = #{repairTimeStart}
  576. </if>
  577. <if test="repairTimeEnd !=null">
  578. and a.repair_time_end = #{repairTimeEnd}
  579. </if>
  580. <if test="repairLasttimeStart !=null">
  581. and a.repair_lasttime_start = #{repairLasttimeStart}
  582. </if>
  583. <if test="repairLasttimeEnd !=null">
  584. and a.repair_lasttime_end = #{repairLasttimeEnd}
  585. </if>
  586. <if test="repairer !=null">
  587. and a.repairer = #{repairer}
  588. </if>
  589. <if test="statusGet !=null">
  590. and a.status_get = #{statusGet}
  591. </if>
  592. <if test="repairRemarks !=null">
  593. and a.repair_remarks = #{repairRemarks}
  594. </if>
  595. <if test="producer !=null">
  596. and a.producer = #{producer}
  597. </if>
  598. <if test="deviceCount !=null">
  599. and a.device_count = #{deviceCount}
  600. </if>
  601. <if test="storeCount !=null">
  602. and a.store_count = #{storeCount}
  603. </if>
  604. <if test="position !=null">
  605. and a.position = #{position}
  606. </if>
  607. <if test="storagerack !=null">
  608. and a.storagerack = #{storagerack}
  609. </if>
  610. <if test="storagerackCell !=null">
  611. and a.storagerack_cell = #{storagerackCell}
  612. </if>
  613. <if test="unitPrice !=null">
  614. and a.unit_price = #{unitPrice}
  615. </if>
  616. <if test="usageDocument !=null">
  617. and a.usage_document = #{usageDocument}
  618. </if>
  619. <if test="placeOfOrigin !=null">
  620. and a.place_of_origin = #{placeOfOrigin}
  621. </if>
  622. <if test="yearOfPurchase !=null">
  623. and a.year_of_purchase = #{yearOfPurchase}
  624. </if>
  625. <if test="netAssetValue !=null">
  626. and a.net_asset_value = #{netAssetValue}
  627. </if>
  628. <if test="voucherType !=null">
  629. and a.voucher_type = #{voucherType}
  630. </if>
  631. <if test="voucherNumber !=null">
  632. and a.voucher_number = #{voucherNumber}
  633. </if>
  634. </where>
  635. <choose>
  636. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  637. ORDER BY ${page.orderBy}
  638. </when>
  639. <otherwise>
  640. </otherwise>
  641. </choose>
  642. </select>
  643. <select id="findCheckData" resultMap="mapOfFind">
  644. SELECT
  645. ddm.grain_id,
  646. ddm.device_name,
  647. ddm.device_model,
  648. ddm.uuid,
  649. ifnull(u.store_count,0) store_count
  650. FROM dm_device_model ddm LEFT JOIN (SELECT model_uuid, sum(store_count) AS store_count FROM dm_device GROUP BY model_uuid) AS u
  651. ON ddm.uuid = u.model_uuid WHERE ddm.device_kind = #{deviceKind} AND ddm.grain_id = #{grainId};
  652. </select>
  653. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  654. parameterType="cn.ourwill.module.house.entity.dm.Device">
  655. INSERT INTO dm_device
  656. <trim prefix="(" suffix=")" suffixOverrides=",">
  657. <if test=" id != null">
  658. id,
  659. </if>
  660. <if test=" modelUuid != null">
  661. model_uuid,
  662. </if>
  663. <if test=" getUuid != null">
  664. get_uuid,
  665. </if>
  666. <if test="keepUuid !=null">
  667. keep_uuid,
  668. </if>
  669. <if test=" assetNumber != null">
  670. asset_number,
  671. </if>
  672. <if test=" deviceNo != null">
  673. device_no,
  674. </if>
  675. <if test=" bookkeeper != null">
  676. bookkeeper,
  677. </if>
  678. <if test=" handler != null">
  679. handler,
  680. </if>
  681. <if test=" productionDate != null">
  682. production_date,
  683. </if>
  684. <if test=" inputDate != null">
  685. input_date,
  686. </if>
  687. <if test=" status != null">
  688. status,
  689. </if>
  690. <if test=" remark != null">
  691. remark,
  692. </if>
  693. <if test=" cId != null">
  694. c_id,
  695. </if>
  696. <if test=" cTime != null">
  697. c_time,
  698. </if>
  699. <if test=" uuid != null">
  700. uuid,
  701. </if>
  702. <if test=" statusKeep != null">
  703. status_keep,
  704. </if>
  705. <if test=" keepLasttimeStart != null">
  706. keep_lasttime_start,
  707. </if>
  708. <if test=" keepLasttimeEnd != null">
  709. keep_lasttime_end,
  710. </if>
  711. <if test=" statusRepair != null">
  712. status_repair,
  713. </if>
  714. <if test=" repairTimeStart != null">
  715. repair_time_start,
  716. </if>
  717. <if test=" repairTimeEnd != null">
  718. repair_time_end,
  719. </if>
  720. <if test=" repairLasttimeStart != null">
  721. repair_lasttime_start,
  722. </if>
  723. <if test=" repairLasttimeEnd != null">
  724. repair_lasttime_end,
  725. </if>
  726. <if test=" repairer != null">
  727. repairer,
  728. </if>
  729. <if test="statusGet !=null">
  730. status_get,
  731. </if>
  732. <if test="repairRemarks !=null">
  733. repair_remarks,
  734. </if>
  735. <if test="producer !=null">
  736. producer,
  737. </if>
  738. <if test="deviceCount !=null">
  739. device_count,
  740. </if>
  741. <if test="storeCount !=null">
  742. store_count,
  743. </if>
  744. <if test="position !=null">
  745. position,
  746. </if>
  747. <if test="storagerack !=null">
  748. storagerack,
  749. </if>
  750. <if test="storagerackCell !=null">
  751. storagerack_cell,
  752. </if>
  753. <if test="unitPrice !=null">
  754. unit_price,
  755. </if>
  756. <if test="usageDocument !=null">
  757. usage_document,
  758. </if>
  759. <if test="placeOfOrigin !=null">
  760. place_of_origin ,
  761. </if>
  762. <if test="yearOfPurchase !=null">
  763. year_of_purchase ,
  764. </if>
  765. <if test="netAssetValue !=null">
  766. net_asset_value,
  767. </if>
  768. <if test="voucherType !=null">
  769. voucher_type ,
  770. </if>
  771. <if test="voucherNumber !=null">
  772. voucher_number,
  773. </if>
  774. <if test="deviceUnit !=null">
  775. device_unit,
  776. </if>
  777. <if test="price !=null">
  778. price
  779. </if>
  780. </trim>
  781. <trim prefix="values (" suffix=")" suffixOverrides=",">
  782. <if test=" id != null">
  783. #{id}, </if>
  784. <if test=" modelUuid != null">
  785. #{modelUuid}, </if>
  786. <if test=" getUuid != null">
  787. #{getUuid}, </if>
  788. <if test="keepUuid !=null">
  789. #{keepUuid}, </if>
  790. <if test=" assetNumber != null">
  791. #{assetNumber}, </if>
  792. <if test=" deviceNo != null">
  793. #{deviceNo}, </if>
  794. <if test=" bookkeeper != null">
  795. #{bookkeeper}, </if>
  796. <if test=" handler != null">
  797. #{handler}, </if>
  798. <if test=" productionDate != null">
  799. #{productionDate}, </if>
  800. <if test=" inputDate != null">
  801. #{inputDate}, </if>
  802. <if test=" status != null">
  803. #{status}, </if>
  804. <if test=" remark != null">
  805. #{remark}, </if>
  806. <if test=" cId != null">
  807. #{cId}, </if>
  808. <if test=" cTime != null">
  809. #{cTime}, </if>
  810. <if test=" uuid != null">
  811. #{uuid}, </if>
  812. <if test=" statusKeep != null">
  813. #{statusKeep}, </if>
  814. <if test=" keepLasttimeStart != null">
  815. #{keepLasttimeStart}, </if>
  816. <if test=" keepLasttimeEnd != null">
  817. #{keepLasttimeEnd}, </if>
  818. <if test=" statusRepair != null">
  819. #{statusRepair}, </if>
  820. <if test=" repairTimeStart != null">
  821. #{repairTimeStart}, </if>
  822. <if test=" repairTimeEnd != null">
  823. #{repairTimeEnd}, </if>
  824. <if test=" repairLasttimeStart != null">
  825. #{repairLasttimeStart}, </if>
  826. <if test=" repairLasttimeEnd != null">
  827. #{repairLasttimeEnd}, </if>
  828. <if test=" repairer != null">
  829. #{repairer}, </if>
  830. <if test="statusGet !=null">
  831. #{statusGet}, </if>
  832. <if test="repairRemarks !=null">
  833. #{repairRemarks},
  834. </if>
  835. <if test="producer !=null">
  836. #{producer},
  837. </if>
  838. <if test="deviceCount !=null">
  839. #{deviceCount},
  840. </if>
  841. <if test="storeCount !=null">
  842. #{storeCount},
  843. </if>
  844. <if test="position !=null">
  845. #{position},
  846. </if>
  847. <if test="storagerack !=null">
  848. #{storagerack},
  849. </if>
  850. <if test="storagerackCell !=null">
  851. #{storagerackCell},
  852. </if>
  853. <if test="unitPrice !=null">
  854. #{unitPrice},
  855. </if>
  856. <if test="usageDocument !=null">
  857. #{usageDocument},
  858. </if>
  859. <if test="placeOfOrigin !=null">
  860. #{placeOfOrigin},
  861. </if>
  862. <if test="yearOfPurchase !=null">
  863. #{yearOfPurchase},
  864. </if>
  865. <if test="netAssetValue !=null">
  866. #{netAssetValue},
  867. </if>
  868. <if test="voucherType !=null">
  869. #{voucherType},
  870. </if>
  871. <if test="voucherNumber !=null">
  872. #{voucherNumber},
  873. </if>
  874. <if test="deviceUnit !=null">
  875. #{deviceUnit},
  876. </if>
  877. <if test="price !=null">
  878. #{price}
  879. </if>
  880. </trim>
  881. </insert>
  882. <update id="update" parameterType="cn.ourwill.module.house.entity.dm.Device">
  883. UPDATE dm_device <set>
  884. <if test="id != null">
  885. id= #{id} ,
  886. </if>
  887. <if test="modelUuid != null">
  888. model_uuid= #{modelUuid} ,
  889. </if>
  890. <if test="getUuid != null">
  891. get_uuid= #{getUuid} ,
  892. </if>
  893. <if test="keepUuid !=null">
  894. keep_uuid = #{keepUuid} ,
  895. </if>
  896. <if test="assetNumber != null">
  897. asset_number= #{assetNumber} ,
  898. </if>
  899. <if test="deviceNo != null">
  900. device_no= #{deviceNo} ,
  901. </if>
  902. <if test="bookkeeper != null">
  903. bookkeeper= #{bookkeeper} ,
  904. </if>
  905. <if test="handler != null">
  906. handler= #{handler} ,
  907. </if>
  908. <if test="productionDate != null">
  909. production_date= #{productionDate} ,
  910. </if>
  911. <if test="inputDate != null">
  912. input_date= #{inputDate} ,
  913. </if>
  914. <if test="status != null">
  915. status= #{status} ,
  916. </if>
  917. <if test="remark != null">
  918. remark= #{remark} ,
  919. </if>
  920. <if test="cId != null">
  921. c_id= #{cId} ,
  922. </if>
  923. <if test="cTime != null">
  924. c_time= #{cTime} ,
  925. </if>
  926. <if test="uuid != null">
  927. uuid= #{uuid} ,
  928. </if>
  929. <if test="statusKeep != null">
  930. status_keep= #{statusKeep} ,
  931. </if>
  932. <if test="keepLasttimeStart != null">
  933. keep_lasttime_start= #{keepLasttimeStart} ,
  934. </if>
  935. <if test="keepLasttimeEnd != null">
  936. keep_lasttime_end= #{keepLasttimeEnd} ,
  937. </if>
  938. <if test="statusRepair != null">
  939. status_repair= #{statusRepair} ,
  940. </if>
  941. <if test="repairTimeStart != null">
  942. repair_time_start= #{repairTimeStart} ,
  943. </if>
  944. <if test="repairTimeEnd != null">
  945. repair_time_end= #{repairTimeEnd} ,
  946. </if>
  947. <if test="repairLasttimeStart != null">
  948. repair_lasttime_start= #{repairLasttimeStart} ,
  949. </if>
  950. <if test="repairLasttimeEnd != null">
  951. repair_lasttime_end= #{repairLasttimeEnd} ,
  952. </if>
  953. <if test="repairer != null">
  954. repairer= #{repairer} ,
  955. </if>
  956. <if test="statusGet !=null">
  957. status_get = #{statusGet} ,
  958. </if>
  959. <if test="repairRemarks !=null">
  960. repair_remarks = #{repairRemarks},
  961. </if>
  962. <if test="producer !=null">
  963. producer = #{producer},
  964. </if>
  965. <if test="deviceCount !=null">
  966. device_count = #{deviceCount},
  967. </if>
  968. <if test="storeCount !=null">
  969. store_count = #{storeCount},
  970. </if>
  971. <if test="position !=null">
  972. position = #{position},
  973. </if>
  974. <if test="storagerack !=null">
  975. storagerack = #{storagerack},
  976. </if>
  977. <if test="storagerackCell !=null">
  978. storagerack_cell = #{storagerackCell},
  979. </if>
  980. <if test="unitPrice !=null">
  981. unit_price = #{unitPrice},
  982. </if>
  983. <if test="usageDocument !=null">
  984. usage_document = #{usageDocument},
  985. </if>
  986. <if test="placeOfOrigin !=null">
  987. place_of_origin = #{placeOfOrigin},
  988. </if>
  989. <if test="yearOfPurchase !=null">
  990. year_of_purchase = #{yearOfPurchase},
  991. </if>
  992. <if test="netAssetValue !=null">
  993. net_asset_value = #{netAssetValue},
  994. </if>
  995. <if test="voucherType !=null">
  996. voucher_type = #{voucherType},
  997. </if>
  998. <if test="voucherNumber !=null">
  999. voucher_number = #{voucherNumber},
  1000. </if>
  1001. <if test="deviceUnit !=null">
  1002. device_unit = #{deviceUnit},
  1003. </if>
  1004. <if test="price !=null">
  1005. price = #{price}
  1006. </if>
  1007. </set>
  1008. WHERE id = #{id}
  1009. </update>
  1010. <update id="updateByUuid" parameterType="cn.ourwill.module.house.entity.dm.Device">
  1011. UPDATE dm_device <set>
  1012. <if test="modelUuid != null">
  1013. model_uuid= #{modelUuid} ,
  1014. </if>
  1015. <if test="getUuid != null">
  1016. get_uuid= #{getUuid} ,
  1017. </if>
  1018. <if test="keepUuid !=null">
  1019. and keep_uuid = #{keepUuid} ,
  1020. </if>
  1021. <if test="assetNumber != null">
  1022. asset_number= #{assetNumber} ,
  1023. </if>
  1024. <if test="deviceNo != null">
  1025. device_no= #{deviceNo} ,
  1026. </if>
  1027. <if test="bookkeeper != null">
  1028. bookkeeper= #{bookkeeper} ,
  1029. </if>
  1030. <if test="handler != null">
  1031. handler= #{handler} ,
  1032. </if>
  1033. <if test="productionDate != null">
  1034. production_date= #{productionDate} ,
  1035. </if>
  1036. <if test="inputDate != null">
  1037. input_date= #{inputDate} ,
  1038. </if>
  1039. <if test="status != null">
  1040. status= #{status} ,
  1041. </if>
  1042. <if test="remark != null">
  1043. remark= #{remark} ,
  1044. </if>
  1045. <if test="cId != null">
  1046. c_id= #{cId} ,
  1047. </if>
  1048. <if test="cTime != null">
  1049. c_time= #{cTime} ,
  1050. </if>
  1051. <if test="uuid != null">
  1052. uuid= #{uuid} ,
  1053. </if>
  1054. <if test="statusKeep != null">
  1055. status_keep= #{statusKeep} ,
  1056. </if>
  1057. <if test="keepLasttimeStart != null">
  1058. keep_lasttime_start= #{keepLasttimeStart} ,
  1059. </if>
  1060. <if test="keepLasttimeEnd != null">
  1061. keep_lasttime_end= #{keepLasttimeEnd} ,
  1062. </if>
  1063. <if test="statusRepair != null">
  1064. status_repair= #{statusRepair} ,
  1065. </if>
  1066. <if test="repairTimeStart != null">
  1067. repair_time_start= #{repairTimeStart} ,
  1068. </if>
  1069. <if test="repairTimeEnd != null">
  1070. repair_time_end= #{repairTimeEnd} ,
  1071. </if>
  1072. <if test="repairLasttimeStart != null">
  1073. repair_lasttime_start= #{repairLasttimeStart} ,
  1074. </if>
  1075. <if test="repairLasttimeEnd != null">
  1076. repair_lasttime_end= #{repairLasttimeEnd} ,
  1077. </if>
  1078. <if test="repairer != null">
  1079. repairer= #{repairer} ,
  1080. </if>
  1081. <if test="statusGet !=null">
  1082. status_get = #{statusGet} ,
  1083. </if>
  1084. <if test="repairRemarks !=null">
  1085. repair_remarks = #{repairRemarks},
  1086. </if>
  1087. <if test="producer !=null">
  1088. producer = #{producer},
  1089. </if>
  1090. <if test="deviceCount !=null">
  1091. device_count = #{deviceCount},
  1092. </if>
  1093. <if test="storeCount !=null">
  1094. store_count = #{storeCount},
  1095. </if>
  1096. <if test="position !=null">
  1097. position = #{position},
  1098. </if>
  1099. <if test="storagerack !=null">
  1100. storagerack = #{storagerack},
  1101. </if>
  1102. <if test="storagerackCell !=null">
  1103. storagerack_cell = #{storagerackCell},
  1104. </if>
  1105. <if test="unitPrice !=null">
  1106. unit_price = #{unitPrice},
  1107. </if>
  1108. <if test="usageDocument !=null">
  1109. usage_document = #{usageDocument},
  1110. </if>
  1111. <if test="placeOfOrigin !=null">
  1112. place_of_origin = #{placeOfOrigin},
  1113. </if>
  1114. <if test="yearOfPurchase !=null">
  1115. year_of_purchase = #{yearOfPurchase},
  1116. </if>
  1117. <if test="netAssetValue !=null">
  1118. net_asset_value = #{netAssetValue},
  1119. </if>
  1120. <if test="voucherType !=null">
  1121. voucher_type = #{voucherType},
  1122. </if>
  1123. <if test="voucherNumber !=null">
  1124. voucher_number = #{voucherNumber},
  1125. </if>
  1126. <if test="deviceUnit !=null">
  1127. device_unit = #{deviceUnit},
  1128. </if>
  1129. <if test="price !=null">
  1130. price = #{price}
  1131. </if>
  1132. </set>
  1133. WHERE uuid = #{uuid}
  1134. </update>
  1135. <update id="updateByModelUuid" parameterType="cn.ourwill.module.house.entity.dm.Device">
  1136. UPDATE dm_device <set>
  1137. <if test="modelUuid != null">
  1138. model_uuid= #{modelUuid} ,
  1139. </if>
  1140. <if test="getUuid != null">
  1141. get_uuid= #{getUuid} ,
  1142. </if>
  1143. <if test="keepUuid !=null">
  1144. and keep_uuid = #{keepUuid} ,
  1145. </if>
  1146. <if test="assetNumber != null">
  1147. asset_number= #{assetNumber} ,
  1148. </if>
  1149. <if test="deviceNo != null">
  1150. device_no= #{deviceNo} ,
  1151. </if>
  1152. <if test="bookkeeper != null">
  1153. bookkeeper= #{bookkeeper} ,
  1154. </if>
  1155. <if test="handler != null">
  1156. handler= #{handler} ,
  1157. </if>
  1158. <if test="productionDate != null">
  1159. production_date= #{productionDate} ,
  1160. </if>
  1161. <if test="inputDate != null">
  1162. input_date= #{inputDate} ,
  1163. </if>
  1164. <if test="status != null">
  1165. status= #{status} ,
  1166. </if>
  1167. <if test="remark != null">
  1168. remark= #{remark} ,
  1169. </if>
  1170. <if test="cId != null">
  1171. c_id= #{cId} ,
  1172. </if>
  1173. <if test="cTime != null">
  1174. c_time= #{cTime} ,
  1175. </if>
  1176. <if test="uuid != null">
  1177. uuid= #{uuid} ,
  1178. </if>
  1179. <if test="statusKeep != null">
  1180. status_keep= #{statusKeep} ,
  1181. </if>
  1182. <if test="keepLasttimeStart != null">
  1183. keep_lasttime_start= #{keepLasttimeStart} ,
  1184. </if>
  1185. <if test="keepLasttimeEnd != null">
  1186. keep_lasttime_end= #{keepLasttimeEnd} ,
  1187. </if>
  1188. <if test="statusRepair != null">
  1189. status_repair= #{statusRepair} ,
  1190. </if>
  1191. <if test="repairTimeStart != null">
  1192. repair_time_start= #{repairTimeStart} ,
  1193. </if>
  1194. <if test="repairTimeEnd != null">
  1195. repair_time_end= #{repairTimeEnd} ,
  1196. </if>
  1197. <if test="repairLasttimeStart != null">
  1198. repair_lasttime_start= #{repairLasttimeStart} ,
  1199. </if>
  1200. <if test="repairLasttimeEnd != null">
  1201. repair_lasttime_end= #{repairLasttimeEnd} ,
  1202. </if>
  1203. <if test="repairer != null">
  1204. repairer= #{repairer} ,
  1205. </if>
  1206. <if test="statusGet !=null">
  1207. status_get = #{statusGet} ,
  1208. </if>
  1209. <if test="repairRemarks !=null">
  1210. repair_remarks = #{repairRemarks},
  1211. </if>
  1212. <if test="producer !=null">
  1213. producer = #{producer},
  1214. </if>
  1215. <if test="deviceCount !=null">
  1216. device_count = #{deviceCount},
  1217. </if>
  1218. <if test="storeCount !=null">
  1219. store_count = #{storeCount},
  1220. </if>
  1221. <if test="position !=null">
  1222. position = #{position},
  1223. </if>
  1224. <if test="storagerack !=null">
  1225. storagerack = #{storagerack},
  1226. </if>
  1227. <if test="storagerackCell !=null">
  1228. storagerack_cell = #{storagerackCell},
  1229. </if>
  1230. <if test="unitPrice !=null">
  1231. unit_price = #{unitPrice},
  1232. </if>
  1233. <if test="usageDocument !=null">
  1234. usage_document = #{usageDocument},
  1235. </if>
  1236. <if test="placeOfOrigin !=null">
  1237. place_of_origin = #{placeOfOrigin},
  1238. </if>
  1239. <if test="yearOfPurchase !=null">
  1240. year_of_purchase = #{yearOfPurchase},
  1241. </if>
  1242. <if test="netAssetValue !=null">
  1243. net_asset_value = #{netAssetValue},
  1244. </if>
  1245. <if test="voucherType !=null">
  1246. voucher_type = #{voucherType},
  1247. </if>
  1248. <if test="voucherNumber !=null">
  1249. voucher_number = #{voucherNumber},
  1250. </if>
  1251. <if test="deviceUnit !=null">
  1252. device_unit = #{deviceUnit},
  1253. </if>
  1254. <if test="price !=null">
  1255. price = #{price}
  1256. </if>
  1257. </set>
  1258. WHERE model_uuid = #{modelUuid}
  1259. ORDER BY id ASC LIMIT 1
  1260. </update>
  1261. <delete id="deleteById" parameterType="java.lang.Long">
  1262. DELETE FROM dm_device WHERE id = #{id}
  1263. </delete>
  1264. <delete id="deleteByIds" parameterType="java.util.List">
  1265. DELETE FROM dm_device WHERE id IN
  1266. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  1267. #{item}
  1268. </foreach>
  1269. </delete>
  1270. <select id="getDeviceByNameModelGrainId" resultMap="mapOfFind" parameterType="String">
  1271. SELECT
  1272. <include refid="columns"/>
  1273. FROM
  1274. dm_device a
  1275. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  1276. <where>
  1277. <if test="deviceName !=''">
  1278. AND ddm.device_name = #{deviceName}
  1279. </if>
  1280. <if test="deviceModel !=''">
  1281. AND ddm.device_model = #{deviceModel}
  1282. </if>
  1283. <if test="grainId !=''">
  1284. AND ddm.grain_id = #{grainId}
  1285. </if>
  1286. </where>
  1287. ORDER BY a.id ASC LIMIT 1
  1288. </select>
  1289. <select id="getsum" resultType="java.lang.Integer">
  1290. SELECT
  1291. SUM(a.store_count)
  1292. FROM
  1293. dm_device a
  1294. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  1295. <where>
  1296. <if test="deviceName !=''">
  1297. AND ddm.device_name = #{deviceName}
  1298. </if>
  1299. <if test="deviceModel !=''">
  1300. AND ddm.device_model = #{deviceModel}
  1301. </if>
  1302. <if test="grainId !=''">
  1303. AND ddm.grain_id = #{grainId}
  1304. </if>
  1305. </where>
  1306. ORDER BY a.id ASC
  1307. </select>
  1308. <select id="getPagsModel" resultMap="mapOfFind" parameterType="String">
  1309. SELECT
  1310. <include refid="columns"/>
  1311. FROM
  1312. dm_device a
  1313. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  1314. <where>
  1315. <if test="deviceModel !=''">
  1316. AND ddm.device_model = #{deviceModel}
  1317. </if>
  1318. <if test="grainId !=''">
  1319. AND ddm.grain_id = #{grainId}
  1320. </if>
  1321. </where>
  1322. </select>
  1323. <select id="getDeviceByNameModel" resultMap="mapOfFind" parameterType="String">
  1324. SELECT
  1325. <include refid="columns"/>
  1326. FROM
  1327. dm_device a
  1328. LEFT JOIN dm_device_model ddm ON ddm.uuid = a.model_uuid
  1329. <where>
  1330. <if test="deviceName !=''">
  1331. AND ddm.device_name = #{deviceName}
  1332. </if>
  1333. <if test="deviceModel !=''">
  1334. AND ddm.device_model = #{deviceModel}
  1335. </if>
  1336. <if test="grainId !=''">
  1337. AND ddm.grain_id = #{grainId}
  1338. </if>
  1339. </where>
  1340. </select>
  1341. <select id="getPags" resultMap="baseMap">
  1342. SELECT
  1343. <include refid="columns"/>
  1344. FROM dm_device a
  1345. <include refid="joinCols"/>
  1346. WHERE a.model_uuid = #{uuid}
  1347. order by a.input_date asc
  1348. </select>
  1349. <select id="getPags1" resultMap="baseMap">
  1350. SELECT
  1351. *
  1352. FROM dm_device a
  1353. <include refid="joinCols"/>
  1354. WHERE a.model_uuid = #{uuid}
  1355. order by a.input_date ASC,a.c_time ASC
  1356. </select>
  1357. <select id="getDeviceName" resultMap="baseMap">
  1358. SELECT
  1359. <include refid="columns"/>
  1360. FROM dm_device a
  1361. <include refid="joinCols"/>
  1362. WHERE a.model_uuid = #{uuid}
  1363. order by a.input_date asc
  1364. </select>
  1365. <select id="getModelUuid" resultMap="baseMap">
  1366. SELECT
  1367. <include refid="columnss"/>,
  1368. <include refid="columsOfFindd"/>
  1369. FROM dm_device a
  1370. left join dm_device_model ddm on model_uuid = ddm.uuid
  1371. <include refid="joinCols"/>
  1372. WHERE a.uuid = #{modelUuid}
  1373. </select>
  1374. <select id="getdeviceId" resultMap="baseMap">
  1375. SELECT
  1376. <include refid="columnss"/>,
  1377. <include refid="columsOfFindd"/>
  1378. FROM dm_device a
  1379. left join dm_device_model ddm on model_uuid = ddm.uuid
  1380. <include refid="joinCols"/>
  1381. WHERE a.device_no = #{deviceNo} and ddm.device_model = #{deviceModel} and ddm.device_name = #{deviceName}
  1382. </select>
  1383. <insert id="insertDevice" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  1384. parameterType="cn.ourwill.module.house.entity.dm.Device">
  1385. INSERT INTO dm_device
  1386. <trim prefix="(" suffix=")" suffixOverrides=",">
  1387. <if test=" id != null">
  1388. id,
  1389. </if>
  1390. <if test=" modelUuid != null">
  1391. model_uuid,
  1392. </if>
  1393. <if test=" getUuid != null">
  1394. get_uuid,
  1395. </if>
  1396. <if test=" deviceNo != null">
  1397. device_no,
  1398. </if>
  1399. <if test=" inputDate != null">
  1400. input_date,
  1401. </if>
  1402. <if test=" remark != null">
  1403. remark,
  1404. </if>
  1405. <if test=" cId != null">
  1406. c_id,
  1407. </if>
  1408. <if test=" cTime != null">
  1409. c_time,
  1410. </if>
  1411. <if test=" uuid != null">
  1412. uuid,
  1413. </if>
  1414. <if test="statusGet !=null">
  1415. status_get,
  1416. </if>
  1417. <if test="deviceCount !=null">
  1418. device_count,
  1419. </if>
  1420. <if test="storeCount !=null">
  1421. store_count,
  1422. </if>
  1423. <if test="unitPrice !=null">
  1424. unitPrice,
  1425. </if>
  1426. </trim>
  1427. <trim prefix="values (" suffix=")" suffixOverrides=",">
  1428. <if test=" id != null">
  1429. #{id}, </if>
  1430. <if test=" modelUuid != null">
  1431. #{modelUuid}, </if>
  1432. <if test=" getUuid != null">
  1433. #{getUuid}, </if>
  1434. <if test=" deviceNo != null">
  1435. #{device_no}, </if>
  1436. <if test=" inputDate != null">
  1437. #{input_date}, </if>
  1438. <if test=" remark != null">
  1439. #{remark}, </if>
  1440. <if test=" cId != null">
  1441. #{cId}, </if>
  1442. <if test=" cTime != null">
  1443. #{cTime}, </if>
  1444. <if test=" uuid != null">
  1445. #{uuid}, </if>
  1446. <if test="statusGet !=null">
  1447. #{statusGet}, </if>
  1448. <if test="deviceCount !=null">
  1449. #{deviceCount}, </if>
  1450. <if test="storeCount !=null">
  1451. #{storeCount}, </if>
  1452. <if test="unitPrice !=null">
  1453. #{unitPrice}, </if>
  1454. </trim>
  1455. </insert>
  1456. </mapper>