协议实现更新,兼容1.0、2.0
This commit is contained in:
parent
472db29426
commit
7cd29efcc9
@ -59,7 +59,7 @@ public class OrderDataLogic implements ServiceLogic {
|
||||
REDIS.setCacheMap(gunkey, cacheGun);
|
||||
Long rdtime = (Long) cacheOrder.get("rdtime");
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap("pile:".concat(orderData.getPileNo()));
|
||||
if (cachePile.get("version").equals("0B")) {
|
||||
if (cachePile.get("version").equals("0C")) {
|
||||
final String hex = orderData.getHex();
|
||||
String cdhex = hex.substring(0xA2 * 2 + 4, hex.length() - 4);
|
||||
if (cdhex.length() > 0) {
|
||||
|
||||
@ -66,7 +66,7 @@ public class RateModelRequestLogic implements ServiceLogic {
|
||||
String rateModel = translate(cacheRateModel);
|
||||
String skey = "pile:".concat(pileNo).concat(".seqhex");
|
||||
String resultStr;
|
||||
if ("0A".equals(version))
|
||||
if (!"0C".equals(version))
|
||||
resultStr = "685E".concat(seqHex(skey)).concat(svc).concat(pileNo).concat(String.format("%04X",
|
||||
stationRateModelId)).concat(rateModel);
|
||||
else
|
||||
|
||||
@ -52,7 +52,7 @@ public class RateModelValidateLogic implements ServiceLogic {
|
||||
String hexCode = ServiceResult.HEX_00;
|
||||
Long rateModelId;
|
||||
String version = (String) cachePile.get("version");
|
||||
if ("0A".equals(version)) rateModelId = Long.valueOf(Integer.parseInt(rateModelIdStr, 16));
|
||||
if ("0C".equals(version)) rateModelId = Long.valueOf(HexUtils.reverseHexInt(rateModelIdStr));
|
||||
else rateModelId = Long.valueOf(rateModelIdStr);
|
||||
Long csRateModelId = rateModelId;
|
||||
if (!charging) {
|
||||
|
||||
@ -133,7 +133,7 @@ public class RealtimeDataLogic implements ServiceLogic {
|
||||
Integer cacheStartSoc = (Integer) cacheOrder.get("startSoc");
|
||||
if (cacheStartSoc == null && socInt != 0) cacheOrder.put("startSoc", socInt);
|
||||
if (socInt != 0) cacheOrder.put("endSoc", socInt);
|
||||
if (cachePile.get("version").equals("0B")) {
|
||||
if (cachePile.get("version").equals("0C")) {
|
||||
final String hex = realtimeData.getHex();
|
||||
String cdhex = hex.substring(0x40 * 2 + 4, hex.length() - 4);
|
||||
if (cdhex.length() > 0) {
|
||||
|
||||
@ -119,7 +119,8 @@ public class ChargingPileServer {
|
||||
cachePile.put("status", DISCONNECTED);
|
||||
REDIS.setCacheMap(pkey, cachePile);
|
||||
putemDisconn(pileNo, cachePile);
|
||||
log.debug("remove handler [{}] for ({})", handler.getName(), pileNo);
|
||||
log.debug("remove handler [{}] for ({}), now try to close conn..", handler.getName(), pileNo);
|
||||
handler.closeConnection();
|
||||
pileMap.remove(handler.getName());
|
||||
versionMapper.remove(handler.getName());
|
||||
}
|
||||
|
||||
@ -30,9 +30,9 @@ public class RateModelTask {
|
||||
if (rateModelIdStation != null) {
|
||||
Set<String> pks = stationDto.getPiles();
|
||||
if (pks != null) for (String pileNo : pks) {
|
||||
Long rateModelIdPile = REDIS.getCacheMapValue(pileNo, "rateModelId");
|
||||
String pk = "pile:".concat(pileNo);
|
||||
Long rateModelIdPile = REDIS.getCacheMapValue(pk, "rateModelId");
|
||||
if (!rateModelIdStation.equals(rateModelIdPile)) {
|
||||
String pk = "pile:".concat(pileNo);
|
||||
String gkPattern = ("gun:").concat(pk).concat("*");
|
||||
Collection<String> gks = REDIS.keys(gkPattern);
|
||||
boolean charging = false;
|
||||
|
||||
@ -2,6 +2,7 @@ package com.xhpc.pp.utils.security;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.xhpc.pp.utils.HexUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
@ -13,6 +14,7 @@ import static com.xhpc.common.core.utils.StringUtils.capitalize;
|
||||
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||
import static com.xhpc.pp.utils.security.CP56Time2a.cp56toDate;
|
||||
|
||||
@Slf4j
|
||||
public class CacheDataUtils {
|
||||
|
||||
public static Object reflectTranslate(Object srcobj, Class tarclz, Class srcclz, Field[] targetfields) throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||
@ -36,7 +38,12 @@ public class CacheDataUtils {
|
||||
tarval = (Integer) tarval > 0 ? tarval : 0;
|
||||
}
|
||||
} else {
|
||||
tarval = HexUtils.reverseHexInt(srcval);
|
||||
try {
|
||||
tarval = HexUtils.reverseHexInt(srcval);
|
||||
} catch (java.lang.NumberFormatException e) { // todo 测试代码,不应该在生产环境运行到这里
|
||||
log.error("fatal!! 4 bytes (bin) number: {} - {}", tarfield.getName(), srcval);
|
||||
tarval = 0;
|
||||
}
|
||||
}
|
||||
} else if (tarFieldName.contains("ime")) {
|
||||
tarval = DateUtil.format(cp56toDate(srcval), NORM_DATETIME_FORMAT);
|
||||
@ -47,6 +54,8 @@ public class CacheDataUtils {
|
||||
}
|
||||
tarclz.getMethod("set".concat(capitalize(tarFieldName)), tarfield.getType()).invoke(tarobj, tarval);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
log.warn(" src[{}], tar[{}] NoSuchMethodException {}", tarclz.getName(),
|
||||
srcclz.getName(), "set".concat(capitalize(tarFieldName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +18,10 @@ spring:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 172.31.183.135:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 172.31.183.135:8848
|
||||
server-addr: 127.0.0.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user