协议1.2.3

This commit is contained in:
ZZ 2022-02-25 16:06:31 +08:00
parent bb92694576
commit 840aeee7f9
4 changed files with 45 additions and 16 deletions

View File

@ -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));

View File

@ -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("刷卡");

View File

@ -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<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("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";

View File

@ -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<String, Object> 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<CacheRealtimeData> realtimeDataList = (List<CacheRealtimeData>) 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<ChargeDetails> 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;