slotNumber 정수로 변경

This commit is contained in:
장선애 2023-09-08 11:30:01 +09:00
parent e4f24bf3a6
commit b410e107e9
3 changed files with 61 additions and 15 deletions

47
k8s/istio-setting.yaml Normal file
View File

@ -0,0 +1,47 @@
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: control-center-management
namespace: sdt-cloud
spec:
servers:
- hosts:
- "*"
port:
name: http
number: 80
protocol: HTTP
selector:
istio: ingressgateway
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: control-center-management
namespace: sdt-cloud
spec:
hosts:
- "*"
http:
- route:
- destination:
host: control-center-management.sdt-cloud.svc.cluster.local
match:
- uri:
prefix: "/chamber"
corsPolicy:
maxAge: 1m
allowCredentials: true
allowHeaders:
- "*"
allowOrigins:
- regex: ".*"
allowMethods:
- GET
- POST
- PUT
- DELETE
- PATCH
- OPTIONS
gateways:
- control-center-management

View File

@ -1,16 +1,17 @@
### ON/OFF 제어 ## ON/OFF 제어
#PATCH http://13.209.39.139:30870/chamber/1/tube/toggle #PATCH http://13.209.39.139:30870/chamber/1/tube/toggle
PATCH http://localhost:8087/chamber/1/tube/toggle PATCH http://13.209.39.139:32171/chamber/1/tube/toggle
#PATCH http://localhost:8087/chamber/1/tube/toggle
Content-Type: application/json Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6ImQxZGJlYWExLWY5ZTUtNGE4OC1hMWM4LTYzMWQ4NTMyOWJmYyIsInJvbGVzIjpbIlJPTEVfQURNSU5JU1RSQVRPUiJdLCJpZCI6IjcyYTUxZDUwLTYwMDEtNDAwYy04NjNmLWZlOGU2OGE1MGExMCIsInN1YiI6InNhLmphbmdAc2R0LmluYyIsImlhdCI6MTY5NDEzNjg4OCwiZXhwIjoxNjk0MTQwNDg4fQ.likh7Ix7p4Yf2iwankLG71VGrgCDzQzhn9Z7QJK0blg Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJvcmdhbml6YXRpb25JZCI6ImQxZGJlYWExLWY5ZTUtNGE4OC1hMWM4LTYzMWQ4NTMyOWJmYyIsInJvbGVzIjpbIlJPTEVfQURNSU5JU1RSQVRPUiJdLCJpZCI6IjcyYTUxZDUwLTYwMDEtNDAwYy04NjNmLWZlOGU2OGE1MGExMCIsInN1YiI6InNhLmphbmdAc2R0LmluYyIsImlhdCI6MTY5NDEzNjg4OCwiZXhwIjoxNjk0MTQwNDg4fQ.likh7Ix7p4Yf2iwankLG71VGrgCDzQzhn9Z7QJK0blg
{ //{
"command" : "OFF", // "command" : "OFF",
"assetCode" : "NODEQ-TEST-1", // "assetCode" : "NODEQ-TEST-1",
"slotNumber" : "1-1", // "slotNumber" : "1-1",
"tube": [ // "tube": [
{"code": "1"}, {"code": "3"}, {"code": "11"}, {"code": "16"} // {"code": "1"}, {"code": "3"}, {"code": "11"}, {"code": "16"}
] // ]
} //}
//{"command": "ON"} {"command": "ON"}

View File

@ -43,8 +43,7 @@ class DefaultTubeService implements TubeService {
Map<String, String> tubeMap = new LinkedHashMap<>(); Map<String, String> tubeMap = new LinkedHashMap<>();
for (Tube tube : request.getTube()) { for (Tube tube : request.getTube()) {
Map<String, Integer> tubeOffsetMap = this.tubeOffset(); Map<String, Integer> tubeOffsetMap = this.tubeOffset();
String offsetKey = request.getSlotNumber().substring(request.getSlotNumber().length() - 1); int tubeOffset = tubeOffsetMap.getOrDefault(request.getSlotNumber(), 1);
int tubeOffset = tubeOffsetMap.getOrDefault(offsetKey, 1);
int tubeKey = Integer.parseInt(tube.getCode()) + tubeOffset; int tubeKey = Integer.parseInt(tube.getCode()) + tubeOffset;
tubeMap.put(String.valueOf(tubeKey), String.valueOf(request.getCommand().ordinal())); tubeMap.put(String.valueOf(tubeKey), String.valueOf(request.getCommand().ordinal()));
} }
@ -75,8 +74,7 @@ class DefaultTubeService implements TubeService {
for (Tube tube : tubes) { for (Tube tube : tubes) {
Map<String, Integer> tubeOffsetMap = this.tubeOffset(); Map<String, Integer> tubeOffsetMap = this.tubeOffset();
String offsetKey = slotNumber.substring(slotNumber.length() - 1); int tubeOffset = tubeOffsetMap.getOrDefault(slotNumber, 1);
int tubeOffset = tubeOffsetMap.getOrDefault(offsetKey, 1);
int offsetResult = Integer.parseInt(tube.getCode()) + tubeOffset; int offsetResult = Integer.parseInt(tube.getCode()) + tubeOffset;
slotMap.put(String.valueOf(offsetResult), String.valueOf(command.ordinal())); slotMap.put(String.valueOf(offsetResult), String.valueOf(command.ordinal()));
} }