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:
@@ -176,24 +176,27 @@ public class YKCUtils {
|
||||
public static Map<String, String> parsePileConnectorCode(String pileConnectorCode) {
|
||||
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);
|
||||
} else if (length == 14) {
|
||||
return ImmutableMap.of("pileSn", pileConnectorCode, "connectorCode", "");
|
||||
} else {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_DATA_LENGTH_ERROR.getValue(), "Invalid EV pile connector code length: " + length);
|
||||
}
|
||||
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EV, pileConnectorCode.length() - 2);
|
||||
} else if (length == Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE) {
|
||||
// 电单车
|
||||
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE, pileConnectorCode.length() - 2);
|
||||
} else if (length == Constants.PILE_SN_LENGTH_FOR_EV || length == Constants.PILE_SN_LENGTH_FOR_EBIKE) {
|
||||
// 充电桩编号
|
||||
return ImmutableMap.of("pileSn", pileConnectorCode, "connectorCode", "");
|
||||
} else {
|
||||
// 电单车桩
|
||||
if (length == Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE) {
|
||||
return parsePileConnector(pileConnectorCode, Constants.PILE_CONNECTOR_CODE_LENGTH_FOR_EBIKE, pileConnectorCode.length() - 2);
|
||||
} else if (length == 8) {
|
||||
return ImmutableMap.of("pileSn", pileConnectorCode, "connectorCode", "");
|
||||
} 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) {
|
||||
String pileConnectorCode = "8800000000000201";
|
||||
pileConnectorCode = "1327388103";
|
||||
// pileConnectorCode = "1327388103";
|
||||
String pileSn = YKCUtils.getPileSn(pileConnectorCode);
|
||||
System.out.println(pileSn);
|
||||
String connectorCode = YKCUtils.getConnectorCode(pileConnectorCode);
|
||||
|
||||
Reference in New Issue
Block a user