mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 算法应用Service
This commit is contained in:
39
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChargeAlgorithmController.java
vendored
Normal file
39
jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChargeAlgorithmController.java
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.jsowell.api.thirdparty;
|
||||
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.response.RestApiResponse;
|
||||
import com.jsowell.thirdparty.platform.service.impl.ChargeAlgorithmService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 算法应用Controller
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2024/12/17 15:20:36
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/chargealgorithm")
|
||||
public class ChargeAlgorithmController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ChargeAlgorithmService chargeAlgorithmService;
|
||||
|
||||
@GetMapping("/pushOrderInfo/{orderCode}")
|
||||
public RestApiResponse<?> pushOrderInfo(@PathVariable("orderCode") String orderCode) {
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
String result = chargeAlgorithmService.pushOrderInfo(orderCode);
|
||||
response = new RestApiResponse<>(result);
|
||||
}catch (Exception e) {
|
||||
logger.error("算法应用推送订单信息 error, ", e);
|
||||
response = new RestApiResponse<>(e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.*;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -44,24 +46,30 @@ public class ChargeAlgorithmService {
|
||||
* 推送充电订单数据
|
||||
* @param orderCode
|
||||
*/
|
||||
public void pushOrderInfo(String orderCode) {
|
||||
public String pushOrderInfo(String orderCode) {
|
||||
// 根据订单号查询订单信息
|
||||
OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(orderCode);
|
||||
if (orderVO == null) {
|
||||
return;
|
||||
return "订单信息为空";
|
||||
}
|
||||
// 计算充电时长
|
||||
long chargingTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime());
|
||||
String transactionCode = orderVO.getTransactionCode();
|
||||
|
||||
// 获取0x15
|
||||
String chargingHandshakeKey = CacheConstants.CHARGING_HANDSHAKE_DATA_BY_TRANSACTION_CODE + transactionCode;
|
||||
ChargingHandshakeData chargingHandshakeData = redisCache.getCacheObject(chargingHandshakeKey);
|
||||
if (chargingHandshakeData == null) {
|
||||
return "0x15信息为空";
|
||||
}
|
||||
|
||||
// 获取0x17
|
||||
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE + transactionCode;
|
||||
ParameterConfigData parameterConfigData = redisCache.getCacheObject(redisKey);
|
||||
if (parameterConfigData == null) {
|
||||
return;
|
||||
return "0x17信息为空";
|
||||
}
|
||||
|
||||
// 获取0x3b缓存信息
|
||||
String transactionDataKey = CacheConstants.TRANSACTION_RECORD_BY_TRANSACTION_CODE + transactionCode;
|
||||
TransactionRecordsData transactionRecordsData = redisCache.getCacheObject(transactionDataKey);
|
||||
@@ -69,33 +77,33 @@ public class ChargeAlgorithmService {
|
||||
// 获取最后一条0x23
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = pileBasicInfoService.getBMSDemandAndChargerOutputInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
return;
|
||||
return "0x23信息为空";
|
||||
}
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = chargerOutputInfoList.get(0);
|
||||
|
||||
// 获取最后一条0x13
|
||||
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(transactionCode);
|
||||
if (CollectionUtils.isEmpty(chargingRealTimeDataList)) {
|
||||
return;
|
||||
}
|
||||
RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
|
||||
// List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(transactionCode);
|
||||
// if (CollectionUtils.isEmpty(chargingRealTimeDataList)) {
|
||||
// return "0x13信息为空";
|
||||
// }
|
||||
// RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0);
|
||||
|
||||
// 获取最后一条0x25
|
||||
List<BMSChargeInfoData> bmsChargeInfoList = pileBasicInfoService.getBMSChargeInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(bmsChargeInfoList)) {
|
||||
return;
|
||||
return "0x25信息为空";
|
||||
}
|
||||
BMSChargeInfoData bmsChargeInfoData = bmsChargeInfoList.get(0);
|
||||
|
||||
ChargeAlgorithmData data = ChargeAlgorithmData.builder()
|
||||
.orderCode(orderCode)
|
||||
.initSoc(Integer.parseInt(orderVO.getStartSoc()))
|
||||
.currentSoc(Integer.parseInt(orderVO.getEndSoc()))
|
||||
.initSoc(new BigDecimal(orderVO.getStartSoc()).intValue())
|
||||
.currentSoc(new BigDecimal(orderVO.getEndSoc()).intValue())
|
||||
.alarmCode(Constants.ZERO)
|
||||
.currentServiceFee(String.valueOf(orderVO.getTotalServiceAmount()))
|
||||
.currentTotalFee(String.valueOf(orderVO.getOrderAmount()))
|
||||
.totalCharge(orderVO.getTotalPower())
|
||||
.totalChargeTime(Integer.parseInt(orderVO.getChargingTime()))
|
||||
.totalChargeTime(Math.toIntExact(chargingTime))
|
||||
.remainChargeTime(Constants.zero)
|
||||
.maxAllowElectricity(parameterConfigData.getBmsMaxCurrent())
|
||||
.singleMaxAllowVoltage(parameterConfigData.getBmsMaxVoltage())
|
||||
@@ -118,12 +126,13 @@ public class ChargeAlgorithmService {
|
||||
.singleMinTemp(bmsChargeInfoData.getMinBatteryTemperature()) // 单体最低温度
|
||||
// .ventTemp() // 出风口温度
|
||||
// .environmentTemp() // 环境温度
|
||||
.gunTemp(realTimeMonitorData.getGunLineCode()) // 充电枪温度
|
||||
// .gunTemp(realTimeMonitorData.getGunLineTemperature()) // 充电枪温度
|
||||
.gunTemp("0") // 充电枪温度
|
||||
.doorStatus(Constants.zero) // 舱门状态
|
||||
.bmsVersion("V1.1") // BMS版本
|
||||
.measuringChargeVoltage(bmsDemandAndChargerOutputData.getBmsChargingVoltage()) // 车辆测量充电电压
|
||||
.measuringChargeElectricity(bmsDemandAndChargerOutputData.getBmsChargingCurrent()) // 车辆测量充电电流
|
||||
.maxSingleVoltageGroupNum(Integer.parseInt(bmsDemandAndChargerOutputData.getBmsMaxVoltageAndGroup())) // 最高单体电压组号
|
||||
.maxSingleVoltageGroupNum(new BigDecimal(bmsDemandAndChargerOutputData.getBmsMaxVoltageAndGroup()).intValue()) // 最高单体电压组号
|
||||
.maxSingleVoltageNum(Integer.parseInt(bmsChargeInfoData.getBmsMaxVoltageNum())) // 最高单体电压编号
|
||||
.maxTempPointNum(Integer.parseInt(bmsChargeInfoData.getMaxTemperatureDetectionNum())) // 最高温度点编号
|
||||
.minTempPointNum(Integer.parseInt(bmsChargeInfoData.getMinTemperatureDetectionNum())) // 最低温度点编号
|
||||
@@ -134,20 +143,14 @@ public class ChargeAlgorithmService {
|
||||
|
||||
.build();
|
||||
|
||||
if (StringUtils.isNotBlank(orderVO.getStartSoc())) {
|
||||
data.setInitSoc(Integer.parseInt(orderVO.getStartSoc()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(orderVO.getEndSoc())) {
|
||||
data.setCurrentSoc(Integer.parseInt(orderVO.getEndSoc()));
|
||||
}
|
||||
|
||||
log.info("发送请求前封装数据 data:{}", JSON.toJSONString(data));
|
||||
|
||||
String url = "http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json";
|
||||
String clientId = "";
|
||||
String clientId = "e488bac5f70b496fa2d82065089e5f81";
|
||||
// 发送请求
|
||||
String response = HttpRequest.post(url).header("clientId", clientId).body(JSON.toJSONString(data)).execute().body();
|
||||
|
||||
log.info("发送请求收到回复 response:{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user