update 算法应用Service

This commit is contained in:
Lemon
2024-11-29 10:04:52 +08:00
parent 8f650843e3
commit d4fa00bb88
4 changed files with 144 additions and 8 deletions

View File

@@ -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:";
/**
* 充电桩最后连接时间
*/

View File

@@ -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)) {

View File

@@ -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;
}

View File

@@ -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();