EquipBoilerMapper.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  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.equipboiler.EquipBoilerMapper">
  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. select rownum,a.* from (
  12. select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,USE_STATUS as status,
  13. TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
  14. FACTORY_CODE,
  15. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  16. left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  17. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) plan_in_check_date,
  18. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  19. left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  20. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) plan_out_check_date,
  21. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  22. left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  23. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 300 limit 1) plan_pressure_check_date
  24. from PRESSURE2_EQUIP_BOILER eb
  25. <where>
  26. eb.deleted = 0
  27. <if test="unitName != null and unitName != ''">
  28. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  29. </if>
  30. <if test="unitCode != null and unitCode != ''">
  31. and eb.unit_code = #{unitCode}
  32. </if>
  33. <if test="unitAddress != null and unitAddress != ''">
  34. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  35. </if>
  36. <if test="equipCode != null and equipCode != ''">
  37. AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
  38. </if>
  39. <if test="relateDepartment != null and relateDepartment != ''">
  40. AND eb.RELATED_DEPARTMENT = #{relateDepartment}
  41. </if>
  42. <if test="equipStreet != null and equipStreet.size() > 0">
  43. AND eb.equip_street IN
  44. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  45. #{listItem}
  46. </foreach>
  47. </if>
  48. <if test="equipDistrict != null and equipDistrict.size() > 0">
  49. AND eb.equip_district IN
  50. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  51. #{listItem}
  52. </foreach>
  53. </if>
  54. <if test="nextDate != null and nextDate.size() >= 2">
  55. AND (
  56. (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  57. OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  58. OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  59. )
  60. </if>
  61. <if test="typeList != null and typeList.size() > 0">
  62. AND eb.type IN
  63. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  64. #{listItem}
  65. </foreach>
  66. </if>
  67. <if test="useStatus != null and useStatus.size() > 0">
  68. AND eb.USE_STATUS IN
  69. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  70. #{listItem}
  71. </foreach>
  72. </if>
  73. <if test="orderId != null and orderId != ''">
  74. AND eb.ID IN (
  75. select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  76. )
  77. </if>
  78. <if test="notOrderId != null and notOrderId != ''">
  79. AND eb.ID NOT IN (
  80. select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  81. )
  82. </if>
  83. </where>
  84. ) a
  85. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  86. </select>
  87. <select id="selectAppointmentItemPageCount">
  88. select count(1) from (
  89. select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,STATUS,
  90. TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
  91. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  92. left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  93. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) plan_in_check_date,
  94. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  95. left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  96. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) plan_out_check_date,
  97. (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
  98. left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
  99. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 300 limit 1) plan_pressure_check_date
  100. from PRESSURE2_EQUIP_BOILER eb
  101. <where>
  102. eb.deleted = 0
  103. <if test="unitName != null and unitName != ''">
  104. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  105. </if>
  106. <if test="unitCode != null and unitCode != ''">
  107. and eb.unit_code = #{unitCode}
  108. </if>
  109. <if test="unitAddress != null and unitAddress != ''">
  110. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  111. </if>
  112. <if test="equipCode != null and equipCode != ''">
  113. AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
  114. </if>
  115. <if test="relateDepartment != null and relateDepartment != ''">
  116. AND eb.RELATED_DEPARTMENT = #{relateDepartment}
  117. </if>
  118. <if test="equipStreet != null and equipStreet.size() > 0">
  119. AND eb.equip_street IN
  120. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  121. #{listItem}
  122. </foreach>
  123. </if>
  124. <if test="equipDistrict != null and equipDistrict.size() > 0">
  125. AND eb.equip_district IN
  126. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  127. #{listItem}
  128. </foreach>
  129. </if>
  130. <if test="nextDate != null and nextDate.size() >= 2">
  131. AND (
  132. (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  133. OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  134. OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  135. )
  136. </if>
  137. <if test="typeList != null and typeList.size() > 0">
  138. AND eb.type IN
  139. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  140. #{listItem}
  141. </foreach>
  142. </if>
  143. <if test="orderId != null and orderId != ''">
  144. AND eb.ID IN (
  145. select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  146. )
  147. </if>
  148. <if test="useStatus != null and useStatus.size() > 0">
  149. AND eb.USE_STATUS IN
  150. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  151. #{listItem}
  152. </foreach>
  153. </if>
  154. <if test="notOrderId != null and notOrderId != ''">
  155. AND eb.ID NOT IN (
  156. select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  157. )
  158. </if>
  159. <if test="factoryCode != null and factoryCode != ''">
  160. AND eb.FACTORY_CODE like CONCAT('%',#{factoryCode},'%')
  161. </if>
  162. </where>
  163. ) a
  164. </select>
  165. <select id="selectAcceptItemPage">
  166. select rownum,a.* from (
  167. select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,USE_STATUS as STATUS,
  168. TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
  169. FACTORY_CODE,
  170. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  171. left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  172. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) plan_in_check_date,
  173. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  174. left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  175. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) plan_out_check_date,
  176. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  177. left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  178. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 300 limit 1) plan_pressure_check_date
  179. from PRESSURE2_EQUIP_BOILER 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="relateDepartment != null and relateDepartment != ''">
  195. AND eb.RELATED_DEPARTMENT = #{relateDepartment}
  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.type 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_BOILER_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_BOILER_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,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,STATUS,
  248. TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
  249. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  250. left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  251. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) plan_in_check_date,
  252. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  253. left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  254. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) plan_out_check_date,
  255. (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
  256. left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
  257. where b.EQUIP_ID = eb.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 300 limit 1) plan_pressure_check_date
  258. from PRESSURE2_EQUIP_BOILER eb
  259. <where>
  260. eb.deleted = 0
  261. <if test="unitName != null and unitName != ''">
  262. AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
  263. </if>
  264. <if test="unitCode != null and unitCode != ''">
  265. and eb.unit_code = #{unitCode}
  266. </if>
  267. <if test="unitAddress != null and unitAddress != ''">
  268. AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
  269. </if>
  270. <if test="equipCode != null and equipCode != ''">
  271. AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
  272. </if>
  273. <if test="relateDepartment != null and relateDepartment != ''">
  274. AND eb.RELATED_DEPARTMENT = #{relateDepartment}
  275. </if>
  276. <if test="equipStreet != null and equipStreet.size() > 0">
  277. AND eb.equip_street IN
  278. <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
  279. #{listItem}
  280. </foreach>
  281. </if>
  282. <if test="equipDistrict != null and equipDistrict.size() > 0">
  283. AND eb.equip_district IN
  284. <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
  285. #{listItem}
  286. </foreach>
  287. </if>
  288. <if test="nextDate != null and nextDate.size() >= 2">
  289. AND (
  290. (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  291. OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  292. OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
  293. )
  294. </if>
  295. <if test="typeList != null and typeList.size() > 0">
  296. AND eb.type IN
  297. <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
  298. #{listItem}
  299. </foreach>
  300. </if>
  301. <if test="orderId != null and orderId != ''">
  302. AND eb.ID IN (
  303. select EQUIP_ID from PRESSURE2_BOILER_ACCEPT_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
  304. )
  305. </if>
  306. <if test="notOrderId != null and notOrderId != ''">
  307. AND eb.ID NOT IN (
  308. select EQUIP_ID from PRESSURE2_BOILER_ACCEPT_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
  309. )
  310. </if>
  311. <if test="useStatus != null and useStatus.size() > 0">
  312. AND eb.USE_STATUS IN
  313. <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
  314. #{listItem}
  315. </foreach>
  316. </if>
  317. </where>
  318. ) a
  319. </select>
  320. <select id="selectDetailsById">
  321. select * from PRESSURE2_EQUIP_BOILER where ID = #{id}
  322. </select>
  323. <select id="selectPendingInspectionBoilerPage"
  324. resultType="cn.start.tz.module.pressure2.controller.admin.planscheduling.vo.EquipBoilerPageRespVO">
  325. SELECT
  326. eb.id,
  327. eb.type,
  328. eb.type as equip_type,
  329. eb.unit_code,
  330. eb.unit_id,
  331. eb.unit_name,
  332. eb.unit_address,
  333. eb.equip_district,
  334. eb.equip_street,
  335. eb.status,
  336. eb.equip_code,
  337. eb.equip_name,
  338. eb.use_register_no,
  339. eb.product_code,
  340. eb.contact,
  341. eb.contact_phone,
  342. eb.related_department as dept_id,
  343. eb.use_time as use_date,
  344. eb.made_time as make_date,
  345. eb.area_type,
  346. eb.boiler_address as equip_address,
  347. eb.sbpzcode as equip_category,
  348. CASE
  349. WHEN #{checkType} = 100 THEN eb.next_in_check_date
  350. WHEN #{checkType} = 200 THEN eb.next_out_check_date
  351. WHEN #{checkType} = 300 THEN eb.next_pressure_check_date
  352. END AS next_check_date,
  353. eb.next_out_check_date as next_year_check_date,
  354. eb.max_continue_evapor as equip_volume,
  355. eb.factory_code as product_no,
  356. lto.task_order_id,
  357. lto.task_status,
  358. CASE WHEN lrfi.refuse_id IS NOT NULL THEN 1 ELSE 0 END AS is_refused,
  359. COALESCE(lrfi.check_type, 100) AS refuse_type,
  360. CASE
  361. WHEN lrfi.refuse_id IS NOT NULL THEN
  362. CASE
  363. WHEN lrfi.is_submit = 0 THEN 100
  364. WHEN lrfi.is_submit = 1 AND lrfi.status = 100 THEN 200
  365. WHEN lrfi.is_submit = 1 AND lrfi.status = 200 THEN 300
  366. WHEN lrfi.is_submit = 1 AND lrfi.status = 300 THEN 300
  367. ELSE 100
  368. END
  369. ELSE NULL
  370. END AS refuse_status,
  371. #{checkType} AS check_type,
  372. CASE
  373. WHEN #{checkType} = 100 THEN '内部检验'
  374. WHEN #{checkType} = 200 THEN '外部检验'
  375. WHEN #{checkType} = 300 THEN '耐压检验'
  376. END AS check_type_str
  377. FROM PRESSURE2_EQUIP_BOILER eb
  378. LEFT JOIN (
  379. SELECT
  380. toi.equip_id,
  381. to1.id AS task_order_id,
  382. to1.task_status,
  383. ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
  384. FROM PRESSURE2_BOILER_TASK_ORDER_ITEM toi
  385. INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
  386. WHERE to1.deleted = 0
  387. AND toi.deleted = 0
  388. AND to1.check_type = #{checkType}
  389. ) lto ON lto.equip_id = eb.id AND lto.rn = 1
  390. LEFT JOIN (
  391. SELECT
  392. roi.id AS refuse_id,
  393. roi.equip_id,
  394. roi.check_type,
  395. roi.is_submit,
  396. roi.status,
  397. roi.report_city_status,
  398. ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
  399. FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
  400. WHERE roi.deleted = 0
  401. AND roi.check_type = #{checkType}
  402. ) lrfi ON lrfi.equip_id = eb.id AND lrfi.rn = 1
  403. <where>
  404. eb.deleted = 0
  405. AND eb.use_register_no is not null
  406. AND eb.use_register_no not in ('未办证', '未领证')
  407. AND eb.use_register_no != ''
  408. <choose>
  409. <when test="checkType == 100">
  410. AND (
  411. eb.next_in_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  412. <if test="showNoCheckDate != null and showNoCheckDate">
  413. OR eb.next_in_check_date IS NULL
  414. </if>
  415. )
  416. </when>
  417. <when test="checkType == 200">
  418. AND (
  419. eb.next_out_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  420. <if test="showNoCheckDate != null and showNoCheckDate">
  421. OR eb.next_out_check_date IS NULL
  422. </if>
  423. )
  424. </when>
  425. <when test="checkType == 300">
  426. AND (
  427. eb.next_pressure_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  428. <if test="showNoCheckDate != null and showNoCheckDate">
  429. OR eb.next_pressure_check_date IS NULL
  430. </if>
  431. )
  432. </when>
  433. </choose>
  434. AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
  435. AND NOT (
  436. lrfi.refuse_id IS NOT NULL
  437. AND lrfi.is_submit = 1
  438. AND lrfi.status = 200
  439. AND lrfi.report_city_status = 200
  440. )
  441. <if test="ids != null and ids.size() > 0">
  442. AND eb.id IN
  443. <foreach collection="ids" item="id" open="(" separator="," close=")">
  444. #{id}
  445. </foreach>
  446. </if>
  447. <if test="type != null and type != ''">
  448. AND eb.type = #{type}
  449. </if>
  450. <if test="productNo != null and productNo != ''">
  451. AND eb.product_code LIKE CONCAT('%', #{productNo}, '%')
  452. </if>
  453. <if test="contactPhone != null and contactPhone != ''">
  454. AND eb.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
  455. </if>
  456. <if test="unitCode != null and unitCode != ''">
  457. AND eb.unit_code = #{unitCode}
  458. </if>
  459. <if test="unitId != null and unitId != ''">
  460. AND eb.unit_id = #{unitId}
  461. </if>
  462. <if test="unitName != null and unitName != ''">
  463. AND eb.unit_name LIKE CONCAT('%', #{unitName}, '%')
  464. </if>
  465. <if test="equipDistrict != null">
  466. AND eb.equip_district = #{equipDistrict}
  467. </if>
  468. <if test="equipDistricts != null and equipDistricts.size() > 0">
  469. AND eb.equip_district IN
  470. <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
  471. #{district}
  472. </foreach>
  473. </if>
  474. <if test="showNoDistrict == null or !showNoDistrict">
  475. AND eb.equip_district IS NOT NULL
  476. </if>
  477. <if test="equipStreet != null">
  478. AND eb.equip_street = #{equipStreet}
  479. </if>
  480. <if test="status != null and status != ''">
  481. AND eb.status = #{status}
  482. </if>
  483. <if test="statusList != null and statusList.size() > 0">
  484. AND eb.status IN
  485. <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
  486. #{listItem}
  487. </foreach>
  488. </if>
  489. <if test="equipCode != null and equipCode != ''">
  490. AND eb.equip_code LIKE CONCAT('%', #{equipCode}, '%')
  491. </if>
  492. <if test="equipType != null and equipType != ''">
  493. AND eb.type = #{equipType}
  494. </if>
  495. <if test="equipTypeList != null and equipTypeList.size() > 0">
  496. AND eb.type IN
  497. <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
  498. #{listItem}
  499. </foreach>
  500. </if>
  501. <if test="useRegisterNo != null and useRegisterNo != ''">
  502. AND eb.use_register_no LIKE CONCAT('%', #{useRegisterNo}, '%')
  503. </if>
  504. <if test="deptId != null and deptId != ''">
  505. AND eb.related_department = #{deptId}
  506. </if>
  507. <if test="isRefused != null">
  508. <choose>
  509. <when test="isRefused">
  510. AND lrfi.refuse_id IS NOT NULL
  511. </when>
  512. <otherwise>
  513. AND lrfi.refuse_id IS NULL
  514. </otherwise>
  515. </choose>
  516. </if>
  517. </where>
  518. ORDER BY
  519. CASE #{checkType}
  520. WHEN 100 THEN eb.next_in_check_date
  521. WHEN 200 THEN eb.next_out_check_date
  522. WHEN 300 THEN eb.next_pressure_check_date
  523. END ASC NULLS LAST
  524. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  525. </select>
  526. <select id="selectPendingInspectionBoilerCount" resultType="java.lang.Long">
  527. SELECT COUNT(1)
  528. FROM PRESSURE2_EQUIP_BOILER eb
  529. LEFT JOIN (
  530. SELECT
  531. toi.equip_id,
  532. to1.id AS task_order_id,
  533. to1.task_status,
  534. ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
  535. FROM PRESSURE2_BOILER_TASK_ORDER_ITEM toi
  536. INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
  537. WHERE to1.deleted = 0
  538. AND toi.deleted = 0
  539. AND to1.check_type = #{checkType}
  540. ) lto ON lto.equip_id = eb.id AND lto.rn = 1
  541. LEFT JOIN (
  542. SELECT
  543. roi.id AS refuse_id,
  544. roi.equip_id,
  545. roi.check_type,
  546. roi.is_submit,
  547. roi.status,
  548. roi.report_city_status,
  549. ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
  550. FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
  551. WHERE roi.deleted = 0
  552. AND roi.check_type = #{checkType}
  553. ) lrfi ON lrfi.equip_id = eb.id AND lrfi.rn = 1
  554. <where>
  555. eb.deleted = 0
  556. AND eb.use_register_no is not null
  557. AND eb.use_register_no not in ('未办证', '未领证')
  558. AND eb.use_register_no != ''
  559. <choose>
  560. <when test="checkType == 100">
  561. AND (
  562. eb.next_in_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  563. <if test="showNoCheckDate != null and showNoCheckDate">
  564. OR eb.next_in_check_date IS NULL
  565. </if>
  566. )
  567. </when>
  568. <when test="checkType == 200">
  569. AND (
  570. eb.next_out_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  571. <if test="showNoCheckDate != null and showNoCheckDate">
  572. OR eb.next_out_check_date IS NULL
  573. </if>
  574. )
  575. </when>
  576. <when test="checkType == 300">
  577. AND (
  578. eb.next_pressure_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  579. <if test="showNoCheckDate != null and showNoCheckDate">
  580. OR eb.next_pressure_check_date IS NULL
  581. </if>
  582. )
  583. </when>
  584. </choose>
  585. AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
  586. AND NOT (
  587. lrfi.refuse_id IS NOT NULL
  588. AND lrfi.is_submit = 1
  589. AND lrfi.status = 200
  590. AND lrfi.report_city_status = 200
  591. )
  592. <if test="ids != null and ids.size() > 0">
  593. AND eb.id IN
  594. <foreach collection="ids" item="id" open="(" separator="," close=")">
  595. #{id}
  596. </foreach>
  597. </if>
  598. <if test="type != null and type != ''">
  599. AND eb.type = #{type}
  600. </if>
  601. <if test="productNo != null and productNo != ''">
  602. AND eb.product_code LIKE CONCAT('%', #{productNo}, '%')
  603. </if>
  604. <if test="contactPhone != null and contactPhone != ''">
  605. AND eb.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
  606. </if>
  607. <if test="unitCode != null and unitCode != ''">
  608. AND eb.unit_code = #{unitCode}
  609. </if>
  610. <if test="unitId != null and unitId != ''">
  611. AND eb.unit_id = #{unitId}
  612. </if>
  613. <if test="unitName != null and unitName != ''">
  614. AND eb.unit_name LIKE CONCAT('%', #{unitName}, '%')
  615. </if>
  616. <if test="equipDistrict != null">
  617. AND eb.equip_district = #{equipDistrict}
  618. </if>
  619. <if test="equipDistricts != null and equipDistricts.size() > 0">
  620. AND eb.equip_district IN
  621. <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
  622. #{district}
  623. </foreach>
  624. </if>
  625. <if test="showNoDistrict == null or !showNoDistrict">
  626. AND eb.equip_district IS NOT NULL
  627. </if>
  628. <if test="equipStreet != null">
  629. AND eb.equip_street = #{equipStreet}
  630. </if>
  631. <if test="status != null and status != ''">
  632. AND eb.status = #{status}
  633. </if>
  634. <if test="statusList != null and statusList.size() > 0">
  635. AND eb.status IN
  636. <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
  637. #{listItem}
  638. </foreach>
  639. </if>
  640. <if test="equipCode != null and equipCode != ''">
  641. AND eb.equip_code LIKE CONCAT('%', #{equipCode}, '%')
  642. </if>
  643. <if test="equipType != null and equipType != ''">
  644. AND eb.type = #{equipType}
  645. </if>
  646. <if test="equipTypeList != null and equipTypeList.size() > 0">
  647. AND eb.type IN
  648. <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
  649. #{listItem}
  650. </foreach>
  651. </if>
  652. <if test="useRegisterNo != null and useRegisterNo != ''">
  653. AND eb.use_register_no LIKE CONCAT('%', #{useRegisterNo}, '%')
  654. </if>
  655. <if test="deptId != null and deptId != ''">
  656. AND eb.related_department = #{deptId}
  657. </if>
  658. <if test="isRefused != null">
  659. <choose>
  660. <when test="isRefused">
  661. AND lrfi.refuse_id IS NOT NULL
  662. </when>
  663. <otherwise>
  664. AND lrfi.refuse_id IS NULL
  665. </otherwise>
  666. </choose>
  667. </if>
  668. </where>
  669. </select>
  670. </mapper>