diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java index c1b906a3..9ef9de60 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java @@ -11,7 +11,6 @@ import com.xhpc.common.data.down.StartChargingData; import com.xhpc.common.data.redis.CacheRateModel; import com.xhpc.pp.logic.RateModelRequestLogic; import com.xhpc.pp.server.ChargingPileServer; -import com.xhpc.pp.tx.ServiceResult; import com.xhpc.pp.utils.security.CRCCalculator; import com.xhpc.pp.utils.security.HexUtils; import org.apache.commons.lang3.ArrayUtils; @@ -105,10 +104,9 @@ public class ChargingController { String gunkey = "gun:".concat(pileNo).concat(startChargingData.getGunId()); String skey = gunkey.concat(".seqhex"); String seq = seqHex(skey); - String rateModelMsg = "680E".concat(seq).concat("000A").concat(pileNo) + String rateModelMsg = "680E".concat(seq).concat("0058").concat(pileNo) .concat(String.format("%04X", stationRateModelId)) - .concat(rateModel) - .concat(ServiceResult.HEX_OK); + .concat(rateModel); rateModelMsg = rateModelMsg.concat(CRCCalculator.calcCrc(rateModel)); String response = HttpUtils.post(fmt(svcSrv).concat("/native/pile/".concat(pileNo).concat("/rateModel")), rateModelMsg); JSONObject responseJson = (JSONObject) JSON.parse(response); @@ -286,7 +284,7 @@ public class ChargingController { } else { // not defined or implemented yet } - String msg = HexUtils.toHex(data).concat(ServiceResult.HEX_OK); + String msg = HexUtils.toHex(data); msg = msg.concat(CRCCalculator.calcCrc(msg)); log.info("start charging order[{}], send msg >>>> |{}|", startChargingData.getOrderNo(), msg); return HexUtils.toBytes(msg); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java index 2008303d..973d2dcd 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java @@ -68,7 +68,7 @@ public class PileController { if (handler != null) { try { handler.sendClientBinary(HexUtils.toBytes(msg)); - r = R.fail("费率模型已下发"); + r = R.ok("费率模型已下发"); } catch (IOException e) { r = R.fail("费率模型下发失败:".concat(e.getMessage())); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/HBLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/HBLogic.java index 2c883a82..fe1078f7 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/HBLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/HBLogic.java @@ -37,7 +37,7 @@ public class HBLogic implements ServiceLogic { REDIS.setCacheMap(gunkey, cacheGun); String skey = gunkey.concat(".seqhex"); String seq = seqHex(skey); - String resultStr = "680D".concat(seq).concat("0004").concat(pileNo).concat(gunId).concat(ServiceResult.HEX_OK); + String resultStr = "680D".concat(seq).concat("0004").concat(pileNo).concat(gunId).concat(ServiceResult.HEX_00); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java index 6643eba0..713bb75c 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/OrderDataLogic.java @@ -50,7 +50,7 @@ public class OrderDataLogic implements ServiceLogic { REDIS.setCacheMap(gunkey, cacheGun); String skey = gunkey.concat(".seqhex"); String seq = seqHex(skey); - String resultStr = "6815".concat(seq).concat("0040").concat(orderNo).concat(ServiceResult.HEX_OK); + String resultStr = "6815".concat(seq).concat("0040").concat(orderNo).concat(ServiceResult.HEX_00); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK, orderNo); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java index 6a993048..bbc8b0c1 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelConfigReplyDataLogic.java @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; import java.util.Map; import static com.xhpc.pp.server.ChargingPileServer.REDIS; -import static com.xhpc.pp.tx.ServiceResult.HEX_OK; +import static com.xhpc.pp.tx.ServiceResult.*; @Lazy @Component("RateModelConfigReplyDataLogic") @@ -29,13 +29,14 @@ public class RateModelConfigReplyDataLogic implements ServiceLogic { ObjectMapper objectMapper = new ObjectMapper(); PileConfigReplyData pileRateModelConfigReplyData = objectMapper.convertValue(req, PileConfigReplyData.class); String configResult = pileRateModelConfigReplyData.getConfigResult(); - if (configResult.equals(HEX_OK)) { + if (HEX_01.equals(configResult)) { // 确定设置成功的rateModelId 可能涉及协议修改 Map cachePile = REDIS.getCacheMap("pile:".concat(pileRateModelConfigReplyData.getPileNo())); ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString())); cachePile.put("rateModelId", cacheStation.getRateModelId()); + return new ServiceResult(OK); } - return new ServiceResult(configResult); + return new ServiceResult(FAIL); } } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java index 62fd8827..99e1cb2d 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelRequestLogic.java @@ -47,8 +47,7 @@ public class RateModelRequestLogic implements ServiceLogic { String seq = seqHex(skey); String resultStr = "680E".concat(seq).concat("000A").concat(pileNo) .concat(String.format("%04X", rateModelId)) - .concat(rateModel) - .concat(ServiceResult.HEX_OK); + .concat(rateModel); resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr)); return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java index 3e19aea8..da3e3d6a 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RateModelValidateLogic.java @@ -30,12 +30,12 @@ public class RateModelValidateLogic implements ServiceLogic { String rateModelIdStr = (String) req.get("rateModelId"); Map cachePile = REDIS.getCacheMap("pile:".concat(pileNo)); String resultCode = ServiceResult.OK; - String hexCode = ServiceResult.HEX_OK; + String hexCode = ServiceResult.HEX_00; ChargingStationDto cacheStation = REDIS.getCacheObject("station:".concat(cachePile.get("stationId").toString())); Long csRateModelId = cacheStation.getRateModelId(); int rateModelId = Integer.parseInt(rateModelIdStr, 16); if (csRateModelId.intValue() != rateModelId) { - hexCode = ServiceResult.HEX_FAIL; + hexCode = ServiceResult.HEX_01; resultCode = ServiceResult.FAIL; } String skey = "pile:".concat(pileNo).concat(".seqhex"); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java index a160d20c..856f3e1b 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RegisterLogic.java @@ -31,16 +31,16 @@ public class RegisterLogic implements ServiceLogic { Map req = sp.getParameters(); String resultCode = ServiceResult.OK; - String hexCode = ServiceResult.HEX_OK; + String hexCode = ServiceResult.HEX_00; String pileNo = (String) req.get("pileNo"); Set whitelist = REDIS.getCacheSet("PILE_WHITELIST"); if (!whitelist.contains(pileNo)) { log.info("pile not in whitelist ({}) ", pileNo); - hexCode = ServiceResult.HEX_FAIL; + hexCode = ServiceResult.HEX_01; resultCode = ServiceResult.FAIL; } else if (!EarlierBeanConf.ifreg(pileNo)) { log.info("pile already registered ({}) ", pileNo); - hexCode = ServiceResult.HEX_FAIL; + hexCode = ServiceResult.HEX_01; resultCode = ServiceResult.FAIL; } else { String pkey = "pile:".concat(pileNo); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java index 5e44567d..373080da 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStartReplyDataLogic.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; import java.util.Map; import static com.xhpc.pp.server.ChargingPileServer.REDIS; -import static com.xhpc.pp.tx.ServiceResult.HEX_OK; +import static com.xhpc.pp.tx.ServiceResult.HEX_01; @Lazy @Component("RemoteStartReplyDataLogic") @@ -42,7 +42,7 @@ public class RemoteStartReplyDataLogic implements ServiceLogic { Map cacheGun = REDIS.getCacheMap(gunkey); REDIS.setCacheMap(gunkey, cacheGun); REDIS.setCacheMap(orderkey, cacheOrder); - if (HEX_OK.equals(remoteStartReplyData.getStartResult())) { + if (HEX_01.equals(remoteStartReplyData.getStartResult())) { pileOrderService.pileStartup(orderNo, 1, "启动充电成功"); } else { cacheGun.put("orderkey", null); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java index 7622b4b9..68c10c8e 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RemoteStopReplyDataLogic.java @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component; import java.util.Map; import static com.xhpc.pp.server.ChargingPileServer.REDIS; -import static com.xhpc.pp.tx.ServiceResult.HEX_OK; +import static com.xhpc.pp.tx.ServiceResult.HEX_01; @Lazy @Component("RemoteStopReplyDataLogic") @@ -41,7 +41,7 @@ public class RemoteStopReplyDataLogic implements ServiceLogic { cacheOrder.put("stopResult", stopResult); REDIS.setCacheMap(orderkey, cacheOrder); String orderNo = orderkey.replace("order:", ""); - if (HEX_OK.equals(remoteStopReplyData.getStopResult())) { + if (HEX_01.equals(remoteStopReplyData.getStopResult())) { pileOrderService.pileStop(orderNo, 1, "停止充电成功"); } else { pileOrderService.pileStartup(orderNo, 2, frs[Integer.parseInt(remoteStopReplyData.getFailReason())]); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/tx/ServiceResult.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/tx/ServiceResult.java index 6765e99e..509df922 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/tx/ServiceResult.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/tx/ServiceResult.java @@ -7,8 +7,8 @@ public class ServiceResult { public static final String OK = "0"; public static final String FAIL = "1"; - public static final String HEX_OK = "00"; - public static final String HEX_FAIL = "01"; + public static final String HEX_00 = "00"; + public static final String HEX_01 = "01"; private String code; private byte[] binary;