“mitao”
2026-03-25 915599e28042d8b47774f7fe695a7019d81efbda
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java
@@ -1,10 +1,12 @@
package com.xiaopeng.maintenance.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.xiaopeng.api.dto.pushMessage.AliPushMessageDTO;
import com.xiaopeng.api.feignClient.account.SysUserClient;
import com.xiaopeng.api.feignClient.account.XpOperationUserClient;
@@ -13,6 +15,7 @@
import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient;
import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetVehicleClient;
import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient;
import com.xiaopeng.api.model.account.SysUser;
import com.xiaopeng.api.model.account.XpOperationsRole;
import com.xiaopeng.api.model.account.XpOperationsUser;
import com.xiaopeng.api.model.account.XpOperationsUserNotification;
@@ -27,6 +30,7 @@
import com.xiaopeng.common.core.enums.TaskTypeNotificationEnum;
import com.xiaopeng.common.core.exception.ServiceException;
import com.xiaopeng.common.core.web.page.PageInfo;
import com.xiaopeng.evi.oss.service.AliOssService;
import com.xiaopeng.maintenance.constant.I18nKeyConstant;
import com.xiaopeng.maintenance.dto.HandleVehicleAccidentDto;
import com.xiaopeng.maintenance.dto.SaveErrorTaskDto;
@@ -41,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;
@@ -61,6 +66,7 @@
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
@@ -134,10 +140,33 @@
    @Resource
    private XpFleetOperationsClient xpFleetOperationsClient;
    @Resource
    private AliOssService aliOssService;
    @Autowired
    private AliOssDownloadUtil aliOssDownloadUtil;
    @Override
    public PageInfo<WorkBenchVO> workbench(WorkBenchQuery query) {
    public PageInfo<WorkBenchVO> workbench(WorkBenchQuery query) throws UnsupportedEncodingException {
        PageInfo<WorkBenchVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<WorkBenchVO> list = this.baseMapper.workbench(pageInfo, query);
        for (WorkBenchVO workBenchVO : list) {
            String vehiclePictures = workBenchVO.getVehiclePictures();
            if (StringUtils.isNotBlank(vehiclePictures)) {
                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);
                workBenchVO.setVehiclePictures(jsonObject.toJSONString());
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
@@ -184,7 +213,6 @@
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
@@ -295,38 +323,58 @@
                }
                // 构建通知内容
                String content = String.format("车辆%s在%s发生了紧急事故,请在%d分钟内到达现场!", plateNumber, xpTask.getVehicleLocation(), processingTimeLimit);
                String bodyJson = buildAccidentPushBodyJson(content, xpTask);
                // 构建通知记录(包含 notificationExt)
                List<XpOperationsUserNotification> notifications = data.stream().map(item -> {
                    XpOperationsUserNotification notification = new XpOperationsUserNotification();
                    notification.setOperationsUserId(item.getId());
                    notification.setNotificationType(NotificationTypeEnum.ACCIDENT_NEW.getCode());
                    notification.setNotificationContent(content);
                    notification.setDataId(xpTask.getId());
                    notification.setReadStatus(0);
                    notification.setNotificationExt(bodyJson);
                    return notification;
                }).collect(Collectors.toList());
                // 批量保存通知记录
                xpOperationUserNotificationClient.addNotificationBatch(notifications);
                log.info("事故通知记录保存成功,共 {} 条", notifications.size());
                // 按设备类型分组发送阿里云推送
                Map<Integer, List<XpOperationsUser>> operationUserMap = data.stream()
                        .filter(u -> u.getDeviceType() != null && u.getPhoneNumber() != null)
                        .collect(Collectors.groupingBy(XpOperationsUser::getDeviceType));
                for (Map.Entry<Integer, List<XpOperationsUser>> entry : operationUserMap.entrySet()) {
                    pushAliMessage(entry.getValue(), content, xpTask);
                }
                String content = buildAccidentNotificationContent(xpTask, plateNumber, processingTimeLimit);
                saveAndPushAccidentNotification(data, content, xpTask);
            } catch (Exception e) {
                log.error("发送事故通知失败,任务ID={}", xpTask.getId(), e);
            }
        });
        executor.shutdown();
    }
    /**
     * 异步发送事故任务分配通知
     *
     * @param xpTask 任务信息
     * @param handlerUserId 当前分配的处理人
     * @param plateNumber 车牌号
     * @param processingTimeLimit 处理时限(分钟)
     */
    private void sendAssignedAccidentNotificationAsync(XpTask xpTask, Long handlerUserId, String plateNumber, Integer processingTimeLimit) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                1, 1, 0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>()
        );
        executor.execute(() -> {
            try {
                R<List<XpOperationsUser>> xpOperationUserResult = xpOperationUserClient.listByIds(Collections.singletonList(handlerUserId));
                List<XpOperationsUser> data = xpOperationUserResult == null ? Collections.emptyList() : xpOperationUserResult.getData();
                if (CollUtil.isEmpty(data)) {
                    return;
                }
                String content = buildAccidentNotificationContent(xpTask, plateNumber, processingTimeLimit);
                saveAndPushAccidentNotification(data, content, xpTask);
            } catch (Exception e) {
                log.error("发送事故任务分配通知失败,任务ID={}, handlerUserId={}", xpTask.getId(), handlerUserId, e);
            }
        });
        executor.shutdown();
    }
    /**
     * 构建事故通知文案
     *
     * @param xpTask 任务信息
     * @param plateNumber 车牌号
     * @param processingTimeLimit 处理时限(分钟)
     * @return 通知内容
     */
    private String buildAccidentNotificationContent(XpTask xpTask, String plateNumber, Integer processingTimeLimit) {
        return String.format("车辆%s在%s发生了紧急事故,请在%d分钟内到达现场!", plateNumber, xpTask.getVehicleLocation(), processingTimeLimit);
    }
    /**
@@ -342,6 +390,40 @@
        param.put("type", TaskTypeNotificationEnum.ACCIDENT_TASK.getCode());
        param.put("id", xpTask.getId().toString());
        return JSONObject.toJSONString(param);
    }
    /**
     * 保存事故通知记录并发送阿里云推送
     *
     * @param data 接收通知的运维人员
     * @param content 通知内容
     * @param xpTask 任务信息
     */
    private void saveAndPushAccidentNotification(List<XpOperationsUser> data, String content, XpTask xpTask) {
        String bodyJson = buildAccidentPushBodyJson(content, xpTask);
        List<XpOperationsUserNotification> notifications = data.stream().map(item -> {
            XpOperationsUserNotification notification = new XpOperationsUserNotification();
            notification.setOperationsUserId(item.getId());
            notification.setNotificationType(NotificationTypeEnum.ACCIDENT_NEW.getCode());
            notification.setNotificationContent(content);
            notification.setDataId(xpTask.getId());
            notification.setReadStatus(0);
            notification.setNotificationExt(bodyJson);
            return notification;
        }).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(notifications)) {
            xpOperationUserNotificationClient.addNotificationBatch(notifications);
            log.info("事故通知记录保存成功,共 {} 条", notifications.size());
        }
        Map<Integer, List<XpOperationsUser>> operationUserMap = data.stream()
                .filter(u -> u.getDeviceType() != null && StringUtils.isNotBlank(u.getPhoneNumber()))
                .collect(Collectors.groupingBy(XpOperationsUser::getDeviceType));
        for (Map.Entry<Integer, List<XpOperationsUser>> entry : operationUserMap.entrySet()) {
            pushAliMessage(entry.getValue(), content, xpTask);
        }
    }
    /**
@@ -367,7 +449,7 @@
    }
    @Override
    public R<TaskAccidentDetailVO> vehicleAccidentDetail(Long id) {
    public R<TaskAccidentDetailVO> vehicleAccidentDetail(Long id) throws UnsupportedEncodingException {
        TaskAccidentDetailVO res = new TaskAccidentDetailVO();
        XpTask task = this.getById(id);
        if (task == null) {
@@ -414,8 +496,30 @@
        if (Objects.nonNull(xpTaskRule)) {
            res.setCanArriveRange(xpTaskRule.getCanArriveRange());
        }
        String taskImage = res.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);
            }
            res.setTaskImage(JSONArray.toJSONString(jsonArray));
        }
        return R.ok(res);
    }
    @ShardingSphereTransactionType(TransactionType.BASE)
    @Transactional(rollbackFor = Exception.class)
    @Override
@@ -450,7 +554,7 @@
    }
    @Override
    public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) {
    public R<TaskRoutineDetailVO> vehicleRoutineDetail(Long id) throws UnsupportedEncodingException {
        TaskRoutineDetailVO res = new TaskRoutineDetailVO();
        XpTask task = this.getById(id);
        if (task == null) {
@@ -502,6 +606,26 @@
                res.setHandleUserName(data.getNickName());
            }
        }
        String taskImage = res.getTaskImage();
        if (StringUtils.isNotBlank(taskImage)) {
            JSONArray jsonArray = JSONArray.parseArray(taskImage);
            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);
            }
            res.setTaskImage(JSONArray.toJSONString(jsonArray));
        }
        return R.ok(res);
    }
@@ -539,10 +663,52 @@
                .eq(XpChargingRecord::getTaskId, id).last("limit 1"));
        if (chargingRecord != null) {
            res.setStartRemainingBattery(chargingRecord.getStartRemainingBattery());
            res.setStartChargingPicture(chargingRecord.getStartChargingPicture());
            String startChargingPicture = res.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);
                }
                res.setStartChargingPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setStartTime(chargingRecord.getStartTime());
            res.setEndRemainingBattery(chargingRecord.getEndRemainingBattery());
            res.setEndChargingPicture(chargingRecord.getEndChargingPicture());
            String endChargingPicture = chargingRecord.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);
                }
                res.setEndChargingPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setEndTime(chargingRecord.getEndTime());
            res.setStartOperationsUserId(chargingRecord.getStartOperationsUserId());
            res.setEndOperationsUserId(chargingRecord.getEndOperationsUserId());
@@ -601,7 +767,28 @@
            res.setStartTime(vehicleRepair.getStartTime());
            res.setEndTime(vehicleRepair.getEndTime());
            res.setRepairReason(vehicleRepair.getRepairReason());
            res.setStartRepairPicture(vehicleRepair.getStartRepairPicture());
            String startRepairPicture = vehicleRepair.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);
                }
                res.setStartRepairPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setRepairMoney(vehicleRepair.getRepairMoney());
            res.setRepairMoneyDetail(vehicleRepair.getRepairMoneyDetail());
            res.setSendUserId(vehicleRepair.getSendUserId());
@@ -614,6 +801,7 @@
                    res.setReturnUserName(operationsUser.getNickName());
                }
            }
            if (vehicleRepair.getSendUserId() != null) {
                XpOperationsUser operationsUser = xpOperationUserClient.queryById(vehicleRepair.getSendUserId()).getData();
                if (operationsUser != null) {
@@ -725,15 +913,118 @@
            res.setCollisionPrevention(vehicleDetection.getCollisionPrevention());
            res.setSensorSelfCheck(vehicleDetection.getSensorSelfCheck());
            res.setSensorCleaning(vehicleDetection.getSensorCleaning());
            res.setSensorCleaningPicture(vehicleDetection.getSensorCleaningPicture());
            String SensorCleaningPicture = vehicleDetection.getSensorCleaningPicture();
            if (StringUtils.isNotBlank(SensorCleaningPicture)) {
                JSONArray jsonArray = JSONArray.parseArray(SensorCleaningPicture);
                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);
                }
                res.setSensorCleaningPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setInteractiveScreen(vehicleDetection.getInteractiveScreen());
            res.setInteractiveScreenPicture(vehicleDetection.getInteractiveScreenPicture());
            String InteractiveScreenPicture = vehicleDetection.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;
                    }
                    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);
                }
                res.setInteractiveScreenPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setHelpButton(vehicleDetection.getHelpButton());
            res.setHelpButtonPicture(vehicleDetection.getHelpButtonPicture());
            String HelpButtonPicture = vehicleDetection.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;
                    }
                    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);
                }
                res.setHelpButtonPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setPaymentFunction(vehicleDetection.getPaymentFunction());
            res.setPaymentFunctionPicture(vehicleDetection.getPaymentFunctionPicture());
            String PaymentFunctionPicture = vehicleDetection.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;
                    }
                    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);
                }
                res.setPaymentFunctionPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setSystemCheck(vehicleDetection.getSystemCheck());
            res.setSystemCheckPicture(vehicleDetection.getSystemCheckPicture());
            String SystemCheckPicture = vehicleDetection.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;
                    }
                    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);
                }
                res.setSystemCheckPicture(JSONArray.toJSONString(jsonArray));
            }
            res.setCheckTime(vehicleDetection.getCheckTime());
            res.setOperationsUserId(vehicleDetection.getOperationsUserId());
            if (vehicleDetection.getOperationsUserId() != null) {
@@ -787,7 +1078,7 @@
    }
    @Override
    public R<TaskCleanDetailVO> cleanDetail(Long id) {
    public R<TaskCleanDetailVO> cleanDetail(Long id) throws UnsupportedEncodingException {
        TaskCleanDetailVO res = new TaskCleanDetailVO();
        XpTask task = this.getById(id);
        if (task == null) {
@@ -820,7 +1111,30 @@
                .eq(XpVehicleClean::getTaskId, id).last("limit 1"));
        if (vehicleDetection != null) {
            res.setHandleTime(vehicleDetection.getCreateTime());
            res.setTaskImage(vehicleDetection.getTaskImage());
            String taskImage = res.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);
                }
                res.setTaskImage(JSONArray.toJSONString(jsonArray));
            }
            res.setOperationUserId(vehicleDetection.getOperationsUserId());
            if (vehicleDetection.getOperationsUserId() != null) {
                XpOperationsUser operationsUser = xpOperationUserClient.queryById(vehicleDetection.getOperationsUserId()).getData();
@@ -904,7 +1218,7 @@
                            .account(operationsUser.getPhoneNumber())
                            .title("任务状态变更")
                            .body(bodyJson)
                            .pushType(AliPushTypeConstant.NOTICE)
                            .pushType(AliPushTypeConstant.MESSAGE)
                            .build());
                }
            } catch (Exception e) {
@@ -1029,6 +1343,13 @@
        // 4. 构建分页结果
        PageInfo<XpTaskRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        for (XpTaskRecordVO record : records) {
            String taskImage = record.getTaskImage();
            record.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(record.getTaskCode()));
        }
        pageInfo.setRecords(records);
        pageInfo.setTotal(resultPage.getTotal());
        return pageInfo;
@@ -1057,10 +1378,10 @@
        PageInfo<TaskManagementPageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TaskManagementPageListVO> list = this.baseMapper.pageListManagement(pageInfo, query);
        for (TaskManagementPageListVO taskManagementPageListVO : list) {
            if (org.springframework.util.StringUtils.hasLength(taskManagementPageListVO.getHandleUserId())){
            if (org.springframework.util.StringUtils.hasLength(taskManagementPageListVO.getHandleUserId())) {
                String[] split = taskManagementPageListVO.getHandleUserId().split(",");
                List<XpOperationsUser> users = operationUserClient.listByIds(Arrays.stream(split).map(Long::parseLong).collect(Collectors.toList())).getData();
                if (users!=null){
                if (users != null) {
                    StringBuilder handleUserName = new StringBuilder();
                    for (XpOperationsUser user : users) {
                        handleUserName.append(user.getNickName()).append(";");
@@ -1131,10 +1452,10 @@
    public List<TaskManagementPageListVO> exportList(TaskManagementPageListQuery query) {
        List<TaskManagementPageListVO> list = this.baseMapper.exportList(query);
        for (TaskManagementPageListVO taskManagementPageListVO : list) {
            if (org.springframework.util.StringUtils.hasLength(taskManagementPageListVO.getHandleUserId())){
            if (org.springframework.util.StringUtils.hasLength(taskManagementPageListVO.getHandleUserId())) {
                String[] split = taskManagementPageListVO.getHandleUserId().split(",");
                List<XpOperationsUser> users = operationUserClient.listByIds(Arrays.stream(split).map(Long::parseLong).collect(Collectors.toList())).getData();
                if (users!=null){
                if (users != null) {
                    StringBuilder handleUserName = new StringBuilder();
                    for (XpOperationsUser user : users) {
                        handleUserName.append(user.getNickName()).append(";");
@@ -1256,16 +1577,41 @@
    @Override
    public R assigneeTask(Long id, Long handlerUserId, Long assigneeUserId) {
        XpTask task = this.getById(id);
        // 查询规则 任务结束时间从任务分配时开始计算
        XpTaskRule taskRule = xpTaskRuleMapper.selectOne(null);
        if (taskRule != null) {
            task.setEndTime(LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit()));
        if (task == null) {
            throw new ServiceException(
                    "任务不存在",
                    I18nKeyConstant.TASK_NOT_EXIST
            );
        }
        boolean isAccidentTask = Integer.valueOf(2).equals(task.getTaskCategory());
        Long vehicleId = task.getVehicleId();
        Integer processingTimeLimit = null;
        String plateNumber = "";
        if (isAccidentTask) {
            // 查询规则 任务结束时间从任务分配时开始计算
            XpTaskRule taskRule = xpTaskRuleMapper.selectOne(null);
            if (taskRule != null) {
                processingTimeLimit = taskRule.getProcessingTimeLimit();
                task.setEndTime(LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit()));
            }
            if (vehicleId != null) {
                XpVehicle vehicle = xpVehicleClient.queryById(vehicleId).getData();
                if (vehicle != null && StringUtils.isNotBlank(vehicle.getPlateNumber())) {
                    plateNumber = vehicle.getPlateNumber();
                }
            }
        } else {
            task.setEndTime(LocalDateTime.now().plusDays(3));
        }
        task.setAssigneeTime(LocalDateTime.now());
        task.setHandleUserId(handlerUserId.toString());
        task.setVehicleId(null);
        task.setAssigneeUserId(assigneeUserId);
        this.updateById(task);
        if (isAccidentTask && processingTimeLimit != null) {
            sendAssignedAccidentNotificationAsync(task, handlerUserId, plateNumber, processingTimeLimit);
        }
        return R.ok();
    }
@@ -1294,6 +1640,7 @@
            task.setReportTime(LocalDateTime.now());
            task.setExpiredNoticeSent(0);
            task.setWillTimeoutNoticeSent(0);
            task.setTaskSource(2);
            saveTask.add(task);
        }
        this.saveBatch(saveTask);
@@ -1301,7 +1648,7 @@
    }
    @Override
    public R<TaskManagementDetailVO> taskDetail(Long id) {
    public R<TaskManagementDetailVO> taskDetail(Long id) throws UnsupportedEncodingException {
        TaskManagementDetailVO managementDetailVO = new TaskManagementDetailVO();
        XpTask task = this.getById(id);
        if (task == null) {
@@ -1317,7 +1664,7 @@
                    I18nKeyConstant.VEHICLE_NOT_EXIST
            );
        }
        String vehiclePicture = aliOssDownloadUtil.getPictureJSONObject(vehicle.getVehiclePictures());
        if (task.getTaskCategory() == 1) {
            // 常规任务
@@ -1333,7 +1680,8 @@
                    taskManagementDetectionDetailVO.setVehicleCode(vehicle.getVehicleCode());
                    taskManagementDetectionDetailVO.setVehicleVin(vehicle.getVehicleVin());
                    taskManagementDetectionDetailVO.setVehicleLocation(task.getVehicleLocation());
                    taskManagementDetectionDetailVO.setVehiclePictures(vehicle.getVehiclePictures());
                    taskManagementDetectionDetailVO.setVehiclePictures(vehiclePicture);
                    taskManagementDetectionDetailVO.setTaskCode(task.getTaskCode());
                    XpVehicleDetection vehicleDetection = vehicleDetectionMapper.selectOne(new LambdaQueryWrapper<XpVehicleDetection>()
                            .eq(XpVehicleDetection::getTaskId, id).last("limit 1"));
@@ -1345,15 +1693,118 @@
                        taskManagementDetectionDetailVO.setCollisionPrevention(vehicleDetection.getCollisionPrevention());
                        taskManagementDetectionDetailVO.setSensorSelfCheck(vehicleDetection.getSensorSelfCheck());
                        taskManagementDetectionDetailVO.setSensorCleaning(vehicleDetection.getSensorCleaning());
                        taskManagementDetectionDetailVO.setSensorCleaningPicture(vehicleDetection.getSensorCleaningPicture());
                        String SensorCleaningPicture = vehicleDetection.getSensorCleaningPicture();
                        if (StringUtils.isNotBlank(SensorCleaningPicture)) {
                            JSONArray jsonArray = JSONArray.parseArray(SensorCleaningPicture);
                            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);
                            }
                            taskManagementDetectionDetailVO.setSensorCleaningPicture(JSONArray.toJSONString(jsonArray));
                        }
                        taskManagementDetectionDetailVO.setInteractiveScreen(vehicleDetection.getInteractiveScreen());
                        taskManagementDetectionDetailVO.setInteractiveScreenPicture(vehicleDetection.getInteractiveScreenPicture());
                        String InteractiveScreenPicture = vehicleDetection.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;
                                }
                                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);
                            }
                            taskManagementDetectionDetailVO.setInteractiveScreenPicture(JSONArray.toJSONString(jsonArray));
                        }
                        taskManagementDetectionDetailVO.setHelpButton(vehicleDetection.getHelpButton());
                        taskManagementDetectionDetailVO.setHelpButtonPicture(vehicleDetection.getHelpButtonPicture());
                        String HelpButtonPicture = vehicleDetection.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;
                                }
                                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);
                            }
                            taskManagementDetectionDetailVO.setHelpButtonPicture(JSONArray.toJSONString(jsonArray));
                        }
                        taskManagementDetectionDetailVO.setPaymentFunction(vehicleDetection.getPaymentFunction());
                        taskManagementDetectionDetailVO.setPaymentFunctionPicture(vehicleDetection.getPaymentFunctionPicture());
                        String PaymentFunctionPicture = vehicleDetection.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;
                                }
                                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);
                            }
                            taskManagementDetectionDetailVO.setPaymentFunctionPicture(JSONArray.toJSONString(jsonArray));
                        }
                        taskManagementDetectionDetailVO.setSystemCheck(vehicleDetection.getSystemCheck());
                        taskManagementDetectionDetailVO.setSystemCheckPicture(vehicleDetection.getSystemCheckPicture());
                        String SystemCheckPicture = vehicleDetection.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;
                                }
                                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);
                            }
                            taskManagementDetectionDetailVO.setSystemCheckPicture(JSONArray.toJSONString(jsonArray));
                        }
                        taskManagementDetectionDetailVO.setCheckTime(vehicleDetection.getCheckTime());
                        taskManagementDetectionDetailVO.setOperationsUserId(vehicleDetection.getOperationsUserId());
                        if (vehicleDetection.getOperationsUserId() != null) {
@@ -1377,7 +1828,7 @@
                    taskManagementChargingDetailVO.setVehicleVin(vehicle.getVehicleVin());
                    taskManagementChargingDetailVO.setVehicleLocation(task.getVehicleLocation());
                    taskManagementChargingDetailVO.setTaskCode(task.getTaskCode());
                    taskManagementChargingDetailVO.setVehiclePictures(vehicle.getVehiclePictures());
                    taskManagementChargingDetailVO.setVehiclePictures(vehiclePicture);
                    XpChargingRecord chargingRecord = chargingRecordMapper.selectOne(new LambdaQueryWrapper<XpChargingRecord>()
                            .eq(XpChargingRecord::getTaskId, id).last("limit 1"));
@@ -1418,7 +1869,7 @@
                    taskManagementPreparationDetailVO.setVehicleVin(vehicle.getVehicleVin());
                    taskManagementPreparationDetailVO.setVehicleLocation(task.getVehicleLocation());
                    taskManagementPreparationDetailVO.setTaskCode(task.getTaskCode());
                    taskManagementPreparationDetailVO.setVehiclePictures(vehicle.getVehiclePictures());
                    taskManagementPreparationDetailVO.setVehiclePictures(vehiclePicture);
                    XpVehiclePreparation vehiclePreparation = vehiclePreparationMapper.selectOne(new LambdaQueryWrapper<XpVehiclePreparation>()
                            .eq(XpVehiclePreparation::getTaskId, id).last("limit 1"));
@@ -1459,7 +1910,7 @@
                    taskManagementCleanDetailVO.setVehicleVin(vehicle.getVehicleVin());
                    taskManagementCleanDetailVO.setVehicleLocation(task.getVehicleLocation());
                    taskManagementCleanDetailVO.setTaskCode(task.getTaskCode());
                    taskManagementCleanDetailVO.setVehiclePictures(vehicle.getVehiclePictures());
                    taskManagementCleanDetailVO.setVehiclePictures(vehiclePicture);
                    XpVehicleClean vehicleClean = vehicleCleanMapper.selectOne(new LambdaQueryWrapper<XpVehicleClean>()
                            .eq(XpVehicleClean::getTaskId, id).last("limit 1"));
@@ -1488,7 +1939,7 @@
                    taskManagementRepairDetailVO.setVehicleVin(vehicle.getVehicleVin());
                    taskManagementRepairDetailVO.setVehicleLocation(task.getVehicleLocation());
                    taskManagementRepairDetailVO.setTaskCode(task.getTaskCode());
                    taskManagementRepairDetailVO.setVehiclePictures(vehicle.getVehiclePictures());
                    taskManagementRepairDetailVO.setVehiclePictures(vehiclePicture);
                    XpVehicleRepair vehicleRepair = vehicleRepairMapper.selectOne(new LambdaQueryWrapper<XpVehicleRepair>()
                            .eq(XpVehicleRepair::getTaskId, id).last("limit 1"));
@@ -1530,7 +1981,7 @@
                    res.setVehicleLocation(task.getVehicleLocation());
                    res.setVehicleVin(vehicle.getVehicleVin());
                    res.setTaskCode(task.getTaskCode());
                    res.setVehiclePictures(vehicle.getVehiclePictures());
                    res.setVehiclePictures(vehiclePicture);
                    XpTaskHandleDetailRoutine xpTaskHandleDetailRoutine = xpTaskHandleDetailRoutineMapper.selectOne(new LambdaQueryWrapper<XpTaskHandleDetailRoutine>()
                            .eq(XpTaskHandleDetailRoutine::getTaskId, id));
                    if (xpTaskHandleDetailRoutine != null) {
@@ -1574,7 +2025,27 @@
            res.setErrorTypeList(xpErrorTypes);
            res.setStatus(task.getStatus());
            res.setTaskDescription(task.getTaskDescription());
            res.setTaskImage(task.getTaskImage());
            String taskImage = task.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);
                }
                res.setTaskImage(JSONArray.toJSONString(jsonArray));
            }
            res.setId(id);
            res.setVehicleId(vehicle.getId());
            res.setTaskUrgencyLevel(task.getTaskUrgencyLevel());
@@ -1583,24 +2054,34 @@
            res.setVehicleCode(vehicle.getVehicleCode());
            res.setVehicleLocation(task.getVehicleLocation());
            res.setVehicleVin(vehicle.getVehicleVin());
            if (task.getReportUserId().equals(0L)){
            if (task.getReportUserId().equals(0L)) {
                // 系统补偿上传车辆异常任务 为系统创建
                res.setReportUserId(0L);
                res.setReportUserName("系统");
                // todo 临时设置 待客户确认默认头像和电话号码
                res.setReportUserPhone("111111");
                res.setReportUserAvatar("[]");
            }else{
                XpOperationsUser data = xpOperationUserClient.queryById(task.getReportUserId()).getData();
                if (data != null ) {
                    res.setReportUserId(data.getId());
                    res.setReportUserName(data.getNickName());
                    res.setReportUserPhone(data.getPhoneNumber());
                    res.setReportUserAvatar(data.getAvatar());
            } else {
                if (Objects.nonNull(task.getTaskSource()) && task.getTaskSource().equals(2)) {
                    List<SysUser> list = sysUserClient.listByIds(Lists.newArrayList(task.getReportUserId())).getData();
                    if (CollUtil.isNotEmpty(list)) {
                        SysUser sysUser = list.get(0);
                        res.setReportUserId(sysUser.getId());
                        res.setReportUserName(sysUser.getNickName());
                        res.setReportUserPhone(sysUser.getPhoneNumber());
                    }
                } else {
                    XpOperationsUser data = xpOperationUserClient.queryById(task.getReportUserId()).getData();
                    if (data != null) {
                        res.setReportUserId(data.getId());
                        res.setReportUserName(data.getNickName());
                        res.setReportUserPhone(data.getPhoneNumber());
                        res.setReportUserAvatar(data.getAvatar());
                    }
                }
            }
            if (task.getHandleUserId()!=null && task.getHandleUserId().split(",").length == 1) {
            if (task.getHandleUserId() != null && task.getHandleUserId().split(",").length == 1) {
                XpOperationsUser operationsUser = xpOperationUserClient.queryById(Long.valueOf(task.getHandleUserId())).getData();
                if (operationsUser != null) {
                    res.setHandleUserId(operationsUser.getId());
@@ -1626,6 +2107,8 @@
            managementDetailVO.setAccidentDetailVO(res);
        }
        return R.ok(managementDetailVO);
    }