| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802 |
- <?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.pressure.dal.mysql.equipcontainer.EquipContainerMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <!--
- AND rownum >= #{startNum} and rownum <= #{endNum}
- -->
- <select id="selectPlanPage">
- SELECT
- a.*,
- co.confirm_order_ids,
- co.confirm_order_count,
- pto.task_order_ids,
- pto.task_order_count,
- ROW_NUMBER() OVER (ORDER BY ${orderBy} ${orderByDesc}) AS rn
- FROM (
- SELECT
- ec.id,
- ec.equip_code,
- ec.unit_code,
- ec.unit_name,
- ec.unit_address,
- ec.equip_street,
- ec.equip_district,
- ec.CONTACT,
- ec.CONTACT_PHONE,
- ec.USE_REGISTER_NO,
- LISTAGG(
- CASE
- WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN ec.id
- ELSE NULL
- END, ',' ON OVERFLOW TRUNCATE
- ) AS equip_ids,
- LISTAGG(
- CASE
- WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN ec.id
- ELSE NULL
- END, ',' ON OVERFLOW TRUNCATE
- ) AS year_equip_ids,
- LISTAGG(
- CASE
- WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN ec.id
- ELSE NULL
- END, ',' ON OVERFLOW TRUNCATE
- ) AS expired_equip_ids,
- SUM(
- CASE
- WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN 1
- ELSE 0
- END
- ) AS count,
- SUM(
- CASE
- WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN 1
- ELSE 0
- END
- ) AS year_count,
- SUM(
- CASE
- WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN 1
- ELSE 0
- END
- ) AS expired_count,
- MIN(
- CASE
- WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN ec.NEXT_CHECK_DATE
- ELSE NULL
- END
- ) AS next_check_date,
- MIN(
- CASE
- WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN ec.NEXT_YEAR_CHECK_DATE
- ELSE NULL
- END
- ) AS next_year_check_date,
- MIN(
- CASE
- WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN ec.NEXT_EXPIRED_CHECK_DATE
- ELSE NULL
- END
- ) AS next_expired_check_date
- FROM PRESSURE_EQUIP_CONTAINER ec
- <where>
- ec.deleted = 0 AND (ec.is_scheduling = 0 OR ec.IS_YEAR_SCHEDULING = 0 OR ec.IS_EXPIRED_SCHEDULING = 0)
- <if test="unitName != null and unitName != ''">
- AND ec.unit_name LIKE CONCAT('%',#{unitName},'%')
- </if>
- <if test="unitAddress != null and unitAddress != ''">
- AND ec.unit_address LIKE CONCAT('%',#{unitAddress},'%')
- </if>
- <choose>
- <when test="scene != null and scene == 0">
- <if test="equipCode != null and equipCode != ''">
- AND ec.equip_code LIKE CONCAT('%',#{equipCode},'%')
- </if>
- </when>
- <otherwise>
- <if test="equipCode != null and equipCode != ''">
- AND ec.unit_code IN (SELECT unit_code FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
- AND ec.equip_street IN (SELECT equip_street FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
- </if>
- </otherwise>
- </choose>
- <if test="equipStreet != null and equipStreet.size() > 0">
- AND ec.equip_street IN
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- AND ec.equip_district IN
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="deptId != null and deptId != ''">
- AND ec.dept_id = #{deptId}
- </if>
- <if test="typeList != null and typeList.size() > 0">
- AND ec.equip_type IN
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size() >= 2">
- AND (
- (ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- )
- </if>
- <if test="unitCodesTrue != null and unitCodesTrue.size() > 0">
- AND ec.unit_code IN
- <foreach close=")" collection="unitCodesTrue" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="unitCodesFalse != null and unitCodesFalse.size() > 0">
- AND ec.unit_code NOT IN
- <foreach close=")" collection="unitCodesFalse" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="status != null and status.size() > 0">
- AND ec.status IN
- <foreach close=")" collection="status" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="unitNames != null and unitNames.size() > 0">
- AND ec.UNIT_NAME IN
- <foreach close=")" collection="unitNames" item="unitNames" open="(" separator=",">
- #{unitNames}
- </foreach>
- </if>
- <if test="useRegisterNo != null and useRegisterNo != ''">
- AND ec.USE_REGISTER_NO LIKE CONCAT('%',#{useRegisterNo},'%')
- </if>
- </where>
- <!-- 关键修改:恢复原来的分组方式 -->
- <choose>
- <when test="scene != null and scene == 0">
- GROUP BY ec.unit_name
- </when>
- <otherwise>
- GROUP BY ec.unit_name, ec.equip_street, ec.CONTACT_PHONE
- </otherwise>
- </choose>
- ) a
- LEFT JOIN (
- SELECT
- unit_code,
- LISTAGG(
- CASE
- WHEN deleted = 0 AND status != 500 AND CREATE_ACCEPT_ORDER = 0 THEN id
- ELSE NULL
- END, ',' ON OVERFLOW TRUNCATE
- ) AS confirm_order_ids,
- COUNT(DISTINCT
- CASE
- WHEN deleted = 0 AND status != 500 AND CREATE_ACCEPT_ORDER = 0 THEN id
- ELSE NULL
- END
- ) AS confirm_order_count
- FROM PRESSURE_APPOINTMENT_CONFIRM_ORDER
- GROUP BY unit_code
- ) co ON co.unit_code = a.unit_code
- LEFT JOIN (
- SELECT
- unit_code,
- LISTAGG(
- CASE
- WHEN deleted = 0 AND TASK_STATUS != 800 THEN id
- ELSE NULL
- END, ',' ON OVERFLOW TRUNCATE
- ) AS task_order_ids,
- COUNT(DISTINCT
- CASE
- WHEN deleted = 0 AND TASK_STATUS != 800 THEN id
- ELSE NULL
- END
- ) AS task_order_count
- FROM PRESSURE_TASK_ORDER
- GROUP BY unit_code
- ) pto ON pto.unit_code = a.unit_code
- WHERE a.count > 0 OR a.year_count > 0 OR a.expired_count > 0
- ORDER BY ${orderBy} ${orderByDesc}
- OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
- </select>
- <select id="selectPlanCount">
- SELECT
- COUNT(1) unit_count,
- SUM(equip_count) equip_count
- FROM (
- SELECT
- ec.unit_code,
- COUNT(ec.equip_code) equip_count,
- SUM(
- CASE
- WHEN ec.NEXT_CHECK_DATE IS NOT NULL AND ec.is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN 1
- ELSE 0
- END
- ) count,
- SUM(
- CASE
- WHEN ec.NEXT_YEAR_CHECK_DATE IS NOT NULL AND ec.is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN 1
- ELSE 0
- END
- ) year_count,
- SUM(
- CASE
- WHEN ec.NEXT_EXPIRED_CHECK_DATE IS NOT NULL AND ec.is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- AND ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]}
- </if>
- THEN 1
- ELSE 0
- END
- ) expired_count
- FROM PRESSURE_EQUIP_CONTAINER ec
- <where>
- ec.deleted = 0 AND (ec.is_scheduling = 0 OR ec.IS_YEAR_SCHEDULING = 0 OR ec.IS_EXPIRED_SCHEDULING = 0)
- <if test="unitName != null and unitName != ''">
- AND ec.unit_name LIKE CONCAT('%',#{unitName},'%')
- </if>
- <if test="unitAddress != null and unitAddress != ''">
- AND ec.unit_address LIKE CONCAT('%',#{unitAddress},'%')
- </if>
- <choose>
- <when test="scene != null and scene == 0">
- <if test="equipCode != null and equipCode != ''">
- AND ec.equip_code LIKE CONCAT('%',#{equipCode},'%')
- </if>
- </when>
- <otherwise>
- <if test="equipCode != null and equipCode != ''">
- AND ec.unit_code IN (SELECT unit_code FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
- AND ec.equip_street IN (SELECT equip_street FROM PRESSURE_EQUIP_CONTAINER WHERE equip_code = #{equipCode} LIMIT 1)
- </if>
- </otherwise>
- </choose>
- <if test="unitNames != null and unitNames.size() > 0">
- AND ec.UNIT_NAME IN
- <foreach close=")" collection="unitNames" item="unitNames" open="(" separator=",">
- #{unitNames}
- </foreach>
- </if>
- <if test="useRegisterNo != null and useRegisterNo != ''">
- AND ec.USE_REGISTER_NO LIKE CONCAT('%',#{useRegisterNo},'%')
- </if>
- <if test="equipStreet != null and equipStreet.size() > 0">
- AND ec.equip_street IN
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- AND ec.equip_district IN
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="deptId != null and deptId != ''">
- AND ec.dept_id = #{deptId}
- </if>
- <if test="typeList != null and typeList.size() > 0">
- AND ec.equip_type IN
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size() >= 2">
- AND (
- (ec.NEXT_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (ec.NEXT_YEAR_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- OR (ec.NEXT_EXPIRED_CHECK_DATE BETWEEN #{nextDate[0]} AND #{nextDate[1]})
- )
- </if>
- <if test="unitCodesTrue != null and unitCodesTrue.size() > 0">
- AND ec.unit_code IN
- <foreach close=")" collection="unitCodesTrue" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="unitCodesFalse != null and unitCodesFalse.size() > 0">
- AND ec.unit_code NOT IN
- <foreach close=")" collection="unitCodesFalse" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="status != null and status.size() > 0">
- AND ec.status IN
- <foreach close=")" collection="status" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- </where>
- <!-- 使用与分页查询相同的分组方式 -->
- <choose>
- <when test="scene != null and scene == 0">
- GROUP BY ec.unit_name
- </when>
- <otherwise>
- GROUP BY ec.unit_name, ec.equip_street, ec.CONTACT_PHONE
- </otherwise>
- </choose>
- ) a
- WHERE a.count > 0 OR a.year_count > 0 OR a.expired_count > 0
- </select>
- <select id="selectPlanItemPage">
- select * from (select id,unit_code,unit_name,equip_code,unit_address,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
- status,equip_name,equip_type,equip_category,use_register_no,equip_volume,product_no,safe_manager,safe_manager_phone,unit_id,
- (select a.id from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
- where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) check_task_id,
- (select a.id from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
- where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) year_check_task_id,
- (select a.id from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
- where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 300 limit 1) expired_check_task_id,
- (select a.PLAN_DATE from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
- where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 100 limit 1) plan_check_date,
- (select a.PLAN_DATE from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
- where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 200 limit 1) plan_year_check_date,
- (select a.PLAN_DATE from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- left join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM b on a.ID = b.SCHEDULING_ID
- where b.equip_id = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.type = 300 limit 1) plan_expired_check_date,
- (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) count,
- (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) year_count,
- (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) expired_count,
- NEXT_CHECK_DATE ,
- NEXT_YEAR_CHECK_DATE,
- NEXT_EXPIRED_CHECK_DATE
- from PRESSURE_EQUIP_CONTAINER eq
- <where>
- deleted = 0
- <if test="unitName != null">
- and unit_name like concat('%',#{unitName},'%')
- </if>
- <if test="unitCode != null">
- and unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null">
- and unit_address like concat('%',#{unitAddress},'%')
- </if>
- <choose>
- <when test="scene != null and scene == 0">
- <if test="equipCode != null and equipCode != ''">
- and equip_code like concat('%',#{equipCode},'%')
- </if>
- </when>
- <otherwise>
- <if test="equipCode != null and equipCode != ''">
- and unit_code in ( select unit_code from PRESSURE_EQUIP_CONTAINER where equip_code =#{equipCode} limit 1)
- </if>
- </otherwise>
- </choose>
- <if test="equipStreet != null and equipStreet.size() > 0">
- and equip_street in
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="productNo != null and productNo != ''">
- and product_no like concat('%',#{productNo},'%')
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- and equip_district in
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="deptId">
- and dept_id = #{deptId}
- </if>
- <if test="typeList != null and typeList.size() > 0 ">
- and equip_type in
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size()>= 2">
- and ((NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
- (NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
- (NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}))
- </if>
- <if test="status != null and status.size() > 0 ">
- and status in
- <foreach close=")" collection="status" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipIds != null and equipIds.size() > 0 ">
- and id in
- <foreach close=")" collection="equipIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="notEquipIds != null and notEquipIds.size() > 0 ">
- and id not in
- <foreach close=")" collection="notEquipIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="unitIds != null and unitIds.size() > 0 ">
- and unit_id in
- <foreach close=")" collection="unitIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- </where>
- <choose>
- <when test="scene != null and scene == 1">
- order by unit_code
- </when>
- </choose>
- ) a
- OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
- </select>
- <select id="selectPlanItemCount">
- select count(equip_code) from (select unit_code,unit_name,equip_code,unit_address,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
- status,equip_name,equip_type,equip_category,use_register_no,equip_volume,product_no,safe_manager,safe_manager_phone,
- (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) count,
- (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) year_count,
- (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) expired_count,
- (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then NEXT_CHECK_DATE else null end) next_check_date,
- (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then NEXT_YEAR_CHECK_DATE else null end) next_year_check_date,
- (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then NEXT_EXPIRED_CHECK_DATE else null end) next_expired_check_date
- from PRESSURE_EQUIP_CONTAINER eq
- <where>
- deleted = 0
- <if test="unitName != null">
- and unit_name like concat('%',#{unitName},'%')
- </if>
- <if test="unitCode != null">
- and unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null">
- and unit_address like concat('%',#{unitAddress},'%')
- </if>
- <choose>
- <when test="scene != null and scene == 0">
- <if test="equipCode != null and equipCode != ''">
- and equip_code like concat('%',#{equipCode},'%')
- </if>
- </when>
- <otherwise>
- <if test="equipCode != null and equipCode != ''">
- and unit_code in ( select unit_code from PRESSURE_EQUIP_CONTAINER where equip_code =#{equipCode} limit 1)
- </if>
- </otherwise>
- </choose>
- <if test="equipStreet != null and equipStreet.size() > 0">
- and equip_street in
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- and equip_district in
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="productNo != null and productNo != ''">
- and product_no like concat('%',#{productNo},'%')
- </if>
- <if test="deptId">
- and dept_id = #{deptId}
- </if>
- <if test="typeList != null and typeList.size() > 0 ">
- and equip_type in
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size()>= 2">
- and ((NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
- (NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
- (NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}))
- </if>
- <if test="status != null and status.size() > 0 ">
- and status in
- <foreach close=")" collection="status" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipIds != null and equipIds.size() > 0 ">
- and id in
- <foreach close=")" collection="equipIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="notEquipIds != null and notEquipIds.size() > 0 ">
- and id not in
- <foreach close=")" collection="notEquipIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="unitIds != null and unitIds.size() > 0 ">
- and unit_id in
- <foreach close=")" collection="unitIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- </where>
- <choose>
- <when test="scene != null and scene == 1">
- order by unit_code
- </when>
- </choose>
- ) a
- </select>
- <select id="selectPlanCalendar">
- select a.ID task_id,a.TYPE check_type,b.unit_code,b.unit_name,b.unit_address,a.plan_date,count(distinct c.ID) equip_count,
- b.equip_district,b.equip_street,FIRST_VALUE(b.lng) lng,FIRST_VALUE(b.lat) lat, a.source,
- e.id APPOINTMENT_ID,f.id ACCEPT_ORDER_ID,f.STATUS accept_status, g.TASK_STATUS
- from PRESSURE_EQUIP_CONTAINER_SCHEDULING a
- inner join PRESSURE_EQUIP_CONTAINER_SCHEDULING_ITEM c on c.SCHEDULING_ID = a.ID and c.DELETED = 0
- inner join PRESSURE_EQUIP_CONTAINER b on b.ID = c.equip_id and b.DELETED = 0
- inner join PRESSURE_EQUIP_CONTAINER_SCHEDULING_USER d on d.SCHEDULING_ID = a.ID and d.DELETED = 0
- left join PRESSURE_APPOINTMENT_CONFIRM_ORDER e on e.SCHEDULING_ID = a.ID
- left join PRESSURE_ACCEPT_ORDER f on f.APPOINTMENT_ID = e.ID
- left join PRESSURE_Task_ORDER g on g.ACCEPT_ORDER_ID = f.ID
- <where>
- a.DELETED = 0
- <if test="planDate != null and planDate.size() >= 2">
- and a.plan_date between #{planDate[0]} and #{planDate[1]}
- </if>
- <if test="userId != null and userId != ''">
- and a.CREATOR = #{userId}
- </if>
- <if test="deptId != null and deptId != ''">
- and b.dept_id = #{deptId}
- </if>
- </where>
- group by b.unit_code,a.plan_date,a.type
- order by b.unit_code
- </select>
- <select id="selectAppointmentItemPage">
- select * from (select id,unit_code,unit_name,equip_code,unit_address,equip_street ,equip_district ,CONTACT,CONTACT_PHONE,
- status,equip_name,equip_type,equip_category,use_register_no,equip_volume,product_no,safe_manager,safe_manager_phone,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- where b.EQUIP_ID = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 100 limit 1) plan_check_date,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- where b.EQUIP_ID = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 200 limit 1) plan_year_check_date,
- (select a.APPOINTMENT_DATE from PRESSURE_APPOINTMENT_CONFIRM_ORDER a
- left join PRESSURE_APPOINTMENT_CONFIRM_ORDER_ITEM b on a.ID = b.ORDER_ID
- where b.EQUIP_ID = eq.id and a.DELETED = 0 and b.DELETED = 0 and a.check_type = 300 limit 1) plan_expired_check_date,
- (case when NEXT_CHECK_DATE is not null and is_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) count,
- (case when NEXT_YEAR_CHECK_DATE is not null and is_year_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) year_count,
- (case when NEXT_EXPIRED_CHECK_DATE is not null and is_expired_scheduling = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) expired_count,
- NEXT_CHECK_DATE ,
- NEXT_YEAR_CHECK_DATE,
- NEXT_EXPIRED_CHECK_DATE
- from PRESSURE_EQUIP_CONTAINER eq
- <where>
- deleted = 0
- <if test="unitName != null">
- and unit_name like concat('%',#{unitName},'%')
- </if>
- <if test="unitCode != null">
- and unit_code = #{unitCode}
- </if>
- <if test="unitAddress != null">
- and unit_address like concat('%',#{unitAddress},'%')
- </if>
- <if test="equipCode != null">
- and unit_code in ( select unit_code from PRESSURE_EQUIP_CONTAINER where equip_code =#{equipCode} limit 1)
- </if>
- <if test="equipStreet != null and equipStreet.size() > 0">
- and equip_street in
- <foreach close=")" collection="equipStreet" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipDistrict != null and equipDistrict.size() > 0">
- and equip_district in
- <foreach close=")" collection="equipDistrict" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="productNo != null and productNo != ''">
- and product_no like concat('%',#{productNo},'%')
- </if>
- <if test="deptId">
- and dept_id = #{deptId}
- </if>
- <if test="typeList != null and typeList.size() > 0 ">
- and equip_type in
- <foreach close=")" collection="typeList" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="nextDate != null and nextDate.size()>= 2">
- and ((NEXT_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
- (NEXT_YEAR_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}) or
- (NEXT_EXPIRED_CHECK_DATE between #{nextDate[0]} and #{nextDate[1]}))
- </if>
- <if test="status != null and status.size() > 0 ">
- and status in
- <foreach close=")" collection="status" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="equipIds != null and equipIds.size() > 0 ">
- and id in
- <foreach close=")" collection="equipIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="notEquipIds != null and notEquipIds.size() > 0 ">
- and id not in
- <foreach close=")" collection="notEquipIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- </where>
- ) a
- order by unit_code
- OFFSET ${(pageNo - 1) * pageSize} ROWS FETCH NEXT #{pageSize} ROWS ONLY
- </select>
- </mapper>
|