| 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); | 
|     } | 
| } |