<?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.xintong.visualinspection.visuallnspection_fjq.dao.FwqCheckOtherDao">

    <select id="getAllCheckOther" parameterType="com.xintong.visualinspection.bean.FwqCheckOther" resultType="com.xintong.visualinspection.bean.FwqCheckOther">
        SELECT *
        FROM other_check
        WHERE check_type = #{check_type}
        <if test="check_time_name != null and check_time_name != ''">
            AND check_time_name = #{check_time_name}
        </if>
        <if test="dept_id != null">
            AND dept_id = #{dept_id}
        </if>
        <if test="special_check_type != null">
            AND special_check_type = #{special_check_type}
        </if>
        ORDER BY check_time DESC
    </select>

    <insert id="addCheckOther" parameterType="com.xintong.visualinspection.bean.FwqCheckOther">
        INSERT INTO
        other_check
        (dept_id,check_person_id,check_score,check_item_id,remark,check_type,file_ids,check_num,check_time,check_time_name,update_time,wrecker_check_type, special_check_type)
        VALUES
        (#{dept_id},#{check_person_id},#{check_score},#{check_item_id},#{remark},#{check_type},#{file_ids},#{check_num},#{check_time},#{check_time_name},now(),#{wrecker_check_type},#{special_check_type})
    </insert>

    <delete id="deleteCheckOther" parameterType="java.lang.Long" >
        DELETE FROM other_check WHERE id =#{id}
    </delete>

    <update id="updateCheckOther" parameterType="com.xintong.visualinspection.bean.FwqCheckOther" >
        UPDATE
        other_check
        SET
        <if test="dept_id != null">dept_id = #{dept_id}</if>
        <if test="check_person_id != null">,check_person_id = #{check_person_id}</if>
        <if test="check_type != null">,check_type = #{check_type}</if>
        <if test="check_type != null">,check_type = #{check_type}</if>
        <if test="check_item_id != null">,check_item_id = #{check_item_id}</if>
        <if test="remark != null and remark !='' " >,remark = #{remark}</if>
        <if test="check_score != null">,check_score = #{check_score}</if>
        <if test="file_ids != null">,file_ids = #{file_ids}</if>
        <if test="check_time != null">,check_time = #{check_time}</if>
        <if test="check_time_name !=  null">,check_time_name= #{check_time_name} </if>
        <if test="check_num != null">,check_num = #{check_num}</if>
        <if test="wrecker_check_type != null">,wrecker_check_type = #{wrecker_check_type}</if>
        <if test="special_check_type != null">,special_check_type = #{special_check_type}</if>
        WHERE
        id = #{id}
    </update>

    <select id="selectCheckById" parameterType="java.lang.Long" resultType="com.xintong.visualinspection.bean.FwqCheckOther" >
        SELECT o.id,o.dept_id,o.check_person_id,o.check_score,o.check_item_id,o.remark,o.check_type,o.file_ids,o.check_num,o.check_time,
        o.check_time_name,o.delete_flag,o.update_time, o.wrecker_check_type,o.special_check_type
        FROM other_check o
        WHERE o.id = #{id}
    </select>

</mapper>


