1. data-fall에 데이터가 없는 경우 NoContent 처리

2. 버전 업데이트
This commit is contained in:
장선애 2023-09-12 13:57:39 +09:00
parent c9046a0fb4
commit 867c398692
5 changed files with 39 additions and 48 deletions

View File

@ -5,7 +5,7 @@ plugins {
}
group = 'inc.sdt.controlcentermanagement'
version = '0.0.5'
version = '0.0.6'
java {
sourceCompatibility = '17'

View File

@ -1,4 +1,4 @@
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 003960268191.dkr.ecr.ap-northeast-2.amazonaws.com
docker build --platform linux/amd64 -t control-center-management ../../
docker tag control-center-management:latest 003960268191.dkr.ecr.ap-northeast-2.amazonaws.com/sdt-cloud/control-center-management:0.0.5
docker push 003960268191.dkr.ecr.ap-northeast-2.amazonaws.com/sdt-cloud/control-center-management:0.0.5
docker tag control-center-management:latest 003960268191.dkr.ecr.ap-northeast-2.amazonaws.com/sdt-cloud/control-center-management:0.0.6
docker push 003960268191.dkr.ecr.ap-northeast-2.amazonaws.com/sdt-cloud/control-center-management:0.0.6

View File

@ -25,4 +25,9 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6ImQxZGJlYWExL
{
"voltageOffset" : 1.5,
"ampereOffset": 1.1
}
}
### 통계 디테일 조회
GET http://localhost:8087/chambers/stats/detail/1
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6ImQxZGJlYWExLWY5ZTUtNGE4OC1hMWM4LTYzMWQ4NTMyOWJmYyIsInJvbGVzIjpbIlJPTEVfQURNSU5JU1RSQVRPUiJdLCJpZCI6IjdjYTBjZWQ5LTk1YjEtNDgzMC05YmJhLWZmZTUwNWVmYzgzMiIsInN1YiI6InNkdC5kZXZAc2R0LmluYyIsImlhdCI6MTY5NDQ5MjIyMSwiZXhwIjoxNjk0NDk1ODIxfQ.ZKa8-eKnJr0VDnGMmExAQnXFTfE4Y38OsI3nZ18S80E

View File

@ -8,7 +8,6 @@ import inc.sdt.controlcentermanagement.presentation.StatsCntRecord;
import inc.sdt.controlcentermanagement.presentation.StatsDetailRecord;
import inc.sdt.controlcentermanagement.presentation.StatsRecord;
import inc.sdt.controlcentermanagement.presentation.support.CustomPage;
import inc.sdt.controlcentermanagement.presentation.support.CustomPageable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@ -63,27 +62,28 @@ 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());
@ -99,6 +99,7 @@ public class DefaultStatsService implements StatsService{
@Override
public Page<StatsDetailRecord> getChamberStatsDetail(int page, int size, String 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<>();
@ -119,39 +120,23 @@ 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);
}
});
}
}
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);
} else {
throw new NoSuchElementException();
}
}));

View File

@ -24,10 +24,11 @@ class RestControllerExceptionHandler {
return ExceptionResponse.builder(HttpStatus.BAD_REQUEST)
.build(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
}
@ExceptionHandler
@ResponseStatus(HttpStatus.NOT_FOUND)
ExceptionResponse handleNoSuchElementException(NoSuchElementException e) {
return ExceptionResponse.builder(HttpStatus.NOT_FOUND)
.build(e.getMessage() + " does not exist.");
@ExceptionHandler(value = NoSuchElementException.class)
@ResponseStatus(HttpStatus.NO_CONTENT)
ExceptionResponse handleNoContentException(NoSuchElementException e) {
return ExceptionResponse.builder(HttpStatus.NO_CONTENT)
.build(e.getMessage());
}
}