<?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.PlatEmployeeHealthMapper">

    <resultMap type="com.project.zcustom.domain.employee.PlatEmployeeHealth" id="platEmployeeHealth">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="appOrg"    column="app_org"    />
        <result property="healthyNum"    column="healthy_num"    />
        <result property="subHealthyNum"    column="sub_healthy_num"    />
        <result property="participateNum"    column="participate_num"    />
        <result property="actualParticipateNum"    column="actual_participate_num"    />
        <result property="participateProportionRate"    column="participate_proportion_rate"    />
    </resultMap>

    <resultMap type="com.project.zcustom.domain.employee.PlatEmployeeHealthIllness" id="platEmployeeHealthIllness">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="appOrg"    column="app_org"    />
        <result property="paramsName"    column="params_name"    />
        <result property="paramsValue"    column="params_value"    />
    </resultMap>

    <select id="getHealthData" parameterType="String" resultMap="platEmployeeHealth">
        SELECT
            sum( participate_num ) AS participate_num,
            sum( actual_participate_num ) AS actual_participate_num
        FROM
            large_plat_employee_health
        WHERE
            del_flag = '0'
        <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
            LIMIT 1
    </select>

    <select id="getIllnessChartData" parameterType="String" resultMap="platEmployeeHealthIllness">
        SELECT
            params_name,
            sum( params_value ) AS params_value
        FROM
            large_plat_employee_health_illness
        WHERE
            del_flag = '0'
        <if test="appOrg != '0000'">AND ( app_org = #{appOrg} ) </if>
        <if test="appOrg == '0000'">GROUP BY params_name </if>
        ORDER BY
            params_value DESC
    </select>

</mapper>
