update 电池算法报告平台

This commit is contained in:
Lemon
2025-11-20 11:02:44 +08:00
parent 277fad8918
commit 3a0ba80c5c
6 changed files with 195 additions and 22 deletions

View File

@@ -9,10 +9,8 @@ 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.service.OrderBasicInfoService;
import com.jsowell.pile.service.PileBasicInfoService;
import com.jsowell.pile.service.PileConnectorInfoService;
import com.jsowell.pile.service.PileStationInfoService;
import com.jsowell.pile.domain.ChargeAlgorithmRecord;
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;
@@ -70,6 +68,8 @@ public class BatteryChargeReportService {
@Autowired
private PileStationInfoService pileStationInfoService;
private ChargeAlgorithmRecordService chargeAlgorithmRecordService;
/**
* 通过订单号统一发送充电电池数据获取 taskId
*
@@ -96,6 +96,16 @@ public class BatteryChargeReportService {
Map<String, Object> map = getDatasByOrderVO(orderVO);
String taskId = pushInfoGetTaskId(map, stationVO, orderVO);
if (StringUtils.isBlank(taskId)) {
log.error("订单:{} 获取到 taskId 为空", orderCode);
return null;
}
// 存入数据库
ChargeAlgorithmRecord record = new ChargeAlgorithmRecord();
record.setOrderCode(orderCode);
record.setTaskId(taskId);
chargeAlgorithmRecordService.insertOrUpdateSelective(record);
return taskId;
}
@@ -106,11 +116,18 @@ public class BatteryChargeReportService {
* @return
*/
public String getUrlByTaskId(String taskId, String reportType) {
// 根据 taskId 获取链接·
// 默认 web 端 url
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 端
// 2-pdf 端
apiUrl = webDomainPrefix + apiPrefix + "pdf/" + taskId;
}
// 发送请求
@@ -127,17 +144,23 @@ public class BatteryChargeReportService {
// 将 result 部分转换成 BatteryReportResult 对象
// 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();
return webUrl;
if (StringUtils.equals(Constants.ONE, reportType)) {
// 1-web 端
resultUrl = batteryReportResult.getWebUrl();
record.setWebUrl(resultUrl);
}else {
// pdf 端
resultUrl = batteryReportResult.getPdfUrl();
record.setPdfUrl(resultUrl);
}
return pdfUrl;
// 保存到数据库
chargeAlgorithmRecordService.updateChargeAlgorithmRecord(record);
return resultUrl;
}
public static void main(String[] args) {
String taskId = "8b8c2fed952f41d39eb583d0021c9908";
String taskId = "1e6e42aa613947bf863bc455c2f3357e";
String url = "https://wx.btiger.net/jeecg-boot" + "/api/docking/report/" + "web/" + taskId;
String result = HttpRequest.get(url).execute().body();