diff --git a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChargeAlgorithmController.java b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChargeAlgorithmController.java index f80d889e4..a1cc8c279 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChargeAlgorithmController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/thirdparty/ChargeAlgorithmController.java @@ -3,6 +3,7 @@ package com.jsowell.api.thirdparty; import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.response.RestApiResponse; +import com.jsowell.common.util.StringUtils; import com.jsowell.thirdparty.platform.dto.BatteryChargeReportDTO; import com.jsowell.thirdparty.platform.service.impl.BatteryChargeReportService; import com.jsowell.thirdparty.platform.service.impl.ChargeAlgorithmService; @@ -31,8 +32,12 @@ public class ChargeAlgorithmController extends BaseController { RestApiResponse response = null; try { // String result = chargeAlgorithmService.pushOrderInfo(orderCode); - String result = batteryChargeReportService.getTaskIdByOrderCode(dto.getOrderCode(), dto.getReportType()); - response = new RestApiResponse<>(result); + String taskId = batteryChargeReportService.getTaskIdByOrderCode(dto.getOrderCode()); + String url = ""; + if (StringUtils.isNotBlank(taskId)) { + url = batteryChargeReportService.getUrlByTaskId(taskId, dto.getReportType()); + } + response = new RestApiResponse<>(url); }catch (Exception e) { logger.error("算法应用推送订单信息 error, ", e); response = new RestApiResponse<>(e); diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index c73a4d0fd..132cb4534 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -86,6 +86,7 @@ import com.jsowell.thirdparty.parking.common.bean.QcyunParkCouponDTO; import com.jsowell.thirdparty.parking.service.LTYTService; import com.jsowell.thirdparty.parking.service.QcyunsService; import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService; +import com.jsowell.thirdparty.platform.service.impl.BatteryChargeReportService; import com.jsowell.thirdparty.platform.util.Cryptos; import com.jsowell.thirdparty.platform.util.Encodes; import com.jsowell.thirdparty.platform.util.GBSignUtils; @@ -292,6 +293,9 @@ public class SpringBootTestController { @Autowired private OrderSplitRecordService orderSplitRecordService; + @Autowired + private BatteryChargeReportService batteryChargeReportService; + @Qualifier("zhongDianLianPlatformServiceImpl") private ThirdPartyPlatformService platformLogic; @@ -305,6 +309,21 @@ public class SpringBootTestController { private final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10, JsowellThreadFactory.forName("test-thread-factory")); + @Test + public void testBatteryReport() throws InterruptedException { + String orderCode = "C25787997784"; + String taskId = batteryChargeReportService.getTaskIdByOrderCode(orderCode); + + + // String taskId = "f46d86c5fc9942c3a4806aa97120d279"; + String url = batteryChargeReportService.getUrlByTaskId(taskId, Constants.TWO); + if (StringUtils.isBlank(url)) { + Thread.sleep(2000); + url = batteryChargeReportService.getUrlByTaskId(taskId, Constants.TWO); + } + System.out.println(url); + } + @Test public void testThread() { threadFactory.newThread(() -> System.out.println("testThread:"+ Thread.currentThread().getName())); 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 index 0c08db650..3692a9bea 100644 --- 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 @@ -33,4 +33,6 @@ public class BatteryReportResult { private String taskId; private String directUrl; + + private String timestamp; } 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 76ebeffab..eb2c9bf4e 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 @@ -2,6 +2,7 @@ package com.jsowell.thirdparty.platform.service.impl; 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.*; @@ -74,7 +75,7 @@ public class BatteryChargeReportService { * * @param orderCode */ - public String getTaskIdByOrderCode(String orderCode, String reportType) { + public String getTaskIdByOrderCode(String orderCode) { // 根据订单号查询订单信息 OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(orderCode); if (orderVO == null) { @@ -124,7 +125,8 @@ public class BatteryChargeReportService { } // 获取对应的 url // 将 result 部分转换成 BatteryReportResult 对象 - BatteryReportResult batteryReportResult = (BatteryReportResult) resultMap.get("result"); + // BatteryReportResult batteryReportResult = (BatteryReportResult) resultMap.get("result"); + BatteryReportResult batteryReportResult = JSONObject.parseObject(resultMap.get("result").toString(), BatteryReportResult.class);; String pdfUrl = batteryReportResult.getPdfUrl(); if (StringUtils.isBlank(pdfUrl)) { String webUrl = batteryReportResult.getWebUrl();