ComPersonDAO.xml 5.21 KB
<?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.yiboshi.science.dao.ComPersonDAO">
    <sql id="allColumns">
        t
        .
        id
        as id, t.cert_id as certId, t.cert_type as certType, t.person_name as personName, t.sex as sex, t.birthday as birthday, t.unit_id as unitId, t.note_state as noteState,
        t.degree as degree, t.duty as duty, t.title as title, t.spec as spec, t.email as email, t.mobile as mobile, t.photo as photo, t.address as address,
        t.expert as expert, t.open_bank as openBank, t.open_acount as openAcount, t.remark as remark, t.created as created, t.updated as updated
    </sql>
    <select id="getListByPage" resultType="com.yiboshi.science.param.dto.ComPersonDTO">
        SELECT
        e.*,d.unit_name,d.unit_type,g.name nation_name,h.name education_name,
        i.name title_name,j.name spec_name,f.username,f.id user_id,l.id user_role_id,l.state,
        (case l.state when 1 then '启用' else '停用' end) state_name
        FROM com_person e
        LEFT JOIN com_unit d ON e.unit_id = d.id
        LEFT JOIN system_user f ON f.person_id = e.id
        LEFT JOIN system_user_role l ON l.user_id = f.id
        left join system_parameter g on e.nation=g.id and g.type_id=11
        left join system_parameter h on e.education=h.id and h.type_id=8
        left join system_parameter i on e.title=i.id and i.type_id=7
        left join system_parameter j on e.spec=j.id and j.type_id=42
        left join system_parameter k on j.parent_id = k.id
        <where>
            ${ew.sqlSegment}
        </where>
        ORDER BY d.tree_code ASC
    </select>
    <select id="getAllListByPage" resultType="com.yiboshi.science.param.dto.ComPersonDTO">
        SELECT
        e.*,d.unit_name,d.unit_type,g.name nation_name,h.name education_name,
        i.name title_name,j.name spec_name
        FROM com_person e
        LEFT JOIN com_unit d ON e.unit_id = d.id
        left join system_parameter g on e.nation=g.id and g.type_id=11
        left join system_parameter h on e.education=h.id and h.type_id=8
        left join system_parameter i on e.title=i.id and i.type_id=7
        left join system_parameter j on e.spec=j.id and j.type_id=42
        left join system_parameter k on j.parent_id = k.id
        <where>
            ${ew.sqlSegment}
        </where>
        ORDER BY d.tree_code ASC
    </select>
    <select id="getPersonById" parameterType="java.lang.String" resultType="com.yiboshi.science.param.dto.ComPersonDTO">
        SELECT a.*,
               b.unit_name,b.tree_code,
               c.name nation_name,
               d.name education_name,
               e.name title_name,
               f.name spec_name,
               g.id   user_id,
               g.username
        FROM com_person a
        LEFT JOIN com_unit b ON a.unit_id = b.id
        LEFT JOIN system_user g ON a.id = g.person_id
        left join system_parameter c on a.nation = c.id and c.type_id = 11
        left join system_parameter d on a.education = d.id and d.type_id = 8
        left join system_parameter e on a.title = e.id and e.type_id = 7
        left join system_parameter f on a.spec = f.id and f.type_id = 42
        where a.id = #{id}
    </select>
    <select id="getList" resultType="com.yiboshi.science.param.dto.ComPersonDTO">
        SELECT a.*, b.unit_name, c.name nation_name, d.name education_name, e.name title_name, f.name spec_name
        FROM com_person a
                 LEFT JOIN com_unit b ON a.unit_id = b.id
                 left join system_parameter c on a.nation = c.id and c.type_id = 11
                 left join system_parameter d on a.education = d.id and d.type_id = 8
                 left join system_parameter e on a.title = e.id and e.type_id = 7
                 left join system_parameter f on a.spec = f.id and f.type_id = 42
    </select>
    <select id="getManagerListByUnitId" resultType="com.yiboshi.science.param.dto.ComPersonDTO">
        SELECT a.*,b.unit_name,c.username,c.password,c.id user_id,d.id user_role_id,d.state,
               (case d.state when 1 then '启用' else '停用' end) state_name
        FROM com_person a
        LEFT JOIN com_unit b ON a.unit_id = b.id
        LEFT JOIN system_user c ON c.person_id = a.id
        LEFT JOIN system_user_role d ON d.user_id = c.id
        where b.id = #{unitId} and d.role_id in('0','1','2')
    </select>
    <select id="getRegisterPersonCount" resultType="com.yiboshi.science.param.dto.DataStatisticsDTO">
        SELECT ifnull(sum(case when e.audit_result is not null and e.audit_result=1 then 1 else 0 end),0) count1,
               ifnull(sum(case when e.audit_result is not null and e.audit_result>1 then 1 else 0 end),0) count2,
               ifnull(sum(case when e.audit_result is not null then 1 else 0 end),0) count5
        FROM com_person e
        <where>
            ${ew.sqlSegment}
        </where>
    </select>

    <select id="getRegisterPersonCountByDay" resultType="com.yiboshi.science.param.dto.DataStatisticsDTO">
        SELECT ifnull(count(1),0) count1
        FROM com_person e
        <where>
            ${ew.sqlSegment} and TO_DAYS(e.created) = TO_DAYS(NOW())
        </where>
    </select>
</mapper>