EquipPipeSchedulingMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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.equippipescheduling.EquipPipeSchedulingMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectPlanPage">
  11. select rownum,a.* from (
  12. select eb.EQUIP_DISTRICT,eb.EQUIP_STREET,eb.UNIT_CODE,eb.UNIT_NAME
  13. ,eb.PIPE_ADDRESS,eb.CONTACT,eb.CONTACT_PHONE,eb.UNIT_ID
  14. ,min(eb.id) as id
  15. ,LISTAGG(CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL
  16. AND eb.HAS_LEGAL_SCHEDULING = 0
  17. <if test="nextDate != null and nextDate.size()>= 2">
  18. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  19. </if>
  20. <if test="useStatus != null and useStatus.size() > 0">
  21. AND eb.USE_STATUS IN
  22. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  23. #{listItem}
  24. </foreach>
  25. </if>
  26. THEN eb.id ELSE NULL END, ',' ON OVERFLOW TRUNCATE) AS legal_equip_ids
  27. ,LISTAGG(CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL
  28. AND eb.HAS_LEGAL_SCHEDULING = 0
  29. <if test="nextDate != null and nextDate.size()>= 2">
  30. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  31. </if>
  32. <if test="useStatus != null and useStatus.size() > 0">
  33. AND eb.USE_STATUS IN
  34. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  35. #{listItem}
  36. </foreach>
  37. </if>
  38. THEN eb.id ELSE NULL END, ',' ON OVERFLOW TRUNCATE) AS year_equip_ids
  39. ,SUM(CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL
  40. AND eb.HAS_LEGAL_SCHEDULING = 0
  41. <if test="nextDate != null and nextDate.size()>= 2">
  42. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  43. </if>
  44. <if test="useStatus != null and useStatus.size() > 0">
  45. AND eb.USE_STATUS IN
  46. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  47. #{listItem}
  48. </foreach>
  49. </if>
  50. THEN 1 ELSE 0 END) AS count_legal
  51. ,SUM(CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL
  52. AND eb.HAS_YEAR_SCHEDULING = 0
  53. <if test="nextDate != null and nextDate.size()>= 2">
  54. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  55. </if>
  56. <if test="useStatus != null and useStatus.size() > 0">
  57. AND eb.USE_STATUS IN
  58. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  59. #{listItem}
  60. </foreach>
  61. </if>
  62. THEN 1 ELSE 0 END) AS count_year
  63. ,MIN(CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL
  64. AND eb.HAS_LEGAL_SCHEDULING = 0
  65. <if test="nextDate != null and nextDate.size()>= 2">
  66. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  67. </if>
  68. <if test="useStatus != null and useStatus.size() > 0">
  69. AND eb.USE_STATUS IN
  70. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  71. #{listItem}
  72. </foreach>
  73. </if>
  74. THEN eb.NEXT_LEGAL_CHECK_DATE ELSE NULL END
  75. ) AS NEXT_LEGAL_CHECK_DATE
  76. ,MIN(CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL
  77. AND eb.HAS_YEAR_SCHEDULING = 0
  78. <if test="nextDate != null and nextDate.size()>= 2">
  79. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  80. </if>
  81. <if test="useStatus != null and useStatus.size() > 0">
  82. AND eb.USE_STATUS IN
  83. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  84. #{listItem}
  85. </foreach>
  86. </if>
  87. THEN eb.NEXT_YEAR_CHECK_DATE ELSE NULL END
  88. ) AS NEXT_YEAR_CHECK_DATE
  89. ,MIN(COALESCE(
  90. CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL AND eb.HAS_LEGAL_SCHEDULING = 0
  91. <if test="nextDate != null and nextDate.size()>= 2">
  92. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  93. </if>
  94. <if test="useStatus != null and useStatus.size() > 0">
  95. AND eb.USE_STATUS IN
  96. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  97. #{listItem}
  98. </foreach>
  99. </if>
  100. THEN eb.NEXT_LEGAL_CHECK_DATE ELSE NULL END,
  101. CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL AND eb.HAS_YEAR_SCHEDULING = 0
  102. <if test="nextDate != null and nextDate.size()>= 2">
  103. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  104. </if>
  105. <if test="useStatus != null and useStatus.size() > 0">
  106. AND eb.USE_STATUS IN
  107. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  108. #{listItem}
  109. </foreach>
  110. </if>
  111. THEN eb.NEXT_YEAR_CHECK_DATE ELSE NULL END
  112. )) AS unified_check_date
  113. from PRESSURE2_EQUIP_PIPE eb
  114. <where>
  115. eb.deleted = 0
  116. <if test="unitName != null and unitName != ''">
  117. AND eb.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  118. </if>
  119. <if test="pipeAddress != null and pipeAddress != ''">
  120. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  121. </if>
  122. <if test="relateDepartment != null and relateDepartment != ''">
  123. AND eb.RELATION_DEPT = #{relateDepartment}
  124. </if>
  125. <if test="projectNo != null and projectNo != ''">
  126. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  127. </if>
  128. <if test="useStatus != null and useStatus.size() > 0">
  129. AND eb.USE_STATUS IN
  130. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  131. #{listItem}
  132. </foreach>
  133. </if>
  134. <if test="equipStreet != null and equipStreet.size() > 0">
  135. AND eb.EQUIP_STREET IN
  136. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  137. #{listItem}
  138. </foreach>
  139. </if>
  140. <if test="equipDistrict != null and equipDistrict.size() > 0">
  141. AND eb.EQUIP_DISTRICT IN
  142. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  143. #{listItem}
  144. </foreach>
  145. </if>
  146. <if test="nextDate != null and nextDate.size() >= 2">
  147. AND (
  148. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  149. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  150. )
  151. </if>
  152. <if test="typeList != null and typeList.size() > 0">
  153. AND eb.PIPE_CATEGORY IN
  154. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  155. #{listItem}
  156. </foreach>
  157. </if>
  158. </where>
  159. group by eb.EQUIP_DISTRICT,eb.EQUIP_STREET,eb.UNIT_CODE,eb.PIPE_ADDRESS,
  160. eb.CONTACT,eb.CONTACT_PHONE
  161. order by unified_check_date NULLS LAST,eb.EQUIP_DISTRICT,eb.EQUIP_STREET
  162. ) a
  163. WHERE a.count_legal > 0 OR a.count_year > 0
  164. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  165. </select>
  166. <select id="selectPlanPageCount">
  167. select count(*) from (
  168. select eb.EQUIP_DISTRICT,eb.EQUIP_STREET,eb.UNIT_CODE,eb.UNIT_NAME
  169. ,eb.PIPE_ADDRESS,eb.CONTACT,eb.CONTACT_PHONE,eb.UNIT_ID
  170. ,min(eb.id) as id
  171. ,LISTAGG(CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL
  172. AND eb.HAS_LEGAL_SCHEDULING = 0
  173. <if test="nextDate != null and nextDate.size()>= 2">
  174. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  175. </if>
  176. <if test="useStatus != null and useStatus.size() > 0">
  177. AND eb.USE_STATUS IN
  178. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  179. #{listItem}
  180. </foreach>
  181. </if>
  182. THEN eb.id ELSE NULL END, ',' ON OVERFLOW TRUNCATE) AS legal_equip_ids
  183. ,LISTAGG(CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL
  184. AND eb.HAS_YEAR_SCHEDULING = 0
  185. <if test="nextDate != null and nextDate.size()>= 2">
  186. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  187. </if>
  188. <if test="useStatus != null and useStatus.size() > 0">
  189. AND eb.USE_STATUS IN
  190. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  191. #{listItem}
  192. </foreach>
  193. </if>
  194. THEN eb.id ELSE NULL END, ',' ON OVERFLOW TRUNCATE) AS year_equip_ids
  195. ,SUM(CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL
  196. AND eb.HAS_LEGAL_SCHEDULING = 0
  197. <if test="nextDate != null and nextDate.size()>= 2">
  198. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  199. </if>
  200. <if test="useStatus != null and useStatus.size() > 0">
  201. AND eb.USE_STATUS IN
  202. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  203. #{listItem}
  204. </foreach>
  205. </if>
  206. THEN 1 ELSE 0 END) AS count_legal
  207. ,SUM(CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL
  208. AND eb.HAS_YEAR_SCHEDULING = 0
  209. <if test="nextDate != null and nextDate.size()>= 2">
  210. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  211. </if>
  212. <if test="useStatus != null and useStatus.size() > 0">
  213. AND eb.USE_STATUS IN
  214. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  215. #{listItem}
  216. </foreach>
  217. </if>
  218. THEN 1 ELSE 0 END) AS count_year
  219. ,MIN(CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL
  220. AND eb.HAS_LEGAL_SCHEDULING = 0
  221. <if test="nextDate != null and nextDate.size()>= 2">
  222. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  223. </if>
  224. <if test="useStatus != null and useStatus.size() > 0">
  225. AND eb.USE_STATUS IN
  226. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  227. #{listItem}
  228. </foreach>
  229. </if>
  230. THEN eb.NEXT_LEGAL_CHECK_DATE ELSE NULL END
  231. ) AS NEXT_LEGAL_CHECK_DATE
  232. ,MIN(CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL
  233. AND eb.HAS_YEAR_SCHEDULING = 0
  234. <if test="nextDate != null and nextDate.size()>= 2">
  235. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  236. </if>
  237. <if test="useStatus != null and useStatus.size() > 0">
  238. AND eb.USE_STATUS IN
  239. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  240. #{listItem}
  241. </foreach>
  242. </if>
  243. THEN eb.NEXT_YEAR_CHECK_DATE ELSE NULL END
  244. ) AS NEXT_YEAR_CHECK_DATE
  245. ,MIN(COALESCE(
  246. CASE WHEN eb.NEXT_LEGAL_CHECK_DATE IS NOT NULL AND eb.HAS_LEGAL_SCHEDULING = 0
  247. <if test="nextDate != null and nextDate.size()>= 2">
  248. AND eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  249. </if>
  250. <if test="useStatus != null and useStatus.size() > 0">
  251. AND eb.USE_STATUS IN
  252. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  253. #{listItem}
  254. </foreach>
  255. </if>
  256. THEN eb.NEXT_LEGAL_CHECK_DATE ELSE NULL END,
  257. CASE WHEN eb.NEXT_YEAR_CHECK_DATE IS NOT NULL AND eb.HAS_YEAR_SCHEDULING = 0
  258. <if test="nextDate != null and nextDate.size()>= 2">
  259. AND eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
  260. </if>
  261. <if test="useStatus != null and useStatus.size() > 0">
  262. AND eb.USE_STATUS IN
  263. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  264. #{listItem}
  265. </foreach>
  266. </if>
  267. THEN eb.NEXT_YEAR_CHECK_DATE ELSE NULL END
  268. )) AS unified_check_date
  269. from PRESSURE2_EQUIP_PIPE eb
  270. <where>
  271. eb.deleted = 0
  272. <if test="unitName != null and unitName != ''">
  273. AND eb.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  274. </if>
  275. <if test="pipeAddress != null and pipeAddress != ''">
  276. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  277. </if>
  278. <if test="relateDepartment != null and relateDepartment != ''">
  279. AND eb.RELATION_DEPT = #{relateDepartment}
  280. </if>
  281. <if test="projectNo != null and projectNo != ''">
  282. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  283. </if>
  284. <if test="useStatus != null and useStatus.size() > 0">
  285. AND eb.USE_STATUS IN
  286. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  287. #{listItem}
  288. </foreach>
  289. </if>
  290. <if test="equipStreet != null and equipStreet.size() > 0">
  291. AND eb.EQUIP_STREET IN
  292. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  293. #{listItem}
  294. </foreach>
  295. </if>
  296. <if test="equipDistrict != null and equipDistrict.size() > 0">
  297. AND eb.EQUIP_DISTRICT IN
  298. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  299. #{listItem}
  300. </foreach>
  301. </if>
  302. <if test="nextDate != null and nextDate.size() >= 2">
  303. AND (
  304. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  305. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  306. )
  307. </if>
  308. <if test="typeList != null and typeList.size() > 0">
  309. AND eb.PIPE_CATEGORY IN
  310. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  311. #{listItem}
  312. </foreach>
  313. </if>
  314. </where>
  315. group by eb.EQUIP_DISTRICT,eb.EQUIP_STREET,eb.UNIT_CODE,eb.PIPE_ADDRESS,
  316. eb.CONTACT,eb.CONTACT_PHONE
  317. ORDER BY unified_check_date NULLS LAST,eb.EQUIP_DISTRICT,eb.EQUIP_STREET
  318. ) a
  319. WHERE a.count_legal > 0 OR a.count_year > 0
  320. </select>
  321. <select id="selectPlanPageGroupProject">
  322. select ped.ID,ped.EQUIP_PIPE_ID,ped.PIPE_NO,ped.PIPE_NAME,ped.PIPE_REG_CODE,ped.PIPE_LENGTH,
  323. pe.PROJECT_NO,pe.PROJECT_NAME,pe.CONTACT,pe.CONTACT_PHONE,ped.HAS_LEGAL_SCHEDULING,ped.HAS_YEAR_SCHEDULING,
  324. pe.NEXT_LEGAL_CHECK_DATE,pe.NEXT_YEAR_CHECK_DATE,
  325. ped.NEXT_LEGAL_CHECK_DATE as NEXT_LEGAL_CHECK_DATE_DETAIL,
  326. ped.NEXT_YEAR_CHECK_DATE as NEXT_YEAR_CHECK_DATE_DETAIL,
  327. pe.UNIT_ID
  328. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  329. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM_DETAIL b on a.ID = b.SCHEDULING_ID
  330. where b.equip_detail_id = ped.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) plan_legal_check_date
  331. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  332. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM_DETAIL b on a.ID = b.SCHEDULING_ID
  333. where b.equip_detail_id = ped.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) plan_year_check_date
  334. from PRESSURE2_EQUIP_PIPE_DETAIL ped
  335. left join PRESSURE2_EQUIP_PIPE pe on ped.EQUIP_PIPE_ID = pe.ID
  336. where pe.DELETED = 0 and ped.DELETED = 0
  337. and (ped.HAS_LEGAL_SCHEDULING = 0 or ped.HAS_YEAR_SCHEDULING = 0)
  338. and ped.EQUIP_PIPE_ID in
  339. <foreach close=")" collection="ids" item="listItem" open="(" separator=",">
  340. #{listItem}
  341. </foreach>
  342. </select>
  343. <select id="selectPlanCalendar">
  344. 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,
  345. b.equip_district,b.equip_street,a.source,FIRST_VALUE(b.lng) lng,FIRST_VALUE(b.lat) lat,
  346. e.id APPOINTMENT_ID,f.id ACCEPT_ORDER_ID,f.STATUS accept_status, g.TASK_STATUS
  347. from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  348. inner join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM c on c.SCHEDULING_ID = a.ID and c.DELETED = 0
  349. inner join PRESSURE2_EQUIP_PIPE b on b.ID = c.equip_id and b.DELETED = 0
  350. inner join PRESSURE2_EQUIP_PIPE_SCHEDULING_USER d on d.SCHEDULING_ID = a.ID and d.DELETED = 0
  351. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER e on e.SCHEDULING_ID = a.ID
  352. left join PRESSURE_ACCEPT_ORDER f on f.APPOINTMENT_ID = e.ID
  353. left join PRESSURE_Task_ORDER g on g.ACCEPT_ORDER_ID = f.ID
  354. <where>
  355. a.DELETED = 0
  356. <if test="planDate != null and planDate.size() >= 2">
  357. and a.plan_date between #{planDate[0]} and #{planDate[1]}
  358. </if>
  359. <if test="userId != null and userId != ''">
  360. and a.CREATOR = #{userId}
  361. </if>
  362. <if test="relateDepartment != null and relateDepartment != ''">
  363. and b.RELATION_DEPT = #{relateDepartment}
  364. </if>
  365. </where>
  366. group by b.unit_code,a.plan_date,a.type,a.ID
  367. order by b.unit_code
  368. </select>
  369. <select id="selectPlanPipesPage">
  370. select rownum,a.* from (
  371. select id,unit_code,unit_name,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  372. NEXT_LEGAL_CHECK_DATE,NEXT_YEAR_CHECK_DATE,project_no,project_name,pipe_category
  373. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  374. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  375. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 order by a.CREATE_TIME DESC limit 1) plan_legal_check_date
  376. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  377. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  378. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 order by a.CREATE_TIME DESC limit 1) plan_year_check_date
  379. from PRESSURE2_EQUIP_PIPE eb
  380. <where>
  381. eb.deleted = 0
  382. <if test="unitName != null and unitName != ''">
  383. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  384. </if>
  385. <if test="unitCode != null">
  386. and eb.unit_code = #{unitCode}
  387. </if>
  388. <if test="pipeAddress != null and pipeAddress != ''">
  389. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  390. </if>
  391. <if test="relateDepartment != null and relateDepartment != ''">
  392. AND eb.RELATION_DEPT = #{relateDepartment}
  393. </if>
  394. <if test="projectNo != null and projectNo != ''">
  395. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  396. </if>
  397. <if test="equipStreet != null and equipStreet.size() > 0">
  398. AND eb.equip_street IN
  399. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  400. #{listItem}
  401. </foreach>
  402. </if>
  403. <if test="equipDistrict != null and equipDistrict.size() > 0">
  404. AND eb.equip_district IN
  405. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  406. #{listItem}
  407. </foreach>
  408. </if>
  409. <if test="nextDate != null and nextDate.size() >= 2">
  410. AND (
  411. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  412. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  413. )
  414. </if>
  415. <if test="typeList != null and typeList.size() > 0">
  416. AND eb.PIPE_CATEGORY IN
  417. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  418. #{listItem}
  419. </foreach>
  420. </if>
  421. <if test="useStatus != null and useStatus.size() > 0">
  422. AND eb.USE_STATUS IN
  423. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  424. #{listItem}
  425. </foreach>
  426. </if>
  427. <if test="equipIds != null and equipIds != ''">
  428. AND eb.id IN
  429. <foreach
  430. collection="equipIds"
  431. item="item" open="(" separator="," close=")">
  432. #{item}
  433. </foreach>
  434. </if>
  435. <if test="taskId != null and taskId != ''">
  436. AND eb.ID IN (
  437. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{taskId} and DELETED = 0
  438. )
  439. </if>
  440. <if test="notTaskId != null and notTaskId != ''">
  441. AND eb.ID NOT IN (
  442. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{notTaskId} and DELETED = 0
  443. )
  444. </if>
  445. </where>
  446. ) a
  447. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  448. </select>
  449. <select id="selectPlanPipesPageCount">
  450. select count(*) from (
  451. select id,unit_code,unit_name,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  452. NEXT_LEGAL_CHECK_DATE,NEXT_YEAR_CHECK_DATE
  453. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  454. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  455. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 order by a.CREATE_TIME limit 1) plan_legal_check_date
  456. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  457. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  458. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 order by a.CREATE_TIME limit 1) plan_year_check_date
  459. from PRESSURE2_EQUIP_PIPE eb
  460. <where>
  461. eb.deleted = 0
  462. <if test="unitName != null and unitName != ''">
  463. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  464. </if>
  465. <if test="unitCode != null">
  466. and eb.unit_code = #{unitCode}
  467. </if>
  468. <if test="pipeAddress != null and pipeAddress != ''">
  469. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  470. </if>
  471. <if test="relateDepartment != null and relateDepartment != ''">
  472. AND eb.RELATION_DEPT = #{relateDepartment}
  473. </if>
  474. <if test="projectNo != null and projectNo != ''">
  475. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  476. </if>
  477. <if test="equipStreet != null and equipStreet.size() > 0">
  478. AND eb.equip_street IN
  479. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  480. #{listItem}
  481. </foreach>
  482. </if>
  483. <if test="equipDistrict != null and equipDistrict.size() > 0">
  484. AND eb.equip_district IN
  485. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  486. #{listItem}
  487. </foreach>
  488. </if>
  489. <if test="nextDate != null and nextDate.size() >= 2">
  490. AND (
  491. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  492. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  493. )
  494. </if>
  495. <if test="typeList != null and typeList.size() > 0">
  496. AND eb.PIPE_CATEGORY IN
  497. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  498. #{listItem}
  499. </foreach>
  500. </if>
  501. <if test="useStatus != null and useStatus.size() > 0">
  502. AND eb.USE_STATUS IN
  503. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  504. #{listItem}
  505. </foreach>
  506. </if>
  507. <if test="taskId != null and taskId != ''">
  508. AND eb.ID IN (
  509. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{taskId} and DELETED = 0
  510. )
  511. </if>
  512. <if test="notTaskId != null and notTaskId != ''">
  513. AND eb.ID NOT IN (
  514. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{notTaskId} and DELETED = 0
  515. )
  516. </if>
  517. <if test="equipIds != null and equipIds != ''">
  518. AND eb.id IN
  519. <foreach
  520. collection="equipIds"
  521. item="item" open="(" separator="," close=")">
  522. #{item}
  523. </foreach>
  524. </if>
  525. </where>
  526. ) a
  527. </select>
  528. </mapper>