mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
新增 获取电池充电报告pdf文件下载链接方法
This commit is contained in:
102
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData2PDF.java
vendored
Normal file
102
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData2PDF.java
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.jsowell.thirdparty.platform.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电池算法报告获取pdf文件Data
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2025/8/20 15:45:38
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class ChargeAlgorithmData2PDF {
|
||||
private String mfrID;
|
||||
private String siteName;
|
||||
private String siteAddress;
|
||||
private String siteLongitude;
|
||||
private String siteLatitude;
|
||||
private String businessHours;
|
||||
private String serviceHotline;
|
||||
private String businessStatus;
|
||||
private Integer sitePileNumber;
|
||||
private Integer siteGunNumber;
|
||||
private String phone;
|
||||
private String siteCode;
|
||||
private String pileCode;
|
||||
private String gunNo;
|
||||
private String readBeforeCharge;
|
||||
|
||||
private Integer doorStatus;
|
||||
|
||||
private Integer bmsChargeMode;
|
||||
|
||||
|
||||
private String vin;
|
||||
private String batteryType;
|
||||
private String nominalEnergy;
|
||||
private String ratedCapacity;
|
||||
private String ratedVoltage;
|
||||
private String maxAllowTemp;
|
||||
private Integer initSoc;
|
||||
private String orderCode;
|
||||
private String beginTime;
|
||||
private Integer totalChargeTime;
|
||||
private Integer remainChargeTime;
|
||||
private String totalCharge;
|
||||
private String alarmCode;
|
||||
private String bmsVersion;
|
||||
|
||||
@JSONField(name = "data")
|
||||
private List<ChargeData> chargeData;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public static class ChargeData{
|
||||
private String dcv;
|
||||
private String dca;
|
||||
private String measuringChargeVoltage;
|
||||
private Integer bmsVoltageFault;
|
||||
private String gunTemp;
|
||||
private String singleMaxAllowVoltage;
|
||||
private String beforeChargeTotalVoltage;
|
||||
private String readCurrentCharge;
|
||||
private String singleMinVoltage;
|
||||
private String bmsDemandElectricity;
|
||||
private String chargePower;
|
||||
private String maxAllowTotalVoltage;
|
||||
private String bmsDemandVoltage;
|
||||
private String maxAllowElectricity;
|
||||
private String measuringChargeElectricity;
|
||||
private String singleMaxVoltage;
|
||||
private String singleMaxTemp;
|
||||
private String singleMinTemp;
|
||||
private String reportTime;
|
||||
private Integer currentSoc;
|
||||
private Integer socStatus;
|
||||
private Integer maxTempPointNum;
|
||||
private Integer minTempPointNum;
|
||||
private Integer maxSingleVoltageNum;
|
||||
private Integer maxSingleVoltageGroupNum;
|
||||
private Integer singleVoltageStatus;
|
||||
private String batteryInsulation;
|
||||
private Integer outputConnectStatus;
|
||||
private Integer bmsConnectError;
|
||||
private Integer bmsVoltageError;
|
||||
private Integer bmsInsulationError;
|
||||
private Integer bmsOverTempError;
|
||||
private Integer bmsHighVoltageError;
|
||||
private Integer bmsElectricityOverFault;
|
||||
private Integer bmsBatteryOverTempError;
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,14 @@ import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.ChargeAlgorithmRecord;
|
||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||
import com.jsowell.pile.service.ChargeAlgorithmRecordService;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.thirdparty.ParameterConfigData;
|
||||
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileDetailVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData;
|
||||
import com.jsowell.thirdparty.platform.domain.ChargeAlgorithmData2PDF;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -47,6 +45,18 @@ public class ChargeAlgorithmService {
|
||||
@Value("${chargeAlgorithm.clientId}")
|
||||
private String clientId;
|
||||
|
||||
@Value("${chargeAlgorithm2pdf.url}")
|
||||
private String send2PdfUrl;
|
||||
|
||||
@Value("${chargeAlgorithm2pdf.getTaskIdUrl}")
|
||||
private String getTaskIdUrl;
|
||||
|
||||
@Value("${chargeAlgorithm2pdf.getPdfLinkUrl}")
|
||||
private String getPdfLinkUrl;
|
||||
|
||||
@Value("${chargeAlgorithm2pdf.token}")
|
||||
private String token;
|
||||
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@@ -59,13 +69,18 @@ public class ChargeAlgorithmService {
|
||||
@Autowired
|
||||
private ChargeAlgorithmRecordService chargeAlgorithmRecordService;
|
||||
|
||||
@Autowired
|
||||
private PileConnectorInfoService pileConnectorInfoService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
|
||||
/**
|
||||
* 推送充电订单数据
|
||||
*
|
||||
* @param orderCode
|
||||
*/
|
||||
public String pushOrderInfo(String orderCode) {
|
||||
@@ -84,52 +99,145 @@ public class ChargeAlgorithmService {
|
||||
// 查询站点信息
|
||||
PileStationVO stationVO = pileStationInfoService.getStationInfo(orderVO.getStationId());
|
||||
|
||||
// 获取各项数据
|
||||
Map<String, Object> map = getDatasByOrderCode(orderCode);
|
||||
|
||||
String webResult = webChargeReport(map, stationVO, orderVO);
|
||||
|
||||
// pdf下载链接(先拿到 taskId, 再根据 taskId 查询 pdf 下载链接)
|
||||
String pdfDownloadURL = PdfChargeReport(map, stationVO, orderVO);
|
||||
|
||||
log.info("接收到电池报告 web页面result:{}, pdf下载链接result:{}", webResult, pdfDownloadURL);
|
||||
return webResult + "\n" + pdfDownloadURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pdf报告 taskId
|
||||
* @param map
|
||||
* @param stationVO
|
||||
* @param orderVO
|
||||
* @return
|
||||
*/
|
||||
private String PdfChargeReport(Map<String, Object> map,
|
||||
PileStationVO stationVO, OrderVO orderVO) {
|
||||
|
||||
ChargingHandshakeData chargingHandshakeData = (ChargingHandshakeData) map.get("chargingHandshakeData"); // 0X15
|
||||
ParameterConfigData parameterConfigData = (ParameterConfigData) map.get("parameterConfigData"); // 0X17
|
||||
TransactionRecordsData transactionRecordsData = (TransactionRecordsData) map.get("transactionRecordsData"); // 0x3b
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = (List<BMSDemandAndChargerOutputData>) map.get("chargerOutputInfoList"); // 0x23List
|
||||
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = chargerOutputInfoList.get(0);
|
||||
// 计算充电时长
|
||||
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信息为空";
|
||||
// 查询枪口、桩数量
|
||||
List<PileConnectorInfoVO> pileConnectorInfoVOS = pileConnectorInfoService.selectConnectorListByStationId(Long.parseLong(stationVO.getId()));
|
||||
if (CollectionUtils.isEmpty(pileConnectorInfoVOS)) {
|
||||
return null;
|
||||
}
|
||||
// 将桩号进行去重汇总
|
||||
// Set<String> strings = pileConnectorInfoVOS.stream()
|
||||
// .collect(Collectors.toMap(
|
||||
// PileConnectorInfoVO::getPileSn,
|
||||
// Function.identity(),
|
||||
// (x1, x2) -> x1
|
||||
// )).keySet();
|
||||
|
||||
// 获取0x17
|
||||
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE + transactionCode;
|
||||
ParameterConfigData parameterConfigData = redisCache.getCacheObject(redisKey);
|
||||
if (parameterConfigData == null) {
|
||||
return "0x17信息为空";
|
||||
Set<String> snList = pileConnectorInfoVOS.stream()
|
||||
.map(PileConnectorInfoVO::getPileSn)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
ChargeAlgorithmData2PDF data = ChargeAlgorithmData2PDF.builder()
|
||||
.mfrID("")
|
||||
.siteName(stationVO.getStationName())
|
||||
.siteAddress(stationVO.getAddress())
|
||||
.siteLongitude(stationVO.getStationLng())
|
||||
.siteLatitude(stationVO.getStationLat())
|
||||
.businessHours(stationVO.getBusinessHours())
|
||||
.serviceHotline(stationVO.getStationTel())
|
||||
.businessStatus(Constants.ZERO) // 营业状态 0-正常; 1-停运
|
||||
.sitePileNumber(snList.size()) // 桩数量
|
||||
.siteGunNumber(pileConnectorInfoVOS.size())
|
||||
.phone("") // 用户手机号码
|
||||
.siteCode(stationVO.getId())
|
||||
.pileCode(orderVO.getPileSn())
|
||||
.gunNo(orderVO.getConnectorCode())
|
||||
.readBeforeCharge(transactionRecordsData.getAmmeterTotalStart())
|
||||
.doorStatus(Constants.zero)
|
||||
.bmsChargeMode(Integer.parseInt(bmsDemandAndChargerOutputData.getBmsChargingModel()))
|
||||
.vin(chargingHandshakeData.getVinCode())
|
||||
.batteryType(chargingHandshakeData.getBmsBatteryType())
|
||||
.nominalEnergy(new BigDecimal(parameterConfigData.getBmsSumEnergy()).toBigInteger().toString())
|
||||
.ratedCapacity(new BigDecimal(parameterConfigData.getBmsSumEnergy()).toBigInteger().toString())
|
||||
.ratedVoltage(chargingHandshakeData.getBmsBatteryVoltage())
|
||||
.maxAllowTemp(parameterConfigData.getBmsMaxTemperature())
|
||||
.initSoc(new BigDecimal(orderVO.getStartSoc()).intValue())
|
||||
.orderCode(orderVO.getOrderCode())
|
||||
.beginTime(orderVO.getStartTime())
|
||||
.totalChargeTime(Math.toIntExact(chargingTime))
|
||||
.remainChargeTime(Constants.zero)
|
||||
.totalCharge(orderVO.getTotalPower())
|
||||
.alarmCode(Constants.ZERO)
|
||||
.bmsVersion("V1.1")
|
||||
|
||||
|
||||
.build();
|
||||
|
||||
List<ChargeAlgorithmData2PDF
|
||||
.ChargeData> chargingDetailInfos = transformData2PDF(map);
|
||||
|
||||
chargingDetailInfos.stream()
|
||||
.filter(info -> info.getCurrentSoc() > 100) // 只处理 currentSoc > 100 的元素
|
||||
.forEach(info -> info.setCurrentSoc(100));
|
||||
Collections.reverse(chargingDetailInfos);
|
||||
|
||||
data.setChargeData(chargingDetailInfos);
|
||||
|
||||
// 发送请求
|
||||
String postUrl = send2PdfUrl + getTaskIdUrl;
|
||||
String response = HttpRequest.post(postUrl).header("token", token).body(JSON.toJSONString(data)).execute().body();
|
||||
|
||||
log.info("获取taskId发送请求收到回复 response:{}", response);
|
||||
|
||||
// 将返回结果转化为json
|
||||
Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(response);
|
||||
String resultCode = String.valueOf(resultMap.get("code"));
|
||||
String pdfDownLoadLink = "";
|
||||
if (StringUtils.equals("200", resultCode)) {
|
||||
// 获取 taskId
|
||||
Map<String, Object> result = (Map<String, Object>)resultMap.get("result");
|
||||
String taskId = String.valueOf(result.get("taskId"));
|
||||
log.info("taskId:{}", taskId);
|
||||
// 通过 taskId 获取 pdf 下载链接
|
||||
pdfDownLoadLink = getPDFDownloadUrlByTaskId(taskId);
|
||||
log.info("收到pdf下载链接:{}", pdfDownLoadLink);
|
||||
}
|
||||
return pdfDownLoadLink;
|
||||
}
|
||||
|
||||
// 获取0x3b缓存信息
|
||||
String transactionDataKey = CacheConstants.TRANSACTION_RECORD_BY_TRANSACTION_CODE + transactionCode;
|
||||
TransactionRecordsData transactionRecordsData = redisCache.getCacheObject(transactionDataKey);
|
||||
/**
|
||||
* web页面报告发送请求
|
||||
* @param map
|
||||
* @param stationVO
|
||||
* @param orderVO
|
||||
* @return
|
||||
*/
|
||||
private String webChargeReport(Map<String, Object> map,
|
||||
PileStationVO stationVO, OrderVO orderVO) {
|
||||
|
||||
// 网页页面报告
|
||||
ChargingHandshakeData chargingHandshakeData = (ChargingHandshakeData) map.get("chargingHandshakeData"); // 0X15
|
||||
ParameterConfigData parameterConfigData = (ParameterConfigData) map.get("parameterConfigData"); // 0X17
|
||||
TransactionRecordsData transactionRecordsData = (TransactionRecordsData) map.get("transactionRecordsData"); // 0x3b
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = (List<BMSDemandAndChargerOutputData>) map.get("chargerOutputInfoList"); // 0x23List
|
||||
|
||||
// 获取最后一条0x23
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = pileBasicInfoService.getBMSDemandAndChargerOutputInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
return "0x23信息为空";
|
||||
}
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = chargerOutputInfoList.get(0);
|
||||
// 计算充电时长
|
||||
long chargingTime = DateUtils.intervalTime(orderVO.getStartTime(), orderVO.getEndTime());
|
||||
|
||||
// 获取最后一条0x13
|
||||
// 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 "0x25信息为空";
|
||||
// }
|
||||
// BMSChargeInfoData bmsChargeInfoData = bmsChargeInfoList.get(0);
|
||||
|
||||
// 封装数据
|
||||
ChargeAlgorithmData data = ChargeAlgorithmData.builder()
|
||||
.vin(chargingHandshakeData.getVinCode())
|
||||
.orderCode(orderCode)
|
||||
.orderCode(orderVO.getOrderCode())
|
||||
.beginTime(orderVO.getStartTime())
|
||||
.initSoc(new BigDecimal(orderVO.getStartSoc()).intValue())
|
||||
.alarmCode(Constants.ZERO)
|
||||
@@ -165,8 +273,11 @@ public class ChargeAlgorithmService {
|
||||
|
||||
.build();
|
||||
|
||||
// List<ChargeAlgorithmData
|
||||
// .ChargingDetailInfo> chargingDetailInfos = transformData(orderVO.getTransactionCode(), chargerOutputInfoList, parameterConfigData, transactionRecordsData);
|
||||
List<ChargeAlgorithmData
|
||||
.ChargingDetailInfo> chargingDetailInfos = transformData(transactionCode, chargerOutputInfoList, parameterConfigData, transactionRecordsData);
|
||||
.ChargingDetailInfo> chargingDetailInfos = transformData(map);
|
||||
|
||||
chargingDetailInfos.stream()
|
||||
.filter(info -> info.getCurrentSoc() > 100) // 只处理 currentSoc > 100 的元素
|
||||
.forEach(info -> info.setCurrentSoc(100));
|
||||
@@ -177,20 +288,20 @@ public class ChargeAlgorithmService {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("dataJson", data);
|
||||
|
||||
log.info("发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject));
|
||||
log.info("web页面发送请求前封装数据 data:{}", JSON.toJSONString(jsonObject));
|
||||
|
||||
// 发送请求
|
||||
String response = HttpRequest.post(url).header("clientId", clientId).body(JSON.toJSONString(jsonObject)).execute().body();
|
||||
|
||||
log.info("发送请求收到回复 response:{}", response);
|
||||
log.info("web页面发送请求收到回复 response:{}", response);
|
||||
// 将返回结果转化为json
|
||||
Map<String, Object> map = (Map<String, Object>) JSON.parse(response);
|
||||
String resultCode = String.valueOf(map.get("code"));
|
||||
Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(response);
|
||||
String resultCode = String.valueOf(resultMap.get("code"));
|
||||
if (StringUtils.equals("200", resultCode)) {
|
||||
// 请求成功,如果该订单没有记录过,则将该份数据报告保存到数据库
|
||||
ChargeAlgorithmRecord record = chargeAlgorithmRecordService.queryRecordByOrderCode(orderCode);
|
||||
ChargeAlgorithmRecord record = chargeAlgorithmRecordService.queryRecordByOrderCode(orderVO.getOrderCode());
|
||||
if (record == null) {
|
||||
String jsonString = JSON.toJSONString(map.get("data"));
|
||||
String jsonString = JSON.toJSONString(resultMap.get("data"));
|
||||
record = JSON.parseObject(jsonString, ChargeAlgorithmRecord.class);
|
||||
chargeAlgorithmRecordService.insertChargeAlgorithmRecord(record);
|
||||
}
|
||||
@@ -198,10 +309,74 @@ public class ChargeAlgorithmService {
|
||||
return response;
|
||||
}
|
||||
|
||||
private List<ChargeAlgorithmData.ChargingDetailInfo> transformData(String transactionCode, List<BMSDemandAndChargerOutputData> chargerOutputInfoList,
|
||||
ParameterConfigData parameterConfigData, TransactionRecordsData transactionRecordsData) {
|
||||
List<ChargeAlgorithmData.ChargingDetailInfo> resultList = new ArrayList<>();
|
||||
ChargeAlgorithmData.ChargingDetailInfo detailInfo;
|
||||
/**
|
||||
* 通过 taskId 获取 pdf 下载链接
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
private String getPDFDownloadUrlByTaskId(String taskId) {
|
||||
String postUrl = send2PdfUrl + getPdfLinkUrl + taskId;
|
||||
// 发送请求
|
||||
String result = HttpRequest.get(postUrl).execute().body();
|
||||
// 将返回结果转化为json
|
||||
Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
|
||||
String resultCode = String.valueOf(resultMap.get("code"));
|
||||
String pdfUrl = "";
|
||||
if (StringUtils.equals("200", resultCode)) {
|
||||
// 获取 pdf下载Url
|
||||
pdfUrl = String.valueOf(resultMap.get("pdfUrl"));
|
||||
}
|
||||
return pdfUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询各项充电数据
|
||||
*
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> getDatasByOrderCode(String orderCode) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
// 0x15数据Data
|
||||
ChargingHandshakeData chargingHandshakeData = null;
|
||||
// 0x17数据data
|
||||
ParameterConfigData parameterConfigData = null;
|
||||
// 0x3b数据data
|
||||
TransactionRecordsData transactionRecordsData = null;
|
||||
// 0x23数据data
|
||||
BMSDemandAndChargerOutputData bmsDemandAndChargerOutputData = null;
|
||||
|
||||
// 根据订单号查询订单信息
|
||||
OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(orderCode);
|
||||
if (orderVO == null) {
|
||||
return map;
|
||||
}
|
||||
String transactionCode = orderVO.getTransactionCode();
|
||||
|
||||
// 获取0x15
|
||||
String chargingHandshakeKey = CacheConstants.CHARGING_HANDSHAKE_DATA_BY_TRANSACTION_CODE + transactionCode;
|
||||
chargingHandshakeData = redisCache.getCacheObject(chargingHandshakeKey);
|
||||
if (chargingHandshakeData == null) {
|
||||
log.info("orderCode:{}, 0x15信息为空", orderCode);
|
||||
}
|
||||
|
||||
// 获取0x17
|
||||
String redisKey = CacheConstants.PARAMETER_CONFIGURATION_BY_TRANSACTION_CODE + transactionCode;
|
||||
parameterConfigData = redisCache.getCacheObject(redisKey);
|
||||
if (parameterConfigData == null) {
|
||||
log.info("orderCode:{}, 0x17信息为空", orderCode);
|
||||
}
|
||||
|
||||
// 获取0x3b缓存信息
|
||||
String transactionDataKey = CacheConstants.TRANSACTION_RECORD_BY_TRANSACTION_CODE + transactionCode;
|
||||
transactionRecordsData = redisCache.getCacheObject(transactionDataKey);
|
||||
|
||||
// 获取最后一条0x23
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = pileBasicInfoService.getBMSDemandAndChargerOutputInfoList(transactionCode);
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
log.info("orderCode:{}, 0x23信息为空", orderCode);
|
||||
}
|
||||
|
||||
// 获取0x25
|
||||
List<BMSChargeInfoData> bmsChargeInfoList = pileBasicInfoService.getBMSChargeInfoList(transactionCode);
|
||||
// 0x13
|
||||
@@ -218,7 +393,6 @@ public class ChargeAlgorithmService {
|
||||
})
|
||||
.collect(Collectors.groupingBy(BMSChargeInfoData::getDateTime));
|
||||
|
||||
|
||||
}
|
||||
if (chargingRealTimeDataList != null) {
|
||||
collect_0x13 = chargingRealTimeDataList.stream()
|
||||
@@ -228,6 +402,32 @@ public class ChargeAlgorithmService {
|
||||
})
|
||||
.collect(Collectors.groupingBy(RealTimeMonitorData::getDateTime));
|
||||
}
|
||||
|
||||
map.put("chargingHandshakeData", chargingHandshakeData); // 0x15
|
||||
map.put("parameterConfigData", parameterConfigData); // 0x17
|
||||
map.put("transactionRecordsData", transactionRecordsData); // 0x3b
|
||||
map.put("chargerOutputInfoList", chargerOutputInfoList); // 0x23List
|
||||
map.put("collect_0x25", collect_0x25);
|
||||
map.put("collect_0x13", collect_0x13);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装web报告充电数据 Datas
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
private List<ChargeAlgorithmData.ChargingDetailInfo> transformData(Map<String, Object> map) {
|
||||
List<ChargeAlgorithmData.ChargingDetailInfo> resultList = new ArrayList<>();
|
||||
ChargeAlgorithmData.ChargingDetailInfo detailInfo;
|
||||
|
||||
ParameterConfigData parameterConfigData = (ParameterConfigData) map.get("parameterConfigData"); // 0X17
|
||||
TransactionRecordsData transactionRecordsData = (TransactionRecordsData) map.get("transactionRecordsData"); // 0x3b
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = (List<BMSDemandAndChargerOutputData>) map.get("chargerOutputInfoList"); // 0x23List
|
||||
Map<String, List<BMSChargeInfoData>> collect_0x25 = (Map<String, List<BMSChargeInfoData>>) map.get("collect_0x25");
|
||||
Map<String, List<RealTimeMonitorData>> collect_0x13 = (Map<String, List<RealTimeMonitorData>>) map.get("collect_0x13");
|
||||
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -243,7 +443,7 @@ public class ChargeAlgorithmService {
|
||||
|
||||
detailInfo.setGunTemp(realTimeData_0x13.getGunLineTemperature());
|
||||
detailInfo.setCurrentSoc(new BigDecimal(realTimeData_0x13.getSOC()).intValue());
|
||||
}else {
|
||||
} else {
|
||||
detailInfo.setGunTemp("0");
|
||||
detailInfo.setCurrentSoc(new BigDecimal(realTimeData_0x23.getSoc()).intValue());
|
||||
}
|
||||
@@ -291,4 +491,90 @@ public class ChargeAlgorithmService {
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装pdf报告充电数据 Datas
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
private List<ChargeAlgorithmData2PDF.ChargeData> transformData2PDF(Map<String, Object> map) {
|
||||
List<ChargeAlgorithmData2PDF.ChargeData> resultList = new ArrayList<>();
|
||||
ChargeAlgorithmData2PDF.ChargeData chargeData;
|
||||
|
||||
ParameterConfigData parameterConfigData = (ParameterConfigData) map.get("parameterConfigData"); // 0X17
|
||||
TransactionRecordsData transactionRecordsData = (TransactionRecordsData) map.get("transactionRecordsData"); // 0x3b
|
||||
List<BMSDemandAndChargerOutputData> chargerOutputInfoList = (List<BMSDemandAndChargerOutputData>) map.get("chargerOutputInfoList"); // 0x23List
|
||||
Map<String, List<BMSChargeInfoData>> collect_0x25 = (Map<String, List<BMSChargeInfoData>>) map.get("collect_0x25");
|
||||
Map<String, List<RealTimeMonitorData>> collect_0x13 = (Map<String, List<RealTimeMonitorData>>) map.get("collect_0x13");
|
||||
|
||||
if (CollectionUtils.isEmpty(chargerOutputInfoList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
for (BMSDemandAndChargerOutputData realTimeData_0x23 : chargerOutputInfoList) {
|
||||
chargeData = new ChargeAlgorithmData2PDF.ChargeData();
|
||||
String dateStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(realTimeData_0x23.getDateTime()));
|
||||
|
||||
// 获取该时间的0x13数据
|
||||
List<RealTimeMonitorData> RealTimeDataList = collect_0x13.get(dateStr);
|
||||
if (RealTimeDataList != null) {
|
||||
RealTimeMonitorData realTimeData_0x13 = RealTimeDataList.get(0);
|
||||
|
||||
chargeData.setGunTemp(realTimeData_0x13.getGunLineTemperature());
|
||||
chargeData.setCurrentSoc(new BigDecimal(realTimeData_0x13.getSOC()).intValue());
|
||||
chargeData.setSocStatus(new BigDecimal(realTimeData_0x13.getSOC()).intValue());
|
||||
} else {
|
||||
chargeData.setGunTemp("0");
|
||||
chargeData.setCurrentSoc(new BigDecimal(realTimeData_0x23.getSoc()).intValue());
|
||||
chargeData.setSocStatus(new BigDecimal(realTimeData_0x23.getSoc()).intValue());
|
||||
}
|
||||
chargeData.setDcv(new BigDecimal(realTimeData_0x23.getPileVoltageOutput()).toBigInteger().toString());
|
||||
chargeData.setDca(new BigDecimal(realTimeData_0x23.getPileCurrentOutput()).toBigInteger().toString());
|
||||
chargeData.setMeasuringChargeVoltage(new BigDecimal(realTimeData_0x23.getBmsChargingVoltage()).toBigInteger().toString());
|
||||
chargeData.setBmsVoltageFault(Constants.zero);
|
||||
chargeData.setSingleMaxAllowVoltage(new BigDecimal(parameterConfigData.getBmsMaxVoltage()).setScale(1, RoundingMode.HALF_DOWN).toString());
|
||||
chargeData.setBeforeChargeTotalVoltage(new BigDecimal(parameterConfigData.getBmsRealTimeVoltage()).toBigInteger().toString());
|
||||
chargeData.setReadCurrentCharge(transactionRecordsData.getAmmeterTotalEnd());
|
||||
chargeData.setSingleMinVoltage(new BigDecimal(realTimeData_0x23.getBmsMaxVoltageAndGroup()).setScale(1, RoundingMode.HALF_DOWN).toString());
|
||||
chargeData.setBmsDemandElectricity(new BigDecimal(realTimeData_0x23.getBmsCurrentDemand()).toBigInteger().toString());
|
||||
chargeData.setChargePower(realTimeData_0x23.getOutputPower());
|
||||
chargeData.setMaxAllowTotalVoltage(new BigDecimal(parameterConfigData.getBmsMaxChargingVoltage()).toBigInteger().toString());
|
||||
chargeData.setBmsDemandVoltage(new BigDecimal(realTimeData_0x23.getBmsVoltageDemand()).toBigInteger().toString());
|
||||
chargeData.setMaxAllowElectricity(new BigDecimal(parameterConfigData.getBmsMaxCurrent()).toBigInteger().toString());
|
||||
chargeData.setMeasuringChargeElectricity(new BigDecimal(realTimeData_0x23.getBmsChargingCurrent()).toBigInteger().toString());
|
||||
chargeData.setSingleMaxVoltage(new BigDecimal(realTimeData_0x23.getBmsMaxVoltageAndGroup()).setScale(1, RoundingMode.HALF_DOWN).toString());
|
||||
chargeData.setReportTime(realTimeData_0x23.getDateTime().replaceAll("[^0-9]", ""));
|
||||
chargeData.setSingleVoltageStatus(Constants.zero);
|
||||
chargeData.setOutputConnectStatus(Constants.zero);
|
||||
chargeData.setBmsConnectError(Constants.zero);
|
||||
chargeData.setBmsVoltageError(Constants.zero);
|
||||
chargeData.setBmsInsulationError(Constants.zero);
|
||||
chargeData.setBmsOverTempError(Constants.zero);
|
||||
chargeData.setBmsHighVoltageError(Constants.zero);
|
||||
chargeData.setBmsElectricityOverFault(Constants.zero);
|
||||
chargeData.setBmsBatteryOverTempError(Constants.zero);
|
||||
|
||||
|
||||
// 获取该时间的0x25数据
|
||||
List<BMSChargeInfoData> bmsChargeInfoDataList = collect_0x25.get(dateStr);
|
||||
|
||||
if (bmsChargeInfoDataList != null) {
|
||||
BMSChargeInfoData realTimeData_0x25 = bmsChargeInfoDataList.get(0);
|
||||
|
||||
chargeData.setSingleMaxTemp(realTimeData_0x25.getBmsMaxBatteryTemperature());
|
||||
chargeData.setSingleMinTemp(realTimeData_0x25.getMinBatteryTemperature());
|
||||
chargeData.setMaxSingleVoltageNum(Integer.parseInt(realTimeData_0x25.getBmsMaxVoltageNum()));
|
||||
chargeData.setMaxSingleVoltageGroupNum(Integer.parseInt(realTimeData_0x23.getBmsMaxVoltageAndGroup().replace(".", "")));
|
||||
chargeData.setMaxTempPointNum(Integer.parseInt(realTimeData_0x25.getMaxTemperatureDetectionNum()));
|
||||
chargeData.setMinTempPointNum(Integer.parseInt(realTimeData_0x25.getMinTemperatureDetectionNum()));
|
||||
chargeData.setBatteryInsulation(realTimeData_0x25.getBmsBatteryInsulationStatus());
|
||||
|
||||
// detailInfo.setVentTemp();
|
||||
// detailInfo.setEnvironmentTemp();
|
||||
}
|
||||
resultList.add(chargeData);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user