mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
新增 云快充协议查询、设置参数帧
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package com.jsowell.netty.command.ykc;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 0x26 平台査询工作参数
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/4/4 9:20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class QueryWorkParamsCommand {
|
||||
/**
|
||||
* 桩编码
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 桩类型 0x00:直流0x01:交流
|
||||
*/
|
||||
private String pileType;
|
||||
|
||||
/**
|
||||
* 最大充电电压
|
||||
*/
|
||||
private String maxChargingVoltage;
|
||||
|
||||
/**
|
||||
* 最大充电电流
|
||||
*/
|
||||
private String maxChargingCurrent;
|
||||
|
||||
/**
|
||||
* 最大充电功率
|
||||
*/
|
||||
private String maxChargingPower;
|
||||
|
||||
/**
|
||||
* 当前充电电压
|
||||
*/
|
||||
private String instantChargingVoltage;
|
||||
|
||||
/**
|
||||
* 当前充电电流
|
||||
*/
|
||||
private String instantChargingCurrent;
|
||||
|
||||
/**
|
||||
* 当前充电功率
|
||||
*/
|
||||
private String instantChargingPower;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.jsowell.netty.handler;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 0x27 充电桩査询工作参数回复
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/4/4 10:06
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class QueryPileWorkParamsHandler extends AbstractHandler{
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_ANSWER_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
||||
log.info("[====充电桩査询工作参数回复====] param:{}", JSONObject.toJSONString(ykcDataProtocol));
|
||||
// 获取消息体
|
||||
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||||
|
||||
int startIndex = 0;
|
||||
int length = 7;
|
||||
|
||||
// 桩编码
|
||||
byte[] pileSnByte = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileSn = BytesUtil.binary(pileSnByte, 16);
|
||||
|
||||
// 保存时间
|
||||
saveLastTime(pileSn);
|
||||
|
||||
// 充电桩类型 0x00:直流0x01:交流
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] pileTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileType = BytesUtil.bcd2Str(pileTypeByteArr);
|
||||
|
||||
// 最高充电电压 精确到小数点后一位;待机置零
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] maxChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxChargingVoltage = YKCUtils.convertVoltageCurrent(maxChargingVoltageByteArr);
|
||||
|
||||
// 最高充电电流
|
||||
startIndex += length;
|
||||
byte[] maxChargingCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxChargingCurrent = YKCUtils.convertVoltageCurrent(maxChargingCurrentByteArr);
|
||||
|
||||
// 最大充电功率
|
||||
startIndex += length;
|
||||
byte[] maxChargingPowerByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxChargingPower = YKCUtils.convertVoltageCurrent(maxChargingPowerByteArr);
|
||||
|
||||
// 当前充电电压
|
||||
startIndex += length;
|
||||
byte[] instantChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String instantChargingVoltage = YKCUtils.convertVoltageCurrent(instantChargingVoltageByteArr);
|
||||
|
||||
// 当前充电电流
|
||||
startIndex += length;
|
||||
byte[] instantChargingCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String instantChargingCurrent = YKCUtils.convertVoltageCurrent(instantChargingCurrentByteArr);
|
||||
|
||||
// 当前充电功率
|
||||
startIndex += length;
|
||||
byte[] instantChargingPowerByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String instantChargingPower = YKCUtils.convertVoltageCurrent(instantChargingPowerByteArr);
|
||||
|
||||
log.info("[====充电桩査询工作参数回复====] 桩编号:{}, 充电桩类型:{}, 最大充电电压:{}, 最高充电电流:{}, " +
|
||||
"最大充电功率:{}, 当前充电电压:{}, 当前充电电流:{}, 当前充电功率:{}",
|
||||
pileSn, pileType, maxChargingVoltage, maxChargingCurrent, maxChargingPower, instantChargingVoltage,
|
||||
instantChargingCurrent, instantChargingPower);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.jsowell.netty.handler;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 0x29 平台设置工作参数回复
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/4/4 13:43
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SettingPileWorkParamsHandler extends AbstractHandler{
|
||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.SETTING_PILE_WORK_PARAMS_ANSWER_CODE.getBytes());
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
||||
log.info("[====平台设置工作参数回复====] param:{}", JSONObject.toJSONString(ykcDataProtocol));
|
||||
// 获取消息体
|
||||
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||||
|
||||
int startIndex = 0;
|
||||
int length = 7;
|
||||
|
||||
// 桩编码
|
||||
byte[] pileSnByte = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileSn = BytesUtil.binary(pileSnByte, 16);
|
||||
|
||||
// 保存时间
|
||||
saveLastTime(pileSn);
|
||||
|
||||
// 设置状态 0x00-成功 0x01-失败
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
byte[] settingStatusByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String settingStatus = BytesUtil.bcd2Str(settingStatusByteArr);
|
||||
|
||||
// 充电桩类型 0x00:直流 0x01:交流
|
||||
startIndex += length;
|
||||
byte[] pileTypeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String pileType = BytesUtil.bcd2Str(pileTypeByteArr);
|
||||
|
||||
// 最高充电电压 精确到小数点后一位;待机置零
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
byte[] maxChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxChargingVoltage = YKCUtils.convertVoltageCurrent(maxChargingVoltageByteArr);
|
||||
|
||||
// 最高充电电流
|
||||
startIndex += length;
|
||||
byte[] maxChargingCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxChargingCurrent = YKCUtils.convertVoltageCurrent(maxChargingCurrentByteArr);
|
||||
|
||||
// 最大充电功率
|
||||
startIndex += length;
|
||||
byte[] maxChargingPowerByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String maxChargingPower = YKCUtils.convertVoltageCurrent(maxChargingPowerByteArr);
|
||||
|
||||
// 当前充电电压
|
||||
startIndex += length;
|
||||
byte[] instantChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String instantChargingVoltage = YKCUtils.convertVoltageCurrent(instantChargingVoltageByteArr);
|
||||
|
||||
// 当前充电电流
|
||||
startIndex += length;
|
||||
byte[] instantChargingCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String instantChargingCurrent = YKCUtils.convertVoltageCurrent(instantChargingCurrentByteArr);
|
||||
|
||||
// 当前充电功率
|
||||
startIndex += length;
|
||||
byte[] instantChargingPowerByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||
String instantChargingPower = YKCUtils.convertVoltageCurrent(instantChargingPowerByteArr);
|
||||
|
||||
log.info("[====平台设置工作参数回复====] 桩编号:{}, 设置状态:{}, 充电桩类型:{}, 最大充电电压:{}, 最高充电电流:{}, " +
|
||||
"最大充电功率:{}, 当前充电电压:{}, 当前充电电流:{}, 当前充电功率:{}",
|
||||
pileSn, settingStatus, pileType, maxChargingVoltage, maxChargingCurrent, maxChargingPower, instantChargingVoltage,
|
||||
instantChargingCurrent, instantChargingPower);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,6 @@
|
||||
package com.jsowell.netty.service.yunkuaichong;
|
||||
|
||||
import com.jsowell.netty.command.ykc.GetRealTimeMonitorDataCommand;
|
||||
import com.jsowell.netty.command.ykc.IssueQRCodeCommand;
|
||||
import com.jsowell.netty.command.ykc.PileSettingCommand;
|
||||
import com.jsowell.netty.command.ykc.ProofreadTimeCommand;
|
||||
import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand;
|
||||
import com.jsowell.netty.command.ykc.RebootCommand;
|
||||
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.StopChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.UpdateFileCommand;
|
||||
import com.jsowell.netty.command.ykc.*;
|
||||
|
||||
/**
|
||||
* 云快充协议,向充电桩发送命令service
|
||||
@@ -67,4 +59,10 @@ public interface YKCPushCommandService {
|
||||
* 发送充电桩设置命令
|
||||
*/
|
||||
void pushPileSettingCommand(PileSettingCommand command);
|
||||
|
||||
/**
|
||||
* 平台査询工作参数
|
||||
* @param command
|
||||
*/
|
||||
void pushQueryWorkParamsCommand(QueryWorkParamsCommand command);
|
||||
}
|
||||
|
||||
@@ -6,21 +6,15 @@ import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.ykc.PileChannelEntity;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.CRC16Util;
|
||||
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.command.ykc.GetRealTimeMonitorDataCommand;
|
||||
import com.jsowell.netty.command.ykc.IssueQRCodeCommand;
|
||||
import com.jsowell.netty.command.ykc.PileSettingCommand;
|
||||
import com.jsowell.netty.command.ykc.ProofreadTimeCommand;
|
||||
import com.jsowell.netty.command.ykc.PublishPileBillingTemplateCommand;
|
||||
import com.jsowell.netty.command.ykc.RebootCommand;
|
||||
import com.jsowell.netty.command.ykc.StartChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.StopChargingCommand;
|
||||
import com.jsowell.netty.command.ykc.UpdateFileCommand;
|
||||
import com.jsowell.netty.command.ykc.*;
|
||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBillingTemplateService;
|
||||
@@ -377,4 +371,30 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.CHARGING_PILE_WORKING_PARAMETER_SETTING_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台査询工作参数
|
||||
* @param command
|
||||
*/
|
||||
@Override
|
||||
public void pushQueryWorkParamsCommand(QueryWorkParamsCommand command) {
|
||||
// 桩编号
|
||||
String pileSn = command.getPileSn();
|
||||
byte[] pileSnByteArr = BytesUtil.str2Bcd(pileSn);
|
||||
// 桩类型
|
||||
byte[] pileType = Constants.oneByteArray;
|
||||
PileModelInfoVO info = pileModelInfoService.getPileModelInfoByPileSn(pileSn);
|
||||
if (info == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
|
||||
}
|
||||
String chargerPileType = info.getChargerPileType();
|
||||
if (StringUtils.equals("1", chargerPileType)) {
|
||||
// 直流
|
||||
pileType = Constants.zeroByteArray;
|
||||
}
|
||||
// 拼装msg信息
|
||||
byte[] msg = Bytes.concat(pileSnByteArr, pileType);
|
||||
|
||||
this.push(msg, pileSn, YKCFrameTypeCode.QUERY_PILE_WORK_PARAMS_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user