mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-27 18:47:58 +08:00
update 算法应用Service
This commit is contained in:
@@ -155,6 +155,11 @@ public class CacheConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String PILE_IS_CHARGING = "pile_is_charging:";
|
public static final String PILE_IS_CHARGING = "pile_is_charging:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0x17参数配置缓存
|
||||||
|
*/
|
||||||
|
public static final String PARAMETER_CONFIGURATION_BY_TRANSACTIONCODE = "ParameterConfigurationByTransactionCode:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电桩最后连接时间
|
* 充电桩最后连接时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package com.jsowell.netty.handler.yunkuaichong;
|
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.YKCDataProtocol;
|
||||||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
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.BytesUtil;
|
||||||
import com.jsowell.common.util.YKCUtils;
|
import com.jsowell.common.util.YKCUtils;
|
||||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||||
|
import com.jsowell.pile.thirdparty.ParameterConfigData;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -14,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数配置 Handler
|
* 参数配置 Handler
|
||||||
@@ -28,6 +32,9 @@ public class ParameterConfigurationHandler extends AbstractYkcHandler {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderBasicInfoService orderBasicInfoService;
|
private OrderBasicInfoService orderBasicInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.PARAMETER_CONFIGURATION_CODE.getBytes());
|
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.PARAMETER_CONFIGURATION_CODE.getBytes());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,6 +128,27 @@ public class ParameterConfigurationHandler extends AbstractYkcHandler {
|
|||||||
byte[] pileMinOutputCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
byte[] pileMinOutputCurrentByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
String pileMinOutputCurrent = String.valueOf(BytesUtil.bytesToIntLittle(pileMinOutputCurrentByteArr) * 0.1 - 400);
|
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传入
|
// 查询该订单下信息,将起始soc传入
|
||||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
||||||
if (Objects.nonNull(orderInfo)) {
|
if (Objects.nonNull(orderInfo)) {
|
||||||
|
|||||||
88
jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ParameterConfigData.java
vendored
Normal file
88
jsowell-pile/src/main/java/com/jsowell/pile/thirdparty/ParameterConfigData.java
vendored
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.jsowell.thirdparty.platform.service.impl;
|
package com.jsowell.thirdparty.platform.service.impl;
|
||||||
|
|
||||||
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
import com.jsowell.common.constant.Constants;
|
import com.jsowell.common.constant.Constants;
|
||||||
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||||
|
import com.jsowell.pile.thirdparty.ParameterConfigData;
|
||||||
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
||||||
import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData;
|
import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -21,6 +24,9 @@ public class ChargeAlgorithmService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderBasicInfoService orderBasicInfoService;
|
private OrderBasicInfoService orderBasicInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送充电订单数据
|
* 推送充电订单数据
|
||||||
* @param orderCode
|
* @param orderCode
|
||||||
@@ -28,6 +34,15 @@ public class ChargeAlgorithmService {
|
|||||||
public void pushOrderInfo(String orderCode) {
|
public void pushOrderInfo(String orderCode) {
|
||||||
// 根据订单号查询订单信息
|
// 根据订单号查询订单信息
|
||||||
OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(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()
|
ChargeAlgorithmData data = ChargeAlgorithmData.builder()
|
||||||
.orderCode(orderCode)
|
.orderCode(orderCode)
|
||||||
@@ -39,23 +54,23 @@ public class ChargeAlgorithmService {
|
|||||||
.totalCharge(orderVO.getTotalPower())
|
.totalCharge(orderVO.getTotalPower())
|
||||||
.totalChargeTime(Integer.parseInt(orderVO.getChargingTime()))
|
.totalChargeTime(Integer.parseInt(orderVO.getChargingTime()))
|
||||||
.remainChargeTime(Constants.zero)
|
.remainChargeTime(Constants.zero)
|
||||||
// .maxAllowElectricity()
|
.maxAllowElectricity(parameterConfigData.getBmsMaxCurrent())
|
||||||
// .singleMaxAllowVoltage()
|
.singleMaxAllowVoltage(parameterConfigData.getBmsMaxVoltage())
|
||||||
// .dcv()
|
// .dcv()
|
||||||
// .dca()
|
// .dca()
|
||||||
// .bmsDemandVoltage()
|
// .bmsDemandVoltage(parameterConfigData.get)
|
||||||
// .bmsDemandElectricity()
|
// .bmsDemandElectricity()
|
||||||
// .bmsChargeMode()
|
// .bmsChargeMode()
|
||||||
// .readBeforeCharge()
|
// .readBeforeCharge()
|
||||||
// .readCurrentCharge()
|
// .readCurrentCharge()
|
||||||
// .beginTime()
|
.beginTime(orderVO.getStartTime())
|
||||||
// .maxAllowTemp()
|
.maxAllowTemp(parameterConfigData.getBmsMaxTemperature())
|
||||||
// .chargePower()
|
// .chargePower()
|
||||||
// .ratedCapacity()
|
// .ratedCapacity()
|
||||||
// .nominalEnergy()
|
// .nominalEnergy()
|
||||||
// .ratedVoltage()
|
// .ratedVoltage()
|
||||||
// .singleMaxVoltage()
|
.singleMaxVoltage(parameterConfigData.getPileMaxOutputVoltage())
|
||||||
// .singleMinVoltage()
|
.singleMinVoltage(parameterConfigData.getPileMinOutputVoltage())
|
||||||
// .singleMaxTemp()
|
// .singleMaxTemp()
|
||||||
// .ventTemp()
|
// .ventTemp()
|
||||||
// .environmentTemp()
|
// .environmentTemp()
|
||||||
@@ -70,7 +85,7 @@ public class ChargeAlgorithmService {
|
|||||||
// .minTempPointNum()
|
// .minTempPointNum()
|
||||||
// .batteryType()
|
// .batteryType()
|
||||||
// .batteryInsulation()
|
// .batteryInsulation()
|
||||||
// .maxAllowTotalVoltage()
|
.maxAllowTotalVoltage(parameterConfigData.getBmsMaxChargingVoltage())
|
||||||
// .beforeChargeTotalVoltage()
|
// .beforeChargeTotalVoltage()
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user