重构与fix

This commit is contained in:
ZZ 2021-10-15 17:09:52 +08:00
parent 17f0edde7f
commit 568cce07b0
16 changed files with 34 additions and 25 deletions

View File

@ -59,7 +59,7 @@ public class CoreDispatcher {
Calendar cal = Calendar.getInstance();
String bearer = null;
AuthSecretToken authSecretTokenOut = getAuthSecretTokenOut(operatorId3irdpty, operatorID);
if (authSecretTokenOut!=null) {
if (authSecretTokenOut == null) {
String error = String.format("secret/token not found for [%s/%s](opId3pt/opId)", operatorId3irdpty, operatorID);
throw new RuntimeException(error);
}

View File

@ -11,6 +11,7 @@ import com.xhpc.evcs.jpa.OrderMappingRepository;
import com.xhpc.evcs.jpa.StatisticTimeIntervalRepository;
import com.xhpc.evcs.utils.DateUtil;
import com.xhpc.evcs.utils.JSONUtil;
import com.xhpc.pp.utils.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -58,10 +59,10 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
equipChargeStatus.setStartChargeSeqStat(2);
equipChargeStatus.setConnectorID(orderkey.substring(6, 22));
String current = REDIS.getCacheMapValue(gunkey, "current");
equipChargeStatus.setCurrentA(Integer.parseInt(current == null ? "10" : current, 16) / 100.0);
equipChargeStatus.setCurrentA(HexUtils.reverseHexInt(current == null ? "9600" : current) / 10.0);
String voltage = REDIS.getCacheMapValue(gunkey, "voltage");
equipChargeStatus.setVoltageA(Integer.parseInt(voltage == null ? "300" : voltage, 16) / 100.0);
Double soc = REDIS.getCacheMapValue(gunkey, "endSoc");
equipChargeStatus.setVoltageA(HexUtils.reverseHexInt(voltage == null ? "D80E" : voltage) / 10.0);
Double soc = REDIS.getCacheMapValue(orderkey, "endSoc");
equipChargeStatus.setSoc(soc == null ? 0 : soc);
equipChargeStatus.setStartTime(cacheGun.get("orderstarttime").toString());
equipChargeStatus.setEndTime(DateUtil.date2String(Calendar.getInstance().getTime(),
@ -87,7 +88,7 @@ public class NotificationEquipChargeStatusTask extends CoreDispatcher {
public static String transferInternetOrderNo(String orderKeyOrNo) {
return "MA6DFCTD5".concat(DateUtil.getYYYY()).concat(orderKeyOrNo.replace("order:", "").substring(18));
return "MA6DFCTD5".concat(DateUtil.getYYYY()).concat(orderKeyOrNo.substring(24));
}
private void calculateEm(EquipChargeStatus equipChargeStatusCD, CacheRateModel cacheRateModel) {

View File

@ -1,4 +1,4 @@
package com.xhpc.pp.utils.security;
package com.xhpc.pp.utils;
import org.apache.commons.lang3.ArrayUtils;
@ -182,12 +182,16 @@ public class HexUtils {
// System.out.println(Integer.parseInt("FF00", 16));
// System.out.println(reverseHexInt("FF00"));
byte[] data1 = toBytes(reverseHex("10270000"));
System.out.println(toInteger(data1, 0, 4));
System.out.println(reverseHexInt("A0860100"));
// byte[] data1 = toBytes(reverseHex("10270000"));
// System.out.println(toInteger(data1, 0, 4));
System.out.println(reverseHexInt("D80E"));
System.out.println(toHexInt(3800));
// System.out.println(toHexInt(100000));
// System.out.println(toBits("1000"));
System.out.println(toHex(new byte[]{104, 13, 19, 123, 0, 3, 105, -123, 71, -123, -106, 50, 84, 1, 0, 72, 106, 104, -94, 19, 124, 0, 59, 105, -123, 71, -123, -106, 50, 84, 1, 33, 9, 24, 9, 67, 57, 0, 2, 105, -123, 71, -123, -106, 50, 84, 1, -88, 97, 43, 9, 50, 9, 21, 48, 117, 50, 9, 50, 9, 21, -64, 87, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 83, 1, 0}));
// System.out.println(toHex(new byte[]{104, 13, 19, 123, 0, 3, 105, -123, 71, -123, -106, 50, 84, 1, 0, 72, 106, 104,
// -94, 19, 124, 0, 59, 105, -123, 71, -123, -106, 50, 84, 1, 33, 9, 24, 9, 67, 57, 0, 2, 105, -123, 71, -123, -106,
// 50, 84, 1, -88, 97, 43, 9, 50, 9, 21, 48, 117, 50, 9, 50, 9, 21, -64, 87, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// -40, 83, 1, 0}));
}

View File

@ -9,9 +9,9 @@ import com.xhpc.common.core.utils.HttpUtils;
import com.xhpc.common.data.down.StartChargingData;
import com.xhpc.pp.logic.RateModelRequestLogic;
import com.xhpc.pp.server.ChargingPileServer;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.CacheDataUtils;
import com.xhpc.pp.utils.security.HexUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.quickserver.net.server.ClientHandler;
import org.slf4j.Logger;
@ -29,7 +29,7 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex;
import static com.xhpc.pp.logic.RegisterLogic.REGISTERED;
import static com.xhpc.pp.server.ChargingPileServer.*;
import static com.xhpc.pp.utils.security.HexUtils.toHexInt;
import static com.xhpc.pp.utils.HexUtils.toHexInt;
@RestController
public class ChargingController {

View File

@ -2,7 +2,7 @@ package com.xhpc.pp.controller;
import com.xhpc.common.api.dto.ChargingStationDto;
import com.xhpc.common.core.domain.R;
import com.xhpc.pp.utils.security.HexUtils;
import com.xhpc.pp.utils.HexUtils;
import lombok.extern.slf4j.Slf4j;
import org.quickserver.net.server.ClientHandler;
import org.springframework.web.bind.annotation.*;

View File

@ -3,8 +3,8 @@ package com.xhpc.pp.logic;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;

View File

@ -8,8 +8,8 @@ import com.xhpc.common.data.up.OrderData;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -7,8 +7,8 @@ import com.xhpc.common.data.redis.CacheRateModel;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
@ -18,7 +18,7 @@ import java.util.Map;
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex;
import static com.xhpc.pp.utils.security.HexUtils.toHexInt;
import static com.xhpc.pp.utils.HexUtils.toHexInt;
@Lazy
@Component("RateModelRequestLogic")

View File

@ -4,8 +4,8 @@ import com.xhpc.common.api.dto.ChargingStationDto;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;

View File

@ -26,9 +26,9 @@ import java.util.Map;
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.CacheDataUtils.reflectTranslate;
import static com.xhpc.pp.utils.security.HexUtils.reverseHexInt;
import static com.xhpc.pp.utils.security.HexUtils.toBits;
@Lazy
@Component("RealtimeDataLogic")
@ -125,7 +125,7 @@ public class RealtimeDataLogic implements ServiceLogic {
realtimeDataList.add(cacheRealtimeData);
Integer cacheStartSoc = (Integer) cacheOrder.get("startSoc");
if (cacheStartSoc == null && socInt != 0) cacheOrder.put("startSoc", socInt);
cacheOrder.put("endSoc", socInt);
if (socInt != 0) cacheOrder.put("endSoc", socInt);
// cacheOrder.put("em", realtimeData.()); //todo 实时时段明细数据是否由桩直接上传?
cacheOrder.put("rbalance", balance);
cacheOrder.put("remainingTime", tr);

View File

@ -4,8 +4,8 @@ import com.xhpc.evcs.dto.ConnectorStatusInfo;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.HexUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;

View File

@ -9,9 +9,9 @@ import com.xhpc.pp.logic.ServiceMainLogic;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.TxException;
import com.xhpc.pp.utils.HexUtils;
import com.xhpc.pp.utils.SpringContextHolder;
import com.xhpc.pp.utils.security.CRCCalculator;
import com.xhpc.pp.utils.security.HexUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.quickserver.net.server.ClientBinaryHandler;
import org.quickserver.net.server.ClientHandler;
@ -26,10 +26,10 @@ import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
import static com.xhpc.common.data.redis.StaticBeanUtil.seqHex;
import static com.xhpc.pp.server.ChargingPileServer.removeHandler;
import static com.xhpc.pp.tx.ServiceResult.OK;
import static com.xhpc.pp.utils.HexUtils.toHex;
import static com.xhpc.pp.utils.security.CP56Time2a.toCp56Hex;
import static com.xhpc.pp.utils.security.CRCCalculator.calcCrc;
import static com.xhpc.pp.utils.security.CacheDataUtils.hori2;
import static com.xhpc.pp.utils.security.HexUtils.toHex;
public class ChargingPileBinaryHandler implements ClientBinaryHandler {

View File

@ -1,7 +1,7 @@
package com.xhpc.pp.server;
import com.xhpc.pp.logic.FieldLogic;
import com.xhpc.pp.utils.security.HexUtils;
import com.xhpc.pp.utils.HexUtils;
import org.quickserver.net.server.ClientHandler;
import org.quickserver.net.server.DataMode;
import org.quickserver.net.server.DataType;

View File

@ -3,6 +3,7 @@ package com.xhpc.pp.utils.security;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.xhpc.pp.utils.HexUtils;
import java.util.Calendar;
import java.util.Date;

View File

@ -1,5 +1,7 @@
package com.xhpc.pp.utils.security;
import com.xhpc.pp.utils.HexUtils;
import java.util.Arrays;
public class CRCCalculator {

View File

@ -1,6 +1,7 @@
package com.xhpc.pp.utils.security;
import cn.hutool.core.date.DateUtil;
import com.xhpc.pp.utils.HexUtils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;