diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/pp/utils/HexUtils.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/pp/utils/HexUtils.java index 386bff79..6391baac 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/pp/utils/HexUtils.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/pp/utils/HexUtils.java @@ -213,7 +213,9 @@ public class HexUtils { // System.out.println(reverseHexInt("FF00")); // byte[] data1 = toBytes(reverseHex("10270000")); // System.out.println(toInteger(data1, 0, 4)); -// System.out.println(reverseHexInt("D80E")); + System.out.println(reverseHexInt("6C3E0000")); + System.out.println(reverseHexInt("80FA4800")); + System.out.println(reverseHexInt("5D000000")); System.out.println(toHexInt(82)); // System.out.println(toHexInt(3800)); // System.out.println(toHexInt(100000)); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index b755605e..72fff6a4 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -734,7 +734,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar xhpcChargeOrder.setStatus(-1); xhpcChargeOrder.setTenantId(tenantId); //获取桩信息 - xhpcChargeOrder.setPower((String) xhpcChargingPileById.get("power")); + Object power = xhpcChargingPileById.get("power"); + xhpcChargeOrder.setPower(power == null ? "120.0" : power.toString()); xhpcChargeOrder.setRateModelId(Long.valueOf(rateModelId)); xhpcChargeOrder.setChargingMode("刷卡"); diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java index 87e4cd50..e2722473 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/PileStartChargingDataLogic.java @@ -22,9 +22,14 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; import java.util.List; import java.util.Map; +import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex; @Lazy @@ -67,17 +72,36 @@ public class PileStartChargingDataLogic implements ServiceLogic { } else { // 调用订单接口 cardNo = iccardInfo.getCardno(); - R r = cardService.cardStartup(cardNo, connectorId, - HexUtils.reverseHexInt(pileStartChargingData.getRateModelId().toString()).toString()); //todo 费率处理 + Integer rateModelId = HexUtils.reverseHexInt(pileStartChargingData.getRateModelId().toString()); + R r = cardService.cardStartup(cardNo, connectorId, rateModelId.toString()); if (r.getCode() == 200) { result = ServiceResult.HEX_01; Map data = (Map) r.getData(); orderNo = (String) data.get("serialNumber"); - String balanceStr = (String) data.get("balance"); - balance = HexUtils.toHexInt(Integer.parseInt(balanceStr) * 100); + Double dBalance = (Double) data.get("balance"); + dBalance = Double.valueOf(dBalance * 100); + balance = HexUtils.toHexInt(dBalance.longValue()); + Map 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("initBalance", dBalance.intValue()); + 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 { + resultStr = r.getMsg(); } cardNo = StringUtils.leftPad(iccardInfo.getCardno(), 16, "0"); - resultStr = r.getMsg(); } } else { resultStr = "01"; diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java index acc1bf92..b2390a05 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/logic/RealtimeDataLogic.java @@ -32,7 +32,6 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS; import static com.xhpc.pp.server.ChargingPileServer.default_version; import static com.xhpc.pp.utils.HexUtils.reverseHexInt; import static com.xhpc.pp.utils.HexUtils.toBits; -import static com.xhpc.pp.utils.security.CP56Time2a.cp56toDateStr; import static com.xhpc.pp.utils.security.CacheDataUtils.reflectTranslate; @Lazy @@ -112,6 +111,13 @@ public class RealtimeDataLogic implements ServiceLogic { Map cacheOrder = REDIS.getCacheMap(orderkey); if (!orderNo.equals("00000000000000000000000000000000")) { if (statusInt == 3) { + Boolean o = (Boolean) cachePile.get("ac.on"); + if (o != null && !o) { + R r = pileOrderService.pileStartup(orderNo, 1, "启动充电成功"); + if (r.getCode() == 200) { + cachePile.put("ac.on", true); + } + } List realtimeDataList = (List) cacheOrder.get("realtimeDataList"); cacheGun.put("idleCnt", 0); if (realtimeDataList == null) { @@ -260,15 +266,11 @@ public class RealtimeDataLogic implements ServiceLogic { int sumPeriod = Integer.parseInt(hex.substring(0, 2), 16); List cds = new ArrayList<>(); - for (int i = 2; i < sumPeriod * 68 + 2; i = i + 68) { + for (int i = 10; i < sumPeriod * 16 + 10; i = i + 16) { ChargeDetails cd = new ChargeDetails(); - cd.setDetailStartTime(cp56toDateStr(hex.substring(i, i + 14))); - cd.setDetailEndTime(cp56toDateStr(hex.substring(i + 14, i + 28))); - cd.setElecPrice(HexUtils.reverseHexInt(hex.substring(i + 28, i + 36)) / 100000.0); - cd.setSevicePrice(HexUtils.reverseHexInt(hex.substring(i + 36, i + 44)) / 100000.0); - cd.setDetailPower(HexUtils.reverseHexInt(hex.substring(i + 44, i + 52)) / 10000.0); - cd.setDetailElecMoney(HexUtils.reverseHexInt(hex.substring(i + 52, i + 60)) / 10000.0); - cd.setDetailElecMoney(HexUtils.reverseHexInt(hex.substring(i + 60, i + 68)) / 10000.0); + cd.setDetailPower(HexUtils.reverseHexInt(hex.substring(i, i + 8)) / 100000.0); + cd.setDetailElecMoney(HexUtils.reverseHexInt(hex.substring(i + 8, i + 16)) / 100000.0); +// cd.setDetailSeviceMoney(HexUtils.reverseHexInt(hex.substring(i + 60, i + 68)) / 10000.0); cds.add(cd); } return cds;