| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="cn.start.tz.module.pressure2.dal.mysql.equipboiler.EquipBoilerMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <select id="selectAppointmentItemPage">
- select rownum,a.* from (
- select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,USE_STATUS as status,
- TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
- FACTORY_CODE,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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
- from PRESSURE2_EQUIP_BOILER eb
- <where>
- eb.deleted = 0
- <if test="unitName != null and unitName != ''">
- AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
- </if>
- <if test="unitCode != null and unitCode != ''">
- and eb.unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null and unitAddress != ''">
- AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
- </if>
- <if test="equipCode != null and equipCode != ''">
- AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
- </if>
- <if test="relateDepartment != null and relateDepartment != ''">
- AND eb.RELATED_DEPARTMENT = #{relateDepartment}
- </if>
- <if test="equipStreet != null and equipStreet.size() > 0">
- AND eb.equip_street IN
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- AND eb.equip_district IN
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size() >= 2">
- AND (
- (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- )
- </if>
- <if test="typeList != null and typeList.size() > 0">
- AND eb.type IN
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="useStatus != null and useStatus.size() > 0">
- AND eb.USE_STATUS IN
- <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="orderId != null and orderId != ''">
- AND eb.ID IN (
- select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
- )
- </if>
- <if test="notOrderId != null and notOrderId != ''">
- AND eb.ID NOT IN (
- select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
- )
- </if>
- </where>
- ) a
- OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
- </select>
- <select id="selectAppointmentItemPageCount">
- select count(1) from (
- select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,STATUS,
- TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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
- from PRESSURE2_EQUIP_BOILER eb
- <where>
- eb.deleted = 0
- <if test="unitName != null and unitName != ''">
- AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
- </if>
- <if test="unitCode != null and unitCode != ''">
- and eb.unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null and unitAddress != ''">
- AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
- </if>
- <if test="equipCode != null and equipCode != ''">
- AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
- </if>
- <if test="relateDepartment != null and relateDepartment != ''">
- AND eb.RELATED_DEPARTMENT = #{relateDepartment}
- </if>
- <if test="equipStreet != null and equipStreet.size() > 0">
- AND eb.equip_street IN
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- AND eb.equip_district IN
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size() >= 2">
- AND (
- (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- )
- </if>
- <if test="typeList != null and typeList.size() > 0">
- AND eb.type IN
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="orderId != null and orderId != ''">
- AND eb.ID IN (
- select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
- )
- </if>
- <if test="useStatus != null and useStatus.size() > 0">
- AND eb.USE_STATUS IN
- <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="notOrderId != null and notOrderId != ''">
- AND eb.ID NOT IN (
- select EQUIP_ID from PRESSURE2_BOILER_APPOINTMENT_CONFIRM_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
- )
- </if>
- <if test="factoryCode != null and factoryCode != ''">
- AND eb.FACTORY_CODE like CONCAT('%',#{factoryCode},'%')
- </if>
- </where>
- ) a
- </select>
- <select id="selectAcceptItemPage">
- select rownum,a.* from (
- select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,USE_STATUS as STATUS,
- TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
- FACTORY_CODE,
- (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
- left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
- left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
- left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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
- from PRESSURE2_EQUIP_BOILER eb
- <where>
- eb.deleted = 0
- <if test="unitName != null and unitName != ''">
- AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
- </if>
- <if test="unitCode != null and unitCode != ''">
- and eb.unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null and unitAddress != ''">
- AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
- </if>
- <if test="equipCode != null and equipCode != ''">
- AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
- </if>
- <if test="relateDepartment != null and relateDepartment != ''">
- AND eb.RELATED_DEPARTMENT = #{relateDepartment}
- </if>
- <if test="equipStreet != null and equipStreet.size() > 0">
- AND eb.equip_street IN
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- AND eb.equip_district IN
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size() >= 2">
- AND (
- (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- )
- </if>
- <if test="typeList != null and typeList.size() > 0">
- AND eb.type IN
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="orderId != null and orderId != ''">
- AND eb.ID IN (
- select EQUIP_ID from PRESSURE2_BOILER_ACCEPT_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
- )
- </if>
- <if test="notOrderId != null and notOrderId != ''">
- AND eb.ID NOT IN (
- select EQUIP_ID from PRESSURE2_BOILER_ACCEPT_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
- )
- </if>
- <if test="factoryCode != null and factoryCode != ''">
- AND eb.FACTORY_CODE like CONCAT('%',#{factoryCode},'%')
- </if>
- <if test="useStatus != null and useStatus.size() > 0">
- AND eb.USE_STATUS IN
- <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- </where>
- ) a
- OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
- </select>
- <select id="selectAcceptItemPageCount">
- select count(1) from (
- select id,unit_code,unit_name,equip_code,equip_street ,equip_district ,USE_REGISTER_NO,CONTACT,CONTACT_PHONE,STATUS,
- TONNAGE,PRODUCT_CODE,MAX_CONTINUE_EVAPOR,NEXT_IN_CHECK_DATE,NEXT_OUT_CHECK_DATE,NEXT_PRESSURE_CHECK_DATE,BOILER_MODEL,
- (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
- left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
- left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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,
- (select a.APPOINTMENT_DATE from PRESSURE_ACCEPT_ORDER a
- left join PRESSURE2_BOILER_ACCEPT_ORDER_ITEM b on a.ID = b.ORDER_ID
- 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
- from PRESSURE2_EQUIP_BOILER eb
- <where>
- eb.deleted = 0
- <if test="unitName != null and unitName != ''">
- AND eb.unit_name LIKE CONCAT('%',#{unitName},'%')
- </if>
- <if test="unitCode != null and unitCode != ''">
- and eb.unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null and unitAddress != ''">
- AND eb.unit_address LIKE CONCAT('%',#{unitAddress},'%')
- </if>
- <if test="equipCode != null and equipCode != ''">
- AND eb.equip_code LIKE CONCAT('%',#{equipCode},'%')
- </if>
- <if test="relateDepartment != null and relateDepartment != ''">
- AND eb.RELATED_DEPARTMENT = #{relateDepartment}
- </if>
- <if test="equipStreet != null and equipStreet.size() > 0">
- AND eb.equip_street IN
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- AND eb.equip_district IN
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size() >= 2">
- AND (
- (eb.NEXT_IN_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_OUT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (eb.NEXT_PRESSURE_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- )
- </if>
- <if test="typeList != null and typeList.size() > 0">
- AND eb.type IN
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="orderId != null and orderId != ''">
- AND eb.ID IN (
- select EQUIP_ID from PRESSURE2_BOILER_ACCEPT_ORDER_ITEM where ORDER_ID = #{orderId} and DELETED = 0
- )
- </if>
- <if test="notOrderId != null and notOrderId != ''">
- AND eb.ID NOT IN (
- select EQUIP_ID from PRESSURE2_BOILER_ACCEPT_ORDER_ITEM where ORDER_ID = #{notOrderId} and DELETED = 0
- )
- </if>
- <if test="useStatus != null and useStatus.size() > 0">
- AND eb.USE_STATUS IN
- <foreach close=")" collection="useStatus" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- </where>
- ) a
- </select>
- <select id="selectDetailsById">
- select * from PRESSURE2_EQUIP_BOILER where ID = #{id}
- </select>
- <select id="selectPendingInspectionBoilerPage"
- resultType="cn.start.tz.module.pressure2.controller.admin.planscheduling.vo.EquipBoilerPageRespVO">
- SELECT
- eb.id,
- eb.type,
- eb.type as equip_type,
- eb.unit_code,
- eb.unit_id,
- eb.unit_name,
- eb.unit_address,
- eb.equip_district,
- eb.equip_street,
- eb.status,
- eb.equip_code,
- eb.equip_name,
- eb.use_register_no,
- eb.product_code,
- eb.contact,
- eb.contact_phone,
- eb.related_department as dept_id,
- eb.use_time as use_date,
- eb.made_time as make_date,
- eb.area_type,
- eb.boiler_address as equip_address,
- eb.sbpzcode as equip_category,
- CASE
- WHEN #{checkType} = 100 THEN eb.next_in_check_date
- WHEN #{checkType} = 200 THEN eb.next_out_check_date
- WHEN #{checkType} = 300 THEN eb.next_pressure_check_date
- END AS next_check_date,
- eb.next_out_check_date as next_year_check_date,
- eb.max_continue_evapor as equip_volume,
- eb.factory_code as product_no,
- lto.task_order_id,
- lto.task_status,
- CASE WHEN lrfi.refuse_id IS NOT NULL THEN 1 ELSE 0 END AS is_refused,
- COALESCE(lrfi.check_type, 100) AS refuse_type,
- CASE
- WHEN lrfi.refuse_id IS NOT NULL THEN
- CASE
- WHEN lrfi.is_submit = 0 THEN 100
- WHEN lrfi.is_submit = 1 AND lrfi.status = 100 THEN 200
- WHEN lrfi.is_submit = 1 AND lrfi.status = 200 THEN 300
- WHEN lrfi.is_submit = 1 AND lrfi.status = 300 THEN 300
- ELSE 100
- END
- ELSE NULL
- END AS refuse_status,
- #{checkType} AS check_type,
- CASE
- WHEN #{checkType} = 100 THEN '内部检验'
- WHEN #{checkType} = 200 THEN '外部检验'
- WHEN #{checkType} = 300 THEN '耐压检验'
- END AS check_type_str
- FROM PRESSURE2_EQUIP_BOILER eb
- LEFT JOIN (
- SELECT
- toi.equip_id,
- to1.id AS task_order_id,
- to1.task_status,
- ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
- FROM PRESSURE2_BOILER_TASK_ORDER_ITEM toi
- INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
- WHERE to1.deleted = 0
- AND toi.deleted = 0
- AND to1.check_type = #{checkType}
- ) lto ON lto.equip_id = eb.id AND lto.rn = 1
- LEFT JOIN (
- SELECT
- roi.id AS refuse_id,
- roi.equip_id,
- roi.check_type,
- roi.is_submit,
- roi.status,
- roi.report_city_status,
- ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
- FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
- WHERE roi.deleted = 0
- AND roi.check_type = #{checkType}
- ) lrfi ON lrfi.equip_id = eb.id AND lrfi.rn = 1
- <where>
- eb.deleted = 0
- AND eb.use_register_no is not null
- AND eb.use_register_no not in ('未办证', '未领证')
- AND eb.use_register_no != ''
- <choose>
- <when test="checkType == 100">
- AND (
- eb.next_in_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
- <if test="showNoCheckDate != null and showNoCheckDate">
- OR eb.next_in_check_date IS NULL
- </if>
- )
- </when>
- <when test="checkType == 200">
- AND (
- eb.next_out_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
- <if test="showNoCheckDate != null and showNoCheckDate">
- OR eb.next_out_check_date IS NULL
- </if>
- )
- </when>
- <when test="checkType == 300">
- AND (
- eb.next_pressure_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
- <if test="showNoCheckDate != null and showNoCheckDate">
- OR eb.next_pressure_check_date IS NULL
- </if>
- )
- </when>
- </choose>
- AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
- AND NOT (
- lrfi.refuse_id IS NOT NULL
- AND lrfi.is_submit = 1
- AND lrfi.status = 200
- AND lrfi.report_city_status = 200
- )
- <if test="ids != null and ids.size() > 0">
- AND eb.id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="type != null and type != ''">
- AND eb.type = #{type}
- </if>
- <if test="productNo != null and productNo != ''">
- AND eb.product_code LIKE CONCAT('%', #{productNo}, '%')
- </if>
- <if test="contactPhone != null and contactPhone != ''">
- AND eb.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
- </if>
- <if test="unitCode != null and unitCode != ''">
- AND eb.unit_code = #{unitCode}
- </if>
- <if test="unitId != null and unitId != ''">
- AND eb.unit_id = #{unitId}
- </if>
- <if test="unitName != null and unitName != ''">
- AND eb.unit_name LIKE CONCAT('%', #{unitName}, '%')
- </if>
- <if test="equipDistrict != null">
- AND eb.equip_district = #{equipDistrict}
- </if>
- <if test="equipDistricts != null and equipDistricts.size() > 0">
- AND eb.equip_district IN
- <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
- #{district}
- </foreach>
- </if>
- <if test="showNoDistrict == null or !showNoDistrict">
- AND eb.equip_district IS NOT NULL
- </if>
- <if test="equipStreet != null">
- AND eb.equip_street = #{equipStreet}
- </if>
- <if test="status != null and status != ''">
- AND eb.status = #{status}
- </if>
- <if test="statusList != null and statusList.size() > 0">
- AND eb.status IN
- <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
- #{listItem}
- </foreach>
- </if>
- <if test="equipCode != null and equipCode != ''">
- AND eb.equip_code LIKE CONCAT('%', #{equipCode}, '%')
- </if>
- <if test="equipType != null and equipType != ''">
- AND eb.type = #{equipType}
- </if>
- <if test="equipTypeList != null and equipTypeList.size() > 0">
- AND eb.type IN
- <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
- #{listItem}
- </foreach>
- </if>
- <if test="useRegisterNo != null and useRegisterNo != ''">
- AND eb.use_register_no LIKE CONCAT('%', #{useRegisterNo}, '%')
- </if>
- <if test="deptId != null and deptId != ''">
- AND eb.related_department = #{deptId}
- </if>
- <if test="isRefused != null">
- <choose>
- <when test="isRefused">
- AND lrfi.refuse_id IS NOT NULL
- </when>
- <otherwise>
- AND lrfi.refuse_id IS NULL
- </otherwise>
- </choose>
- </if>
- </where>
- ORDER BY
- CASE #{checkType}
- WHEN 100 THEN eb.next_in_check_date
- WHEN 200 THEN eb.next_out_check_date
- WHEN 300 THEN eb.next_pressure_check_date
- END ASC NULLS LAST
- OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
- </select>
- <select id="selectPendingInspectionBoilerCount" resultType="java.lang.Long">
- SELECT COUNT(1)
- FROM PRESSURE2_EQUIP_BOILER eb
- LEFT JOIN (
- SELECT
- toi.equip_id,
- to1.id AS task_order_id,
- to1.task_status,
- ROW_NUMBER() OVER (PARTITION BY toi.equip_id ORDER BY to1.create_time DESC) AS rn
- FROM PRESSURE2_BOILER_TASK_ORDER_ITEM toi
- INNER JOIN pressure_task_order to1 ON to1.id = toi.order_id
- WHERE to1.deleted = 0
- AND toi.deleted = 0
- AND to1.check_type = #{checkType}
- ) lto ON lto.equip_id = eb.id AND lto.rn = 1
- LEFT JOIN (
- SELECT
- roi.id AS refuse_id,
- roi.equip_id,
- roi.check_type,
- roi.is_submit,
- roi.status,
- roi.report_city_status,
- ROW_NUMBER() OVER (PARTITION BY roi.equip_id ORDER BY roi.create_time DESC) AS rn
- FROM PRESSURE2_APPOINTMENT_CONFIRM_ORDER_REFUSE_ITEM roi
- WHERE roi.deleted = 0
- AND roi.check_type = #{checkType}
- ) lrfi ON lrfi.equip_id = eb.id AND lrfi.rn = 1
- <where>
- eb.deleted = 0
- AND eb.use_register_no is not null
- AND eb.use_register_no not in ('未办证', '未领证')
- AND eb.use_register_no != ''
- <choose>
- <when test="checkType == 100">
- AND (
- eb.next_in_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
- <if test="showNoCheckDate != null and showNoCheckDate">
- OR eb.next_in_check_date IS NULL
- </if>
- )
- </when>
- <when test="checkType == 200">
- AND (
- eb.next_out_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
- <if test="showNoCheckDate != null and showNoCheckDate">
- OR eb.next_out_check_date IS NULL
- </if>
- )
- </when>
- <when test="checkType == 300">
- AND (
- eb.next_pressure_check_date BETWEEN #{checkDateStart} AND #{checkDateEnd}
- <if test="showNoCheckDate != null and showNoCheckDate">
- OR eb.next_pressure_check_date IS NULL
- </if>
- )
- </when>
- </choose>
- AND (lto.task_order_id IS NULL OR lto.task_status IN (800, 200))
- AND NOT (
- lrfi.refuse_id IS NOT NULL
- AND lrfi.is_submit = 1
- AND lrfi.status = 200
- AND lrfi.report_city_status = 200
- )
- <if test="ids != null and ids.size() > 0">
- AND eb.id IN
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="type != null and type != ''">
- AND eb.type = #{type}
- </if>
- <if test="productNo != null and productNo != ''">
- AND eb.product_code LIKE CONCAT('%', #{productNo}, '%')
- </if>
- <if test="contactPhone != null and contactPhone != ''">
- AND eb.contact_phone LIKE CONCAT('%', #{contactPhone}, '%')
- </if>
- <if test="unitCode != null and unitCode != ''">
- AND eb.unit_code = #{unitCode}
- </if>
- <if test="unitId != null and unitId != ''">
- AND eb.unit_id = #{unitId}
- </if>
- <if test="unitName != null and unitName != ''">
- AND eb.unit_name LIKE CONCAT('%', #{unitName}, '%')
- </if>
- <if test="equipDistrict != null">
- AND eb.equip_district = #{equipDistrict}
- </if>
- <if test="equipDistricts != null and equipDistricts.size() > 0">
- AND eb.equip_district IN
- <foreach collection="equipDistricts" item="district" open="(" separator="," close=")">
- #{district}
- </foreach>
- </if>
- <if test="showNoDistrict == null or !showNoDistrict">
- AND eb.equip_district IS NOT NULL
- </if>
- <if test="equipStreet != null">
- AND eb.equip_street = #{equipStreet}
- </if>
- <if test="status != null and status != ''">
- AND eb.status = #{status}
- </if>
- <if test="statusList != null and statusList.size() > 0">
- AND eb.status IN
- <foreach collection="statusList" item="listItem" open="(" separator="," close=")">
- #{listItem}
- </foreach>
- </if>
- <if test="equipCode != null and equipCode != ''">
- AND eb.equip_code LIKE CONCAT('%', #{equipCode}, '%')
- </if>
- <if test="equipType != null and equipType != ''">
- AND eb.type = #{equipType}
- </if>
- <if test="equipTypeList != null and equipTypeList.size() > 0">
- AND eb.type IN
- <foreach collection="equipTypeList" item="listItem" open="(" separator="," close=")">
- #{listItem}
- </foreach>
- </if>
- <if test="useRegisterNo != null and useRegisterNo != ''">
- AND eb.use_register_no LIKE CONCAT('%', #{useRegisterNo}, '%')
- </if>
- <if test="deptId != null and deptId != ''">
- AND eb.related_department = #{deptId}
- </if>
- <if test="isRefused != null">
- <choose>
- <when test="isRefused">
- AND lrfi.refuse_id IS NOT NULL
- </when>
- <otherwise>
- AND lrfi.refuse_id IS NULL
- </otherwise>
- </choose>
- </if>
- </where>
- </select>
- </mapper>
|