<?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="com.chinaweal.aiccs.aiccs.claim.mapper.TSSupEntBaseMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.chinaweal.aiccs.aiccs.claim.entity.TSSupEntBase">
        <id column="PRIPID" property="pripid" />
        <result column="INSOBJTYPE" property="insobjtype" />
        <result column="INSOBJTYPENAME" property="insobjtypename" />
        <result column="CLAIMDATE" property="claimdate" />
        <result column="INDUSTRYTYPE" property="industrytype" />
        <result column="IMPORTANTAREA" property="importantarea" />
        <result column="STATUS" property="status" />
        <result column="LEVELTYPE" property="leveltype" />
        <result column="LAUPTIME" property="lauptime" />
        <result column="AREA_CODE" property="areaCode" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        PRIPID, INSOBJTYPE, INSOBJTYPENAME, CLAIMDATE, INDUSTRYTYPE, IMPORTANTAREA, STATUS, LEVELTYPE, LAUPTIME, AREA_CODE
    </sql>

    <!--统计 已认领主体类型-->
    <select id="statisticalEntity" resultType="java.util.HashMap" parameterType="java.lang.String">
        select sum(case WHEN t.enttype='9910' then 1 else 0 end) as individual,
        sum(case WHEN t.enttype='9100' or t.enttype='9200'  then 1 else 0 end) as farmerCoop,
        sum(case WHEN t.enttype!='9100' and t.enttype!='9200' and t.enttype!='9910' then 1 else 0 end) as enterprise
        from TSClaim tc
        left join TREntBase t on tc.pripid = t.pripid
        left join TREntBaseAddr t1 on tc.entbaseaddrid = t1.entbaseaddrid
        where tc.tclaimstatus = '2'
        <if test="claimaicid != null and claimaicid != ''">
            AND tc.claimaicid = #{claimaicid,jdbcType=VARCHAR}
        </if>
    </select>

</mapper>
