package com.moral.api.pojo.vo.monitorPoint; import com.moral.api.entity.Device; import com.moral.api.entity.MonitorPoint; import com.moral.api.pojo.vo.device.DeviceVO; import lombok.Data; import java.util.ArrayList; import java.util.List; /** * @ClassName MonitorPointsVO * @Description TODO * @Author 陈凯裕 * @Date 2021/7/1 14:33 * @Version TODO **/ @Data public class MonitorPointsVO { private List monitorPoints; public static MonitorPointsVO convert(List monitorPoints){ MonitorPointsVO monitorPointsVO = new MonitorPointsVO(); List monitorPointVOS = new ArrayList<>(); for (MonitorPoint monitorPoint : monitorPoints) { MonitorPointVO monitorPointVO = new MonitorPointVO(); List devices = monitorPoint.getDevices(); List deviceVOS = new ArrayList<>(); for (Device device : devices) { DeviceVO deviceVO = deviceConvert(device); deviceVOS.add(deviceVO); } monitorPointVO.setId(monitorPoint.getId()); monitorPointVO.setName(monitorPoint.getName()); monitorPointVO.setLatitude(monitorPoint.getLatitude()); monitorPointVO.setLongitude(monitorPoint.getLongitude()); monitorPointVO.setDevices(deviceVOS); monitorPointVOS.add(monitorPointVO); } monitorPointsVO.setMonitorPoints(monitorPointVOS); return monitorPointsVO; } private static DeviceVO deviceConvert(Device device){ DeviceVO vo = new DeviceVO(); vo.setName(device.getName()); vo.setMac(device.getMac()); vo.setState(device.getState()); vo.setLatitude(device.getLatitude()); vo.setLongitude(device.getLongitude()); return vo; } }