| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?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.pipeequipment.PipeEquipmentMapper">
- <!--
- 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
- 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
- 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
- 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
- -->
- <select id="selectPlanPage">
- select USE_PROJECT_CODE,USE_PROJECT_NAME,USE_UNIT_NAME,PIPE_ADDRESS,sum(PIPE_LEN) total_len , use_unit_security_man,use_unit_security_man_phone ,
- pipe_administrative_region,pipe_street,min(NEXT_LEGAL_INSPECTION_DATE) NEXT_LEGAL_INSPECTION_DATE,min(NEXT_ANNUAL_DATE) NEXT_ANNUAL_DATE,
- sum(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_LEGAL_INSPECTION_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) LEGAL_INSPECTION_COUNT,
- sum(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_ANNUAL_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) ANNUAL_COUNT,
- listagg(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0 then id else null end,',') equip_ids,
- listagg(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0 then id else null end,',') annual_equip_ids
- from PRESSURE_PIPE_EQUIPMENT
- where DELETED = 0 and (IS_SCHEDULING = 0 or IS_YEAR_SCHEDULING = 0) and USE_UNIT_NAME is not null
- <where>
- <if test="useUnitName != null">
- and use_unit_name like concat('%',#{useUnitName},'%')
- </if>
- <if test="pipeAddress != null">
- and pipe_address like concat('%',#{pipeAddress},'%')
- </if>
- <if test="pipeAdministrativeRegion != null">
- and pipe_administrative_region = #{pipeAdministrativeRegion}
- </if>
- <if test="pipeStreet != null">
- and pipe_street = #{pipeStreet}
- </if>
- </where>
- group by pipe_administrative_region,pipe_street,USE_UNIT_NAME
- </select>
- <select id="countPlanPage">
- select count(1) from (
- select USE_UNIT_NAME,PIPE_ADDRESS,sum(PIPE_LEN) total_len , use_unit_security_man,use_unit_security_man_phone ,
- pipe_administrative_region,pipe_street,min(NEXT_LEGAL_INSPECTION_DATE) NEXT_LEGAL_INSPECTION_DATE,min(NEXT_ANNUAL_DATE) NEXT_ANNUAL_DATE,
- sum(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_LEGAL_INSPECTION_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) LEGAL_INSPECTION_COUNT,
- sum(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0
- <if test="nextDate != null and nextDate.size()>= 2">
- and NEXT_ANNUAL_DATE between #{nextDate[0]} and #{nextDate[1]}
- </if>
- then 1 else 0 end) ANNUAL_COUNT
- from PRESSURE_PIPE_EQUIPMENT
- where DELETED = 0 and (IS_SCHEDULING = 0 or IS_YEAR_SCHEDULING = 0) and USE_UNIT_NAME is not null
- <where>
- <if test="useUnitName != null">
- and use_unit_name like concat('%',#{useUnitName},'%')
- </if>
- <if test="pipeAddress != null">
- and pipe_address like concat('%',#{pipeAddress},'%')
- </if>
- <if test="pipeAdministrativeRegion != null">
- and pipe_administrative_region = #{pipeAdministrativeRegion}
- </if>
- <if test="pipeStreet != null">
- and pipe_street = #{pipeStreet}
- </if>
- </where>
- group by pipe_administrative_region,pipe_street,USE_UNIT_NAME
- ) as aa
- </select>
- <select id="selectPlanPageGroupProject">
- select USE_PROJECT_CODE,USE_PROJECT_NAME,PIPE_STREET,PIPE_ADMINISTRATIVE_REGION,
- sum(PIPE_LEN) total_len,min(NEXT_LEGAL_INSPECTION_DATE) NEXT_LEGAL_INSPECTION_DATE,min(NEXT_ANNUAL_DATE) NEXT_ANNUAL_DATE,
- sum(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0
- then 1 else 0 end) LEGAL_INSPECTION_COUNT,
- sum(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0
- then 1 else 0 end) ANNUAL_COUNT,
- listagg(case when NEXT_LEGAL_INSPECTION_DATE is not null and IS_SCHEDULING = 0 then id else null end,',') equip_ids,
- listagg(case when NEXT_ANNUAL_DATE is not null and IS_YEAR_SCHEDULING = 0 then id else null end,',') annual_equip_ids
- from PRESSURE_PIPE_EQUIPMENT
- where DELETED = 0 and (IS_SCHEDULING = 0 or IS_YEAR_SCHEDULING = 0) and USE_UNIT_NAME is not null
- and id in
- <foreach close=")" collection="ids" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- group by USE_PROJECT_NAME
- </select>
- </mapper>
|