EquipPipeSchedulingMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  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_YEAR_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="selectPlanPagePipe">
  322. select rownum,a.* from (
  323. select eb.EQUIP_DISTRICT,eb.EQUIP_STREET,eb.UNIT_CODE,eb.UNIT_NAME
  324. ,eb.PIPE_ADDRESS,eb.CONTACT,eb.CONTACT_PHONE,eb.UNIT_ID,eb.id
  325. ,eb.PROJECT_NO,eb.PROJECT_NAME,eb.HAS_LEGAL_SCHEDULING,eb.HAS_YEAR_SCHEDULING,eb.PIPE_CATEGORY
  326. ,eb.NEXT_LEGAL_CHECK_DATE
  327. ,eb.NEXT_YEAR_CHECK_DATE
  328. ,scheduling_info.plan_legal_checkdate
  329. ,scheduling_info.plan_year_checkdate
  330. from PRESSURE2_EQUIP_PIPE eb
  331. LEFT JOIN (
  332. SELECT
  333. b.equip_id,
  334. MAX(CASE WHEN s.type = 100 THEN s.PLAN_DATE END) AS plan_legal_checkdate,
  335. MAX(CASE WHEN s.type = 200 THEN s.PLAN_DATE END) AS plan_year_checkdate
  336. FROM PRESSURE2_EQUIP_PIPE_SCHEDULING s
  337. INNER JOIN PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b ON s.ID = b.SCHEDULING_ID
  338. WHERE s.DELETED = 0 AND b.DELETED = 0 AND s.type IN (100, 200)
  339. GROUP BY b.equip_id
  340. ) scheduling_info ON eb.ID = scheduling_info.equip_id
  341. <where>
  342. eb.deleted = 0
  343. --and (select count(*) num_pipe from (
  344. --select ped.ID
  345. --from PRESSURE2_EQUIP_PIPE_DETAIL ped
  346. --left join PRESSURE2_EQUIP_PIPE pe on ped.EQUIP_PIPE_ID = pe.ID
  347. --where pe.DELETED = 0 and ped.DELETED = 0
  348. --and (ped.HAS_LEGAL_SCHEDULING = 0 or ped.HAS_YEAR_SCHEDULING = 0)
  349. --and ped.EQUIP_PIPE_ID = eb.id
  350. --) a) > 0
  351. <if test="unitName != null and unitName != ''">
  352. AND eb.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  353. </if>
  354. <if test="pipeAddress != null and pipeAddress != ''">
  355. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  356. </if>
  357. <if test="relateDepartment != null and relateDepartment != ''">
  358. AND eb.RELATION_DEPT = #{relateDepartment}
  359. </if>
  360. <if test="projectNo != null and projectNo != ''">
  361. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  362. </if>
  363. <if test="projectName != null and projectName != ''">
  364. AND eb.PROJECT_NAME LIKE CONCAT('%',#{projectName},'%')
  365. </if>
  366. <if test="useStatus != null and useStatus.size() > 0">
  367. AND eb.USE_STATUS IN
  368. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  369. #{listItem}
  370. </foreach>
  371. </if>
  372. <if test="equipStreet != null and equipStreet.size() > 0">
  373. AND eb.EQUIP_STREET IN
  374. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  375. #{listItem}
  376. </foreach>
  377. </if>
  378. <if test="equipDistrict != null and equipDistrict.size() > 0">
  379. AND eb.EQUIP_DISTRICT IN
  380. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  381. #{listItem}
  382. </foreach>
  383. </if>
  384. <if test="nextDate != null and nextDate.size() >= 2">
  385. AND (
  386. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  387. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  388. )
  389. </if>
  390. <if test="typeList != null and typeList.size() > 0">
  391. AND eb.PIPE_CATEGORY IN
  392. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  393. #{listItem}
  394. </foreach>
  395. </if>
  396. </where>
  397. group by eb.id
  398. ) a
  399. --WHERE a.count_in > 0 OR a.count_out > 0 OR a.count_pre > 0
  400. order by
  401. <choose>
  402. <when test="sort != null and sort == 'nextLegalCheckDate'">
  403. NVL(a.NEXT_LEGAL_CHECK_DATE, '1000-12-31')
  404. </when>
  405. <when test="sort != null and sort == 'nextYearCheckDate'">
  406. NVL(a.NEXT_YEAR_CHECK_DATE, '1000-12-31')
  407. </when>
  408. <otherwise>
  409. NVL(a.NEXT_LEGAL_CHECK_DATE, '1000-12-31')
  410. </otherwise>
  411. </choose>
  412. <if test="order != null and order != ''">
  413. <choose>
  414. <when test="order == 'descending'">
  415. desc
  416. </when>
  417. <otherwise>
  418. asc
  419. </otherwise>
  420. </choose>
  421. </if>
  422. , a.UNIT_NAME
  423. <if test="pageSize != -1">
  424. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  425. </if>
  426. </select>
  427. <select id="selectPlanPagePipeCount">
  428. select count(*) from (
  429. select eb.EQUIP_DISTRICT,eb.EQUIP_STREET,eb.UNIT_CODE,eb.UNIT_NAME
  430. ,eb.PIPE_ADDRESS,eb.CONTACT,eb.CONTACT_PHONE,eb.UNIT_ID,eb.id
  431. ,eb.PROJECT_NO,eb.PROJECT_NAME,eb.HAS_LEGAL_SCHEDULING,eb.HAS_YEAR_SCHEDULING,eb.PIPE_CATEGORY
  432. ,eb.NEXT_LEGAL_CHECK_DATE
  433. ,eb.NEXT_YEAR_CHECK_DATE
  434. ,scheduling_info.plan_legal_checkdate
  435. ,scheduling_info.plan_year_checkdate
  436. from PRESSURE2_EQUIP_PIPE eb
  437. LEFT JOIN (
  438. SELECT
  439. b.equip_id,
  440. MAX(CASE WHEN s.type = 100 THEN s.PLAN_DATE END) AS plan_legal_checkdate,
  441. MAX(CASE WHEN s.type = 200 THEN s.PLAN_DATE END) AS plan_year_checkdate
  442. FROM PRESSURE2_EQUIP_PIPE_SCHEDULING s
  443. INNER JOIN PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b ON s.ID = b.SCHEDULING_ID
  444. WHERE s.DELETED = 0 AND b.DELETED = 0 AND s.type IN (100, 200)
  445. GROUP BY b.equip_id
  446. ) scheduling_info ON eb.ID = scheduling_info.equip_id
  447. <where>
  448. eb.deleted = 0
  449. <if test="unitName != null and unitName != ''">
  450. AND eb.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  451. </if>
  452. <if test="pipeAddress != null and pipeAddress != ''">
  453. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  454. </if>
  455. <if test="relateDepartment != null and relateDepartment != ''">
  456. AND eb.RELATION_DEPT = #{relateDepartment}
  457. </if>
  458. <if test="projectNo != null and projectNo != ''">
  459. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  460. </if>
  461. <if test="projectName != null and projectName != ''">
  462. AND eb.PROJECT_NAME LIKE CONCAT('%',#{projectName},'%')
  463. </if>
  464. <if test="useStatus != null and useStatus.size() > 0">
  465. AND eb.USE_STATUS IN
  466. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  467. #{listItem}
  468. </foreach>
  469. </if>
  470. <if test="equipStreet != null and equipStreet.size() > 0">
  471. AND eb.EQUIP_STREET IN
  472. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  473. #{listItem}
  474. </foreach>
  475. </if>
  476. <if test="equipDistrict != null and equipDistrict.size() > 0">
  477. AND eb.EQUIP_DISTRICT IN
  478. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  479. #{listItem}
  480. </foreach>
  481. </if>
  482. <if test="nextDate != null and nextDate.size() >= 2">
  483. AND (
  484. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  485. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  486. )
  487. </if>
  488. <if test="typeList != null and typeList.size() > 0">
  489. AND eb.PIPE_CATEGORY IN
  490. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  491. #{listItem}
  492. </foreach>
  493. </if>
  494. </where>
  495. group by eb.id
  496. ) a
  497. </select>
  498. <select id="selectPlanPageGroupProject">
  499. select ped.ID,ped.EQUIP_PIPE_ID,ped.PIPE_NO,ped.PIPE_NAME,ped.PIPE_REG_CODE,ped.PIPE_LENGTH,
  500. pe.PROJECT_NO,pe.PROJECT_NAME,pe.CONTACT,pe.CONTACT_PHONE,ped.HAS_LEGAL_SCHEDULING,ped.HAS_YEAR_SCHEDULING,
  501. pe.NEXT_LEGAL_CHECK_DATE,pe.NEXT_YEAR_CHECK_DATE,
  502. ped.NEXT_LEGAL_CHECK_DATE as NEXT_LEGAL_CHECK_DATE_DETAIL,
  503. ped.NEXT_YEAR_CHECK_DATE as NEXT_YEAR_CHECK_DATE_DETAIL,
  504. pe.UNIT_ID,ped.PIPE_LEVEL,ped.PIPE_TYPE,ped.PIPE_MATERIAL,ped.MATERIAL_STANDARD,ped.LEGAL_SAFETY_STATUS_LEVEL,ped.YEAR_SAFETY_STATUS_LEVEL
  505. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  506. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM_DETAIL b on a.ID = b.SCHEDULING_ID
  507. 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
  508. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  509. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM_DETAIL b on a.ID = b.SCHEDULING_ID
  510. 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
  511. from PRESSURE2_EQUIP_PIPE_DETAIL ped
  512. left join PRESSURE2_EQUIP_PIPE pe on ped.EQUIP_PIPE_ID = pe.ID
  513. where pe.DELETED = 0 and ped.DELETED = 0
  514. and (ped.HAS_LEGAL_SCHEDULING = 0 or ped.HAS_YEAR_SCHEDULING = 0)
  515. and ped.EQUIP_PIPE_ID in
  516. <foreach close=")" collection="ids" item="listItem" open="(" separator=",">
  517. #{listItem}
  518. </foreach>
  519. </select>
  520. <select id="selectPlanCalendar">
  521. 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,
  522. b.equip_district,b.equip_street,a.source,FIRST_VALUE(b.lng) lng,FIRST_VALUE(b.lat) lat,
  523. e.id APPOINTMENT_ID,f.id ACCEPT_ORDER_ID,f.STATUS accept_status, g.TASK_STATUS
  524. from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  525. inner join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM c on c.SCHEDULING_ID = a.ID and c.DELETED = 0
  526. inner join PRESSURE2_EQUIP_PIPE b on b.ID = c.equip_id and b.DELETED = 0
  527. --inner join PRESSURE2_EQUIP_PIPE_SCHEDULING_USER d on d.SCHEDULING_ID = a.ID and d.DELETED = 0
  528. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER e on e.SCHEDULING_ID = a.ID
  529. left join PRESSURE_ACCEPT_ORDER f on f.APPOINTMENT_ID = e.ID
  530. left join PRESSURE_Task_ORDER g on g.ACCEPT_ORDER_ID = f.ID
  531. <where>
  532. a.DELETED = 0
  533. <if test="planDate != null and planDate.size() >= 2">
  534. and a.plan_date between #{planDate[0]} and #{planDate[1]}
  535. </if>
  536. <if test="userId != null and userId != ''">
  537. and a.CREATOR = #{userId}
  538. </if>
  539. <if test="relateDepartment != null and relateDepartment != ''">
  540. and b.RELATION_DEPT = #{relateDepartment}
  541. </if>
  542. </where>
  543. group by b.unit_code,a.plan_date,a.type,a.ID
  544. order by b.unit_code
  545. </select>
  546. <select id="selectShiftSchedule">
  547. 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,
  548. b.equip_district,b.equip_street,a.source,FIRST_VALUE(b.lng) lng,FIRST_VALUE(b.lat) lat,
  549. b.CONTACT,b.CONTACT_PHONE,b.PIPE_LENGTH_TOTAL,b.LAST_LEGAL_PERIODICAL_INSPECTION_REPORT_NO,b.LAST_YEAR_REPORT_NO,b.LAST_MAINTENANCE_REPORT_NO,
  550. e.id APPOINTMENT_ID,f.id ACCEPT_ORDER_ID,f.STATUS accept_status, g.TASK_STATUS ,b.PIPE_ADDRESS
  551. from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  552. inner join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM c on c.SCHEDULING_ID = a.ID and c.DELETED = 0
  553. inner join PRESSURE2_EQUIP_PIPE b on b.ID = c.equip_id and b.DELETED = 0
  554. --inner join PRESSURE2_EQUIP_PIPE_SCHEDULING_USER d on d.SCHEDULING_ID = a.ID and d.DELETED = 0
  555. left join PRESSURE_APPOINTMENT_CONFIRM_ORDER e on e.SCHEDULING_ID = a.ID
  556. left join PRESSURE_ACCEPT_ORDER f on f.APPOINTMENT_ID = e.ID
  557. left join PRESSURE_Task_ORDER g on g.ACCEPT_ORDER_ID = f.ID
  558. <where>
  559. a.DELETED = 0
  560. <if test="startDate != null and endDate == null">
  561. and a.plan_date &gt;= #{startDate}
  562. </if>
  563. <if test="startDate == null and endDate != null">
  564. and a.plan_date &lt;= #{endDate}
  565. </if>
  566. <if test="startDate != null and endDate != null">
  567. and a.plan_date between #{startDate} and #{endDate}
  568. </if>
  569. <if test="checkType != null and checkType != ''">
  570. and a.TYPE = #{checkType}
  571. </if>
  572. <if test="unitName != null and unitName != ''">
  573. and b.unit_name like CONCAT('%',#{unitName},'%')
  574. </if>
  575. <if test="relateDepartment != null and relateDepartment != ''">
  576. and b.RELATION_DEPT = #{relateDepartment}
  577. </if>
  578. </where>
  579. group by b.unit_code,a.plan_date,a.type,a.ID
  580. <choose>
  581. <when test="orderBy != null and orderBy != '' and orderType != null and orderType != ''">
  582. <choose>
  583. <when test="orderBy == 'date'">
  584. order by a.plan_date ${orderType}
  585. </when>
  586. <when test="orderBy == 'unitName'">
  587. order by b.unit_name ${orderType}
  588. </when>
  589. <otherwise>
  590. order by a.plan_date
  591. </otherwise>
  592. </choose>
  593. </when>
  594. <otherwise>
  595. order by a.plan_date
  596. </otherwise>
  597. </choose>
  598. </select>
  599. <select id="selectPlanPipesPage">
  600. select rownum,a.* from (
  601. select id,unit_code,unit_name,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  602. NEXT_LEGAL_CHECK_DATE,NEXT_YEAR_CHECK_DATE,project_no,project_name,pipe_category
  603. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  604. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  605. 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
  606. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  607. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  608. 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
  609. from PRESSURE2_EQUIP_PIPE eb
  610. <where>
  611. eb.deleted = 0
  612. <if test="unitName != null and unitName != ''">
  613. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  614. </if>
  615. <if test="unitCode != null">
  616. and eb.unit_code = #{unitCode}
  617. </if>
  618. <if test="pipeAddress != null and pipeAddress != ''">
  619. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  620. </if>
  621. <if test="relateDepartment != null and relateDepartment != ''">
  622. AND eb.RELATION_DEPT = #{relateDepartment}
  623. </if>
  624. <if test="projectNo != null and projectNo != ''">
  625. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  626. </if>
  627. <if test="equipStreet != null and equipStreet.size() > 0">
  628. AND eb.equip_street IN
  629. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  630. #{listItem}
  631. </foreach>
  632. </if>
  633. <if test="equipDistrict != null and equipDistrict.size() > 0">
  634. AND eb.equip_district IN
  635. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  636. #{listItem}
  637. </foreach>
  638. </if>
  639. <if test="nextDate != null and nextDate.size() >= 2">
  640. AND (
  641. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  642. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  643. )
  644. </if>
  645. <if test="typeList != null and typeList.size() > 0">
  646. AND eb.PIPE_CATEGORY IN
  647. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  648. #{listItem}
  649. </foreach>
  650. </if>
  651. <if test="useStatus != null and useStatus.size() > 0">
  652. AND eb.USE_STATUS IN
  653. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  654. #{listItem}
  655. </foreach>
  656. </if>
  657. <if test="equipIds != null and equipIds != ''">
  658. AND eb.id IN
  659. <foreach
  660. collection="equipIds"
  661. item="item" open="(" separator="," close=")">
  662. #{item}
  663. </foreach>
  664. </if>
  665. <if test="taskId != null and taskId != ''">
  666. AND eb.ID IN (
  667. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{taskId} and DELETED = 0
  668. )
  669. </if>
  670. <if test="notTaskId != null and notTaskId != ''">
  671. AND eb.ID NOT IN (
  672. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{notTaskId} and DELETED = 0
  673. )
  674. </if>
  675. </where>
  676. ) a
  677. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  678. </select>
  679. <select id="selectPlanPipesPageCount">
  680. select count(*) from (
  681. select id,unit_code,unit_name,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
  682. NEXT_LEGAL_CHECK_DATE,NEXT_YEAR_CHECK_DATE
  683. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  684. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  685. 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
  686. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  687. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  688. 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
  689. from PRESSURE2_EQUIP_PIPE eb
  690. <where>
  691. eb.deleted = 0
  692. <if test="unitName != null and unitName != ''">
  693. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  694. </if>
  695. <if test="unitCode != null">
  696. and eb.unit_code = #{unitCode}
  697. </if>
  698. <if test="pipeAddress != null and pipeAddress != ''">
  699. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{pipeAddress},'%')
  700. </if>
  701. <if test="relateDepartment != null and relateDepartment != ''">
  702. AND eb.RELATION_DEPT = #{relateDepartment}
  703. </if>
  704. <if test="projectNo != null and projectNo != ''">
  705. AND eb.PROJECT_NO LIKE CONCAT('%',#{projectNo},'%')
  706. </if>
  707. <if test="equipStreet != null and equipStreet.size() > 0">
  708. AND eb.equip_street IN
  709. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  710. #{listItem}
  711. </foreach>
  712. </if>
  713. <if test="equipDistrict != null and equipDistrict.size() > 0">
  714. AND eb.equip_district IN
  715. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  716. #{listItem}
  717. </foreach>
  718. </if>
  719. <if test="nextDate != null and nextDate.size() >= 2">
  720. AND (
  721. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  722. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  723. )
  724. </if>
  725. <if test="typeList != null and typeList.size() > 0">
  726. AND eb.PIPE_CATEGORY IN
  727. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  728. #{listItem}
  729. </foreach>
  730. </if>
  731. <if test="useStatus != null and useStatus.size() > 0">
  732. AND eb.USE_STATUS IN
  733. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  734. #{listItem}
  735. </foreach>
  736. </if>
  737. <if test="taskId != null and taskId != ''">
  738. AND eb.ID IN (
  739. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{taskId} and DELETED = 0
  740. )
  741. </if>
  742. <if test="notTaskId != null and notTaskId != ''">
  743. AND eb.ID NOT IN (
  744. select EQUIP_ID from PRESSURE2_EQUIP_PIPE_SCHEDULING_item where SCHEDULING_ID = #{notTaskId} and DELETED = 0
  745. )
  746. </if>
  747. <if test="equipIds != null and equipIds != ''">
  748. AND eb.id IN
  749. <foreach
  750. collection="equipIds"
  751. item="item" open="(" separator="," close=")">
  752. #{item}
  753. </foreach>
  754. </if>
  755. </where>
  756. ) a
  757. </select>
  758. </mapper>