tube stats detail 삭제된 코드 재추가

This commit is contained in:
장선애 2023-09-12 16:48:23 +09:00
parent 2aed8b9f65
commit 4c553d2938
1 changed files with 41 additions and 22 deletions

View File

@ -38,6 +38,7 @@ public class DefaultStatsService implements StatsService{
@Override
public List<StatsRecord> getChamberStats() {
log.info("[getChamberStats]");
List<Slot> all= slotRepositoryDelegate.getAll();
Map<String, List<Slot>> groupByChamber = all.stream().collect(Collectors.groupingBy(Slot::getChamberNumber));
@ -62,28 +63,27 @@ public class DefaultStatsService implements StatsService{
log.info("optional = {}",optional);
if(optional.isPresent()){
List<DataResource> content = optional.get().getContent();
for (DataResource dataResource : content) {
dataResource.getData().forEach((key, value) -> {
if (key.contains("er2")) {
for(DataResource dataResource : content){
dataResource.getData().forEach((key, value)->{
if(key.contains("er2")){
errTotalCnt.updateAndGet(v -> v + 1);
if ((int) value > 0) {
if((int)value > 0){
err2Cnt.updateAndGet(v -> v + 1);
}
}
if (key.contains("do")) {
if(key.contains("do")){
onTotalCnt.updateAndGet(v -> v + 1);
offTotalCnt.updateAndGet(v -> v + 1);
if ((int) value > 0) {
if((int)value > 0){
onCnt.updateAndGet(v -> v + 1);
} else {
}else{
offCnt.updateAndGet(v -> v + 1);
}
}
});
}
} else {
throw new NoSuchElementException();
}
}
StatsCntRecord onCntRecord = new StatsCntRecord(onCnt.get(), onTotalCnt.get());
@ -98,8 +98,8 @@ public class DefaultStatsService implements StatsService{
@Override
public Page<StatsDetailRecord> getChamberStatsDetail(int page, int size, String chamberNumber) {
log.info("[getChamberStatsDetail] chamberNumber: {}", chamberNumber);
List<Slot> all= slotRepositoryDelegate.getAll().stream().filter(slot -> slot.getChamberNumber().equals(chamberNumber)).toList();
if (all.isEmpty()) throw new NoSuchElementException();
Pageable pageable = PageRequest.of(page, size);
List<StatsDetailRecord> statsDetailRecords = new LinkedList<>();
@ -120,24 +120,43 @@ public class DefaultStatsService implements StatsService{
if(optional.isPresent()){
List<DataResource> content = optional.get().getContent();
for (DataResource dataResource : content) {
dataResource.getData().forEach((key, value) -> {
if (key.startsWith("current")) {
currentMap.put(key.replace("current", ""), value);
} else if (key.startsWith("voltage")) {
voltageMap.put(key.replace("voltage", ""), value);
} else if (key.startsWith("do")) {
doMap.put(key.replace("do", ""), value);
} else if (key.startsWith("er1")) {
er1Map.put(key.replace("er1", ""), value);
} else if (key.startsWith("er2")) {
er2Map.put(key.replace("er2", ""), value);
for(DataResource dataResource : content){
dataResource.getData().forEach((key, value)->{
if(key.startsWith("current")){
currentMap.put(key.replace("current",""), value);
}else if(key.startsWith("voltage")){
voltageMap.put(key.replace("voltage",""), value);
}else if(key.startsWith("do")){
doMap.put(key.replace("do",""), value);
}else if(key.startsWith("er1")){
er1Map.put(key.replace("er1",""), value);
}else if(key.startsWith("er2")){
er2Map.put(key.replace("er2",""), value);
}
});
}
} else {
throw new NoSuchElementException();
}
for(int i=0 ; i < 16 ; i++){
StatsDetailRecord statsDetailRecord = new StatsDetailRecord(
slot.getAssetCode(),
slot.getSlotNumber(),
String.valueOf(i),
"status",
String.valueOf(voltageMap.get(String.valueOf(i))),
String.valueOf(currentMap.get(String.valueOf(i))),
String.valueOf(doMap.get(String.valueOf(i))),
String.valueOf(er1Map.get(String.valueOf(i))),
String.valueOf(er2Map.get(String.valueOf(i))),
"passTime",
"retentionRate",
String.valueOf(slot.getTube().get(i).getVoltageOffset()),
String.valueOf(slot.getTube().get(i).getAmpereOffset())
);
statsDetailRecords.add(statsDetailRecord);
}
}));
statsDetailRecords.sort(new StatsDetailSlotNumberComparator());