This commit is contained in:
chy
2026-05-11 00:10:21 +08:00
4 changed files with 28 additions and 1 deletions

View File

@@ -213,6 +213,9 @@ public class Device extends BaseEntity
@TableField(exist = false)
private Boolean canConfigPoll = false;
@TableField(exist = false)
private List<DeviceLog> logs;
public static long getSerialVersionUID() {
return serialVersionUID;

View File

@@ -5,6 +5,7 @@ package iot.lidee.iot.mapper.bygz;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import iot.lidee.framework.mybatis.mapper.BaseMapperX;
import iot.lidee.iot.domain.Device;
import iot.lidee.iot.domain.DeviceLog;
import iot.lidee.iot.model.bygz.DevGzbxWxgdDO;
import org.apache.ibatis.annotations.Mapper;
@@ -23,4 +24,6 @@ public interface DevGzbxWxgdMapper extends BaseMapperX<DevGzbxWxgdDO> {
List<DevGzbxWxgdDO> selectWxgdByType(String devtype);
List<Device> deviceList(String devtype);
List<DeviceLog> deviceLogList(String serialNumber);
}

View File

@@ -93,6 +93,11 @@ public class DeviceMaintenanceRepairServiceImpl implements IDeviceMaintenanceRep
*/
@Override
public List<Device> deviceList(String devtype) {
return devGzbxWxgdMapper.deviceList(devtype);
List<Device> devices = devGzbxWxgdMapper.deviceList(devtype);
for (Device device : devices) {
device.setLogs(devGzbxWxgdMapper.deviceLogList(device.getSerialNumber()));
}
return devices;
}
}

View File

@@ -65,4 +65,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w.del_flag = 0 AND g.group_id = #{devtype}
</select>
<select id="deviceLogList" resultType="iot.lidee.iot.domain.DeviceLog">
SELECT
*
FROM (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY identity ORDER BY create_time DESC) AS rn
FROM
iot_device_log
WHERE
serial_number = #{serialNumber}
) t
WHERE rn = 1
</select>
</mapper>