2023-03-04 16:29:55 +08:00
|
|
|
|
package com.jsowell.netty.handler;
|
|
|
|
|
|
|
|
|
|
|
|
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 com.jsowell.pile.domain.OrderBasicInfo;
|
2024-01-06 15:13:50 +08:00
|
|
|
|
import com.jsowell.pile.service.OrderBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import io.netty.channel.Channel;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 参数配置 Handler
|
|
|
|
|
|
*
|
|
|
|
|
|
* GBT-27930 充电桩与 BMS 参数配置阶段报文
|
|
|
|
|
|
* @author JS-ZZA
|
|
|
|
|
|
* @date 2022/9/19 13:24
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
@Component
|
|
|
|
|
|
public class ParameterConfigurationHandler extends AbstractHandler{
|
|
|
|
|
|
@Autowired
|
2024-01-06 15:13:50 +08:00
|
|
|
|
private OrderBasicInfoService orderBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.PARAMETER_CONFIGURATION_CODE.getBytes());
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void afterPropertiesSet() throws Exception {
|
|
|
|
|
|
YKCOperateFactory.register(type, this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
2024-03-19 16:22:40 +08:00
|
|
|
|
// log.info("[===参数配置===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 获取消息体
|
|
|
|
|
|
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
|
|
|
|
|
|
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
|
int length = 16;
|
|
|
|
|
|
|
|
|
|
|
|
// 交易流水号
|
|
|
|
|
|
byte[] serialNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
2023-03-13 16:29:25 +08:00
|
|
|
|
String transactionCode = BytesUtil.bcd2Str(serialNumByteArr);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
// 桩编码
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 7;
|
|
|
|
|
|
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
// 保存时间
|
2023-12-07 16:19:47 +08:00
|
|
|
|
saveLastTimeAndCheckChannel(pileSn, channel);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
// 枪号
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] pileConnectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 单体动力蓄电池最高允许充电电压 0.01 V/位, 0 V 偏移量; 数据范围: 0~24 V
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 2;
|
|
|
|
|
|
byte[] BMSMaxVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 最高允许充电电流 0.1 A/位, -400A 偏移量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] BMSMaxCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 动力蓄电池标称总能量 0.1 kWh/位, 0 kWh 偏移量; 数据范围: 0~1000 kWh
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] BMSSumEnergyByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 最高允许充电总电压 0.1 V/位, 0 V 偏移量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] BMSMaxChargingVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 最高允许温度 1ºC/位, -50 ºC 偏移量;数据范 围: -50 ºC ~+200 ºC
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 1;
|
|
|
|
|
|
byte[] BMSMaxTemperatureByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 整车动力 蓄电池荷电状态(soc) 0.1%/位, 0%偏移量;数据范围: 0~100%
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
length = 2;
|
|
|
|
|
|
byte[] BMSSocByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
String soc = YKCUtils.convertVoltageCurrent(BMSSocByteArr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// BMS 整车动力蓄电池当前电池电压 整车动力蓄电池总电压
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] BMSRealTimeVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// 电桩最高输出电压 0.1 V /位, 0 V 偏移量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] pileMaxOutputVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// 电桩最低输出电压 0.1 V /位, 0 V 偏移量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] pileMinOutputVoltageByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// 电桩最大输出电流 0.1 A/位, -400 A 偏移量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] pileMaxOutputCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
// 电桩最小输出电流 0.1 A/位, -400 A 偏移量
|
|
|
|
|
|
startIndex += length;
|
|
|
|
|
|
byte[] pileMinOutputCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
|
|
|
|
|
|
|
|
|
|
log.info("参数配置, 起始SOC:{}", soc);
|
|
|
|
|
|
|
|
|
|
|
|
// 查询该订单下信息,将起始soc传入
|
2023-03-13 16:29:25 +08:00
|
|
|
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (Objects.nonNull(orderInfo)) {
|
|
|
|
|
|
OrderBasicInfo orderBasicInfo = OrderBasicInfo.builder()
|
|
|
|
|
|
.id(orderInfo.getId())
|
2024-01-06 15:13:50 +08:00
|
|
|
|
.startSoc(soc)
|
2023-03-04 16:29:55 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|