| | |
| | | package com.xiaopeng.maintenance.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | 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.account.XpOperationsUserPositionDTO; |
| | | import com.xiaopeng.api.dto.pushMessage.AliPushMessageDTO; |
| | | import com.xiaopeng.api.feignClient.account.SysUserClient; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserNotificationClient; |
| | | import com.xiaopeng.api.feignClient.operation.SmsClient; |
| | | import com.xiaopeng.api.feignClient.pushMessage.WebSocketMessageClient; |
| | | import com.xiaopeng.api.feignClient.pushMessage.XpAliPushMessageClient; |
| | | 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; |
| | | import com.xiaopeng.api.model.maintenance.*; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.XpTaskVO; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.maintenance.TaskScheduleConstants; |
| | | import com.xiaopeng.api.vo.operation.SmsVo; |
| | | import com.xiaopeng.common.core.constant.AliPushTypeConstant; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.enums.NotificationTypeEnum; |
| | |
| | | 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; |
| | |
| | | import com.xiaopeng.maintenance.model.query.WorkBenchQuery; |
| | | import com.xiaopeng.maintenance.model.query.XpTaskRecordPageQuery; |
| | | import com.xiaopeng.maintenance.model.vo.*; |
| | | import com.xiaopeng.maintenance.repo.XpOperationsUserRepository; |
| | | 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; |
| | |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | |
| | | @Autowired |
| | | private XpVehicleCleanMapper vehicleCleanMapper; |
| | | @Autowired |
| | | @Resource |
| | | private XpOperationUserClient xpOperationUserClient; |
| | | @Autowired |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | @Autowired |
| | | private XpTaskHandleDetailRoutineMapper xpTaskHandleDetailRoutineMapper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | private XpVehicleClient xpVehicleClient; |
| | | @Autowired |
| | | private XpTaskRuleMapper xpTaskRuleMapper; |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | @Autowired |
| | | @Resource |
| | | private XpAliPushMessageClient xpAliPushMessageClient; |
| | | @Autowired |
| | | @Resource |
| | | private XpOperationUserNotificationClient xpOperationUserNotificationClient; |
| | | @Autowired |
| | | private IXpTaskRuleRoleService xpTaskRuleRoleService; |
| | |
| | | @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; |
| | | } |
| | |
| | | PageInfo<TaskPageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TaskPageListVO> list = this.baseMapper.pageList(pageInfo, query); |
| | | XpTaskRule xpTaskRule = xpTaskRuleMapper.selectOne(new LambdaQueryWrapper<XpTaskRule>().last("limit 1")); |
| | | // if (Objects.nonNull(xpTaskRule)) { |
| | | // list.stream().filter(item -> item.getTaskCategory().equals(2)).forEach(item -> { |
| | | // item.setCanArriveRange(xpTaskRule.getCanArriveRange()); |
| | | // }); |
| | | // } |
| | | if (Objects.nonNull(xpTaskRule)) { |
| | | list.stream().filter(item -> item.getTaskCategory().equals(2)).forEach(item -> { |
| | | item.setCanArriveRange(xpTaskRule.getCanArriveRange()); |
| | | }); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | xpTask.setTaskCode(code); |
| | | xpTask.setTaskCategory(2); |
| | | String[] split = dto.getTaskTypeId().split(","); |
| | | List<String> typeIds = new ArrayList<>(); |
| | | for (String s : split) { |
| | | typeIds.add(s.trim()); |
| | | } |
| | | StringBuilder temp = new StringBuilder(dto.getTaskTypeId()); |
| | | List<Long> children = typeIds.stream().map(Long::parseLong).collect(Collectors.toList()); |
| | | List<Long> parentIds = errorTypeMapper.selectList(new LambdaQueryWrapper<XpErrorType>() |
| | | .in(XpErrorType::getId, children)).stream().map(XpErrorType::getParentId).distinct().collect(Collectors.toList()); |
| | | for (Long parentId : parentIds) { |
| | | temp.append(",").append(parentId); |
| | | } |
| | | xpTask.setTaskTypeId(temp.toString()); |
| | | xpTask.setTaskTypeId(normalizeAccidentTaskTypeId(dto.getTaskTypeId())); |
| | | xpTask.setTaskUrgencyLevel(dto.getTaskUrgencyLevel()); |
| | | xpTask.setTaskDescription(dto.getTaskDescription()); |
| | | xpTask.setTaskImage(dto.getTaskImage()); |
| | | xpTask.setVehicleId(dto.getId()); |
| | | XpVehicle vehicle = xpVehicleClient.queryById(xpTask.getVehicleId()).getData(); |
| | | // if (vehicle!=null){ |
| | | // VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vehicle.getVehicleVin())), VehiclePosition.class); |
| | | // if (vehiclePosition != null) { |
| | | // double x = vehiclePosition.getPoint().getX(); |
| | | // double y = vehiclePosition.getPoint().getY(); |
| | | // xpTask.setVehicleLon(new BigDecimal(x)); |
| | | // xpTask.setVehicleLat(new BigDecimal(y)); |
| | | // } |
| | | // } |
| | | if (Objects.isNull(vehicle)) { |
| | | throw new ServiceException("上报失败,未获取到车辆信息", I18nKeyConstant.TASK_VEHICLE_NOT_EXIST); |
| | | } |
| | | // VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vehicle.getVehicleVin())), VehiclePosition.class); |
| | | // if (Objects.isNull(vehiclePosition)) { |
| | | // log.error("事故上报未获取到车辆当前定位"); |
| | | // throw new ServiceException("获取车辆实时定位信息失败,请稍后重试", I18nKeyConstant.TASK_SAVE_ERROR); |
| | | // } |
| | | // xpTask.setVehicleLon(new BigDecimal(vehiclePosition.getPoint().getX())); |
| | | // xpTask.setVehicleLat(new BigDecimal(vehiclePosition.getPoint().getY())); |
| | | // Map<String, String> geocode = gdMapGeocodingUtil.geocode(xpTask.getVehicleLon().toString(), xpTask.getVehicleLat().toString()); |
| | | // String address = geocode == null ? null : geocode.get("address"); |
| | | // if (StringUtils.isBlank(address)) { |
| | | // log.error("事故上报通过车辆定位从高德获取地址信息失败"); |
| | | // throw new ServiceException("获取车辆实时定位信息失败,请稍后重试", I18nKeyConstant.TASK_SAVE_ERROR); |
| | | // } |
| | | // xpTask.setVehicleLocation(address); |
| | | // 临时处理 |
| | | xpTask.setVehicleLon(new BigDecimal("104.055683")); |
| | | xpTask.setVehicleLat(new BigDecimal("30.585991")); |
| | |
| | | } |
| | | |
| | | // 构建通知内容 |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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()); |
| | | } |
| | | |
| | | XpTaskVO xpTaskVO = new XpTaskVO(); |
| | | BeanUtil.copyProperties(xpTask, xpTaskVO); |
| | | xpWebSocketMessageClient.pushTask(xpTaskVO); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | WebSocketMessageClient xpWebSocketMessageClient; |
| | | /** |
| | | * 推送阿里云通知 |
| | | * |
| | |
| | | } |
| | | |
| | | @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) { |
| | |
| | | if (Objects.nonNull(xpTaskRule)) { |
| | | res.setCanArriveRange(xpTaskRule.getCanArriveRange()); |
| | | } |
| | | res.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(res.getTaskImage())); |
| | | return R.ok(res); |
| | | } |
| | | |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | |
| | | } |
| | | |
| | | @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) { |
| | |
| | | res.setHandleUserName(data.getNickName()); |
| | | } |
| | | } |
| | | res.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(res.getTaskImage())); |
| | | return R.ok(res); |
| | | } |
| | | |
| | |
| | | res.setPlateNumber(vehicle.getPlateNumber()); |
| | | res.setVehicleColor(vehicle.getVehicleColor()); |
| | | res.setVehicleCode(vehicle.getVehicleCode()); |
| | | res.setVehicleVin(vehicle.getVehicleVin()); |
| | | res.setVehicleLocation(task.getVehicleLocation()); |
| | | res.setCreateBy(task.getCreateBy()); |
| | | res.setCreateTime(task.getCreateTime()); |
| | |
| | | res.setTaskTypeId(task.getTaskTypeId()); |
| | | res.setStatus(task.getStatus()); |
| | | XpChargingRecord chargingRecord = chargingRecordMapper.selectOne(new LambdaQueryWrapper<XpChargingRecord>() |
| | | .eq(XpChargingRecord::getTaskId, id).last("limit 1")); |
| | | .eq(XpChargingRecord::getTaskId, id).last("limit 1").orderByDesc(XpChargingRecord::getCreateTime)); |
| | | if (chargingRecord != null) { |
| | | res.setStartRemainingBattery(chargingRecord.getStartRemainingBattery()); |
| | | res.setStartChargingPicture(chargingRecord.getStartChargingPicture()); |
| | | res.setStartChargingPicture(aliOssDownloadUtil.getPictureJsonArray(chargingRecord.getStartChargingPicture())); |
| | | res.setStartTime(chargingRecord.getStartTime()); |
| | | res.setEndRemainingBattery(chargingRecord.getEndRemainingBattery()); |
| | | res.setEndChargingPicture(chargingRecord.getEndChargingPicture()); |
| | | res.setEndChargingPicture(aliOssDownloadUtil.getPictureJsonArray(chargingRecord.getEndChargingPicture())); |
| | | |
| | | res.setEndTime(chargingRecord.getEndTime()); |
| | | res.setStartOperationsUserId(chargingRecord.getStartOperationsUserId()); |
| | | res.setEndOperationsUserId(chargingRecord.getEndOperationsUserId()); |
| | |
| | | res.setStartTime(vehicleRepair.getStartTime()); |
| | | res.setEndTime(vehicleRepair.getEndTime()); |
| | | res.setRepairReason(vehicleRepair.getRepairReason()); |
| | | res.setStartRepairPicture(vehicleRepair.getStartRepairPicture()); |
| | | |
| | | |
| | | res.setStartRepairPicture(aliOssDownloadUtil.getPictureJsonArray(vehicleRepair.getStartRepairPicture())); |
| | | res.setRepairMoney(vehicleRepair.getRepairMoney()); |
| | | res.setRepairMoneyDetail(vehicleRepair.getRepairMoneyDetail()); |
| | | res.setSendUserId(vehicleRepair.getSendUserId()); |
| | |
| | | res.setReturnUserName(operationsUser.getNickName()); |
| | | } |
| | | } |
| | | |
| | | if (vehicleRepair.getSendUserId() != null) { |
| | | XpOperationsUser operationsUser = xpOperationUserClient.queryById(vehicleRepair.getSendUserId()).getData(); |
| | | if (operationsUser != null) { |
| | |
| | | res.setPlateNumber(vehicle.getPlateNumber()); |
| | | res.setVehicleColor(vehicle.getVehicleColor()); |
| | | res.setVehicleCode(vehicle.getVehicleCode()); |
| | | res.setVehicleVin(vehicle.getVehicleVin()); |
| | | res.setVehicleLocation(task.getVehicleLocation()); |
| | | res.setCreateBy(task.getCreateBy()); |
| | | res.setCreateTime(task.getCreateTime()); |
| | |
| | | res.setCollisionPrevention(vehicleDetection.getCollisionPrevention()); |
| | | res.setSensorSelfCheck(vehicleDetection.getSensorSelfCheck()); |
| | | res.setSensorCleaning(vehicleDetection.getSensorCleaning()); |
| | | res.setSensorCleaningPicture(vehicleDetection.getSensorCleaningPicture()); |
| | | res.setSensorCleaningPicture(aliOssDownloadUtil.getPictureJsonArray(vehicleDetection.getSensorCleaningPicture())); |
| | | res.setInteractiveScreen(vehicleDetection.getInteractiveScreen()); |
| | | res.setInteractiveScreenPicture(vehicleDetection.getInteractiveScreenPicture()); |
| | | String InteractiveScreenPicture = vehicleDetection.getInteractiveScreenPicture(); |
| | | res.setInteractiveScreenPicture(aliOssDownloadUtil.getPictureJsonArray(vehicleDetection.getInteractiveScreenPicture())); |
| | | res.setHelpButton(vehicleDetection.getHelpButton()); |
| | | res.setHelpButtonPicture(vehicleDetection.getHelpButtonPicture()); |
| | | res.setHelpButtonPicture(aliOssDownloadUtil.getPictureJsonArray(vehicleDetection.getHelpButtonPicture())); |
| | | res.setPaymentFunction(vehicleDetection.getPaymentFunction()); |
| | | res.setPaymentFunctionPicture(vehicleDetection.getPaymentFunctionPicture()); |
| | | res.setPaymentFunctionPicture(aliOssDownloadUtil.getPictureJsonArray(vehicleDetection.getPaymentFunctionPicture())); |
| | | res.setSystemCheck(vehicleDetection.getSystemCheck()); |
| | | res.setSystemCheckPicture(vehicleDetection.getSystemCheckPicture()); |
| | | res.setSystemCheckPicture(aliOssDownloadUtil.getPictureJsonArray(vehicleDetection.getSystemCheckPicture())); |
| | | res.setCheckTime(vehicleDetection.getCheckTime()); |
| | | res.setOperationsUserId(vehicleDetection.getOperationsUserId()); |
| | | if (vehicleDetection.getOperationsUserId() != null) { |
| | |
| | | xpTaskHandleDetailRoutine.setOperationsUserId(id); |
| | | xpTaskHandleDetailRoutineMapper.insert(xpTaskHandleDetailRoutine); |
| | | //更新任务状态为已完成 |
| | | lambdaUpdate().set(XpTask::getStatus, 2).eq(XpTask::getId, dto.getId()).update(); |
| | | lambdaUpdate().set(XpTask::getStatus, 2).set(XpTask::getHandleUserId, id) |
| | | .set(XpTask::getHandleTime, LocalDateTime.now()) |
| | | .eq(XpTask::getId, dto.getId()) |
| | | .update(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @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) { |
| | |
| | | XpVehicleClean vehicleDetection = vehicleCleanMapper.selectOne(new LambdaQueryWrapper<XpVehicleClean>() |
| | | .eq(XpVehicleClean::getTaskId, id).last("limit 1")); |
| | | if (vehicleDetection != null) { |
| | | res.setHandleTime(vehicleDetection.getCreateTime()); |
| | | |
| | | |
| | | res.setTaskImage(vehicleDetection.getTaskImage()); |
| | | res.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(vehicleDetection.getTaskImage())); |
| | | res.setOperationUserId(vehicleDetection.getOperationsUserId()); |
| | | if (vehicleDetection.getOperationsUserId() != null) { |
| | | XpOperationsUser operationsUser = xpOperationUserClient.queryById(vehicleDetection.getOperationsUserId()).getData(); |
| | | if (operationsUser != null) { |
| | | res.setOperationsUserName(operationsUser.getNickName()); |
| | | res.setHandleUserName(operationsUser.getNickName()); |
| | | } |
| | | } |
| | | } |
| | |
| | | return R.fail("任务已被处理"); |
| | | } |
| | | |
| | | Long vehicleId = task.getVehicleId(); |
| | | String plateNumber = ""; |
| | | try { |
| | | if (vehicleId != null) { |
| | | R<XpVehicle> vehicleResult = xpVehicleClient.queryById(vehicleId); |
| | | XpVehicle vehicle = vehicleResult == null ? null : vehicleResult.getData(); |
| | | if (vehicle != null && StringUtils.isNotBlank(vehicle.getPlateNumber())) { |
| | | plateNumber = vehicle.getPlateNumber(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("confirmArrive查询车辆信息失败,taskId={}, vehicleId={}", id, vehicleId, e); |
| | | } |
| | | String taskCode = StringUtils.isNotBlank(task.getTaskCode()) |
| | | ? task.getTaskCode() |
| | | : String.valueOf(task.getId()); |
| | | |
| | | // 更新任务 |
| | | task.setStatus(1); |
| | | task.setVehicleId(null); |
| | | task.setHandleUserId(userId.toString()); |
| | | |
| | | this.updateById(task); |
| | | |
| | | // 保存通知记录 + 推送阿里云 NOTICE 消息(不影响主流程) |
| | | try { |
| | | String content = String.format("你处理的%s关联车辆:%s状态由待到达变更为待处理", taskCode, plateNumber); |
| | | String bodyJson = buildTaskStatusChangedPushBodyJson(content, id); |
| | | |
| | | XpOperationsUserNotification notification = new XpOperationsUserNotification(); |
| | | notification.setNotificationType(NotificationTypeEnum.ACCIDENT_STATUS_CHANGED.getCode()); |
| | | notification.setNotificationContent(content); |
| | | notification.setOperationsUserId(userId); |
| | | notification.setDataId(id); |
| | | notification.setReadStatus(0); |
| | | notification.setNotificationExt(bodyJson); |
| | | xpOperationUserNotificationClient.addNotificationBatch(Collections.singletonList(notification)); |
| | | |
| | | XpOperationsUser operationsUser = xpOperationUserClient.queryById(userId).getData(); |
| | | if (operationsUser != null |
| | | && operationsUser.getDeviceType() != null |
| | | && StringUtils.isNotBlank(operationsUser.getPhoneNumber())) { |
| | | xpAliPushMessageClient.pushMessage(AliPushMessageDTO.builder() |
| | | .deviceType(operationsUser.getDeviceType()) |
| | | .account(operationsUser.getPhoneNumber()) |
| | | .title("任务状态变更") |
| | | .body(bodyJson) |
| | | .pushType(AliPushTypeConstant.MESSAGE) |
| | | .build()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("confirmArrive消息通知失败,taskId={}, userId={}", id, userId, e); |
| | | } |
| | | return R.ok(); |
| | | |
| | | } catch (InterruptedException e) { |
| | |
| | | lock.unlock(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 构建任务状态变更推送 body JSON |
| | | */ |
| | | private String buildTaskStatusChangedPushBodyJson(String content, Long taskId) { |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("content", content); |
| | | param.put("strategy", NotificationTypeEnum.ACCIDENT_STATUS_CHANGED.getCode()); |
| | | param.put("type", TaskTypeNotificationEnum.ACCIDENT_TASK.getCode()); |
| | | param.put("id", taskId == null ? "0" : taskId.toString()); |
| | | return JSONObject.toJSONString(param); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | // 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; |
| | |
| | | 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(";"); |
| | |
| | | taskManagementPageListVO.setHandleUserName(handleUserName.toString()); |
| | | } |
| | | } |
| | | if (taskManagementPageListVO.getTaskCategory() == 1) { |
| | | switch (taskManagementPageListVO.getTaskTypeId()) { |
| | | case "1": |
| | | taskManagementPageListVO.setTaskTypeName("车辆检查"); |
| | | break; |
| | | case "2": |
| | | taskManagementPageListVO.setTaskTypeName("车辆充电"); |
| | | break; |
| | | case "3": |
| | | taskManagementPageListVO.setTaskTypeName("车辆整备"); |
| | | break; |
| | | case "4": |
| | | taskManagementPageListVO.setTaskTypeName("整备洗车"); |
| | | break; |
| | | case "5": |
| | | taskManagementPageListVO.setTaskTypeName("车辆维修"); |
| | | break; |
| | | case "6": |
| | | taskManagementPageListVO.setTaskTypeName("车辆保养"); |
| | | break; |
| | | case "7": |
| | | taskManagementPageListVO.setTaskTypeName("车辆保险到期"); |
| | | break; |
| | | case "8": |
| | | taskManagementPageListVO.setTaskTypeName("车辆年检到期"); |
| | | break; |
| | | case "9": |
| | | taskManagementPageListVO.setTaskTypeName("车辆运营资质到期"); |
| | | break; |
| | | default: |
| | | taskManagementPageListVO.setTaskTypeName(""); |
| | | break; |
| | | } |
| | | } else { |
| | | StringBuilder taskTypeName = new StringBuilder(); |
| | | String[] typeIds = taskManagementPageListVO.getTaskTypeId().split(","); |
| | | List<XpErrorType> xpErrorTypes = errorTypeMapper.selectList(new LambdaQueryWrapper<XpErrorType>() |
| | | .in(XpErrorType::getId, Arrays.asList(typeIds)).orderByAsc(XpErrorType::getParentId)); |
| | | List<XpErrorType> parents = new ArrayList<>(); |
| | | for (XpErrorType xpErrorType : xpErrorTypes) { |
| | | if (xpErrorType.getParentId() == 0) { |
| | | parents.add(xpErrorType); |
| | | } |
| | | } |
| | | for (XpErrorType parent : parents) { |
| | | List<XpErrorType> children = xpErrorTypes.stream().filter(e -> e.getParentId().equals(parent.getId())).collect(Collectors.toList()); |
| | | taskTypeName.append(parent.getErrorName()).append(">"); |
| | | for (XpErrorType child : children) { |
| | | taskTypeName.append(child.getErrorName()).append(";"); |
| | | } |
| | | } |
| | | |
| | | taskManagementPageListVO.setTaskTypeName(taskTypeName.substring(0, taskTypeName.length() - 1)); |
| | | } |
| | | taskManagementPageListVO.setTaskTypeName(resolveManagementTaskTypeName(taskManagementPageListVO)); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | |
| | | 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(";"); |
| | |
| | | taskManagementPageListVO.setHandleUserName(handleUserName.toString()); |
| | | } |
| | | } |
| | | if (taskManagementPageListVO.getTaskCategory() == 1) { |
| | | switch (taskManagementPageListVO.getTaskTypeId()) { |
| | | case "1": |
| | | taskManagementPageListVO.setTaskTypeName("车辆检查"); |
| | | break; |
| | | case "2": |
| | | taskManagementPageListVO.setTaskTypeName("车辆充电"); |
| | | break; |
| | | case "3": |
| | | taskManagementPageListVO.setTaskTypeName("车辆整备"); |
| | | break; |
| | | case "4": |
| | | taskManagementPageListVO.setTaskTypeName("整备洗车"); |
| | | break; |
| | | case "5": |
| | | taskManagementPageListVO.setTaskTypeName("车辆维修"); |
| | | break; |
| | | case "6": |
| | | taskManagementPageListVO.setTaskTypeName("车辆保养"); |
| | | break; |
| | | case "7": |
| | | taskManagementPageListVO.setTaskTypeName("车辆保险到期"); |
| | | break; |
| | | case "8": |
| | | taskManagementPageListVO.setTaskTypeName("车辆年检到期"); |
| | | break; |
| | | case "9": |
| | | taskManagementPageListVO.setTaskTypeName("车辆运营资质到期"); |
| | | break; |
| | | default: |
| | | taskManagementPageListVO.setTaskTypeName(""); |
| | | break; |
| | | } |
| | | } else { |
| | | StringBuilder taskTypeName = new StringBuilder(); |
| | | String[] typeIds = taskManagementPageListVO.getTaskTypeId().split(","); |
| | | List<XpErrorType> xpErrorTypes = errorTypeMapper.selectList(new LambdaQueryWrapper<XpErrorType>() |
| | | .in(XpErrorType::getId, Arrays.asList(typeIds)).orderByAsc(XpErrorType::getParentId)); |
| | | List<XpErrorType> parents = new ArrayList<>(); |
| | | for (XpErrorType xpErrorType : xpErrorTypes) { |
| | | if (xpErrorType.getParentId() == 0) { |
| | | parents.add(xpErrorType); |
| | | } |
| | | } |
| | | for (XpErrorType parent : parents) { |
| | | List<XpErrorType> children = xpErrorTypes.stream().filter(e -> e.getParentId().equals(parent.getId())).collect(Collectors.toList()); |
| | | taskTypeName.append(parent.getErrorName()).append(">"); |
| | | for (XpErrorType child : children) { |
| | | taskTypeName.append(child.getErrorName()).append(";"); |
| | | } |
| | | } |
| | | |
| | | taskManagementPageListVO.setTaskTypeName(taskTypeName.substring(0, taskTypeName.length() - 1)); |
| | | } |
| | | taskManagementPageListVO.setTaskTypeName(resolveManagementTaskTypeName(taskManagementPageListVO)); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private String resolveManagementTaskTypeName(TaskManagementPageListVO taskManagementPageListVO) { |
| | | if (Integer.valueOf(1).equals(taskManagementPageListVO.getTaskCategory())) { |
| | | return resolveRoutineTaskTypeName(taskManagementPageListVO.getTaskTypeId()); |
| | | } |
| | | if (Integer.valueOf(2).equals(taskManagementPageListVO.getTaskCategory())) { |
| | | return resolveAccidentTaskTypeName(taskManagementPageListVO.getTaskTypeId()); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private String resolveRoutineTaskTypeName(String taskTypeId) { |
| | | if (StringUtils.isBlank(taskTypeId)) { |
| | | return ""; |
| | | } |
| | | switch (taskTypeId) { |
| | | case "1": |
| | | return "车辆检查"; |
| | | case "2": |
| | | return "车辆充电"; |
| | | case "3": |
| | | return "车辆整备"; |
| | | case "4": |
| | | return "整备洗车"; |
| | | case "5": |
| | | return "车辆维修"; |
| | | case "6": |
| | | return "车辆保养"; |
| | | case "7": |
| | | return "车辆保险到期"; |
| | | case "8": |
| | | return "车辆年检到期"; |
| | | case "9": |
| | | return "车辆运营资质到期"; |
| | | default: |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | private String resolveAccidentTaskTypeName(String taskTypeId) { |
| | | List<Long> orderedTypeIds = parseAccidentTaskTypeIds(taskTypeId); |
| | | if (orderedTypeIds.isEmpty()) { |
| | | return ""; |
| | | } |
| | | |
| | | Map<Long, XpErrorType> errorTypeMap = getAccidentErrorTypeMap(orderedTypeIds); |
| | | if (errorTypeMap.isEmpty()) { |
| | | return ""; |
| | | } |
| | | |
| | | LinkedHashSet<Long> orderedParentIds = new LinkedHashSet<>(); |
| | | LinkedHashMap<Long, List<XpErrorType>> childrenByParent = new LinkedHashMap<>(); |
| | | for (Long typeId : orderedTypeIds) { |
| | | XpErrorType errorType = errorTypeMap.get(typeId); |
| | | if (errorType == null || StringUtils.isBlank(errorType.getErrorName())) { |
| | | continue; |
| | | } |
| | | |
| | | if (isTopLevelErrorType(errorType)) { |
| | | orderedParentIds.add(errorType.getId()); |
| | | continue; |
| | | } |
| | | |
| | | Long parentId = errorType.getParentId(); |
| | | if (parentId == null) { |
| | | continue; |
| | | } |
| | | orderedParentIds.add(parentId); |
| | | childrenByParent.computeIfAbsent(parentId, key -> new ArrayList<>()).add(errorType); |
| | | } |
| | | |
| | | List<String> displayNames = new ArrayList<>(); |
| | | for (Long parentId : orderedParentIds) { |
| | | XpErrorType parent = errorTypeMap.get(parentId); |
| | | List<XpErrorType> children = childrenByParent.get(parentId); |
| | | if (CollectionUtils.isEmpty(children)) { |
| | | if (parent != null && StringUtils.isNotBlank(parent.getErrorName())) { |
| | | displayNames.add(parent.getErrorName()); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | String parentName = parent == null ? null : parent.getErrorName(); |
| | | for (XpErrorType child : children) { |
| | | if (StringUtils.isBlank(parentName)) { |
| | | displayNames.add(child.getErrorName()); |
| | | } else { |
| | | displayNames.add(parentName + ">" + child.getErrorName()); |
| | | } |
| | | } |
| | | } |
| | | return String.join(";", displayNames); |
| | | } |
| | | |
| | | private Map<Long, XpErrorType> getAccidentErrorTypeMap(List<Long> orderedTypeIds) { |
| | | Map<Long, XpErrorType> errorTypeMap = getErrorTypeMap(orderedTypeIds); |
| | | if (errorTypeMap.isEmpty()) { |
| | | return errorTypeMap; |
| | | } |
| | | |
| | | Set<Long> missingParentIds = new LinkedHashSet<>(); |
| | | for (Long typeId : orderedTypeIds) { |
| | | XpErrorType errorType = errorTypeMap.get(typeId); |
| | | if (errorType == null || isTopLevelErrorType(errorType)) { |
| | | continue; |
| | | } |
| | | if (errorType.getParentId() != null && !errorTypeMap.containsKey(errorType.getParentId())) { |
| | | missingParentIds.add(errorType.getParentId()); |
| | | } |
| | | } |
| | | if (!missingParentIds.isEmpty()) { |
| | | errorTypeMap.putAll(getErrorTypeMap(missingParentIds)); |
| | | } |
| | | return errorTypeMap; |
| | | } |
| | | |
| | | private boolean isTopLevelErrorType(XpErrorType errorType) { |
| | | return errorType.getParentId() == null || errorType.getParentId() == 0L; |
| | | } |
| | | |
| | | private String normalizeAccidentTaskTypeId(String taskTypeId) { |
| | | List<Long> orderedTypeIds = parseAccidentTaskTypeIds(taskTypeId); |
| | | if (orderedTypeIds.isEmpty()) { |
| | | return taskTypeId; |
| | | } |
| | | |
| | | LinkedHashSet<Long> normalizedTypeIds = new LinkedHashSet<>(orderedTypeIds); |
| | | Map<Long, XpErrorType> errorTypeMap = getErrorTypeMap(orderedTypeIds); |
| | | for (Long typeId : orderedTypeIds) { |
| | | XpErrorType errorType = errorTypeMap.get(typeId); |
| | | if (errorType == null || errorType.getParentId() == null || errorType.getParentId() == 0L) { |
| | | continue; |
| | | } |
| | | normalizedTypeIds.add(errorType.getParentId()); |
| | | } |
| | | return normalizedTypeIds.stream().map(String::valueOf).collect(Collectors.joining(",")); |
| | | } |
| | | |
| | | private List<Long> parseAccidentTaskTypeIds(String taskTypeId) { |
| | | if (StringUtils.isBlank(taskTypeId)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | LinkedHashSet<Long> typeIds = new LinkedHashSet<>(); |
| | | for (String typeId : taskTypeId.split(",")) { |
| | | if (StringUtils.isBlank(typeId)) { |
| | | continue; |
| | | } |
| | | try { |
| | | typeIds.add(Long.parseLong(typeId.trim())); |
| | | } catch (NumberFormatException ignored) { |
| | | } |
| | | } |
| | | return new ArrayList<>(typeIds); |
| | | } |
| | | |
| | | private Map<Long, XpErrorType> getErrorTypeMap(Collection<Long> typeIds) { |
| | | if (CollectionUtils.isEmpty(typeIds)) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | return errorTypeMapper.selectBatchIds(typeIds).stream() |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toMap(XpErrorType::getId, errorType -> errorType, (left, right) -> left)); |
| | | } |
| | | |
| | | @Override |
| | | public XpTask queryInfoByVehicleId(Long vehicleId) { |
| | | return this.baseMapper.queryInfoByVehicleId(vehicleId); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private XpOperationsUserRepository repository; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void reassign(Long taskId, String msg) { |
| | | |
| | | XpTask task = getById(taskId); |
| | | XpVehicle vehicle = xpVehicleClient.queryById(task.getVehicleId()).getData(); |
| | | XpTaskRule taskRule = xpTaskRuleService.lambdaQuery().last("limit 1").one(); |
| | | |
| | | int type = 9; |
| | | if(task.getTaskCategory() != 2) { |
| | | type = Integer.parseInt(task.getTaskTypeId()); |
| | | } |
| | | |
| | | List<XpTaskRuleRole> taskRuleRole = xpTaskRuleRoleService.lambdaQuery().eq(XpTaskRuleRole::getRuleType, type).list(); |
| | | |
| | | if (Objects.isNull(taskRuleRole) || Objects.isNull(taskRule)) { |
| | | throw new ServiceException("未配置车辆事故任务分配规则"); |
| | | } |
| | | |
| | | List<XpTask.Reject> rejects = Optional.ofNullable(task.getExcluded()).orElse(new ArrayList<>()); |
| | | XpTask.Reject reject = task.reject(msg); |
| | | rejects.add(reject); |
| | | task.setExcluded(rejects); |
| | | task.setReassignmentStatus(2); |
| | | Set<String> excludedUserIds = rejects.stream().map(XpTask.Reject::getRejectUserId).collect(Collectors.toSet()); |
| | | |
| | | Long fleetId = xpFleetVehicleClient.getFleetIdByVehicleId(vehicle.getId()).getData(); |
| | | List<Long> roleIds = taskRuleRole.stream().map(XpTaskRuleRole::getRoleId).collect(Collectors.toList()); |
| | | List<Long> ids = xpFleetOperationsClient.getOperationsIdsByFleetId(fleetId).getData();//TODO 空指针 |
| | | String belongUserIds = xpOperationUserClient.getXpOperationsRoleByRoleIds(roleIds).getData().stream() |
| | | .map(XpOperationsRole::getOperationsUserId) |
| | | .filter(ids::contains) |
| | | .filter(id -> !excludedUserIds.contains(id.toString())) |
| | | .map(String::valueOf).collect(Collectors.joining(",")); |
| | | |
| | | |
| | | // VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vehicle.getVehicleVin())), VehiclePosition.class); |
| | | VehiclePosition vehiclePosition = new VehiclePosition(); |
| | | vehiclePosition.setPoint(new GeoJsonPoint(103.12615621, 30.264561)); |
| | | String handlerUser = chooseNearestAvailableOperationsUser(belongUserIds, vehiclePosition); |
| | | task.setHandleUserId(handlerUser); |
| | | if(handlerUser == null) { |
| | | task.setStatus(4); |
| | | noticeAdministrator(task);//TODO 需要通知管理员手动处理,考虑再AliPushUtil 中给管理员发送消息 |
| | | } |
| | | updateById(task); |
| | | if(StringUtils.isNotBlank(task.getHandleUserId())){ |
| | | List<Long> id = Collections.singletonList(Long.parseLong(task.getHandleUserId())); |
| | | String roleName = xpOperationUserClient.listByIdsWithRole(id).getData().get(0).getRoleName(); |
| | | reject.setRejectUserRoleName(roleName); |
| | | sendAccidentNotificationAsync(task, vehicle.getPlateNumber(), taskRule.getProcessingTimeLimit()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void saveVehicleAccidentError(Long vehicleId) { |
| | |
| | | if (Objects.isNull(taskRuleRole) || Objects.isNull(taskRule)) { |
| | | throw new ServiceException("未配置车辆事故任务分配规则"); |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | //查找事故处理人,处理角色和车辆所属的车队 |
| | | Long fleetId = xpFleetVehicleClient.getFleetIdByVehicleId(vehicle.getId()).getData(); |
| | | List<Long> roleIds = taskRuleRole.stream().map(XpTaskRuleRole::getRoleId).collect(Collectors.toList()); |
| | | List<XpOperationsRole> data = xpOperationUserClient.getXpOperationsRoleByRoleIds(roleIds).getData(); |
| | | List<Long> ids = xpFleetOperationsClient.getOperationsIdsByFleetId(fleetId).getData(); |
| | | List<XpOperationsRole> collect = data.stream().filter(x -> ids.contains(x.getOperationsUserId())).collect(Collectors.toList()); |
| | | String belongUserIds = collect.stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toSet()).stream().map(String::valueOf).collect(Collectors.joining(",")); |
| | | String belongUserIds = xpOperationUserClient.getXpOperationsRoleByRoleIds(roleIds).getData().stream() |
| | | .map(XpOperationsRole::getOperationsUserId) |
| | | .filter(ids::contains) |
| | | .map(String::valueOf).collect(Collectors.joining(",")); |
| | | |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vehicle.getVehicleVin())), VehiclePosition.class); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(vehiclePosition.getPoint().getX() + "", vehiclePosition.getPoint().getY() + ""); |
| | | String address = geocode.get("address"); |
| | | |
| | | XpTask task = new XpTask(); |
| | | String taskCode = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | String taskCode = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | task.setTaskCode(taskCode); |
| | | task.setTaskCategory(TaskScheduleConstants.TASK_CATEGORY_ACCIDENT); |
| | | task.setTaskTypeId("8,10"); |
| | |
| | | task.setVehicleLocation(address); |
| | | task.setVehicleLat(new BigDecimal(vehiclePosition.getPoint().getY())); |
| | | task.setVehicleLon(new BigDecimal(vehiclePosition.getPoint().getX())); |
| | | task.setHandleUserId(belongUserIds); |
| | | String handlerUser = chooseNearestAvailableOperationsUser(belongUserIds, vehiclePosition); |
| | | task.setHandleUserId(handlerUser); |
| | | if(handlerUser == null) { |
| | | task.setStatus(4); |
| | | noticeAdministrator(task); |
| | | } |
| | | task.setAssigneeTime(LocalDateTime.now()); |
| | | task.setReportUserId(0L); |
| | | task.setReportTime(LocalDateTime.now()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void accept(String taskId) { |
| | | |
| | | XpTask task = getById(Long.valueOf(taskId)); |
| | | XpVehicle vehicle = xpVehicleClient.queryById(task.getVehicleId()).getData(); |
| | | updateTaskStatus(task.getId(), TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE, Long.valueOf(task.getHandleUserId())); |
| | | sendAccidentNotificationAsync(getById(task.getId()), vehicle.getPlateNumber(), (int) Duration.between(LocalDateTime.now(),task.getEndTime()).toMinutes()); |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<XpTaskVO> reassignTaskPageList(TaskPageListQuery query) { |
| | | |
| | | PageInfo<TaskPageListQuery> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | |
| | | return baseMapper.reassignTaskPageList(pageInfo,query); |
| | | } |
| | | |
| | | @Override |
| | | public XpTaskVO detail(Long taskId) { |
| | | XpTask task = getById(taskId); |
| | | if (task == null) { |
| | | return null; |
| | | } |
| | | XpTaskVO xpTaskVO = new XpTaskVO(); |
| | | BeanUtil.copyProperties(task, xpTaskVO); |
| | | |
| | | String taskImage = xpTaskVO.getTaskImage(); |
| | | if (StringUtils.isNotBlank(taskImage)) { |
| | | try { |
| | | xpTaskVO.setTaskImage(aliOssDownloadUtil.getPictureJsonArray(taskImage)); |
| | | } catch (Exception e) { |
| | | log.error("获取任务图片下载地址失败,taskId={}", taskId, e); |
| | | } |
| | | } |
| | | |
| | | // 2. 如果有车辆信息,可以补充车辆相关详情(如果需要) |
| | | if (task.getVehicleId() != null) { |
| | | R<XpVehicle> vehicleResult = xpVehicleClient.queryById(task.getVehicleId()); |
| | | if (vehicleResult != null && vehicleResult.getData() != null) { |
| | | XpVehicle vehicle = vehicleResult.getData(); |
| | | xpTaskVO.setPlateNumber(vehicle.getPlateNumber()); |
| | | // xpTaskVO.setVehicleColor(vehicle.getVehicleColor()); |
| | | // xpTaskVO.setVehicleCode(vehicle.getVehicleCode()); |
| | | // xpTaskVO.setVehicleVin(vehicle.getVehicleVin()); |
| | | |
| | | } |
| | | } |
| | | |
| | | return xpTaskVO; |
| | | } |
| | | |
| | | @Value("${robotaxi.sms.app-id:1476153389173952512}") |
| | | private String smsAppId; |
| | | @Value("${robotaxi.sms.app-push-config-code:ROBOTAXI_VERIFY_CODE_SMS}") |
| | | private String ROBOTAXI_VERIFY_CODE_SMS_TPL; |
| | | @Resource |
| | | private SmsClient smsClient; |
| | | |
| | | private void noticeAdministrator(XpTask task) { |
| | | |
| | | SmsVo smsVo = new SmsVo(); |
| | | smsVo.setAppId(smsAppId); |
| | | smsVo.setParams(Collections.EMPTY_MAP); |
| | | smsVo.setTemplateCode(ROBOTAXI_VERIFY_CODE_SMS_TPL); |
| | | |
| | | String adminPhone = "139.."; |
| | | |
| | | smsVo.setReceivers(adminPhone); |
| | | smsClient.pushSms(smsVo); |
| | | |
| | | } |
| | | |
| | | private String chooseNearestAvailableOperationsUser(String belongUserIds, VehiclePosition vehiclePosition) { |
| | | |
| | | if (StringUtils.isBlank(belongUserIds)) return null; |
| | | List<Long> ids = Arrays.stream(belongUserIds.split(",")).filter(StringUtils::isNotBlank).map(Long::valueOf).collect(Collectors.toList()); |
| | | |
| | | // 让mongo根据[id in ids]返回距离排序的users |
| | | // List<XpOperationsUserPositionDTO> users = mongoTemplate.find(new Query(Criteria.where("_id").in(ids)), XpOperationsUserPositionDTO.class); |
| | | |
| | | List<XpOperationsUserPositionDTO> XpOperationsUserPositionDTOs = repository.findWithDistance(new Point(vehiclePosition.getPoint().getX(), vehiclePosition.getPoint().getY()), 1000, ids); |
| | | |
| | | boolean skipBusy = false;//TODO 获取系统配置,是否开启跳过忙碌 |
| | | |
| | | List<XpOperationsUserPositionDTO> candidates = XpOperationsUserPositionDTOs.stream() |
| | | // .filter(positionDTO -> skipBusy && positionDTO.getStatus() == 1) |
| | | .sorted(Comparator.comparing(XpOperationsUserPositionDTO::getDistance)) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (candidates.isEmpty()) return null; |
| | | |
| | | return String.valueOf(candidates.get(0).getId()); |
| | | } |
| | | |
| | | |
| | | |
| | | @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.setReassignmentStatus(2); |
| | | 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(); |
| | | } |
| | | |
| | |
| | | public void saveTask(SaveErrorTaskDto dto, Long reportUserId) { |
| | | |
| | | List<XpTask> saveTask = new ArrayList<>(); |
| | | String normalizedTaskTypeId = normalizeAccidentTaskTypeId(dto.getTaskTypeId()); |
| | | for (Long vehicleId : dto.getVehicleIds()) { |
| | | XpTask task = new XpTask(); |
| | | BeanUtils.copyProperties(dto, task); |
| | |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | task.setTaskCode(code); |
| | | task.setTaskCategory(2); |
| | | task.setTaskTypeId(dto.getTaskTypeId()); |
| | | task.setTaskTypeId(normalizedTaskTypeId); |
| | | task.setTaskUrgencyLevel(dto.getTaskUrgencyLevel()); |
| | | task.setTaskDescription(dto.getTaskDescription()); |
| | | task.setTaskImage(dto.getTaskImage()); |
| | |
| | | task.setReportTime(LocalDateTime.now()); |
| | | task.setExpiredNoticeSent(0); |
| | | task.setWillTimeoutNoticeSent(0); |
| | | task.setTaskSource(2); |
| | | saveTask.add(task); |
| | | } |
| | | this.saveBatch(saveTask); |
| | |
| | | } |
| | | |
| | | @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) { |
| | |
| | | I18nKeyConstant.VEHICLE_NOT_EXIST |
| | | ); |
| | | } |
| | | |
| | | String vehiclePicture = aliOssDownloadUtil.getPictureJSONObject(vehicle.getVehiclePictures()); |
| | | if (task.getTaskCategory() == 1) { |
| | | // 常规任务 |
| | | |
| | |
| | | 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")); |
| | |
| | | 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) { |
| | |
| | | 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")); |
| | |
| | | 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")); |
| | |
| | | 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")); |
| | |
| | | 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")); |
| | |
| | | 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) { |
| | |
| | | Map<Long, List<XpErrorType>> errorType = errorTypeMapper.selectList(new LambdaQueryWrapper<XpErrorType>() |
| | | .in(XpErrorType::getId, Arrays.asList(task.getTaskTypeId().split(",")))) |
| | | .stream().collect(Collectors.groupingBy(XpErrorType::getParentId)); |
| | | if (CollUtil.isEmpty(errorType)) { |
| | | throw new ServiceException( |
| | | "事故类型不存在", |
| | | I18nKeyConstant.ACCIDENT_TYPE_NOT_EXIST |
| | | ); |
| | | } |
| | | List<XpErrorType> xpErrorTypes = errorType.get(0L); |
| | | for (XpErrorType xpErrorType : xpErrorTypes) { |
| | | xpErrorType.setChild(errorType.get(xpErrorType.getId())); |
| | |
| | | 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()); |
| | |
| | | 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().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()); |
| | |
| | | |
| | | managementDetailVO.setAccidentDetailVO(res); |
| | | } |
| | | |
| | | |
| | | return R.ok(managementDetailVO); |
| | | } |
| | | |