diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index 6d5c6822a..39657f815 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -155,6 +155,11 @@ public class CacheConstants { */ public static final String PILE_IS_CHARGING = "pile_is_charging:"; + /** + * 0x17参数配置缓存 + */ + public static final String PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE = "ParameterConfigurationByTransactionCode:"; + /** * 充电桩最后连接时间 */ diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ParameterConfigurationHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ParameterConfigurationHandler.java index 544e6fd92..2d89ebfc8 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ParameterConfigurationHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/ParameterConfigurationHandler.java @@ -1,12 +1,15 @@ package com.jsowell.netty.handler.yunkuaichong; +import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; +import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.YKCUtils; import com.jsowell.netty.factory.YKCOperateFactory; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; +import com.jsowell.pile.thirdparty.ParameterConfigData; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -14,6 +17,7 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.util.Objects; +import java.util.concurrent.TimeUnit; /** * 参数配置 Handler @@ -28,6 +32,9 @@ public class ParameterConfigurationHandler extends AbstractYkcHandler { @Autowired private OrderBasicInfoService orderBasicInfoService; + @Autowired + private RedisCache redisCache; + private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.PARAMETER_CONFIGURATION_CODE.getBytes()); @Override @@ -121,6 +128,27 @@ public class ParameterConfigurationHandler extends AbstractYkcHandler { byte[] pileMinOutputCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length); String pileMinOutputCurrent = String.valueOf(BytesUtil.bytesToIntLittle(pileMinOutputCurrentByteArr) * 0.1 - 400); + // 将解析出的信息存入缓存(过期时间7天) + ParameterConfigData data = ParameterConfigData.builder() + .transactionCode(transactionCode) + .pileSn(pileSn) + .pileConnectorCode(pileConnectorCode) + .bmsMaxVoltage(BMSMaxVoltage) + .bmsMaxCurrent(BMSMaxCurrent) + .bmsSumEnergy(BMSSumEnergy) + .bmsMaxChargingVoltage(BMSMaxChargingVoltage) + .bmsMaxTemperature(BMSMaxTemperature) + .soc(soc) + .bmsRealTimeVoltage(BMSRealTimeVoltage) + .pileMaxOutputVoltage(pileMaxOutputVoltage) + .pileMinOutputVoltage(pileMinOutputVoltage) + .pileMaxOutputCurrent(pileMaxOutputCurrent) + .pileMinOutputCurrent(pileMinOutputCurrent) + + .build(); + String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE + transactionCode; + redisCache.setCacheObject(redisKey, data, 7, TimeUnit.DAYS); + // 查询该订单下信息,将起始soc传入 OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); if (Objects.nonNull(orderInfo)) { diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ParameterConfigData.java b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ParameterConfigData.java new file mode 100644 index 000000000..0d2c069d2 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ParameterConfigData.java @@ -0,0 +1,88 @@ +package com.jsowell.pile.thirdparty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 0x17参数配置对象 + * + * @author Lemon + * @Date 2024/11/28 14:43:28 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class ParameterConfigData { + /** + * 交易流水号 + */ + private String transactionCode; + + /** + * 桩编码 + */ + private String pileSn; + + /** + * 枪号 + */ + private String pileConnectorCode; + + /** + * BMS 单体动力蓄电池最高允许充电电压 0.01 V/位, 0 V 偏移量; 数据范围: 0~24 V + */ + private String bmsMaxVoltage; + + /** + * BMS 最高允许充电电流 0.1 A/位, -400A 偏移量 + */ + private String bmsMaxCurrent; + + /** + * BMS 动力蓄电池标称总能量 0.1 kWh/位, 0 kWh 偏移量; 数据范围: 0~1000 kWh + */ + private String bmsSumEnergy; + + /** + * BMS 最高允许充电总电压 0.1 V/位, 0 V 偏移量 + */ + private String bmsMaxChargingVoltage; + + /** + * BMS 最高允许温度 1ºC/位, -50 ºC 偏移量;数据范 围: -50 ºC ~+200 ºC + */ + private String bmsMaxTemperature; + + /** + * BMS 整车动力 蓄电池荷电状态(soc) 0.1%/位, 0%偏移量;数据范围: 0~100% + */ + private String soc; + + /** + * BMS 整车动力蓄电池当前电池电压 整车动力蓄电池总电压 + */ + private String bmsRealTimeVoltage; + + /** + * 电桩最高输出电压 0.1 V /位, 0 V 偏移量 + */ + private String pileMaxOutputVoltage; + + /** + * 电桩最低输出电压 0.1 V /位, 0 V 偏移量 + */ + private String pileMinOutputVoltage; + + /** + * 电桩最大输出电流 0.1 A/位, -400 A 偏移量 + */ + private String pileMaxOutputCurrent; + + /** + * 电桩最小输出电流 0.1 A/位, -400 A 偏移量 + */ + private String pileMinOutputCurrent; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java index aa597e21a..485a2518a 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java @@ -1,9 +1,12 @@ package com.jsowell.thirdparty.platform.service.impl; +import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; +import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.service.OrderBasicInfoService; +import com.jsowell.pile.thirdparty.ParameterConfigData; import com.jsowell.pile.vo.uniapp.customer.OrderVO; import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData; import org.springframework.beans.factory.annotation.Autowired; @@ -21,6 +24,9 @@ public class ChargeAlgorithmService { @Autowired private OrderBasicInfoService orderBasicInfoService; + @Autowired + private RedisCache redisCache; + /** * 推送充电订单数据 * @param orderCode @@ -28,6 +34,15 @@ public class ChargeAlgorithmService { public void pushOrderInfo(String orderCode) { // 根据订单号查询订单信息 OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(orderCode); + if (orderVO == null) { + return; + } + // 获取0x17缓存中的信息 + String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE + orderVO.getTransactionCode(); + ParameterConfigData parameterConfigData = redisCache.getCacheObject(redisKey); + if (parameterConfigData == null) { + return; + } ChargeAlgorithmData data = ChargeAlgorithmData.builder() .orderCode(orderCode) @@ -39,23 +54,23 @@ public class ChargeAlgorithmService { .totalCharge(orderVO.getTotalPower()) .totalChargeTime(Integer.parseInt(orderVO.getChargingTime())) .remainChargeTime(Constants.zero) - // .maxAllowElectricity() - // .singleMaxAllowVoltage() + .maxAllowElectricity(parameterConfigData.getBmsMaxCurrent()) + .singleMaxAllowVoltage(parameterConfigData.getBmsMaxVoltage()) // .dcv() // .dca() - // .bmsDemandVoltage() + // .bmsDemandVoltage(parameterConfigData.get) // .bmsDemandElectricity() // .bmsChargeMode() // .readBeforeCharge() // .readCurrentCharge() - // .beginTime() - // .maxAllowTemp() + .beginTime(orderVO.getStartTime()) + .maxAllowTemp(parameterConfigData.getBmsMaxTemperature()) // .chargePower() // .ratedCapacity() // .nominalEnergy() // .ratedVoltage() - // .singleMaxVoltage() - // .singleMinVoltage() + .singleMaxVoltage(parameterConfigData.getPileMaxOutputVoltage()) + .singleMinVoltage(parameterConfigData.getPileMinOutputVoltage()) // .singleMaxTemp() // .ventTemp() // .environmentTemp() @@ -70,7 +85,7 @@ public class ChargeAlgorithmService { // .minTempPointNum() // .batteryType() // .batteryInsulation() - // .maxAllowTotalVoltage() + .maxAllowTotalVoltage(parameterConfigData.getBmsMaxChargingVoltage()) // .beforeChargeTotalVoltage() .build();