<?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.bonus.boot.manager.manager.dao.UtilDao">
    <select id="determineIfExists" resultType="java.lang.Integer">
        select count(1) from ${tableName} where ${filedId} = #{filedValue} and is_active = '1'
        <if test="id != null and id != ''">
            and id != #{id}
        </if>
        limit 1
    </select>


    <select id="getHospitalSelect" resultType="com.bonus.boot.manager.basic.entity.MapBean" parameterType="com.bonus.boot.manager.basic.entity.MapBean">
       select id as `key`,hospital as `value` from pm_base_hospital where is_active ='1'
       <if test="value !=null and value !='' and value !='null' ">
           and id like concat ('%',#{value},'%')
       </if>
    </select>
    <select id="getPackageType" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select id as `key`,CASE WHEN type_name = '1' THEN '标准套餐' WHEN type_name = '2' THEN '个性化套餐' WHEN type_name = '3' THEN '职业健康套餐' END AS `value` from pm_base_type_package where is_active ='1'
    </select>
    <select id="getPersonType" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select id as `key`,name as `value` from sys_dic_detail where type ='personType'
    </select>
    <select id="getSpecialPost" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select id as `key`,job_name as `value` from pm_base_special_job where is_active ='1'
    </select>
    <select id="getRole" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select id as `key`,name as `value` from sys_role where is_active ='1'
    </select>

    <select id="getSetMeal" resultType="com.bonus.boot.manager.basic.entity.MapBean" parameterType="com.bonus.boot.manager.basic.entity.MapBean">
        select pbc.id as `key`,pbc.comb_name as `value` from
        pm_base_combination pbc
        LEFT JOIN (SELECT * from sys_dic_detail WHERE type ='personType') a on a.id =pbc.person_type
        where is_active = '1'
        <if test="type !=null and type !=''">
            and  pbc.comb_sex = #{type}
        </if>
        <if test="keyWord != null and keyWord !=''">
            and  pbc.person_type = #{keyWord}
        </if>
        <if test="checkId != null and checkId !=''">
            and  pbc.check_id = #{checkId}
        </if>
        <if test="higherJob != null and higherJob !=''">
            and  pbc.if_highee = #{higherJob}
        </if>

    </select>
    <select id="findteltpone" resultType="java.lang.Integer">
select count(1) from pm_base_physical where telep_number=#{0} and is_active='1'
</select>
    <select id="getstandId" resultType="java.lang.String">
        select id from pm_base_type_package where type_name='1' and is_active='1'
    </select>
    <select id="userteltpone" resultType="java.lang.Integer">
        select count(1) from sys_user where phone=#{0}
    </select>
    <select id="personIfExists" resultType="java.lang.Integer">
        select count(1) from ${tableName} where ${filedId} = #{filedValue} and is_active = '1'
    </select>
    <select id="getHazard" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select DISTINCT hazards as `key`,hazards as `value` from pm_occupation_phy_result where is_active ='1' and hazards is not null
    </select>
    <select id="getExaminationHospital" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select id as `key`,hospital as `value` from pm_base_hospital where is_active = '1'
    </select>
    <select id="getNewHospitalSelect" resultType="com.bonus.boot.manager.basic.entity.MapBean">
        select id as `key`,hospital as `value` from pm_base_hospital where is_active ='1'
    </select>


</mapper>

