SignInMapper.xml 8.34 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.in.mapper.SignInMapper">
    <resultMap type="com.ruoyi.pojo.response.SignInResponseVo" id="SignInResultVO">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="jobCode"    column="jobCode"    />
        <result property="deviceId"    column="device_id"    />
        <result property="ip"    column="ip"    />
        <result property="image"    column="image"    />
        <result property="status"    column="status"    />
        <result property="updateBy"    column="update_by"    />
        <result property="singnIn"    column="singn_in"    />
        <result property="alcoholFlag"    column="alcohol_flag"    />
        <result property="type"    column="type"    />
        <result property="updateTime"    column="update_time"    />
        <result property="alcoholIntake"    column="alcohol_intake"    />
        <result property="remark"    column="remark"    />
        <result property="posts"    column="posts"    />
        <result property="name"    column="personnel_name"    />
    </resultMap>
    <resultMap type="SignIn" id="SignInResult">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="jobCode"    column="jobCode"    />
        <result property="deviceId"    column="device_id"    />
        <result property="ip"    column="ip"    />
        <result property="image"    column="image"    />
        <result property="status"    column="status"    />
        <result property="updateBy"    column="update_by"    />
        <result property="singnIn"    column="singn_in"    />
        <result property="alcoholFlag"    column="alcohol_flag"    />
        <result property="type"    column="type"    />
        <result property="updateTime"    column="update_time"    />
        <result property="alcoholIntake"    column="alcohol_intake"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSignInVo">
        select id, create_time, jobCode, device_id,ip,image, status, update_by, singn_in, alcohol_flag, type, update_time, alcohol_intake, remark from sign_in
    </sql>

    <select id="selectSignInList" parameterType="com.ruoyi.pojo.response.SignInResponseVo" resultMap="SignInResultVO">
        select sign_in.*,driver.posts,driver.personnel_name
        from sign_in,driver
        WHERE
        driver.job_code = sign_in.jobCode
            <if test="jobCode != null  and jobCode != ''"> and jobCode = #{jobCode}</if>
            <if test="ip != null  and ip != ''"> and ip = #{ip}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="singnIn != null  and singnIn != ''"> and singn_in = #{singnIn}</if>
            <if test="alcoholFlag != null "> and alcohol_flag = #{alcoholFlag}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="alcoholIntake != null "> and alcohol_intake = #{alcoholIntake}</if>
        order by create_time desc
    </select>
    
    <select id="selectSignInById" parameterType="Long" resultMap="SignInResult">
        <include refid="selectSignInVo"/>
        where id = #{id}
    </select>
    <select id="getReportScrollViewTable" resultType="com.ruoyi.pojo.response.ReportViewResponseVo">
        SELECT
        sign_in.id,
        sign_in.singn_in singnIn,
        driver.job_code jobCode,
        personnel_name `name`,
        sign_in.create_time createTime,
        `status`,
        type,
        alcohol_flag alcoholFlag,
        alcohol_intake alcoholIntake,
        sign_in.image,
        sign_in.remark,
        driver.posts
        FROM
        sign_in,
        driver
        WHERE
        sign_in.jobCode = driver.job_code
        <if test="jobCode != '' and jobCode != null">
          and  sign_in.jobCode = #{jobCode}
        </if>
        <if test="startTime != '' and startTime != null">
            and DATE_FORMAT(sign_in.create_time,'%Y-%m-%d') >= #{startTime}
            and DATE_FORMAT(sign_in.create_time,'%Y-%m-%d') &lt;= #{endTime}
        </if>
        <if test="status != '' and status != null">
            and sign_in.status = #{status}
        </if>
        <if test="name != '' and name != null">
            and driver.personnel_name = #{name}
        </if>
        <if test="ids != null and ids.size() > 0">
            and sign_in.id in
        <foreach collection="ids" item="id" open="(" close=")" separator=",">
            #{id}
        </foreach>
        </if>
        order by sign_in.create_time desc
    </select>
    <select id="getSignErrorList" resultType="com.ruoyi.in.domain.SignIn">
        <include refid="selectSignInVo"></include>
        where `status` = 2
        <if test="endTime != '' and endTime != null">
            and DATE_FORMAT(create_time,'%Y-%m-%d') >= #{startTime}
            and DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= #{endTime}
        </if>
        <if test="jobCode != '' and jobCode != null">
            and jobCode = #{jobCode}
        </if>

    </select>

    <insert id="insertSignIn" parameterType="SignIn" useGeneratedKeys="true" keyProperty="id">
        insert into sign_in
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="createTime != null">create_time,</if>
            <if test="jobCode != null">jobCode,</if>
            <if test="ip != null">ip,</if>
            <if test="deviceId != null">device_id,</if>
            <if test="image != null">image,</if>
            <if test="status != null">status,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="singnIn != null">singn_in,</if>
            <if test="alcoholFlag != null">alcohol_flag,</if>
            <if test="type != null">`type`,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="alcoholIntake != null">alcohol_intake,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createTime != null">#{createTime},</if>
            <if test="jobCode != null">#{jobCode},</if>
            <if test="ip != null">#{ip},</if>
            <if test="deviceId != null">#{deviceId},</if>
            <if test="image != null">#{image},</if>
            <if test="status != null">#{status},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="singnIn != null">#{singnIn},</if>
            <if test="alcoholFlag != null">#{alcoholFlag},</if>
            <if test="type != null">#{type},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="alcoholIntake != null">#{alcoholIntake},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateSignIn" parameterType="SignIn">
        update sign_in
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="jobCode != null">jobCode = #{jobCode},</if>
            <if test="ip != null">ip = #{ip},</if>
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="image != null">image = #{image},</if>
            <if test="status != null">status = #{status},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="singnIn != null">singn_in = #{singnIn},</if>
            <if test="alcoholFlag != null">alcohol_flag = #{alcoholFlag},</if>
            <if test="type != null">type = #{type},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="alcoholIntake != null">alcohol_intake = #{alcoholIntake},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSignInById" parameterType="Long">
        delete from sign_in where id = #{id}
    </delete>

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