<?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.sundot.airport.check.mapper.CheckCorrectionMapper">

    <resultMap type="CheckCorrection" id="CheckCorrectionResult">
        <result property="tenantId" column="tenant_id"/>
        <result property="revision" column="revision"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="correctionCode" column="correction_code"/>
        <result property="checkRecordId" column="check_record_id"/>
        <result property="rectificationDetails" column="rectification_details"/>
        <result property="responsibleUserId" column="responsible_user_id"/>
        <result property="correctionDuration" column="correction_duration"/>
        <result property="correctionResult" column="correction_result"/>
        <result property="correctionTime" column="correction_time"/>
        <result property="verifierUserId" column="verifier_user_id"/>
        <result property="verificationResult" column="verification_result"/>
        <result property="verificationTime" column="verification_time"/>
        <result property="status" column="status"/>
        <result property="id" column="id"/>
        <result property="responsibleUserName" column="responsible_user_name"/>
        <result property="verifierUserName" column="verifier_user_name"/>
        <result property="checkedLevel" column="checked_level"/>
        <result property="evidenceUrl" column="evidence_url"/>
        <result property="remark" column="remark"/>
        <result property="statusDesc" column="status_desc"/>
        <result property="checkedLevelDesc" column="checked_level_desc"/>
        <result property="verificationResultDesc" column="verification_result_desc"/>
        <result property="evidenceId" column="evidence_id"/>
        <result property="comprehensiveEvaluation" column="comprehensive_evaluation"/>
        <result property="rectificationSuggestions" column="rectification_suggestions"/>
        <result property="checkerId" column="checker_id"/>
        <result property="checkerName" column="checker_name"/>
        <result property="checkTime" column="check_time"/>
        <result property="terminlCode" column="terminl_code"/>
        <result property="terminlName" column="terminl_name"/>
        <result property="regionalCode" column="regional_code"/>
        <result property="regionalName" column="regional_name"/>
        <result property="channelCode" column="channel_code"/>
        <result property="channelName" column="channel_name"/>
        <result property="checkedDepartmentId" column="checked_department_id"/>
        <result property="checkedDepartmentName" column="checked_department_name"/>
        <result property="checkedTeamId" column="checked_team_id"/>
        <result property="checkedTeamName" column="checked_team_name"/>
        <result property="checkedDepartmentLeaderId" column="checked_department_leader_id"/>
        <result property="checkedDepartmentLeaderName" column="checked_department_leader_name"/>
        <result property="checkedTeamLeaderId" column="checked_team_leader_id"/>
        <result property="checkedTeamLeaderName" column="checked_team_leader_name"/>
        <result property="checkedPersonnelId" column="checked_personnel_id"/>
        <result property="checkedPersonnelName" column="checked_personnel_name"/>
        <result property="rectificationDeadline" column="rectification_deadline"/>
        <result property="taskCode" column="task_code"/>
        <result property="taskName" column="task_name"/>
        <result property="documentCode" column="document_code"/>
        <result property="documentName" column="document_name"/>
        <result property="correctionName" column="correction_name"/>
        <result property="checkedDeptId" column="checked_dept_id"/>
        <result property="checkedDeptName" column="checked_dept_name"/>
        <result property="processStatus" column="process_status"/>
        <result property="processStatusDesc" column="process_status_desc"/>
        <result property="checkLevel" column="check_level"/>
        <result property="checkLevelDesc" column="check_level_desc"/>
        <result property="selectTeamId" column="select_team_id"/>
        <result property="selectTeamName" column="select_team_name"/>
        <result property="selectTeamLeaderId" column="select_team_leader_id"/>
        <result property="selectTeamLeaderName" column="select_team_leader_name"/>
        <result property="isSelectTeam" column="is_select_team"/>
        <result property="isSelfCheck" column="is_self_check"/>
        <result property="completionTime" column="completion_time"/>
        <result property="instanceId" column="instance_id"/>
        <result property="checkedBrigadeId" column="checked_brigade_id"/>
        <result property="checkedBrigadeName" column="checked_brigade_name"/>
        <result property="checkedBrigadeLeaderId" column="checked_brigade_leader_id"/>
        <result property="checkedBrigadeLeaderName" column="checked_brigade_leader_name"/>
    </resultMap>

    <sql id="selectCheckCorrectionVo">
        select tenant_id,
               revision,
               create_by,
               create_time,
               update_by,
               update_time,
               correction_code,
               check_record_id,
               rectification_details,
               responsible_user_id,
               correction_duration,
               correction_result,
               correction_time,
               verifier_user_id,
               verification_result,
               verification_time,
               status,
               id,
               responsible_user_name,
               verifier_user_name,
               checked_level,
               evidence_url,
               remark,
               status_desc,
               checked_level_desc,
               verification_result_desc,
               evidence_id,
               comprehensive_evaluation,
               rectification_suggestions,
               checker_id,
               checker_name,
               check_time,
               terminl_code,
               terminl_name,
               regional_code,
               regional_name,
               channel_code,
               channel_name,
               checked_department_id,
               checked_department_name,
               checked_team_id,
               checked_team_name,
               checked_department_leader_id,
               checked_department_leader_name,
               checked_team_leader_id,
               checked_team_leader_name,
               checked_personnel_id,
               checked_personnel_name,
               rectification_deadline,
               task_code,
               task_name,
               document_code,
               document_name,
               correction_name,
               checked_dept_id,
               checked_dept_name,
               process_status,
               process_status_desc,
               check_level,
               check_level_desc,
               select_team_id,
               select_team_name,
               select_team_leader_id,
               select_team_leader_name,
               is_select_team,
               is_self_check,
               completion_time,
               instance_id,
               checked_brigade_id,
               checked_brigade_name,
               checked_brigade_leader_id,
               checked_brigade_leader_name
        from check_correction
    </sql>

    <select id="selectCheckCorrectionList" parameterType="CheckCorrection" resultMap="CheckCorrectionResult">
        <include refid="selectCheckCorrectionVo"/>
        <where>
            <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
            <if test="revision != null ">and revision = #{revision}</if>
            <if test="correctionCode != null  and correctionCode != ''">and correction_code = #{correctionCode}</if>
            <if test="checkRecordId != null ">and check_record_id = #{checkRecordId}</if>
            <if test="rectificationDetails != null  and rectificationDetails != ''">and rectification_details =
                #{rectificationDetails}
            </if>
            <if test="responsibleUserId != null ">and responsible_user_id = #{responsibleUserId}</if>
            <if test="correctionDuration != null ">and correction_duration = #{correctionDuration}</if>
            <if test="correctionResult != null  and correctionResult != ''">and correction_result =
                #{correctionResult}
            </if>
            <if test="correctionTime != null ">and correction_time = #{correctionTime}</if>
            <if test="verifierUserId != null ">and verifier_user_id = #{verifierUserId}</if>
            <if test="verificationResult != null  and verificationResult != ''">and verification_result =
                #{verificationResult}
            </if>
            <if test="verificationTime != null ">and verification_time = #{verificationTime}</if>
            <if test="status != null  and status != ''">and status = #{status}</if>
            <if test="responsibleUserName != null  and responsibleUserName != ''">and responsible_user_name like
                concat('%', #{responsibleUserName}, '%')
            </if>
            <if test="verifierUserName != null  and verifierUserName != ''">and verifier_user_name like concat('%',
                #{verifierUserName}, '%')
            </if>
            <if test="checkedLevel != null  and checkedLevel != ''">and checked_level = #{checkedLevel}</if>
            <if test="evidenceUrl != null  and evidenceUrl != ''">and evidence_url = #{evidenceUrl}</if>
            <if test="statusDesc != null  and statusDesc != ''">and status_desc = #{statusDesc}</if>
            <if test="checkedLevelDesc != null  and checkedLevelDesc != ''">and checked_level_desc =
                #{checkedLevelDesc}
            </if>
            <if test="verificationResultDesc != null  and verificationResultDesc != ''">and verification_result_desc =
                #{verificationResultDesc}
            </if>
            <if test="evidenceId != null  and evidenceId != ''">and evidence_id = #{evidenceId}</if>
            <if test="comprehensiveEvaluation != null  and comprehensiveEvaluation != ''">and comprehensive_evaluation =
                #{comprehensiveEvaluation}
            </if>
            <if test="rectificationSuggestions != null  and rectificationSuggestions != ''">and
                rectification_suggestions = #{rectificationSuggestions}
            </if>
            <if test="checkerId != null ">and checker_id = #{checkerId}</if>
            <if test="checkerName != null  and checkerName != ''">and checker_name like concat('%', #{checkerName},
                '%')
            </if>
            <if test="checkTime != null ">
                and check_time <![CDATA[>=]]> #{checkTime}
                and check_time <![CDATA[<]]> date_add(#{checkTime}, interval 1 day)
            </if>
            <if test="terminlCode != null  and terminlCode != ''">and terminl_code = #{terminlCode}</if>
            <if test="terminlName != null  and terminlName != ''">and terminl_name like concat('%', #{terminlName},
                '%')
            </if>
            <if test="regionalCode != null  and regionalCode != ''">and regional_code = #{regionalCode}</if>
            <if test="regionalName != null  and regionalName != ''">and regional_name like concat('%', #{regionalName},
                '%')
            </if>
            <if test="channelCode != null  and channelCode != ''">and channel_code = #{channelCode}</if>
            <if test="channelName != null  and channelName != ''">and channel_name like concat('%', #{channelName},
                '%')
            </if>
            <if test="checkedDepartmentId != null ">and checked_department_id = #{checkedDepartmentId}</if>
            <if test="checkedDepartmentName != null  and checkedDepartmentName != ''">and checked_department_name like
                concat('%', #{checkedDepartmentName}, '%')
            </if>
            <if test="checkedTeamId != null ">and checked_team_id = #{checkedTeamId}</if>
            <if test="checkedTeamName != null  and checkedTeamName != ''">and checked_team_name like concat('%',
                #{checkedTeamName}, '%')
            </if>
            <if test="checkedDepartmentLeaderId != null ">and checked_department_leader_id =
                #{checkedDepartmentLeaderId}
            </if>
            <if test="checkedDepartmentLeaderName != null  and checkedDepartmentLeaderName != ''">and
                checked_department_leader_name like concat('%', #{checkedDepartmentLeaderName}, '%')
            </if>
            <if test="checkedTeamLeaderId != null ">and checked_team_leader_id = #{checkedTeamLeaderId}</if>
            <if test="checkedTeamLeaderName != null  and checkedTeamLeaderName != ''">and checked_team_leader_name like
                concat('%', #{checkedTeamLeaderName}, '%')
            </if>
            <if test="checkedPersonnelId != null ">and checked_personnel_id = #{checkedPersonnelId}</if>
            <if test="checkedPersonnelName != null  and checkedPersonnelName != ''">and checked_personnel_name like
                concat('%', #{checkedPersonnelName}, '%')
            </if>
            <if test="rectificationDeadline != null ">and rectification_deadline = #{rectificationDeadline}</if>
            <if test="taskCode != null  and taskCode != ''">and task_code = #{taskCode}</if>
            <if test="taskName != null  and taskName != ''">and task_name like concat('%', #{taskName}, '%')</if>
            <if test="documentCode != null  and documentCode != ''">and document_code = #{documentCode}</if>
            <if test="documentName != null  and documentName != ''">and document_name like concat('%', #{documentName},
                '%')
            </if>
            <if test="correctionName != null  and correctionName != ''">and correction_name like concat('%',
                #{correctionName}, '%')
            </if>
            <if test="checkedDeptId != null ">and checked_dept_id = #{checkedDeptId}</if>
            <if test="checkedDeptName != null  and checkedDeptName != ''">and checked_dept_name like concat('%',
                #{checkedDeptName}, '%')
            </if>
            <if test="processStatus != null  and processStatus != ''">and process_status = #{processStatus}</if>
            <if test="processStatusDesc != null  and processStatusDesc != ''">and process_status_desc =
                #{processStatusDesc}
            </if>
            <if test="checkLevel != null  and checkLevel != ''">and check_level = #{checkLevel}</if>
            <if test="checkLevelDesc != null  and checkLevelDesc != ''">and check_level_desc = #{checkLevelDesc}</if>
            <if test="selectTeamId != null ">and select_team_id = #{selectTeamId}</if>
            <if test="selectTeamName != null  and selectTeamName != ''">and select_team_name like concat('%',
                #{selectTeamName}, '%')
            </if>
            <if test="selectTeamLeaderId != null ">and select_team_leader_id = #{selectTeamLeaderId}</if>
            <if test="selectTeamLeaderName != null  and selectTeamLeaderName != ''">and select_team_leader_name like
                concat('%', #{selectTeamLeaderName}, '%')
            </if>
            <if test="isSelectTeam != null ">and is_select_team = #{isSelectTeam}</if>
            <if test="isSelfCheck != null ">and is_self_check = #{isSelfCheck}</if>
            <if test="completionTime != null ">and completion_time = #{completionTime}</if>
            <if test="instanceId != null ">and instance_id = #{instanceId}</if>
            <if test="checkedBrigadeId != null ">and checked_brigade_id = #{checkedBrigadeId}</if>
            <if test="checkedBrigadeName != null  and checkedBrigadeName != ''">and checked_brigade_name like
                concat('%', #{checkedBrigadeName}, '%')
            </if>
            <if test="checkedBrigadeLeaderId != null ">and checked_brigade_leader_id = #{checkedBrigadeLeaderId}</if>
            <if test="checkedBrigadeLeaderName != null  and checkedBrigadeLeaderName != ''">and
                checked_brigade_leader_name like concat('%', #{checkedBrigadeLeaderName}, '%')
            </if>
            <if test="startDate != null and endDate != null">
                and (check_time >= #{startDate}
                and check_time <![CDATA[ < ]]> date_add(#{endDate} , interval 1 day))
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="selectCheckCorrectionById" parameterType="Long" resultMap="CheckCorrectionResult">
        <include refid="selectCheckCorrectionVo"/>
        where id = #{id}
    </select>

    <insert id="insertCheckCorrection" parameterType="CheckCorrection" useGeneratedKeys="true" keyProperty="id">
        insert into check_correction
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tenantId != null">tenant_id,</if>
            <if test="revision != null">revision,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="correctionCode != null and correctionCode != ''">correction_code,</if>
            <if test="checkRecordId != null">check_record_id,</if>
            <if test="rectificationDetails != null">rectification_details,</if>
            <if test="responsibleUserId != null">responsible_user_id,</if>
            <if test="correctionDuration != null">correction_duration,</if>
            <if test="correctionResult != null">correction_result,</if>
            <if test="correctionTime != null">correction_time,</if>
            <if test="verifierUserId != null">verifier_user_id,</if>
            <if test="verificationResult != null">verification_result,</if>
            <if test="verificationTime != null">verification_time,</if>
            <if test="status != null">status,</if>
            <if test="responsibleUserName != null and responsibleUserName != ''">responsible_user_name,</if>
            <if test="verifierUserName != null and verifierUserName != ''">verifier_user_name,</if>
            <if test="checkedLevel != null and checkedLevel != ''">checked_level,</if>
            <if test="evidenceUrl != null">evidence_url,</if>
            <if test="remark != null">remark,</if>
            <if test="statusDesc != null and statusDesc != ''">status_desc,</if>
            <if test="checkedLevelDesc != null and checkedLevelDesc != ''">checked_level_desc,</if>
            <if test="verificationResultDesc != null">verification_result_desc,</if>
            <if test="evidenceId != null">evidence_id,</if>
            <if test="comprehensiveEvaluation != null">comprehensive_evaluation,</if>
            <if test="rectificationSuggestions != null">rectification_suggestions,</if>
            <if test="checkerId != null">checker_id,</if>
            <if test="checkerName != null">checker_name,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="terminlCode != null">terminl_code,</if>
            <if test="terminlName != null">terminl_name,</if>
            <if test="regionalCode != null">regional_code,</if>
            <if test="regionalName != null">regional_name,</if>
            <if test="channelCode != null">channel_code,</if>
            <if test="channelName != null">channel_name,</if>
            <if test="checkedDepartmentId != null">checked_department_id,</if>
            <if test="checkedDepartmentName != null">checked_department_name,</if>
            <if test="checkedTeamId != null">checked_team_id,</if>
            <if test="checkedTeamName != null">checked_team_name,</if>
            <if test="checkedDepartmentLeaderId != null">checked_department_leader_id,</if>
            <if test="checkedDepartmentLeaderName != null">checked_department_leader_name,</if>
            <if test="checkedTeamLeaderId != null">checked_team_leader_id,</if>
            <if test="checkedTeamLeaderName != null">checked_team_leader_name,</if>
            <if test="checkedPersonnelId != null">checked_personnel_id,</if>
            <if test="checkedPersonnelName != null">checked_personnel_name,</if>
            <if test="rectificationDeadline != null">rectification_deadline,</if>
            <if test="taskCode != null">task_code,</if>
            <if test="taskName != null">task_name,</if>
            <if test="documentCode != null">document_code,</if>
            <if test="documentName != null">document_name,</if>
            <if test="correctionName != null">correction_name,</if>
            <if test="checkedDeptId != null">checked_dept_id,</if>
            <if test="checkedDeptName != null">checked_dept_name,</if>
            <if test="processStatus != null">process_status,</if>
            <if test="processStatusDesc != null">process_status_desc,</if>
            <if test="checkLevel != null">check_level,</if>
            <if test="checkLevelDesc != null">check_level_desc,</if>
            <if test="selectTeamId != null">select_team_id,</if>
            <if test="selectTeamName != null">select_team_name,</if>
            <if test="selectTeamLeaderId != null">select_team_leader_id,</if>
            <if test="selectTeamLeaderName != null">select_team_leader_name,</if>
            <if test="isSelectTeam != null">is_select_team,</if>
            <if test="isSelfCheck != null">is_self_check,</if>
            <if test="completionTime != null">completion_time,</if>
            <if test="instanceId != null">instance_id,</if>
            <if test="checkedBrigadeId != null">checked_brigade_id,</if>
            <if test="checkedBrigadeName != null">checked_brigade_name,</if>
            <if test="checkedBrigadeLeaderId != null">checked_brigade_leader_id,</if>
            <if test="checkedBrigadeLeaderName != null">checked_brigade_leader_name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tenantId != null">#{tenantId},</if>
            <if test="revision != null">#{revision},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="correctionCode != null and correctionCode != ''">#{correctionCode},</if>
            <if test="checkRecordId != null">#{checkRecordId},</if>
            <if test="rectificationDetails != null">#{rectificationDetails},</if>
            <if test="responsibleUserId != null">#{responsibleUserId},</if>
            <if test="correctionDuration != null">#{correctionDuration},</if>
            <if test="correctionResult != null">#{correctionResult},</if>
            <if test="correctionTime != null">#{correctionTime},</if>
            <if test="verifierUserId != null">#{verifierUserId},</if>
            <if test="verificationResult != null">#{verificationResult},</if>
            <if test="verificationTime != null">#{verificationTime},</if>
            <if test="status != null">#{status},</if>
            <if test="responsibleUserName != null and responsibleUserName != ''">#{responsibleUserName},</if>
            <if test="verifierUserName != null and verifierUserName != ''">#{verifierUserName},</if>
            <if test="checkedLevel != null and checkedLevel != ''">#{checkedLevel},</if>
            <if test="evidenceUrl != null">#{evidenceUrl},</if>
            <if test="remark != null">#{remark},</if>
            <if test="statusDesc != null and statusDesc != ''">#{statusDesc},</if>
            <if test="checkedLevelDesc != null and checkedLevelDesc != ''">#{checkedLevelDesc},</if>
            <if test="verificationResultDesc != null">#{verificationResultDesc},</if>
            <if test="evidenceId != null">#{evidenceId},</if>
            <if test="comprehensiveEvaluation != null">#{comprehensiveEvaluation},</if>
            <if test="rectificationSuggestions != null">#{rectificationSuggestions},</if>
            <if test="checkerId != null">#{checkerId},</if>
            <if test="checkerName != null">#{checkerName},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="terminlCode != null">#{terminlCode},</if>
            <if test="terminlName != null">#{terminlName},</if>
            <if test="regionalCode != null">#{regionalCode},</if>
            <if test="regionalName != null">#{regionalName},</if>
            <if test="channelCode != null">#{channelCode},</if>
            <if test="channelName != null">#{channelName},</if>
            <if test="checkedDepartmentId != null">#{checkedDepartmentId},</if>
            <if test="checkedDepartmentName != null">#{checkedDepartmentName},</if>
            <if test="checkedTeamId != null">#{checkedTeamId},</if>
            <if test="checkedTeamName != null">#{checkedTeamName},</if>
            <if test="checkedDepartmentLeaderId != null">#{checkedDepartmentLeaderId},</if>
            <if test="checkedDepartmentLeaderName != null">#{checkedDepartmentLeaderName},</if>
            <if test="checkedTeamLeaderId != null">#{checkedTeamLeaderId},</if>
            <if test="checkedTeamLeaderName != null">#{checkedTeamLeaderName},</if>
            <if test="checkedPersonnelId != null">#{checkedPersonnelId},</if>
            <if test="checkedPersonnelName != null">#{checkedPersonnelName},</if>
            <if test="rectificationDeadline != null">#{rectificationDeadline},</if>
            <if test="taskCode != null">#{taskCode},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="documentCode != null">#{documentCode},</if>
            <if test="documentName != null">#{documentName},</if>
            <if test="correctionName != null">#{correctionName},</if>
            <if test="checkedDeptId != null">#{checkedDeptId},</if>
            <if test="checkedDeptName != null">#{checkedDeptName},</if>
            <if test="processStatus != null">#{processStatus},</if>
            <if test="processStatusDesc != null">#{processStatusDesc},</if>
            <if test="checkLevel != null">#{checkLevel},</if>
            <if test="checkLevelDesc != null">#{checkLevelDesc},</if>
            <if test="selectTeamId != null">#{selectTeamId},</if>
            <if test="selectTeamName != null">#{selectTeamName},</if>
            <if test="selectTeamLeaderId != null">#{selectTeamLeaderId},</if>
            <if test="selectTeamLeaderName != null">#{selectTeamLeaderName},</if>
            <if test="isSelectTeam != null">#{isSelectTeam},</if>
            <if test="isSelfCheck != null">#{isSelfCheck},</if>
            <if test="completionTime != null">#{completionTime},</if>
            <if test="instanceId != null">#{instanceId},</if>
            <if test="checkedBrigadeId != null">#{checkedBrigadeId},</if>
            <if test="checkedBrigadeName != null">#{checkedBrigadeName},</if>
            <if test="checkedBrigadeLeaderId != null">#{checkedBrigadeLeaderId},</if>
            <if test="checkedBrigadeLeaderName != null">#{checkedBrigadeLeaderName},</if>
        </trim>
    </insert>

    <update id="updateCheckCorrection" parameterType="CheckCorrection">
        update check_correction
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="revision != null">revision = #{revision},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="correctionCode != null and correctionCode != ''">correction_code = #{correctionCode},</if>
            <if test="checkRecordId != null">check_record_id = #{checkRecordId},</if>
            <if test="rectificationDetails != null">rectification_details = #{rectificationDetails},</if>
            <if test="responsibleUserId != null">responsible_user_id = #{responsibleUserId},</if>
            <if test="correctionDuration != null">correction_duration = #{correctionDuration},</if>
            <if test="correctionResult != null">correction_result = #{correctionResult},</if>
            <if test="correctionTime != null">correction_time = #{correctionTime},</if>
            <if test="verifierUserId != null">verifier_user_id = #{verifierUserId},</if>
            <if test="verificationResult != null">verification_result = #{verificationResult},</if>
            <if test="verificationTime != null">verification_time = #{verificationTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="responsibleUserName != null and responsibleUserName != ''">responsible_user_name =
                #{responsibleUserName},
            </if>
            <if test="verifierUserName != null and verifierUserName != ''">verifier_user_name = #{verifierUserName},
            </if>
            <if test="checkedLevel != null and checkedLevel != ''">checked_level = #{checkedLevel},</if>
            <if test="evidenceUrl != null">evidence_url = #{evidenceUrl},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="statusDesc != null and statusDesc != ''">status_desc = #{statusDesc},</if>
            <if test="checkedLevelDesc != null and checkedLevelDesc != ''">checked_level_desc = #{checkedLevelDesc},
            </if>
            <if test="verificationResultDesc != null">verification_result_desc = #{verificationResultDesc},</if>
            <if test="evidenceId != null">evidence_id = #{evidenceId},</if>
            <if test="comprehensiveEvaluation != null">comprehensive_evaluation = #{comprehensiveEvaluation},</if>
            <if test="rectificationSuggestions != null">rectification_suggestions = #{rectificationSuggestions},</if>
            <if test="checkerId != null">checker_id = #{checkerId},</if>
            <if test="checkerName != null">checker_name = #{checkerName},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="terminlCode != null">terminl_code = #{terminlCode},</if>
            <if test="terminlName != null">terminl_name = #{terminlName},</if>
            <if test="regionalCode != null">regional_code = #{regionalCode},</if>
            <if test="regionalName != null">regional_name = #{regionalName},</if>
            <if test="channelCode != null">channel_code = #{channelCode},</if>
            <if test="channelName != null">channel_name = #{channelName},</if>
            <if test="checkedDepartmentId != null">checked_department_id = #{checkedDepartmentId},</if>
            <if test="checkedDepartmentName != null">checked_department_name = #{checkedDepartmentName},</if>
            <if test="checkedTeamId != null">checked_team_id = #{checkedTeamId},</if>
            <if test="checkedTeamName != null">checked_team_name = #{checkedTeamName},</if>
            <if test="checkedDepartmentLeaderId != null">checked_department_leader_id = #{checkedDepartmentLeaderId},
            </if>
            <if test="checkedDepartmentLeaderName != null">checked_department_leader_name =
                #{checkedDepartmentLeaderName},
            </if>
            <if test="checkedTeamLeaderId != null">checked_team_leader_id = #{checkedTeamLeaderId},</if>
            <if test="checkedTeamLeaderName != null">checked_team_leader_name = #{checkedTeamLeaderName},</if>
            <if test="checkedPersonnelId != null">checked_personnel_id = #{checkedPersonnelId},</if>
            <if test="checkedPersonnelName != null">checked_personnel_name = #{checkedPersonnelName},</if>
            <if test="rectificationDeadline != null">rectification_deadline = #{rectificationDeadline},</if>
            <if test="taskCode != null">task_code = #{taskCode},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="documentCode != null">document_code = #{documentCode},</if>
            <if test="documentName != null">document_name = #{documentName},</if>
            <if test="correctionName != null">correction_name = #{correctionName},</if>
            <if test="checkedDeptId != null">checked_dept_id = #{checkedDeptId},</if>
            <if test="checkedDeptName != null">checked_dept_name = #{checkedDeptName},</if>
            <if test="processStatus != null">process_status = #{processStatus},</if>
            <if test="processStatusDesc != null">process_status_desc = #{processStatusDesc},</if>
            <if test="checkLevel != null">check_level = #{checkLevel},</if>
            <if test="checkLevelDesc != null">check_level_desc = #{checkLevelDesc},</if>
            <if test="selectTeamId != null">select_team_id = #{selectTeamId},</if>
            <if test="selectTeamName != null">select_team_name = #{selectTeamName},</if>
            <if test="selectTeamLeaderId != null">select_team_leader_id = #{selectTeamLeaderId},</if>
            <if test="selectTeamLeaderName != null">select_team_leader_name = #{selectTeamLeaderName},</if>
            <if test="isSelectTeam != null">is_select_team = #{isSelectTeam},</if>
            <if test="isSelfCheck != null">is_self_check = #{isSelfCheck},</if>
            <if test="completionTime != null">completion_time = #{completionTime},</if>
            <if test="instanceId != null">instance_id = #{instanceId},</if>
            <if test="checkedBrigadeId != null">checked_brigade_id = #{checkedBrigadeId},</if>
            <if test="checkedBrigadeName != null">checked_brigade_name = #{checkedBrigadeName},</if>
            <if test="checkedBrigadeLeaderId != null">checked_brigade_leader_id = #{checkedBrigadeLeaderId},</if>
            <if test="checkedBrigadeLeaderName != null">checked_brigade_leader_name = #{checkedBrigadeLeaderName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCheckCorrectionById" parameterType="Long">
        delete
        from check_correction
        where id = #{id}
    </delete>

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

    <!-- 统计用户在指定时间范围内的巡检问题数（按二级分类） -->
    <select id="countCheckProblemsByModule" resultType="com.sundot.airport.common.dto.ModuleStatisticsDTO">
        SELECT
            cpi.category_name_two AS moduleName,
            COUNT(1) AS problemCount
        FROM check_correction cc
        INNER JOIN check_project_item cpi ON (cpi.source_id = cc.id AND cpi.type = 'CHECK_CORRECTION')
        INNER JOIN check_user cu ON (cu.source_id = cpi.id AND cu.type = 'PROBLEM_RECTIFICATION_INSPECTION_ITEM_DETAILS')
        WHERE cu.user_id = #{userId}
          AND cc.check_time &gt;= #{startDate}
          AND cc.check_time &lt; #{endDate}
        GROUP BY cpi.category_name_two
    </select>
</mapper>