diff --git a/jsowell-common/src/main/java/com/jsowell/common/core/domain/ykc/YKCFrameTypeCode.java b/jsowell-common/src/main/java/com/jsowell/common/core/domain/ykc/YKCFrameTypeCode.java index 4e8c5a4e2..ff6e7aa80 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/core/domain/ykc/YKCFrameTypeCode.java +++ b/jsowell-common/src/main/java/com/jsowell/common/core/domain/ykc/YKCFrameTypeCode.java @@ -84,6 +84,15 @@ public enum YKCFrameTypeCode { REMOTE_ISSUE_QRCODE_CODE(0xF0, "后台远程下发二维码前缀指令"), REMOTE_ISSUE_QRCODE_ANSWER_CODE(0xF1, "桩应答远程下发二维码前缀指令"), + /** + * 补充内容 + */ + QUERY_PILE_WORK_PARAMS_CODE(0X26, "平台査询工作参数"), + QUERY_PILE_WORK_PARAMS_ANSWER_CODE(0X27, "充电桩査询工作参数回复"), + + SETTING_PILE_WORK_PARAMS_CODE(0x28, " 平台设置工作参数"), + SETTING_PILE_WORK_PARAMS_ANSWER_CODE(0x29, "平台设置工作参数回复"), + // 自定义FrameType PILE_LOG_OUT(9999, "充电桩退出"), diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/QueryWorkParamsCommand.java b/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/QueryWorkParamsCommand.java new file mode 100644 index 000000000..6218f0c99 --- /dev/null +++ b/jsowell-netty/src/main/java/com/jsowell/netty/command/ykc/QueryWorkParamsCommand.java @@ -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; +} diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/QueryPileWorkParamsHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/QueryPileWorkParamsHandler.java new file mode 100644 index 000000000..67d7c1989 --- /dev/null +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/QueryPileWorkParamsHandler.java @@ -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; + } +} diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/SettingPileWorkParamsHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/SettingPileWorkParamsHandler.java new file mode 100644 index 000000000..72d061901 --- /dev/null +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/SettingPileWorkParamsHandler.java @@ -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; + } +} diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java index 53c45c40c..62e9f4367 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/YKCPushCommandService.java @@ -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); } diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java index 74f456a6e..6460f44b3 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/service/yunkuaichong/impl/YKCPushCommandServiceImpl.java @@ -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); + } }