update 电池报告算法Service移动至pile模块下

This commit is contained in:
Lemon
2026-03-10 09:22:22 +08:00
parent 6ddff8db35
commit cc1b58a9d1
7 changed files with 49 additions and 23 deletions

View File

@@ -0,0 +1,105 @@
package com.jsowell.pile.domain.batteryreport;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 电池充电报告Data
*
* @author Lemon
* @Date 2025/9/10 14:29:28
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BatteryChargeReportData {
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<BatteryChargeReportData.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 readBeforeCharge;
private Integer doorStatus;
private Integer bmsChargeMode;
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;
}
}

View File

@@ -0,0 +1,38 @@
package com.jsowell.pile.domain.batteryreport;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 电池报告 result 部分
*
* @author Lemon
* @Date 2025/9/11 13:48:33
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BatteryReportResult {
private String pdfUrl;
private String webUrl;
private String fileName;
private String expireTime;
private String reportId;
private String fileSize;
private String generateTime;
private String taskId;
private String directUrl;
private String timestamp;
}

View File

@@ -0,0 +1,460 @@
package com.jsowell.pile.service.batteryreport;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
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.domain.ChargeAlgorithmRecord;
import com.jsowell.pile.domain.batteryreport.BatteryChargeReportData;
import com.jsowell.pile.domain.batteryreport.BatteryReportResult;
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 org.apache.commons.lang3.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
/**
* 电池充电报告Service
*
* @author Lemon
* @Date 2025/9/10 13:42:28
*/
@Service
public class BatteryChargeReportService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Value("${batteryChargeReport.webDomainPrefix}")
private String webDomainPrefix;
@Value("${batteryChargeReport.getTaskIdApi}")
private String getTaskIdApi;
@Value("${batteryChargeReport.apiPrefix}")
private String apiPrefix;
@Value("${batteryChargeReport.token}")
private String token;
@Value("${batteryChargeReport.mfrID}")
private String mfrID;
@Autowired
private RedisCache redisCache;
@Autowired
private OrderBasicInfoService orderBasicInfoService;
@Autowired
private PileBasicInfoService pileBasicInfoService;
@Autowired
private PileConnectorInfoService pileConnectorInfoService;
@Autowired
private PileStationInfoService pileStationInfoService;
@Autowired
private ChargeAlgorithmRecordService chargeAlgorithmRecordService;
/**
* 通过订单号统一发送充电电池数据获取 taskId
*
* @param orderCode
*/
public String getTaskIdByOrderCode(String orderCode) {
// 根据订单号查询订单信息
OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(orderCode);
if (orderVO == null) {
log.error("统一发送orderCode:{} 充电电池数据 error, 订单信息为空", orderCode);
return null;
}
// 先判断直流桩还是交流桩,如果是交流桩就不进行计算
PileDetailVO pileDetailVO = pileBasicInfoService.selectPileDetailByPileSn(orderVO.getPileSn());
if (StringUtils.equals(Constants.TWO, pileDetailVO.getChargePortType())) {
log.info("订单:{} 为交流桩订单,不进行充电算法计算", orderCode);
return null;
}
// 查询站点信息
PileStationVO stationVO = pileStationInfoService.getStationInfo(orderVO.getStationId());
// 获取各项数据
Map<String, Object> map = getDatasByOrderVO(orderVO);
String taskId = pushInfoGetTaskId(map, stationVO, orderVO);
if (StringUtils.isBlank(taskId)) {
log.error("订单:{} 获取到 taskId 为空", orderCode);
return null;
}
ChargeAlgorithmRecord record = chargeAlgorithmRecordService.queryRecordByOrderCode(orderCode);
if (record != null) {
record.setTaskId(taskId);
chargeAlgorithmRecordService.updateChargeAlgorithmRecord(record);
}else {
record = new ChargeAlgorithmRecord();
record.setTaskId(taskId);
record.setOrderCode(orderCode);
chargeAlgorithmRecordService.insertOrUpdateSelective(record);
}
return taskId;
}
/**
* 通过taskId获取链接
* @param taskId
* @param reportType 1-web链接2-pdf链接
* @return
*/
public String getUrlByTaskId(String taskId, String reportType) {
String resultUrl = "";
// 根据 taskId 获取链接
// 通过 taskId 获取充电算法记录
ChargeAlgorithmRecord record = chargeAlgorithmRecordService.queryRecordByTaskId(taskId);
if (record == null) {
log.error("taskId:{} 获取充电算法记录为空", taskId);
return null;
}
// 默认 1-web 端 url
String apiUrl = webDomainPrefix + apiPrefix + "web/" + taskId;
if (StringUtils.equals(Constants.TWO, reportType)) {
// 2-pdf 端
apiUrl = webDomainPrefix + apiPrefix + "pdf/" + taskId;
}
// 发送请求
String result = HttpRequest.get(apiUrl).header("token", token).execute().body();
log.info("发送获取报告result:{}", result);
// 将返回结果转化为json
Map<String, Object> resultMap = (Map<String, Object>) JSON.parse(result);
String resultCode = String.valueOf(resultMap.get("code"));
if (!StringUtils.equals(Constants.TWO_HUNDRED, resultCode)) {
return null;
}
// 获取对应的 url
// 将 result 部分转换成 BatteryReportResult 对象
// BatteryReportResult batteryReportResult = (BatteryReportResult) resultMap.get("result");
BatteryReportResult batteryReportResult = JSONObject.parseObject(resultMap.get("result").toString(), BatteryReportResult.class);;
if (StringUtils.equals(Constants.ONE, reportType)) {
if (StringUtils.isNotBlank(batteryReportResult.getWebUrl())) {
// 1-web 端
resultUrl = batteryReportResult.getWebUrl();
record.setWebUrl(resultUrl);
}
}else {
if (StringUtils.isNotBlank(batteryReportResult.getPdfUrl())) {
// pdf 端
resultUrl = batteryReportResult.getPdfUrl();
record.setPdfUrl(resultUrl);
}
}
// 保存到数据库
chargeAlgorithmRecordService.updateChargeAlgorithmRecord(record);
return resultUrl;
}
public static void main(String[] args) {
String a = "03";
System.out.println(String.valueOf(Integer.parseInt(a)));
// String taskId = "1e6e42aa613947bf863bc455c2f3357e";
// String url = "https://wx.btiger.net/jeecg-boot" + "/api/docking/report/" + "web/" + taskId;
// String result = HttpRequest.get(url).execute().body();
//
// System.out.println(result);
}
/**
* 推送信息获取taskId
*
* @param map
* @param stationVO
* @param orderVO
* @return
*/
private String pushInfoGetTaskId(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());
// 查询枪口、桩数量
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();
Set<String> snList = pileConnectorInfoVOS.stream()
.map(PileConnectorInfoVO::getPileSn)
.collect(Collectors.toSet());
String batteryType = String.valueOf(Integer.parseInt(chargingHandshakeData.getBmsBatteryType()));
// 如果 batteryType != 1/2/3/4/5
if (!StringUtils.equalsAny(batteryType, "1", "2", "3", "4", "5")) {
// 随机生成一个1-3的数
batteryType = String.valueOf(RandomUtils.nextInt(1, 4));
}
BatteryChargeReportData data = BatteryChargeReportData.builder()
.mfrID(mfrID)
.siteName(stationVO.getStationName())
.siteAddress(stationVO.getAddress())
.siteLongitude(stationVO.getStationLng())
.siteLatitude(stationVO.getStationLat())
.businessHours(stationVO.getBusinessHours() == null ? "00:00-24:00" : stationVO.getBusinessHours())
.serviceHotline(stationVO.getStationTel())
.businessStatus(Constants.ZERO) // 营业状态 0-正常; 1-停运
.sitePileNumber(snList.size()) // 桩数量
.siteGunNumber(pileConnectorInfoVOS.size())
.phone(orderVO.getPhoneNumber()) // 用户手机号码
.siteCode(stationVO.getId())
.pileCode(orderVO.getPileSn())
.gunNo(orderVO.getConnectorCode())
.readBeforeCharge(transactionRecordsData.getAmmeterTotalStart())
.doorStatus(Constants.zero)
.bmsChargeMode(Integer.parseInt(bmsDemandAndChargerOutputData.getBmsChargingModel()))
.vin(transactionRecordsData.getVinCode())
.batteryType(batteryType)
.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.DOUBLE_ZERO)
.bmsVersion("V1.1")
.build();
List<BatteryChargeReportData
.ChargeData> chargingDetailInfos = transformData(map);
chargingDetailInfos.stream()
.filter(info -> info.getCurrentSoc() > 100) // 只处理 currentSoc > 100 的元素
.forEach(info -> info.setCurrentSoc(100));
Collections.reverse(chargingDetailInfos);
data.setChargeData(chargingDetailInfos);
// 发送请求
String postUrl = webDomainPrefix + getTaskIdApi;
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 taskId = "";
if (StringUtils.equals(Constants.TWO_HUNDRED, resultCode)) {
// 获取 taskId
Map<String, Object> result = (Map<String, Object>)resultMap.get("result");
taskId = String.valueOf(result.get("taskId"));
log.info("taskId:{}", taskId);
}
return taskId;
}
/**
* 根据订单号查询各项充电数据
*
* @param orderVO
* @return
*/
private Map<String, Object> getDatasByOrderVO(OrderVO orderVO) {
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;
String orderCode = orderVO.getOrderCode();
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
List<RealTimeMonitorData> chargingRealTimeDataList = orderBasicInfoService.getChargingRealTimeData(transactionCode);
Map<String, List<BMSChargeInfoData>> collect_0x25 = new LinkedHashMap<>();
Map<String, List<RealTimeMonitorData>> collect_0x13 = new LinkedHashMap<>();
if (bmsChargeInfoList != null) {
// 按照dateTime分组将key设置为 yyyy-MM-dd HH:mm:00 格式)
collect_0x25 = bmsChargeInfoList.stream()
.map(x -> {
x.setDateTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(x.getDateTime())));
return x;
})
.collect(Collectors.groupingBy(BMSChargeInfoData::getDateTime));
}
if (chargingRealTimeDataList != null) {
collect_0x13 = chargingRealTimeDataList.stream()
.map(x -> {
x.setDateTime(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", DateUtils.parseDate(x.getDateTime())));
return x;
})
.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;
}
/**
* 封装充电数据 Datas
* @param map
* @return
*/
private List<BatteryChargeReportData.ChargeData> transformData(Map<String, Object> map) {
List<BatteryChargeReportData.ChargeData> resultList = new ArrayList<>();
BatteryChargeReportData.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 BatteryChargeReportData.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.setReadBeforeCharge(transactionRecordsData.getAmmeterTotalStart());
chargeData.setDoorStatus(Constants.zero);
chargeData.setBmsChargeMode(Constants.two);
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_0x25.getBmsMaxVoltageNum()));
chargeData.setMaxTempPointNum(Integer.parseInt(realTimeData_0x25.getMaxTemperatureDetectionNum()));
chargeData.setMinTempPointNum(Integer.parseInt(realTimeData_0x25.getMinTemperatureDetectionNum()));
chargeData.setBatteryInsulation(Constants.DOUBLE_ZERO);
// detailInfo.setVentTemp();
// detailInfo.setEnvironmentTemp();
}
resultList.add(chargeData);
}
return resultList;
}
}

View File

@@ -8,6 +8,7 @@ import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.dto.BatteryChargeReportDTO;
import com.jsowell.pile.service.ChargeAlgorithmRecordService;
import com.jsowell.pile.service.batteryreport.BatteryChargeReportService;
import com.jsowell.pile.vo.uniapp.customer.ChargeAlgorithmRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -25,6 +26,9 @@ public class ChargeAlgorithmRecordServiceImpl implements ChargeAlgorithmRecordSe
@Autowired
private ChargeAlgorithmRecordMapper chargeAlgorithmRecordMapper;
@Autowired
private BatteryChargeReportService batteryChargeReportService;
/**
* 查询电池充电算法记录
*
@@ -125,20 +129,44 @@ public class ChargeAlgorithmRecordServiceImpl implements ChargeAlgorithmRecordSe
*/
@Override
public String getUrlByParams(BatteryChargeReportDTO dto) {
ChargeAlgorithmRecord record = queryRecordByOrderCode(dto.getOrderCode());
String reportType = dto.getReportType();
if (StringUtils.equals(Constants.ONE, reportType)) {
// 1-web 端
if (StringUtils.isNotBlank(record.getWebUrl())) {
return record.getWebUrl();
}
}else if (StringUtils.equals(Constants.TWO, reportType)) {
// 2-pdf 端
if (StringUtils.isNotBlank(record.getPdfUrl())) {
return record.getPdfUrl();
}
// 参数校验
if (dto == null || StringUtils.isBlank(dto.getOrderCode())) {
return StringUtils.EMPTY;
}
return "";
ChargeAlgorithmRecord record = queryRecordByOrderCode(dto.getOrderCode());
if (record == null) {
return StringUtils.EMPTY;
}
// 获取记录中的URL
String urlFromRecord = getUrlFromRecordByType(record, dto.getReportType());
if (StringUtils.isNotBlank(urlFromRecord)) {
return urlFromRecord;
}
// 如果记录中没有且taskId存在通过服务获取
if (StringUtils.isNotBlank(dto.getTaskId())) {
return batteryChargeReportService.getUrlByTaskId(dto.getTaskId(), dto.getReportType());
}
return StringUtils.EMPTY;
}
/**
* 通过记录获取URL
* @param record
* @param reportType
* @return
*/
private String getUrlFromRecordByType(ChargeAlgorithmRecord record, String reportType) {
if (StringUtils.equals(Constants.ONE, reportType)) {
return record.getWebUrl();
} else if (StringUtils.equals(Constants.TWO, reportType)) {
return record.getPdfUrl();
}
return null;
}
/**