zhangnaisong
2024-08-05 ae64126733bedc1a15a0177b105fec7f499ada81
ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
@@ -12,11 +12,58 @@
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
    </resultMap>
    <resultMap type="ArdTankLock" id="ArdTankLockWithStateResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
        <association property="ardTankLockState" javaType="com.ruoyi.sy.domain.ArdTankLockState">
            <result property="id"    column="sid"    />
            <result property="lockId"    column="lock_id"    />
            <result property="lockNum"    column="slock_num"    />
            <result property="lockState"    column="lock_state"    />
            <result property="lockPositionState"    column="lock_position_state"    />
            <result property="lockShellState"    column="lock_shell_state"    />
            <result property="restartState"    column="srestart_state"    />
            <result property="batterVoltage"    column="batter_voltage"    />
            <result property="powerVoltage"    column="power_voltage"    />
            <result property="uploadTime"    column="upload_time"    />
            <result property="uniqueMark"    column="unique_mark"    />
            <result property="lockStateMark"    column="lock_state_mark"    />
        </association>
    </resultMap>
    <resultMap type="ArdTankLock" id="ArdTankLockWithPasswordResult">
        <result property="id"    column="id"    />
        <result property="lockNum"    column="lock_num"    />
        <result property="lockName"    column="lock_name"    />
        <result property="imgPositionTop"    column="img_position_top"    />
        <result property="imgPositionLeft"    column="img_position_left"    />
        <result property="carId"    column="car_id"    />
        <result property="enable"    column="enable"    />
        <result property="restartState"    column="restart_state"    />
        <result property="onlineTime"    column="online_time"    />
        <collection property="ardTankLockPasswords" ofType="com.ruoyi.sy.domain.ArdTankLockPassword">
            <result property="id"    column="pid"    />
            <result property="lockId"    column="lock_id"    />
            <result property="password"    column="password"    />
            <result property="no"    column="no"    />
            <result property="createTime"    column="create_time"    />
            <result property="useTime"    column="use_time"    />
        </collection>
    </resultMap>
    <sql id="selectArdTankLockVo">
        select id, lock_num, lock_name, img_position_top, img_position_left, car_id, enable, online_time from ard_tank_lock
        select id, lock_num, lock_name, img_position_top, img_position_left, car_id, enable, restart_state, online_time from ard_tank_lock
    </sql>
    <select id="selectArdTankLockList" parameterType="ArdTankLock" resultMap="ArdTankLockResult">
@@ -28,6 +75,7 @@
            <if test="imgPositionLeft != null  and imgPositionLeft != ''"> and img_position_left = #{imgPositionLeft}</if>
            <if test="carId != null  and carId != ''"> and car_id = #{carId}</if>
            <if test="enable != null  and enable != ''"> and enable = #{enable}</if>
            <if test="restartState != null  and restartState != ''"> and restart_state = #{restartState}</if>
            <if test="onlineTime != null  and onlineTime != ''"> and online_time = #{onlineTime}</if>
        </where>
    </select>
@@ -47,6 +95,7 @@
            <if test="imgPositionLeft != null">img_position_left,</if>
            <if test="carId != null">car_id,</if>
            <if test="enable != null">enable,</if>
            <if test="restartState != null">restart_state,</if>
            <if test="onlineTime != null">online_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -57,6 +106,7 @@
            <if test="imgPositionLeft != null">#{imgPositionLeft},</if>
            <if test="carId != null">#{carId},</if>
            <if test="enable != null">#{enable},</if>
            <if test="restartState != null">#{restartState},</if>
            <if test="onlineTime != null">#{onlineTime},</if>
         </trim>
    </insert>
@@ -70,6 +120,7 @@
            <if test="imgPositionLeft != null">img_position_left = #{imgPositionLeft},</if>
            <if test="carId != null">car_id = #{carId},</if>
            <if test="enable != null">enable = #{enable},</if>
            <if test="restartState != null">restart_state = #{restartState},</if>
            <if test="onlineTime != null">online_time = #{onlineTime},</if>
        </trim>
        where id = #{id}
@@ -85,4 +136,158 @@
            #{id}
        </foreach>
    </delete>
    <select id="getAll" resultMap="ArdTankLockResult">
        select * from ard_tank_lock atl order by atl.car_id,lock_num
    </select>
    <insert id="insertArdTankLocks" parameterType="com.ruoyi.sy.domain.ArdTankLock" >
        insert into ard_tank_lock (id, lock_num, lock_name,
        img_position_top, img_position_left, car_id,
        enable, restart_state, online_time)
        values
        <foreach collection ="ardTankLocks" item="ardTankLock" separator =",">
            (#{ardTankLock.id},#{ardTankLock.lockNum},#{ardTankLock.lockName},
            #{ardTankLock.imgPositionTop},#{ardTankLock.imgPositionLeft},
            #{ardTankLock.carId},#{ardTankLock.enable},#{ardTankLock.restartState},
             #{ardTankLock.onlineTime})
        </foreach >
    </insert>
    <select id="getLockByCarId" resultMap="ArdTankLockWithStateResult" parameterType="java.lang.String">
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num,
        t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark,
        t.lock_state_mark from (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
        coalesce(atl.online_time,'') as online_time,coalesce(atls.id,'') as sid,
        coalesce(atls.lock_id,'') as lock_id,coalesce(atls.lock_num,'') as slock_num,
        coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state,
        coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state,
        coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage,
        coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark,
        case atls.lock_state
          when '关锁状态' then false
          when '异常状态' then false
          /*when '动作状态' then false*/
          when '操控中...' then false
          when '开锁状态' then true
          else false
          end as lock_state_mark,
        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id
        where car_id = #{carId} order by atls.upload_time desc,atl.lock_num)t where t.rn = 1
    </select>
    <delete id="deleteLockByCarId" parameterType="java.lang.String">
        delete from ard_tank_lock where car_id = #{carId}
    </delete>
    <delete id="deleteArdTankLockByIdSet" >
        delete from ard_tank_lock where id in
        <foreach item="id" collection="idSet" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectArdTankLockTotal" resultType="java.lang.Long">
        select count(distinct atl.car_id) from ard_tank_lock atl
    </select>
    <select id="getLockByCarIdList" resultType="com.ruoyi.sy.domain.ArdTankLock" >
        select * from ard_tank_lock atl where car_id in
        <foreach item="id" collection="carIdList" open="(" separator="," close=")">
            #{id}
        </foreach>
        order by atl.car_id,lock_num
    </select>
    <select id="selectArdTankLockAllTotal" resultType="java.lang.Long">
        select count(*) from ard_tank_lock atl
    </select>
    <select id="selectArdTankLockTotalByCarIdList" resultType="java.lang.Long">
        select count(*) from ard_tank_lock where car_id in
        <foreach item="id" collection="carIdList" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
    <delete id="deleteArdTankLockAndWallByCarIds" >
        delete from ard_tank_wall_lock atwl where atwl.lock_id in (
        select atl.id from ard_tank_lock atl
        where atl.car_id in
        <foreach item="carId" collection="carIds" open="(" separator="," close=")">
            #{carId}
        </foreach>
        );
        delete from ard_tank_lock atl
        where atl.car_id in
        <foreach item="carId" collection="carIds" open="(" separator="," close=")">
            #{carId}
        </foreach>
    </delete>
    <select id="getIdByLockNum" resultType="java.lang.String" parameterType="java.lang.String">
        select id from ard_tank_lock atl where atl.lock_num = #{lockNum}
    </select>
    <select id="selectArdTankLockWithPassword" resultMap="ArdTankLockWithPasswordResult" >
        select atl."id",atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl."enable",atl.restart_state,
        atl.online_time,atlp."id" as pid,atlp.lock_id,atlp."password",
        atlp.create_time,atlp.use_time  from ard_tank_lock atl
        left join ard_tank_lock_password atlp on atl.id = atlp.lock_id and use_time is null
    </select>
    <select id="getArdTankLockAllWithState" resultMap="ArdTankLockWithStateResult" >
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num,
        t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark,
        t.lock_state_mark from (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top,
        atl.img_position_left,atl.car_id,atl.enable,atl.restart_state,
        coalesce(atl.online_time,'') as online_time,coalesce(atls.id,'') as sid,
        coalesce(atls.lock_id,'') as lock_id,coalesce(atls.lock_num,'') as slock_num,
        coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state,
        coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state,
        coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage,
        coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark,
        case atls.lock_state
            when '关锁状态' then false
            when '异常状态' then false
            /*when '动作状态' then false*/
            when '操控中...' then false
            when '开锁状态' then true
            else false
            end as lock_state_mark,
        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id)t where t.rn = 1
    </select>
    <select id="getArdTankLockCount" resultType="java.lang.Long" >
        select count(*) from ard_tank_lock
    </select>
    <select id="getArdTankLockWithStateByCarId" resultMap="ArdTankLockWithStateResult" >
        select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left,
        t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num,
        t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state,
        t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark from (
        select atl.*,atls.id as sid,atls.lock_id,atls.lock_num as slock_num,atls.lock_state,
        atls.lock_position_state,atls.lock_shell_state,atls.restart_state as srestart_state,
        atls.batter_voltage,atls.power_voltage,atls.upload_time,atls.unique_mark,
        rank() over(partition by atl.lock_num,atl.online_time order by atls.upload_time desc) rn
        from ard_tank_lock atl
        left join ard_tank_lock_state atls on atl.lock_num = atls.lock_num
        where atl.car_id = #{carId})t where t.rn = 1
    </select>
    <update id="updateLockEnableByCarId" parameterType="java.lang.String">
        update ard_tank_lock set enable = #{enable}
        where car_id = #{carId}
    </update>
</mapper>