兼容未知字段

This commit is contained in:
ZZ 2021-11-17 17:36:17 +08:00
parent 24fb0c36ea
commit b3b5344209
5 changed files with 111 additions and 17 deletions

View File

@ -32,7 +32,7 @@ public class DTOJsonHelper {
try {
CommonResponse commonResponse = JSONUtil.readParams(responseBody, CommonResponse.class);
String data = (String) commonResponse.getData();
if (authSecretToken != null) {
if (authSecretToken != null && !data.isEmpty()) {
data = Aes128Cbc.decryptString(data, authSecretToken.getDataSecret(), authSecretToken.getDataSecretIV());
}
if (!data.isEmpty()) {

View File

@ -2,15 +2,11 @@ package com.xhpc.evcs.dto;
import com.fasterxml.jackson.annotation.*;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
@Getter
@Setter
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class StartChargeRequest {
@JsonProperty("StartChargeSeq")
@ -38,7 +34,7 @@ public class StartChargeRequest {
String userId3rdpty;
@JsonIgnore
private Map<String, Object> additionalProperties;
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
@ -52,4 +48,100 @@ public class StartChargeRequest {
this.additionalProperties.put(name, value);
}
@JsonProperty("StartChargeSeq")
public String getStartChargeSeq() {
return startChargeSeq;
}
@JsonProperty("StartChargeSeq")
public void setStartChargeSeq(String startChargeSeq) {
this.startChargeSeq = startChargeSeq;
}
@JsonProperty("ConnectorID")
public String getConnectorId() {
return connectorId;
}
@JsonProperty("ConnectorID")
public void setConnectorId(String connectorId) {
this.connectorId = connectorId;
}
@JsonProperty("QRCode")
public String getqRCode() {
return qRCode;
}
@JsonProperty("QRCode")
public void setqRCode(String qRCode) {
this.qRCode = qRCode;
}
@JsonProperty("PlateNum")
public String getPlateNum() {
return plateNum;
}
@JsonProperty("PlateNum")
public void setPlateNum(String plateNum) {
this.plateNum = plateNum;
}
@JsonProperty("CarPlateNo")
public String getPlateNum2() {
return plateNum2;
}
@JsonProperty("CarPlateNo")
public void setPlateNum2(String plateNum2) {
this.plateNum2 = plateNum2;
}
@JsonProperty("ChargingAmt")
public Integer getChargingAmt() {
return chargingAmt;
}
@JsonProperty("ChargingAmt")
public void setChargingAmt(Integer chargingAmt) {
this.chargingAmt = chargingAmt;
}
@JsonProperty("driverId")
public String getDriverId() {
return driverId;
}
@JsonProperty("driverId")
public void setDriverId(String driverId) {
this.driverId = driverId;
}
@JsonProperty("UserId")
public String getUserId3rdpty() {
return userId3rdpty;
}
@JsonProperty("UserId")
public void setUserId3rdpty(String userId3rdpty) {
this.userId3rdpty = userId3rdpty;
}
}

View File

@ -61,8 +61,9 @@ public class Aes128Cbc {
NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, NoSuchPaddingException,
InvalidKeyException {
System.out.println(decryptString("L+FOSPaN073SDRBNMqKBAQ==",
"ojs67l46z3f7rhok", "tet9swfkyojkhaos"
System.out.println(decryptString("gbmqQAsXVr/c1cvxNkxog7GXLZMMLEp9vGV3O/aW60ZkWNzFsLkwMd0tqb7nU6SKR0QrNL9n" +
"+ayJRaL0LTjPRA==",
"8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"
));
//ujNoGsWRo5MyPKYOxeofKwgPEng3xF+yhM8DDjwtwHo=
System.out.println(encrypt("{\"StationIDs\":[\"1\"]}", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));

View File

@ -110,7 +110,7 @@ public class NotificationStationStatusTask extends CoreDispatcher {
connectorStatusInfo.getOperatorID());
EvcsStatus status = DTOJsonHelper.parseResponseData(responseBody, EvcsStatus.class, authSecretTokenOut);
if (status == null || status.getStatus() != 0) {
log.error(String.format("push CD notification connector[%s] failed: %s",
log.error(String.format("push station status connector[%s] failed: %s",
connectorStatusInfo.getConnectorID(), responseBody));
}
return status;

View File

@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@ -62,12 +63,12 @@ public class RegisterLogic implements ServiceLogic {
REDIS.setCacheMap(gunkey, cacheGun);
String svcSrvKeyNew = "svcSrvGuns:".concat(getLocalIPAndPort());
cachePileGunSvcSrv(gunkey, svcSrvKeyNew);
// final Collection<String> cacheSvcSrvKeys = REDIS.keys("svcSrvGuns:*");
// for (String svcSrvKey : cacheSvcSrvKeys) {
// if (!svcSrvKey.equals(svcSrvKeyNew)) {
// REDIS.deleteSetVal(svcSrvKey, gunkey);
// }
// } todo ucat
final Collection<String> cacheSvcSrvKeys = REDIS.keys("svcSrvGuns:*");
for (String svcSrvKey : cacheSvcSrvKeys) {
if (!svcSrvKey.equals(svcSrvKeyNew)) {
REDIS.deleteSetVal(svcSrvKey, gunkey);
}
}
}
log.info("pile (re)registered ({}) ", pileNo);
}