update 算法应用Service

This commit is contained in:
Lemon
2024-12-02 10:08:32 +08:00
parent 9abaf38542
commit ecdecbaf74
5 changed files with 23 additions and 8 deletions

View File

@@ -158,7 +158,7 @@ public class CacheConstants {
/**
* 0x17参数配置缓存
*/
public static final String PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE = "ParameterConfigurationByTransactionCode:";
public static final String PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE = "parameter_configuration_by_transaction_code:";
/**
* 充电桩最后连接时间
@@ -170,6 +170,11 @@ public class CacheConstants {
*/
public static final String SELECT_PILE_CONNECTOR_INFO_LIST = "select_pile_connector_info_list:";
/**
* 0x3b交易记录缓存key
*/
public static final String TRANSACTION_RECORD_BY_TRANSACTION_CODE = "transaction_record_by_transaction_code:";
/**
* 充电桩状态前缀
*/

View File

@@ -51,12 +51,14 @@ public class ChargingHandshakeHandler extends AbstractYkcHandler {
startIndex += length;
length = 1;
byte[] pileConnectorNumByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String connectorCode = BytesUtil.bcd2Str(pileConnectorNumByteArr);
// BMS 通信协议版本号 当前版本为 V1.1 表示为: byte3 byte2—0001Hbyte1—01H
startIndex += length;
length = 3;
byte[] BMSCommunicationProtocolVersionByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
// BMS 电池类型 01H:铅酸电池;02H:氢 电池;03H:磷酸铁锂电池;04H:锰 酸锂电池;05H:钴酸锂电池 ;06H: 三元材料电池;07H:聚合物锂离子 电池;08H:钛酸锂电池;FFH:其他
startIndex += length;
length = 1;

View File

@@ -15,7 +15,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@@ -146,7 +145,7 @@ public class ParameterConfigurationHandler extends AbstractYkcHandler {
.pileMinOutputCurrent(pileMinOutputCurrent)
.build();
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE + transactionCode;
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE + transactionCode;
redisCache.setCacheObject(redisKey, data, 7, TimeUnit.DAYS);
// 查询该订单下信息将起始soc传入

View File

@@ -33,6 +33,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
/**
* 交易记录确认
@@ -562,6 +563,10 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler {
.logicCard(logicCard)
.build();
// 保存交易记录到redis (缓存时间1天)
String recordRedisKey = CacheConstants.TRANSACTION_RECORD_BY_TRANSACTION_CODE + transactionCode;
redisCache.setCacheObject(recordRedisKey, data, 1, TimeUnit.DAYS);
// 保存报文
String jsonMsg = JSON.toJSONString(data);
pileMsgRecordService.save(pileSn, pileSn + connectorCode, type, jsonMsg, ykcDataProtocol.getHEXString());

View File

@@ -2,9 +2,9 @@ package com.jsowell.thirdparty.platform.service.impl;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
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;
@@ -37,12 +37,16 @@ public class ChargeAlgorithmService {
if (orderVO == null) {
return;
}
String transactionCode = orderVO.getTransactionCode();
// 获取0x17缓存中的信息
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE + orderVO.getTransactionCode();
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE + transactionCode;
ParameterConfigData parameterConfigData = redisCache.getCacheObject(redisKey);
if (parameterConfigData == null) {
return;
}
// 获取0x3b缓存信息
String transactionDataKey = CacheConstants.TRANSACTION_RECORD_BY_TRANSACTION_CODE + transactionCode;
TransactionRecordsData transactionRecordsData = redisCache.getCacheObject(transactionDataKey);
ChargeAlgorithmData data = ChargeAlgorithmData.builder()
.orderCode(orderCode)
@@ -61,13 +65,13 @@ public class ChargeAlgorithmService {
// .bmsDemandVoltage(parameterConfigData.get)
// .bmsDemandElectricity()
// .bmsChargeMode()
// .readBeforeCharge()
// .readCurrentCharge()
.readBeforeCharge(transactionRecordsData.getAmmeterTotalStart())
.readCurrentCharge(transactionRecordsData.getAmmeterTotalEnd())
.beginTime(orderVO.getStartTime())
.maxAllowTemp(parameterConfigData.getBmsMaxTemperature())
// .chargePower()
// .ratedCapacity()
// .nominalEnergy()
.nominalEnergy(parameterConfigData.getBmsSumEnergy())
// .ratedVoltage()
.singleMaxVoltage(parameterConfigData.getPileMaxOutputVoltage())
.singleMinVoltage(parameterConfigData.getPileMinOutputVoltage())