DriverMapper.xml 8.61 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.ruoyi.driver.mapper.DriverMapper">
    
    <resultMap type="Driver" id="DriverResult">
        <result property="id"    column="id"    />
        <result property="jobCode"    column="job_code"    />
        <result property="companyCode"    column="company_code"    />
        <result property="brancheCompanyCode"    column="branche_company_code"    />
        <result property="personnelName"    column="personnel_name"    />
        <result property="papersCode"    column="papers_code"    />
        <result property="icCardCode"    column="ic_card_code"    />
        <result property="personnelType"    column="personnel_type"    />
        <result property="posts"    column="posts"    />
        <result property="card"    column="card"    />
        <result property="telphone"    column="telphone"    />
        <result property="icRfid"    column="ic_rfid"    />
        <result property="idRfid"    column="id_rfid"    />
        <result property="tagRfid"    column="tag_rfid"    />
        <result property="remark"    column="remark"    />
        <result property="lineName"    column="line_name"    />
        <result property="lineCode"    column="line_code"    />
    </resultMap>

    <sql id="selectDriverVo">
        select id, job_code, company_code, branche_company_code, personnel_name, papers_code, ic_card_code, personnel_type, posts, card, telphone, ic_rfid, id_rfid, tag_rfid, remark, line_name, line_code from driver
    </sql>
    <sql id="insertDriverVo">
        job_code, company_code, branche_company_code, personnel_name, papers_code, ic_card_code, personnel_type, posts, card, telphone, ic_rfid, id_rfid, tag_rfid, remark, line_name, line_code
    </sql>

    <select id="selectDriverList" parameterType="Driver" resultMap="DriverResult">
        <include refid="selectDriverVo"/>
        <where>  
            <if test="jobCode != null  and jobCode != ''"> and job_code = #{jobCode}</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="brancheCompanyCode != null  and brancheCompanyCode != ''"> and branche_company_code = #{brancheCompanyCode}</if>
            <if test="personnelName != null  and personnelName != ''"> and personnel_name like concat('%', #{personnelName}, '%')</if>
            <if test="papersCode != null  and papersCode != ''"> and papers_code = #{papersCode}</if>
            <if test="icCardCode != null  and icCardCode != ''"> and ic_card_code = #{icCardCode}</if>
            <if test="personnelType != null  and personnelType != ''"> and personnel_type = #{personnelType}</if>
            <if test="posts != null  and posts != ''"> and posts = #{posts}</if>
            <if test="card != null  and card != ''"> and card = #{card}</if>
            <if test="telphone != null  and telphone != ''"> and telphone = #{telphone}</if>
            <if test="icRfid != null  and icRfid != ''"> and ic_rfid = #{icRfid}</if>
            <if test="idRfid != null  and idRfid != ''"> and id_rfid = #{idRfid}</if>
            <if test="tagRfid != null  and tagRfid != ''"> and tag_rfid = #{tagRfid}</if>
            <if test="lineName != null  and lineName != ''"> and line_name like concat('%', #{lineName}, '%')</if>
            <if test="lineCode != null  and lineCode != ''"> and line_code = #{lineCode}</if>
        </where>
    </select>
    
    <select id="selectDriverById" parameterType="Long" resultMap="DriverResult">
        <include refid="selectDriverVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id">
        insert into driver
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jobCode != null and jobCode != ''">job_code,</if>
            <if test="companyCode != null and companyCode != ''">company_code,</if>
            <if test="brancheCompanyCode != null">branche_company_code,</if>
            <if test="personnelName != null">personnel_name,</if>
            <if test="papersCode != null">papers_code,</if>
            <if test="icCardCode != null">ic_card_code,</if>
            <if test="personnelType != null">personnel_type,</if>
            <if test="posts != null">posts,</if>
            <if test="card != null">card,</if>
            <if test="telphone != null">telphone,</if>
            <if test="icRfid != null">ic_rfid,</if>
            <if test="idRfid != null">id_rfid,</if>
            <if test="tagRfid != null">tag_rfid,</if>
            <if test="remark != null">remark,</if>
            <if test="lineName != null">line_name,</if>
            <if test="lineCode != null">line_code,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jobCode != null and jobCode != ''">#{jobCode},</if>
            <if test="companyCode != null and companyCode != ''">#{companyCode},</if>
            <if test="brancheCompanyCode != null">#{brancheCompanyCode},</if>
            <if test="personnelName != null">#{personnelName},</if>
            <if test="papersCode != null">#{papersCode},</if>
            <if test="icCardCode != null">#{icCardCode},</if>
            <if test="personnelType != null">#{personnelType},</if>
            <if test="posts != null">#{posts},</if>
            <if test="card != null">#{card},</if>
            <if test="telphone != null">#{telphone},</if>
            <if test="icRfid != null">#{icRfid},</if>
            <if test="idRfid != null">#{idRfid},</if>
            <if test="tagRfid != null">#{tagRfid},</if>
            <if test="remark != null">#{remark},</if>
            <if test="lineName != null">#{lineName},</if>
            <if test="lineCode != null">#{lineCode},</if>
         </trim>
    </insert>

    <update id="updateDriver" parameterType="Driver">
        update driver
        <trim prefix="SET" suffixOverrides=",">
            <if test="jobCode != null and jobCode != ''">job_code = #{jobCode},</if>
            <if test="companyCode != null and companyCode != ''">company_code = #{companyCode},</if>
            <if test="brancheCompanyCode != null">branche_company_code = #{brancheCompanyCode},</if>
            <if test="personnelName != null">personnel_name = #{personnelName},</if>
            <if test="papersCode != null">papers_code = #{papersCode},</if>
            <if test="icCardCode != null">ic_card_code = #{icCardCode},</if>
            <if test="personnelType != null">personnel_type = #{personnelType},</if>
            <if test="posts != null">posts = #{posts},</if>
            <if test="card != null">card = #{card},</if>
            <if test="telphone != null">telphone = #{telphone},</if>
            <if test="icRfid != null">ic_rfid = #{icRfid},</if>
            <if test="idRfid != null">id_rfid = #{idRfid},</if>
            <if test="tagRfid != null">tag_rfid = #{tagRfid},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="lineName != null">line_name = #{lineName},</if>
            <if test="lineCode != null">line_code = #{lineCode},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDriverById" parameterType="Long">
        delete from driver where id = #{id}
    </delete>

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


    <insert id="saveDrivers">

        INSERT INTO driver (
        <include refid="insertDriverVo"></include>
        )
        VALUES
        <foreach collection="drivers" item="item" index="index" separator=",">
            (
            #{item.jobCode,jdbcType=VARCHAR},
            #{item.companyCode,jdbcType=VARCHAR},
            #{item.brancheCompanyCode,jdbcType=VARCHAR},
            #{item.personnelName,jdbcType=VARCHAR},
            #{item.papersCode,jdbcType=VARCHAR},
            #{item.icCardCode,jdbcType=VARCHAR},
            #{item.personnelType,jdbcType=VARCHAR},
            #{item.posts,jdbcType=VARCHAR},
            #{item.card,jdbcType=VARCHAR},
            #{item.telphone,jdbcType=VARCHAR},
            #{item.icRfid,jdbcType=VARCHAR},
            #{item.idRfid,jdbcType=VARCHAR},
            #{item.tagRfid,jdbcType=VARCHAR},
            #{item.remark,jdbcType=VARCHAR},
            #{item.lineName,jdbcType=VARCHAR},
            #{item.lineCode,jdbcType=VARCHAR}
            )
        </foreach>
        on duplicate key update
        personnel_name = values(personnel_name)
    </insert>

</mapper>