7 changed files with 161 additions and 4 deletions
@ -0,0 +1,28 @@ |
|||
package com.kms.yg.cz.enmu; |
|||
|
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Getter |
|||
public enum MonitorGroupEnum { |
|||
|
|||
SK("水库", Arrays.asList(MonitorIndexEnum.WATER, MonitorIndexEnum.RAINFALL, MonitorIndexEnum.WATER_STORE)), |
|||
; |
|||
private final String group; |
|||
private final List<MonitorIndexEnum> indexElements; |
|||
|
|||
|
|||
MonitorGroupEnum(String group, List<MonitorIndexEnum> indexElements) { |
|||
this.group = group; |
|||
this.indexElements = indexElements; |
|||
} |
|||
|
|||
public List<MonitorIndexEnum.IndexInfo> info() { |
|||
return this.indexElements.stream() |
|||
.map(MonitorIndexEnum::getIndexInfos) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
} |
@ -0,0 +1,56 @@ |
|||
package com.kms.yg.cz.enmu; |
|||
|
|||
import lombok.Data; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
import java.util.stream.Stream; |
|||
|
|||
import static com.kms.yg.cz.enmu.MarkTypeEnum.CHFLLV; |
|||
import static com.kms.yg.cz.enmu.MarkTypeEnum.FSLTDZ_LIMIT; |
|||
import static com.kms.yg.cz.enmu.MonitorTypeEnum.*; |
|||
|
|||
@Getter |
|||
public enum MonitorIndexEnum { |
|||
WATER("水位信息", Arrays.asList(WATER_LEVEL, MAX_WATER_LEVEL, MIN_WATER_LEVEL, AVG_WATER_LEVEL), |
|||
Arrays.asList(FSLTDZ_LIMIT, CHFLLV)), |
|||
RAINFALL("降雨量", Arrays.asList(MonitorTypeEnum.RAINFALL, MAX_RAINFALL, MIN_RAINFALL, AVG_RAINFALL)), |
|||
WATER_STORE("蓄水量", Collections.singletonList(STORE_WATER)), |
|||
; |
|||
|
|||
private final String group; |
|||
private final List<MonitorTypeEnum> indexElements; |
|||
private final List<MarkTypeEnum> markTypes; |
|||
|
|||
MonitorIndexEnum(String group, List<MonitorTypeEnum> indexElements) { |
|||
this(group, indexElements, Collections.emptyList()); |
|||
} |
|||
|
|||
MonitorIndexEnum(String group, List<MonitorTypeEnum> indexElements, List<MarkTypeEnum> markTypes) { |
|||
this.group = group; |
|||
this.indexElements = indexElements; |
|||
this.markTypes = markTypes; |
|||
} |
|||
|
|||
public IndexInfo getIndexInfos() { |
|||
IndexInfo indexInfo = new IndexInfo(); |
|||
indexInfo.setGroup(group); |
|||
indexInfo.setItems( |
|||
Stream.concat(indexElements.stream(), |
|||
markTypes.stream()) |
|||
.filter(item -> item instanceof MonitorIndexInfo) |
|||
.map(item -> (MonitorIndexInfo) item) |
|||
.map(MonitorIndexInfo::toInfo) |
|||
.collect(Collectors.toList())); |
|||
return indexInfo; |
|||
} |
|||
|
|||
@Data |
|||
public static class IndexInfo { |
|||
private String group; |
|||
private List<Info> items; |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.kms.yg.cz.enmu; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
public interface MonitorIndexInfo { |
|||
|
|||
String getZhName(); |
|||
|
|||
String getUnit(); |
|||
|
|||
String name(); |
|||
|
|||
default Info toInfo() { |
|||
Info info = new Info(); |
|||
info.setZhName(getZhName()); |
|||
info.setUnit(getUnit()); |
|||
info.setKey(name()); |
|||
return info; |
|||
} |
|||
|
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@Data |
|||
class Info { |
|||
private String zhName; |
|||
private String unit; |
|||
private String key; |
|||
private String value; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue