You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.8 KiB
114 lines
3.8 KiB
package com.mh.common.enums; |
|
|
|
import com.mh.common.core.domain.entity.DeviceReport; |
|
|
|
import java.time.LocalDateTime; |
|
import java.util.*; |
|
|
|
/** |
|
* @Author : Rainbow |
|
* @date : 2023/6/19 |
|
*/ |
|
public enum ComputeEnum implements ComputeService { |
|
|
|
/** |
|
* 电表 |
|
*/ |
|
DEVICES("计量设备数据处理", 5) { |
|
@Override |
|
public ArrayList<Map<LocalDateTime, DeviceReport>> getDataList( |
|
Map.Entry<String, Map<LocalDateTime, List<DeviceReport>>> entry) { |
|
|
|
ArrayList<Map<LocalDateTime, DeviceReport>> result = new ArrayList<>(); |
|
|
|
//获取到电表的数据,按照表号分组分组,紧接着再按照小时分组。需要计算分组后的数据取出最大值 |
|
Map<LocalDateTime, List<DeviceReport>> deviceMap = entry.getValue(); |
|
String deviceNum = entry.getKey(); |
|
Set<Map.Entry<LocalDateTime, List<DeviceReport>>> groupEntryList = deviceMap.entrySet(); |
|
for (Map.Entry<LocalDateTime, List<DeviceReport>> listEntry : groupEntryList) { |
|
LocalDateTime key = listEntry.getKey(); |
|
List<DeviceReport> value = listEntry.getValue(); |
|
DeviceReport maxEntity = value.stream() |
|
.max(Comparator.comparing(obj -> Double.valueOf(obj.getCurValue()))) |
|
.orElse(null); |
|
HashMap<LocalDateTime, DeviceReport> map = new HashMap<>(); |
|
map.put(key, maxEntity); |
|
result.add(map); |
|
} |
|
|
|
return result; |
|
} |
|
}, |
|
/** |
|
* 冷量计 |
|
*/ |
|
CLOUD("冷量计数据处理", 2) { |
|
@Override |
|
public ArrayList<Map<LocalDateTime, DeviceReport>> getDataList( |
|
Map.Entry<String, Map<LocalDateTime, List<DeviceReport>>> entry) { |
|
ArrayList<Map<LocalDateTime, DeviceReport>> result = new ArrayList<>(); |
|
|
|
//获取到电表的数据,按照表号分组分组,紧接着再按照小时分组。需要计算分组后的数据取出最大值 |
|
Map<LocalDateTime, List<DeviceReport>> deviceMap = entry.getValue(); |
|
String deviceNum = entry.getKey(); |
|
Set<Map.Entry<LocalDateTime, List<DeviceReport>>> groupEntryList = deviceMap.entrySet(); |
|
for (Map.Entry<LocalDateTime, List<DeviceReport>> listEntry : groupEntryList) { |
|
LocalDateTime key = listEntry.getKey(); |
|
List<DeviceReport> value = listEntry.getValue(); |
|
DeviceReport maxEntity = value.stream() |
|
.max(Comparator.comparing(obj -> Double.valueOf(obj.getCurValue()))) |
|
.orElse(null); |
|
HashMap<LocalDateTime, DeviceReport> map = new HashMap<>(); |
|
map.put(key, maxEntity); |
|
result.add(map); |
|
} |
|
|
|
return result; |
|
} |
|
}, |
|
/** |
|
* 温度计 |
|
*/ |
|
COLD("温度计数据处理", 1) { |
|
@Override |
|
public ArrayList<Map<LocalDateTime, DeviceReport>> getDataList( |
|
Map.Entry<String, Map<LocalDateTime, List<DeviceReport>>> entry) { |
|
return null; |
|
} |
|
}; |
|
|
|
private String des; |
|
private int key; |
|
|
|
private static final Map<Integer, ComputeEnum> lookup = new HashMap<>(); |
|
|
|
static { |
|
for (ComputeEnum c : ComputeEnum.values()) { |
|
lookup.put(c.getKey(), c); |
|
} |
|
} |
|
|
|
ComputeEnum(String des, int key) { |
|
this.des = des; |
|
this.key = key; |
|
} |
|
|
|
public String getDes() { |
|
return des; |
|
} |
|
|
|
public void setDes(String des) { |
|
this.des = des; |
|
} |
|
|
|
public int getKey() { |
|
return key; |
|
} |
|
|
|
public static ComputeEnum get(int key) { |
|
return lookup.get(key); |
|
} |
|
|
|
public abstract ArrayList<Map<LocalDateTime, DeviceReport>> getDataList( |
|
Map.Entry<String, Map<LocalDateTime, List<DeviceReport>>> entry); |
|
}
|
|
|