PipeTaskOrderMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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.pipetaskorder.PipeTaskOrderMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectPage">
  11. select rownum,a.* from (
  12. select bto.* from PRESSURE_TASK_ORDER bto
  13. <where>
  14. bto.DELETED = 0 and bto.EQUIP_MAIN_TYPE = 300
  15. <if test="orderNo != null and orderNo != ''">
  16. AND bto.ORDER_NO LIKE CONCAT('%',#{orderNo},'%')
  17. </if>
  18. <if test="unitName != null and unitName != ''">
  19. AND bto.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  20. </if>
  21. <if test="unitPhone != null and unitPhone != ''">
  22. AND bto.UNIT_PHONE LIKE CONCAT('%',#{unitPhone},'%')
  23. </if>
  24. <if test="checkType != null and checkType != ''">
  25. AND bto.CHECK_TYPE = #{checkType}
  26. </if>
  27. <if test="deptId != null and deptId != ''">
  28. AND bto.DEPT_ID = #{deptId}
  29. </if>
  30. <if test="checkDate != null and checkDate.size() >= 2">
  31. AND bto.CHECK_DATE BETWEEN #{checkDate[0]} AND #{checkDate[1]}
  32. </if>
  33. <if test="contractNo != null and contractNo != ''">
  34. AND bto.CONTRACT_NO LIKE CONCAT('%',#{contractNo},'%')
  35. </if>
  36. <if test="taskStatus != null and taskStatus != ''">
  37. AND bto.TASK_STATUS = #{taskStatus}
  38. </if>
  39. <if test="checkUserIds != null and checkUserIds.size() >= 1">
  40. AND bto.ID in (select tu.ORDER_ID from pressure2_pipe_task_order_user tu
  41. where tu.deleted = 0 and tu.USER_ID IN
  42. <foreach close=")" collection="checkUserIds" item="listItem" open="(" separator=",">
  43. #{listItem}
  44. </foreach>
  45. )
  46. </if>
  47. <if test="submitIds != null and submitIds.size() >= 1">
  48. AND bto.SUBMIT_ID IN
  49. <foreach close=")" collection="submitIds" item="listItem" open="(" separator=",">
  50. #{listItem}
  51. </foreach>
  52. </if>
  53. <if test="submitId != null and submitId != ''">
  54. AND bto.SUBMIT_ID = #{submitId}
  55. </if>
  56. <if test="deptId != null and deptId != ''">
  57. AND bto.DEPT_ID = #{deptId}
  58. </if>
  59. <if test="submitTime != null and submitTime.size() >= 2">
  60. AND bto.SUBMIT_TIME BETWEEN #{submitTime[0]} AND #{submitTime[1]}
  61. </if>
  62. <if test="status != null and status != ''">
  63. AND bto.STATUS = #{status}
  64. </if>
  65. <if test="permissionUserId != null and permissionUserId != ''">
  66. AND ( bto.MANAGER_ID = #{permissionUserId}
  67. or bto.ID in (select tu.ORDER_ID from pressure2_pipe_task_order_user tu
  68. where tu.deleted = 0 and tu.USER_ID = #{permissionUserId} ) )
  69. </if>
  70. <if test="permissionDeptIds != null and permissionDeptIds != ''">
  71. AND ( bto.DEPT_ID in
  72. <foreach close=")" collection="permissionDeptIds" item="listItem" open="(" separator=",">
  73. #{listItem}
  74. </foreach>
  75. )
  76. </if>
  77. <if test="hasPermission != null and hasPermission == false">
  78. AND 1 = 2
  79. </if>
  80. </where>
  81. order by bto.CREATE_TIME desc
  82. ) a
  83. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  84. </select>
  85. <select id="selectPageCount">
  86. select count(1) from (
  87. select bto.* from PRESSURE_TASK_ORDER bto
  88. <where>
  89. bto.DELETED = 0 and bto.EQUIP_MAIN_TYPE = 300
  90. <if test="orderNo != null and orderNo != ''">
  91. AND bto.ORDER_NO LIKE CONCAT('%',#{orderNo},'%')
  92. </if>
  93. <if test="unitName != null and unitName != ''">
  94. AND bto.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  95. </if>
  96. <if test="checkType != null and checkType != ''">
  97. AND bto.CHECK_TYPE = #{checkType}
  98. </if>
  99. <if test="deptId != null and deptId != ''">
  100. AND bto.DEPT_ID = #{deptId}
  101. </if>
  102. <if test="checkDate != null and checkDate.size() >= 2">
  103. AND bto.CHECK_DATE BETWEEN #{checkDate[0]} AND #{checkDate[1]}
  104. </if>
  105. <if test="contractNo != null and contractNo != ''">
  106. AND bto.CONTRACT_NO LIKE CONCAT('%',#{contractNo},'%')
  107. </if>
  108. <if test="taskStatus != null and taskStatus != ''">
  109. AND bto.TASK_STATUS = #{taskStatus}
  110. </if>
  111. <if test="checkUserIds != null and checkUserIds.size() >= 1">
  112. AND bto.ID in (select tu.ORDER_ID from pressure2_pipe_task_order_user tu
  113. left join SYSTEM_USERS u on u.ID = tu.USER_ID
  114. where tu.deleted = 0 and tu.USER_ID IN
  115. <foreach close=")" collection="checkUserIds" item="listItem" open="(" separator=",">
  116. #{listItem}
  117. </foreach>
  118. )
  119. </if>
  120. <if test="submitIds != null and submitIds.size() >= 1">
  121. AND bto.SUBMIT_ID IN
  122. <foreach close=")" collection="submitIds" item="listItem" open="(" separator=",">
  123. #{listItem}
  124. </foreach>
  125. </if>
  126. <if test="submitId != null and submitId != ''">
  127. AND bto.SUBMIT_ID = #{submitId}
  128. </if>
  129. <if test="deptId != null and deptId != ''">
  130. AND bto.DEPT_ID = #{deptId}
  131. </if>
  132. <if test="submitTime != null and submitTime.size() >= 2">
  133. AND bto.SUBMIT_TIME BETWEEN #{submitTime[0]} AND #{submitTime[1]}
  134. </if>
  135. <if test="status != null and status != ''">
  136. AND bto.STATUS = #{status}
  137. </if>
  138. <if test="permissionUserId != null and permissionUserId != ''">
  139. AND ( bto.MANAGER_ID = #{permissionUserId}
  140. or bto.ID in (select tu.ORDER_ID from pressure2_pipe_task_order_user tu
  141. where tu.deleted = 0 and tu.USER_ID = #{permissionUserId} ) )
  142. </if>
  143. <if test="permissionDeptIds != null and permissionDeptIds != ''">
  144. AND ( bto.DEPT_ID in
  145. <foreach close=")" collection="permissionDeptIds" item="listItem" open="(" separator=",">
  146. #{listItem}
  147. </foreach>
  148. )
  149. </if>
  150. <if test="hasPermission != null and hasPermission == false">
  151. AND 1 = 2
  152. </if>
  153. </where>
  154. ) a
  155. </select>
  156. <select id="selectItemPage">
  157. select rownum,a.* from (
  158. select DISTINCT tt.ID
  159. ,bto.ID as ORDER_ID
  160. ,bto.ORDER_NO
  161. ,bto.UNIT_NAME
  162. ,bto.CHECK_TYPE
  163. ,bto.DEPT_ID
  164. ,btoir.TASK_STATUS
  165. ,bto.CHECK_DATE
  166. ,bto.MANAGER_ID
  167. ,tt.MAIN_CHECKER
  168. ,tt.END_CHECK_DATE
  169. ,bto.CREATE_TIME
  170. ,epp.ID AS EQUIP_ID
  171. -- 去重后聚合
  172. ,WM_CONCAT(epp.PROJECT_NO) as PROJECT_NO
  173. -- 设备任务
  174. from PRESSURE2_PIPE_TASK_ORDER_INPUT tt
  175. left join PRESSURE_TASK_ORDER bto on bto.ID = tt.ORDER_ID and bto.EQUIP_MAIN_TYPE = 300
  176. left join PRESSURE2_PIPE_TASK_ORDER_ITEM_REPORT btoir on btoir.ORDER_ID = tt.ORDER_ID and btoir.REPORT_TYPE = 100
  177. left join PRESSURE2_PIPE_TASK_ORDER_ITEM ptoi on ptoi.ORDER_ID = tt.ORDER_ID and ptoi.DELETED = 0
  178. left join (
  179. -- 先对 PROJECT_NO 和 PROJECT_NAME 去重
  180. select distinct ID, PROJECT_NO, PROJECT_NAME
  181. from PRESSURE2_EQUIP_PIPE
  182. where DELETED = 0
  183. ) epp on epp.ID = ptoi.EQUIP_ID
  184. <where>
  185. tt.DELETED = 0 AND bto.DELETED = 0 and btoir.DELETED = 0
  186. -- 只显示已认领的任务单
  187. AND bto.TASK_STATUS = 400
  188. <if test="isClaim != null">
  189. <if test="isClaim == 'unclaim'">
  190. AND (tt.MAIN_CHECKER IS NULL OR tt.MAIN_CHECKER = '')
  191. </if>
  192. <if test="isClaim == 'claim'">
  193. AND (tt.MAIN_CHECKER IS NOT NULL AND tt.MAIN_CHECKER != '')
  194. </if>
  195. </if>
  196. <if test="taskStatusList != null and taskStatusList.size() > 0">
  197. AND btoir.TASK_STATUS IN
  198. <foreach collection="taskStatusList" item="taskStatus" open="(" separator="," close=")">
  199. #{taskStatus}
  200. </foreach>
  201. </if>
  202. <if test="unitCode != null and unitCode != ''">
  203. AND bto.UNIT_CODE LIKE CONCAT('%',#{unitCode},'%')
  204. </if>
  205. <if test="orderNo != null and orderNo != ''">
  206. AND bto.ORDER_NO LIKE CONCAT('%',#{orderNo},'%')
  207. </if>
  208. <if test="unitName != null and unitName != ''">
  209. AND bto.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  210. </if>
  211. <if test="checkType != null and checkType != ''">
  212. AND bto.CHECK_TYPE = #{checkType}
  213. </if>
  214. <if test="deptId != null and deptId != ''">
  215. AND bto.DEPT_ID = #{deptId}
  216. </if>
  217. <if test="orderId != null and orderId != ''">
  218. AND bto.ID = #{orderId}
  219. </if>
  220. <if test="checkDate != null and checkDate.size() >= 2">
  221. AND bto.CHECK_DATE BETWEEN #{checkDate[0]} AND #{checkDate[1]}
  222. </if>
  223. <if test="mainCheckerIds != null and mainCheckerIds.size() > 0">
  224. AND tt.MAIN_CHECKER IN
  225. <foreach collection="mainCheckerIds" item="mainCheckerId" open="(" separator="," close=")">
  226. #{mainCheckerId}
  227. </foreach>
  228. </if>
  229. <if test="managerIds != null and managerIds.size() > 0">
  230. AND bto.MANAGER_ID IN
  231. <foreach collection="managerIds" item="managerId" open="(" separator="," close=")">
  232. #{managerId}
  233. </foreach>
  234. </if>
  235. <if test="checkUserIds != null and checkUserIds.size() > 0">
  236. AND bto.ID in (select ORDER_ID from PRESSURE2_PIPE_TASK_ORDER_USER where DELETED = 0 and USER_ID IN
  237. <foreach collection="checkUserIds" item="checkUserId" open="(" separator="," close=")">
  238. #{checkUserId}
  239. </foreach>
  240. )
  241. </if>
  242. <if test="permissionUserId != null and permissionUserId != ''">
  243. AND ( bto.MANAGER_ID = #{permissionUserId}
  244. or bto.ID in (select tu.ORDER_ID from pressure2_pipe_task_order_user tu
  245. where tu.deleted = 0 and tu.USER_ID = #{permissionUserId} ) )
  246. </if>
  247. <if test="permissionDeptIds != null and permissionDeptIds != ''">
  248. AND ( bto.DEPT_ID in
  249. <foreach close=")" collection="permissionDeptIds" item="listItem" open="(" separator=",">
  250. #{listItem}
  251. </foreach>
  252. )
  253. </if>
  254. <if test="hasPermission != null and hasPermission == false">
  255. AND 1 = 2
  256. </if>
  257. </where>
  258. group by tt.ID, bto.ID, bto.ORDER_NO, bto.UNIT_NAME, bto.CHECK_TYPE, btoir.TASK_STATUS,
  259. bto.CHECK_DATE, bto.MANAGER_ID, tt.MAIN_CHECKER, tt.END_CHECK_DATE, bto.CREATE_TIME
  260. <if test="projectNo != null and projectNo != ''">
  261. HAVING WM_CONCAT(epp.PROJECT_NO) LIKE CONCAT('%',#{projectNo},'%')
  262. </if>
  263. order by bto.CREATE_TIME desc
  264. ) a
  265. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  266. </select>
  267. <select id="selectItemPageCount">
  268. select count(*) from (
  269. select DISTINCT tt.ID
  270. ,bto.ID as ORDER_ID
  271. ,bto.ORDER_NO
  272. ,bto.UNIT_NAME
  273. ,bto.CHECK_TYPE
  274. ,btoir.TASK_STATUS
  275. ,bto.CHECK_DATE
  276. ,bto.MANAGER_ID
  277. ,tt.MAIN_CHECKER
  278. ,tt.END_CHECK_DATE
  279. ,bto.CREATE_TIME
  280. -- 去重后聚合
  281. ,WM_CONCAT(epp.PROJECT_NO) as PROJECT_NO
  282. -- 设备任务
  283. from PRESSURE2_PIPE_TASK_ORDER_INPUT tt
  284. left join PRESSURE_TASK_ORDER bto on bto.ID = tt.ORDER_ID and bto.EQUIP_MAIN_TYPE = 300
  285. left join PRESSURE2_PIPE_TASK_ORDER_ITEM_REPORT btoir on btoir.ORDER_ID = tt.ORDER_ID and btoir.REPORT_TYPE = 100
  286. left join PRESSURE2_PIPE_TASK_ORDER_ITEM ptoi on ptoi.ORDER_ID = tt.ORDER_ID and ptoi.DELETED = 0
  287. left join (
  288. -- 先对 PROJECT_NO 和 PROJECT_NAME 去重
  289. select distinct ID, PROJECT_NO, PROJECT_NAME
  290. from PRESSURE2_EQUIP_PIPE
  291. where DELETED = 0
  292. ) epp on epp.ID = ptoi.EQUIP_ID
  293. <where>
  294. tt.DELETED = 0 AND bto.DELETED = 0 and btoir.DELETED = 0
  295. -- 只显示已认领的任务单
  296. AND bto.TASK_STATUS = 400
  297. <if test="isClaim != null">
  298. <if test="isClaim == 'unclaim'">
  299. AND (tt.MAIN_CHECKER IS NULL OR tt.MAIN_CHECKER = '')
  300. </if>
  301. <if test="isClaim == 'claim'">
  302. AND (tt.MAIN_CHECKER IS NOT NULL AND tt.MAIN_CHECKER != '')
  303. </if>
  304. </if>
  305. <if test="taskStatusList != null and taskStatusList.size() > 0">
  306. AND btoir.TASK_STATUS IN
  307. <foreach collection="taskStatusList" item="taskStatus" open="(" separator="," close=")">
  308. #{taskStatus}
  309. </foreach>
  310. </if>
  311. <if test="unitCode != null and unitCode != ''">
  312. AND bto.UNIT_CODE LIKE CONCAT('%',#{unitCode},'%')
  313. </if>
  314. <if test="orderNo != null and orderNo != ''">
  315. AND bto.ORDER_NO LIKE CONCAT('%',#{orderNo},'%')
  316. </if>
  317. <if test="unitName != null and unitName != ''">
  318. AND bto.UNIT_NAME LIKE CONCAT('%',#{unitName},'%')
  319. </if>
  320. <if test="checkType != null and checkType != ''">
  321. AND bto.CHECK_TYPE = #{checkType}
  322. </if>
  323. <if test="deptId != null and deptId != ''">
  324. AND bto.DEPT_ID = #{deptId}
  325. </if>
  326. <if test="orderId != null and orderId != ''">
  327. AND bto.ID = #{orderId}
  328. </if>
  329. <if test="checkDate != null and checkDate.size() >= 2">
  330. AND bto.CHECK_DATE BETWEEN #{checkDate[0]} AND #{checkDate[1]}
  331. </if>
  332. <if test="mainCheckerIds != null and mainCheckerIds.size() > 0">
  333. AND tt.MAIN_CHECKER IN
  334. <foreach collection="mainCheckerIds" item="mainCheckerId" open="(" separator="," close=")">
  335. #{mainCheckerId}
  336. </foreach>
  337. </if>
  338. <if test="managerIds != null and managerIds.size() > 0">
  339. AND bto.MANAGER_ID IN
  340. <foreach collection="managerIds" item="managerId" open="(" separator="," close=")">
  341. #{managerId}
  342. </foreach>
  343. </if>
  344. <if test="checkUserIds != null and checkUserIds.size() > 0">
  345. AND bto.ID in (select ORDER_ID from PRESSURE2_PIPE_TASK_ORDER_USER where DELETED = 0 and USER_ID IN
  346. <foreach collection="checkUserIds" item="checkUserId" open="(" separator="," close=")">
  347. #{checkUserId}
  348. </foreach>
  349. )
  350. </if>
  351. <if test="permissionUserId != null and permissionUserId != ''">
  352. AND ( bto.MANAGER_ID = #{permissionUserId}
  353. or bto.ID in (select tu.ORDER_ID from pressure2_pipe_task_order_user tu
  354. where tu.deleted = 0 and tu.USER_ID = #{permissionUserId} ) )
  355. </if>
  356. <if test="permissionDeptIds != null and permissionDeptIds != ''">
  357. AND ( bto.DEPT_ID in
  358. <foreach close=")" collection="permissionDeptIds" item="listItem" open="(" separator=",">
  359. #{listItem}
  360. </foreach>
  361. )
  362. </if>
  363. <if test="hasPermission != null and hasPermission == false">
  364. AND 1 = 2
  365. </if>
  366. </where>
  367. group by tt.ID, bto.ID, bto.ORDER_NO, bto.UNIT_NAME, bto.CHECK_TYPE, btoir.TASK_STATUS,
  368. bto.CHECK_DATE, bto.MANAGER_ID, tt.MAIN_CHECKER, tt.END_CHECK_DATE, bto.CREATE_TIME
  369. <if test="projectNo != null and projectNo != ''">
  370. HAVING WM_CONCAT(epp.PROJECT_NO) LIKE CONCAT('%',#{projectNo},'%')
  371. </if>
  372. order by bto.CREATE_TIME desc
  373. ) a
  374. </select>
  375. <select id="selectPipesPage">
  376. select rownum,a.* from (
  377. select eb.id,eb.unit_code,eb.unit_name,eb.equip_street,eb.equip_district,
  378. eb.CONTACT,eb.CONTACT_PHONE,eb.USE_STATUS,eb.PIPE_ADDRESS,eb.RELATION_DEPT,
  379. eb.PROJECT_NO,eb.PROJECT_NAME,eb.NEXT_LEGAL_CHECK_DATE,
  380. eb.NEXT_YEAR_CHECK_DATE,eb.PIPE_CATEGORY
  381. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  382. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  383. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) plan_legal_check_date
  384. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  385. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  386. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) plan_year_check_date
  387. from PRESSURE2_EQUIP_PIPE eb
  388. <where>
  389. eb.deleted = 0
  390. <if test="unitName != null and unitName != ''">
  391. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  392. </if>
  393. <if test="unitCode != null">
  394. and eb.unit_code = #{unitCode}
  395. </if>
  396. <if test="unitAddress != null and unitAddress != ''">
  397. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{unitAddress},'%')
  398. </if>
  399. <if test="deptId != null and deptId != ''">
  400. AND eb.RELATION_DEPT = #{deptId}
  401. </if>
  402. <if test="equipStreet != null and equipStreet.size() > 0">
  403. AND eb.equip_street IN
  404. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  405. #{listItem}
  406. </foreach>
  407. </if>
  408. <if test="equipDistrict != null and equipDistrict.size() > 0">
  409. AND eb.equip_district IN
  410. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  411. #{listItem}
  412. </foreach>
  413. </if>
  414. <if test="nextDate != null and nextDate.size() >= 2">
  415. AND (
  416. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  417. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  418. )
  419. </if>
  420. <if test="typeList != null and typeList.size() > 0">
  421. AND eb.PIPE_CATEGORY IN
  422. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  423. #{listItem}
  424. </foreach>
  425. </if>
  426. <if test="useStatus != null and useStatus.size() > 0">
  427. AND eb.USE_STATUS IN
  428. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  429. #{listItem}
  430. </foreach>
  431. </if>
  432. <if test="orderId != null and orderId != ''">
  433. AND eb.ID IN (
  434. select EQUIP_ID from PRESSURE2_PIPE_TASK_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  435. )
  436. </if>
  437. <if test="notOrderId != null and notOrderId != ''">
  438. AND eb.ID NOT IN (
  439. select EQUIP_ID from PRESSURE2_PIPE_TASK_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  440. )
  441. </if>
  442. </where>
  443. ) a
  444. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  445. </select>
  446. <select id="selectPipesPageCount">
  447. select count(*) from (
  448. select eb.id,eb.unit_code,eb.unit_name,eb.equip_street,eb.equip_district,
  449. eb.CONTACT,eb.CONTACT_PHONE,eb.USE_STATUS,eb.PIPE_ADDRESS,eb.RELATION_DEPT,
  450. eb.PROJECT_NO,eb.PROJECT_NAME,eb.NEXT_LEGAL_CHECK_DATE,
  451. eb.NEXT_YEAR_CHECK_DATE,eb.PIPE_CATEGORY
  452. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  453. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  454. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) plan_legal_check_date
  455. ,(select a.PLAN_DATE from PRESSURE2_EQUIP_PIPE_SCHEDULING a
  456. left join PRESSURE2_EQUIP_PIPE_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
  457. where b.equip_id = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) plan_year_check_date
  458. from PRESSURE2_EQUIP_PIPE eb
  459. <where>
  460. eb.deleted = 0
  461. <if test="unitName != null and unitName != ''">
  462. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  463. </if>
  464. <if test="unitCode != null">
  465. and eb.unit_code = #{unitCode}
  466. </if>
  467. <if test="unitAddress != null and unitAddress != ''">
  468. AND eb.PIPE_ADDRESS LIKE CONCAT('%',#{unitAddress},'%')
  469. </if>
  470. <if test="deptId != null and deptId != ''">
  471. AND eb.RELATION_DEPT = #{deptId}
  472. </if>
  473. <if test="equipStreet != null and equipStreet.size() > 0">
  474. AND eb.equip_street IN
  475. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  476. #{listItem}
  477. </foreach>
  478. </if>
  479. <if test="equipDistrict != null and equipDistrict.size() > 0">
  480. AND eb.equip_district IN
  481. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  482. #{listItem}
  483. </foreach>
  484. </if>
  485. <if test="nextDate != null and nextDate.size() >= 2">
  486. AND (
  487. (eb.NEXT_LEGAL_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  488. OR (eb.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  489. )
  490. </if>
  491. <if test="typeList != null and typeList.size() > 0">
  492. AND eb.PIPE_CATEGORY IN
  493. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  494. #{listItem}
  495. </foreach>
  496. </if>
  497. <if test="useStatus != null and useStatus.size() > 0">
  498. AND eb.USE_STATUS IN
  499. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  500. #{listItem}
  501. </foreach>
  502. </if>
  503. <if test="orderId != null and orderId != ''">
  504. AND eb.ID IN (
  505. select EQUIP_ID from PRESSURE2_PIPE_TASK_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  506. )
  507. </if>
  508. <if test="notOrderId != null and notOrderId != ''">
  509. AND eb.ID NOT IN (
  510. select EQUIP_ID from PRESSURE2_PIPE_TASK_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  511. )
  512. </if>
  513. </where>
  514. ) a
  515. </select>
  516. </mapper>