update 电池充电报告逻辑

This commit is contained in:
Lemon
2025-09-12 11:03:09 +08:00
parent 8047a3c149
commit d11383a04c
2 changed files with 64 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
package com.jsowell.thirdparty.platform.domain;
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;
}

View File

@@ -18,6 +18,7 @@ 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.BatteryChargeReportData;
import com.jsowell.thirdparty.platform.domain.BatteryReportResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -93,7 +94,17 @@ public class BatteryChargeReportService {
Map<String, Object> map = getDatasByOrderVO(orderVO);
String taskId = pushInfoGetTaskId(map, stationVO, orderVO);
// 根据 taskId 获取链接
return taskId;
}
/**
* 通过taskId获取链接
* @param taskId
* @param reportType 1-web链接2-pdf链接
* @return
*/
public String getUrlByTaskId(String taskId, String reportType) {
// 根据 taskId 获取链接·
// 默认 web 端 url
String apiUrl = webDomainPrefix + apiPrefix + "web/" + taskId;
if (StringUtils.equals(Constants.TWO, reportType)) {
@@ -104,9 +115,24 @@ public class BatteryChargeReportService {
String result = HttpRequest.get(apiUrl).execute().body();
log.info("发送获取报告result:{}", result);
return 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");
String pdfUrl = batteryReportResult.getPdfUrl();
if (StringUtils.isBlank(pdfUrl)) {
String webUrl = batteryReportResult.getWebUrl();
return webUrl;
}
return pdfUrl;
}
public static void main(String[] args) {
String taskId = "8b8c2fed952f41d39eb583d0021c9908";
String url = "https://wx.btiger.net/jeecg-boot" + "/api/docking/report/" + "web/" + taskId;