liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/controller/XpVehicleDetectionController.java
@@ -1,10 +1,9 @@
package com.xiaopeng.maintenance.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.xiaopeng.api.feignClient.account.XpOperationUserClient;
import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.common.security.service.TokenService;
@@ -14,8 +13,10 @@
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;
import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
@@ -26,9 +27,9 @@
import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
 * <p>
@@ -38,6 +39,7 @@
 * @author xiaochen
 * @since 2026-02-06
 */
@Slf4j
@Api(tags = "车辆检测")
@RestController
@RequestMapping("")
@@ -53,12 +55,13 @@
    private XpOperationUserClient xpOperationUserClient;
    @Autowired
    private XpTaskService xpTaskService;
    @Autowired
    private AliOssDownloadUtil aliOssDownloadUtil;
    /**
     * 车辆运维-车辆运维-开始自检
     */
    @ApiOperation(value = "车辆运维-车辆运维-开始自检", tags = {"运维APP-车辆管理"})
    @GetMapping("/api/v1/vehicleDetection/startDetection")
    @GetMapping("/maintenance-app/api/v1/vehicleDetection/startDetection")
    public R<Map<String, Integer>> startDetection(@RequestParam Long vehicleId) {
        // TODO 开始自检
@@ -74,13 +77,14 @@
    }
    /**
     * 车辆详情-车辆运维-车辆检测提交
     */
    @Transactional
    @ShardingSphereTransactionType(TransactionType.BASE)
    @ApiOperation(value = "车辆运维-车辆运维-车辆检测提交", tags = {"运维APP-车辆管理"})
    @PostMapping("/api/v1/vehicleDetection/saveDetection")
    @PostMapping("/maintenance-app/api/v1/vehicleDetection/saveDetection")
    public R<String> saveDetection(@RequestBody XpVehicleDetectionDTO dto) {
        Long id = tokenService.getLoginOperationUser().getId();
        dto.setOperationsUserId(id);
@@ -96,15 +100,20 @@
     * 车辆运维-车辆运维-检测记录详情
     */
    @ApiOperation(value = "车辆运维-运维记录-检测记录详情", tags = {"运维APP-车辆管理"})
    @GetMapping("/api/v1/vehicleDetection/detectionDetail")
    @GetMapping("/maintenance-app/api/v1/vehicleDetection/detectionDetail")
    public R<XpVehicleDetectionVO> detectionDetail(@RequestParam Long id) throws UnsupportedEncodingException {
        XpVehicleDetectionVO xpVehicleDetectionVO = xpVehicleDetectionService.detectionDetail(id);
        String vehiclePictures = xpVehicleDetectionVO.getVehiclePictures();
        if (vehiclePictures != null && !vehiclePictures.isEmpty()) {
            JSONObject jsonObject = JSONObject.parseObject(vehiclePictures);
            // 1
            String downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
            // 2
                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());
        }
@@ -113,14 +122,14 @@
        String sensorCleaningPicture = xpVehicleDetectionVO.getSensorCleaningPicture();
        if (StringUtils.isNotBlank(sensorCleaningPicture)) {
            JSONArray jsonArray = JSONArray.parseArray(sensorCleaningPicture);
            for (Object o : jsonArray) {
                JSONObject jsonObject = (JSONObject)o;
                String downloadUrl = null;
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");
                try {
                    //1
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                    log.error("获取图片下载地址失败", e);
                }
                jsonObject.put("url", downloadUrl);
            }
@@ -131,14 +140,14 @@
        String interactiveScreenPicture = xpVehicleDetectionVO.getInteractiveScreenPicture();
        if (StringUtils.isNotBlank(interactiveScreenPicture)) {
            JSONArray jsonArray = JSONArray.parseArray(interactiveScreenPicture);
            for (Object o : jsonArray) {
                JSONObject jsonObject = (JSONObject)o;
                String downloadUrl = null;
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");
                try {
                    //1
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                    log.error("获取图片下载地址失败", e);
                }
                jsonObject.put("url", downloadUrl);
            }
@@ -149,14 +158,14 @@
        String helpButtonPicture = xpVehicleDetectionVO.getHelpButtonPicture();
        if (StringUtils.isNotBlank(helpButtonPicture)) {
            JSONArray jsonArray = JSONArray.parseArray(helpButtonPicture);
            for (Object o : jsonArray) {
                JSONObject jsonObject = (JSONObject)o;
                String downloadUrl = null;
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");
                try {
                    //1
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                    log.error("获取图片下载地址失败", e);
                }
                jsonObject.put("url", downloadUrl);
            }
@@ -167,14 +176,14 @@
        String paymentFunctionPicture = xpVehicleDetectionVO.getPaymentFunctionPicture();
        if (StringUtils.isNotBlank(paymentFunctionPicture)) {
            JSONArray jsonArray = JSONArray.parseArray(paymentFunctionPicture);
            for (Object o : jsonArray) {
                JSONObject jsonObject = (JSONObject)o;
                String downloadUrl = null;
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");
                try {
                    //1
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                    log.error("获取图片下载地址失败", e);
                }
                jsonObject.put("url", downloadUrl);
            }
@@ -185,14 +194,14 @@
        String systemCheckPicture = xpVehicleDetectionVO.getSystemCheckPicture();
        if (StringUtils.isNotBlank(systemCheckPicture)) {
            JSONArray jsonArray = JSONArray.parseArray(systemCheckPicture);
            for (Object o : jsonArray) {
                JSONObject jsonObject = (JSONObject)o;
                String downloadUrl = null;
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                // 1
                String downloadUrl = jsonObject.getString("url");
                try {
                    //1
                    downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                } catch (UnsupportedEncodingException e) {
                    throw new RuntimeException(e);
                    log.error("获取图片下载地址失败", e);
                }
                jsonObject.put("url", downloadUrl);
            }
@@ -213,105 +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 = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                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 (Object o : jsonArray) {
                    JSONObject jsonObject = (JSONObject)o;
                    String downloadUrl = null;
                    try {
                        // 1
                        downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                    } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(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 (Object o : jsonArray) {
                    JSONObject jsonObject = (JSONObject)o;
                    String downloadUrl = null;
                    try {
                        //1
                        downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                    } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(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 (Object o : jsonArray) {
                    JSONObject jsonObject = (JSONObject)o;
                    String downloadUrl = null;
                    try {
                        //1
                        downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                    } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(e);
                    }
                    jsonObject.put("url", downloadUrl);
                }
                xpVehicleDetectionVO.setHelpButtonPicture(JSONArray.toJSONString(jsonArray));
            }
            String paymentFunctionPicture = xpVehicleDetectionVO.getPaymentFunctionPicture();
            if (StringUtils.isNotBlank(paymentFunctionPicture)) {
                JSONArray jsonArray = JSONArray.parseArray(paymentFunctionPicture);
                for (Object o : jsonArray) {
                    JSONObject jsonObject = (JSONObject)o;
                    String downloadUrl = null;
                    try {
                        //1
                        downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                    } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(e);
                    }
                    jsonObject.put("url", downloadUrl);
                }
                xpVehicleDetectionVO.setPaymentFunctionPicture(JSONArray.toJSONString(jsonArray));
            }
            String systemCheckPicture = xpVehicleDetectionVO.getSystemCheckPicture();
            if (StringUtils.isNotBlank(systemCheckPicture)) {
                JSONArray jsonArray = JSONArray.parseArray(systemCheckPicture);
                for (Object o : jsonArray) {
                    JSONObject jsonObject = (JSONObject)o;
                    String downloadUrl = null;
                    try {
                        //1
                        downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true);
                    } catch (UnsupportedEncodingException e) {
                        throw new RuntimeException(e);
                    }
                    jsonObject.put("url", downloadUrl);
                }
                xpVehicleDetectionVO.setSystemCheckPicture(JSONArray.toJSONString(jsonArray));
            }
            xpVehicleDetectionVO.setSystemCheckPicture(aliOssDownloadUtil.getPictureJsonArray(xpVehicleDetectionVO.getSystemCheckPicture()));
        }
        return R.ok(pageInfo);
    }