From d11383a04cfbaf7f410ad4cdb81e5904a21ff277 Mon Sep 17 00:00:00 2001 From: Lemon Date: Fri, 12 Sep 2025 11:03:09 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E7=94=B5=E6=B1=A0=E5=85=85?= =?UTF-8?q?=E7=94=B5=E6=8A=A5=E5=91=8A=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/domain/BatteryReportResult.java | 36 +++++++++++++++++++ .../impl/BatteryChargeReportService.java | 30 ++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BatteryReportResult.java diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BatteryReportResult.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BatteryReportResult.java new file mode 100644 index 000000000..0c08db650 --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/domain/BatteryReportResult.java @@ -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; +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/BatteryChargeReportService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/BatteryChargeReportService.java index 0023ce757..b9a9255d7 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/BatteryChargeReportService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/BatteryChargeReportService.java @@ -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 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 resultMap = (Map) 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;