| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.dto.pushMessage.AliPushMessageDTO; |
| | |
| | | private XpVehicleRepairMapper vehicleRepairMapper; |
| | | @Autowired |
| | | private XpVehiclePreparationMapper vehiclePreparationMapper; |
| | | @Autowired |
| | | private XpVehicleDescriptionMapper vehicleDescriptionMapper; |
| | | @Autowired |
| | | private XpVehicleDetectionMapper vehicleDetectionMapper; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void saveVehicleAccidentError(Long vehicleId) { |
| | | XpTask xpTask = new XpTask(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | xpTask.setTaskCode(code); |
| | | xpTask.setTaskCategory(2); |
| | | // todo 事故类型待客户确定 |
| | | xpTask.setTaskTypeId("1"); |
| | | xpTask.setTaskUrgencyLevel(0); |
| | | xpTask.setTaskDescription("车辆发生异常"); |
| | | 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)); |
| | | } |
| | | } |
| | | |
| | | xpTask.setVehicleId(vehicleId); |
| | | // 系统上传异常任务标识 |
| | | xpTask.setReportUserId(0L); |
| | | xpTask.setReportTime(LocalDateTime.now()); |
| | | xpTask.setStatus(0); |
| | | xpTask.setCreateBy("admin"); |
| | | XpTaskRule taskRule = xpTaskRuleService.lambdaQuery().last("limit 1").one(); |
| | | XpTaskRuleRole taskRuleRole = xpTaskRuleRoleService.lambdaQuery().eq(XpTaskRuleRole::getRuleType, 9).last("limit 1").one(); |
| | | if (Objects.isNull(taskRuleRole) || Objects.isNull(taskRule)) { |
| | | throw new ServiceException("未配置车辆事故任务分配规则"); |
| | | } |
| | | R<List<XpOperationsRole>> xpOperationsRoleResult = xpOperationUserClient.getXpOperationsRoleByRoleId(taskRuleRole.getRoleId()); |
| | | if (CollUtil.isNotEmpty(xpOperationsRoleResult.getData())) { |
| | | List<Long> userIds = xpOperationsRoleResult.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList()); |
| | | xpTask.setHandleUserId(StringUtils.join(userIds, ",")); |
| | | } |
| | | // 根据事故处理限时配置设置任务截止时间 |
| | | LocalDateTime endTime = LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit()); |
| | | xpTask.setEndTime(endTime); |
| | | this.save(xpTask); |
| | | |
| | | // 发送消息通知 |
| | | List<Long> userIds = Arrays.stream(xpTask.getHandleUserId().split(",")).map(Long::valueOf).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(userIds)) { |
| | | R<List<XpOperationsUser>> xpOperationUserResult = xpOperationUserClient.listByIds(userIds); |
| | | List<XpOperationsUser> data = xpOperationUserResult.getData(); |
| | | if (CollUtil.isNotEmpty(data)) { |
| | | |
| | | String plateNumber = Objects.nonNull(vehicle) ? vehicle.getPlateNumber() : ""; |
| | | // 车辆${车牌号}在${车辆位置信息}发生了紧急事故,请在${到达现场限时}内到达现场!${APP链接} |
| | | String content = String.format("车辆%s在%s发生了紧急事故,请在%d分钟内到达现场!", plateNumber, xpTask.getVehicleLocation(), taskRule.getProcessingTimeLimit()); |
| | | List<XpOperationsUserNotification> notifications = data.stream().map(item -> { |
| | | XpOperationsUserNotification notification = new XpOperationsUserNotification(); |
| | | notification.setOperationsUserId(item.getId()); |
| | | notification.setNotificationContent(content); |
| | | notification.setReadStatus(0); |
| | | notification.setCreateTime(LocalDateTime.now()); |
| | | return notification; |
| | | }).collect(Collectors.toList()); |
| | | xpOperationUserNotificationClient.addNotificationBatch(notifications); |
| | | // 发送阿里云推送 |
| | | Map<Integer, List<XpOperationsUser>> operationUserMap = data.stream().collect(Collectors.groupingBy(XpOperationsUser::getDeviceType)); |
| | | for (Map.Entry<Integer, List<XpOperationsUser>> integerListEntry : operationUserMap.entrySet()) { |
| | | List<XpOperationsUser> value = integerListEntry.getValue(); |
| | | pushAliMessage(value, content, xpTask); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public R assigneeTask(Long id, Long handlerUserId, Long assigneeUserId) { |
| | | XpTask task = this.getById(id); |
| | | task.setAssigneeTime(LocalDateTime.now()); |
| | |
| | | |
| | | @Override |
| | | public void saveTask(SaveErrorTaskDto dto, Long reportUserId) { |
| | | |
| | | List<Long> vehicleIds = dto.getVehicleIds(); |
| | | List<XpVehicle> vehicles = xpVehicleClient.listByIds(vehicleIds).getData(); |
| | | List<XpTask> saveTask = new ArrayList<>(); |
| | | for (Long vehicleId : dto.getVehicleIds()) { |
| | | XpTask task = new XpTask(); |
| | |
| | | task.setEndTime(LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit())); |
| | | } |
| | | task.setTaskCategory(2); |
| | | // todo 临时处理 |
| | | task.setHandleUserId("1"); |
| | | XpTaskRuleRole taskRuleRole = xpTaskRuleRoleService.lambdaQuery().eq(XpTaskRuleRole::getRuleType, 9).last("limit 1").one(); |
| | | if (Objects.isNull(taskRuleRole) || Objects.isNull(taskRule)) { |
| | | throw new ServiceException("未配置车辆事故任务分配规则"); |
| | | } |
| | | R<List<XpOperationsRole>> xpOperationsRoleResult = xpOperationUserClient.getXpOperationsRoleByRoleId(taskRuleRole.getRoleId()); |
| | | if (CollUtil.isNotEmpty(xpOperationsRoleResult.getData())) { |
| | | List<Long> userIds = xpOperationsRoleResult.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList()); |
| | | task.setHandleUserId(StringUtils.join(userIds, ",")); |
| | | } |
| | | // 根据事故处理限时配置设置任务截止时间 |
| | | LocalDateTime endTime = LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit()); |
| | | task.setEndTime(endTime); |
| | | task.setTaskTypeId(dto.getTaskTypeId()); |
| | | task.setTaskUrgencyLevel(dto.getTaskUrgencyLevel()); |
| | | task.setTaskDescription(dto.getTaskDescription()); |
| | |
| | | task.setReportUserId(reportUserId); |
| | | task.setReportTime(LocalDateTime.now()); |
| | | saveTask.add(task); |
| | | // 发送消息通知 |
| | | List<Long> userIds = Arrays.stream(task.getHandleUserId().split(",")).map(Long::valueOf).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(userIds)) { |
| | | XpVehicle vehicle = vehicles.stream().filter(e -> e.getId().equals(vehicleId)).findFirst().orElse(null); |
| | | R<List<XpOperationsUser>> xpOperationUserResult = xpOperationUserClient.listByIds(userIds); |
| | | List<XpOperationsUser> data = xpOperationUserResult.getData(); |
| | | if (CollUtil.isNotEmpty(data)) { |
| | | |
| | | String plateNumber = Objects.nonNull(vehicle) ? vehicle.getPlateNumber() : ""; |
| | | // 车辆${车牌号}在${车辆位置信息}发生了紧急事故,请在${到达现场限时}内到达现场!${APP链接} |
| | | String content = String.format("车辆%s在%s发生了紧急事故,请在%d分钟内到达现场!", plateNumber, task.getVehicleLocation(), taskRule.getProcessingTimeLimit()); |
| | | List<XpOperationsUserNotification> notifications = data.stream().map(item -> { |
| | | XpOperationsUserNotification notification = new XpOperationsUserNotification(); |
| | | notification.setOperationsUserId(item.getId()); |
| | | notification.setNotificationContent(content); |
| | | notification.setReadStatus(0); |
| | | notification.setCreateTime(LocalDateTime.now()); |
| | | return notification; |
| | | }).collect(Collectors.toList()); |
| | | xpOperationUserNotificationClient.addNotificationBatch(notifications); |
| | | // 发送阿里云推送 |
| | | Map<Integer, List<XpOperationsUser>> operationUserMap = data.stream().collect(Collectors.groupingBy(XpOperationsUser::getDeviceType)); |
| | | for (Map.Entry<Integer, List<XpOperationsUser>> integerListEntry : operationUserMap.entrySet()) { |
| | | List<XpOperationsUser> value = integerListEntry.getValue(); |
| | | pushAliMessage(value, content, task); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | this.saveBatch(saveTask); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | XpVehiclePreparation vehiclePreparation = vehiclePreparationMapper.selectOne(new LambdaQueryWrapper<XpVehiclePreparation>() |
| | | .eq(XpVehiclePreparation::getTaskId, id).last("limit 1")); |
| | | XpVehicleDescription xpVehicleDescription = vehicleDescriptionMapper.selectOne( |
| | | new LambdaQueryWrapper<XpVehicleDescription>().eq(XpVehicleDescription::getDescriptionType, 5) |
| | | ); |
| | | if (xpVehicleDescription != null) { |
| | | taskManagementPreparationDetailVO.setLostItemsDetail(xpVehicleDescription.getDescriptionContent()); |
| | | } |
| | | if (vehiclePreparation != null) { |
| | | taskManagementPreparationDetailVO.setLeftFrontWheel(vehiclePreparation.getLeftFrontWheel()); |
| | | taskManagementPreparationDetailVO.setRightFrontWheel(vehiclePreparation.getRightFrontWheel()); |