修正卡启动余额应答
This commit is contained in:
parent
fafee173a6
commit
5e92204b66
@ -214,7 +214,7 @@ public class HexUtils {
|
||||
// byte[] data1 = toBytes(reverseHex("10270000"));
|
||||
// System.out.println(toInteger(data1, 0, 4));
|
||||
// System.out.println(reverseHexInt("D80E"));
|
||||
System.out.println(toHexInt(15));
|
||||
System.out.println(toHexInt(82));
|
||||
// System.out.println(toHexInt(3800));
|
||||
// System.out.println(toHexInt(100000));
|
||||
// System.out.println(toBits("1000"));
|
||||
|
||||
@ -110,7 +110,8 @@ public class ChargingController {
|
||||
Long stationRateModelId = cacheStation.getRateModelId();
|
||||
Long pileRateModelId = (Long) cachePile.get("rateModelId");
|
||||
if (!stationRateModelId.equals(pileRateModelId)) {
|
||||
String resultStr = RateModelRequestLogic.translate(pileNo, stationRateModelId, "0058");
|
||||
String resultStr = RateModelRequestLogic.translate(pileNo, stationRateModelId, "0058",
|
||||
(String) cachePile.get("version"));
|
||||
String response = HttpUtils.post(fmt(svcSrv).concat("/native/pile/".concat(pileNo).concat("/rateModel")),
|
||||
resultStr);
|
||||
JSONObject responseJson = (JSONObject) JSON.parse(response);
|
||||
|
||||
@ -52,7 +52,7 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
//todo 桩停用
|
||||
String accountOrCardNo = pileStartChargingData.getAccountOrCardNo();
|
||||
String corpNo = connectorId.substring(0, 6);
|
||||
String balance = "0000";
|
||||
String balance = "00000000";
|
||||
String cardNo = "0000000000000000";
|
||||
String orderNo = "00000000000000000000000000000000";
|
||||
if (pileStartChargingData.getStartType().equals("01")) { //刷卡启动
|
||||
@ -71,7 +71,10 @@ public class PileStartChargingDataLogic implements ServiceLogic {
|
||||
HexUtils.reverseHexInt(pileStartChargingData.getRateModelId().toString()).toString()); //todo 费率处理
|
||||
if (r.getCode() == 200) {
|
||||
result = ServiceResult.HEX_01;
|
||||
orderNo = (String) ((Map) r.getData()).get("serialNumber");
|
||||
Map data = (Map) r.getData();
|
||||
orderNo = (String) data.get("serialNumber");
|
||||
String balanceStr = (String) data.get("balance");
|
||||
balance = HexUtils.toHexInt(Integer.parseInt(balanceStr) * 100);
|
||||
}
|
||||
cardNo = StringUtils.leftPad(iccardInfo.getCardno(), 16, "0");
|
||||
resultStr = r.getMsg();
|
||||
|
||||
@ -48,8 +48,7 @@ public class RateModelRequestLogic implements ServiceLogic {
|
||||
json.put("error", "场站没有设置费率");
|
||||
return new ServiceResult(null, ServiceResult.FAIL, json);
|
||||
}
|
||||
String resultStr = translate(pileNo, stationRateModelId, "000A");
|
||||
|
||||
String resultStr = translate(pileNo, stationRateModelId, "000A", (String) cachePile.get("version"));
|
||||
XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
|
||||
deviceMessage.setType(StationDeviceEnum.PILE.getCode());
|
||||
deviceMessage.setSerialNumber(pileNo);
|
||||
@ -61,14 +60,18 @@ public class RateModelRequestLogic implements ServiceLogic {
|
||||
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
|
||||
}
|
||||
|
||||
public static String translate(String pileNo, Long stationRateModelId, String svc) {
|
||||
public static String translate(String pileNo, Long stationRateModelId, String svc, String version) {
|
||||
|
||||
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(stationRateModelId.toString()));
|
||||
String rateModel = translate(cacheRateModel);
|
||||
String skey = "pile:".concat(pileNo).concat(".seqhex");
|
||||
String resultStr = "685E".concat(seqHex(skey)).concat(svc).concat(pileNo)
|
||||
.concat(String.format("%04X", stationRateModelId))
|
||||
.concat(rateModel);
|
||||
String resultStr;
|
||||
if ("0A".equals(version))
|
||||
resultStr = "685E".concat(seqHex(skey)).concat(svc).concat(pileNo).concat(String.format("%04X",
|
||||
stationRateModelId)).concat(rateModel);
|
||||
else
|
||||
resultStr =
|
||||
"6860".concat(seqHex(skey)).concat(svc).concat(pileNo).concat(HexUtils.toHexInt(stationRateModelId)).concat(rateModel);
|
||||
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
|
||||
return resultStr;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public class RateModelValidateLogic implements ServiceLogic {
|
||||
|
||||
Map<String, Object> req = sp.getParameters();
|
||||
String pileNo = (String) req.get("pileNo");
|
||||
String rateModelIdStr = (String) req.get("rateModelId");
|
||||
String rateModelIdStr = req.get("rateModelId").toString();
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(pileNo));
|
||||
Integer gunNum = (Integer) cachePile.get("gunNum");
|
||||
boolean charging = false;
|
||||
@ -50,7 +50,10 @@ public class RateModelValidateLogic implements ServiceLogic {
|
||||
}
|
||||
String resultCode = ServiceResult.OK;
|
||||
String hexCode = ServiceResult.HEX_00;
|
||||
Long rateModelId = Long.valueOf(Integer.parseInt(rateModelIdStr, 16));
|
||||
Long rateModelId;
|
||||
String version = (String) cachePile.get("version");
|
||||
if ("0A".equals(version)) rateModelId = Long.valueOf(Integer.parseInt(rateModelIdStr, 16));
|
||||
else rateModelId = Long.valueOf(rateModelIdStr);
|
||||
Long csRateModelId = rateModelId;
|
||||
if (!charging) {
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString()));
|
||||
|
||||
@ -30,6 +30,7 @@ public class RateModelTask {
|
||||
if (rateModelIdStation != null) {
|
||||
Set<String> pks = stationDto.getPiles();
|
||||
if (pks != null) for (String pk : pks) {
|
||||
pk = "pile:".concat(pk);
|
||||
Long rateModelIdPile = REDIS.getCacheMapValue(pk, "rateModelId");
|
||||
if (!rateModelIdStation.equals(rateModelIdPile)) {
|
||||
String gkPattern = ("gun:").concat(pk).concat("*");
|
||||
@ -44,7 +45,8 @@ public class RateModelTask {
|
||||
if (!charging) {
|
||||
ClientHandler handler = getHandler(pk);
|
||||
if (handler != null && handler.isOpen()) {
|
||||
String rsmsg = RateModelRequestLogic.translate(pk, rateModelIdStation, "0058");
|
||||
String rsmsg = RateModelRequestLogic.translate(pk, rateModelIdStation, "0058",
|
||||
REDIS.getCacheMapValue(pk, "version"));
|
||||
try {
|
||||
handler.sendClientBinary(HexUtils.toBytes(rsmsg));
|
||||
log.info("pile[{}] rate model[{}] sent ⚪", pk, rateModelIdStation);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user