EquipContainerMapper.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.start.tz.module.pressure.dal.mysql.equipcontainer.EquipContainerMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <!--
  11. AND rownum &gt;= #{startNum} and rownum &lt;= #{endNum}
  12. -->
  13. <select id="selectPlanPage">
  14. SELECT
  15. a.*,
  16. co.confirm_order_ids,
  17. co.confirm_order_count,
  18. pto.task_order_ids,
  19. pto.task_order_count,
  20. ROW_NUMBER() OVER (ORDER BY ${orderBy} ${orderByDesc}) AS rn
  21. FROM (
  22. SELECT
  23. ec.id,
  24. ec.equip_code,
  25. ec.unit_code,
  26. ec.unit_name,
  27. ec.unit_address,
  28. ec.equip_street,
  29. ec.equip_district,
  30. ec.CONTACT,
  31. ec.CONTACT_PHONE,
  32. ec.USE_REGISTER_NO,
  33. LISTAGG(
  34. CASE
  35. WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
  36. <if test="nextDate != null and nextDate.size()>= 2">
  37. AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  38. </if>
  39. THEN ec.id
  40. ELSE NULL
  41. END, ',' ON OVERFLOW TRUNCATE
  42. ) AS equip_ids,
  43. LISTAGG(
  44. CASE
  45. WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
  46. <if test="nextDate != null and nextDate.size()>= 2">
  47. AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  48. </if>
  49. THEN ec.id
  50. ELSE NULL
  51. END, ',' ON OVERFLOW TRUNCATE
  52. ) AS year_equip_ids,
  53. LISTAGG(
  54. CASE
  55. WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
  56. <if test="nextDate != null and nextDate.size()>= 2">
  57. AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  58. </if>
  59. THEN ec.id
  60. ELSE NULL
  61. END, ',' ON OVERFLOW TRUNCATE
  62. ) AS expired_equip_ids,
  63. SUM(
  64. CASE
  65. WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
  66. <if test="nextDate != null and nextDate.size()>= 2">
  67. AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  68. </if>
  69. THEN 1
  70. ELSE 0
  71. END
  72. ) AS count,
  73. SUM(
  74. CASE
  75. WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
  76. <if test="nextDate != null and nextDate.size()>= 2">
  77. AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  78. </if>
  79. THEN 1
  80. ELSE 0
  81. END
  82. ) AS year_count,
  83. SUM(
  84. CASE
  85. WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
  86. <if test="nextDate != null and nextDate.size()>= 2">
  87. AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  88. </if>
  89. THEN 1
  90. ELSE 0
  91. END
  92. ) AS expired_count,
  93. MIN(
  94. CASE
  95. WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
  96. <if test="nextDate != null and nextDate.size()>= 2">
  97. AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  98. </if>
  99. THEN ec.NEXT_CHECK_DATE
  100. ELSE NULL
  101. END
  102. ) AS next_check_date,
  103. MIN(
  104. CASE
  105. WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
  106. <if test="nextDate != null and nextDate.size()>= 2">
  107. AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  108. </if>
  109. THEN ec.NEXT_YEAR_CHECK_DATE
  110. ELSE NULL
  111. END
  112. ) AS next_year_check_date,
  113. MIN(
  114. CASE
  115. WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
  116. <if test="nextDate != null and nextDate.size()>= 2">
  117. AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  118. </if>
  119. THEN ec.NEXT_EXPIRED_CHECK_DATE
  120. ELSE NULL
  121. END
  122. ) AS next_expired_check_date
  123. FROM PRESSURE_EQUIP_CONTAINER ec
  124. <where>
  125. ec.deleted = 0 AND (ec.is_scheduling = 0 OR ec.IS_YEAR_SCHEDULING = 0 OR ec.IS_EXPIRED_SCHEDULING = 0)
  126. <if test="unitName != null and unitName != ''">
  127. AND ec.unit_name LIKE CONCAT('%',#{unitName},'%')
  128. </if>
  129. <if test="unitAddress != null and unitAddress != ''">
  130. AND ec.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  131. </if>
  132. <choose>
  133. <when test="scene != null and scene == 0">
  134. <if test="equipCode != null and equipCode != ''">
  135. AND ec.equip_code LIKE CONCAT('%',#{equipCode},'%')
  136. </if>
  137. </when>
  138. <otherwise>
  139. <if test="equipCode != null and equipCode != ''">
  140. AND ec.unit_code IN (SELECT unit_code FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
  141. AND ec.equip_street IN (SELECT equip_street FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
  142. </if>
  143. </otherwise>
  144. </choose>
  145. <if test="equipStreet != null and equipStreet.size() > 0">
  146. AND ec.equip_street IN
  147. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  148. #{listItem}
  149. </foreach>
  150. </if>
  151. <if test="equipDistrict != null and equipDistrict.size() > 0">
  152. AND ec.equip_district IN
  153. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  154. #{listItem}
  155. </foreach>
  156. </if>
  157. <if test="deptId != null and deptId != ''">
  158. AND ec.dept_id = #{deptId}
  159. </if>
  160. <if test="typeList != null and typeList.size() > 0">
  161. AND ec.equip_type IN
  162. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  163. #{listItem}
  164. </foreach>
  165. </if>
  166. <if test="nextDate != null and nextDate.size() >= 2">
  167. AND (
  168. (ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  169. OR (ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  170. OR (ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  171. )
  172. </if>
  173. <if test="unitCodesTrue != null and unitCodesTrue.size() > 0">
  174. AND ec.unit_code IN
  175. <foreach close=")" collection="unitCodesTrue" item="listItem" open="(" separator=",">
  176. #{listItem}
  177. </foreach>
  178. </if>
  179. <if test="unitCodesFalse != null and unitCodesFalse.size() > 0">
  180. AND ec.unit_code NOT IN
  181. <foreach close=")" collection="unitCodesFalse" item="listItem" open="(" separator=",">
  182. #{listItem}
  183. </foreach>
  184. </if>
  185. <if test="status != null and status.size() > 0">
  186. AND ec.status IN
  187. <foreach close=")" collection="status" item="listItem" open="(" separator=",">
  188. #{listItem}
  189. </foreach>
  190. </if>
  191. <if test="unitNames != null and unitNames.size() > 0">
  192. AND ec.UNIT_NAME IN
  193. <foreach close=")" collection="unitNames" item="unitNames" open="(" separator=",">
  194. #{unitNames}
  195. </foreach>
  196. </if>
  197. <if test="useRegisterNo != null and useRegisterNo != ''">
  198. AND ec.USE_REGISTER_NO LIKE CONCAT('%',#{useRegisterNo},'%')
  199. </if>
  200. </where>
  201. <!-- 关键修改:恢复原来的分组方式 -->
  202. <choose>
  203. <when test="scene != null and scene == 0">
  204. GROUP BY ec.unit_name
  205. </when>
  206. <otherwise>
  207. GROUP BY ec.unit_name, ec.equip_street, ec.CONTACT_PHONE
  208. </otherwise>
  209. </choose>
  210. ) a
  211. LEFT JOIN (
  212. SELECT
  213. unit_code,
  214. LISTAGG(
  215. CASE
  216. WHEN deleted = 0 AND status != 500 AND CREATE_ACCEPT_ORDER = 0 THEN id
  217. ELSE NULL
  218. END, ',' ON OVERFLOW TRUNCATE
  219. ) AS confirm_order_ids,
  220. COUNT(DISTINCT
  221. CASE
  222. WHEN deleted = 0 AND status != 500 AND CREATE_ACCEPT_ORDER = 0 THEN id
  223. ELSE NULL
  224. END
  225. ) AS confirm_order_count
  226. FROM PRESSURE_APPOINTMENT_CONFIRM_ORDER
  227. GROUP BY unit_code
  228. ) co ON co.unit_code = a.unit_code
  229. LEFT JOIN (
  230. SELECT
  231. unit_code,
  232. LISTAGG(
  233. CASE
  234. WHEN deleted = 0 AND TASK_STATUS != 800 THEN id
  235. ELSE NULL
  236. END, ',' ON OVERFLOW TRUNCATE
  237. ) AS task_order_ids,
  238. COUNT(DISTINCT
  239. CASE
  240. WHEN deleted = 0 AND TASK_STATUS != 800 THEN id
  241. ELSE NULL
  242. END
  243. ) AS task_order_count
  244. FROM PRESSURE_TASK_ORDER
  245. GROUP BY unit_code
  246. ) pto ON pto.unit_code = a.unit_code
  247. WHERE a.count > 0 OR a.year_count > 0 OR a.expired_count > 0
  248. ORDER BY ${orderBy} ${orderByDesc}
  249. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  250. </select>
  251. <select id="selectPlanCount">
  252. SELECT
  253. COUNT(1) unit_count,
  254. SUM(equip_count) equip_count
  255. FROM (
  256. SELECT
  257. ec.unit_code,
  258. COUNT(ec.equip_code) equip_count,
  259. SUM(
  260. CASE
  261. WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
  262. <if test="nextDate != null and nextDate.size()>= 2">
  263. AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  264. </if>
  265. THEN 1
  266. ELSE 0
  267. END
  268. ) count,
  269. SUM(
  270. CASE
  271. WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
  272. <if test="nextDate != null and nextDate.size()>= 2">
  273. AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  274. </if>
  275. THEN 1
  276. ELSE 0
  277. END
  278. ) year_count,
  279. SUM(
  280. CASE
  281. WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
  282. <if test="nextDate != null and nextDate.size()>= 2">
  283. AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  284. </if>
  285. THEN 1
  286. ELSE 0
  287. END
  288. ) expired_count
  289. FROM PRESSURE_EQUIP_CONTAINER ec
  290. <where>
  291. ec.deleted = 0 AND (ec.is_scheduling = 0 OR ec.IS_YEAR_SCHEDULING = 0 OR ec.IS_EXPIRED_SCHEDULING = 0)
  292. <if test="unitName != null and unitName != ''">
  293. AND ec.unit_name LIKE CONCAT('%',#{unitName},'%')
  294. </if>
  295. <if test="unitAddress != null and unitAddress != ''">
  296. AND ec.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  297. </if>
  298. <choose>
  299. <when test="scene != null and scene == 0">
  300. <if test="equipCode != null and equipCode != ''">
  301. AND ec.equip_code LIKE CONCAT('%',#{equipCode},'%')
  302. </if>
  303. </when>
  304. <otherwise>
  305. <if test="equipCode != null and equipCode != ''">
  306. AND ec.unit_code IN (SELECT unit_code FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
  307. AND ec.equip_street IN (SELECT equip_street FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
  308. </if>
  309. </otherwise>
  310. </choose>
  311. <if test="unitNames != null and unitNames.size() > 0">
  312. AND ec.UNIT_NAME IN
  313. <foreach close=")" collection="unitNames" item="unitNames" open="(" separator=",">
  314. #{unitNames}
  315. </foreach>
  316. </if>
  317. <if test="useRegisterNo != null and useRegisterNo != ''">
  318. AND ec.USE_REGISTER_NO LIKE CONCAT('%',#{useRegisterNo},'%')
  319. </if>
  320. <if test="equipStreet != null and equipStreet.size() > 0">
  321. AND ec.equip_street IN
  322. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  323. #{listItem}
  324. </foreach>
  325. </if>
  326. <if test="equipDistrict != null and equipDistrict.size() > 0">
  327. AND ec.equip_district IN
  328. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  329. #{listItem}
  330. </foreach>
  331. </if>
  332. <if test="deptId != null and deptId != ''">
  333. AND ec.dept_id = #{deptId}
  334. </if>
  335. <if test="typeList != null and typeList.size() > 0">
  336. AND ec.equip_type IN
  337. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  338. #{listItem}
  339. </foreach>
  340. </if>
  341. <if test="nextDate != null and nextDate.size() >= 2">
  342. AND (
  343. (ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  344. OR (ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  345. OR (ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  346. )
  347. </if>
  348. <if test="unitCodesTrue != null and unitCodesTrue.size() > 0">
  349. AND ec.unit_code IN
  350. <foreach close=")" collection="unitCodesTrue" item="listItem" open="(" separator=",">
  351. #{listItem}
  352. </foreach>
  353. </if>
  354. <if test="unitCodesFalse != null and unitCodesFalse.size() > 0">
  355. AND ec.unit_code NOT IN
  356. <foreach close=")" collection="unitCodesFalse" item="listItem" open="(" separator=",">
  357. #{listItem}
  358. </foreach>
  359. </if>
  360. <if test="status != null and status.size() > 0">
  361. AND ec.status IN
  362. <foreach close=")" collection="status" item="listItem" open="(" separator=",">
  363. #{listItem}
  364. </foreach>
  365. </if>
  366. </where>
  367. <!-- 使用与分页查询相同的分组方式 -->
  368. <choose>
  369. <when test="scene != null and scene == 0">
  370. GROUP BY ec.unit_name
  371. </when>
  372. <otherwise>
  373. GROUP BY ec.unit_name, ec.equip_street, ec.CONTACT_PHONE
  374. </otherwise>
  375. </choose>
  376. ) a
  377. WHERE a.count > 0 OR a.year_count > 0 OR a.expired_count > 0
  378. </select>
  379. <select id="selectPlanItemPage">
  380. select * from (select id,unit_code,unit_name,equip_code,unit_address,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  381. status,equip_name,equip_type,equip_category,use_register_no,equip_volume,product_no,safe_manager,safe_manager_phone,unit_id,
  382. (select a.id from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  383. left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  384. where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) check_task_id,
  385. (select a.id from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  386. left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  387. where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) year_check_task_id,
  388. (select a.id from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  389. left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  390. where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 300 limit 1) expired_check_task_id,
  391. (select a.PLAN_DATE from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  392. left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  393. where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) plan_check_date,
  394. (select a.PLAN_DATE from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  395. left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  396. where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) plan_year_check_date,
  397. (select a.PLAN_DATE from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  398. left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  399. where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 300 limit 1) plan_expired_check_date,
  400. (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
  401. <if test="nextDate != null and nextDate.size()>= 2">
  402. and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  403. </if>
  404. then 1 else 0 end) count,
  405. (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
  406. <if test="nextDate != null and nextDate.size()>= 2">
  407. and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  408. </if>
  409. then 1 else 0 end) year_count,
  410. (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
  411. <if test="nextDate != null and nextDate.size()>= 2">
  412. and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  413. </if>
  414. then 1 else 0 end) expired_count,
  415. NEXT_CHECK_DATE ,
  416. NEXT_YEAR_CHECK_DATE,
  417. NEXT_EXPIRED_CHECK_DATE
  418. from PRESSURE_EQUIP_CONTAINER eq
  419. <where>
  420. deleted = 0
  421. <if test="unitName != null">
  422. and unit_name like concat('%',#{unitName},'%')
  423. </if>
  424. <if test="unitCode != null">
  425. and unit_code = #{unitCode}
  426. </if>
  427. <if test="unitAddress != null">
  428. and unit_address like concat('%',#{unitAddress},'%')
  429. </if>
  430. <choose>
  431. <when test="scene != null and scene == 0">
  432. <if test="equipCode != null and equipCode != ''">
  433. and equip_code like concat('%',#{equipCode},'%')
  434. </if>
  435. </when>
  436. <otherwise>
  437. <if test="equipCode != null and equipCode != ''">
  438. and unit_code in ( select unit_code from PRESSURE_EQUIP_CONTAINER where equip_code =#{equipCode} limit 1)
  439. </if>
  440. </otherwise>
  441. </choose>
  442. <if test="equipStreet != null and equipStreet.size() > 0">
  443. and equip_street in
  444. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  445. #{listItem}
  446. </foreach>
  447. </if>
  448. <if test="productNo != null and productNo != ''">
  449. and product_no like concat('%',#{productNo},'%')
  450. </if>
  451. <if test="equipDistrict != null and equipDistrict.size() > 0">
  452. and equip_district in
  453. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  454. #{listItem}
  455. </foreach>
  456. </if>
  457. <if test="deptId">
  458. and dept_id = #{deptId}
  459. </if>
  460. <if test="typeList != null and typeList.size() > 0 ">
  461. and equip_type in
  462. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  463. #{listItem}
  464. </foreach>
  465. </if>
  466. <if test="nextDate != null and nextDate.size()>= 2">
  467. and ((NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
  468. (NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
  469. (NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}))
  470. </if>
  471. <if test="status != null and status.size() > 0 ">
  472. and status in
  473. <foreach close=")" collection="status" item="listItem" open="(" separator=",">
  474. #{listItem}
  475. </foreach>
  476. </if>
  477. <if test="equipIds != null and equipIds.size() > 0 ">
  478. and id in
  479. <foreach close=")" collection="equipIds" item="listItem" open="(" separator=",">
  480. #{listItem}
  481. </foreach>
  482. </if>
  483. <if test="notEquipIds != null and notEquipIds.size() > 0 ">
  484. and id not in
  485. <foreach close=")" collection="notEquipIds" item="listItem" open="(" separator=",">
  486. #{listItem}
  487. </foreach>
  488. </if>
  489. <if test="unitIds != null and unitIds.size() > 0 ">
  490. and unit_id in
  491. <foreach close=")" collection="unitIds" item="listItem" open="(" separator=",">
  492. #{listItem}
  493. </foreach>
  494. </if>
  495. </where>
  496. <choose>
  497. <when test="scene != null and scene == 1">
  498. order by unit_code
  499. </when>
  500. </choose>
  501. ) a
  502. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  503. </select>
  504. <select id="selectPlanItemCount">
  505. select count(equip_code) from (select unit_code,unit_name,equip_code,unit_address,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  506. status,equip_name,equip_type,equip_category,use_register_no,equip_volume,product_no,safe_manager,safe_manager_phone,
  507. (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
  508. <if test="nextDate != null and nextDate.size()>= 2">
  509. and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  510. </if>
  511. then 1 else 0 end) count,
  512. (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
  513. <if test="nextDate != null and nextDate.size()>= 2">
  514. and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  515. </if>
  516. then 1 else 0 end) year_count,
  517. (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
  518. <if test="nextDate != null and nextDate.size()>= 2">
  519. and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  520. </if>
  521. then 1 else 0 end) expired_count,
  522. (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
  523. <if test="nextDate != null and nextDate.size()>= 2">
  524. and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  525. </if>
  526. then NEXT_CHECK_DATE else null end) next_check_date,
  527. (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
  528. <if test="nextDate != null and nextDate.size()>= 2">
  529. and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  530. </if>
  531. then NEXT_YEAR_CHECK_DATE else null end) next_year_check_date,
  532. (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
  533. <if test="nextDate != null and nextDate.size()>= 2">
  534. and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  535. </if>
  536. then NEXT_EXPIRED_CHECK_DATE else null end) next_expired_check_date
  537. from PRESSURE_EQUIP_CONTAINER eq
  538. <where>
  539. deleted = 0
  540. <if test="unitName != null">
  541. and unit_name like concat('%',#{unitName},'%')
  542. </if>
  543. <if test="unitCode != null">
  544. and unit_code = #{unitCode}
  545. </if>
  546. <if test="unitAddress != null">
  547. and unit_address like concat('%',#{unitAddress},'%')
  548. </if>
  549. <choose>
  550. <when test="scene != null and scene == 0">
  551. <if test="equipCode != null and equipCode != ''">
  552. and equip_code like concat('%',#{equipCode},'%')
  553. </if>
  554. </when>
  555. <otherwise>
  556. <if test="equipCode != null and equipCode != ''">
  557. and unit_code in ( select unit_code from PRESSURE_EQUIP_CONTAINER where equip_code =#{equipCode} limit 1)
  558. </if>
  559. </otherwise>
  560. </choose>
  561. <if test="equipStreet != null and equipStreet.size() > 0">
  562. and equip_street in
  563. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  564. #{listItem}
  565. </foreach>
  566. </if>
  567. <if test="equipDistrict != null and equipDistrict.size() > 0">
  568. and equip_district in
  569. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  570. #{listItem}
  571. </foreach>
  572. </if>
  573. <if test="productNo != null and productNo != ''">
  574. and product_no like concat('%',#{productNo},'%')
  575. </if>
  576. <if test="deptId">
  577. and dept_id = #{deptId}
  578. </if>
  579. <if test="typeList != null and typeList.size() > 0 ">
  580. and equip_type in
  581. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  582. #{listItem}
  583. </foreach>
  584. </if>
  585. <if test="nextDate != null and nextDate.size()>= 2">
  586. and ((NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
  587. (NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
  588. (NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}))
  589. </if>
  590. <if test="status != null and status.size() > 0 ">
  591. and status in
  592. <foreach close=")" collection="status" item="listItem" open="(" separator=",">
  593. #{listItem}
  594. </foreach>
  595. </if>
  596. <if test="equipIds != null and equipIds.size() > 0 ">
  597. and id in
  598. <foreach close=")" collection="equipIds" item="listItem" open="(" separator=",">
  599. #{listItem}
  600. </foreach>
  601. </if>
  602. <if test="notEquipIds != null and notEquipIds.size() > 0 ">
  603. and id not in
  604. <foreach close=")" collection="notEquipIds" item="listItem" open="(" separator=",">
  605. #{listItem}
  606. </foreach>
  607. </if>
  608. <if test="unitIds != null and unitIds.size() > 0 ">
  609. and unit_id in
  610. <foreach close=")" collection="unitIds" item="listItem" open="(" separator=",">
  611. #{listItem}
  612. </foreach>
  613. </if>
  614. </where>
  615. <choose>
  616. <when test="scene != null and scene == 1">
  617. order by unit_code
  618. </when>
  619. </choose>
  620. ) a
  621. </select>
  622. <select id="selectPlanCalendar">
  623. select a.ID task_id,a.TYPE check_type,b.unit_code,b.unit_name,b.unit_address,a.plan_date,count(distinct c.ID) equip_count,
  624. b.equip_district,b.equip_street,FIRST_VALUE(b.lng) lng,FIRST_VALUE(b.lat) lat, a.source,
  625. e.id APPOINTMENT_ID,f.id ACCEPT_ORDER_ID,f.STATUS accept_status, g.TASK_STATUS
  626. from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
  627. inner join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM c on c.SCHEDULING_ID = a.ID and c.DELETED = 0
  628. inner join PRESSURE_EQUIP_CONTAINER b on b.ID = c.equip_id and b.DELETED = 0
  629. inner join PRESSURE_EQUIP_CONTAINER_SCHEDULING_USER d on d.SCHEDULING_ID = a.ID and d.DELETED = 0
  630. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER e on e.SCHEDULING_ID = a.ID
  631. left join PRESSURE_ACCEPT_ORDER f on f.APPOINTMENT_ID = e.ID
  632. left join PRESSURE_Task_ORDER g on g.ACCEPT_ORDER_ID = f.ID
  633. <where>
  634. a.DELETED = 0
  635. <if test="planDate != null and planDate.size() >= 2">
  636. and a.plan_date between #{planDate[0]} and #{planDate[1]}
  637. </if>
  638. <if test="userId != null and userId != ''">
  639. and a.CREATOR = #{userId}
  640. </if>
  641. <if test="deptId != null and deptId != ''">
  642. and b.dept_id = #{deptId}
  643. </if>
  644. </where>
  645. group by b.unit_code,a.plan_date,a.type
  646. order by b.unit_code
  647. </select>
  648. <select id="selectAppointmentItemPage">
  649. select * from (select id,unit_code,unit_name,equip_code,unit_address,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  650. status,equip_name,equip_type,equip_category,use_register_no,equip_volume,product_no,safe_manager,safe_manager_phone,
  651. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  652. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  653. where b.EQUIP_ID = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) plan_check_date,
  654. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  655. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  656. where b.EQUIP_ID = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) plan_year_check_date,
  657. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  658. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  659. where b.EQUIP_ID = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 300 limit 1) plan_expired_check_date,
  660. (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
  661. <if test="nextDate != null and nextDate.size()>= 2">
  662. and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  663. </if>
  664. then 1 else 0 end) count,
  665. (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
  666. <if test="nextDate != null and nextDate.size()>= 2">
  667. and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  668. </if>
  669. then 1 else 0 end) year_count,
  670. (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
  671. <if test="nextDate != null and nextDate.size()>= 2">
  672. and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
  673. </if>
  674. then 1 else 0 end) expired_count,
  675. NEXT_CHECK_DATE ,
  676. NEXT_YEAR_CHECK_DATE,
  677. NEXT_EXPIRED_CHECK_DATE
  678. from PRESSURE_EQUIP_CONTAINER eq
  679. <where>
  680. deleted = 0
  681. <if test="unitName != null">
  682. and unit_name like concat('%',#{unitName},'%')
  683. </if>
  684. <if test="unitCode != null">
  685. and unit_code = #{unitCode}
  686. </if>
  687. <if test="unitAddress != null">
  688. and unit_address like concat('%',#{unitAddress},'%')
  689. </if>
  690. <if test="equipCode != null">
  691. and unit_code in ( select unit_code from PRESSURE_EQUIP_CONTAINER where equip_code =#{equipCode} limit 1)
  692. </if>
  693. <if test="equipStreet != null and equipStreet.size() > 0">
  694. and equip_street in
  695. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  696. #{listItem}
  697. </foreach>
  698. </if>
  699. <if test="equipDistrict != null and equipDistrict.size() > 0">
  700. and equip_district in
  701. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  702. #{listItem}
  703. </foreach>
  704. </if>
  705. <if test="productNo != null and productNo != ''">
  706. and product_no like concat('%',#{productNo},'%')
  707. </if>
  708. <if test="deptId">
  709. and dept_id = #{deptId}
  710. </if>
  711. <if test="typeList != null and typeList.size() > 0 ">
  712. and equip_type in
  713. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  714. #{listItem}
  715. </foreach>
  716. </if>
  717. <if test="nextDate != null and nextDate.size()>= 2">
  718. and ((NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
  719. (NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
  720. (NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}))
  721. </if>
  722. <if test="status != null and status.size() > 0 ">
  723. and status in
  724. <foreach close=")" collection="status" item="listItem" open="(" separator=",">
  725. #{listItem}
  726. </foreach>
  727. </if>
  728. <if test="equipIds != null and equipIds.size() > 0 ">
  729. and id in
  730. <foreach close=")" collection="equipIds" item="listItem" open="(" separator=",">
  731. #{listItem}
  732. </foreach>
  733. </if>
  734. <if test="notEquipIds != null and notEquipIds.size() > 0 ">
  735. and id not in
  736. <foreach close=")" collection="notEquipIds" item="listItem" open="(" separator=",">
  737. #{listItem}
  738. </foreach>
  739. </if>
  740. </where>
  741. ) a
  742. order by unit_code
  743. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  744. </select>
  745. </mapper>