|
|
@@ -1,10 +1,15 @@
|
|
|
package com.coffee.bus.stats.entity;
|
|
|
|
|
|
+import com.coffee.bus.enums.DeviceAlarmEnum;
|
|
|
+import com.coffee.bus.enums.DeviceStatusEnum;
|
|
|
+import com.coffee.bus.enums.FlowStatusEnum;
|
|
|
+import com.coffee.bus.service.dto.CombineAlarmResult;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.Data;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
-import java.util.function.Function;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @author lifang
|
|
|
@@ -14,32 +19,36 @@ import java.util.function.Function;
|
|
|
* @createTime 2022年06月11日 17:10:00
|
|
|
*/
|
|
|
public class AlarmScatter extends LinkedHashMap<String, Map<String, AlarmScatter.AlarmStatsByTime>> {
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getJam(String time) {
|
|
|
- return this.computeIfAbsent("jam", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getJam(String time) {
|
|
|
+ return this.computeIfAbsent("堵塞",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementJam(String time) {
|
|
|
incrementValue(this.getJam(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getLimit(String time) {
|
|
|
- return this.computeIfAbsent("limit", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getLimit(String time) {
|
|
|
+ return this.computeIfAbsent("极限",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementLimit(String time) {
|
|
|
incrementValue(this.getLimit(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getNoBox(String time) {
|
|
|
- return this.computeIfAbsent("noBox", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getNoBox(String time) {
|
|
|
+ return this.computeIfAbsent("未装药盒",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementNoBox(String time) {
|
|
|
incrementValue(this.getNoBox(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getOutOfControl(String time) {
|
|
|
- return this.computeIfAbsent("outOfControl", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getOutOfControl(String time) {
|
|
|
+ return this.computeIfAbsent("电机失控",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementOutOfControl(String time) {
|
|
|
@@ -47,8 +56,9 @@ public class AlarmScatter extends LinkedHashMap<String, Map<String, AlarmScatter
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getAnalgesicPoor(String time) {
|
|
|
- return this.computeIfAbsent("analgesicPoor", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getAnalgesicPoor(String time) {
|
|
|
+ return this.computeIfAbsent("镇痛不足",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -56,8 +66,9 @@ public class AlarmScatter extends LinkedHashMap<String, Map<String, AlarmScatter
|
|
|
incrementValue(this.getAnalgesicPoor(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getNoSignal(String time) {
|
|
|
- return this.computeIfAbsent("noSignal", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getNoSignal(String time) {
|
|
|
+ return this.computeIfAbsent("不在服务区",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementNoSignal(String time) {
|
|
|
@@ -65,16 +76,18 @@ public class AlarmScatter extends LinkedHashMap<String, Map<String, AlarmScatter
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getMachine(String time) {
|
|
|
- return this.computeIfAbsent("machine", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getMachine(String time) {
|
|
|
+ return this.computeIfAbsent("机械故障",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementMachine(String time) {
|
|
|
incrementValue(this.getMachine(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getLowBattery(String time) {
|
|
|
- return this.computeIfAbsent("lowBattery", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getLowBattery(String time) {
|
|
|
+ return this.computeIfAbsent("电量耗尽",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -82,8 +95,9 @@ public class AlarmScatter extends LinkedHashMap<String, Map<String, AlarmScatter
|
|
|
incrementValue(this.getLowBattery(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getBubble(String time) {
|
|
|
- return this.computeIfAbsent("bubble", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getBubble(String time) {
|
|
|
+ return this.computeIfAbsent("气泡无液",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -91,37 +105,82 @@ public class AlarmScatter extends LinkedHashMap<String, Map<String, AlarmScatter
|
|
|
incrementValue(this.getBubble(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getLowInfusion(String time) {
|
|
|
- return this.computeIfAbsent("lowInfusion", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getLowInfusion(String time) {
|
|
|
+ return this.computeIfAbsent("低输注",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementLowInfusion(String time) {
|
|
|
incrementValue(this.getLowInfusion(time));
|
|
|
}
|
|
|
|
|
|
- public Map<String, AlarmScatter.AlarmStatsByTime> getInfusionMax(String time) {
|
|
|
- return this.computeIfAbsent("infusionMax", initValue(time));
|
|
|
+ public AlarmScatter.AlarmStatsByTime getInfusionMax(String time) {
|
|
|
+ return this.computeIfAbsent("返厂维护",k->new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(time,t->AlarmStatsByTime.of(time,0));
|
|
|
}
|
|
|
|
|
|
public void incrementInfusionMax(String time) {
|
|
|
- incrementValue(this.getInfusionMax(time));
|
|
|
- }
|
|
|
-
|
|
|
- private void incrementValue(Map<String, AlarmScatter.AlarmStatsByTime> map){
|
|
|
-
|
|
|
+ incrementValue(this.getLowInfusion(time));
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Function<String, Map<String, AlarmScatter.AlarmStatsByTime>> initValue(String time){
|
|
|
- return k->{
|
|
|
- Map<String, AlarmScatter.AlarmStatsByTime> map = new LinkedHashMap<>();
|
|
|
- map.computeIfAbsent(time,t->AlarmStatsByTime.of(time,0L));
|
|
|
- return map;
|
|
|
- };
|
|
|
- }
|
|
|
+ private void incrementValue(AlarmScatter.AlarmStatsByTime stats){
|
|
|
+ stats.setCount(Optional.ofNullable(stats.getCount()).orElse(0) +1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void handle(CombineAlarmResult alarmResult,String time) {
|
|
|
+ if (Boolean.TRUE.equals(alarmResult.getIsAlarm())) {
|
|
|
+ DeviceAlarmEnum alarm = alarmResult.getAlarm();
|
|
|
+ switch (alarm){
|
|
|
+ case Jam:
|
|
|
+ incrementJam(time);
|
|
|
+ break;
|
|
|
+ case Limit:
|
|
|
+ incrementLimit(time);
|
|
|
+ break;
|
|
|
+ case NotBox:
|
|
|
+ incrementNoBox(time);
|
|
|
+ break;
|
|
|
+ case Machine:
|
|
|
+ incrementMachine(time);
|
|
|
+ break;
|
|
|
+ case OutOfControl:
|
|
|
+ incrementOutOfControl(time);
|
|
|
+ break;
|
|
|
+ case LowBattery:
|
|
|
+ incrementLowBattery(time);
|
|
|
+ break;
|
|
|
+ case Bubble:
|
|
|
+ incrementBubble(time);
|
|
|
+ break;
|
|
|
+ case InfusionMax:
|
|
|
+ incrementInfusionMax(time);
|
|
|
+ break;
|
|
|
+ default:break;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ Boolean warnAnalgesicPoor = alarmResult.getWarnAnalgesicPoor();
|
|
|
+ if (Boolean.TRUE.equals(warnAnalgesicPoor)) {
|
|
|
+ incrementAnalgesicPoor(time);
|
|
|
+ }
|
|
|
+ DeviceStatusEnum runState = alarmResult.getRunState();
|
|
|
+ if (DeviceStatusEnum.NoSignal.equals(runState)) {
|
|
|
+ incrementNoSignal(time);
|
|
|
+ }
|
|
|
+ FlowStatusEnum warnFlow = alarmResult.getWarnFlow();
|
|
|
+ if (FlowStatusEnum.Lowest.equals(warnFlow)) {
|
|
|
+ incrementLowInfusion(time);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
@AllArgsConstructor(staticName = "of")
|
|
|
public static class AlarmStatsByTime{
|
|
|
private String time;
|
|
|
- private Long count;
|
|
|
+ private Integer count;
|
|
|
}
|
|
|
}
|