Merge branch 'dev-new' into dev-new-rabbitmq

# Conflicts:
#	jsowell-admin/src/test/java/SpringBootTestController.java
This commit is contained in:
Guoqs
2024-11-29 15:32:19 +08:00
16 changed files with 350 additions and 18 deletions

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