<?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.project.zcustom.mapper.employee.PlatEmployeeTypeMapper">
    <resultMap type="com.project.zcustom.domain.employee.PlatEmployeeType" id="platEmployeeType">
        <result property="id"    column="id"    />
        <result property="propertyNum"    column="property_num"    />
        <result property="associationNum"    column="association_num"    />
        <result property="loanNum"    column="loan_num"    />
        <result property="insideNum"    column="inside_num"    />
    </resultMap>

    <resultMap type="com.project.zcustom.domain.access.PlatAccess" id="platAccess">
        <result property="id"    column="id"    />
        <result property="blackListsNum"    column="black_lists_num"    />
        <result property="guardCardNum"    column="guard_card_num"    />
        <result property="carLicenseNum"    column="car_license_num"    />
    </resultMap>

    <select id="getEmployeePieData" parameterType="String" resultMap="platEmployeeType">
        SELECT
            sum( inside_num ) AS inside_num,
            sum( loan_num ) AS loan_num,
            sum( association_num ) AS association_num,
            sum( property_num ) AS property_num
        FROM
            large_plat_employee_type
        WHERE
            del_flag = '0'
            <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
            LIMIT 1
    </select>

    <select id="getEnterBuildData" parameterType="String" resultMap="platEmployeeType">
        SELECT
            sum( entry_internal_num ) AS entry_internal_num,
            sum( entry_to_loan_num ) AS entry_to_loan_num,
            sum( entry_assist_num ) AS entry_assist_num,
            sum( entry_property_num ) AS entry_property_num,
            sum( visitor_num ) AS visitor_num,
            sum( gross_num ) AS gross_num
        FROM
            large_plat_employee_type
        WHERE
            del_flag = '0'
        <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
            LIMIT 1
    </select>

    <select id="getChartsFlowData" parameterType="String" resultMap="platEmployeeType">
        SELECT
            time_sign,
            sum( inside_num ) AS inside_num,
            sum( loan_num ) AS loan_num,
            sum( association_num ) AS association_num,
            sum( property_num ) AS property_num,
            sum( visit_num ) AS visit_num
        FROM
            large_plat_employee_type_flow
        WHERE
            del_flag = '0'
        <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
        GROUP BY
            time_sign
        ORDER BY
            time_sign ASC
            LIMIT 7
    </select>

    <select id="getSexChartData" parameterType="String" resultMap="platEmployeeType">
        SELECT
            sum( man_num ) AS man_num,
            sum( women_num ) AS women_num
        FROM
            large_plat_employee_type
        WHERE
            del_flag = '0'
        <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
            LIMIT 1
    </select>

    <select id="getOtherData" parameterType="String" resultMap="platAccess">
        SELECT
            sum( car_license_num ) AS car_license_num,
            sum( guard_card_num ) AS guard_card_num,
            sum( black_lists_num ) AS black_lists_num
        FROM
            large_plat_access
        WHERE
            del_flag = '0'
        <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
            LIMIT 1
    </select>
</mapper>
