jinpengyong
2023-10-20 17c774c9c13febdcff654ffd6bbabd313c37a3ee
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
package com.moral.api.pojo.vo.historyFiveMinutely;
 
import com.moral.api.entity.Device;
import com.moral.api.pojo.dto.historyFiveMinutely.DeviceAndFiveMinuteDataDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @ClassName DeviceAndFiveMinuteDataVO
 * @Description TODO
 * @Author 陈凯裕
 * @Date 2021/7/16 11:17
 * @Version TODO
 **/
@Data
@AllArgsConstructor
public class DeviceAndFiveMinuteDataVO {
 
    private List<Map<String, Object>> devices;
 
    public static DeviceAndFiveMinuteDataVO convert(List<DeviceAndFiveMinuteDataDTO> dtos) {
        List<Map<String, Object>> devices = new ArrayList<>();
        for (DeviceAndFiveMinuteDataDTO dto : dtos) {
            Device device = dto.getDevice();
            Map<String, Object> sensorValue = dto.getSensorValue();
            Map<String, Object> deviceValue = new HashMap<>();
            deviceValue.put("latitude",device.getLatitude());
            deviceValue.put("longitude",device.getLongitude());
            deviceValue.put("state",device.getState());
            deviceValue.put("mac",device.getMac());
            deviceValue.putAll(sensorValue);
            devices.add(deviceValue);
        }
        return new DeviceAndFiveMinuteDataVO(devices);
    }
}