InstallListMapper.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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="com.bz.smart_city.dao.assistant.InstallListMapper">
  4. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.assistant.InstallList">
  5. <!--@mbg.generated-->
  6. <id column="id" property="id" />
  7. <result column="site_id" property="siteId" />
  8. <result column="install_plan_id" property="installPlanId" />
  9. <result column="install_plan_data_id" property="installPlanDataId" />
  10. <result column="building_id" property="buildingId" />
  11. <result column="accept_plan_id" property="acceptPlanId" />
  12. <result column="intall_batch_id" property="intallBatchId" />
  13. <result column="customer_id" property="customerId" />
  14. <result column="door_no" property="doorNo" />
  15. <result column="device_id" property="deviceId" />
  16. <result column="device_type_id" property="deviceTypeId" />
  17. <result column="device_no" property="deviceNo" />
  18. <result column="electronic_no" property="electronicNo" />
  19. <result column="file_no" property="fileNo" />
  20. <result column="new_meter_start" property="newMeterStart" />
  21. <result column="old_meter_end" property="oldMeterEnd" />
  22. <result column="image_url" property="imageUrl" />
  23. <result column="old_image_url" property="oldImageUrl" />
  24. <result column="user_name" property="userName" />
  25. <result column="user_phone" property="userPhone" />
  26. <result column="is_in_plan" property="isInPlan" />
  27. <result column="is_installed" property="isInstalled" />
  28. <result column="is_accepted" property="isAccepted" />
  29. <result column="plan_time" property="planTime" />
  30. <result column="install_time" property="installTime" />
  31. <result column="accept_time" property="acceptTime" />
  32. <result column="remark" property="remark" />
  33. <result column="status" property="status" />
  34. <result column="date_create" property="dateCreate" />
  35. <result column="date_update" property="dateUpdate" />
  36. <result column="create_by" property="createBy" />
  37. <result column="update_by" property="updateBy" />
  38. <result column="floor" property="floor" />
  39. </resultMap>
  40. <resultMap id="BaseResultMapWithAccount" type="com.bz.smart_city.entity.assistant.InstallList">
  41. <!--@mbg.generated-->
  42. <id column="id" property="id" />
  43. <result column="site_id" property="siteId" />
  44. <result column="install_plan_id" property="installPlanId" />
  45. <result column="install_plan_data_id" property="installPlanDataId" />
  46. <result column="building_id" property="buildingId" />
  47. <result column="accept_plan_id" property="acceptPlanId" />
  48. <result column="intall_batch_id" property="intallBatchId" />
  49. <result column="customer_id" property="customerId" />
  50. <result column="door_no" property="doorNo" />
  51. <result column="device_id" property="deviceId" />
  52. <result column="device_type_id" property="deviceTypeId" />
  53. <result column="device_no" property="deviceNo" />
  54. <result column="electronic_no" property="electronicNo" />
  55. <result column="file_no" property="fileNo" />
  56. <result column="new_meter_start" property="newMeterStart" />
  57. <result column="old_meter_end" property="oldMeterEnd" />
  58. <result column="image_url" property="imageUrl" />
  59. <result column="old_image_url" property="oldImageUrl" />
  60. <result column="user_name" property="userName" />
  61. <result column="user_phone" property="userPhone" />
  62. <result column="is_in_plan" property="isInPlan" />
  63. <result column="is_installed" property="isInstalled" />
  64. <result column="is_accepted" property="isAccepted" />
  65. <result column="plan_time" property="planTime" />
  66. <result column="install_time" property="installTime" />
  67. <result column="accept_time" property="acceptTime" />
  68. <result column="remark" property="remark" />
  69. <result column="status" property="status" />
  70. <result column="date_create" property="dateCreate" />
  71. <result column="date_update" property="dateUpdate" />
  72. <result column="create_by" property="createBy" />
  73. <result column="update_by" property="updateBy" />
  74. <result column="floor" property="floor" />
  75. <result column="metercode" property="metercode" />
  76. <result column="account_id" property="accountId" />
  77. </resultMap>
  78. <sql id="Base_Column_List">
  79. <!--@mbg.generated-->
  80. id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id,
  81. intall_batch_id, customer_id, door_no, device_id, device_type_id, device_no, electronic_no,
  82. file_no, new_meter_start, old_meter_end, image_url, old_image_url, user_name, user_phone,
  83. is_in_plan, is_installed, is_accepted, plan_time, install_time, accept_time, remark,
  84. `status`, date_create, date_update, create_by, update_by, `floor`
  85. </sql>
  86. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.assistant.InstallList" useGeneratedKeys="true">
  87. <!--@mbg.generated-->
  88. insert into sc_install_list
  89. <trim prefix="(" suffix=")" suffixOverrides=",">
  90. <if test="siteId != null">
  91. site_id,
  92. </if>
  93. <if test="installPlanId != null">
  94. install_plan_id,
  95. </if>
  96. <if test="installPlanDataId != null">
  97. install_plan_data_id,
  98. </if>
  99. <if test="buildingId != null">
  100. building_id,
  101. </if>
  102. <if test="acceptPlanId != null">
  103. accept_plan_id,
  104. </if>
  105. <if test="intallBatchId != null">
  106. intall_batch_id,
  107. </if>
  108. <if test="customerId != null">
  109. customer_id,
  110. </if>
  111. <if test="doorNo != null">
  112. door_no,
  113. </if>
  114. <if test="deviceId != null">
  115. device_id,
  116. </if>
  117. <if test="deviceTypeId != null">
  118. device_type_id,
  119. </if>
  120. <if test="deviceNo != null">
  121. device_no,
  122. </if>
  123. <if test="electronicNo != null">
  124. electronic_no,
  125. </if>
  126. <if test="fileNo != null">
  127. file_no,
  128. </if>
  129. <if test="newMeterStart != null">
  130. new_meter_start,
  131. </if>
  132. <if test="oldMeterEnd != null">
  133. old_meter_end,
  134. </if>
  135. <if test="imageUrl != null">
  136. image_url,
  137. </if>
  138. <if test="oldImageUrl != null">
  139. old_image_url,
  140. </if>
  141. <if test="userName != null">
  142. user_name,
  143. </if>
  144. <if test="userPhone != null">
  145. user_phone,
  146. </if>
  147. <if test="isInPlan != null">
  148. is_in_plan,
  149. </if>
  150. <if test="isInstalled != null">
  151. is_installed,
  152. </if>
  153. <if test="isAccepted != null">
  154. is_accepted,
  155. </if>
  156. <if test="planTime != null">
  157. plan_time,
  158. </if>
  159. <if test="installTime != null">
  160. install_time,
  161. </if>
  162. <if test="acceptTime != null">
  163. accept_time,
  164. </if>
  165. <if test="remark != null">
  166. remark,
  167. </if>
  168. <if test="status != null">
  169. `status`,
  170. </if>
  171. <if test="dateCreate != null">
  172. date_create,
  173. </if>
  174. <if test="dateUpdate != null">
  175. date_update,
  176. </if>
  177. <if test="createBy != null">
  178. create_by,
  179. </if>
  180. <if test="updateBy != null">
  181. update_by,
  182. </if>
  183. <if test="floor != null">
  184. `floor`,
  185. </if>
  186. <if test="idCard != null">
  187. id_card,
  188. </if>
  189. </trim>
  190. <trim prefix="values (" suffix=")" suffixOverrides=",">
  191. <if test="siteId != null">
  192. #{siteId},
  193. </if>
  194. <if test="installPlanId != null">
  195. #{installPlanId},
  196. </if>
  197. <if test="installPlanDataId != null">
  198. #{installPlanDataId},
  199. </if>
  200. <if test="buildingId != null">
  201. #{buildingId},
  202. </if>
  203. <if test="acceptPlanId != null">
  204. #{acceptPlanId},
  205. </if>
  206. <if test="intallBatchId != null">
  207. #{intallBatchId},
  208. </if>
  209. <if test="customerId != null">
  210. #{customerId},
  211. </if>
  212. <if test="doorNo != null">
  213. #{doorNo},
  214. </if>
  215. <if test="deviceId != null">
  216. #{deviceId},
  217. </if>
  218. <if test="deviceTypeId != null">
  219. #{deviceTypeId},
  220. </if>
  221. <if test="deviceNo != null">
  222. #{deviceNo},
  223. </if>
  224. <if test="electronicNo != null">
  225. #{electronicNo},
  226. </if>
  227. <if test="fileNo != null">
  228. #{fileNo},
  229. </if>
  230. <if test="newMeterStart != null">
  231. #{newMeterStart},
  232. </if>
  233. <if test="oldMeterEnd != null">
  234. #{oldMeterEnd},
  235. </if>
  236. <if test="imageUrl != null">
  237. #{imageUrl},
  238. </if>
  239. <if test="oldImageUrl != null">
  240. #{oldImageUrl},
  241. </if>
  242. <if test="userName != null">
  243. #{userName},
  244. </if>
  245. <if test="userPhone != null">
  246. #{userPhone},
  247. </if>
  248. <if test="isInPlan != null">
  249. #{isInPlan},
  250. </if>
  251. <if test="isInstalled != null">
  252. #{isInstalled},
  253. </if>
  254. <if test="isAccepted != null">
  255. #{isAccepted},
  256. </if>
  257. <if test="planTime != null">
  258. #{planTime},
  259. </if>
  260. <if test="installTime != null">
  261. #{installTime},
  262. </if>
  263. <if test="acceptTime != null">
  264. #{acceptTime},
  265. </if>
  266. <if test="remark != null">
  267. #{remark},
  268. </if>
  269. <if test="status != null">
  270. #{status},
  271. </if>
  272. <if test="dateCreate != null">
  273. #{dateCreate},
  274. </if>
  275. <if test="dateUpdate != null">
  276. #{dateUpdate},
  277. </if>
  278. <if test="createBy != null">
  279. #{createBy},
  280. </if>
  281. <if test="updateBy != null">
  282. #{updateBy},
  283. </if>
  284. <if test="floor != null">
  285. #{floor},
  286. </if>
  287. <if test="idCard != null">
  288. #{idCard},
  289. </if>
  290. </trim>
  291. </insert>
  292. <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.assistant.InstallList">
  293. <!--@mbg.generated-->
  294. update sc_install_list
  295. <set>
  296. <if test="siteId != null">
  297. site_id = #{siteId},
  298. </if>
  299. <if test="installPlanId != null">
  300. install_plan_id = #{installPlanId},
  301. </if>
  302. <if test="installPlanDataId != null">
  303. install_plan_data_id = #{installPlanDataId},
  304. </if>
  305. <if test="buildingId != null">
  306. building_id = #{buildingId},
  307. </if>
  308. <if test="acceptPlanId != null">
  309. accept_plan_id = #{acceptPlanId},
  310. </if>
  311. <if test="intallBatchId != null">
  312. intall_batch_id = #{intallBatchId},
  313. </if>
  314. <if test="customerId != null">
  315. customer_id = #{customerId},
  316. </if>
  317. <if test="doorNo != null">
  318. door_no = #{doorNo},
  319. </if>
  320. <if test="deviceId != null">
  321. device_id = #{deviceId},
  322. </if>
  323. <if test="deviceTypeId != null">
  324. device_type_id = #{deviceTypeId},
  325. </if>
  326. <if test="deviceNo != null">
  327. device_no = #{deviceNo},
  328. </if>
  329. <if test="electronicNo != null">
  330. electronic_no = #{electronicNo},
  331. </if>
  332. <if test="fileNo != null">
  333. file_no = #{fileNo},
  334. </if>
  335. <if test="newMeterStart != null">
  336. new_meter_start = #{newMeterStart},
  337. </if>
  338. <if test="oldMeterEnd != null">
  339. old_meter_end = #{oldMeterEnd},
  340. </if>
  341. <if test="imageUrl != null">
  342. image_url = #{imageUrl},
  343. </if>
  344. <if test="oldImageUrl != null">
  345. old_image_url = #{oldImageUrl},
  346. </if>
  347. <if test="userName != null">
  348. user_name = #{userName},
  349. </if>
  350. <if test="userPhone != null">
  351. user_phone = #{userPhone},
  352. </if>
  353. <if test="isInPlan != null">
  354. is_in_plan = #{isInPlan},
  355. </if>
  356. <if test="isInstalled != null">
  357. is_installed = #{isInstalled},
  358. </if>
  359. <if test="isAccepted != null">
  360. is_accepted = #{isAccepted},
  361. </if>
  362. <if test="planTime != null">
  363. plan_time = #{planTime},
  364. </if>
  365. <if test="installTime != null">
  366. install_time = #{installTime},
  367. </if>
  368. <if test="acceptTime != null">
  369. accept_time = #{acceptTime},
  370. </if>
  371. <if test="remark != null">
  372. remark = #{remark},
  373. </if>
  374. <if test="status != null">
  375. `status` = #{status},
  376. </if>
  377. <if test="dateCreate != null">
  378. date_create = #{dateCreate},
  379. </if>
  380. <if test="dateUpdate != null">
  381. date_update = #{dateUpdate},
  382. </if>
  383. <if test="createBy != null">
  384. create_by = #{createBy},
  385. </if>
  386. <if test="updateBy != null">
  387. update_by = #{updateBy},
  388. </if>
  389. <if test="floor != null">
  390. `floor` = #{floor},
  391. </if>
  392. <if test="idCard != null">
  393. id_card = #{idCard},
  394. </if>
  395. </set>
  396. where id = #{id}
  397. </update>
  398. <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
  399. <!--@mbg.generated-->
  400. insert into sc_install_list
  401. (site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id,
  402. customer_id, door_no, device_id, device_type_id, device_no, electronic_no, file_no,
  403. new_meter_start, old_meter_end, image_url, old_image_url, user_name, user_phone,
  404. is_in_plan, is_installed, is_accepted, plan_time, install_time, accept_time, remark,
  405. `status`, date_create, date_update, create_by, update_by, `floor`,account_id,id_card,metercode)
  406. values
  407. <foreach collection="list" item="item" separator=",">
  408. (#{item.siteId}, #{item.installPlanId}, #{item.installPlanDataId}, #{item.buildingId},
  409. #{item.acceptPlanId}, #{item.intallBatchId}, #{item.customerId}, #{item.doorNo},
  410. #{item.deviceId}, #{item.deviceTypeId}, #{item.deviceNo}, #{item.electronicNo},
  411. #{item.fileNo}, #{item.newMeterStart}, #{item.oldMeterEnd}, #{item.imageUrl}, #{item.oldImageUrl},
  412. #{item.userName}, #{item.userPhone}, #{item.isInPlan}, #{item.isInstalled}, #{item.isAccepted},
  413. #{item.planTime}, #{item.installTime}, #{item.acceptTime}, #{item.remark}, #{item.status},
  414. #{item.dateCreate}, #{item.dateUpdate}, #{item.createBy}, #{item.updateBy}, #{item.floor},#{item.account_id},#{item.idCard}
  415. ,#{item.fileNo})
  416. </foreach>
  417. </insert>
  418. <select id="queryInstallList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
  419. SELECT
  420. n.id as id,
  421. n.site_id as site_id,
  422. n.install_plan_id as install_plan_id,
  423. n.building_id as building_id,
  424. b.`name` as building_name,
  425. n.accept_plan_id as accept_plan_id,
  426. n.intall_batch_id as intall_batch_id,
  427. n.customer_id as customer_id,
  428. c.customer_name as customer_name,
  429. n.door_no as door_no,
  430. n.device_id as device_id,
  431. sd.device_type as device_type_id,
  432. dt.model as model,
  433. dt.equipment_type as equipment_type,
  434. dm.id as factory_id,
  435. dm.`name` as facory_name,
  436. sd.device_no as device_no,
  437. sd.water_meter_no as electronic_no,
  438. sd.water_meter_file_no as file_no,
  439. sd.seal_no,
  440. n.new_meter_start as new_meter_start,
  441. n.old_meter_end as old_meter_end,
  442. n.image_url as new_image_url,
  443. n.old_image_url as old_image_url,
  444. n.user_name as user_name,
  445. n.user_phone as user_phone,
  446. n.id_card as id_card,
  447. n.is_in_plan as is_in_plan,
  448. n.is_installed as is_installed,
  449. n.is_accepted as is_accepted,
  450. n.plan_time as plan_time,
  451. n.install_time as install_time,
  452. n.accept_time as accept_time,
  453. n.remark as remark,
  454. n.floor as floor,
  455. com.id as community_id,
  456. com.name as community_name,
  457. swmed.meter_reading,
  458. n.metercode as metercode,
  459. n.account_id as account_id,
  460. n.account_id as accountId,
  461. swrd.concentrator_id,
  462. swrd.collector_id,
  463. swrd.channel_number_id,
  464. swrd.port,
  465. scon.serial_number as concentrator_name,
  466. scol.collector_no as collector_name,
  467. scn.channel_name as channel_number_name
  468. FROM
  469. sc_install_list n
  470. left join sc_device sd on (sd.id = n.device_id)
  471. left join sc_building b on (b.id = n.building_id)
  472. left join sc_customer c on (c.id = n.customer_id)
  473. left join sc_device_type dt on (dt.id = sd.device_type)
  474. left join sc_device_manufacturer dm on (dm.id = dt.manufacturer_id)
  475. left join sc_community com on (com.id = b.community)
  476. left join sc_water_meter_error_days swmed on ( swmed.device_id = n.device_id)
  477. left join sc_water_related_device swrd on ( swrd.device_id = sd.id and swrd.status = 1)
  478. left join sc_concentrator scon on(scon.id = swrd.concentrator_id)
  479. left join sc_collector scol on(scol.id = swrd.collector_id)
  480. left join sc_channel_number scn on(scn.id = swrd.channel_number_id)
  481. WHERE
  482. n.STATUS = 1
  483. <if test="siteId != null">
  484. and n.site_id = #{siteId}
  485. </if>
  486. <if test="customerId != null">
  487. and n.customer_id = #{customerId}
  488. </if>
  489. <if test="installPlanId != null">
  490. and n.install_plan_id = #{installPlanId}
  491. </if>
  492. <if test="buildingId != null">
  493. and n.building_id = #{buildingId}
  494. </if>
  495. <if test="acceptPlanId != null">
  496. and n.accept_plan_id = #{acceptPlanId}
  497. </if>
  498. <if test="intallBatchId != null">
  499. and n.intall_batch_id = #{intallBatchId}
  500. </if>
  501. <if test="doorNo != null">
  502. and n.door_no = #{doorNo}
  503. </if>
  504. <if test="deviceId != null">
  505. and n.device_id = #{deviceId}
  506. </if>
  507. <if test="deviceTypeId != null">
  508. and n.device_type_id = #{deviceTypeId}
  509. </if>
  510. <if test="deviceNo != null">
  511. and n.device_no = #{deviceNo}
  512. </if>
  513. <if test="electronicNo != null">
  514. and n.electronic_no = #{electronicNo}
  515. </if>
  516. <if test="fileNo != null">
  517. and n.file_no = #{fileNo}
  518. </if>
  519. <if test="isInstalled != null">
  520. and n.is_installed = #{isInstalled}
  521. </if>
  522. <if test="isAccepted != null">
  523. and n.is_accepted = #{isAccepted}
  524. </if>
  525. <if test="isInPlan != null">
  526. and n.is_in_plan = #{isInPlan}
  527. </if>
  528. <if test="floor != null">
  529. and n.floor = #{floor}
  530. </if>
  531. order by n.date_create desc
  532. </select>
  533. <select id="queryPlanBuildingList" resultType="com.bz.smart_city.dto.assistant.PlanBuildingDTO">
  534. SELECT
  535. list.buidling_id AS building_id,
  536. list.building_name AS building_name,
  537. SUM( IF ( list.`is_installed` = 1, 1, 0 ) ) AS installed_count,
  538. SUM( IF ( list.`is_installed` = 0, 1, 0 ) ) AS un_install_count
  539. FROM
  540. (
  541. SELECT
  542. sil.building_id as buidling_id,
  543. sb.`name` as building_name,
  544. sil.is_installed
  545. FROM sc_install_list sil
  546. LEFT JOIN sc_building sb on (sb.id = sil.building_id and sb.status = 1)
  547. WHERE sil.`status` = 1
  548. and sil.is_accepted = 0
  549. and sil.install_plan_id in (
  550. SELECT
  551. ip.id
  552. FROM
  553. sc_install_plan ip
  554. WHERE
  555. ip.`status` = 1
  556. <if test="communityId != null and communityId != 0">
  557. and ip.community_id = #{communityId}
  558. </if>
  559. <if test="customerId != null and customerId != 0">
  560. AND ip.customer_id = #{customerId}
  561. </if>
  562. )
  563. <if test="customerId != null and customerId != 0">
  564. and sil.customer_id = #{customerId}
  565. </if>
  566. <if test="buildingName != null and buildingName != ''">
  567. and sb.name like concat('%',#{buildingName},'%')
  568. </if>
  569. ) list
  570. GROUP BY
  571. list.buidling_id,
  572. list.building_name
  573. order by building_name
  574. </select>
  575. <select id="queryPlanBuildingList1" resultType="com.bz.smart_city.dto.assistant.PlanBuildingDTO">
  576. SELECT
  577. list.buidling_id AS building_id,
  578. list.building_name AS building_name,
  579. SUM( IF ( list.`is_installed` = 1, 1, 0 ) ) AS installed_count,
  580. SUM( IF ( list.`is_installed` = 0, 1, 0 ) ) AS un_install_count
  581. FROM
  582. (
  583. SELECT
  584. tmp.buidling_id,
  585. tmp.building_name,
  586. il.is_installed
  587. FROM
  588. (
  589. SELECT
  590. ip.id,
  591. ip.community_id,
  592. cm.`name`,
  593. ip.buidling_id,
  594. ip.building_name
  595. FROM
  596. sc_install_plan ip
  597. LEFT JOIN sc_community cm ON ( ip.community_id = cm.id )
  598. WHERE
  599. ip.`status` = 1
  600. <if test="communityId != null and communityId != 0">
  601. and ip.community_id = #{communityId}
  602. </if>
  603. <if test="customerId != null and customerId != 0">
  604. AND ip.customer_id = #{customerId}
  605. </if>
  606. ) tmp
  607. JOIN sc_install_list il ON ( il.install_plan_id = tmp.id and il.building_id = tmp.buidling_id and il.`status` = 1 )
  608. ) list
  609. GROUP BY
  610. list.buidling_id,
  611. list.building_name
  612. order by un_install_count desc
  613. </select>
  614. <select id="queryPlanCommunityList" resultType="com.bz.smart_city.dto.assistant.PlanCommunityDTO">
  615. SELECT
  616. list.community_id AS community_id,
  617. list.NAME AS community_name,
  618. SUM( IF ( list.`is_installed` = 1, 1, 0 ) ) AS installed_count,
  619. SUM( IF ( list.`is_installed` = 0, 1, 0 ) ) AS un_install_count
  620. FROM
  621. (
  622. SELECT
  623. tmp.community_id,
  624. tmp.`name`,
  625. il.is_installed
  626. FROM
  627. (
  628. SELECT
  629. ip.id,
  630. ip.community_id,
  631. cm.`name`
  632. FROM
  633. sc_install_plan ip
  634. LEFT JOIN sc_community cm ON ( ip.community_id = cm.id )
  635. WHERE
  636. ip.`status` = 1
  637. <if test="customerId != null and customerId != 0">
  638. AND ip.customer_id = #{customerId}
  639. </if>
  640. <if test="communityName != null and communityName != '' ">
  641. AND cm.`name` LIKE #{communityName}
  642. </if>
  643. ) tmp
  644. JOIN sc_install_list il ON ( il.install_plan_id = tmp.id AND il.`status` = 1 and il.is_accepted = 0 and il.customer_id = #{customerId})
  645. ) list
  646. GROUP BY
  647. list.community_id,
  648. list.NAME
  649. order by un_install_count desc
  650. </select>
  651. <select id="queryUnPlanList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
  652. SELECT
  653. t.id as id,
  654. t.install_time as install_time,
  655. t.device_no as device_no,
  656. t.electronic_no as electronic_no,
  657. t.new_meter_start as new_meter_start,
  658. ct.customer_name as customer_name,
  659. t.customer_id,
  660. c.`name` as community_name,
  661. b.community as community_id,
  662. b.`name` as building_name,
  663. t.building_id,
  664. IF(t.accept_plan_id is null,0,1) as is_selected,
  665. t.door_no as door_no
  666. FROM
  667. sc_install_list t
  668. left join sc_building b on (t.building_id = b.id)
  669. left join sc_community c on (c.id = b.community)
  670. left join sc_customer ct on (t.customer_id = ct.id)
  671. WHERE
  672. t.is_installed = 1
  673. AND t.is_accepted = 0
  674. <if test="siteId != null">
  675. and t.site_id = #{siteId}
  676. </if>
  677. <if test="deviceNo != null and deviceNo != ''">
  678. and (t.device_no like #{deviceNo} or t.electronic_no like #{deviceNo})
  679. </if>
  680. <if test="communityId != null ">
  681. and c.id = #{communityId}
  682. </if>
  683. <if test="buildingId != null">
  684. and t.building_id = #{buildingId}
  685. </if>
  686. <if test="customerId != null">
  687. and t.customer_id = #{customerId}
  688. </if>
  689. AND ( t.accept_plan_id IS NULL OR t.accept_plan_id = #{acceptPlanId} )
  690. </select>
  691. <update id="updateBySelective">
  692. update
  693. sc_install_list
  694. <set>
  695. <if test="record.installPlanId != null">
  696. install_plan_id = #{record.installPlanId},
  697. </if>
  698. <if test="record.intallBatchId != null">
  699. intall_batch_id = #{record.intallBatchId},
  700. </if>
  701. <if test="record.deviceTypeId != null">
  702. device_type_id = #{record.deviceTypeId},
  703. </if>
  704. <if test="record.isInPlan != null">
  705. is_in_plan = #{record.isInPlan},
  706. </if>
  707. <if test="record.isInstalled != null">
  708. is_installed = #{record.isInstalled},
  709. </if>
  710. <if test="record.isAccepted != null">
  711. is_accepted = #{record.isAccepted},
  712. </if>
  713. <if test="record.planTime != null">
  714. plan_time = #{record.planTime},
  715. </if>
  716. <if test="record.installTime != null">
  717. install_time = #{record.installTime},
  718. </if>
  719. <if test="record.acceptTime != null">
  720. accept_time = #{record.acceptTime},
  721. </if>
  722. <if test="record.status != null">
  723. `status` = #{record.status},
  724. </if>
  725. <if test="record.createBy != null">
  726. create_by = #{record.createBy},
  727. </if>
  728. <if test="record.updateBy != null">
  729. update_by = #{record.updateBy},
  730. </if>
  731. </set>
  732. where
  733. status = 1
  734. <if test="param.acceptPlanId != null">
  735. and accept_plan_id = #{param.acceptPlanId}
  736. </if>
  737. </update>
  738. <update id="updateAcceptPlan">
  739. update
  740. sc_install_list
  741. set accept_plan_id = #{record.acceptPlanId}
  742. where status = 1 and accept_plan_id = #{param.acceptPlanId}
  743. </update>
  744. <!--按安装计划id查询已安装数-->
  745. <select id="countByInstallPlanIdAndIsInstalled" resultType="int">
  746. SELECT COUNT(1) FROM sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId} AND is_installed = #{isInstalled}
  747. </select>
  748. <!--按安装计划id更新状态(删除)-->
  749. <update id="delByInstallPlanId">
  750. update sc_install_list set status=0,date_update=NOW(),update_by=#{username} WHERE status = 1 AND install_plan_id = #{installPlanId}
  751. </update>
  752. <!--按安装计划id查询-->
  753. <select id="getInstallList" resultMap="BaseResultMap">
  754. select id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id, customer_id, door_no, device_id, device_no, electronic_no, user_name, user_phone, is_in_plan, is_installed, install_time from sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId}
  755. </select>
  756. <update id="updateByPrimaryKey">
  757. update sc_install_list
  758. <set>
  759. device_id = #{deviceId},
  760. device_type_id = #{deviceTypeId},
  761. device_no = #{deviceNo},
  762. electronic_no = #{electronicNo},
  763. file_no = #{fileNo},
  764. new_meter_start = #{newMeterStart},
  765. old_meter_end = #{oldMeterEnd},
  766. image_url = #{imageUrl},
  767. old_image_url = #{oldImageUrl},
  768. is_installed = #{isInstalled},
  769. install_time = #{installTime},
  770. update_by = #{updateBy},
  771. </set>
  772. where id = #{id}
  773. </update>
  774. <update id="updateByDeviceId2" parameterType="com.bz.smart_city.entity.assistant.InstallList">
  775. update sc_install_list
  776. <set>
  777. <if test="newMeterStart != null">
  778. new_meter_start = #{newMeterStart},
  779. </if>
  780. <if test="oldMeterEnd != null">
  781. old_meter_end = #{oldMeterEnd},
  782. </if>
  783. <if test="dateUpdate != null">
  784. date_update = #{dateUpdate},
  785. </if>
  786. </set>
  787. where device_id = #{deviceId}
  788. </update>
  789. <select id="queryUnPlanedList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
  790. SELECT
  791. t.id as id,
  792. t.install_time as install_time,
  793. t.device_no as device_no,
  794. t.electronic_no as electronic_no,
  795. t.new_meter_start as new_meter_start,
  796. ct.customer_name as customer_name,
  797. t.customer_id,
  798. c.`name` as community_name,
  799. b.community as community_id,
  800. b.`name` as building_name,
  801. t.building_id,
  802. t.door_no as door_no,
  803. d.device_status
  804. FROM
  805. sc_install_list t
  806. left join sc_building b on (t.building_id = b.id)
  807. left join sc_community c on (c.id = b.community)
  808. left join sc_customer ct on (t.customer_id = ct.id)
  809. left join sc_device d on (t.device_id = d.id)
  810. WHERE t.status = 1
  811. and t.is_installed = 1
  812. AND t.is_accepted = 0
  813. and t.accept_plan_id is null
  814. and t.customer_id = #{customerId}
  815. <if test="meterCode != null and meterCode != ''">
  816. and (t.device_no like #{meterCode} or t.electronic_no like #{meterCode})
  817. </if>
  818. <if test="communityId != null ">
  819. and c.id = #{communityId}
  820. </if>
  821. <if test="buildingId != null">
  822. and t.building_id = #{buildingId}
  823. </if>
  824. <if test="deviceStatus != null and deviceStatus !=''">
  825. and d.device_status = #{deviceStatus}
  826. </if>
  827. order by t.install_time desc
  828. </select>
  829. <select id="queryPlanedtList" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
  830. SELECT
  831. t.id as id,
  832. t.install_time as install_time,
  833. t.device_no as device_no,
  834. t.electronic_no as electronic_no,
  835. t.new_meter_start as new_meter_start,
  836. ct.customer_name as customer_name,
  837. t.customer_id,
  838. c.`name` as community_name,
  839. b.community as community_id,
  840. b.`name` as building_name,
  841. t.building_id,
  842. t.door_no as door_no,
  843. d.device_status
  844. FROM
  845. sc_install_list t
  846. left join sc_building b on (t.building_id = b.id)
  847. left join sc_community c on (c.id = b.community)
  848. left join sc_customer ct on (t.customer_id = ct.id)
  849. left join sc_device d on (t.device_id = d.id)
  850. WHERE t.status = 1
  851. and t.is_installed = 1
  852. and t.accept_plan_id = #{acceptPlanId}
  853. and t.customer_id = #{customerId}
  854. <if test="meterCode != null and meterCode != ''">
  855. and (t.device_no like #{meterCode} or t.electronic_no like #{meterCode})
  856. </if>
  857. <if test="communityId != null ">
  858. and c.id = #{communityId}
  859. </if>
  860. <if test="buildingId != null">
  861. and t.building_id = #{buildingId}
  862. </if>
  863. <if test="deviceStatus != null and deviceStatus != '' ">
  864. and d.device_status = #{deviceStatus}
  865. </if>
  866. </select>
  867. <update id="updateAcceptPlanNull">
  868. update
  869. sc_install_list
  870. set accept_plan_id = null
  871. where is_accepted = 0
  872. and id = #{id}
  873. and accept_plan_id = #{acceptPlanId}
  874. </update>
  875. <select id="findById" resultMap="BaseResultMap">
  876. select * from sc_install_list where id = #{id} and status = 1
  877. </select>
  878. <select id="findByIdWithLock" resultMap="BaseResultMapWithAccount">
  879. select * from sc_install_list where id = #{id} and status = 1 for update
  880. </select>
  881. <select id="findByDeviceId" resultMap="BaseResultMap">
  882. select * from sc_install_list where status = 1 and device_id = #{deviceId}
  883. </select>
  884. <select id="getInstallListByBuildIngId" resultMap="BaseResultMap">
  885. select id, site_id, install_plan_id, install_plan_data_id, building_id, accept_plan_id, intall_batch_id, customer_id, door_no, device_id, device_no, electronic_no, file_no, user_name, user_phone, id_card, is_in_plan, is_installed, install_time from sc_install_list WHERE status = 1 AND install_plan_id = #{installPlanId} and building_id = #{buildingId}
  886. </select>
  887. <select id="queryFloorList" resultType="java.lang.Integer">
  888. select floor from sc_install_list where status = 1 and building_id = #{buildingId} group by floor order by floor asc
  889. </select>
  890. <update id="updateByDeviceId">
  891. update
  892. sc_install_list
  893. <set>
  894. <if test="newDeviceNo != null">
  895. device_no = #{newDeviceNo},
  896. </if>
  897. <if test="newWaterMeterNo != null">
  898. electronic_no = #{newWaterMeterNo}
  899. </if>
  900. </set>
  901. where
  902. status = 1
  903. and device_id = #{deviceId}
  904. </update>
  905. <select id="meterAccept" resultType="com.bz.smart_city.dto.sync.MeterAcceptDto">
  906. select
  907. sd.water_meter_file_no as file_no,
  908. sil.is_installed as status
  909. from sc_install_list sil
  910. inner join sc_device sd on(sd.id = sil.device_id)
  911. where sil.status = 1 and sd.status = 1
  912. and sd.customer_id = #{customerId}
  913. <if test="createDate != null and createDate != ''"> and DATE_FORMAT(sil.accept_time, '%Y%m%d' ) = #{createDate}</if>
  914. <if test="fileNo != null and fileNo.size() != 0">
  915. and sd.water_meter_file_no in <foreach collection="fileNo" item="item" open="(" separator="," close=")">#{item}</foreach>
  916. </if>
  917. </select>
  918. </mapper>