zhangnaisong
2024-08-06 fb486d8c2447a9a18eb929d81094bfd46c78fe27
ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
@@ -62,6 +62,44 @@
        </collection>
    </resultMap>
    <resultMap type="ArdTankLock" id="ArdTankLockWithWallAndStateResult">
        <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="slock_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>
        <collection property="ardTankWallLockList" ofType="com.ruoyi.sy.domain.ArdTankWallLock">
            <result property="processType"    column="process_type"    />
            <result property="id"    column="mid"    />
            <result property="wallId"    column="wall_id"    />
            <result property="lockId"    column="lock_id"    />
            <association property="ardTankWall" javaType="com.ruoyi.sy.domain.ArdTankWall">
                <result property="id"    column="wid"    />
                <result property="wallName"    column="wall_name"    />
                <result property="wallPoi"    column="wall_poi"    />
                <result property="wallType"    column="wall_type"    />
            </association>
        </collection>
    </resultMap>
    <sql id="selectArdTankLockVo">
        select id, lock_num, lock_name, img_position_top, img_position_left, car_id, enable, restart_state, online_time from ard_tank_lock
    </sql>
@@ -290,4 +328,28 @@
        update ard_tank_lock set enable = #{enable}
        where car_id = #{carId}
    </update>
    <select id="selectArdTankLockWithWallAndStateByCarId" resultMap="ArdTankLockWithWallAndStateResult" >
        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.mid,t.wall_id,t.lock_id,
        t.process_type,t.wid,t.wall_name,t.wall_poi,t.wall_type,t.sid,t.slock_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.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,atwl.id as mid,
        atwl.wall_id,atwl.lock_id,atwl.process_type,atw.id as wid,
        atw.wall_name,atw.wall_poi,atw.wall_type,coalesce(atls.id,'') as sid,
        coalesce(atls.lock_id,'') as slock_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,
        rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn
        from ard_tank_lock atl
        inner join ard_tank_wall_lock atwl on atl.id = atwl.lock_id
        inner join ard_tank_wall atw on atwl.wall_id = atw.id
        left join ard_tank_lock_state atls on atl."id" = atls.lock_id
        where atl.car_id = #{carId} and atwl.process_type != '0')t where t.rn = 1
    </select>
</mapper>