DriverSchedulingMapper.xml 4.95 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"/>
        <result column="sign_type" property="signType"></result>
        <result column="remark" property="remark"></result>
        <result column="upDown" property="upDown"></result>
        <result column="qdzCode" property="qdzCode"></result>
        <result column="qdzName" property="qdzName"></result>
        <result column="zdzCode" property="zdzCode"></result>

    </resultMap>

    <sql id="selectColumn">
       id, job_code,name,posts,schedule_date,line_name,lp_name,nbbm,bc_type,fcsj_t,zdsj_t,sign_in_id,ex_type,sign_time,alcohol_flag,alcohol_intake,sign_type,remark
    </sql>


    <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,upDown,qdzCode,qdzName,zdzCode,zdzName,scheduling_type)
        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},#{item.upDown},#{item.qdzCode},#{item.qdzName},#{item.zdzCode},#{item.zdzName},#{item.type}
            )
        </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>

    <update id="updateRosterById" parameterType="com.ruoyi.domain.DriverScheduling">

    </update>

    <select id="queryToDay" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling">
        select scheduling.*,driver.fleet_name fleetName,equipment.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 scheduling.`name` = #{name}
            </if>
            <if test="lineName !=null and lineName != ''">
                and scheduling.line_name like concat('%', #{lineName}, '%')
            </if>
            <if test="date != null and date != '' and endDate != null and endDate != ''">
                and schedule_date between #{date} and #{endDate}
            </if>
            and (scheduling.scheduling_type = 1 or scheduling.scheduling_type is null)
        </where>




    </select>
    <select id="queryByMonth" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling">
        select scheduling.*, driver.fleet_name fleetName,equi pment.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>

    <select id="querySelectColumnById" parameterType="java.lang.Integer" resultMap="Scheduling">
        select <include refid="selectColumn"></include> from scheduling where id=#{id}
    </select>
</mapper>