mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 19:29:52 +08:00
update 电单车协议
This commit is contained in:
@@ -176,24 +176,27 @@ public class YKCUtils {
|
|||||||
public static Map<String, String> parsePileConnectorCode(String pileConnectorCode) {
|
public static Map<String, String> parsePileConnectorCode(String pileConnectorCode) {
|
||||||
int length = pileConnectorCode.length();
|
int length = pileConnectorCode.length();
|
||||||
|
|
||||||
if (length > 10) {
|
// 如果length不等于14, 16, 8, 10, 2, 判断为错误的长度
|
||||||
// 汽车桩
|
if (length != Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EV
|
||||||
|
&& length != Constants.PILE_SN_LENGTH_FOR_EV
|
||||||
|
&& length != Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE
|
||||||
|
&& length != Constants.PILE_SN_LENGTH_FOR_EBIKE
|
||||||
|
&& length != 2) {
|
||||||
|
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR.getValue(), "Invalid pile connector code length: " + length);
|
||||||
|
}
|
||||||
|
|
||||||
if (length == Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EV) {
|
if (length == Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EV) {
|
||||||
|
// 汽车桩
|
||||||
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EV, pileConnectorCode.length() - 2);
|
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EV, pileConnectorCode.length() - 2);
|
||||||
} else if (length == 14) {
|
} else if (length == Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE) {
|
||||||
return ImmutableMap.of("pileSn", pileConnectorCode, "connectorCode", "");
|
// 电单车
|
||||||
} else {
|
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR.getValue(), "Invalid EV pile connector code length: " + length);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 电单车桩
|
|
||||||
if (length == Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE) {
|
|
||||||
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE, pileConnectorCode.length() - 2);
|
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE, pileConnectorCode.length() - 2);
|
||||||
} else if (length == 8) {
|
} else if (length == Constants.PILE_SN_LENGTH_FOR_EV || length == Constants.PILE_SN_LENGTH_FOR_EBIKE) {
|
||||||
|
// 充电桩编号
|
||||||
return ImmutableMap.of("pileSn", pileConnectorCode, "connectorCode", "");
|
return ImmutableMap.of("pileSn", pileConnectorCode, "connectorCode", "");
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR.getValue(), "Invalid e-bike pile connector code length: " + length);
|
// 枪口号
|
||||||
}
|
return ImmutableMap.of("pileSn", "", "connectorCode", pileConnectorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +222,7 @@ public class YKCUtils {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String pileConnectorCode = "8800000000000201";
|
String pileConnectorCode = "8800000000000201";
|
||||||
pileConnectorCode = "1327388103";
|
// pileConnectorCode = "1327388103";
|
||||||
String pileSn = YKCUtils.getPileSn(pileConnectorCode);
|
String pileSn = YKCUtils.getPileSn(pileConnectorCode);
|
||||||
System.out.println(pileSn);
|
System.out.println(pileSn);
|
||||||
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user