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<MonitorPointVO> monitorPoints;
|
|
public static MonitorPointsVO convert(List<MonitorPoint> monitorPoints){
|
MonitorPointsVO monitorPointsVO = new MonitorPointsVO();
|
List<MonitorPointVO> monitorPointVOS = new ArrayList<>();
|
for (MonitorPoint monitorPoint : monitorPoints) {
|
MonitorPointVO monitorPointVO = new MonitorPointVO();
|
List<Device> devices = monitorPoint.getDevices();
|
List<DeviceVO> deviceVOS = new ArrayList<>();
|
for (Device device : devices) {
|
DeviceVO deviceVO = deviceConvert(device);
|
deviceVOS.add(deviceVO);
|
}
|
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.setLatitude(device.getLatitude());
|
vo.setLongitude(device.getLongitude());
|
return vo;
|
}
|
}
|