mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-30 20:17:59 +08:00
update 预约充电
This commit is contained in:
@@ -22,7 +22,6 @@ import com.jsowell.pile.domain.ykcCommond.*;
|
|||||||
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
|
import com.jsowell.pile.dto.PublishBillingTemplateDTO;
|
||||||
import com.jsowell.pile.dto.RemoteAccountBalanceUpdateDTO;
|
import com.jsowell.pile.dto.RemoteAccountBalanceUpdateDTO;
|
||||||
import com.jsowell.pile.dto.UpdateFirmwareDTO;
|
import com.jsowell.pile.dto.UpdateFirmwareDTO;
|
||||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
|
||||||
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
import com.jsowell.pile.vo.web.BillingTemplateVO;
|
||||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||||
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
||||||
@@ -520,11 +519,86 @@ public class PileRemoteService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 羽信预约充电指令
|
* 羽信预约充电指令
|
||||||
|
*
|
||||||
* @return result: 1-成功; 0-失败
|
* @return result: 1-成功; 0-失败
|
||||||
*/
|
*/
|
||||||
public String yuxinReservationCharging(YuxinReservationChargingCommand command) {
|
public String yuxinReservationCharging(YuxinReservationChargingCommand command) {
|
||||||
byte[] bytes = ykcPushCommandService.pushYuxinReservationChargingCommand(command);
|
byte[] bytes = ykcPushCommandService.pushYuxinReservationChargingCommand(command);
|
||||||
return parseReservationChargingResponse(bytes);
|
return parseYuxinReservationChargingResponse(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseYuxinReservationChargingResponse(byte[] bytes) {
|
||||||
|
String result = "0";
|
||||||
|
if (Objects.isNull(bytes)) {
|
||||||
|
log.warn("羽信预约启动充电回复为空, 原始报文:null");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String rawMessage = BytesUtil.bin2HexStr(bytes);
|
||||||
|
try {
|
||||||
|
YKCDataProtocol ykcDataProtocol = new YKCDataProtocol(bytes);
|
||||||
|
String responseFrameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
|
||||||
|
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||||||
|
if (!StringUtils.equals(responseFrameType,
|
||||||
|
YKCUtils.frameType2Str(YKCFrameTypeCode.YUXIN_RESERVATION_CHARGING_SETUP_ANSWER_CODE.getBytes()))) {
|
||||||
|
log.warn("羽信预约启动充电回复帧类型异常, 帧类型:{}, 原始报文:{}", responseFrameType, rawMessage);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (Objects.isNull(msgBody) || msgBody.length < 27) {
|
||||||
|
log.warn("羽信预约启动充电回复长度异常, 帧类型:{}, 报文体长度:{}, 原始报文:{}",
|
||||||
|
responseFrameType, Objects.isNull(msgBody) ? null : msgBody.length, rawMessage);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int startIndex = 0;
|
||||||
|
int length = 16;
|
||||||
|
byte[] transactionCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String transactionCode = BytesUtil.bcd2Str(transactionCodeByteArr);
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 7;
|
||||||
|
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String connectorCode = parseYuxinConnectorCode(connectorCodeByteArr);
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
byte[] reservationTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String reservationType = BytesUtil.bin2HexStr(reservationTypeByteArr);
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
byte[] resultCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String resultCode = BytesUtil.bin2HexStr(resultCodeByteArr);
|
||||||
|
|
||||||
|
startIndex += length;
|
||||||
|
length = 1;
|
||||||
|
byte[] failedReasonByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
|
String failedReason = BytesUtil.bin2HexStr(failedReasonByteArr);
|
||||||
|
String failedReasonMsg = getYuxinFailedReasonMsg(failedReason);
|
||||||
|
|
||||||
|
if (StringUtils.equals(resultCode, "01")) {
|
||||||
|
result = "1";
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("{}羽信预约启动充电回复sync, 交易流水号:{}, 桩SN:{}, 枪口号:{}({}), 预约方式:{}({}), 设置结果:{}({}), 失败原因:{}({}), 原始报文:{}",
|
||||||
|
responseFrameType, transactionCode, pileSn, connectorCode, getYuxinConnectorCodeMsg(connectorCode),
|
||||||
|
reservationType, getYuxinReservationTypeMsg(reservationType),
|
||||||
|
resultCode, getYuxinSetupResultMsg(resultCode), failedReason, failedReasonMsg, rawMessage);
|
||||||
|
if (!StringUtils.equals(resultCode, "01")) {
|
||||||
|
log.warn("羽信预约启动充电设置失败, 交易流水号:{}, 桩SN:{}, 枪口号:{}({}), 失败原因:{}({}), 原始报文:{}",
|
||||||
|
transactionCode, pileSn, connectorCode, getYuxinConnectorCodeMsg(connectorCode),
|
||||||
|
failedReason, failedReasonMsg, rawMessage);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("羽信预约启动充电回复解析异常, 原始报文:{}", rawMessage, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseReservationChargingResponse(byte[] bytes) {
|
private String parseReservationChargingResponse(byte[] bytes) {
|
||||||
@@ -601,6 +675,31 @@ public class PileRemoteService {
|
|||||||
return String.format("%02d", connectorCodeByteArr[0] & 0xFF);
|
return String.format("%02d", connectorCodeByteArr[0] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getYuxinConnectorCodeMsg(String connectorCode) {
|
||||||
|
if (StringUtils.equals(connectorCode, "00")) {
|
||||||
|
return "所有枪";
|
||||||
|
}
|
||||||
|
return Integer.parseInt(connectorCode) + "号枪";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getYuxinReservationTypeMsg(String reservationType) {
|
||||||
|
if (StringUtils.equals(reservationType, "00")) {
|
||||||
|
return "立即预约";
|
||||||
|
} else if (StringUtils.equals(reservationType, "01")) {
|
||||||
|
return "取消预约";
|
||||||
|
}
|
||||||
|
return reservationType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getYuxinSetupResultMsg(String resultCode) {
|
||||||
|
if (StringUtils.equals(resultCode, "00")) {
|
||||||
|
return "失败";
|
||||||
|
} else if (StringUtils.equals(resultCode, "01")) {
|
||||||
|
return "成功";
|
||||||
|
}
|
||||||
|
return resultCode;
|
||||||
|
}
|
||||||
|
|
||||||
private String getYuxinFailedReasonMsg(String failedReason) {
|
private String getYuxinFailedReasonMsg(String failedReason) {
|
||||||
if (StringUtils.equals(failedReason, "00")) {
|
if (StringUtils.equals(failedReason, "00")) {
|
||||||
return "无";
|
return "无";
|
||||||
|
|||||||
Reference in New Issue
Block a user