liujie
2026-03-25 d597b03477f904bc87bc9c3a984f9bfa485a906d
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;
    /**
     * 车辆运维-车辆运维-开始自检
     */
@@ -106,7 +108,7 @@
        if (vehiclePictures != null && !vehiclePictures.isEmpty()) {
            JSONObject jsonObject = JSONObject.parseObject(vehiclePictures);
            // 2
                String downloadUrl = jsonObject.getString("url");;
                String downloadUrl = jsonObject.getString("url");
                try {
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
@@ -123,7 +125,7 @@
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");;
                String downloadUrl = jsonObject.getString("url");
                try {
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
@@ -141,7 +143,7 @@
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");;
                String downloadUrl = jsonObject.getString("url");
                try {
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
@@ -159,7 +161,7 @@
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");;
                String downloadUrl = jsonObject.getString("url");
                try {
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
@@ -177,7 +179,7 @@
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");;
                String downloadUrl = jsonObject.getString("url");
                try {
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
@@ -195,7 +197,7 @@
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");;
                String downloadUrl = jsonObject.getString("url");
                try {
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
@@ -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);
    }