WIP:三方对接逻辑
This commit is contained in:
parent
93e2f109bb
commit
2280e9af5e
@ -15,7 +15,7 @@ public class StartChargeRequest {
|
|||||||
@JsonProperty("StartChargeSeq")
|
@JsonProperty("StartChargeSeq")
|
||||||
String startChargeSeq;
|
String startChargeSeq;
|
||||||
|
|
||||||
@JsonProperty("ConnectorId")
|
@JsonProperty("ConnectorID")
|
||||||
String connectorId;
|
String connectorId;
|
||||||
|
|
||||||
@JsonProperty("QRCode")
|
@JsonProperty("QRCode")
|
||||||
@ -24,10 +24,16 @@ public class StartChargeRequest {
|
|||||||
@JsonProperty("PlateNum")
|
@JsonProperty("PlateNum")
|
||||||
String plateNum;
|
String plateNum;
|
||||||
|
|
||||||
|
@JsonProperty("CarPlateNo")
|
||||||
|
String plateNum2;
|
||||||
|
|
||||||
@JsonProperty("ChargingAmt")
|
@JsonProperty("ChargingAmt")
|
||||||
Integer chargingAmt;
|
Integer chargingAmt;
|
||||||
|
|
||||||
@JsonProperty("driverId")
|
@JsonProperty("driverId")
|
||||||
String driverId;
|
String driverId;
|
||||||
|
|
||||||
|
@JsonProperty("UserId")
|
||||||
|
String userId3rdpty;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,12 @@ public class Aes128Cbc {
|
|||||||
NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, NoSuchPaddingException,
|
NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, NoSuchPaddingException,
|
||||||
InvalidKeyException {
|
InvalidKeyException {
|
||||||
|
|
||||||
System.out.println(encrypt("{\"PageNo\": \"1\", \"PageSize\": 49}", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));
|
System.out.println(decryptString("6vjf229/jP0V/lvorkuYeRSKiv" +
|
||||||
|
"+A2CMWqPaFVhjebxCxkYmRObUp9I8EoXkHLoeHYRVZwlG47PQ1N4YIn6B5bvtpP4hmFkgHvNzg7UW5+GnCSKxV9RBXxGW" +
|
||||||
|
"/uWDiPQbgh6gflk4Ia/zvgD9ZLTyAXAm4in/dYovaWcHm08fZ" +
|
||||||
|
"+xfGoHENu1taQO7BcWidJJtmPkVAWECKTHEbcoFcZagKjHIJV5f7V8OrmawYGQqNmA8=", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"
|
||||||
|
));
|
||||||
|
//ujNoGsWRo5MyPKYOxeofKwgPEng3xF+yhM8DDjwtwHo=
|
||||||
System.out.println(encrypt("{\"StationIDs\":[\"1\"]}", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));
|
System.out.println(encrypt("{\"StationIDs\":[\"1\"]}", "8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));
|
||||||
System.out.println(encrypt("{\"OperatorID\":\"MA5FNJXW9\", \"OperatorSecret\":\"Ut5UFdqDthiJyncU\"}",
|
System.out.println(encrypt("{\"OperatorID\":\"MA5FNJXW9\", \"OperatorSecret\":\"Ut5UFdqDthiJyncU\"}",
|
||||||
"8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));
|
"8LpncubmWiPCzY3V", "av6A8QdnRaVRMXu6"));
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
<groupId>com.xhpc</groupId>
|
<groupId>com.xhpc</groupId>
|
||||||
<artifactId>evcs-common</artifactId>
|
<artifactId>evcs-common</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
|
|||||||
@ -53,6 +53,8 @@ public class QueryEquipAuthController {
|
|||||||
String terminalStatus = (String) realTimeTerminalData.get("vehicleGunStatus");
|
String terminalStatus = (String) realTimeTerminalData.get("vehicleGunStatus");
|
||||||
if ("否".equals(terminalStatus)) {
|
if ("否".equals(terminalStatus)) {
|
||||||
resp.setMsg("gun is not plugging");
|
resp.setMsg("gun is not plugging");
|
||||||
|
resp.setRet("1");
|
||||||
|
equipAuthResponse.setSuccStat(1);
|
||||||
equipAuthResponse.setFailReason(1);
|
equipAuthResponse.setFailReason(1);
|
||||||
} else {
|
} else {
|
||||||
resp.setMsg("success");
|
resp.setMsg("success");
|
||||||
|
|||||||
@ -39,96 +39,97 @@ public class QueryEquipBusinessPolicyController {
|
|||||||
commonResponse.setRet("1");
|
commonResponse.setRet("1");
|
||||||
return commonResponse;
|
return commonResponse;
|
||||||
}
|
}
|
||||||
Long rateModelId = (Long) cachePile.get("rateModelId");
|
|
||||||
CacheRateModel rateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
|
||||||
String[] tfPricesSeq = rateModel.getTfPricesSeq();
|
|
||||||
|
|
||||||
//存储时段
|
|
||||||
ArrayList<String> modelTypes = new ArrayList<>();
|
ArrayList<String> modelTypes = new ArrayList<>();
|
||||||
//存储时段个数
|
//存储时段个数
|
||||||
ArrayList<Integer> modelCount = new ArrayList<>();
|
ArrayList<Integer> modelCount = new ArrayList<>();
|
||||||
//建立对应时段的映射Map集合,存放其对应的价格和服务费
|
Long rateModelId = (Long) cachePile.get("rateModelId");
|
||||||
Map<String, Object> timeMap = new HashMap<>();
|
CacheRateModel rateModel = REDIS.getCacheObject("rateModel:" + rateModelId);
|
||||||
//个数计数器
|
PolicyInfos[] policyInfosArr = new PolicyInfos[0];
|
||||||
int count = 0;
|
if (rateModel != null) {
|
||||||
//最后一个时段的前一个时段的下标索引
|
String[] tfPricesSeq = rateModel.getTfPricesSeq();
|
||||||
int index = 0;
|
//存储时段
|
||||||
//遍历获取每一个时段
|
//建立对应时段的映射Map集合,存放其对应的价格和服务费
|
||||||
for (int i = 0; i < tfPricesSeq.length - 1; i++) {
|
Map<String, Object> timeMap = new HashMap<>();
|
||||||
count++;
|
//个数计数器
|
||||||
//如果当前时段与后面的时段不相同,则表示当前时段已经结束,添加当前时段到list中,并将其坐标存放到另一个集合中。
|
int count = 0;
|
||||||
if (!tfPricesSeq[i].equals(tfPricesSeq[i + 1])) {
|
//最后一个时段的前一个时段的下标索引
|
||||||
//将每段时间的索引,赋值
|
int index = 0;
|
||||||
index = i;
|
//遍历获取每一个时段
|
||||||
modelTypes.add(tfPricesSeq[i]);
|
for (int i = 0; i < tfPricesSeq.length - 1; i++) {
|
||||||
modelCount.add(count);
|
count++;
|
||||||
//如果这段时段结束,则重置计数器
|
//如果当前时段与后面的时段不相同,则表示当前时段已经结束,添加当前时段到list中,并将其坐标存放到另一个集合中。
|
||||||
count = 0;
|
if (!tfPricesSeq[i].equals(tfPricesSeq[i + 1])) {
|
||||||
|
//将每段时间的索引,赋值
|
||||||
|
index = i;
|
||||||
|
modelTypes.add(tfPricesSeq[i]);
|
||||||
|
modelCount.add(count);
|
||||||
|
//如果这段时段结束,则重置计数器
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
//获取最后一个时段的费率值
|
||||||
//获取最后一个时段的费率值
|
String lastModelType = tfPricesSeq[tfPricesSeq.length - 1];
|
||||||
String lastModelType = tfPricesSeq[tfPricesSeq.length - 1];
|
//放入到类型list中
|
||||||
//放入到类型list中
|
modelTypes.add(lastModelType);
|
||||||
modelTypes.add(lastModelType);
|
//获取最后一个时段的费率的个数
|
||||||
//获取最后一个时段的费率的个数
|
int lastCount = (tfPricesSeq.length - 1) - index;
|
||||||
int lastCount = (tfPricesSeq.length - 1) - index;
|
//放入到个数List中
|
||||||
//放入到个数List中
|
modelCount.add(lastCount);
|
||||||
modelCount.add(lastCount);
|
|
||||||
|
|
||||||
//获取各个类型的时段的时间区间,并将其存放至timeList集合中。
|
//获取各个类型的时段的时间区间,并将其存放至timeList集合中。
|
||||||
//定义一个初始时间段
|
//定义一个初始时间段
|
||||||
String initTime = "000000";
|
String initTime = "000000";
|
||||||
//添加临时存储变量
|
//添加临时存储变量
|
||||||
int temp = -1;
|
int temp = -1;
|
||||||
ArrayList<String> timeList = new ArrayList<>();
|
ArrayList<String> timeList = new ArrayList<>();
|
||||||
//放入必有初始时间
|
//放入必有初始时间
|
||||||
timeList.add(initTime);
|
timeList.add(initTime);
|
||||||
//根据出现的时段个数确定他们的时间区间,然后存放至List集合中
|
//根据出现的时段个数确定他们的时间区间,然后存放至List集合中
|
||||||
for (int i = 0; i < modelCount.size() - 1; i++) {
|
for (int i = 0; i < modelCount.size() - 1; i++) {
|
||||||
if (temp != -1) {
|
if (temp != -1) {
|
||||||
Integer integer = modelCount.get(i);
|
Integer integer = modelCount.get(i);
|
||||||
int hours = integer / 2;
|
int hours = integer / 2;
|
||||||
temp = temp + hours;
|
temp = temp + hours;
|
||||||
String hoursStr = String.format("%02d", temp);
|
String hoursStr = String.format("%02d", temp);
|
||||||
String finalTime = hoursStr + "0000";
|
String finalTime = hoursStr + "0000";
|
||||||
timeList.add(finalTime);
|
timeList.add(finalTime);
|
||||||
} else {
|
} else {
|
||||||
Integer integer = modelCount.get(i);
|
Integer integer = modelCount.get(i);
|
||||||
int hours = integer / 2;
|
int hours = integer / 2;
|
||||||
//记录中间时间
|
//记录中间时间
|
||||||
temp = hours;
|
temp = hours;
|
||||||
String hoursStr = String.format("%02d", temp);
|
String hoursStr = String.format("%02d", temp);
|
||||||
String finalTime = hoursStr + "0000";
|
String finalTime = hoursStr + "0000";
|
||||||
timeList.add(finalTime);
|
timeList.add(finalTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
policyInfosArr = new PolicyInfos[timeList.size()];
|
||||||
|
for (int i = 0; i <= timeList.size() - 1; i++) {
|
||||||
PolicyInfos[] policyInfosArr = new PolicyInfos[timeList.size()];
|
PolicyInfos policyInfos = new PolicyInfos();
|
||||||
for (int i = 0; i <= timeList.size() - 1; i++) {
|
policyInfos.setStartTime(timeList.get(i));
|
||||||
PolicyInfos policyInfos = new PolicyInfos();
|
String modelType = modelTypes.get(i);
|
||||||
policyInfos.setStartTime(timeList.get(i));
|
switch (modelType) {
|
||||||
String modelType = modelTypes.get(i);
|
case "00":
|
||||||
switch (modelType) {
|
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT1SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
case "00":
|
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT1Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT1SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
break;
|
||||||
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT1Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
case "01":
|
||||||
break;
|
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT2SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
case "01":
|
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT2Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT2SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
break;
|
||||||
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT2Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
case "02":
|
||||||
break;
|
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT3SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
case "02":
|
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT3Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT3SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
break;
|
||||||
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT3Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
case "03":
|
||||||
break;
|
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT4SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
case "03":
|
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT4Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
||||||
policyInfos.setServicePrice(BigDecimal.valueOf((long) rateModel.getT4SvcPrice()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
break;
|
||||||
policyInfos.setElecPrice(BigDecimal.valueOf((long) rateModel.getT4Price()).divide(BigDecimal.valueOf(100000L)).setScale(4).doubleValue());
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
break;
|
policyInfosArr[i] = policyInfos;
|
||||||
}
|
}
|
||||||
policyInfosArr[i] = policyInfos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//封装数据
|
//封装数据
|
||||||
|
|||||||
@ -51,13 +51,16 @@ public class QueryStartChargeController {
|
|||||||
resp.setMsg("This 3rd has no token");
|
resp.setMsg("This 3rd has no token");
|
||||||
} else {
|
} else {
|
||||||
// invoke a order making interface(finished);
|
// invoke a order making interface(finished);
|
||||||
R res = pileOrderService.pileStartUpBy3rd(startChargeSeq, startChargeRequest.getDriverId(), startChargeRequest.getChargingAmt(), startChargeRequest.getPlateNum(), 0, connectorID);
|
String plateNum = startChargeRequest.getPlateNum();
|
||||||
|
plateNum = plateNum == null ? startChargeRequest.getPlateNum2() : plateNum;
|
||||||
|
R res = pileOrderService.pileStartUpBy3rd(startChargeSeq, startChargeRequest.getDriverId(),
|
||||||
|
startChargeRequest.getChargingAmt(), plateNum, 0, connectorID);
|
||||||
startChargeResponse.setStartChargeSeq(startChargeSeq);
|
startChargeResponse.setStartChargeSeq(startChargeSeq);
|
||||||
startChargeResponse.setConnectorID(connectorID);
|
startChargeResponse.setConnectorID(connectorID);
|
||||||
if (res.getCode() != 200) {
|
if (res.getCode() != 200) {
|
||||||
startChargeResponse.setSuccStat(1);
|
startChargeResponse.setSuccStat(1);
|
||||||
startChargeResponse.setFailReason(0);
|
startChargeResponse.setFailReason(0);
|
||||||
startChargeResponse.setStartChargeSeqStat(5);
|
startChargeResponse.setStartChargeSeqStat(4);
|
||||||
} else {
|
} else {
|
||||||
Map<String, Object> etOrderData = (Map<String, Object>) res.getData();
|
Map<String, Object> etOrderData = (Map<String, Object>) res.getData();
|
||||||
EtOrderMapping etOrderMapping = new EtOrderMapping();
|
EtOrderMapping etOrderMapping = new EtOrderMapping();
|
||||||
@ -81,6 +84,7 @@ public class QueryStartChargeController {
|
|||||||
pushOrder.put("chargeOrderInfoNotificationStat", 0);
|
pushOrder.put("chargeOrderInfoNotificationStat", 0);
|
||||||
REDIS.setCacheMap("pushOrder:".concat(orderNo), pushOrder);
|
REDIS.setCacheMap("pushOrder:".concat(orderNo), pushOrder);
|
||||||
}
|
}
|
||||||
|
resp.setMsg(res.getMsg());
|
||||||
resp.setRet(String.valueOf(res.getCode()));
|
resp.setRet(String.valueOf(res.getCode()));
|
||||||
}
|
}
|
||||||
resp.setData(JSONUtil.toJSONString(startChargeResponse));
|
resp.setData(JSONUtil.toJSONString(startChargeResponse));
|
||||||
|
|||||||
@ -46,9 +46,9 @@ public class QueryStationStatusController {
|
|||||||
if (null != chargingStationDto) {
|
if (null != chargingStationDto) {
|
||||||
pileIds = chargingStationDto.getPiles();
|
pileIds = chargingStationDto.getPiles();
|
||||||
}
|
}
|
||||||
|
boolean existsGun = false;
|
||||||
|
List<ConnectorStatusInfo> connectorStatusInfos = new ArrayList<>();
|
||||||
for (String pileId : pileIds) {
|
for (String pileId : pileIds) {
|
||||||
boolean existsGun = false;
|
|
||||||
List<ConnectorStatusInfo> connectorStatusInfos = new ArrayList<>();
|
|
||||||
for (String value : gunsIds) {
|
for (String value : gunsIds) {
|
||||||
if (pileId.equals(value.substring(0, 14))) {
|
if (pileId.equals(value.substring(0, 14))) {
|
||||||
existsGun = true;
|
existsGun = true;
|
||||||
@ -63,12 +63,12 @@ public class QueryStationStatusController {
|
|||||||
connectorStatusInfos.add(connectorStatusInfo);
|
connectorStatusInfos.add(connectorStatusInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existsGun) {
|
}
|
||||||
StationStatusInfo stationStatusInfo = new StationStatusInfo();
|
if (existsGun) {
|
||||||
stationStatusInfo.setStationID(stationID);
|
StationStatusInfo stationStatusInfo = new StationStatusInfo();
|
||||||
stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos);
|
stationStatusInfo.setStationID(stationID);
|
||||||
stationStatusInfos.add(stationStatusInfo);
|
stationStatusInfo.setConnectorStatusInfos(connectorStatusInfos);
|
||||||
}
|
stationStatusInfos.add(stationStatusInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class QueryStationStatusController {
|
|||||||
}
|
}
|
||||||
CommonResponse resp = new CommonResponse();
|
CommonResponse resp = new CommonResponse();
|
||||||
resp.setRet("0");
|
resp.setRet("0");
|
||||||
resp.setMsg("");
|
resp.setMsg("Query station status success");
|
||||||
resp.setData(JSONUtil.toJSONString(stationStatusInfoWrappers));
|
resp.setData(JSONUtil.toJSONString(stationStatusInfoWrappers));
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
package com.xhpc.evcs.api;
|
package com.xhpc.evcs.api;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.xhpc.evcs.config.EvcsFilter;
|
|
||||||
import com.xhpc.evcs.domain.AuthSecretToken;
|
import com.xhpc.evcs.domain.AuthSecretToken;
|
||||||
|
import com.xhpc.evcs.domain.XhpcInternetUser;
|
||||||
import com.xhpc.evcs.dto.CommonResponse;
|
import com.xhpc.evcs.dto.CommonResponse;
|
||||||
import com.xhpc.evcs.dto.TokenRequest;
|
import com.xhpc.evcs.dto.TokenRequest;
|
||||||
import com.xhpc.evcs.dto.TokenResponse;
|
import com.xhpc.evcs.dto.TokenResponse;
|
||||||
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
import com.xhpc.evcs.jpa.AuthSecretTokenRepository;
|
||||||
|
import com.xhpc.evcs.jpa.XhpcInternetUserRepository;
|
||||||
import com.xhpc.evcs.utils.JSONUtil;
|
import com.xhpc.evcs.utils.JSONUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -17,7 +16,10 @@ import org.springframework.web.bind.annotation.RequestHeader;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -28,6 +30,8 @@ public class QueryTokenController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthSecretTokenRepository authSecretTokenRepository;
|
private AuthSecretTokenRepository authSecretTokenRepository;
|
||||||
|
@Autowired
|
||||||
|
private XhpcInternetUserRepository xhpcInternetUserRepository;
|
||||||
|
|
||||||
@PostMapping("/v1/query_token")
|
@PostMapping("/v1/query_token")
|
||||||
public CommonResponse queryToken(@RequestHeader(value = "enc.out", defaultValue = "true") String encout,
|
public CommonResponse queryToken(@RequestHeader(value = "enc.out", defaultValue = "true") String encout,
|
||||||
@ -37,55 +41,66 @@ public class QueryTokenController {
|
|||||||
CommonResponse resp = new CommonResponse();
|
CommonResponse resp = new CommonResponse();
|
||||||
resp.setRet("0");
|
resp.setRet("0");
|
||||||
resp.setMsg("");
|
resp.setMsg("");
|
||||||
|
String decodedData = (String) tokenRequest.getAdditionalProperties().get("Data");
|
||||||
|
try {
|
||||||
|
tokenRequest = JSONUtil.readParams(decodedData, TokenRequest.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("invalid Data string: {}", decodedData);
|
||||||
|
}
|
||||||
String operatorID = tokenRequest.getOperatorId();
|
String operatorID = tokenRequest.getOperatorId();
|
||||||
TokenResponse tokenResponse = new TokenResponse();
|
TokenResponse tokenResponse = new TokenResponse();
|
||||||
tokenResponse.setOperatorId("MA6DFCTD5");
|
tokenResponse.setOperatorId("MA6DFCTD5");
|
||||||
tokenResponse.setSuccStat(0);
|
tokenResponse.setSuccStat(0);
|
||||||
tokenResponse.setFailReason(0);
|
tokenResponse.setFailReason(0);
|
||||||
String data = null;
|
String data = null;
|
||||||
AuthSecretToken authSecretTokenIn =
|
XhpcInternetUser xhpcInternetUser =
|
||||||
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(
|
xhpcInternetUserRepository.findByOperatorIdEvcsAndCooperationStartTimeBeforeAndCooperationEndTimeAfter(tokenRequest.getOperatorId(), Instant.now(), Instant.now());
|
||||||
operatorID, AuthSecretToken.SECRET_TOKEN_TYPE_IN, tokenRequest.getOperatorSecret()).orElse(null);
|
if (xhpcInternetUser != null) {
|
||||||
if (authSecretTokenIn == null) {
|
String operatorSecret = tokenRequest.getOperatorSecret();
|
||||||
resp.setRet("4003");
|
if (operatorSecret == null) {
|
||||||
resp.setMsg("Invalid OperatorID/Secret");
|
operatorSecret = tokenRequest.getOperatorSecret();
|
||||||
tokenResponse.setSuccStat(1);
|
|
||||||
tokenResponse.setFailReason(2);
|
|
||||||
resp.setData(data);
|
|
||||||
} else {
|
|
||||||
String token;
|
|
||||||
if (authSecretTokenIn.getTokenExpiry() != null && !authSecretTokenIn.getTokenExpiry().before(Calendar.getInstance().getTime())) {
|
|
||||||
token = authSecretTokenIn.getToken();
|
|
||||||
} else {
|
|
||||||
token = UUID.randomUUID().toString().replaceAll("-", "");
|
|
||||||
authSecretTokenIn.setToken(token);
|
|
||||||
authSecretTokenIn.setTokenExpiry(getTokenExpiry());
|
|
||||||
authSecretTokenRepository.save(authSecretTokenIn);
|
|
||||||
}
|
}
|
||||||
tokenResponse.setAccessToken(token);
|
AuthSecretToken authSecretTokenIn =
|
||||||
tokenResponse.setTokenAvailableTime(7200);
|
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(
|
||||||
tokenResponse.setSuccStat(0);
|
operatorID, AuthSecretToken.SECRET_TOKEN_TYPE_IN, operatorSecret).orElse(null);
|
||||||
tokenResponse.setFailReason(0);
|
if (authSecretTokenIn == null) {
|
||||||
resp.setMsg("Query token success");
|
resp.setRet("4003");
|
||||||
resp.setData(JSONUtil.toJSONString(tokenResponse));
|
resp.setMsg("Invalid OperatorID/Secret");
|
||||||
byte[] buf = JSONUtil.toJSONString(resp).getBytes(StandardCharsets.UTF_8);
|
tokenResponse.setSuccStat(1);
|
||||||
log.debug("out.plain: {}", new String(buf, StandardCharsets.UTF_8));
|
tokenResponse.setFailReason(2);
|
||||||
if (!encout.equalsIgnoreCase("false") || !authSecretTokenIn.isEncrypt()) {
|
resp.setData(data);
|
||||||
final JsonNode encrypt = EvcsFilter.encryptRespOut(authSecretTokenIn.getDataSecret(),
|
} else {
|
||||||
authSecretTokenIn.getDataSecretIV(), authSecretTokenIn.getSigSecret(), buf);
|
String token;
|
||||||
resp.setData(encrypt.get("Data"));
|
if (authSecretTokenIn.getTokenExpiry() != null && !authSecretTokenIn.getTokenExpiry().before(Calendar.getInstance().getTime())) {
|
||||||
resp.setSig(encrypt.get("Sig").asText());
|
token = authSecretTokenIn.getToken();
|
||||||
log.debug("out.enc: {}", resp);
|
} else {
|
||||||
|
token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
authSecretTokenIn.setToken(token);
|
||||||
|
authSecretTokenIn.setTokenExpiry(getTokenExpiry(xhpcInternetUser));
|
||||||
|
authSecretTokenRepository.save(authSecretTokenIn);
|
||||||
|
}
|
||||||
|
tokenResponse.setAccessToken(token);
|
||||||
|
Instant te = authSecretTokenIn.getTokenExpiry().toInstant();
|
||||||
|
tokenResponse.setTokenAvailableTime(Long.valueOf(ChronoUnit.SECONDS.between(Instant.now(), te)).intValue());
|
||||||
|
tokenResponse.setSuccStat(0);
|
||||||
|
tokenResponse.setFailReason(0);
|
||||||
|
resp.setMsg("Query token success");
|
||||||
|
resp.setData(JSONUtil.toJSONString(tokenResponse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getTokenExpiry() {
|
private Date getTokenExpiry(XhpcInternetUser xhpcInternetUser) {
|
||||||
|
|
||||||
DateTime dt = new DateTime();
|
Instant cooperationEndTime = xhpcInternetUser.getCooperationEndTime();
|
||||||
dt = dt.plusSeconds(7200);
|
LocalDateTime now = LocalDateTime.now();
|
||||||
return dt.toDate();
|
Instant tokenEndtime = now.plusSeconds(7200).toInstant(ZoneId.systemDefault().getRules().getOffset(now));
|
||||||
|
if (tokenEndtime.isAfter(cooperationEndTime)) {
|
||||||
|
return Date.from(cooperationEndTime);
|
||||||
|
} else {
|
||||||
|
return Date.from(tokenEndtime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,10 @@ public class EvcsFilter extends OncePerRequestFilter {
|
|||||||
AuthSecretToken authSecretTokenIn;
|
AuthSecretToken authSecretTokenIn;
|
||||||
Date now = Calendar.getInstance().getTime();
|
Date now = Calendar.getInstance().getTime();
|
||||||
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
|
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
|
||||||
if (authorization != null && authorization.startsWith("Bearer ")) {
|
if (servletPath.endsWith("query_token")) {
|
||||||
|
handleQueryToken(request, response, chain, requestWrapper, bodyString, commonRequest, operatorId,
|
||||||
|
responseWrapper);
|
||||||
|
} else if (authorization != null && authorization.startsWith("Bearer ")) {
|
||||||
String token = authorization.substring(7);
|
String token = authorization.substring(7);
|
||||||
authSecretTokenIn =
|
authSecretTokenIn =
|
||||||
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndTokenExpiryGreaterThan(
|
authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenTypeAndTokenExpiryGreaterThan(
|
||||||
@ -94,41 +97,6 @@ public class EvcsFilter extends OncePerRequestFilter {
|
|||||||
chain.doFilter(requestWrapper, responseWrapper);
|
chain.doFilter(requestWrapper, responseWrapper);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (authorization == null) { //todo giv't better arrangement
|
|
||||||
if (servletPath.endsWith("/query_token")) {
|
|
||||||
authSecretTokenIn = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
|
||||||
AuthSecretToken.SECRET_TOKEN_TYPE_IN).orElse(null);
|
|
||||||
if (authSecretTokenIn == null) {
|
|
||||||
CommonResponse resp = new CommonResponse();
|
|
||||||
resp.setRet("4003");
|
|
||||||
resp.setMsg("Invalid OperatorID");
|
|
||||||
String data = JSONUtil.toJSONString(resp);
|
|
||||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
// response.setStatus(403);
|
|
||||||
responseWrapper = new ContentCachingResponseWrapper(response);
|
|
||||||
chain.doFilter(requestWrapper, responseWrapper);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
final byte[] decrypt;
|
|
||||||
try {
|
|
||||||
decrypt = decrypt(request, authSecretTokenIn, commonRequest, bodyString);
|
|
||||||
} catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
CommonResponse resp = new CommonResponse();
|
|
||||||
resp.setRet("4003");
|
|
||||||
resp.setMsg("Invalid Encryption");
|
|
||||||
String data = JSONUtil.toJSONString(resp);
|
|
||||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
chain.doFilter(requestWrapper, responseWrapper);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
((HttpServletRequestRepeatReadWrapper) requestWrapper).setBody(decrypt);
|
|
||||||
chain.doFilter(requestWrapper, response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//decrypt request
|
//decrypt request
|
||||||
byte[] decryptedReq = null;
|
byte[] decryptedReq = null;
|
||||||
@ -136,22 +104,26 @@ public class EvcsFilter extends OncePerRequestFilter {
|
|||||||
CommonResponse resp = new CommonResponse();
|
CommonResponse resp = new CommonResponse();
|
||||||
authSecretTokenIn = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
authSecretTokenIn = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
||||||
AuthSecretToken.SECRET_TOKEN_TYPE_IN).orElse(null);
|
AuthSecretToken.SECRET_TOKEN_TYPE_IN).orElse(null);
|
||||||
if (authSecretTokenIn != null
|
if (authSecretTokenIn != null) {
|
||||||
&& now.before(authSecretTokenIn.getTokenExpiry())
|
if (servletPath.endsWith("query_token") ||
|
||||||
&& authorization != null && authorization.substring(7).equals(authSecretTokenIn.getToken())) {
|
(now.before(authSecretTokenIn.getTokenExpiry())
|
||||||
try {
|
&& authorization != null && authorization.substring(7).equals(authSecretTokenIn.getToken()))) {
|
||||||
if (authSecretTokenIn.isEncrypt() && !"false".equals(encin)) {
|
try {
|
||||||
decryptedReq = decrypt(request, authSecretTokenIn, commonRequest, bodyString);
|
if (authSecretTokenIn.isEncrypt() && !"false".equals(encin)) {
|
||||||
} else {
|
decryptedReq = decrypt(request, authSecretTokenIn, commonRequest, bodyString);
|
||||||
decryptedReq = commonRequest.getData().getBytes(StandardCharsets.UTF_8);
|
} else {
|
||||||
|
String data = commonRequest.getData();
|
||||||
|
if (data == null) data = bodyString;
|
||||||
|
decryptedReq = data.getBytes(StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
commonRequest.setData(new String(decryptedReq));
|
||||||
|
log.debug("in.dec: {}", commonRequest);
|
||||||
|
} catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
||||||
|
erroMsg = e.getMessage();
|
||||||
}
|
}
|
||||||
commonRequest.setData(new String(decryptedReq));
|
} else {
|
||||||
log.debug("in.dec: {}", commonRequest);
|
erroMsg = "Authorization error, check OperatorID or token expiry";
|
||||||
} catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
|
||||||
erroMsg = e.getMessage();
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
erroMsg = "Authorization error, check OperatorID or token expiry";
|
|
||||||
}
|
}
|
||||||
if (decryptedReq != null && decryptedReq.length > 0) {
|
if (decryptedReq != null && decryptedReq.length > 0) {
|
||||||
requestWrapper = new HttpServletRequestWritableWrapper(request,
|
requestWrapper = new HttpServletRequestWritableWrapper(request,
|
||||||
@ -193,11 +165,47 @@ public class EvcsFilter extends OncePerRequestFilter {
|
|||||||
resp.setMsg("Encryption error");
|
resp.setMsg("Encryption error");
|
||||||
String data = JSONUtil.toJSONString(resp);
|
String data = JSONUtil.toJSONString(resp);
|
||||||
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||||
chain.doFilter(requestWrapper, responseWrapper);
|
// chain.doFilter(requestWrapper, responseWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleQueryToken(HttpServletRequest request,
|
||||||
|
HttpServletResponse response, FilterChain chain,
|
||||||
|
ServletRequest requestWrapper, String bodyString, CommonRequest commonRequest,
|
||||||
|
String operatorId,
|
||||||
|
ContentCachingResponseWrapper responseWrapper) throws IOException, ServletException {
|
||||||
|
|
||||||
|
AuthSecretToken authSecretTokenIn = authSecretTokenRepository.findByOperatorId3irdptyAndSecretTokenType(operatorId,
|
||||||
|
AuthSecretToken.SECRET_TOKEN_TYPE_IN).orElse(null);
|
||||||
|
if (authSecretTokenIn == null) {
|
||||||
|
CommonResponse resp = new CommonResponse();
|
||||||
|
resp.setRet("4003");
|
||||||
|
resp.setMsg("Invalid OperatorID");
|
||||||
|
String data = JSONUtil.toJSONString(resp);
|
||||||
|
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||||
|
// response.setStatus(403);
|
||||||
|
responseWrapper = new ContentCachingResponseWrapper(response);
|
||||||
|
// chain.doFilter(requestWrapper, responseWrapper);
|
||||||
|
} else {
|
||||||
|
final byte[] decrypt;
|
||||||
|
try {
|
||||||
|
decrypt = decrypt(request, authSecretTokenIn, commonRequest, bodyString);
|
||||||
|
} catch (BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | IllegalBlockSizeException | NoSuchPaddingException | InvalidKeyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
CommonResponse resp = new CommonResponse();
|
||||||
|
resp.setRet("4003");
|
||||||
|
resp.setMsg("Invalid Encryption");
|
||||||
|
String data = JSONUtil.toJSONString(resp);
|
||||||
|
response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
|
||||||
|
// chain.doFilter(requestWrapper, responseWrapper);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
((HttpServletRequestRepeatReadWrapper) requestWrapper).setBody(decrypt);
|
||||||
|
// chain.doFilter(requestWrapper, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] internalError() {
|
private byte[] internalError() {
|
||||||
|
|
||||||
CommonResponse resp = new CommonResponse();
|
CommonResponse resp = new CommonResponse();
|
||||||
@ -295,11 +303,13 @@ public class EvcsFilter extends OncePerRequestFilter {
|
|||||||
JsonNode timestampNode = rootNode.path("TimeStamp");
|
JsonNode timestampNode = rootNode.path("TimeStamp");
|
||||||
JsonNode seqNode = rootNode.path("Seq");
|
JsonNode seqNode = rootNode.path("Seq");
|
||||||
if (!dataNode.isNull()) {
|
if (!dataNode.isNull()) {
|
||||||
String computedSig = HMAC.hmacDigest(
|
if (!dataNode.asText().startsWith("{")) {
|
||||||
operatorIDNode.asText().concat(dataNode.asText()).concat(timestampNode.asText()).concat(seqNode.asText()),
|
String computedSig = HMAC.hmacDigest(
|
||||||
authSecretToken.getSigSecret());
|
operatorIDNode.asText().concat(dataNode.asText()).concat(timestampNode.asText()).concat(seqNode.asText()),
|
||||||
if ((encin == null || !"false".equals(encin)) && !computedSig.equals(sigNode.asText())) {
|
authSecretToken.getSigSecret());
|
||||||
throw new InvalidAlgorithmParameterException("Illegal Sig, computed: ".concat(computedSig));
|
if ((encin == null || !"false".equals(encin)) && !computedSig.equals(sigNode.asText())) {
|
||||||
|
throw new InvalidAlgorithmParameterException("Illegal Sig, computed: ".concat(computedSig));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String rawData = dataNode.asText();
|
String rawData = dataNode.asText();
|
||||||
String decryptedData = rawData;
|
String decryptedData = rawData;
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.xhpc.evcs.jpa;
|
||||||
|
|
||||||
|
import com.xhpc.evcs.domain.XhpcInternetUser;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.data.repository.query.QueryByExampleExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface XhpcInternetUserRepository extends JpaRepository<XhpcInternetUser, Long>,
|
||||||
|
QueryByExampleExecutor<XhpcInternetUser>, JpaSpecificationExecutor<XhpcInternetUser> {
|
||||||
|
|
||||||
|
XhpcInternetUser findByOperatorIdEvcsAndCooperationStartTimeBeforeAndCooperationEndTimeAfter(String operatorId3rdpty,
|
||||||
|
Instant now, Instant now2);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -14,8 +14,8 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>evcs-core</module>
|
|
||||||
<module>evcs-common</module>
|
<module>evcs-common</module>
|
||||||
|
<module>evcs-core</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
|
|||||||
@ -67,5 +67,10 @@ public interface PileOrderService {
|
|||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
|
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
|
||||||
R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber, @RequestParam(value = "driverId") String driverId, @RequestParam(value = "chargingAmt") Integer chargingAmt, @RequestParam(value = "plateNum", required = false) String plateNum, @RequestParam(value = "status") Integer status, @RequestParam(value = "connectorId") String connectorId);
|
R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber,
|
||||||
|
@RequestParam(value = "driverId", required = false) String driverId,
|
||||||
|
@RequestParam(value = "chargingAmt", required = false, defaultValue = "500") Integer chargingAmt,
|
||||||
|
@RequestParam(value = "plateNum", required = false) String plateNum,
|
||||||
|
@RequestParam(value = "status") Integer status,
|
||||||
|
@RequestParam(value = "connectorId") String connectorId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class PileOrderFallbackFactory implements FallbackFactory<PileOrderServic
|
|||||||
@Override
|
@Override
|
||||||
public R pileStartUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId) {
|
public R pileStartUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId) {
|
||||||
|
|
||||||
return R.fail("通过第三方创建充电订单失败:" + cause.getMessage());
|
return R.fail("互联网订单启动失败:" + cause.getMessage());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,274 @@
|
|||||||
|
package com.xhpc.evcs.domain;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
@Table(name = "xhpc_internet_user")
|
||||||
|
@Entity
|
||||||
|
public class XhpcInternetUser extends BaseEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "internet_user_id", nullable = false)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "name", length = 30)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "phone", length = 11)
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Column(name = "contact_name", length = 30)
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
@Column(name = "contact_phone", length = 20)
|
||||||
|
private String contactPhone;
|
||||||
|
|
||||||
|
@Column(name = "open_bank", length = 20)
|
||||||
|
private String openBank;
|
||||||
|
|
||||||
|
@Column(name = "card_number", length = 100)
|
||||||
|
private String cardNumber;
|
||||||
|
|
||||||
|
@Column(name = "cooperation_start_time")
|
||||||
|
private Instant cooperationStartTime;
|
||||||
|
|
||||||
|
@Column(name = "cooperation_end_time")
|
||||||
|
private Instant cooperationEndTime;
|
||||||
|
|
||||||
|
@Column(name = "balance")
|
||||||
|
private Double balance;
|
||||||
|
|
||||||
|
@Column(name = "area_code")
|
||||||
|
private Integer areaCode;
|
||||||
|
|
||||||
|
@Column(name = "address", length = 50)
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Column(name = "detailed_address", length = 50)
|
||||||
|
private String detailedAddress;
|
||||||
|
|
||||||
|
@Column(name = "commission_type")
|
||||||
|
private Integer commissionType;
|
||||||
|
|
||||||
|
@Column(name = "commission_rate")
|
||||||
|
private Double commissionRate;
|
||||||
|
|
||||||
|
@Column(name = "longitude", length = 30)
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
@Column(name = "latitude", length = 30)
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
@Column(name = "status")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Column(name = "del_flag")
|
||||||
|
private Character delFlag;
|
||||||
|
|
||||||
|
@Column(name = "operator_id_evcs", length = 20)
|
||||||
|
private String operatorIdEvcs;
|
||||||
|
|
||||||
|
public String getOperatorIdEvcs() {
|
||||||
|
|
||||||
|
return operatorIdEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperatorIdEvcs(String operatorIdEvcs) {
|
||||||
|
|
||||||
|
this.operatorIdEvcs = operatorIdEvcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Character getDelFlag() {
|
||||||
|
|
||||||
|
return delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelFlag(Character delFlag) {
|
||||||
|
|
||||||
|
this.delFlag = delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLatitude() {
|
||||||
|
|
||||||
|
return latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLatitude(String latitude) {
|
||||||
|
|
||||||
|
this.latitude = latitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLongitude() {
|
||||||
|
|
||||||
|
return longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLongitude(String longitude) {
|
||||||
|
|
||||||
|
this.longitude = longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getCommissionRate() {
|
||||||
|
|
||||||
|
return commissionRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommissionRate(Double commissionRate) {
|
||||||
|
|
||||||
|
this.commissionRate = commissionRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCommissionType() {
|
||||||
|
|
||||||
|
return commissionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommissionType(Integer commissionType) {
|
||||||
|
|
||||||
|
this.commissionType = commissionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDetailedAddress() {
|
||||||
|
|
||||||
|
return detailedAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDetailedAddress(String detailedAddress) {
|
||||||
|
|
||||||
|
this.detailedAddress = detailedAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAreaCode() {
|
||||||
|
|
||||||
|
return areaCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAreaCode(Integer areaCode) {
|
||||||
|
|
||||||
|
this.areaCode = areaCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getBalance() {
|
||||||
|
|
||||||
|
return balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBalance(Double balance) {
|
||||||
|
|
||||||
|
this.balance = balance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCooperationEndTime() {
|
||||||
|
|
||||||
|
return cooperationEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCooperationEndTime(Instant cooperationEndTime) {
|
||||||
|
|
||||||
|
this.cooperationEndTime = cooperationEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCooperationStartTime() {
|
||||||
|
|
||||||
|
return cooperationStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCooperationStartTime(Instant cooperationStartTime) {
|
||||||
|
|
||||||
|
this.cooperationStartTime = cooperationStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCardNumber() {
|
||||||
|
|
||||||
|
return cardNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCardNumber(String cardNumber) {
|
||||||
|
|
||||||
|
this.cardNumber = cardNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOpenBank() {
|
||||||
|
|
||||||
|
return openBank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenBank(String openBank) {
|
||||||
|
|
||||||
|
this.openBank = openBank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactPhone() {
|
||||||
|
|
||||||
|
return contactPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContactPhone(String contactPhone) {
|
||||||
|
|
||||||
|
this.contactPhone = contactPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactName() {
|
||||||
|
|
||||||
|
return contactName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContactName(String contactName) {
|
||||||
|
|
||||||
|
this.contactName = contactName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone() {
|
||||||
|
|
||||||
|
return phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone(String phone) {
|
||||||
|
|
||||||
|
this.phone = phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -437,9 +437,15 @@ public class XhpcPileOrderController extends BaseController {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
|
@GetMapping(value = "/chargeOrder/pileStartUpBy3rd")
|
||||||
public R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber, @RequestParam(value = "driverId") String driverId, @RequestParam(value = "chargingAmt") Integer chargingAmt, @RequestParam(value = "plateNum", required = false) String plateNum, @RequestParam(value = "status") Integer status, @RequestParam(value = "connectorId") String connectorId) {
|
public R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String internetSerialNumber,
|
||||||
return xhpcChargeOrderService.startUpBy3rd(internetSerialNumber, driverId, chargingAmt, plateNum, status, connectorId);
|
@RequestParam(value = "driverId", required = false) String driverId,
|
||||||
}
|
@RequestParam(value = "chargingAmt", required = false, defaultValue = "500") Integer chargingAmt,
|
||||||
|
@RequestParam(value = "plateNum", required = false) String plateNum,
|
||||||
|
@RequestParam(value = "status") Integer status,
|
||||||
|
@RequestParam(value = "connectorId") String connectorId) {
|
||||||
|
|
||||||
|
return xhpcChargeOrderService.startUpBy3rd(internetSerialNumber, driverId, chargingAmt, plateNum, status, connectorId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,10 +20,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.hutool.core.util.NumberUtil.isInteger;
|
import static cn.hutool.core.util.NumberUtil.isInteger;
|
||||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||||
@ -105,8 +102,8 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
cacheTerminalStatusMap.put(terminalId, statusOrSOC);
|
cacheTerminalStatusMap.put(terminalId, statusOrSOC);
|
||||||
REDIS.setCacheMap(stationTermStatusKey, cacheTerminalStatusMap);
|
REDIS.setCacheMap(stationTermStatusKey, cacheTerminalStatusMap);
|
||||||
Map<String, Object> cacheOrder = REDIS.getCacheMap(orderkey);
|
Map<String, Object> cacheOrder = REDIS.getCacheMap(orderkey);
|
||||||
List<CacheRealtimeData> realtimeDataList = (List<CacheRealtimeData>) cacheOrder.get("realtimeDataList");
|
|
||||||
if (!orderNo.equals("00000000000000000000000000000000") && statusInt == 3) {
|
if (!orderNo.equals("00000000000000000000000000000000") && statusInt == 3) {
|
||||||
|
List<CacheRealtimeData> realtimeDataList = (List<CacheRealtimeData>) cacheOrder.get("realtimeDataList");
|
||||||
cacheGun.put("idleCnt", 0);
|
cacheGun.put("idleCnt", 0);
|
||||||
if (realtimeDataList == null) {
|
if (realtimeDataList == null) {
|
||||||
realtimeDataList = new ArrayList<>();
|
realtimeDataList = new ArrayList<>();
|
||||||
@ -177,14 +174,22 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
Integer idleCnt = (Integer) cacheGun.get("idleCnt");
|
Integer idleCnt = (Integer) cacheGun.get("idleCnt");
|
||||||
idleCnt = idleCnt == null ? 0 : idleCnt;
|
idleCnt = idleCnt == null ? 0 : idleCnt;
|
||||||
idleCnt++;
|
idleCnt++;
|
||||||
if (idleCnt > 3 && orderkey != null) {
|
if (idleCnt > 3) {
|
||||||
Map<String, Object> problematicOrder = REDIS.getCacheMap(orderkey);
|
if (orderkey != null) {
|
||||||
Object orderData = problematicOrder.get("orderData");
|
Map<String, Object> problematicOrder = REDIS.getCacheMap(orderkey);
|
||||||
String status = (String) problematicOrder.get("status");
|
Object orderData = problematicOrder.get("orderData");
|
||||||
if (!isInteger(status) && !status.equals("充电中") && orderData == null) {
|
String status = (String) problematicOrder.get("status");
|
||||||
pileOrderService.abnormalOrder(orderNo);
|
if (!isInteger(status) && !status.equals("充电中") && orderData == null) {
|
||||||
cacheGun.put("orderkey", null);
|
pileOrderService.abnormalOrder(orderNo);
|
||||||
idleCnt = 0;
|
log.error("abnormal order[{}]", orderNo);
|
||||||
|
cacheGun.put("orderkey", null);
|
||||||
|
idleCnt = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Collection<String> cacheOrderKyes = REDIS.keys("order:".concat(terminalId).concat("*"));
|
||||||
|
for (String cacheOrderKye : cacheOrderKyes) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cacheGun.put("idleCnt", idleCnt);
|
cacheGun.put("idleCnt", idleCnt);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user