update 电单车协议

This commit is contained in:
Guoqs
2024-09-04 14:27:15 +08:00
parent 6ee161de0a
commit 0d26625b57
3 changed files with 48 additions and 65 deletions

View File

@@ -72,96 +72,93 @@ public class EBikeMessageCmd82 extends AbsEBikeMessage {
@Setter
@NoArgsConstructor
public static class SpecificData {
private String rateMode; // 费率模式 (1字节)
private String balanceOrValidity; // 余额/有效期 (4字节)
private String portNumber; // 端口号 (指实际端口号, 发指令的时候自动转换为桩能识别的byte字节)
private String chargeCommand; // 充电命令 (1字节)
private String chargeDurationOrPower; // 充电时长/电量 (2字节)
private int rateMode; // 费率模式 (1字节)
private int balanceOrValidity; // 余额/有效期 (4字节)
private int portNumber; // 端口号 (指实际端口号, 发指令的时候自动转换为桩能识别的byte字节)
private int chargeCommand; // 充电命令 (1字节)
private int chargeDurationOrPower; // 充电时长/电量 (2字节)
private String orderNumber; // 订单编号 (16字节)
private String maxChargeDuration; // 最大充电时长 (2字节)
private String overloadPower; // 过载功率 (2字节)
private String qrCodeLight; // 二维码灯 (1字节)
private String longChargeMode; // 长充模式 (1字节)
private String extraFloatChargeTime; // 额外浮充时间 (2字节)
private String skipShortCircuitDetection; // 是否跳过短路检测 (1字节)
private String noUserPullOutCheck; // 不判断用户拔出 (1字节)
private String forceAutoStopWhenFull; // 强制带充满自停 (1字节)
private String fullChargePower; // 充满功率 (1字节)
private String maxFullChargePowerCheckTime; // 充满功率最长判断时间 (1字节)
private int maxChargeDuration; // 最大充电时长 (2字节)
private int overloadPower; // 过载功率 (2字节)
private int qrCodeLight; // 二维码灯 (1字节)
private int longChargeMode; // 长充模式 (1字节)
private int extraFloatChargeTime; // 额外浮充时间 (2字节)
private int skipShortCircuitDetection; // 是否跳过短路检测 (1字节)
private int noUserPullOutCheck; // 不判断用户拔出 (1字节)
private int forceAutoStopWhenFull; // 强制带充满自停 (1字节)
private int fullChargePower; // 充满功率 (1字节)
private int maxFullChargePowerCheckTime; // 充满功率最长判断时间 (1字节)
public SpecificData(byte[] dataBytes) {
byte rateModeBytes = dataBytes[0];
this.rateMode = BytesUtil.bcd2StrLittle(new byte[]{rateModeBytes});
this.rateMode = BytesUtil.bytesToIntLittle(new byte[]{rateModeBytes});
byte[] balanceOrValidityBytes = Arrays.copyOfRange(dataBytes, 1, 5);
this.balanceOrValidity = BytesUtil.bcd2StrLittle(balanceOrValidityBytes);
this.balanceOrValidity = BytesUtil.bytesToIntLittle(balanceOrValidityBytes);
byte portNumberBytes = dataBytes[5];
this.portNumber = BytesUtil.bcd2StrLittle(new byte[]{portNumberBytes});
this.portNumber = BytesUtil.bytesToIntLittle(new byte[]{portNumberBytes});
byte chargeCommandBytes = dataBytes[6];
this.chargeCommand = BytesUtil.bcd2StrLittle(new byte[]{chargeCommandBytes});
this.chargeCommand = BytesUtil.bytesToIntLittle(new byte[]{chargeCommandBytes});
byte[] chargeDurationOrPowerBytes = Arrays.copyOfRange(dataBytes, 7, 9);
this.chargeDurationOrPower = BytesUtil.bcd2StrLittle(chargeDurationOrPowerBytes);
this.chargeDurationOrPower = BytesUtil.bytesToIntLittle(chargeDurationOrPowerBytes);
byte[] orderNumberBytes = Arrays.copyOfRange(dataBytes, 9, 25);
this.orderNumber = BytesUtil.bcd2StrLittle(orderNumberBytes);
byte[] maxChargeDurationBytes = Arrays.copyOfRange(dataBytes, 25, 27);
this.maxChargeDuration = BytesUtil.bcd2StrLittle(maxChargeDurationBytes);
this.maxChargeDuration = BytesUtil.bytesToIntLittle(maxChargeDurationBytes);
byte[] overloadPowerBytes = Arrays.copyOfRange(dataBytes, 27, 29);
this.overloadPower = BytesUtil.bcd2StrLittle(overloadPowerBytes);
this.overloadPower = BytesUtil.bytesToIntLittle(overloadPowerBytes);
byte qrCodeLightBytes = dataBytes[29];
this.qrCodeLight = BytesUtil.bcd2StrLittle(new byte[]{qrCodeLightBytes});
this.qrCodeLight = BytesUtil.bytesToIntLittle(new byte[]{qrCodeLightBytes});
byte longChargeModeBytes = dataBytes[30];
this.longChargeMode = BytesUtil.bcd2StrLittle(new byte[]{longChargeModeBytes});
this.longChargeMode = BytesUtil.bytesToIntLittle(new byte[]{longChargeModeBytes});
byte[] extraFloatChargeTimeBytes = Arrays.copyOfRange(dataBytes, 31, 33);
this.extraFloatChargeTime = BytesUtil.bcd2StrLittle(extraFloatChargeTimeBytes);
this.extraFloatChargeTime = BytesUtil.bytesToIntLittle(extraFloatChargeTimeBytes);
byte skipShortCircuitDetectionBytes = dataBytes[33];
this.skipShortCircuitDetection = BytesUtil.bcd2StrLittle(new byte[]{skipShortCircuitDetectionBytes});
this.skipShortCircuitDetection = BytesUtil.bytesToIntLittle(new byte[]{skipShortCircuitDetectionBytes});
byte noUserPullOutCheckBytes = dataBytes[34];
this.noUserPullOutCheck = BytesUtil.bcd2StrLittle(new byte[]{noUserPullOutCheckBytes});
this.noUserPullOutCheck = BytesUtil.bytesToIntLittle(new byte[]{noUserPullOutCheckBytes});
byte forceAutoStopWhenFullByte = dataBytes[35];
this.forceAutoStopWhenFull = BytesUtil.bcd2StrLittle(new byte[]{forceAutoStopWhenFullByte});
this.forceAutoStopWhenFull = BytesUtil.bytesToIntLittle(new byte[]{forceAutoStopWhenFullByte});
byte fullChargePowerBytes = dataBytes[36];
this.fullChargePower = BytesUtil.bcd2StrLittle(new byte[]{fullChargePowerBytes});
this.fullChargePower = BytesUtil.bytesToIntLittle(new byte[]{fullChargePowerBytes});
byte maxFullChargePowerCheckTimeBytes = dataBytes[37];
this.maxFullChargePowerCheckTime = BytesUtil.bcd2StrLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
this.maxFullChargePowerCheckTime = BytesUtil.bytesToIntLittle(new byte[]{maxFullChargePowerCheckTimeBytes});
}
// 获取字节数组
public byte[] getBytes() {
// 费率模式
byte[] rateModeBytes = BytesUtil.intToBytesLittle(Integer.parseInt(rateMode), 1);
byte[] rateModeBytes = BytesUtil.intToBytesLittle(rateMode, 1);
// 余额/有效期
byte[] balanceOrValidityBytes = BytesUtil.intToBytesLittle(Integer.parseInt(balanceOrValidity), 4);
byte[] balanceOrValidityBytes = BytesUtil.intToBytesLittle(balanceOrValidity, 4);
// 端口号
byte[] portNumberBytes = YouDianUtils.convertPortNumberToBytes(portNumber);
// 充电命令
byte[] chargeCommandBytes = BytesUtil.intToBytesLittle(Integer.parseInt(chargeCommand), 1);
byte[] chargeCommandBytes = BytesUtil.intToBytesLittle(chargeCommand, 1);
// 充电时长/电量
byte[] chargeDurationOrPowerBytes = BytesUtil.stringToHexBytes(chargeDurationOrPower, 2);
byte[] chargeDurationOrPowerBytes = BytesUtil.intToBytesLittle(chargeDurationOrPower, 2);
// 订单编号
// byte[] orderNumberBytes = BytesUtil.stringToHexBytes(orderNumber, 16);
byte[] orderNumberBytes = BytesUtil.ensureLength(BytesUtil.str2Bcd(orderNumber), 16);
// 最大充电时长
// byte[] maxChargeDurationBytes = BytesUtil.stringToHexBytes(maxChargeDuration, 2);
byte[] maxChargeDurationBytes = BytesUtil.intToBytesLittle(Integer.parseInt(maxChargeDuration), 2);
byte[] maxChargeDurationBytes = BytesUtil.intToBytesLittle(maxChargeDuration, 2);
// 过载功率
// byte[] overloadPowerBytes = BytesUtil.stringToHexBytes(overloadPower, 2);
byte[] overloadPowerBytes = BytesUtil.intToBytesLittle(Integer.parseInt(overloadPower), 2);
byte[] overloadPowerBytes = BytesUtil.intToBytesLittle(overloadPower, 2);
// 二维码灯
byte[] qrCodeLightBytes = BytesUtil.intToBytesLittle(Integer.parseInt(qrCodeLight), 1);
byte[] qrCodeLightBytes = BytesUtil.intToBytesLittle(qrCodeLight, 1);
// 长充模式
// byte[] longChargeModeBytes = BytesUtil.stringToHexBytes(longChargeMode, 1);
// 额外浮充时间

View File

@@ -185,31 +185,17 @@ public class PileRemoteService {
pileBillingTemplate.setPublishTime(new Date());
pileBillingTemplateService.updatePileBillingTemplate(pileBillingTemplate);
// 获取到站点下所有的桩
List<PileDetailVO> pileList = pileBasicInfoService.selectPileListByStationIds(Lists.newArrayList(Long.valueOf(dto.getStationId())));
if (CollectionUtils.isEmpty(pileList)) {
log.warn("获取到站点下所有的桩, 通过站点id:{}查询充电桩列表为空", dto.getStationId());
return false;
// 获取到站点下所有的桩, 下发计费模板, 电单车不支持
if (StringUtils.equals(billingTemplateVO.getDeviceType(), "1")) {
List<PileDetailVO> pileList = pileBasicInfoService.selectPileListByStationIds(Lists.newArrayList(Long.valueOf(dto.getStationId())));
if (CollectionUtils.isNotEmpty(pileList)) {
for (PileDetailVO pileInfoVO : pileList) {
// 下发计费模板
publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO);
}
}
}
// 保存计费模板和桩的关系
// List<PileBillingRelation> relationList = Lists.newArrayList();
for (PileDetailVO pileInfoVO : pileList) {
// push
publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO);
// 入库
// relationList.add(PileBillingRelation.builder()
// .pileSn(pileInfoVO.getPileSn())
// .billingTemplateCode(billingTemplateVO.getTemplateCode())
// .stationId(dto.getStationId())
// .build());
}
// if (CollectionUtils.isNotEmpty(relationList)) {
// pileBillingTemplateService.insertPileBillingRelation(relationList);
// }
// 修改计费模板状态
pileBillingTemplateService.changeStationTemplate(dto.getStationId(), dto.getTemplateId(), billingTemplateVO.getDeviceType());
return true;

View File

@@ -30,7 +30,7 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
EBikeMessageCmd82.SpecificData data = new EBikeMessageCmd82.SpecificData();
// 充电模式
data.setRateMode("0");
data.setRateMode("3");
// 余额或有效期
data.setBalanceOrValidity("356");
// 端口号
@@ -45,7 +45,7 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
data.setOrderNumber(orderNumber);
// 最大充电时长
data.setMaxChargeDuration("28800");
data.setMaxChargeDuration("0");
// 过载功率
data.setOverloadPower("5000");
data.setQrCodeLight("0");