| | |
| | | package com.xiaopeng.maintenance.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | 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.xiaopeng.api.dto.account.XpOperationsUserQueryDTO; |
| | | 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; |
| | |
| | | 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.account.XpOperationsUserWithRoleVO; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.maintenance.TaskScheduleConstants; |
| | | import com.xiaopeng.common.core.constant.AliPushTypeConstant; |
| | |
| | | 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.service.XpTaskService; |
| | | import com.xiaopeng.maintenance.utils.GDMapGeocodingUtil; |
| | | import com.xiaopeng.maintenance.utils.UUIDUtil; |
| | | import com.xiaopeng.maintenance.vo.TaskCleanDetailVO; |
| | | import com.xiaopeng.maintenance.vo.TaskDetectionDetailVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | | import org.apache.shardingsphere.transaction.core.TransactionType; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | 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; |
| | |
| | | @Resource |
| | | private XpFleetOperationsClient xpFleetOperationsClient; |
| | | |
| | | @Resource |
| | | private AliOssService aliOssService; |
| | | |
| | | @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; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | |
| | | @Override |
| | | public void saveVehicleAccident(SaveVehicleAccidentDto dto, XpOperationsUser xpOperationsUser) { |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public XpTask saveVehicleAccident(SaveVehicleAccidentDto dto, XpOperationsUser xpOperationsUser) { |
| | | XpTask xpTask = new XpTask(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | |
| | | 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); |
| | |
| | | xpTask.setStatus(0); |
| | | xpTask.setCreateBy(xpOperationsUser.getNickName()); |
| | | 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)) { |
| | | List<XpTaskRuleRole> list = xpTaskRuleRoleService.lambdaQuery().eq(XpTaskRuleRole::getRuleType, 9).list(); |
| | | if (CollUtil.isEmpty(list) || Objects.isNull(taskRule)) { |
| | | throw new ServiceException("未配置车辆事故任务分配规则"); |
| | | } |
| | | R<List<XpOperationsRole>> xpOperationsRoleResult = xpOperationUserClient.getXpOperationsRoleByRoleId(taskRuleRole.getRoleId()); |
| | | List<Long> roleIds = list.stream().map(XpTaskRuleRole::getRoleId).collect(Collectors.toList()); |
| | | R<List<XpOperationsRole>> xpOperationsRoleResult = xpOperationUserClient.getXpOperationsRoleByRoleIds(roleIds); |
| | | if (CollUtil.isNotEmpty(xpOperationsRoleResult.getData())) { |
| | | List<Long> userIds = xpOperationsRoleResult.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList()); |
| | | Long fleetId = xpFleetVehicleClient.getFleetIdByVehicleId(vehicle.getId()).getData(); |
| | | List<Long> ids = xpFleetOperationsClient.getOperationsIdsByFleetId(fleetId).getData(); |
| | | // 根据配置的事故处理角色和事故车辆所属车队人员,确定最终的任务分配人列表(取交集) |
| | | List<Long> userIds = xpOperationsRoleResult.getData().stream().filter(x -> ids.contains(x.getOperationsUserId())) |
| | | .map(XpOperationsRole::getOperationsUserId) |
| | | .distinct().collect(Collectors.toList()); |
| | | xpTask.setHandleUserId(StringUtils.join(userIds, ",")); |
| | | } |
| | | // 根据事故处理限时配置设置任务截止时间 |
| | | LocalDateTime endTime = LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit()); |
| | | xpTask.setEndTime(endTime); |
| | | xpTask.setExpiredNoticeSent(0); |
| | | xpTask.setWillTimeoutNoticeSent(0); |
| | | this.save(xpTask); |
| | | if (xpTask.getId() == null && StringUtils.isNotBlank(xpTask.getTaskCode())) { |
| | | XpTask savedTask = this.getOne(new LambdaQueryWrapper<XpTask>() |
| | | .eq(XpTask::getTaskCode, xpTask.getTaskCode()) |
| | | .last("limit 1")); |
| | | if (savedTask != null && savedTask.getId() != null) { |
| | | xpTask.setId(savedTask.getId()); |
| | | } |
| | | } |
| | | |
| | | // 异步发送消息通知 |
| | | String plateNumber = Objects.nonNull(vehicle) ? vehicle.getPlateNumber() : ""; |
| | | sendAccidentNotificationAsync(xpTask, plateNumber, taskRule.getProcessingTimeLimit()); |
| | | return xpTask; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | @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) { |
| | |
| | | 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()); |
| | |
| | | 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 |
| | | public R handleVehicleAccident(HandleVehicleAccidentDto dto, XpOperationsUser xpOperationsUser) { |
| | | XpTask task = this.getById(dto.getId()); |
| | |
| | | task.setHandleTime(LocalDateTime.now()); |
| | | task.setHandleUserId(xpOperationsUser.getId().toString()); |
| | | task.setStatus(2); |
| | | updateById(task); |
| | | // 存储事故处理日志 |
| | | XpTaskHandleDetail xpTaskHandleDetail = new XpTaskHandleDetail(); |
| | | xpTaskHandleDetail.setTaskId(task.getId()); |
| | |
| | | } |
| | | |
| | | @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) { |
| | |
| | | I18nKeyConstant.VEHICLE_NOT_EXIST |
| | | ); |
| | | } |
| | | //查询任务处理记录 |
| | | XpTaskHandleDetailRoutine xpTaskHandleDetailRoutine = xpTaskHandleDetailRoutineMapper.selectOne(new LambdaQueryWrapper<XpTaskHandleDetailRoutine>() |
| | | .eq(XpTaskHandleDetailRoutine::getTaskId, id).last("limit 1")); |
| | | res.setId(id); |
| | | res.setTaskUrgencyLevel(task.getTaskUrgencyLevel()); |
| | | res.setEndTime(task.getEndTime()); |
| | |
| | | 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.setTaskImage(task.getTaskImage()); |
| | | res.setHandleUserId(task.getHandleUserId()); |
| | | res.setHandleTime(task.getHandleTime()); |
| | | if (Objects.nonNull(xpTaskHandleDetailRoutine)) { |
| | | res.setTaskDescription(xpTaskHandleDetailRoutine.getTaskDescription()); |
| | | task.setHandleUserId(xpTaskHandleDetailRoutine.getOperationsUserId().toString()); |
| | | res.setHandleTime(xpTaskHandleDetailRoutine.getCreateTime()); |
| | | res.setTaskImage(xpTaskHandleDetailRoutine.getTaskImage()); |
| | | } |
| | | if (Objects.nonNull(task.getHandleUserId()) && task.getHandleUserId().split(",").length == 1) { |
| | | XpOperationsUser data = xpOperationUserClient.queryById(Long.valueOf(task.getHandleUserId())).getData(); |
| | | if (Objects.nonNull(data)) { |
| | | 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); |
| | | } |
| | | |
| | |
| | | .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()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<com.xiaopeng.maintenance.vo.TaskRepairDetailVO> repairDetail(Long id) { |
| | | com.xiaopeng.maintenance.vo.TaskRepairDetailVO res = new com.xiaopeng.maintenance.vo.TaskRepairDetailVO(); |
| | | public R<TaskRepairDetailVO> repairDetail(Long id) { |
| | | TaskRepairDetailVO res = new TaskRepairDetailVO(); |
| | | |
| | | |
| | | XpTask task = this.getById(id); |
| | |
| | | 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()); |
| | |
| | | res.setReturnUserName(operationsUser.getNickName()); |
| | | } |
| | | } |
| | | |
| | | if (vehicleRepair.getSendUserId() != null) { |
| | | XpOperationsUser operationsUser = xpOperationUserClient.queryById(vehicleRepair.getSendUserId()).getData(); |
| | | if (operationsUser != null) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<com.xiaopeng.maintenance.vo.TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | com.xiaopeng.maintenance.vo.TaskPreparationDetailVO res = new com.xiaopeng.maintenance.vo.TaskPreparationDetailVO(); |
| | | public R<TaskPreparationDetailVO> preparationDetail(Long id) { |
| | | TaskPreparationDetailVO res = new TaskPreparationDetailVO(); |
| | | |
| | | |
| | | XpTask task = this.getById(id); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<com.xiaopeng.maintenance.vo.TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | com.xiaopeng.maintenance.vo.TaskDetectionDetailVO res = new com.xiaopeng.maintenance.vo.TaskDetectionDetailVO(); |
| | | public R<TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | TaskDetectionDetailVO res = new TaskDetectionDetailVO(); |
| | | XpTask task = this.getById(id); |
| | | if (task == null) { |
| | | throw new ServiceException( |
| | |
| | | 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()); |
| | | |
| | | |
| | | 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) { |
| | |
| | | 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<com.xiaopeng.maintenance.vo.TaskCleanDetailVO> cleanDetail(Long id) { |
| | | com.xiaopeng.maintenance.vo.TaskCleanDetailVO res = new com.xiaopeng.maintenance.vo.TaskCleanDetailVO(); |
| | | public R<TaskCleanDetailVO> cleanDetail(Long id) throws UnsupportedEncodingException { |
| | | TaskCleanDetailVO res = new TaskCleanDetailVO(); |
| | | XpTask task = this.getById(id); |
| | | if (task == null) { |
| | | throw new ServiceException( |
| | |
| | | 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()); |
| | | |
| | | 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(); |
| | | if (operationsUser != null) { |
| | | res.setOperationsUserName(operationsUser.getNickName()); |
| | | res.setHandleUserName(operationsUser.getNickName()); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public R confirmArrive(Long id, Long userId) { |
| | | RLock lock = redissonClient.getLock("TASK_CONFIRM_" + id); |
| | | |
| | |
| | | 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 && org.apache.commons.lang3.StringUtils.isNotBlank(vehicle.getPlateNumber())) { |
| | | plateNumber = vehicle.getPlateNumber(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("confirmArrive查询车辆信息失败,taskId={}, vehicleId={}", id, vehicleId, e); |
| | | } |
| | | String taskCode = org.apache.commons.lang3.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(); |
| | | 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 { |
| | | // 1 |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | record.setTaskImage(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | pageInfo.setRecords(records); |
| | | pageInfo.setTotal(resultPage.getTotal()); |
| | | return pageInfo; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateTaskStatus(Long taskId, Integer status) { |
| | | public void updateTaskStatus(Long taskId, Integer status, Long operationUserId) { |
| | | if (Objects.nonNull(taskId)) { |
| | | XpTask task = this.getById(taskId); |
| | | if (Objects.nonNull(task)) { |
| | | this.lambdaUpdate().set(XpTask::getStatus, status).eq(XpTask::getId, taskId).update(); |
| | | this.lambdaUpdate().set(XpTask::getStatus, status).eq(XpTask::getId, taskId) |
| | | .set(XpTask::getHandleUserId, operationUserId) |
| | | .set(XpTask::getHandleTime, LocalDateTime.now()) |
| | | .update(); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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(";"); |
| | |
| | | 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(";"); |
| | |
| | | public void saveVehicleAccidentError(Long vehicleId) { |
| | | XpVehicle vehicle = xpVehicleClient.queryById(vehicleId).getData(); |
| | | XpTaskRule taskRule = xpTaskRuleService.lambdaQuery().last("limit 1").one(); |
| | | XpTaskRuleRole taskRuleRole = xpTaskRuleRoleService.lambdaQuery().eq(XpTaskRuleRole::getRuleType, 9).last("limit 1").one(); |
| | | List<XpTaskRuleRole> taskRuleRole = xpTaskRuleRoleService.lambdaQuery().eq(XpTaskRuleRole::getRuleType, 9).list(); |
| | | if (Objects.isNull(taskRuleRole) || Objects.isNull(taskRule)) { |
| | | throw new ServiceException("未配置车辆事故任务分配规则"); |
| | | } |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | //查找事故处理人,处理角色和车辆所属的车队 |
| | | Long fleetId = xpFleetVehicleClient.getFleetIdByVehicleId(vehicle.getId()).getData(); |
| | | XpOperationsUserQueryDTO dto = new XpOperationsUserQueryDTO(); |
| | | dto.setRoleId(taskRuleRole.getRoleId()); |
| | | List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.queryByConditions(dto).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<XpOperationsUserWithRoleVO> collect = data.stream().filter(x -> ids.contains(x.getId())).collect(Collectors.toList()); |
| | | String belongUserIds = collect.stream().map(XpOperationsUserWithRoleVO::getId).collect(Collectors.toSet()).stream().map(String::valueOf).collect(Collectors.joining(",")); |
| | | 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(",")); |
| | | |
| | | 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() + ""); |
| | |
| | | task.setReportTime(LocalDateTime.now()); |
| | | task.setEndTime(LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit())); |
| | | task.setExpiredNoticeSent(0); |
| | | task.setWillTimeoutNoticeSent(0); |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE); |
| | | task.setCreateBy("系统自动生成"); |
| | | task.setCreateTime(LocalDateTime.now()); |
| | |
| | | @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())); |
| | | } |
| | | task.setAssigneeTime(LocalDateTime.now()); |
| | | task.setHandleUserId(handlerUserId.toString()); |
| | | task.setVehicleId(null); |
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | task.setTaskCode(code); |
| | | // 查询规则 |
| | | XpTaskRule taskRule = xpTaskRuleMapper.selectOne(null); |
| | | if (taskRule != null) { |
| | | task.setEndTime(LocalDateTime.now().plusMinutes(taskRule.getProcessingTimeLimit())); |
| | | } |
| | | task.setTaskCategory(2); |
| | | // todo 临时处理 |
| | | task.setHandleUserId("1"); |
| | | task.setTaskTypeId(dto.getTaskTypeId()); |
| | | task.setTaskUrgencyLevel(dto.getTaskUrgencyLevel()); |
| | | task.setTaskDescription(dto.getTaskDescription()); |
| | |
| | | task.setVehicleLat(dto.getVehicleLat()); |
| | | task.setReportUserId(reportUserId); |
| | | 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) { |
| | |
| | | taskManagementDetectionDetailVO.setVehicleCode(vehicle.getVehicleCode()); |
| | | taskManagementDetectionDetailVO.setVehicleVin(vehicle.getVehicleVin()); |
| | | taskManagementDetectionDetailVO.setVehicleLocation(task.getVehicleLocation()); |
| | | taskManagementDetectionDetailVO.setVehiclePictures(vehicle.getVehiclePictures()); |
| | | |
| | | if (vehicle.getVehiclePictures() != null) { |
| | | JSONObject jsonObject = JSONObject.parseObject(vehicle.getVehiclePictures()); |
| | | // 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); |
| | | taskManagementDetectionDetailVO.setVehiclePictures(jsonObject.toJSONString()); |
| | | } |
| | | |
| | | 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) { |
| | |
| | | res.setErrorTypeList(xpErrorTypes); |
| | | res.setStatus(task.getStatus()); |
| | | res.setTaskDescription(task.getTaskDescription()); |
| | | res.setTaskImage(task.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.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); |
| | | } |
| | | |