mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-08 12:00:11 +08:00
update 预约充电update 预约充电
This commit is contained in:
@@ -7,7 +7,8 @@ import com.jsowell.common.util.YKCUtils;
|
||||
/**
|
||||
* 云快充 帧类型码
|
||||
* FrameTypeCode
|
||||
* frame
|
||||
* 单数为 桩 -> 平台
|
||||
* 双数为 平台 -> 桩
|
||||
*/
|
||||
public enum YKCFrameTypeCode {
|
||||
|
||||
@@ -71,8 +72,8 @@ public enum YKCFrameTypeCode {
|
||||
BILLING_TEMPLATE_SETTING_CODE(0x58, "计费模型设置"),
|
||||
BILLING_TEMPLATE_SETTING_ANSWER_CODE(0x57, "计费模型设置应答"),
|
||||
|
||||
RESERVATION_CHARGING_CODE(0x60, "预约充电设置"),
|
||||
RESERVATION_CHARGING_ANSWER_CODE(0x59, "预约充电设置响应"), // RESERVATION
|
||||
RESERVATION_CHARGING_SETUP_CODE(0x60, "预约充电设置"),
|
||||
RESERVATION_CHARGING_SETUP_ANSWER_CODE(0x59, "预约充电设置响应"), // RESERVATION
|
||||
|
||||
RESERVATION_CHARGING_STARTUP_RESULT_ANSWER_CODE(0x64, "预约充电启动结果上传响应"), // 平台响应
|
||||
RESERVATION_CHARGING_STARTUP_RESULT_CODE(0x65, "预约充电启动结果上传"), // 桩 -> 平台
|
||||
@@ -150,31 +151,38 @@ public enum YKCFrameTypeCode {
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求应答 帧类型关系
|
||||
* 桩请求 - 平台应答 帧类型关系
|
||||
* PlatformAnswersRelation
|
||||
*/
|
||||
public enum ResponseRelation {
|
||||
public enum PlatformAnswersRelation {
|
||||
// 登录
|
||||
LOGIN(LOGIN_CODE.getCode(), LOGIN_ANSWER_CODE.getCode()),
|
||||
|
||||
// 心跳
|
||||
HEART_BEAT(HEART_BEAT_CODE.getCode(), HEART_BEAT_ANSWER_CODE.getCode()),
|
||||
|
||||
// 计费模板验证
|
||||
BILLING_TEMPLATE_VALIDATE(BILLING_TEMPLATE_VALIDATE_CODE.getCode(), BILLING_TEMPLATE_VALIDATE_ANSWER_CODE.getCode()),
|
||||
|
||||
// 计费模板请求
|
||||
BILLING_TEMPLATE(BILLING_TEMPLATE_CODE.getCode(), BILLING_TEMPLATE_ANSWER_CODE.getCode()),
|
||||
|
||||
// 请求开始充电
|
||||
START_CHARGING(REQUEST_START_CHARGING_CODE.getCode(), CONFIRM_START_CHARGING_CODE.getCode()),
|
||||
|
||||
// 远程请求充电
|
||||
REMOTE_START_CHARGING(REMOTE_CONTROL_START_CODE.getCode(), REMOTE_START_CHARGING_ANSWER_CODE.getCode()),
|
||||
|
||||
// 远程停止充电
|
||||
REMOTE_STOP_CHARGING(REMOTE_STOP_CHARGING_CODE.getCode(), REMOTE_STOP_CHARGING_ANSWER_CODE.getCode()),
|
||||
|
||||
// 交易记录
|
||||
TRANSACTION_RECORDS(TRANSACTION_RECORDS_CODE.getCode(), TRANSACTION_RECORDS_CONFIRM_CODE.getCode()),
|
||||
// 远程账户更新
|
||||
REMOTE_ACCOUNT_BALANCE_UPDATE(REMOTE_ACCOUNT_BALANCE_UPDATE_CODE.getCode(), REMOTE_ACCOUNT_BALANCE_UPDATE_ANSWER_CODE.getCode()),
|
||||
TRANSACTION_RECORDS_V13(TRANSACTION_RECORDS_OLD_VERSION_CODE.getCode(), TRANSACTION_RECORDS_CONFIRM_CODE.getCode()),
|
||||
|
||||
// 预约充电启动结果
|
||||
RESERVATION_CHARGING_STARTUP_RESULT(RESERVATION_CHARGING_STARTUP_RESULT_CODE.getCode(), RESERVATION_CHARGING_STARTUP_RESULT_ANSWER_CODE.getCode()),
|
||||
|
||||
|
||||
;
|
||||
// 请求帧类型
|
||||
private int requestFrameType;
|
||||
@@ -198,16 +206,73 @@ public enum YKCFrameTypeCode {
|
||||
this.responseFrameType = responseFrameType;
|
||||
}
|
||||
|
||||
ResponseRelation(int requestFrameType, int responseFrameType) {
|
||||
PlatformAnswersRelation(int requestFrameType, int responseFrameType) {
|
||||
this.requestFrameType = requestFrameType;
|
||||
this.responseFrameType = responseFrameType;
|
||||
}
|
||||
|
||||
// 根据请求帧类型 获取应答帧类型 int类型
|
||||
public static int getResponseFrameTypeByRequestFrameType(int requestFrameType) {
|
||||
for (ResponseRelation responseRelation : ResponseRelation.values()) {
|
||||
if (responseRelation.getRequestFrameType() == requestFrameType) {
|
||||
return responseRelation.getResponseFrameType();
|
||||
for (PlatformAnswersRelation relation : PlatformAnswersRelation.values()) {
|
||||
if (relation.getRequestFrameType() == requestFrameType) {
|
||||
return relation.getResponseFrameType();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 根据请求帧类型 获取应答帧类型 byte[]类型
|
||||
public static byte[] getResponseFrameTypeBytes(byte[] requestFrameType) {
|
||||
int frameType = BytesUtil.bytesToInt(requestFrameType);
|
||||
return BytesUtil.intToBytes(getResponseFrameTypeByRequestFrameType(frameType), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台请求 - 桩应答 帧类型关系
|
||||
* PileAnswersRelation
|
||||
*/
|
||||
public enum PileAnswersRelation {
|
||||
// 预约充电设置
|
||||
RESERVATION_CHARGING_SETUP(RESERVATION_CHARGING_SETUP_CODE.getCode(), RESERVATION_CHARGING_SETUP_ANSWER_CODE.getCode()),
|
||||
|
||||
// 远程账户余额更新
|
||||
REMOTE_ACCOUNT_BALANCE_UPDATE(REMOTE_ACCOUNT_BALANCE_UPDATE_CODE.getCode(), REMOTE_ACCOUNT_BALANCE_UPDATE_ANSWER_CODE.getCode()),
|
||||
|
||||
;
|
||||
// 请求帧类型
|
||||
private int requestFrameType;
|
||||
|
||||
// 响应帧类型
|
||||
private int responseFrameType;
|
||||
|
||||
public int getRequestFrameType() {
|
||||
return requestFrameType;
|
||||
}
|
||||
|
||||
public void setRequestFrameType(int requestFrameType) {
|
||||
this.requestFrameType = requestFrameType;
|
||||
}
|
||||
|
||||
public int getResponseFrameType() {
|
||||
return responseFrameType;
|
||||
}
|
||||
|
||||
public void setResponseFrameType(int responseFrameType) {
|
||||
this.responseFrameType = responseFrameType;
|
||||
}
|
||||
|
||||
PileAnswersRelation(int requestFrameType, int responseFrameType) {
|
||||
this.requestFrameType = requestFrameType;
|
||||
this.responseFrameType = responseFrameType;
|
||||
}
|
||||
|
||||
// 根据请求帧类型 获取应答帧类型 int类型
|
||||
public static int getResponseFrameTypeByRequestFrameType(int requestFrameType) {
|
||||
for (PileAnswersRelation relation : PileAnswersRelation.values()) {
|
||||
if (relation.getRequestFrameType() == requestFrameType) {
|
||||
return relation.getResponseFrameType();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractHandler implements InitializingBean {
|
||||
// 请求帧类型
|
||||
byte[] requestFrameType = ykcDataProtocol.getFrameType();
|
||||
// 应答帧类型
|
||||
byte[] responseFrameType = YKCFrameTypeCode.ResponseRelation.getResponseFrameTypeBytes(requestFrameType);
|
||||
byte[] responseFrameType = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(requestFrameType);
|
||||
|
||||
// 数据域 值为“序列号域+加密标志+帧类型标志+消息体”字节数之和
|
||||
byte[] dataFields = Bytes.concat(serialNumber, encryptFlag, responseFrameType, messageBody);
|
||||
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractHandler implements InitializingBean {
|
||||
// 请求帧类型
|
||||
byte[] requestFrameType = ykcDataProtocol.getFrameType();
|
||||
// 应答帧类型
|
||||
byte[] responseFrameType = YKCFrameTypeCode.ResponseRelation.getResponseFrameTypeBytes(requestFrameType);
|
||||
byte[] responseFrameType = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(requestFrameType);
|
||||
|
||||
// 数据域 值为“序列号域+加密标志+帧类型标志+消息体”字节数之和
|
||||
byte[] dataFields = Bytes.concat(serialNumber, encryptFlag, responseFrameType, messageBody);
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ReservationChargingHandler extends AbstractHandler{
|
||||
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_CODE.getBytes());
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ReservationChargingResponseHandler extends AbstractHandler{
|
||||
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_ANSWER_CODE.getBytes());
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_ANSWER_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
this.channelWrite(channel.id(), buffer);
|
||||
if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) {
|
||||
// 应答帧类型
|
||||
byte[] responseFrameTypeBytes = YKCFrameTypeCode.ResponseRelation.getResponseFrameTypeBytes(frameTypeBytes);
|
||||
byte[] responseFrameTypeBytes = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(frameTypeBytes);
|
||||
String responseFrameType = YKCUtils.frameType2Str(responseFrameTypeBytes);
|
||||
log.info("【>>>>>平台响应消息>>>>>】channel:{}, 响应帧类型:{}, 响应帧名称:{}, 原帧类型:{}, 原帧名称:{}, 序列号域:{}, response:{}",
|
||||
channel.id(), responseFrameType, YKCFrameTypeCode.getFrameTypeStr(responseFrameType),
|
||||
|
||||
@@ -184,7 +184,7 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
.reservedEndTime(pileReservationInfo.getEndTime().toLocalTime())
|
||||
.amount(Constants.WHITELIST_DEFAULT_AMOUNT)
|
||||
.build();
|
||||
pileRemoteService.reservationCharging(command);
|
||||
// pileRemoteService.reservationCharging(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
.reservedEndTime(pileReservationInfo.getEndTime().toLocalTime())
|
||||
.amount(Constants.WHITELIST_DEFAULT_AMOUNT)
|
||||
.build();
|
||||
pileRemoteService.reservationCharging(command);
|
||||
// pileRemoteService.reservationCharging(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,12 +413,8 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作
|
||||
* 0x01:启动 0x02:取消 0x03:修改
|
||||
*/
|
||||
// 操作 0x01:启动 0x02:取消 0x03:修改
|
||||
String operation = "03";
|
||||
|
||||
if (StringUtils.isNotBlank(dto.getStartTime())) {
|
||||
pileReservationInfo.setStartTime(Time.valueOf(dto.getStartTime()));
|
||||
operation = "03";
|
||||
@@ -427,6 +423,10 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
pileReservationInfo.setEndTime(Time.valueOf(dto.getEndTime()));
|
||||
operation = "03";
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getVerifyIdentity())) {
|
||||
pileReservationInfo.setVerifyIdentity(dto.getVerifyIdentity());
|
||||
operation = "03";
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getStatus())) {
|
||||
pileReservationInfo.setStatus(dto.getStatus());
|
||||
if (StringUtils.equals(dto.getStatus(), Constants.ZERO)) {
|
||||
@@ -437,12 +437,11 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
operation = "01";
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(dto.getVerifyIdentity())) {
|
||||
pileReservationInfo.setVerifyIdentity(dto.getVerifyIdentity());
|
||||
}
|
||||
pileReservationInfo.setUpdateBy(dto.getMemberId());
|
||||
this.insertOrUpdateSelective(pileReservationInfo);
|
||||
|
||||
/*
|
||||
先发送指令, 收到回复更新数据库
|
||||
*/
|
||||
// 查询会员的绑定vin列表 2024年7月30日11点04分 以当前请求会员的VIN为准
|
||||
List<MemberPlateNumberVO> plateNumberVOList = memberPlateNumberRelationService.selectMemberPlateNumberRelation(dto.getMemberId());
|
||||
List<String> vinCodes = Lists.newArrayList();
|
||||
@@ -457,10 +456,7 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
while (vinCodes.size() < 3) {
|
||||
vinCodes.add("");
|
||||
}
|
||||
|
||||
String type = StringUtils.equals(pileReservationInfo.getReservationType(), "single") ? "00" : "01";
|
||||
|
||||
// 发送指令
|
||||
ReservationChargingCommand command = ReservationChargingCommand.builder()
|
||||
.transactionCode(Constants.ILLEGAL_TRANSACTION_CODE)
|
||||
.pileSn(pileReservationInfo.getPileSn())
|
||||
@@ -476,6 +472,11 @@ public class PileReservationInfoServiceImpl implements PileReservationInfoServic
|
||||
.amount(Constants.WHITELIST_DEFAULT_AMOUNT)
|
||||
.build();
|
||||
pileRemoteService.reservationCharging(command);
|
||||
|
||||
// 从redis中获取回复, 3秒没有获取到判为超时
|
||||
|
||||
|
||||
this.insertOrUpdateSelective(pileReservationInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_RESTART_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_CONTROL_START_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_STOP_CHARGING_CODE.getBytes()),
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_CODE.getBytes())
|
||||
YKCUtils.frameType2Str(YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE.getBytes())
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -539,7 +539,7 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
reservationTypeByteArr, verifyIdentityByteArr, vin1ByteArr, vin2ByteArr, vin3ByteArr,
|
||||
reservedStartTimeByteArr, reservedEndTimeByteArr, amountByteArr);
|
||||
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVATION_CHARGING_CODE);
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.RESERVATION_CHARGING_SETUP_CODE);
|
||||
|
||||
log.info("【=====平台下发指令=====】: 预约充电指令, 交易流水号:{}, 桩编号:{}, 枪口号:{}, 操作:{}, 身份验证:{}, 开始时间:{}, 结束时间:{}, 启动金额:{}",
|
||||
transactionCode, pileSn, connectorCode, operation, verifyIdentity, DateUtils.formatDateTime(reservedStartTime), DateUtils.formatDateTime(reservedEndTime), amount);
|
||||
|
||||
@@ -203,7 +203,7 @@
|
||||
t2.data_secret as dataSecret,
|
||||
t2.data_secret_IV as dataSecretIv
|
||||
from thirdparty_station_relation t1
|
||||
join thirdparty_setting_info t2 on t1.third_party_type = t2.type
|
||||
join thirdparty_setting_info t2 on t1.third_party_type = t2.type
|
||||
where t1.del_flag = '0'
|
||||
<if test="stationId != null">
|
||||
and t1.station_id = #{stationId,jdbcType=BIGINT}
|
||||
|
||||
Reference in New Issue
Block a user