zhangnaisong
2024-07-24 9aac460a313ac8284e0fd633183c93815f95e0de
ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
@@ -157,4 +157,27 @@
            #{carId}
        </foreach>
    </select>
    <select id="getCarListByDeptIdList" resultMap="ArdSyCarResult">
        select * from ard_sy_car where dept_id in
        <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
            #{deptId}
        </foreach>
    </select>
    <select id="selectArdSyCarAndTankLockByUserId" resultMap="ArdSyCarLockResult">
        select "asc".id,"asc".car_id,"asc".car_model,"asc".car_type,
        "asc".car_brand,"asc".dept_id,"asc".car_picture,atl.id as lid,
        atl.lock_num,atl.lock_name,atl.img_position_top,atl.img_position_left,
        atl.car_id as lcar_id,atl.enable,coalesce(atl.restart_state,'') as restart_state,
        coalesce(atl.online_time,'') as online_time
        from ard_sy_car "asc"
        inner join ard_tank_lock atl on "asc".car_id = atl.car_id
        where "asc".dept_id in (
        with recursive rsd as (
            select sd.dept_id from sys_dept sd where sd.dept_id =
            (select dept_id from sys_user su where su.user_id = #{userId})
            union
            select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
        )
        select dept_id from rsd) order by "asc".car_id desc,atl.lock_num
    </select>
</mapper>