DrawLotsGroupJudgesMapper.xml 7.29 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.zhongzhi.dao.DrawLotsGroupJudgesMapper">
    <select id="matchJudges" resultType="com.zhongzhi.vo.drawlots.MatchJudgesVO">
        SELECT
            t2.id,
            t.id mapping_id,
            t2.username,
            t.expector_type,
            t.role_type,
            t3.group_name,
            t2.telephone,
            t2.unit,
            t2.position
        FROM
            draw_lots_group_judges t
            LEFT JOIN project_judge t2 ON t.judge_id = t2.id
            LEFT JOIN draw_lot_group_dict t3 ON t.group_id = t3.id
        WHERE
            t.delete_time IS NULL
            AND t2.delete_time IS NULL
            and t3.delete_time is null
            and t.scene_id = #{sceneId}
            <if test="userName != null and userName != ''">
                and (t2.username like concat('%', #{userName}, '%') or t2.telephone like concat('%', #{userName}, '%') )
            </if>
            <if test="expectorType != null and expectorType != ''">
                and t.expector_type = #{expectorType}
            </if>
            <if test="roleType != null and roleType != ''">
                and t.role_type = #{roleType}
            </if>
    </select>

    <select id="selectJudges" resultType="com.zhongzhi.vo.drawlots.SelectJudgesVO">
        SELECT
            t2.id,
            t2.username,
            t2.unit,
            t2.position,
            t2.telephone
        FROM
             project_judge t2
        WHERE
            t2.delete_time IS NULL
            <if test="userName != null and userName != ''">
                and (t2.username like concat('%', #{userName}, '%') or t2.telephone like concat('%', #{userName}, '%') )
            </if>
            and t2.id not in (
            select judge_id from
            draw_lots_group_judges t
            where t.delete_time is null
            AND t.scene_id = #{sceneId}
            )
    </select>

    <select id="allNum" resultType="java.lang.Integer">
        SELECT
            t.group_num
        FROM
            draw_lots_judge_num t
        WHERE
            t.delete_time IS NULL
            AND t.group_id = #{groupId}
    </select>

    <select id="drawJudgeInfo" resultType="com.zhongzhi.vo.drawlots.DrawJudgeInfoVO">
        SELECT
            t.role_type,
            t.expector_type,
            t3.username,
            t2.group_num
        FROM
            draw_lots_judge_num t2
            left join draw_lots_group_judges t on t2.group_id = t.group_id and t2.group_num = t.group_num
            LEFT JOIN project_judge t3 ON t.judge_id = t3.id
        WHERE
            t.delete_time IS NULL
            AND t2.group_id = #{groupId}
            order by t2.group_num
    </select>

    <select id="currentGroupLeaderCnt" resultType="java.lang.Integer">
        SELECT
            count( 1 )
        FROM
            draw_lots_group_judges t
        WHERE
            t.delete_time IS NULL
            AND t.role_type = '组长'
            AND t.group_id = #{groupId}
    </select>

    <select id="noLeaderGroup" resultType="com.zhongzhi.model.DrawLotGroupDictDO">
        SELECT
            *
        FROM
            draw_lot_group_dict t
        WHERE
            t.scene_id = #{sceneId}
            AND t.id NOT IN (
            SELECT
                t.group_id
            FROM
                draw_lots_group_judges t
            WHERE
            t.scene_id = #{sceneId}
            AND t.role_type = '组长'
          	and t.group_id is not null
)
    </select>

    <select id="noMemberGroup" resultType="com.zhongzhi.model.DrawLotGroupDictDO">
        SELECT
            *
        FROM
            (
            SELECT
                t.id,
                t.group_name,
                ifnull( t2.cnt, 0 ) cnt,
                t.teach_cnt,
                t.field_cnt
            FROM
                draw_lot_group_dict t
                LEFT JOIN (
                SELECT
                    t.scene_id,
                    t.group_id,
                    count( 1 ) cnt
                FROM
                    draw_lots_group_judges t
                WHERE
                    t.delete_time IS NULL
                    AND t.scene_id = #{sceneId}
                    AND t.expector_type = #{teachType}
                GROUP BY
                    t.scene_id,
                    t.group_id,
                    t.expector_type
                ) t2 ON t.id = t2.group_id
                where t.scene_id = #{sceneId}
            ) t
        WHERE
            1 = 1
            <if test="teachType == '教育专家'">
                AND t.teach_cnt > t.cnt
            </if>
            <if test="teachType == '行业专家'">
                AND t.field_cnt > t.cnt
            </if>
    </select>

    <select id="login" resultType="com.zhongzhi.vo.drawlots.LoginVO">
        SELECT
            *
        FROM
            (
            SELECT
                concat( t2.group_name, '', t.group_num ) NAME,
                t2.group_name,
                t.group_id,
                t.group_num,
                t2.scene_id
            FROM
                draw_lots_judge_num t
                LEFT JOIN draw_lot_group_dict t2 ON t.group_id = t2.id
            WHERE
                t.delete_time IS NULL
                AND t2.delete_time IS NULL
            ) t
        WHERE
            t.NAME = #{name}
    </select>

    <select id="judgeScoreScreen" resultType="com.zhongzhi.vo.drawlots.ScoreScreenVO">
        SELECT
            t.judge_id,
            t2.score,
            t2.submit_status
        FROM
            draw_lots_group_judges t
            LEFT JOIN (
            SELECT
                t.judge_id,
                t.score,
                t.submit_status
            FROM
                draw_lots_scores t
                LEFT JOIN draw_lots_group_items t2 ON t.scene_id = t2.scene_id
                AND t.group_id = t2.group_id
                AND t.project_id = t2.project_id
                LEFT JOIN draw_lot_group_dict t3 ON t.group_id = t3.id
            WHERE
                t.delete_time IS NULL
                AND t.group_id = #{groupId}
                AND t2.group_num = #{groupNum}
                and t.submit_status in ('已提交','弃权')
            ORDER BY
                t2.group_num
            ) t2 ON t.judge_id = t2.judge_id
        WHERE
            t.delete_time IS NULL
            AND t.group_id = #{groupId}
    </select>

    <select id="existNum" resultType="java.lang.Integer">
        SELECT
            t.group_num
        FROM
            draw_lots_group_judges t
        WHERE
            t.delete_time IS NULL
            AND t.group_id = #{groupId}
    </select>

    <select id="judgeInfo" resultType="com.zhongzhi.vo.drawlots.JudgeFullInfoVO">
        SELECT
            t.judge_id,
            t2.username,
            t.group_num,
            t3.group_name,
            t.expector_type,
            t.role_type
        FROM
            draw_lots_group_judges t
            LEFT JOIN project_judge t2 ON t.judge_id = t2.id
            LEFT JOIN draw_lot_group_dict t3 ON t.group_id = t3.id
        WHERE
            t.delete_time IS NULL
            AND t2.delete_time IS NULL
            AND t.group_num = #{groupNum}
            AND t.group_id = #{groupId}
    </select>

</mapper>