<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.sheet.dao.ibatis.SheetMatterDaoImpl">


    <select id="getSubListCount" parameterType="paramDto" resultType="int">
        SELECT
        count( 1 )
        FROM
        mortals_xhx_sheet_matter AS a
        LEFT JOIN ( SELECT matterNo FROM mortals_xhx_matter WHERE siteId = #{condition.siteId} ) AS b ON a.matterNo = b.matterNo
        <trim suffixOverrides="where" suffix="">
            where b.matterNo IS NULL and
            <trim prefixOverrides="and" prefix="">
                <if test="condition.areaCode!=null and condition.areaCode!=''">
                    and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
                </if>
                <if test="condition.deptCode!=null and condition.deptCode!=''">
                    and a.deptCode = #{condition.deptCode,jdbcType=VARCHAR}
                </if>
                <if test="condition.matterName != null and condition.matterName != ''">
                    and a.matterName like #{condition.matterName}
                </if>
            </trim>
        </trim>
    </select>

    <!-- 获取事项差集列表列表 -->
    <select id="getSubList" parameterType="paramDto" resultMap="SheetMatterEntity-Map">
        select
        <include refid="_columns"/>
        FROM
        mortals_xhx_sheet_matter AS a
        LEFT JOIN ( SELECT matterNo FROM mortals_xhx_matter WHERE siteId = #{condition.siteId} ) AS b ON a.matterNo = b.matterNo
        <trim suffixOverrides="where" suffix="">
            where b.matterNo IS NULL and
            <trim prefixOverrides="and" prefix="">
                <if test="condition.areaCode!=null and condition.areaCode!=''">
                    and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
                </if>
                <if test="condition.deptCode!=null and condition.deptCode!=''">
                    and a.deptCode = #{condition.deptCode,jdbcType=VARCHAR}
                </if>
                <if test="condition.matterName != null and condition.matterName != ''">
                     and a.matterName like #{condition.matterName}
                </if>
            </trim>
        </trim>
    </select>
</mapper>