<?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.testor.module.lease.dao.TLeaseBankDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.lease.model.domain.TLeaseBank">
        <id column="id" property="id"/>
        <id column="org_name" property="orgName"/>
        <id column="lease_name" property="leaseName"/>
        <id column="lease_code" property="leaseCode"/>
        <id column="lease_status" property="leaseStatus"/>
        <id column="process_status" property="processStatus"/>
        <id column="ref_id" property="refId"/>
        <id column="process_id" property="processId"/>
        <id column="parent_id" property="parentId"/>
        <id column="org_id" property="orgId"/>
    </resultMap>
<!--获取危险源总数-->
    <select id="getRiskRourceNum"
            resultType="int">

        select count(*) riskRourceNum  from t_safe_risk_source
        where status = 0
        <if test="orgs!=null and orgs.size>0">
            AND org_id in
            <foreach open="(" close=")" separator="," collection="orgs" item="item" index="index">
                #{item}
            </foreach>
        </if>


    </select>

    <!--获取重大危险源-->
    <select id="getMajor"
            resultType="int">

        select count(*) riskRourceNum  from t_safe_risk_source
        where status = 0
          and is_major = 1
        <if test="orgs!=null and orgs.size>0">
            AND org_id in
            <foreach open="(" close=")" separator="," collection="orgs" item="item" index="index">
                #{item}
            </foreach>
        </if>


    </select>

    <!--获取风险点的数量-->
    <select id="getRiskPoint"
            resultType="int">

        select count(*) riskRourceNum  from t_safe_risk_point
        where status = 0
        <if test="orgs!=null and orgs.size>0">
            AND org_id in
            <foreach open="(" close=")" separator="," collection="orgs" item="item" index="index">
                #{item}
            </foreach>
        </if>


    </select>
</mapper>