MemberDictMapper.xml 7.64 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.laowu.mapper.MemberDictMapper">

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, user_name, status, telephone, id_card_type, id_card, province, city, town, address, education, education_type, college_id, start_date, end_date, major_id, rank, is_poor, is_migration, is_party, job_status
    </sql>

    <select id="allMembers" resultType="com.laowu.vo.member.AllMembersVO">
        SELECT DISTINCT
            t.id,
            t.user_name,
            t.STATUS,
            t.telephone,
            t.id_card_type,
            t.id_card,
            t.province,
            t.city,
            t.county,
            t.address
        FROM
            member_dict t
        LEFT JOIN member_positions t2 ON t.id = t2.member_id
        LEFT JOIN position_dict t3 ON t2.position_id = t3.id
        left join position_dict t4 ON t3.parent_id = t4.id
        WHERE
            t.delete_date IS NULL
            <if test="status != null and status != ''">
                AND t.STATUS = #{status}
            </if>
            <if test="province != null and province != ''">
                AND t.province = #{province}
            </if>
            <if test="city != null and city != ''">
                AND t.city = #{city}
            </if>
            <if test="county != null and county != ''">
                AND t.county = #{county}
            </if>
            <if test="userName != null and userName != ''">
                AND t.user_name like concat('%', #{userName}, '%')
            </if>
            <if test="positionId != null and positionId != ''">
                and (t3.id = #{positionId} or t3.parent_id = #{positionId} or t4.parent_id = #{positionId})
            </if>
        order by t.create_date
    </select>

    <select id="members" parameterType="long" resultType="long">
        SELECT
            t.id
        FROM
            member_dict t
            left join member_team_mapping t2 on t.id = t2.member_id
        WHERE
            t.delete_date IS NULL
            and t2.delete_date is null
            AND t2.team_id = #{teamId}
    </select>

    <select id="memberPositions" parameterType="long" resultType="com.laowu.model.PositionDictDO">
        SELECT
            t2.*
        FROM
            member_positions t
            LEFT JOIN position_dict t2 ON t.position_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.member_id = #{memberId}
    </select>

    <select id="laborAbility" resultType="integer">
        SELECT
            count( 1 )
        FROM
            member_dict t
        WHERE
            t.delete_date IS NULL
            AND t.labor_ability IN ( '技能劳动力', '普通劳动力', '部分丧失劳动力' )
            AND t.province = #{province}
            AND t.city = #{city}
            <if test="county != null and county != ''">
                and t.county = #{county}
            </if>
            <if test="isPoor != null and isPoor != ''">
                and t.is_poor = #{isPoor}
            </if>
    </select>

    <select id="cityEmployeeCnt" parameterType="string" resultType="integer">
        SELECT
            count( 1 )
        FROM
            member_dict t
        WHERE
            t.delete_date IS NULL
            AND ( t.province_now = '上海市'
                    OR t.province_employment = '上海市')
                and t.province = #{province}
                AND t.city = #{city}
    </select>

    <select id="migrationCnt" resultType="integer">
        SELECT
            count( 1 )
        FROM
            member_dict t
        WHERE
            t.delete_date IS NULL
            and t.is_migration = #{isMigration}
            AND ( t.province_now = '上海市'
                    OR t.province_employment = '上海市')
                and t.province = #{province}
                AND t.city = #{city}
    </select>

    <select id="memberCertCnt" resultType="integer">
        SELECT
            count( 1 )
        FROM
            member_dict t
            LEFT JOIN ( SELECT t.member_id FROM member_certs t WHERE t.delete_date IS NULL GROUP BY t.member_id HAVING count( 1 )> 0 ) t2 ON t.id = t2.member_id
        WHERE
            t.delete_date IS NULL
            AND t2.member_id IS NOT NULL
            AND ( t.province_now = '上海市'
                    OR t.province_employment = '上海市')
                and t.province = #{province}
                AND t.city = #{city}
    </select>

    <select id="businessTop7" resultType="com.laowu.vo.station.BusinessTop7VO">
       SELECT
            t2.business,
            count( 1 ) AS cnt
        FROM
            member_dict t
            LEFT JOIN business_dict t2 ON t.business_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t.business_id IS NOT NULL
            AND t.business_id = 5
            AND ( t.province_now = '上海市' OR t.province_employment = '上海市')
            and t.province = #{province}
            AND t.city = #{city}
                UNION
        SELECT
            t2.business,
            cnt
        FROM
            (
            SELECT
                t.business_id,
                count( 1 ) AS cnt
            FROM
                member_dict t
            WHERE
                t.delete_date IS NULL
                AND t.business_id IS NOT NULL
                AND t.business_id != 5
                AND ( t.province_now = '上海市' OR t.province_employment = '上海市')
                and t.province = #{province}
                AND t.city = #{city}
            GROUP BY
                t.business_id
            ORDER BY
                count( 1 ) DESC
            ) t
            LEFT JOIN business_dict t2 ON t.business_id = t2.id
            LIMIT 7
    </select>

    <select id="middleSalary" resultType="double">
        SELECT
            t.average_salary
        FROM
            member_dict t
        WHERE
            t.delete_date IS NULL
            AND ( t.province_now = '上海市'
                    OR t.province_employment = '上海市')
                and t.province = #{province}
                AND t.city = #{city}
        ORDER BY
            t.average_salary
    </select>

    <select id="education" resultType="integer">
        SELECT
            count( 1 )
        FROM
            member_dict t
        WHERE
            t.delete_date IS NULL
            AND t.education = #{education}
        <if test="destinationProvince != null and destinationProvince != ''">
            AND ( t.province_now = #{destinationProvince}
            OR t.province_employment = #{destinationProvince})
        </if>
        and t.province = #{province}
        AND t.city = #{city}
            <if test="county != null and county != ''">
                and t.county = #{county}
            </if>
    </select>

    <select id="ageLabor" resultType="integer">
        SELECT
            count( 1 )
        FROM
            member_dict t
        WHERE
            t.delete_date IS NULL
            AND t.province = #{province}
            AND t.city = #{city}
            <if test="county != null and county != ''">
                and t.county = #{county}
            </if>
            AND t.labor_ability IN ( '技能劳动力', '普通劳动力', '部分丧失劳动力' )
            <if test="maxAge != null and maxAge != ''">
                and t.age &lt;= #{maxAge}
            </if>
            <if test="minAge != null and minAge != ''">
                and t.age >= #{minAge}
            </if>
    </select>

</mapper>