EquipBoilerMapper.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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,eb.EQUIP_NAME,
  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.pending_inspection_remark,
  343. eb.related_department as dept_id,
  344. eb.use_time as use_date,
  345. eb.made_time as make_date,
  346. eb.area_type,
  347. eb.boiler_address as equip_address,
  348. eb.sbpzcode as equip_category,
  349. CASE
  350. WHEN #{checkType} = 100 THEN eb.next_in_check_date
  351. WHEN #{checkType} = 200 THEN eb.next_out_check_date
  352. WHEN #{checkType} = 300 THEN eb.next_pressure_check_date
  353. END AS next_check_date,
  354. eb.next_out_check_date as next_year_check_date,
  355. eb.max_continue_evapor as equip_volume,
  356. eb.factory_code as product_no,
  357. lto.task_order_id,
  358. lto.task_status,
  359. CASE WHEN lrfi.refuse_id IS NOT NULL THEN 1 ELSE 0 END AS is_refused,
  360. COALESCE(lrfi.check_type, 100) AS refuse_type,
  361. CASE
  362. WHEN lrfi.refuse_id IS NOT NULL THEN
  363. CASE
  364. WHEN lrfi.is_submit = 0 THEN 100
  365. WHEN lrfi.is_submit = 1 AND lrfi.status = 100 THEN 200
  366. WHEN lrfi.is_submit = 1 AND lrfi.status = 200 THEN 300
  367. WHEN lrfi.is_submit = 1 AND lrfi.status = 300 THEN 300
  368. ELSE 100
  369. END
  370. ELSE NULL
  371. END AS refuse_status,
  372. #{checkType} AS check_type,
  373. CASE
  374. WHEN #{checkType} = 100 THEN '内部检验'
  375. WHEN #{checkType} = 200 THEN '外部检验'
  376. WHEN #{checkType} = 300 THEN '耐压检验'
  377. END AS check_type_str
  378. FROM PRESSURE2_EQUIP_BOILER eb
  379. LEFT JOIN (
  380. SELECT
  381. toi.equip_id,
  382. to1.id AS task_order_id,
  383. to1.task_status,
  384. ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
  385. FROM PRESSURE2_BOILER_TASK_ORDER_ITEM toi
  386. INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
  387. WHERE to1.deleted = 0
  388. AND toi.deleted = 0
  389. AND to1.check_type = #{checkType}
  390. ) lto ON lto.equip_id = eb.id AND lto.rn = 1
  391. LEFT JOIN (
  392. SELECT
  393. roi.id AS refuse_id,
  394. roi.equip_id,
  395. roi.check_type,
  396. roi.is_submit,
  397. roi.status,
  398. roi.report_city_status,
  399. ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
  400. FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
  401. WHERE roi.deleted = 0
  402. AND roi.check_type = #{checkType}
  403. ) lrfi ON lrfi.equip_id = eb.id AND lrfi.rn = 1
  404. <where>
  405. eb.deleted = 0
  406. AND eb.use_register_no is not null
  407. AND eb.use_register_no not in ('未办证', '未领证')
  408. AND eb.use_register_no != ''
  409. <choose>
  410. <when test="checkType == 100">
  411. AND (
  412. eb.next_in_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  413. <if test="showNoCheckDate != null and showNoCheckDate">
  414. OR eb.next_in_check_date IS NULL
  415. </if>
  416. )
  417. </when>
  418. <when test="checkType == 200">
  419. AND (
  420. eb.next_out_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  421. <if test="showNoCheckDate != null and showNoCheckDate">
  422. OR eb.next_out_check_date IS NULL
  423. </if>
  424. )
  425. </when>
  426. <when test="checkType == 300">
  427. AND (
  428. eb.next_pressure_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  429. <if test="showNoCheckDate != null and showNoCheckDate">
  430. OR eb.next_pressure_check_date IS NULL
  431. </if>
  432. )
  433. </when>
  434. </choose>
  435. AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
  436. AND NOT (
  437. lrfi.refuse_id IS NOT NULL
  438. AND lrfi.is_submit = 1
  439. AND lrfi.status = 200
  440. AND lrfi.report_city_status = 200
  441. )
  442. <if test="ids != null and ids.size() > 0">
  443. AND eb.id IN
  444. <foreach collection="ids" item="id" open="(" separator="," close=")">
  445. #{id}
  446. </foreach>
  447. </if>
  448. <if test="type != null and type != ''">
  449. AND eb.type = #{type}
  450. </if>
  451. <if test="productNo != null and productNo != ''">
  452. AND eb.product_code LIKE CONCAT('%', #{productNo}, '%')
  453. </if>
  454. <if test="contactPhone != null and contactPhone != ''">
  455. AND eb.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
  456. </if>
  457. <if test="unitCode != null and unitCode != ''">
  458. AND eb.unit_code = #{unitCode}
  459. </if>
  460. <if test="unitId != null and unitId != ''">
  461. AND eb.unit_id = #{unitId}
  462. </if>
  463. <if test="unitName != null and unitName != ''">
  464. AND eb.unit_name LIKE CONCAT('%', #{unitName}, '%')
  465. </if>
  466. <if test="equipDistrict != null">
  467. AND eb.equip_district = #{equipDistrict}
  468. </if>
  469. <if test="equipDistricts != null and equipDistricts.size() > 0">
  470. AND eb.equip_district IN
  471. <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
  472. #{district}
  473. </foreach>
  474. </if>
  475. <if test="showNoDistrict == null or !showNoDistrict">
  476. AND eb.equip_district IS NOT NULL
  477. </if>
  478. <if test="equipStreet != null">
  479. AND eb.equip_street = #{equipStreet}
  480. </if>
  481. <if test="status != null and status != ''">
  482. AND eb.status = #{status}
  483. </if>
  484. <if test="statusList != null and statusList.size() > 0">
  485. AND eb.status IN
  486. <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
  487. #{listItem}
  488. </foreach>
  489. </if>
  490. <if test="equipCode != null and equipCode != ''">
  491. AND eb.equip_code LIKE CONCAT('%', #{equipCode}, '%')
  492. </if>
  493. <if test="equipType != null and equipType != ''">
  494. AND eb.type = #{equipType}
  495. </if>
  496. <if test="equipTypeList != null and equipTypeList.size() > 0">
  497. AND eb.type IN
  498. <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
  499. #{listItem}
  500. </foreach>
  501. </if>
  502. <if test="useRegisterNo != null and useRegisterNo != ''">
  503. AND eb.use_register_no LIKE CONCAT('%', #{useRegisterNo}, '%')
  504. </if>
  505. <if test="deptId != null and deptId != ''">
  506. AND eb.related_department = #{deptId}
  507. </if>
  508. <if test="isRefused != null">
  509. <choose>
  510. <when test="isRefused">
  511. AND lrfi.refuse_id IS NOT NULL
  512. </when>
  513. <otherwise>
  514. AND lrfi.refuse_id IS NULL
  515. </otherwise>
  516. </choose>
  517. </if>
  518. </where>
  519. ORDER BY
  520. CASE #{checkType}
  521. WHEN 100 THEN eb.next_in_check_date
  522. WHEN 200 THEN eb.next_out_check_date
  523. WHEN 300 THEN eb.next_pressure_check_date
  524. END ASC NULLS LAST
  525. OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
  526. </select>
  527. <select id="selectPendingInspectionBoilerCount" resultType="java.lang.Long">
  528. SELECT COUNT(1)
  529. FROM PRESSURE2_EQUIP_BOILER eb
  530. LEFT JOIN (
  531. SELECT
  532. toi.equip_id,
  533. to1.id AS task_order_id,
  534. to1.task_status,
  535. ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
  536. FROM PRESSURE2_BOILER_TASK_ORDER_ITEM toi
  537. INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
  538. WHERE to1.deleted = 0
  539. AND toi.deleted = 0
  540. AND to1.check_type = #{checkType}
  541. ) lto ON lto.equip_id = eb.id AND lto.rn = 1
  542. LEFT JOIN (
  543. SELECT
  544. roi.id AS refuse_id,
  545. roi.equip_id,
  546. roi.check_type,
  547. roi.is_submit,
  548. roi.status,
  549. roi.report_city_status,
  550. ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
  551. FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
  552. WHERE roi.deleted = 0
  553. AND roi.check_type = #{checkType}
  554. ) lrfi ON lrfi.equip_id = eb.id AND lrfi.rn = 1
  555. <where>
  556. eb.deleted = 0
  557. AND eb.use_register_no is not null
  558. AND eb.use_register_no not in ('未办证', '未领证')
  559. AND eb.use_register_no != ''
  560. <choose>
  561. <when test="checkType == 100">
  562. AND (
  563. eb.next_in_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  564. <if test="showNoCheckDate != null and showNoCheckDate">
  565. OR eb.next_in_check_date IS NULL
  566. </if>
  567. )
  568. </when>
  569. <when test="checkType == 200">
  570. AND (
  571. eb.next_out_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  572. <if test="showNoCheckDate != null and showNoCheckDate">
  573. OR eb.next_out_check_date IS NULL
  574. </if>
  575. )
  576. </when>
  577. <when test="checkType == 300">
  578. AND (
  579. eb.next_pressure_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
  580. <if test="showNoCheckDate != null and showNoCheckDate">
  581. OR eb.next_pressure_check_date IS NULL
  582. </if>
  583. )
  584. </when>
  585. </choose>
  586. AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
  587. AND NOT (
  588. lrfi.refuse_id IS NOT NULL
  589. AND lrfi.is_submit = 1
  590. AND lrfi.status = 200
  591. AND lrfi.report_city_status = 200
  592. )
  593. <if test="ids != null and ids.size() > 0">
  594. AND eb.id IN
  595. <foreach collection="ids" item="id" open="(" separator="," close=")">
  596. #{id}
  597. </foreach>
  598. </if>
  599. <if test="type != null and type != ''">
  600. AND eb.type = #{type}
  601. </if>
  602. <if test="productNo != null and productNo != ''">
  603. AND eb.product_code LIKE CONCAT('%', #{productNo}, '%')
  604. </if>
  605. <if test="contactPhone != null and contactPhone != ''">
  606. AND eb.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
  607. </if>
  608. <if test="unitCode != null and unitCode != ''">
  609. AND eb.unit_code = #{unitCode}
  610. </if>
  611. <if test="unitId != null and unitId != ''">
  612. AND eb.unit_id = #{unitId}
  613. </if>
  614. <if test="unitName != null and unitName != ''">
  615. AND eb.unit_name LIKE CONCAT('%', #{unitName}, '%')
  616. </if>
  617. <if test="equipDistrict != null">
  618. AND eb.equip_district = #{equipDistrict}
  619. </if>
  620. <if test="equipDistricts != null and equipDistricts.size() > 0">
  621. AND eb.equip_district IN
  622. <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
  623. #{district}
  624. </foreach>
  625. </if>
  626. <if test="showNoDistrict == null or !showNoDistrict">
  627. AND eb.equip_district IS NOT NULL
  628. </if>
  629. <if test="equipStreet != null">
  630. AND eb.equip_street = #{equipStreet}
  631. </if>
  632. <if test="status != null and status != ''">
  633. AND eb.status = #{status}
  634. </if>
  635. <if test="statusList != null and statusList.size() > 0">
  636. AND eb.status IN
  637. <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
  638. #{listItem}
  639. </foreach>
  640. </if>
  641. <if test="equipCode != null and equipCode != ''">
  642. AND eb.equip_code LIKE CONCAT('%', #{equipCode}, '%')
  643. </if>
  644. <if test="equipType != null and equipType != ''">
  645. AND eb.type = #{equipType}
  646. </if>
  647. <if test="equipTypeList != null and equipTypeList.size() > 0">
  648. AND eb.type IN
  649. <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
  650. #{listItem}
  651. </foreach>
  652. </if>
  653. <if test="useRegisterNo != null and useRegisterNo != ''">
  654. AND eb.use_register_no LIKE CONCAT('%', #{useRegisterNo}, '%')
  655. </if>
  656. <if test="deptId != null and deptId != ''">
  657. AND eb.related_department = #{deptId}
  658. </if>
  659. <if test="isRefused != null">
  660. <choose>
  661. <when test="isRefused">
  662. AND lrfi.refuse_id IS NOT NULL
  663. </when>
  664. <otherwise>
  665. AND lrfi.refuse_id IS NULL
  666. </otherwise>
  667. </choose>
  668. </if>
  669. </where>
  670. </select>
  671. </mapper>