mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 电单车协议
This commit is contained in:
@@ -32,16 +32,26 @@ public class Constants {
|
||||
public static final String ILLEGAL_TRANSACTION_CODE = "00000000000000000000000000000000";
|
||||
|
||||
// 充电桩sn号长度
|
||||
public static final int PILE_SN_LENGTH = 14;
|
||||
public static final int PILE_SN_LENGTH_FOR_EV = 14;
|
||||
|
||||
// 充电桩枪口号长度
|
||||
public static final int CONNECTOR_CODE_LENGTH = 2;
|
||||
public static final int CONNECTOR_CODE_LENGTH_FOR_EV = 2;
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH = PILE_SN_LENGTH_FOR_EV + CONNECTOR_CODE_LENGTH_FOR_EV;
|
||||
|
||||
// 充电桩sn号长度
|
||||
public static final int PILE_SN_LENGTH_FOR_EBIKE = 14;
|
||||
|
||||
// 充电桩枪口号长度
|
||||
public static final int CONNECTOR_CODE_LENGTH_FOR_EBIKE = 2;
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE = PILE_SN_LENGTH_FOR_EBIKE + CONNECTOR_CODE_LENGTH_FOR_EBIKE;
|
||||
|
||||
// 汇付手续费费率
|
||||
public static final String FEE_RATES = "0.0055";
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH = PILE_SN_LENGTH + CONNECTOR_CODE_LENGTH;
|
||||
|
||||
public static final String SOCKET_IP = "127.0.0.1";
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.jsowell.common.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class YKCUtils {
|
||||
@@ -67,11 +71,6 @@ public class YKCUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
byte[] length = new byte[]{0x22};
|
||||
System.out.println(BytesUtil.bytesToIntLittle(length));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换电压电流以及起始soc
|
||||
* 精确到小数点后一位;待机置零
|
||||
@@ -152,4 +151,66 @@ public class YKCUtils {
|
||||
public static String parseVin(byte[] vinCodeByteArr) {
|
||||
return BytesUtil.ascii2Str(vinCodeByteArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析充电桩编号
|
||||
*/
|
||||
public static Map<String, String> parsePileConnectorCode(String pileConnectorCode) {
|
||||
// 长度大于10是汽车桩, 否则是电单车桩
|
||||
String pileSn;
|
||||
String connectorCode = "";
|
||||
if (pileConnectorCode.length() > 10) {
|
||||
// 汽车桩, 桩编号14位, 枪口号2位
|
||||
if (pileConnectorCode.length() == 16) {
|
||||
pileSn = StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2);
|
||||
connectorCode = StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2);
|
||||
} else if (pileConnectorCode.length() == 14){
|
||||
pileSn = pileConnectorCode;
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
} else {
|
||||
// 电单车桩, 桩编号8位, 枪口号2位
|
||||
if (pileConnectorCode.length() == 10) {
|
||||
pileSn = StringUtils.substring(pileConnectorCode, 0, pileConnectorCode.length() - 2);
|
||||
connectorCode = StringUtils.substring(pileConnectorCode, pileConnectorCode.length() - 2);
|
||||
} else if (pileConnectorCode.length() == 8){
|
||||
pileSn = pileConnectorCode;
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR);
|
||||
}
|
||||
}
|
||||
Map<String, String> resultMap = Maps.newHashMap();
|
||||
resultMap.put("pileSn", pileSn);
|
||||
resultMap.put("connectorCode", connectorCode);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pileSn
|
||||
* @param pileConnectorCode 充电桩枪口编号
|
||||
* @return
|
||||
*/
|
||||
public static String getPileSn(String pileConnectorCode) {
|
||||
Map<String, String> map = parsePileConnectorCode(pileConnectorCode);
|
||||
return map.get("pileSn");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枪口号
|
||||
* @param pileConnectorCode 充电桩枪口编号
|
||||
* @return
|
||||
*/
|
||||
public static String getConnectorCode(String pileConnectorCode) {
|
||||
Map<String, String> map = parsePileConnectorCode(pileConnectorCode);
|
||||
return map.get("connectorCode");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String pileConnectorCode = "8800000000000201";
|
||||
String pileSn = YKCUtils.getPileSn(pileConnectorCode);
|
||||
System.out.println(pileSn);
|
||||
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
||||
System.out.println(connectorCode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user