LinggangKeyWorkLocationMapper.xml 8.43 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.mapper.key.location.LinggangKeyWorkLocationMapper">
    <resultMap id="BaseResultMap" type="com.ruoyi.domain.key.location.LinggangKeyWorkLocation">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="yard_Id" jdbcType="INTEGER" property="yardId"/>
        <result column="yard_Name" jdbcType="VARCHAR" property="yardName"/>
        <result column="device" jdbcType="VARCHAR" property="device"/>
        <result column="cabinet_No" jdbcType="VARCHAR" property="cabinetNo"/>
        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="del_flag" jdbcType="BIT" property="delFlag"/>
        <result column="event_Type" jdbcType="INTEGER" property="eventType"/>
        <result column="key_info_id" jdbcType="INTEGER" property="keyInfoId"/>
        <result column="schedule_date" jdbcType="TIMESTAMP" property="scheduleDate"/>
        <result column="scheduling_id" jdbcType="VARCHAR" property="schedulingId"/>
    </resultMap>

    <insert id="insertSelective" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
            parameterType="com.ruoyi.domain.key.location.LinggangKeyWorkLocation">
        INSERT INTO key_work_location
        <include refid="insertSelectiveColumn"></include>
        <include refid="insertSelectiveValue"></include>
    </insert>
    <select id="listOfDeviceKeyIdScheduleDate"  resultMap="BaseResultMap">
        select <include refid="columns"></include> from key_work_location
        where del_flag = 0 and(
        <foreach collection="localtions" item="item" separator="or" open="(" close=")">
            device=#{item.device} and key_info_id=#{item.keyInfoId} and schedule_date=#{item.scheduleDate}
        </foreach>
        )
    </select>

    <select id="listRecent" resultMap="BaseResultMap">
        select <include refid="columns"></include> from key_work_location
        where 1=1 and
        <foreach collection="localtions" open="(" close=")" separator="or " item="item">
            <include refid="where"></include>
        </foreach>
    </select>
    <select id="listRecentDates" resultType="com.ruoyi.domain.key.location.LinggangKeyWorkLocation">
        select <include refid="columns"></include> from key_work_location
        where 1=1
              <if test="null != keyInfoIds">
                  and key_info_id in
                  <foreach collection="keyInfoIds" item="item" separator="," open="(" close=")">#{item}</foreach>
              </if>

            <if test="null!=dates">
               and (
                <foreach collection="dates" item="item" separator="or " open="(" close=")">
                    schedule_date between #{item.startDate} and #{item.endDate}
                </foreach>
                )
            </if>
    </select>

    <sql id="columns">
        id
        ,  yard_Id   ,  yard_Name   ,  device   ,  cabinet_No   ,  create_by   ,  create_time   ,  update_by   ,  update_time   ,  del_flag   ,  event_Type   ,  key_info_id   ,  schedule_date   ,  scheduling_id
    </sql>

    <sql id="insert_columns">
        id
        ,  yard_Id  ,  yard_Name  ,  device  ,  cabinet_No  ,  create_by  ,  create_time  ,  update_by  ,  update_time  ,  del_flag  ,  event_Type  ,  key_info_id  ,  schedule_date  ,  scheduling_id
    </sql>

    <sql id="insert_values">
        #{id}
        ,
        #{yardId},
        #{yardName},
        #{device},
        #{cabinetNo},
        #{createBy},
        #{createTime},
        #{updateBy},
        #{updateTime},
        #{delFlag},
        #{eventType},
        #{keyInfoId},
        #{scheduleDate},
        #{schedulingId}
    </sql>

    <sql id="insertSelectiveColumn">
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="null!=id">id,</if>
            <if test="null!=yardId">yard_Id,</if>
            <if test="null!=yardName">yard_Name,</if>
            <if test="null!=device">device,</if>
            <if test="null!=cabinetNo">cabinet_No,</if>
            <if test="null!=createBy">create_by,</if>
            <if test="null!=createTime">create_time,</if>
            <if test="null!=updateBy">update_by,</if>
            <if test="null!=updateTime">update_time,</if>
            <if test="null!=delFlag">del_flag,</if>
            <if test="null!=eventType">event_Type,</if>
            <if test="null!=keyInfoId">key_info_id,</if>
            <if test="null!=scheduleDate">schedule_date,</if>
            <if test="null!=schedulingId">scheduling_id,</if>
        </trim>
    </sql>

    <sql id="insertSelectiveValue">
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="null!=id">#{id,jdbcType=BIGINT},</if>
            <if test="null!=yardId">#{yardId,jdbcType=INTEGER},</if>
            <if test="null!=yardName">#{yardName,jdbcType=VARCHAR},</if>
            <if test="null!=device">#{device,jdbcType=VARCHAR},</if>
            <if test="null!=cabinetNo">#{cabinetNo,jdbcType=VARCHAR},</if>
            <if test="null!=createBy">#{createBy,jdbcType=BIGINT},</if>
            <if test="null!=createTime">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="null!=updateBy">#{updateBy,jdbcType=BIGINT},</if>
            <if test="null!=updateTime">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="null!=delFlag">#{delFlag,jdbcType=BIT},</if>
            <if test="null!=eventType">#{eventType,jdbcType=INTEGER},</if>
            <if test="null!=keyInfoId">#{keyInfoId,jdbcType=INTEGER},</if>
            <if test="null!=scheduleDate">#{scheduleDate,jdbcType=TIMESTAMP},</if>
            <if test="null!=schedulingId">#{schedulingId,jdbcType=VARCHAR},</if>
        </trim>
    </sql>

    <sql id="updateByPrimaryKeySelectiveSql">
        <set>
            <if test="null!=id">id = #{id,jdbcType=BIGINT},</if>
            <if test="null!=yardId">yard_Id = #{yardId,jdbcType=INTEGER},</if>
            <if test="null!=yardName">yard_Name = #{yardName,jdbcType=VARCHAR},</if>
            <if test="null!=device">device = #{device,jdbcType=VARCHAR},</if>
            <if test="null!=cabinetNo">cabinet_No = #{cabinetNo,jdbcType=VARCHAR},</if>
            <if test="null!=createBy">create_by = #{createBy,jdbcType=BIGINT},</if>
            <if test="null!=createTime">create_time = #{createTime,jdbcType=TIMESTAMP},</if>
            <if test="null!=updateBy">update_by = #{updateBy,jdbcType=BIGINT},</if>
            <if test="null!=updateTime">update_time = #{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="null!=delFlag">del_flag = #{delFlag,jdbcType=BIT},</if>
            <if test="null!=eventType">event_Type = #{eventType,jdbcType=INTEGER},</if>
            <if test="null!=keyInfoId">key_info_id = #{keyInfoId,jdbcType=INTEGER},</if>
            <if test="null!=scheduleDate">schedule_date = #{scheduleDate,jdbcType=TIMESTAMP},</if>
            <if test="null!=schedulingId">scheduling_id = #{schedulingId,jdbcType=VARCHAR},</if>
        </set>
    </sql>

    <sql id="where">
        <if test="null!=id">AND id = #{id,jdbcType=BIGINT},</if>
        <if test="null!=yardId">AND yard_Id = #{yardId,jdbcType=INTEGER},</if>
        <if test="null!=yardName">AND yard_Name = #{yardName,jdbcType=VARCHAR},</if>
        <if test="null!=device">AND device = #{device,jdbcType=VARCHAR},</if>
        <if test="null!=cabinetNo">AND cabinet_No = #{cabinetNo,jdbcType=VARCHAR},</if>
        <if test="null!=createBy">AND create_by = #{createBy,jdbcType=BIGINT},</if>
        <if test="null!=createTime">AND create_time = #{createTime,jdbcType=TIMESTAMP},</if>
        <if test="null!=updateBy">AND update_by = #{updateBy,jdbcType=BIGINT},</if>
        <if test="null!=updateTime">AND update_time = #{updateTime,jdbcType=TIMESTAMP},</if>
        <if test="null!=delFlag">AND del_flag = #{delFlag,jdbcType=BIT},</if>
        <if test="null!=eventType">AND event_Type = #{eventType,jdbcType=INTEGER},</if>
        <if test="null!=keyInfoId">AND key_info_id = #{keyInfoId,jdbcType=INTEGER},</if>
        <if test="null!=scheduleDate">AND schedule_date = #{scheduleDate,jdbcType=TIMESTAMP},</if>
        <if test="null!=schedulingId">AND scheduling_id = #{schedulingId,jdbcType=VARCHAR},</if>
    </sql>
</mapper>