<?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.ruoyi.postCheck.mapper.PostAssessmentRatingMapper">

    <resultMap type="PostAssessmentRating" id="PostAssessmentRatingResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="deptId"    column="dept_id"    />
        <result property="postId"    column="post_id"    />
        <result property="headUserId"    column="head_user_id"    />
        <result property="integrityIssuesTotal"    column="integrity_issues_total"    />
        <result property="integrityIssuesResolved"    column="integrity_issues_resolved"    />
        <result property="effectivenessIssuesTotal"    column="effectiveness_issues_total"    />
        <result property="effectivenessIssuesResolved"    column="effectiveness_issues_resolved"    />
        <result property="suitabilityIssuesTotal"    column="suitability_issues_total"    />
        <result property="suitabilityIssuesResolved"    column="suitability_issues_resolved"    />
        <result property="peerEvaluationScore"    column="peer_evaluation_score"    />
        <result property="dailyScore"    column="daily_score"    />
        <result property="departmentScore"    column="department_score"    />
        <result property="positionScore"    column="position_score"    />
        <result property="ratingTime"    column="rating_time"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="majorOrGroup"    column="major_or_group"    />
        <result property="planStartTime"    column="plan_start_time"    />
        <result property="planEndTime"    column="plan_end_time"    />
    </resultMap>

    <sql id="selectPostAssessmentRatingVo">
        select id,plan_start_time,plan_end_time, type, dept_id, post_id, head_user_id, integrity_issues_total, integrity_issues_resolved, effectiveness_issues_total, effectiveness_issues_resolved, suitability_issues_total, suitability_issues_resolved, peer_evaluation_score, daily_score, department_score, position_score, rating_time, remark, del_flag, create_time, create_by, update_time, update_by,major_or_group from post_assessment_rating
    </sql>

    <select id="selectPostAssessmentRatingList" parameterType="PostAssessmentRating" resultMap="PostAssessmentRatingResult">
        <include refid="selectPostAssessmentRatingVo"/>
        <where>
            <if test="type != null "> and type = #{type}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="postId != null "> and post_id = #{postId}</if>
            <if test="headUserId != null "> and head_user_id = #{headUserId}</if>
            <if test="integrityIssuesTotal != null "> and integrity_issues_total = #{integrityIssuesTotal}</if>
            <if test="integrityIssuesResolved != null "> and integrity_issues_resolved = #{integrityIssuesResolved}</if>
            <if test="effectivenessIssuesTotal != null "> and effectiveness_issues_total = #{effectivenessIssuesTotal}</if>
            <if test="effectivenessIssuesResolved != null "> and effectiveness_issues_resolved = #{effectivenessIssuesResolved}</if>
            <if test="suitabilityIssuesTotal != null "> and suitability_issues_total = #{suitabilityIssuesTotal}</if>
            <if test="suitabilityIssuesResolved != null "> and suitability_issues_resolved = #{suitabilityIssuesResolved}</if>
            <if test="peerEvaluationScore != null "> and peer_evaluation_score = #{peerEvaluationScore}</if>
            <if test="dailyScore != null "> and daily_score = #{dailyScore}</if>
            <if test="departmentScore != null "> and department_score = #{departmentScore}</if>
            <if test="positionScore != null "> and position_score = #{positionScore}</if>
            <if test="ratingTime != null "> and rating_time = #{ratingTime}</if>

            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                AND TO_DATE(u.rating_time, 'yyyy-mm-dd') &gt;= TO_DATE(#{params.beginTime}, 'yyyy-mm-dd')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                AND TO_DATE(u.rating_time, 'yyyy-mm-dd') &lt;= TO_DATE(#{params.endTime}, 'yyyy-mm-dd')
            </if>
        </where>
    </select>

    <select id="selectPostAssessmentRatingById" parameterType="Long" resultMap="PostAssessmentRatingResult">
        <include refid="selectPostAssessmentRatingVo"/>
        where id = #{id}
    </select>

    <insert id="insertPostAssessmentRating" parameterType="PostAssessmentRating">
        insert into post_assessment_rating
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="type != null">type,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="postId != null">post_id,</if>
            <if test="headUserId != null">head_user_id,</if>
            <if test="integrityIssuesTotal != null">integrity_issues_total,</if>
            <if test="integrityIssuesResolved != null">integrity_issues_resolved,</if>
            <if test="effectivenessIssuesTotal != null">effectiveness_issues_total,</if>
            <if test="effectivenessIssuesResolved != null">effectiveness_issues_resolved,</if>
            <if test="suitabilityIssuesTotal != null">suitability_issues_total,</if>
            <if test="suitabilityIssuesResolved != null">suitability_issues_resolved,</if>
            <if test="peerEvaluationScore != null">peer_evaluation_score,</if>
            <if test="dailyScore != null">daily_score,</if>
            <if test="departmentScore != null">department_score,</if>
            <if test="positionScore != null">position_score,</if>
            <if test="ratingTime != null">rating_time,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="type != null">#{type},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="postId != null">#{postId},</if>
            <if test="headUserId != null">#{headUserId},</if>
            <if test="integrityIssuesTotal != null">#{integrityIssuesTotal},</if>
            <if test="integrityIssuesResolved != null">#{integrityIssuesResolved},</if>
            <if test="effectivenessIssuesTotal != null">#{effectivenessIssuesTotal},</if>
            <if test="effectivenessIssuesResolved != null">#{effectivenessIssuesResolved},</if>
            <if test="suitabilityIssuesTotal != null">#{suitabilityIssuesTotal},</if>
            <if test="suitabilityIssuesResolved != null">#{suitabilityIssuesResolved},</if>
            <if test="peerEvaluationScore != null">#{peerEvaluationScore},</if>
            <if test="dailyScore != null">#{dailyScore},</if>
            <if test="departmentScore != null">#{departmentScore},</if>
            <if test="positionScore != null">#{positionScore},</if>
            <if test="ratingTime != null">#{ratingTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updatePostAssessmentRating" parameterType="PostAssessmentRating">
        update post_assessment_rating
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="postId != null">post_id = #{postId},</if>
            <if test="headUserId != null">head_user_id = #{headUserId},</if>
            <if test="integrityIssuesTotal != null">integrity_issues_total = #{integrityIssuesTotal},</if>
            <if test="integrityIssuesResolved != null">integrity_issues_resolved = #{integrityIssuesResolved},</if>
            <if test="effectivenessIssuesTotal != null">effectiveness_issues_total = #{effectivenessIssuesTotal},</if>
            <if test="effectivenessIssuesResolved != null">effectiveness_issues_resolved = #{effectivenessIssuesResolved},</if>
            <if test="suitabilityIssuesTotal != null">suitability_issues_total = #{suitabilityIssuesTotal},</if>
            <if test="suitabilityIssuesResolved != null">suitability_issues_resolved = #{suitabilityIssuesResolved},</if>
            <if test="peerEvaluationScore != null">peer_evaluation_score = #{peerEvaluationScore},</if>
            <if test="dailyScore != null">daily_score = #{dailyScore},</if>
            <if test="departmentScore != null">department_score = #{departmentScore},</if>
            <if test="positionScore != null">position_score = #{positionScore},</if>
            <if test="ratingTime != null">rating_time = #{ratingTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostAssessmentRatingById" parameterType="Long">
        delete from post_assessment_rating where id = #{id}
    </delete>

    <delete id="deletePostAssessmentRatingByIds" parameterType="String">
        delete from post_assessment_rating where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="getSysDeptName" resultType="java.lang.String">
        SELECT  "dept_name"
        FROM  "public"."sys_dept" where dept_id = #{id};
    </select>
</mapper>
