| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- <?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.com.goldenwater.dcproj.dao.TacInspYearBatchDao">
- <resultMap type="cn.com.goldenwater.dcproj.model.TacInspYearBatch" id="tacInspYearBatchResultMap">
- <result property="id" column="ID"/>
- <result property="year" column="YEAR"/>
- <result property="batch" column="BATCH"/>
- <result property="isAreaGroup" column="IS_AREA_GROUP"/>
- <result property="isPersGroup" column="IS_PERS_GROUP"/>
- <result property="isAppraisal" column="IS_APPRAISAL"/>
- <result property="persId" column="PERS_ID"/>
- <result property="inTm" column="IN_TM"/>
- <result property="upTm" column="UP_TM"/>
- <result property="dataStat" column="DATA_STAT"/>
- <result property="province" column="PROVINCE"/>
- <result property="type" column="TYPE"/>
- </resultMap>
-
- <sql id="table_columns">
- ID,
- YEAR,
- BATCH,
- IS_AREA_GROUP,
- IS_PERS_GROUP,
- IS_APPRAISAL,
- PERS_ID,
- IN_TM,
- UP_TM,
- DATA_STAT,PROVINCE,TYPE
- </sql>
- <sql id="entity_properties">
- #{id},
- #{year},
- #{batch},
- #{isAreaGroup},
- #{isPersGroup},
- #{isAppraisal},
- #{persId},
- #{inTm},
- #{upTm},
- #{dataStat},#{province},#{type}
- </sql>
- <!-- 使用like用法:columnName like concat('%',#columnName#,'%') -->
- <sql id="page_where">
- <trim prefix="where" prefixOverrides="and | or ">
- <if test="year != null and year != ''">and YEAR = #{year}</if>
- <if test="batch != null and batch != ''">and BATCH = #{batch}</if>
- <if test="isAreaGroup != null and isAreaGroup != ''">and IS_AREA_GROUP = #{isAreaGroup}</if>
- <if test="isPersGroup != null and isPersGroup != ''">and IS_PERS_GROUP = #{isPersGroup}</if>
- <if test="isAppraisal != null and isAppraisal != ''">and IS_APPRAISAL = #{isAppraisal}</if>
- <if test="persId != null and persId != ''">and PERS_ID = #{persId}</if>
- <if test="inTm != null">and IN_TM = #{inTm}</if>
- <if test="upTm != null">and UP_TM = #{upTm}</if>
- <if test="dataStat != null and dataStat != ''">and DATA_STAT = #{dataStat}</if>
- <if test="type != null and type != ''">and TYPE = #{type}</if>
- <include refid="choseSql"/>
- </trim>
- </sql>
- <sql id="choseSql" >
- <trim>
- <choose>
- <when test="province !=null and province !=''">
- and t.province=#{province}
- </when>
- <otherwise>
- and t.province is null
- </otherwise>
- </choose>
- </trim>
- </sql>
- <select id="get" resultMap="tacInspYearBatchResultMap" parameterType="String" >
- select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH where ID = #{id}
- </select>
- <select id="getBy" resultMap="tacInspYearBatchResultMap">
- select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
- </select>
- <select id="findAll" resultMap="tacInspYearBatchResultMap">
- select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH
- </select>
- <select id="findList" resultMap="tacInspYearBatchResultMap">
- select <include refid="table_columns" /> from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
- </select>
- <select id="selectCount" resultType="int" >
- select count(ID) from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
- </select>
- <insert id="insert" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
- insert into TAC_INSP_YEAR_BATCH( <include refid="table_columns" /> )
- values ( <include refid="entity_properties" /> )
- </insert>
- <delete id="delete" parameterType="java.lang.String">
- delete from TAC_INSP_YEAR_BATCH where ID = #{id}
- </delete>
- <delete id="deleteBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
- delete from TAC_INSP_YEAR_BATCH t <include refid="page_where" />
- </delete>
- <update id="deleteInFlag" parameterType="java.lang.String">
- update TAC_INSP_YEAR_BATCH set flag_valid = 0 where ID = #{id}
- </update>
- <update id="update" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
- update TAC_INSP_YEAR_BATCH
- <trim prefix="set" suffixOverrides=",">
- <if test="year != null and year != ''">YEAR = #{year},</if>
- <if test="batch != null and batch != ''">BATCH = #{batch},</if>
- <if test="isAreaGroup != null and isAreaGroup != ''">IS_AREA_GROUP = #{isAreaGroup},</if>
- <if test="isPersGroup != null and isPersGroup != ''">IS_PERS_GROUP = #{isPersGroup},</if>
- <if test="isAppraisal != null and isAppraisal != ''">IS_APPRAISAL = #{isAppraisal},</if>
- <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
- <if test="inTm != null">IN_TM = #{inTm},</if>
- <if test="upTm != null">UP_TM = #{upTm},</if>
- <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
- <if test="province != null and province != ''">PROVINCE = #{province},</if>
- <if test="type != null and type != ''">TYPE = #{type},</if>
- </trim>
- <where>ID = #{id}</where>
- </update>
- <update id="updateBy" parameterType="cn.com.goldenwater.dcproj.model.TacInspYearBatch">
- update TAC_INSP_YEAR_BATCH
- <trim prefix="set" suffixOverrides=",">
- <if test="year != null and year != ''">YEAR = #{year},</if>
- <if test="batch != null and batch != ''">BATCH = #{batch},</if>
- <if test="isAreaGroup != null and isAreaGroup != ''">IS_AREA_GROUP = #{isAreaGroup},</if>
- <if test="isPersGroup != null and isPersGroup != ''">IS_PERS_GROUP = #{isPersGroup},</if>
- <if test="isAppraisal != null and isAppraisal != ''">IS_APPRAISAL = #{isAppraisal},</if>
- <if test="persId != null and persId != ''">PERS_ID = #{persId},</if>
- <if test="inTm != null">IN_TM = #{inTm},</if>
- <if test="upTm != null">UP_TM = #{upTm},</if>
- <if test="dataStat != null and dataStat != ''">DATA_STAT = #{dataStat},</if>
- <if test="province != null and province != ''">PROVINCE = #{province},</if>
- <if test="type != null and type != ''">TYPE = #{type},</if>
- </trim>
- <include refid="page_where" />
- </update>
- <!-- 其他自定义SQL -->
- <select id="getTacInspYearBatchList" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- SELECT T.* FROM TAC_INSP_YEAR_BATCH T
- <where>
- <include refid="choseSql"/>
- <if test="dataStat != null and dataStat != ''">
- AND t.data_stat = #{dataStat}
- </if>
- <if test="year != null">
- AND t.year = #{year}
- </if>
- <if test="batch != null">
- AND t.batch = #{batch}
- </if>
- <if test="id != null and id != ''">
- and t.id = #{id}
- </if>
- </where>
- ORDER BY T.IN_TM DESC
- </select>
- <select id="getTacInspBatchByPersId" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select t.* from TAC_INSP_YEAR_BATCH t
- where
- REGEXP_LIKE(
- t.id,'^('||
- ( case when(SELECT count(year_batch_id) from TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{persId})>0 then
- (SELECT replace(LISTAGG(year_batch_id, ',') as
- id FROM TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID =#{persId} GROUP BY year_batch_id)
- else (select 'non' from dual) end)
- ||')')
- <include refid="choseSql"/>
- <if test="dataStat != null and dataStat != ''">
- AND t.data_stat = #{dataStat}
- </if>
- <if test="year != null">
- AND t.year = #{year}
- </if>
- <if test="batch != null">
- AND t.batch = #{batch}
- </if>
- order by t.IN_TM desc
- </select>
- <select id="getBatchList" resultType="cn.com.goldenwater.dcproj.model.TacInspYearBatch" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select t.*,p.id as persAreaId from TAC_INSP_YEAR_BATCH t left join TAC_INSP_PERS_AREA_PRIS p on t.id = p.year_batch_id
- where 1=1
- <include refid="choseSql"/>
- <if test="dataStat != null and dataStat != ''">
- AND t.data_stat = #{dataStat}
- </if>
- <if test="years != null and years != ''">
- AND t.year in (${years})
- </if>
- <if test="year != null and year != ''">
- and t.year = #{year}
- </if>
- <if test="batchs != null and batchs != ''">
- AND t.batch in (${batchs})
- </if>
- order by t.batch asc
- </select>
- <select id="countGroupAndPers" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select b.*,c.persCount from (
- select a.year,a.batch,count(*) as groupCount from (
- select distinct t.year,t.batch,t.group_id from tac_insp_year_batch_group_pers t where t.group_id is not null
- and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <if test="adCode != null and adCode != ''">
- and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/> )
- </if>
- <if test="type != null and type != ''">
- and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type}
- <include refid="choseSql"/>
- )
- </if>
- ) a group by a.batch,a.year
- ) b left join (
- select t.batch,t.year,count(*) as persCount from tac_insp_year_batch_group_pers t where t.group_id is not null
- and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <if test="adCode != null and adCode != ''">
- and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/>)
- </if>
- <if test="type != null and type != ''">
- and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/> )
- </if>
- group by t.batch,t.year
- ) c on b.batch = c.batch
- </select>
- <select id="countRoleTypeAndPers" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select a.*,b.ctCount from (
- select b.year,b.role_type,count(*) as persCount from (
- select distinct t.year,t.ROLE_TYPE,t.pers_id from tac_insp_year_batch_group_pers t where t.pers_id is not null and t.group_id is not null
- and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <if test="adCode != null and adCode != ''">
- and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/>)
- </if>
- <if test="type != null and type != ''">
- and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/> )
- </if>
- ) b group by b.year,b.role_type
- ) a left join (
- select t.year,t.role_type,count(*) as ctCount from tac_insp_year_batch_group_pers t where t.pers_id is not null and t.group_id is not null
- and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <if test="adCode != null and adCode != ''">
- and t.group_id in (select group_id from tac_insp_year_batch_area t where ad_code like '${adCode}%' <include refid="choseSql"/> )
- </if>
- <if test="type != null and type != ''">
- and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/> )
- </if>
- group by t.year,t.role_type
- ) b on a.year = b.year and a.role_type = b.role_type
- </select>
- <select id="countArea" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select t.year,
- LISTAGG(t.year || '年第' || t.batch || '批次,稽察时间 ' ||
- case when to_char(t.up_tm, 'yyyy-MM-dd') is null then '无' else to_char(t.up_tm, 'yyyy-MM-dd') end, ',')
- WITHIN GROUP (ORDER BY t.year,t.ad_code,t.ad_name)
- as detail,
- t.ad_code,
- t.ad_name,
- count(*) as count
- from tac_insp_year_batch_area t
- where 1 = 1
- <include refid="choseSql"/>
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <if test="adCode != null and adCode != ''">
- and t.ad_code like '${adCode}%'
- </if>
- <if test="type != null and type != ''">
- and t.group_id in (select group_id from TAC_PAWP_RGSTR t where type = #{type} <include refid="choseSql"/>)
- </if>
- group by t.year,t.ad_code,t.ad_name
- </select>
- <select id="getAllCountPers" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select count(*) as count from (
- select DISTINCT pers_id from TAC_INSP_YEAR_BATCH_GROUP_PERS t where t.pers_id is not null and t.group_id is not NULL
- and t.year_batch_id in (select id from TAC_INSP_YEAR_BATCH where province=#{province})
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <if test="adCode != null and adCode != ''">
- and t.group_id in (select group_id from tac_insp_year_batch_area t where adCode = #{adCode}
- <include refid="choseSql"/>
- )
- </if>
- <if test="type != null and type != ''">
- and t.group_id in (select group_id from tac_pawp_rgstr t where type = #{type} <include refid="choseSql"/> )
- </if>
- )
- </select>
- <select id="countObjByYear" resultType="cn.com.goldenwater.dcproj.dto.TacCountDto" parameterType="cn.com.goldenwater.dcproj.param.TacInspYearBatchParam">
- select count(*) as count, t.type as name from (
- select t.* from TAC_INSP_YEAR_BATCH t where t.type is not null
- <if test="persId != null and persId != ''">
- and t.id in (select year_batch_id FROM TAC_INSP_YEAR_BATCH_GROUP_PERS WHERE PERS_ID in (select id from tac_worker_b b where b.login_id = #{persId}))
- </if>
- <if test="year != null">
- and t.year = #{year}
- </if>
- <if test="batch != null">
- and t.batch = #{batch}
- </if>
- <include refid="choseSql"/>
- ) t group by t.type
- </select>
- </mapper>
|