From b94510459021405ee2ce81c3932694f2a3ac0325 Mon Sep 17 00:00:00 2001 From: ZZ Date: Tue, 26 Oct 2021 15:46:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E7=94=B5=E6=96=B0=E7=94=B5=E9=80=94in?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhpc/evcs/domain/XhpcChargingStation.java | 13 +++++++ .../java/com/xhpc/evcs/dto/PageRequest.java | 8 ++-- .../java/com/xhpc/evcs/dto/StationInfo.java | 6 +-- .../com/xhpc/evcs/encryption/Aes128Cbc.java | 36 +++++++---------- .../xhpc/evcs/api/StationsInfoController.java | 31 ++++++++++----- .../java/com/xhpc/evcs/config/EvcsFilter.java | 11 +++--- .../common/api/dto/ChargingStationDto.java | 39 +++++++++++++++++-- 7 files changed, 99 insertions(+), 45 deletions(-) diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingStation.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingStation.java index 722ed706..d5451a9c 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingStation.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/domain/XhpcChargingStation.java @@ -83,6 +83,19 @@ public class XhpcChargingStation extends BaseEntity { @Column(name = "operator_id_evcs", length = 20) private String operatorIdEvcs; + @Column(name = "service_tel") + private String serviceTel; + + public String getServiceTel() { + + return serviceTel; + } + + public void setServiceTel(String serviceTel) { + + this.serviceTel = serviceTel; + } + public String getOperatorIdEvcs() { return operatorIdEvcs; diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/PageRequest.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/PageRequest.java index 6b9f3eec..5124858d 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/PageRequest.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/PageRequest.java @@ -1,18 +1,20 @@ package com.xhpc.evcs.dto; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import lombok.Setter; -@Getter -@Setter +@JsonInclude(JsonInclude.Include.NON_NULL) @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) +@Getter +@Setter public class PageRequest { @JsonProperty("LastQueryTime") - String lastQueryTime; + String lastQueryTime = ""; @JsonProperty(value = "PageNo", defaultValue = "1") //CAUTION: PageNo must not wrote as PageNon or anything else Integer pageNo = 1; @JsonProperty(value = "PageSize", defaultValue = "10") diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationInfo.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationInfo.java index dea09088..ff954c69 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationInfo.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/dto/StationInfo.java @@ -50,13 +50,13 @@ public class StationInfo extends CommonStationInfo { public String serviceTel; @Transient @JsonProperty("StationType") - public Long stationType; + public Integer stationType; @Transient @JsonProperty("StationStatus") - public Long stationStatus; + public Integer stationStatus; @Transient @JsonProperty("ParkNums") - public Long parkNums; + public Integer parkNums; @Transient @JsonProperty("StationLng") public Double stationLng; diff --git a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/encryption/Aes128Cbc.java b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/encryption/Aes128Cbc.java index 5212d00b..1d2cf110 100644 --- a/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/encryption/Aes128Cbc.java +++ b/evcs-modules/evcs-common/src/main/java/com/xhpc/evcs/encryption/Aes128Cbc.java @@ -3,6 +3,8 @@ package com.xhpc.evcs.encryption; import javax.crypto.*; import javax.crypto.spec.SecretKeySpec; import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.nio.charset.StandardCharsets; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -62,28 +64,18 @@ public class Aes128Cbc { InvalidKeyException { System.out.println(encrypt("{\"PageNo\": \"1\", \"PageSize\": 49}", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6")); - System.out.println(decryptString("ywyEEd5aKPJOTraAY/gXB/bA+UNprpYnSaOhfF5lKc/Zcv" + - "/BRasig4KSPJD7UmrH2vjLVIWXPw42EbLgV9bXr5SzUSVAT28ief2nk6hpWnT8Dcvhn3W4bj7UdEY" + - "/AdONVXWuq2MZQocGYEVNvWcSD0OVCJ04fNTwPR4hs1xI/QDg9/hqYdQbvWt3go/y" + - "+M9wxd4vq8m44RPQ5zjW3vxFxc4oMg2t0oTdk6W5AzJzAGWhU/4xIv+8gLeh6/blpW/VBUK82+4tcdG2JSJv/DcaDM0" + - "/7C1LsCYY17o6gGd1mFVDSZhYcaOmOska+h+eyTKL4i8oHpT6uf+hFDRVBUC1OTjDeiL9NyIxcwd" + - "/MMfAaF04wHOHrYMavL5wcBUZWwtU1QSLWXkUy7muJNYvVg4dmw92nNKaJtxgFycXVGkSP3Nc6y" + - "/sAzYkTz9Wfn4RLVOkpyYJMOo1Tz93/OFEKQFPnjzSRQAVYiuPzuySKjXdcDY8AfqmDqYuVZ2FhH0iVU6FiSsK4" + - "+al0hnLOcnftqYtYSd7ir2coP6XtNejOByqFPrShMp4rPQLvDpFibV87clFMwWOGBiB0eFRvRbOSntDYN7PBpFHHJXRkNi3VCMiJ" + - "+Y=", - "8LpncubmWiPCzY3V" - , "av6A8QdnRaVRMXu6")); - System.out.println(decryptString("ywyEEd5aKPJOTraAY" + - "/gXB5Sz0CiZyWlVKyOoQDHvSZBdtC1aYGzpgAmLAQ7P2f0ArSSVx6xoF8sz2JyXKD00XiHuA4oc1hJnT1mRRetryz8bxmj6m" + - "/ClMebuBmtotiKxJqIZr5tayh/hizhcX2L8UUUDmKfp4Q1de1P/swB2VPC8suvrw2Y04r2I2MtF+7mHj1DdDn" + - "/DIStLJMLV9tx7xTu2K5fWS1E2ZUv33dVKRcA9qQGFmrI1IFLZyhIFcomv78nzXDg9U6/HRK3/JvtWxm9b6eDO" + - "/a5rUwpe1gKPFsVK/MvAXAxU8dmyIzxzC3fLQB1KFcG8XUWrejpakVwh5tKxKhmofWFXlja7FSC" + - "/vVdHjL5pOiBAOoxtmBDVPVrua2+/Nz5q9neXdA3olEamKYVCtFSWgSptFjhQb8pGAzSTxwuA+e4fJ5RqeAc+Ka0aHycpvtG" + - "/oZZN8+9xhWcnGWj0R8/xsXzFdXOnJ6/DI9SgKOUAzb/AGfHPeJJMibEru+nKrjuo3cNfyue6n6V2hu0Juxr" + - "/iLg2zRLVB54wL4Lvy3pi+9ULHzI7SBgKyF6bxxoeuS4YfmaVK+fhseqWNtxk" + - "/d8XJu93CqDUoxH5c1IEw16gQ1h9DMhVug2Cg8JbSkIGeFHhCvicOxIuUS2Uc2YgoUTbY0podXkJToBKByGJq7BjNdk49uhFlnHNMO4UZ5LzinsJZxxxdWtUIpqUvTf8a1x210u/IT3BYHQj+K+NeDfbzb2ga6Qdj3+CLL21", - "8LpncubmWiPCzY3V" - , "av6A8QdnRaVRMXu6")); +// System.out.println(decryptString("ywyEEd5aKPJOTraAY/gXB/bA+UNprpYnSaOhfF5lKc/Zcv" + +// "/BRasig4KSPJD7UmrH2vjLVIWXPw42EbLgV9bXr5SzUSVAT28ief2nk6hpWnT8Dcvhn3W4bj7UdEY" + +// "/AdONVXWuq2MZQocGYEVNvWcSD0OVCJ04fNTwPR4hs1xI/QDg9/hqYdQbvWt3go/y" + +// "+M9wxd4vq8m44RPQ5zjW3vxFxc4oMg2t0oTdk6W5AzJzAGWhU/4xIv+8gLeh6/blpW/VBUK82+4tcdG2JSJv/DcaDM0" + +// "/7C1LsCYY17o6gGd1mFVDSZhYcaOmOska+h+eyTKL4i8oHpT6uf+hFDRVBUC1OTjDeiL9NyIxcwd" + +// "/MMfAaF04wHOHrYMavL5wcBUZWwtU1QSLWXkUy7muJNYvVg4dmw92nNKaJtxgFycXVGkSP3Nc6y" + +// "/sAzYkTz9Wfn4RLVOkpyYJMOo1Tz93/OFEKQFPnjzSRQAVYiuPzuySKjXdcDY8AfqmDqYuVZ2FhH0iVU6FiSsK4" + +// "+al0hnLOcnftqYtYSd7ir2coP6XtNejOByqFPrShMp4rPQLvDpFibV87clFMwWOGBiB0eFRvRbOSntDYN7PBpFHHJXRkNi3VCMiJ" + +// "+Y=", +// "8LpncubmWiPCzY3V" +// , "av6A8QdnRaVRMXu6")); + System.out.println(new BigDecimal("244.0111117").setScale(6, RoundingMode.HALF_UP).doubleValue()); } } diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/StationsInfoController.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/StationsInfoController.java index d4075e92..86da1e06 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/StationsInfoController.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/api/StationsInfoController.java @@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -33,9 +35,10 @@ public class StationsInfoController extends CoreDispatcher { private XhpcChargingStationRepository xhpcChargingStationRepository; @Autowired private XhpcStationInternetBlacklistRepository xhpcStationInternetBlacklistRepo; + private String[] GUNNAMES = {"", "A", "B", "C", "D"}; @PostMapping("/v1/query_stations_info") - public CommonResponse queryStationsInfo(@RequestBody CommonRequest commonRequest) throws Exception { + public CommonResponse queryStationsInfo(@RequestBody(required = false) CommonRequest commonRequest) throws Exception { assert false; String operatorId = commonRequest.getOperatorId(); @@ -74,7 +77,7 @@ public class StationsInfoController extends CoreDispatcher { ChargingStationDto chargingStationDto = REDIS.getCacheObject(stationKey); if (chargingStationDto.getPiles() != null) { //todo rm dup or-else? StationInfo station = new StationInfo(); - station.setStationStatus(50L); + station.setStationStatus(50); final String stationId = stationKey.replace("station:", ""); station.setStationId(stationId); Double lat = chargingStationDto.getLat(); @@ -85,20 +88,28 @@ public class StationsInfoController extends CoreDispatcher { XhpcChargingStation xhpcChargingStation = xhpcChargingStationRepository.findOne(example).orElse(null); if (null != xhpcChargingStation) { - chargingStationDto.setLat(Double.valueOf(xhpcChargingStation.getLatitude())); - chargingStationDto.setLng(Double.valueOf(xhpcChargingStation.getLongitude())); - chargingStationDto.setType(Long.valueOf(xhpcChargingStation.getType())); + chargingStationDto.setLat(new BigDecimal(xhpcChargingStation.getLatitude()).setScale(6, + RoundingMode.HALF_UP).doubleValue()); + chargingStationDto.setLng(new BigDecimal(xhpcChargingStation.getLongitude()).setScale(6, + RoundingMode.HALF_UP).doubleValue()); + chargingStationDto.setType(xhpcChargingStation.getType()); chargingStationDto.setOperatorId(xhpcChargingStation.getOperatorIdEvcs() == null ? "MA6DFCTD5" : xhpcChargingStation.getOperatorIdEvcs()); chargingStationDto.setAreaCode(xhpcChargingStation.getAreaCode().toString()); + chargingStationDto.setName(xhpcChargingStation.getName()); + chargingStationDto.setServiceTel(xhpcChargingStation.getServiceTel()); REDIS.setCacheObject(stationKey, chargingStationDto); } } station.setStationLat(chargingStationDto.getLat()); station.setStationLng(chargingStationDto.getLng()); station.setStationType(chargingStationDto.getType()); + station.setStationStatus(50); + station.setParkNums(chargingStationDto.getParkNums()); station.setOperatorId(chargingStationDto.getOperatorId()); station.setEquipmentOwnerId(chargingStationDto.getOperatorId()); + station.setStationName(chargingStationDto.getName()); + station.setCountryCode("CN"); station.setAreaCode(chargingStationDto.getAreaCode()); station.setConstruction(chargingStationDto.getConstruction()); List piles = getEquipmentInfos(chargingStationDto.getPiles()); @@ -132,14 +143,12 @@ public class StationsInfoController extends CoreDispatcher { Example example = Example.of(pileExample); XhpcChargingPile xhpcChargingPile = xhpcChargingPileRepository.findOne(example).orElse(null); if (xhpcChargingPile != null) { - cachePile.put("connectorType", xhpcChargingPile.getType() == null ? Integer.valueOf(4) : - Integer.valueOf(xhpcChargingPile.getType())); + cachePile.put("connectorType", xhpcChargingPile.getType() == null ? 4 : xhpcChargingPile.getType()); cachePile.put("voltageUpperLimits", xhpcChargingPile.getMaxVoltage().intValue()); cachePile.put("voltageLowerLimits", xhpcChargingPile.getMinVoltage().intValue()); cachePile.put("current", xhpcChargingPile.getCurrent()); cachePile.put("power", xhpcChargingPile.getPower()); - cachePile.put("nationalStandard", xhpcChargingPile.getNationalStandard().equals("2011") ? - Integer.valueOf(1) : Integer.valueOf(2)); + cachePile.put("nationalStandard", xhpcChargingPile.getNationalStandard().equals("2011") ? 1 : 2); cachePile.put("equipmentType", xhpcChargingPile.getType()); REDIS.setCacheMap("pile:".concat(pileNo), cachePile); } @@ -163,6 +172,10 @@ public class StationsInfoController extends CoreDispatcher { String gunId = pileNo.concat(String.format("%02d", i)); ConnectorInfo connectorInfo = new ConnectorInfo(); connectorInfo.setConnectorID(gunId); + String connectorName = (String) REDIS.getCacheMapValue("gun:".concat(gunId), "terminalName"); //todo setem in redis! + connectorInfo.setConnectorName(connectorName == null ? + Integer.parseInt(pileNo.substring(5, 10)) + "号桩 " + GUNNAMES[i] + + "枪" : connectorName); Integer connectorType = (Integer) cachePile.get("connectorType"); connectorInfo.setConnectorType(connectorType == null ? 4 : connectorType); Integer voltageUpperLimits = (Integer) cachePile.get("voltageUpperLimits"); diff --git a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java index c066f39e..38041e14 100644 --- a/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java +++ b/evcs-modules/evcs-core/src/main/java/com/xhpc/evcs/config/EvcsFilter.java @@ -174,11 +174,12 @@ public class EvcsFilter extends OncePerRequestFilter { byte[] buf = responseWrapper.getContentAsByteArray(); log.debug("out.plain: {}", new String(buf, StandardCharsets.UTF_8)); String encryptedData; - AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId, - AuthSecretToken.SECRET_TOKEN_TYPE_OUT).orElse(null); - if (encout == null && authSecretTokenOut != null) { - encryptedData = encryptRespOut(authSecretTokenOut.getDataSecret(), authSecretTokenOut.getDataSecretIV(), - authSecretTokenOut.getSigSecret(), buf).toString(); +// AuthSecretToken authSecretTokenOut = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType +// (operatorId, +// AuthSecretToken.SECRET_TOKEN_TYPE_OUT).orElse(null); + if (encout == null && authSecretTokenIn != null) { + encryptedData = encryptRespOut(authSecretTokenIn.getDataSecret(), authSecretTokenIn.getDataSecretIV(), + authSecretTokenIn.getSigSecret(), buf).toString(); log.debug("out.enc: {}", encryptedData); response.getOutputStream().write(encryptedData == null ? internalError() : encryptedData.getBytes(StandardCharsets.UTF_8)); diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java index e9546f82..4e009763 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java @@ -10,9 +10,32 @@ public class ChargingStationDto { private String operatorId; private Double lat; private Double lng; - private Long type; + private Integer type; private Long construction; private String areaCode; + private String name; + private String serviceTel; + private Integer parkNums; + + public Integer getParkNums() { + + return parkNums; + } + + public void setParkNums(Integer parkNums) { + + this.parkNums = parkNums; + } + + public String getName() { + + return name; + } + + public void setName(String name) { + + this.name = name; + } public Double getLat() { @@ -34,12 +57,12 @@ public class ChargingStationDto { this.lng = lng; } - public Long getType() { + public Integer getType() { return type; } - public void setType(Long type) { + public void setType(Integer type) { this.type = type; } @@ -104,4 +127,14 @@ public class ChargingStationDto { this.areaCode = areaCode; } + public void setServiceTel(String serviceTel) { + + this.serviceTel = serviceTel; + } + + public String getServiceTel() { + + return serviceTel; + } + }