EquipPipeMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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.pressure2.dal.mysql.equippipe.EquipPipeMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectAppointmentItemPage"
  11. resultType="cn.start.tz.module.pressure2.controller.admin.appointmentconfirmorder.vo.PipeAppointmentEquipsPageRespVO">
  12. select rownum,a.* from (
  13. select
  14. eb.id,
  15. eb.unit_code,
  16. eb.unit_name,
  17. eb.equip_street,
  18. eb.equip_district ,
  19. eb.CONTACT ,
  20. eb.CONTACT_PHONE ,
  21. eb.PROJECT_NAME ,
  22. eb.PROJECT_NO ,
  23. eb.PIPE_CATEGORY ,
  24. eb.NEXT_LEGAL_CHECK_DATE,
  25. eb.NEXT_YEAR_CHECK_DATE,
  26. eb.USE_STATUS as status,
  27. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  28. left join PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  29. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) as planLegalCheckDate,
  30. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  31. left join PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  32. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) as planYearCheckDate
  33. from PRESSURE2_EQUIP_PIPE eb
  34. <where>
  35. eb.deleted = 0
  36. <if test="unitName != null and unitName != ''">
  37. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  38. </if>
  39. <if test="unitCode != null and unitCode != ''">
  40. and eb.unit_code = #{unitCode}
  41. </if>
  42. <if test="unitAddress != null and unitAddress != ''">
  43. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  44. </if>
  45. <if test="relateDepartment != null and relateDepartment != ''">
  46. AND eb.RELATION_DEPT = #{relateDepartment}
  47. </if>
  48. <if test="equipStreet != null and equipStreet.size() > 0">
  49. AND eb.equip_street IN
  50. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  51. #{listItem}
  52. </foreach>
  53. </if>
  54. <if test="equipDistrict != null and equipDistrict.size() > 0">
  55. AND eb.equip_district IN
  56. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  57. #{listItem}
  58. </foreach>
  59. </if>
  60. <if test="nextDate != null and nextDate.size() >= 2">
  61. AND (
  62. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  63. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  64. )
  65. </if>
  66. <if test="typeList != null and typeList.size() > 0">
  67. AND eb.PIPE_CATEGORY IN
  68. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  69. #{listItem}
  70. </foreach>
  71. </if>
  72. <if test="useStatus != null and useStatus.size() > 0">
  73. AND eb.USE_STATUS IN
  74. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  75. #{listItem}
  76. </foreach>
  77. </if>
  78. <if test="orderId != null and orderId != ''">
  79. AND eb.ID IN (
  80. select EQUIP_ID from PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  81. )
  82. </if>
  83. <if test="notOrderId != null and notOrderId != ''">
  84. AND eb.ID NOT IN (
  85. select EQUIP_ID from PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  86. )
  87. </if>
  88. </where>
  89. ) a
  90. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  91. </select>
  92. <select id="selectAppointmentItemPageCount">
  93. select COUNT(*) from (
  94. select
  95. eb.id
  96. from PRESSURE2_EQUIP_PIPE eb
  97. <where>
  98. eb.deleted = 0
  99. <if test="unitName != null and unitName != ''">
  100. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  101. </if>
  102. <if test="unitCode != null and unitCode != ''">
  103. and eb.unit_code = #{unitCode}
  104. </if>
  105. <if test="unitAddress != null and unitAddress != ''">
  106. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  107. </if>
  108. <if test="relateDepartment != null and relateDepartment != ''">
  109. AND eb.RELATION_DEPT = #{relateDepartment}
  110. </if>
  111. <if test="equipStreet != null and equipStreet.size() > 0">
  112. AND eb.equip_street IN
  113. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  114. #{listItem}
  115. </foreach>
  116. </if>
  117. <if test="equipDistrict != null and equipDistrict.size() > 0">
  118. AND eb.equip_district IN
  119. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  120. #{listItem}
  121. </foreach>
  122. </if>
  123. <if test="nextDate != null and nextDate.size() >= 2">
  124. AND (
  125. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  126. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  127. )
  128. </if>
  129. <if test="typeList != null and typeList.size() > 0">
  130. AND eb.PIPE_CATEGORY IN
  131. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  132. #{listItem}
  133. </foreach>
  134. </if>
  135. <if test="useStatus != null and useStatus.size() > 0">
  136. AND eb.USE_STATUS IN
  137. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  138. #{listItem}
  139. </foreach>
  140. </if>
  141. <if test="orderId != null and orderId != ''">
  142. AND eb.ID IN (
  143. select EQUIP_ID from PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  144. )
  145. </if>
  146. <if test="notOrderId != null and notOrderId != ''">
  147. AND eb.ID NOT IN (
  148. select EQUIP_ID from PRESSURE2_PIPE_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  149. )
  150. </if>
  151. </where>
  152. ) a
  153. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  154. </select>
  155. <select id="selectAcceptItemPage">
  156. select rownum,a.* from (
  157. select
  158. eb.id,
  159. eb.unit_code,
  160. eb.unit_name,
  161. eb.equip_street,
  162. eb.equip_district ,
  163. eb.CONTACT ,
  164. eb.CONTACT_PHONE ,
  165. eb.PROJECT_NAME ,
  166. eb.PROJECT_NO ,
  167. eb.PIPE_CATEGORY ,
  168. eb.NEXT_LEGAL_CHECK_DATE,
  169. eb.NEXT_YEAR_CHECK_DATE,
  170. eb.USE_STATUS as status,
  171. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  172. left join PRESSURE2_PIPE_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  173. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) as
  174. planLegalCheckDate,
  175. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  176. left join PRESSURE2_PIPE_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  177. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) as
  178. planYearCheckDate
  179. from PRESSURE2_EQUIP_PIPE eb
  180. <where>
  181. eb.deleted = 0
  182. <if test="unitName != null and unitName != ''">
  183. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  184. </if>
  185. <if test="unitCode != null and unitCode != ''">
  186. and eb.unit_code = #{unitCode}
  187. </if>
  188. <if test="unitAddress != null and unitAddress != ''">
  189. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  190. </if>
  191. <if test="equipCode != null and equipCode != ''">
  192. AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
  193. </if>
  194. <if test="deptId != null and deptId != ''">
  195. AND eb.RELATION_DEPT = #{deptId}
  196. </if>
  197. <if test="equipStreet != null and equipStreet.size() > 0">
  198. AND eb.equip_street IN
  199. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  200. #{listItem}
  201. </foreach>
  202. </if>
  203. <if test="equipDistrict != null and equipDistrict.size() > 0">
  204. AND eb.equip_district IN
  205. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  206. #{listItem}
  207. </foreach>
  208. </if>
  209. <if test="nextDate != null and nextDate.size() >= 2">
  210. AND (
  211. (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  212. OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  213. OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  214. )
  215. </if>
  216. <if test="typeList != null and typeList.size() > 0">
  217. AND eb.PIPE_CATEGORY IN
  218. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  219. #{listItem}
  220. </foreach>
  221. </if>
  222. <if test="orderId != null and orderId != ''">
  223. AND eb.ID IN (
  224. select EQUIP_ID from PRESSURE2_PIPE_ACCEPT_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  225. )
  226. </if>
  227. <if test="notOrderId != null and notOrderId != ''">
  228. AND eb.ID NOT IN (
  229. select EQUIP_ID from PRESSURE2_PIPE_ACCEPT_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  230. )
  231. </if>
  232. <if test="factoryCode != null and factoryCode != ''">
  233. AND eb.FACTORY_CODE like CONCAT('%',#{factoryCode},'%')
  234. </if>
  235. <if test="useStatus != null and useStatus.size() > 0">
  236. AND eb.USE_STATUS IN
  237. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  238. #{listItem}
  239. </foreach>
  240. </if>
  241. </where>
  242. ) a
  243. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  244. </select>
  245. <select id="selectAcceptItemPageCount">
  246. select count(1) from (
  247. select id
  248. from PRESSURE2_EQUIP_PIPE eb
  249. <where>
  250. eb.deleted = 0
  251. <if test="unitName != null and unitName != ''">
  252. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  253. </if>
  254. <if test="unitCode != null and unitCode != ''">
  255. and eb.unit_code = #{unitCode}
  256. </if>
  257. <if test="unitAddress != null and unitAddress != ''">
  258. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  259. </if>
  260. <if test="equipCode != null and equipCode != ''">
  261. AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
  262. </if>
  263. <if test="deptId != null and deptId != ''">
  264. AND eb.RELATION_DEPT = #{deptId}
  265. </if>
  266. <if test="equipStreet != null and equipStreet.size() > 0">
  267. AND eb.equip_street IN
  268. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  269. #{listItem}
  270. </foreach>
  271. </if>
  272. <if test="equipDistrict != null and equipDistrict.size() > 0">
  273. AND eb.equip_district IN
  274. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  275. #{listItem}
  276. </foreach>
  277. </if>
  278. <if test="nextDate != null and nextDate.size() >= 2">
  279. AND (
  280. (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  281. OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  282. OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  283. )
  284. </if>
  285. <if test="typeList != null and typeList.size() > 0">
  286. AND eb.PIPE_CATEGORY IN
  287. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  288. #{listItem}
  289. </foreach>
  290. </if>
  291. <if test="orderId != null and orderId != ''">
  292. AND eb.ID IN (
  293. select EQUIP_ID from PRESSURE2_PIPE_ACCEPT_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  294. )
  295. </if>
  296. <if test="notOrderId != null and notOrderId != ''">
  297. AND eb.ID NOT IN (
  298. select EQUIP_ID from PRESSURE2_PIPE_ACCEPT_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  299. )
  300. </if>
  301. <if test="useStatus != null and useStatus.size() > 0">
  302. AND eb.USE_STATUS IN
  303. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  304. #{listItem}
  305. </foreach>
  306. </if>
  307. </where>
  308. ) a
  309. </select>
  310. <select id="selectPendingInspectionPipePage"
  311. resultType="cn.start.tz.module.pressure2.controller.admin.planscheduling.vo.EquipPipePageRespVO">
  312. SELECT
  313. ep.id,
  314. ep.unit_code,
  315. ep.unit_id,
  316. ep.unit_name,
  317. ep.unit_address,
  318. ep.equip_district,
  319. ep.equip_street,
  320. ep.use_status as status,
  321. ep.project_no as equip_code,
  322. ep.project_name as equip_name,
  323. ep.certificate_no as use_register_no,
  324. ep.contact,
  325. ep.contact_phone,
  326. ep.relation_dept as dept_id,
  327. ep.use_date,
  328. ep.pipe_address as equip_address,
  329. ep.pipe_category as equip_type,
  330. ep.next_legal_check_date as next_check_date,
  331. ep.next_year_check_date as next_year_check_date,
  332. ep.pipe_length_total as equip_volume,
  333. lto.task_order_id,
  334. lto.task_status,
  335. CASE WHEN lrfi.refuse_id IS NOT NULL OR lyrfi.refuse_id IS NOT NULL THEN 1 ELSE 0 END AS is_refused,
  336. COALESCE(lrfi.check_type, lyrfi.check_type, 100) AS refuse_type,
  337. CASE
  338. WHEN lrfi.refuse_id IS NOT NULL THEN
  339. CASE
  340. WHEN lrfi.is_submit = 0 THEN 100
  341. WHEN lrfi.is_submit = 1 AND lrfi.status = 100 THEN 200
  342. WHEN lrfi.is_submit = 1 AND lrfi.status = 200 THEN 300
  343. WHEN lrfi.is_submit = 1 AND lrfi.status = 300 THEN 300
  344. ELSE 100
  345. END
  346. WHEN lyrfi.refuse_id IS NOT NULL THEN
  347. CASE
  348. WHEN lyrfi.report_city_status = 100 THEN 100
  349. WHEN lyrfi.report_city_status = 200 AND lyrfi.status = 200 THEN 300
  350. ELSE 100
  351. END
  352. ELSE NULL
  353. END AS refuse_status,
  354. #{checkType} AS check_type,
  355. CASE
  356. WHEN #{checkType} = 100 THEN '定期检验'
  357. WHEN #{checkType} = 200 THEN '年度检查'
  358. END AS check_type_str
  359. FROM PRESSURE2_EQUIP_PIPE ep
  360. LEFT JOIN (
  361. SELECT
  362. toi.equip_id,
  363. to1.id AS task_order_id,
  364. to1.task_status,
  365. ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
  366. FROM PRESSURE2_PIPE_TASK_ORDER_ITEM toi
  367. INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
  368. WHERE to1.deleted = 0
  369. AND toi.deleted = 0
  370. AND to1.check_type = #{checkType}
  371. ) lto ON lto.equip_id = ep.id AND lto.rn = 1
  372. LEFT JOIN (
  373. SELECT
  374. roi.id AS refuse_id,
  375. roi.equip_id,
  376. roi.check_type,
  377. roi.is_submit,
  378. roi.status,
  379. roi.report_city_status,
  380. ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
  381. FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
  382. WHERE roi.deleted = 0
  383. AND roi.check_type = #{checkType}
  384. ) lrfi ON lrfi.equip_id = ep.id AND lrfi.rn = 1
  385. LEFT JOIN (
  386. SELECT
  387. ryi.id AS refuse_id,
  388. ryi.equip_id,
  389. 200 AS check_type,
  390. ryi.report_city_status,
  391. ryi.status,
  392. ROW_NUMBER() OVER (PARTITION BY ryi.equip_id ORDER BY ryi.create_time DESC) AS rn
  393. FROM PRESSURE2_APPOINTMENT_CONFIRM_REFUSE_YEAR_ITEM ryi
  394. WHERE ryi.deleted = 0
  395. ) lyrfi ON lyrfi.equip_id = ep.id AND lyrfi.rn = 1
  396. <where>
  397. ep.deleted = 0
  398. AND ep.is_effective != '否'
  399. <choose>
  400. <when test="checkType == 100">
  401. AND (
  402. ep.next_legal_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  403. <if test="showNoCheckDate != null and showNoCheckDate">
  404. OR ep.next_legal_check_date IS NULL
  405. </if>
  406. )
  407. </when>
  408. <when test="checkType == 200">
  409. AND (
  410. ep.next_year_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  411. <if test="showNoCheckDate != null and showNoCheckDate">
  412. OR ep.next_year_check_date IS NULL
  413. </if>
  414. )
  415. </when>
  416. </choose>
  417. AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
  418. AND NOT (
  419. lrfi.refuse_id IS NOT NULL
  420. AND lrfi.is_submit = 1
  421. AND lrfi.status = 200
  422. AND lrfi.report_city_status = 200
  423. AND lrfi.check_type = #{checkType}
  424. )
  425. <if test="checkType == 200">
  426. AND NOT (
  427. lyrfi.refuse_id IS NOT NULL
  428. AND lyrfi.report_city_status = 200
  429. AND lyrfi.status = 200
  430. )
  431. </if>
  432. <if test="ids != null and ids.size() > 0">
  433. AND ep.id IN
  434. <foreach collection="ids" item="id" open="(" separator="," close=")">
  435. #{id}
  436. </foreach>
  437. </if>
  438. <if test="productNo != null and productNo != ''">
  439. AND ep.project_no LIKE CONCAT('%', #{productNo}, '%')
  440. </if>
  441. <if test="contactPhone != null and contactPhone != ''">
  442. AND ep.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
  443. </if>
  444. <if test="unitCode != null and unitCode != ''">
  445. AND ep.unit_code = #{unitCode}
  446. </if>
  447. <if test="unitId != null and unitId != ''">
  448. AND ep.unit_id = #{unitId}
  449. </if>
  450. <if test="unitName != null and unitName != ''">
  451. AND ep.unit_name LIKE CONCAT('%', #{unitName}, '%')
  452. </if>
  453. <if test="equipDistrict != null">
  454. AND ep.equip_district = #{equipDistrict}
  455. </if>
  456. <if test="equipDistricts != null and equipDistricts.size() > 0">
  457. AND ep.equip_district IN
  458. <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
  459. #{district}
  460. </foreach>
  461. </if>
  462. <if test="showNoDistrict == null or !showNoDistrict">
  463. AND ep.equip_district IS NOT NULL
  464. </if>
  465. <if test="equipStreet != null">
  466. AND ep.equip_street = #{equipStreet}
  467. </if>
  468. <if test="status != null and status != ''">
  469. AND ep.use_status = #{status}
  470. </if>
  471. <if test="statusList != null and statusList.size() > 0">
  472. AND ep.use_status IN
  473. <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
  474. #{listItem}
  475. </foreach>
  476. </if>
  477. <if test="equipCode != null and equipCode != ''">
  478. AND ep.project_no LIKE CONCAT('%', #{equipCode}, '%')
  479. </if>
  480. <if test="equipType != null and equipType != ''">
  481. AND ep.pipe_category = #{equipType}
  482. </if>
  483. <if test="equipTypeList != null and equipTypeList.size() > 0">
  484. AND ep.pipe_category IN
  485. <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
  486. #{listItem}
  487. </foreach>
  488. </if>
  489. <if test="useRegisterNo != null and useRegisterNo != ''">
  490. AND ep.certificate_no LIKE CONCAT('%', #{useRegisterNo}, '%')
  491. </if>
  492. <if test="deptId != null and deptId != ''">
  493. AND ep.relation_dept = #{deptId}
  494. </if>
  495. <if test="isRefused != null">
  496. <choose>
  497. <when test="isRefused">
  498. AND (lrfi.refuse_id IS NOT NULL OR lyrfi.refuse_id IS NOT NULL)
  499. </when>
  500. <otherwise>
  501. AND (lrfi.refuse_id IS NULL AND lyrfi.refuse_id IS NULL)
  502. </otherwise>
  503. </choose>
  504. </if>
  505. </where>
  506. ORDER BY
  507. CASE #{checkType}
  508. WHEN 100 THEN ep.next_legal_check_date
  509. WHEN 200 THEN ep.next_year_check_date
  510. END ASC NULLS LAST
  511. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  512. </select>
  513. <select id="selectPendingInspectionPipeCount" resultType="java.lang.Long">
  514. SELECT COUNT(1)
  515. FROM PRESSURE2_EQUIP_PIPE ep
  516. LEFT JOIN (
  517. SELECT
  518. toi.equip_id,
  519. to1.id AS task_order_id,
  520. to1.task_status,
  521. ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
  522. FROM PRESSURE2_PIPE_TASK_ORDER_ITEM toi
  523. INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
  524. WHERE to1.deleted = 0
  525. AND toi.deleted = 0
  526. AND to1.check_type = #{checkType}
  527. ) lto ON lto.equip_id = ep.id AND lto.rn = 1
  528. LEFT JOIN (
  529. SELECT
  530. roi.id AS refuse_id,
  531. roi.equip_id,
  532. roi.check_type,
  533. roi.is_submit,
  534. roi.status,
  535. roi.report_city_status,
  536. ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
  537. FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
  538. WHERE roi.deleted = 0
  539. AND roi.check_type = #{checkType}
  540. ) lrfi ON lrfi.equip_id = ep.id AND lrfi.rn = 1
  541. LEFT JOIN (
  542. SELECT
  543. ryi.id AS refuse_id,
  544. ryi.equip_id,
  545. 200 AS check_type,
  546. ryi.report_city_status,
  547. ryi.status,
  548. ROW_NUMBER() OVER (PARTITION BY ryi.equip_id ORDER BY ryi.create_time DESC) AS rn
  549. FROM PRESSURE2_APPOINTMENT_CONFIRM_REFUSE_YEAR_ITEM ryi
  550. WHERE ryi.deleted = 0
  551. ) lyrfi ON lyrfi.equip_id = ep.id AND lyrfi.rn = 1
  552. <where>
  553. ep.deleted = 0
  554. AND ep.is_effective != '否'
  555. <choose>
  556. <when test="checkType == 100">
  557. AND (
  558. ep.next_legal_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  559. <if test="showNoCheckDate != null and showNoCheckDate">
  560. OR ep.next_legal_check_date IS NULL
  561. </if>
  562. )
  563. </when>
  564. <when test="checkType == 200">
  565. AND (
  566. ep.next_year_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  567. <if test="showNoCheckDate != null and showNoCheckDate">
  568. OR ep.next_year_check_date IS NULL
  569. </if>
  570. )
  571. </when>
  572. </choose>
  573. AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
  574. AND NOT (
  575. lrfi.refuse_id IS NOT NULL
  576. AND lrfi.is_submit = 1
  577. AND lrfi.status = 200
  578. AND lrfi.report_city_status = 200
  579. AND lrfi.check_type = #{checkType}
  580. )
  581. <if test="checkType == 200">
  582. AND NOT (
  583. lyrfi.refuse_id IS NOT NULL
  584. AND lyrfi.report_city_status = 200
  585. AND lyrfi.status = 200
  586. )
  587. </if>
  588. <if test="ids != null and ids.size() > 0">
  589. AND ep.id IN
  590. <foreach collection="ids" item="id" open="(" separator="," close=")">
  591. #{id}
  592. </foreach>
  593. </if>
  594. <if test="productNo != null and productNo != ''">
  595. AND ep.project_no LIKE CONCAT('%', #{productNo}, '%')
  596. </if>
  597. <if test="contactPhone != null and contactPhone != ''">
  598. AND ep.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
  599. </if>
  600. <if test="unitCode != null and unitCode != ''">
  601. AND ep.unit_code = #{unitCode}
  602. </if>
  603. <if test="unitId != null and unitId != ''">
  604. AND ep.unit_id = #{unitId}
  605. </if>
  606. <if test="unitName != null and unitName != ''">
  607. AND ep.unit_name LIKE CONCAT('%', #{unitName}, '%')
  608. </if>
  609. <if test="equipDistrict != null">
  610. AND ep.equip_district = #{equipDistrict}
  611. </if>
  612. <if test="equipDistricts != null and equipDistricts.size() > 0">
  613. AND ep.equip_district IN
  614. <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
  615. #{district}
  616. </foreach>
  617. </if>
  618. <if test="showNoDistrict == null or !showNoDistrict">
  619. AND ep.equip_district IS NOT NULL
  620. </if>
  621. <if test="equipStreet != null">
  622. AND ep.equip_street = #{equipStreet}
  623. </if>
  624. <if test="status != null and status != ''">
  625. AND ep.use_status = #{status}
  626. </if>
  627. <if test="statusList != null and statusList.size() > 0">
  628. AND ep.use_status IN
  629. <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
  630. #{listItem}
  631. </foreach>
  632. </if>
  633. <if test="equipCode != null and equipCode != ''">
  634. AND ep.project_no LIKE CONCAT('%', #{equipCode}, '%')
  635. </if>
  636. <if test="equipType != null and equipType != ''">
  637. AND ep.pipe_category = #{equipType}
  638. </if>
  639. <if test="equipTypeList != null and equipTypeList.size() > 0">
  640. AND ep.pipe_category IN
  641. <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
  642. #{listItem}
  643. </foreach>
  644. </if>
  645. <if test="useRegisterNo != null and useRegisterNo != ''">
  646. AND ep.certificate_no LIKE CONCAT('%', #{useRegisterNo}, '%')
  647. </if>
  648. <if test="deptId != null and deptId != ''">
  649. AND ep.relation_dept = #{deptId}
  650. </if>
  651. <if test="isRefused != null">
  652. <choose>
  653. <when test="isRefused">
  654. AND (lrfi.refuse_id IS NOT NULL OR lyrfi.refuse_id IS NOT NULL)
  655. </when>
  656. <otherwise>
  657. AND (lrfi.refuse_id IS NULL AND lyrfi.refuse_id IS NULL)
  658. </otherwise>
  659. </choose>
  660. </if>
  661. </where>
  662. </select>
  663. </mapper>