xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/controller/XpVehicleCleanController.java
@@ -18,6 +18,7 @@ import com.xiaopeng.maintenance.model.vo.XpVehicleCleanVO; import com.xiaopeng.maintenance.service.IXpVehicleCleanService; import com.xiaopeng.maintenance.service.XpTaskService; import com.xiaopeng.maintenance.utils.AliOssDownloadUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -64,6 +65,8 @@ private ThreadPoolTaskScheduler taskScheduler; @Autowired private AliOssService aliOssService; @Autowired private AliOssDownloadUtil aliOssDownloadUtil; /** * 车辆运维-车辆运维-车身清洁 @@ -168,23 +171,7 @@ for (XpVehicleClean record : records) { String taskImage = record.getTaskImage(); if (StringUtils.isNotBlank(taskImage)) { JSONArray jsonArray = JSONArray.parseArray(taskImage); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } record.setTaskImage(JSONArray.toJSONString(jsonArray)); } record.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(record.getTaskImage())); data.stream().filter(xpOperationsUser -> xpOperationsUser.getId().equals(record.getOperationsUserId())).findFirst().ifPresent(xpOperationsUser -> record.setCreateBy(xpOperationsUser.getNickName())); } return R.ok(page); xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/controller/XpVehicleDetectionController.java
@@ -13,6 +13,7 @@ import com.xiaopeng.maintenance.model.vo.XpVehicleDetectionVO; import com.xiaopeng.maintenance.service.IXpVehicleDetectionService; import com.xiaopeng.maintenance.service.XpTaskService; import com.xiaopeng.maintenance.utils.AliOssDownloadUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -54,7 +55,8 @@ private XpOperationUserClient xpOperationUserClient; @Autowired private XpTaskService xpTaskService; @Autowired private AliOssDownloadUtil aliOssDownloadUtil; /** * 车辆运维-车辆运维-开始自检 */ @@ -220,122 +222,17 @@ public R<PageInfo<XpVehicleDetectionVO>> queryDetectionByVehicleId(@Valid @RequestBody XpVehicleDetectionPageQuery query) throws UnsupportedEncodingException { PageInfo<XpVehicleDetectionVO> pageInfo = xpVehicleDetectionService.queryDetectionByVehicleId(query); for (XpVehicleDetectionVO xpVehicleDetectionVO : pageInfo.getRecords()) { String vehiclePictures = xpVehicleDetectionVO.getVehiclePictures(); if (vehiclePictures != null && !vehiclePictures.isEmpty()) { JSONObject jsonObject = JSONObject.parseObject(vehiclePictures); // 1 String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); xpVehicleDetectionVO.setVehiclePictures(jsonObject.toJSONString()); } xpVehicleDetectionVO.setVehiclePictures(aliOssDownloadUtil.getPictureJSONObject(xpVehicleDetectionVO.getVehiclePictures())); xpVehicleDetectionVO.setSensorCleaningPicture(aliOssDownloadUtil.getPictureJsonArray(xpVehicleDetectionVO.getSensorCleaningPicture())); String sensorCleaningPicture = xpVehicleDetectionVO.getSensorCleaningPicture(); if (StringUtils.isNotBlank(sensorCleaningPicture)) { JSONArray jsonArray = JSONArray.parseArray(sensorCleaningPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); // 1 String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpVehicleDetectionVO.setSensorCleaningPicture(JSONArray.toJSONString(jsonArray)); } xpVehicleDetectionVO.setInteractiveScreenPicture(aliOssDownloadUtil.getPictureJsonArray(xpVehicleDetectionVO.getInteractiveScreenPicture())); xpVehicleDetectionVO.setHelpButtonPicture(aliOssDownloadUtil.getPictureJsonArray(xpVehicleDetectionVO.getHelpButtonPicture())); String interactiveScreenPicture = xpVehicleDetectionVO.getInteractiveScreenPicture(); if (StringUtils.isNotBlank(interactiveScreenPicture)) { JSONArray jsonArray = JSONArray.parseArray(interactiveScreenPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } // 1 String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpVehicleDetectionVO.setInteractiveScreenPicture(JSONArray.toJSONString(jsonArray)); } xpVehicleDetectionVO.setPaymentFunctionPicture(aliOssDownloadUtil.getPictureJsonArray(xpVehicleDetectionVO.getPaymentFunctionPicture())); String helpButtonPicture = xpVehicleDetectionVO.getHelpButtonPicture(); if (StringUtils.isNotBlank(helpButtonPicture)) { JSONArray jsonArray = JSONArray.parseArray(helpButtonPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } // 1 String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpVehicleDetectionVO.setHelpButtonPicture(JSONArray.toJSONString(jsonArray)); } String paymentFunctionPicture = xpVehicleDetectionVO.getPaymentFunctionPicture(); if (StringUtils.isNotBlank(paymentFunctionPicture)) { JSONArray jsonArray = JSONArray.parseArray(paymentFunctionPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } // 1 String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpVehicleDetectionVO.setPaymentFunctionPicture(JSONArray.toJSONString(jsonArray)); } String systemCheckPicture = xpVehicleDetectionVO.getSystemCheckPicture(); if (StringUtils.isNotBlank(systemCheckPicture)) { JSONArray jsonArray = JSONArray.parseArray(systemCheckPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } // 1 String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } xpVehicleDetectionVO.setSystemCheckPicture(JSONArray.toJSONString(jsonArray)); } xpVehicleDetectionVO.setSystemCheckPicture(aliOssDownloadUtil.getPictureJsonArray(xpVehicleDetectionVO.getSystemCheckPicture())); } return R.ok(pageInfo); } xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpChargingRecordServiceImpl.java
@@ -20,6 +20,7 @@ import com.xiaopeng.maintenance.model.query.XpChargingRecordPageQuery; import com.xiaopeng.maintenance.model.vo.XpChargingRecordVO; import com.xiaopeng.maintenance.service.IXpChargingRecordService; import com.xiaopeng.maintenance.utils.AliOssDownloadUtil; import com.xiaopeng.maintenance.vo.ChargingStatusVO; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -55,6 +56,9 @@ @Autowired private AliOssService aliOssService; @Autowired private AliOssDownloadUtil aliOssDownloadUtil; @Override public void startCharging(XpChargingRecordStartDTO dto, Long id) { // 创建车辆充电记录 @@ -265,69 +269,10 @@ } String vehiclePictures = vo.getVehiclePictures(); if (StringUtils.isNotBlank(vehiclePictures)) { JSONArray jsonArray = JSONArray.parseArray(vehiclePictures); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } vo.setVehiclePictures(JSONArray.toJSONString(jsonArray)); } vo.setVehiclePictures(aliOssDownloadUtil.getPictureJSONObject(vo.getVehiclePictures())); String startChargingPicture = vo.getStartChargingPicture(); if (StringUtils.isNotBlank(startChargingPicture)) { JSONArray jsonArray = JSONArray.parseArray(startChargingPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } vo.setStartChargingPicture(JSONArray.toJSONString(jsonArray)); } String endChargingPicture = vo.getEndChargingPicture(); if (StringUtils.isNotBlank(endChargingPicture)) { JSONArray jsonArray = JSONArray.parseArray(endChargingPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } vo.setEndChargingPicture(JSONArray.toJSONString(jsonArray)); } vo.setStartChargingPicture(aliOssDownloadUtil.getPictureJsonArray(vo.getStartChargingPicture())); vo.setEndChargingPicture(aliOssDownloadUtil.getPictureJsonArray(vo.getEndChargingPicture())); records.add(vo); } } xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java
@@ -45,6 +45,7 @@ import com.xiaopeng.maintenance.service.IXpTaskRuleRoleService; import com.xiaopeng.maintenance.service.IXpTaskRuleService; import com.xiaopeng.maintenance.service.XpTaskService; import com.xiaopeng.maintenance.utils.AliOssDownloadUtil; import com.xiaopeng.maintenance.utils.GDMapGeocodingUtil; import com.xiaopeng.maintenance.utils.UUIDUtil; import com.xiaopeng.maintenance.vo.TaskCleanDetailVO; @@ -141,6 +142,8 @@ @Resource private AliOssService aliOssService; @Autowired private AliOssDownloadUtil aliOssDownloadUtil; @Override public PageInfo<WorkBenchVO> workbench(WorkBenchQuery query) throws UnsupportedEncodingException { @@ -1288,28 +1291,8 @@ PageInfo<XpTaskRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); for (XpTaskRecordVO record : records) { String taskImage = record.getTaskImage(); if (StringUtils.isNotBlank(taskImage)) { JSONArray jsonArray = JSONArray.parseArray(taskImage); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url"); ; try { // 1 downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } jsonObject.put("url", downloadUrl); } record.setTaskImage(JSONArray.toJSONString(jsonArray)); } record.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(record.getTaskCode())); } xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpVehiclePreparationServiceImpl.java
@@ -21,6 +21,7 @@ import com.xiaopeng.maintenance.model.vo.OperationRecordsVO; import com.xiaopeng.maintenance.model.vo.XpVehiclePreparationVO; import com.xiaopeng.maintenance.service.IXpVehiclePreparationService; import com.xiaopeng.maintenance.utils.AliOssDownloadUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -66,6 +67,8 @@ private MongoTemplate mongoTemplate; @Autowired private AliOssService aliOssService; @Autowired private AliOssDownloadUtil aliOssDownloadUtil; @Override public PageInfo<OperationRecordsVO> operationRecords(OperationRecordsQuery query) { @@ -314,6 +317,16 @@ String userName = userNameMap.get(preparation.getOperationsUserId()); vo.setOperationsUserName(userName); } preparation.setLeftFrontWheel(aliOssDownloadUtil.getPictureJsonArray(preparation.getLeftFrontWheel())); preparation.setRightFrontWheel(aliOssDownloadUtil.getPictureJsonArray(preparation.getRightFrontWheel())); preparation.setLeftRearWheel(aliOssDownloadUtil.getPictureJsonArray(preparation.getLeftRearWheel())); preparation.setRightRearWheel(aliOssDownloadUtil.getPictureJsonArray(preparation.getRightRearWheel())); preparation.setBrakeLight(aliOssDownloadUtil.getPictureJsonArray(preparation.getBrakeLight())); preparation.setFogLight(aliOssDownloadUtil.getPictureJsonArray(preparation.getFogLight())); preparation.setBodyEmblem(aliOssDownloadUtil.getPictureJsonArray(preparation.getBodyEmblem())); preparation.setCabinCleaning(aliOssDownloadUtil.getPictureJsonArray(preparation.getCabinCleaning())); preparation.setLostItems(aliOssDownloadUtil.getPictureJsonArray(preparation.getLostItems())); records.add(vo); } xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpVehicleRepairServiceImpl.java
@@ -22,9 +22,11 @@ import com.xiaopeng.maintenance.model.vo.XpVehicleRepairMgtVO; import com.xiaopeng.maintenance.model.vo.XpVehicleRepairVO; import com.xiaopeng.maintenance.service.IXpVehicleRepairService; import com.xiaopeng.maintenance.utils.AliOssDownloadUtil; import com.xiaopeng.maintenance.vo.ChargingStatusVO; import com.xiaopeng.maintenance.vo.RepairStatusVO; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -54,6 +56,9 @@ @Autowired private AliOssService aliOssService; @Autowired private AliOssDownloadUtil aliOssDownloadUtil; @Override public XpVehicleRepairVO repairDetail(Long id) { // 查询车辆充电记录 @@ -65,7 +70,7 @@ XpVehicle xpVehicle = xpVehicleClient.queryById(xpVehicleRepair.getVehicleId()).getData(); if (Objects.nonNull(xpVehicle)) { xpVehicleRepairVO.setPlateNumber(xpVehicle.getPlateNumber()); xpVehicleRepairVO.setVehiclePictures(xpVehicle.getVehiclePictures()); xpVehicleRepairVO.setVehiclePictures(aliOssDownloadUtil.getPictureJSONObject(xpVehicle.getVehiclePictures())); xpVehicleRepairVO.setAcceptOrTest(xpVehicle.getAcceptOrTest()); xpVehicleRepairVO.setVehicleColor(xpVehicle.getVehicleColor()); } @@ -171,46 +176,10 @@ } String RepairMoneyDetail = vo.getRepairMoneyDetail(); if (StringUtils.isNotBlank(RepairMoneyDetail)) { JSONArray jsonArray = JSONArray.parseArray(RepairMoneyDetail); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } vo.setRepairMoneyDetail(JSONArray.toJSONString(jsonArray)); } vo.setRepairMoneyDetail(aliOssDownloadUtil.getPictureJsonArray(RepairMoneyDetail)); String StartRepairPicture = vo.getStartRepairPicture(); if (StringUtils.isNotBlank(StartRepairPicture)) { JSONArray jsonArray = JSONArray.parseArray(StartRepairPicture); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = jsonObject.getString("url");; try { downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } vo.setStartRepairPicture(JSONArray.toJSONString(jsonArray)); } vo.setStartRepairPicture(aliOssDownloadUtil.getPictureJsonArray(StartRepairPicture)); records.add(vo); } } xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/utils/AliOssDownloadUtil.java
New file @@ -0,0 +1,88 @@ package com.xiaopeng.maintenance.utils; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.xiaopeng.evi.oss.service.AliOssService; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.UnsupportedEncodingException; import java.util.Objects; /** * @author MiTao * @date 2026-03-25 11:24 * */ @Slf4j @Component public class AliOssDownloadUtil { @Autowired private AliOssService aliOssService; public String getPictureJsonArray(String json) { JSONArray res = new JSONArray(); if (json == null || json.isEmpty()) { return res.toJSONString(); } if (json.startsWith("{")) { JSONObject jsonObject = JSONObject.parseObject(json); if (Objects.isNull(jsonObject)) { return res.toJSONString(); } String downloadUrl = ""; try { downloadUrl = aliOssService.getDownloadUrl( jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); res.add(jsonObject); } else if (json.startsWith("[")) { JSONArray jsonArray = JSONArray.parseArray(json); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (Objects.isNull(jsonObject)) { continue; } String downloadUrl = ""; try { downloadUrl = aliOssService.getDownloadUrl( jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); } res = jsonArray; } return res.toJSONString(); } /** * JSONObject类型图片 * @param json * @return */ public String getPictureJSONObject(String json){ JSONObject jsonObject = JSONObject.parseObject(json); if (Objects.isNull(jsonObject)) { return new JSONObject().toJSONString(); } String downloadUrl = jsonObject.getString("url"); try { downloadUrl = aliOssService.getDownloadUrl( jsonObject.getString("id"), jsonObject.getString("name"), true); } catch (UnsupportedEncodingException e) { log.error("获取图片下载地址失败", e); } jsonObject.put("url", downloadUrl); return jsonObject.toJSONString(); } }