更新VIN码启动充电
This commit is contained in:
parent
4f6dccda05
commit
c58dceea4b
@ -3,6 +3,7 @@ package com.xhpc.pp.logic;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xhpc.common.api.CardService;
|
||||
import com.xhpc.common.api.PileOrderService;
|
||||
import com.xhpc.common.core.constant.Constants;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.data.up.PileStartChargingData;
|
||||
import com.xhpc.common.domain.IccardInfo;
|
||||
@ -90,7 +91,8 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
rateModelId = ((Long) REDIS.getCacheMapValue("pile:".concat(connectorId.substring(0, 14)),
|
||||
"rateModelId")).intValue();
|
||||
R r = cardService.cardStartup(cardNo, connectorId, rateModelId.toString());
|
||||
if (r.getCode() == 200) {
|
||||
int code = r.getCode();
|
||||
if (code == 200) {
|
||||
result = ServiceResult.HEX_01;
|
||||
Map data = (Map) r.getData();
|
||||
orderNo = (String) data.get("serialNumber");
|
||||
@ -116,12 +118,15 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
REDIS.setCacheMapValue("gun:".concat(connectorId), "ac.on", false);
|
||||
resultStr = "00";
|
||||
} else {
|
||||
String internalError = r.getMsg();
|
||||
if (internalError.startsWith("0") || internalError.startsWith("1")) {
|
||||
resultStr = internalError;
|
||||
resultStr = "1C";
|
||||
if(code < 600){
|
||||
String errorMsg = r.getMsg();
|
||||
if ( errorMsg != null && (errorMsg.startsWith("0") || errorMsg.startsWith("1")) ) {
|
||||
resultStr = errorMsg;
|
||||
}
|
||||
log.error("pile start charging internalError: {}", resultStr);
|
||||
} else {
|
||||
resultStr = "1C";
|
||||
log.error("pile start charging internalError: {}", internalError);
|
||||
resultStr = getFailReasonByCode(code);
|
||||
}
|
||||
}
|
||||
cardNo = StringUtils.leftPad(iccardInfo.getCardno(), 16, "0");
|
||||
@ -137,7 +142,8 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
String vinCode = asciiToString(pileStartChargingData.getVin());
|
||||
|
||||
R r = pileOrderService.pileVin(connectorId, vinCode);
|
||||
if (r.getCode() == 200) {
|
||||
int code = r.getCode();
|
||||
if (code == 200) {
|
||||
if(r.getData() == null){
|
||||
return new ServiceResult(ServiceResult.FAIL);
|
||||
}
|
||||
@ -171,12 +177,15 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
REDIS.setCacheMapValue("gun:".concat(connectorId), "ac.on", false);
|
||||
resultStr = "00";
|
||||
} else {
|
||||
String internalError = r.getMsg();
|
||||
if (internalError.startsWith("0") || internalError.startsWith("1")) {
|
||||
resultStr = internalError;
|
||||
resultStr = Constants.INTERNAL_ERROR;
|
||||
if(code < 600){
|
||||
String errorMsg = r.getMsg();
|
||||
if ( errorMsg != null && (errorMsg.startsWith("0") || errorMsg.startsWith("1")) ) {
|
||||
resultStr = errorMsg;
|
||||
}
|
||||
log.error("pile start charging internalError: {}", errorMsg);
|
||||
} else {
|
||||
resultStr = "1C";
|
||||
log.error("pile start charging internalError: {}", internalError);
|
||||
resultStr = getFailReasonByCode(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,6 +193,19 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
String hex =
|
||||
"682A".concat(seqHex(skey)).concat("0032").concat(orderNo).concat(connectorId).concat(cardNo).concat(balance).concat(result).concat(resultStr);
|
||||
hex = hex.concat(CRCCalculator.calcCrc(hex));
|
||||
|
||||
Integer startFlag = result.equals(ServiceResult.HEX_01) ? 2: 4;
|
||||
|
||||
String pushOrderKey = "pushOrder:".concat(orderNo);
|
||||
Map<String, Object> pushOrder = REDIS.getCacheMap(pushOrderKey);
|
||||
if (pushOrder != null) {
|
||||
REDIS.setCacheMapValue(pushOrderKey, "startChargeSeqStat", startFlag);
|
||||
} else {
|
||||
Map map = new HashMap<>();
|
||||
map.put("startChargeSeqStat", startFlag);
|
||||
REDIS.setCacheMap(pushOrderKey, map);
|
||||
}
|
||||
|
||||
String remark = "充电桩发起充电";
|
||||
XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
|
||||
deviceMessage.setType(StationDeviceEnum.PILE.getCode());
|
||||
@ -195,6 +217,31 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
return new ServiceResult(HexUtils.toBytes(hex), result);
|
||||
}
|
||||
|
||||
private static String getFailReasonByCode(int code){
|
||||
String failReason = "";
|
||||
switch (code){
|
||||
case 1888: failReason = Constants.EMPTY_VIN; break;
|
||||
case 1880: failReason = Constants.INVALID_VIN;break;
|
||||
case 1881: failReason = Constants.UNEXIST_VIN;break;
|
||||
case 1104: failReason = Constants.UNUSE_TERMINAL;break;
|
||||
case 1103: failReason = Constants.EXCEPTION_ORDER;break;
|
||||
case 1100: failReason = Constants.INSUFFICIENT_ACCOUNT; break;
|
||||
case 1101: failReason = Constants.REFUND_ORDER; break;
|
||||
case 1102: failReason = Constants.CHARGE_ORDER; break;
|
||||
case 1105: failReason = Constants.UNREGISTERED_TERMINAL; break;
|
||||
case 1106:
|
||||
case 1008: failReason = Constants.UNKNOWN_GUN; break;
|
||||
case 1107: failReason = Constants.OFFLINE_TERMINAL; break;
|
||||
case 1109: failReason = Constants.INSERT_THE_GUN; break;
|
||||
case 1111: failReason = Constants.FAULT_TERMINAL; break;
|
||||
case 1112: failReason = Constants.CHARGE_TERMINAL; break;
|
||||
|
||||
default: failReason = Constants.INTERNAL_ERROR; break;
|
||||
}
|
||||
|
||||
return failReason;
|
||||
}
|
||||
|
||||
|
||||
public static String asciiToString(String text) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user