liujie
2026-01-15 f94782b7302f761799c1a0fbc155bed2d4dc504f
ruoyi-system/src/main/resources/mapper/system/DeviceUsageMapper.xml
@@ -20,5 +20,30 @@
        left join device t2 on t1.device_id = t2.id
        where t1.project_id =#{id}
    </select>
    <select id="getDeviceList" resultType="com.ruoyi.system.vo.DeviceListVo">
        select t1.id, t1.name, t1.create_time, t1.properties,   t1.type, latest.record_time as checkTime
        from device t1
                 left join device_usage t2 on t1.id = t2.device_id
                 left join (
                     select device_id, max(create_time) as record_time
                     from record
                     group by device_id
                 ) latest on t1.id = latest.device_id
        where t2.project_id = #{query.projectId} and t2.deleted = 0
        <if test="query.type != null">
            and t1.type = #{query.type}
        </if>
        <if test="query.content!= null and query.content!=''">
            and t1.name like CONCAT('%', #{query.content}, '%')
        </if>
        <if test="query.startTime != null and query.startTime != ''">
            and latest.record_time >= #{query.startTime}
        </if>
        <if test="query.endTime != null and query.endTime != ''">
            and   #{query.endTime} >=latest.record_time
        </if>
        order by latest.record_time desc
    </select>
</mapper>