kaiyu
2021-07-01 49875151be4b427935fcb3d60696e99ba9d2e1ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
    }
}