更新vin码起动
This commit is contained in:
parent
25e17f7d67
commit
c74eb70879
@ -2,6 +2,7 @@ package com.xhpc.pp.logic;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.xhpc.common.api.CardService;
|
import com.xhpc.common.api.CardService;
|
||||||
|
import com.xhpc.common.api.PileOrderService;
|
||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.common.data.up.PileStartChargingData;
|
import com.xhpc.common.data.up.PileStartChargingData;
|
||||||
import com.xhpc.common.domain.IccardInfo;
|
import com.xhpc.common.domain.IccardInfo;
|
||||||
@ -46,6 +47,9 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
|||||||
@Resource
|
@Resource
|
||||||
private CardService cardService;
|
private CardService cardService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
PileOrderService pileOrderService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServiceResult service(ServiceParameter sp) throws Exception {
|
public ServiceResult service(ServiceParameter sp) throws Exception {
|
||||||
|
|
||||||
@ -101,6 +105,7 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
|||||||
cacheOrder.put("rateModelId", rateModelId);
|
cacheOrder.put("rateModelId", rateModelId);
|
||||||
cacheOrder.put("pileNo", pileNo);
|
cacheOrder.put("pileNo", pileNo);
|
||||||
cacheOrder.put("initBalance", dBalance.intValue() * 100);
|
cacheOrder.put("initBalance", dBalance.intValue() * 100);
|
||||||
|
cacheOrder.put("startType", pileStartChargingData.getStartType());
|
||||||
cacheOrder.put("logicCardNo", cardNo);
|
cacheOrder.put("logicCardNo", cardNo);
|
||||||
cacheOrder.put("physicCardNo", accountOrCardNo);
|
cacheOrder.put("physicCardNo", accountOrCardNo);
|
||||||
cacheOrder.put("gunId", connectorId);
|
cacheOrder.put("gunId", connectorId);
|
||||||
@ -124,6 +129,56 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
|||||||
} else {
|
} else {
|
||||||
resultStr = "01";
|
resultStr = "01";
|
||||||
}
|
}
|
||||||
|
} else if (pileStartChargingData.getStartType().equals("03")){ // VIN码充电
|
||||||
|
if (pileStartChargingData.getVin().equals("0000000000000000000000000000000000")){
|
||||||
|
return new ServiceResult(ServiceResult.FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
String vinCode = asciiToString(pileStartChargingData.getVin());
|
||||||
|
|
||||||
|
R r = pileOrderService.pileVin(connectorId, vinCode);
|
||||||
|
if (r.getCode() == 200) {
|
||||||
|
if(r.getData() == null){
|
||||||
|
return new ServiceResult(ServiceResult.FAIL);
|
||||||
|
}
|
||||||
|
Integer rateModelId = pileStartChargingData.getRateModelId(); // todo not very strict.
|
||||||
|
if (rateModelId == null)
|
||||||
|
rateModelId = ((Long) REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)),
|
||||||
|
"rateModelId")).intValue();
|
||||||
|
|
||||||
|
result = ServiceResult.HEX_01;
|
||||||
|
Map data = (Map) r.getData();
|
||||||
|
orderNo = (String) data.get("serialNumber");
|
||||||
|
Double dBalance = (Double) data.get("balance");
|
||||||
|
dBalance = dBalance * 100;
|
||||||
|
balance = HexUtils.toHexInt(dBalance.longValue());
|
||||||
|
Map<String, Object> cacheOrder = new HashMap<>();
|
||||||
|
String pileNo = connectorId.substring(0, 14);
|
||||||
|
String pkey = "pile:".concat(pileNo);
|
||||||
|
Long pileRateModelId = REDIS.getCacheMapValue(pkey, "rateModelId");
|
||||||
|
cacheOrder.put("pileRateModelId", pileRateModelId);
|
||||||
|
cacheOrder.put("rateModelId", rateModelId);
|
||||||
|
cacheOrder.put("pileNo", pileNo);
|
||||||
|
cacheOrder.put("startType", pileStartChargingData.getStartType());
|
||||||
|
cacheOrder.put("initBalance", dBalance.intValue() * 100);
|
||||||
|
cacheOrder.put("logicCardNo", cardNo);
|
||||||
|
cacheOrder.put("physicCardNo", accountOrCardNo);
|
||||||
|
cacheOrder.put("gunId", connectorId);
|
||||||
|
cacheOrder.put("startTime",
|
||||||
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()).format(Instant.now()));
|
||||||
|
String orderkey = "order:".concat(orderNo);
|
||||||
|
REDIS.setCacheMap(orderkey, cacheOrder);
|
||||||
|
REDIS.setCacheMapValue("gun:".concat(connectorId), "ac.on", false);
|
||||||
|
resultStr = "00";
|
||||||
|
} else {
|
||||||
|
String internalError = r.getMsg();
|
||||||
|
if (internalError.startsWith("0") || internalError.startsWith("1")) {
|
||||||
|
resultStr = internalError;
|
||||||
|
} else {
|
||||||
|
resultStr = "1C";
|
||||||
|
log.error("pile start charging internalError: {}", internalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String skey = "gun:".concat(connectorId).concat(".seqhex");
|
String skey = "gun:".concat(connectorId).concat(".seqhex");
|
||||||
String hex =
|
String hex =
|
||||||
@ -140,4 +195,21 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
|||||||
return new ServiceResult(HexUtils.toBytes(hex), result);
|
return new ServiceResult(HexUtils.toBytes(hex), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String asciiToString(String text) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (int i = 0; i < text.length(); i++) {
|
||||||
|
if (text.charAt(i) == '1' && i < text.length() - 2) {
|
||||||
|
int code = Integer.parseInt(text.substring(i, i + 3), 16);
|
||||||
|
builder.append((char) code);
|
||||||
|
i += 2;
|
||||||
|
} else if (i < text.length() - 1) {
|
||||||
|
int code = Integer.parseInt(text.substring(i, i + 2), 16);
|
||||||
|
builder.append((char) code);
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user