From a6b8a023706892b73374e05571ef940ea5bf5b0f Mon Sep 17 00:00:00 2001 From: Lemon Date: Fri, 29 Aug 2025 14:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=94=B5=E6=B1=A0=E5=85=85=E7=94=B5=E6=8A=A5=E5=91=8Apdf?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E9=93=BE=E6=8E=A5=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 5 + .../src/main/resources/application.yml | 4 + .../impl/PileStationInfoServiceImpl.java | 2 + .../jsowell/pile/vo/web/PileStationVO.java | 4 + .../domain/ChargeAlgorithmData2PDF.java | 102 +++++ .../service/impl/ChargeAlgorithmService.java | 392 +++++++++++++++--- 6 files changed, 456 insertions(+), 53 deletions(-) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData2PDF.java diff --git a/jsowell-admin/src/main/resources/application-dev.yml b/jsowell-admin/src/main/resources/application-dev.yml index 7f319657c..d150825b3 100644 --- a/jsowell-admin/src/main/resources/application-dev.yml +++ b/jsowell-admin/src/main/resources/application-dev.yml @@ -252,6 +252,11 @@ parking: chargeAlgorithm: url: http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json clientId: e488bac5f70b496fa2d82065089e5f81 +chargeAlgorithm2pdf: + url: https://wx.btiger.net/jeecg-boot + getTaskIdUrl: /api/docking/api/evaluate + getPdfLinkUrl: /api/docking/report/pdf/ + token: MTc0NzcyMjgwMzg0NC1xNmFucG96cHR4aQ== # dubbo配置 dubbo: diff --git a/jsowell-admin/src/main/resources/application.yml b/jsowell-admin/src/main/resources/application.yml index 33ed80692..b1fd96a92 100644 --- a/jsowell-admin/src/main/resources/application.yml +++ b/jsowell-admin/src/main/resources/application.yml @@ -147,4 +147,8 @@ wulian: chargeAlgorithm: url: http://150.158.199.92:58910/gateway/api/user/battery/algorithm/json clientId: e488bac5f70b496fa2d82065089e5f81 +chargeAlgorithm2pdf: + getTaskIdUrl: /api/docking/api/evaluate + getPdfLinkUrl: /api/docking/report/pdf/ + token: MTc0NzcyMjgwMzg0NC1xNmFucG96cHR4aQ== diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index 8e03737d3..a1361b5db 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -206,6 +206,8 @@ public class PileStationInfoServiceImpl implements PileStationInfoService { vo.setStationLat(String.format("%.6f", coordinate.getLat())); vo.setStationLng(String.format("%.6f", coordinate.getLng())); log.debug("高德坐标:{}, 转天地图坐标:{}", pileStationInfo.getStationLng() + ", " + pileStationInfo.getStationLat(), vo.getStationLng() + ", " + vo.getStationLat()); + vo.setAMapStationLat(pileStationInfo.getStationLat()); + vo.setAMapStationLng(pileStationInfo.getStationLng()); } vo.setCountryCode(pileStationInfo.getCountryCode()); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/PileStationVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/PileStationVO.java index 0a681c626..9592b5a75 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/PileStationVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/PileStationVO.java @@ -139,11 +139,15 @@ public class PileStationVO { */ private String stationLng; + private String aMapStationLng; + /** * 纬度 */ private String stationLat; + private String aMapStationLat; + /** * 停车场库编号 */ diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData2PDF.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData2PDF.java new file mode 100644 index 000000000..7fe43347f --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/ChargeAlgorithmData2PDF.java @@ -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; + + @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; + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java index d158366b0..da94c9a72 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/ChargeAlgorithmService.java @@ -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 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 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 chargerOutputInfoList = (List) 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 pileConnectorInfoVOS = pileConnectorInfoService.selectConnectorListByStationId(Long.parseLong(stationVO.getId())); + if (CollectionUtils.isEmpty(pileConnectorInfoVOS)) { + return null; } + // 将桩号进行去重汇总 + // Set 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 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 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 resultMap = (Map) JSON.parse(response); + String resultCode = String.valueOf(resultMap.get("code")); + String pdfDownLoadLink = ""; + if (StringUtils.equals("200", resultCode)) { + // 获取 taskId + Map result = (Map)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 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 chargerOutputInfoList = (List) map.get("chargerOutputInfoList"); // 0x23List - // 获取最后一条0x23 - List 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 chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(transactionCode); - // if (CollectionUtils.isEmpty(chargingRealTimeDataList)) { - // return "0x13信息为空"; - // } - // RealTimeMonitorData realTimeMonitorData = chargingRealTimeDataList.get(0); - - // 获取最后一条0x25 - // List 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 chargingDetailInfos = transformData(orderVO.getTransactionCode(), chargerOutputInfoList, parameterConfigData, transactionRecordsData); List 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 map = (Map) JSON.parse(response); - String resultCode = String.valueOf(map.get("code")); + Map resultMap = (Map) 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 transformData(String transactionCode, List chargerOutputInfoList, - ParameterConfigData parameterConfigData, TransactionRecordsData transactionRecordsData) { - List 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 resultMap = (Map) 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 getDatasByOrderCode(String orderCode) { + Map 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 chargerOutputInfoList = pileBasicInfoService.getBMSDemandAndChargerOutputInfoList(transactionCode); + if (CollectionUtils.isEmpty(chargerOutputInfoList)) { + log.info("orderCode:{}, 0x23信息为空", orderCode); + } + // 获取0x25 List 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 transformData(Map map) { + List resultList = new ArrayList<>(); + ChargeAlgorithmData.ChargingDetailInfo detailInfo; + + ParameterConfigData parameterConfigData = (ParameterConfigData) map.get("parameterConfigData"); // 0X17 + TransactionRecordsData transactionRecordsData = (TransactionRecordsData) map.get("transactionRecordsData"); // 0x3b + List chargerOutputInfoList = (List) map.get("chargerOutputInfoList"); // 0x23List + Map> collect_0x25 = (Map>) map.get("collect_0x25"); + Map> collect_0x13 = (Map>) 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 transformData2PDF(Map map) { + List resultList = new ArrayList<>(); + ChargeAlgorithmData2PDF.ChargeData chargeData; + + ParameterConfigData parameterConfigData = (ParameterConfigData) map.get("parameterConfigData"); // 0X17 + TransactionRecordsData transactionRecordsData = (TransactionRecordsData) map.get("transactionRecordsData"); // 0x3b + List chargerOutputInfoList = (List) map.get("chargerOutputInfoList"); // 0x23List + Map> collect_0x25 = (Map>) map.get("collect_0x25"); + Map> collect_0x13 = (Map>) 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 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 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; + } }