DriverSchedulingMapper.xml 3.89 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.DriverSchedulingMapper">


    <resultMap id="Scheduling" type="com.ruoyi.domain.DriverScheduling">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="job_code" property="jobCode"/>
        <result column="name" property="name"/>
        <result column="posts" property="posts"/>
        <result column="schedule_date" property="scheduleDate" jdbcType="DATE"/>
        <result column="line_name" property="lineName"/>
        <result column="lp_name" property="lpName"/>
        <result column="nbbm" property="nbbm"/>
        <result column="bc_type" property="bcType"/>
        <result column="fcsj_t" property="fcsjT" jdbcType="BIGINT"/>
        <result column="zdsj_t" property="zdsjT" jdbcType="BIGINT"/>
        <result column="sign_in_id" property="signInId" jdbcType="BIGINT"/>
        <result column="ex_type" property="exType" jdbcType="TINYINT"/>
        <result column="sign_time" property="signTime" jdbcType="DATETIMEOFFSET"/>
        <result column="alcohol_flag" property="alcoholFlag" jdbcType="DATETIMEOFFSET"/>
        <result column="alcohol_intake" property="alcoholIntake"/>
    </resultMap>
    <insert id="insertRoster" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
        insert into scheduling (schedule_date,line_name,job_code,`name`,posts,lp_name,nbbm,bc_type,fcsj_t,zdsj_t)
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.scheduleDate},
            #{item.lineName},
            #{item.jobCode},
            #{item.name},
            #{item.posts},
            #{item.lpName},
            #{item.nbbm},
            #{item.bcType},
            #{item.fcsjT},
            #{item.zdsjT}
            )
        </foreach>
        on duplicate key update
        job_code = values(job_code)
    </insert>
    <update id="updateRoster">
        update scheduling
        set sign_in_id     = #{signInId},
            ex_type        = #{exType},
            sign_time      = #{signTime},
            remark         = #{remark},
            sign_type      = #{signType},
            alcohol_flag   = #{alcoholFlag},
            alcohol_intake = #{alcoholIntake}
        where id = #{scheduling.id}
    </update>

    <select id="queryToDay" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling">
        select scheduling.*,driver.fleet_name fleetName,equipment.site_name siteName from
        scheduling left join driver on scheduling.job_code = driver.job_code
        left join sign_in on scheduling.sign_in_id = sign_in.id
        left join equipment on equipment.device_id = sign_in.device_id
        <where>
            <if test="jobCode !=null and jobCode != ''">
                and scheduling.job_code = #{jobCode}
            </if>
            <if test="name !=null and name != ''">
                and `name` = #{name}
            </if>
            <if test="lineName !=null and lineName != ''">
                and scheduling.line_name like concat('%', #{lineName}, '%')
            </if>
            <if test="date != null and date != ''">
                and schedule_date = #{date}
            </if>
        </where>


    </select>
    <select id="queryByMonth" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling">
        select scheduling.*, driver.fleet_name fleetName,equipment.site_name siteName
        from scheduling
                 left join driver on driver.job_code = scheduling.job_code
                 left join sign_in on scheduling.sign_in_id = sign_in.id
                 left join equipment on equipment.device_id = sign_in.device_id
        where schedule_date &gt;= #{startDate}
          and schedule_date &lt;= #{endDate}
    </select>
</mapper>