| | |
| | | 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.feignClient.account.SysUserClient; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationUserClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.account.SysUser; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | import com.xiaopeng.api.model.maintenance.*; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.maintenance.constant.I18nKeyConstant; |
| | | import com.xiaopeng.maintenance.dto.HandleVehicleAccidentDto; |
| | | import com.xiaopeng.maintenance.dto.SaveErrorTaskDto; |
| | | import com.xiaopeng.maintenance.dto.SaveRoutineDetailDto; |
| | | import com.xiaopeng.maintenance.dto.SaveVehicleAccidentDto; |
| | | import com.xiaopeng.maintenance.mapper.*; |
| | | import com.xiaopeng.maintenance.model.query.TaskManagementPageListQuery; |
| | | import com.xiaopeng.maintenance.model.query.TaskPageListQuery; |
| | | import com.xiaopeng.maintenance.model.query.WorkBenchQuery; |
| | | import com.xiaopeng.maintenance.model.query.XpTaskRecordPageQuery; |
| | | import com.xiaopeng.maintenance.model.vo.*; |
| | | import com.xiaopeng.maintenance.service.XpTaskService; |
| | | import com.xiaopeng.maintenance.utils.UUIDUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | private XpVehicleCleanMapper vehicleCleanMapper; |
| | | @Autowired |
| | | private XpOperationUserClient xpOperationUserClient; |
| | | @Autowired |
| | | private SysUserClient sysUserClient; |
| | | @Autowired |
| | | private XpTaskHandleDetailRoutineMapper xpTaskHandleDetailRoutineMapper; |
| | | |
| | |
| | | @Override |
| | | public void saveVehicleAccident(SaveVehicleAccidentDto dto, XpOperationsUser xpOperationsUser) { |
| | | XpTask xpTask = new XpTask(); |
| | | xpTask.setTaskCode("1"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); |
| | | xpTask.setTaskCode(code); |
| | | xpTask.setTaskCategory(2); |
| | | xpTask.setTaskTypeId(dto.getTaskTypeId()); |
| | | xpTask.setTaskUrgencyLevel(dto.getTaskUrgencyLevel()); |
| | |
| | | @Override |
| | | public R<com.xiaopeng.maintenance.vo.TaskDetectionDetailVO> detectionDetail(Long id) { |
| | | com.xiaopeng.maintenance.vo.TaskDetectionDetailVO res = new com.xiaopeng.maintenance.vo.TaskDetectionDetailVO(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | XpTask task = this.getById(id); |
| | | if (task == null){ |
| | | throw new ServiceException( |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R confirmArrive(Integer id) { |
| | | public R confirmArrive(Long id) { |
| | | XpTask task = this.getById(id); |
| | | if (task!=null){ |
| | | task.setStatus(1); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TaskManagementPageListVO> pageListManagement(TaskManagementPageListQuery query) { |
| | | PageInfo<TaskManagementPageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TaskManagementPageListVO> list = this.baseMapper.pageListManagement(pageInfo, query); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public R assigneeTask(Long id, Long handlerUserId,Long assigneeUserId) { |
| | | XpTask task = this.getById(id); |
| | | task.setAssigneeTime(LocalDateTime.now()); |
| | | task.setHandleUserId(handlerUserId); |
| | | task.setAssigneeUserId(assigneeUserId); |
| | | this.updateById(task); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public void saveTask(SaveErrorTaskDto dto, Long reportUserId) { |
| | | |
| | | XpTask task = new XpTask(); |
| | | BeanUtils.copyProperties(dto, task); |
| | | task.setReportTime(LocalDateTime.now()); |
| | | task.setStatus(0); |
| | | 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())); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public R<TaskManagementDetailVO> taskDetail(Long id) { |
| | | TaskManagementDetailVO managementDetailVO = new TaskManagementDetailVO(); |
| | | XpTask task = this.getById(id); |
| | | if (task == null){ |
| | | throw new ServiceException( |
| | | "任务不存在", |
| | | I18nKeyConstant.TASK_NOT_EXIST |
| | | ); |
| | | } |
| | | XpVehicle vehicle = xpVehicleClient.queryById(task.getVehicleId()).getData(); |
| | | if (vehicle == null){ |
| | | throw new ServiceException( |
| | | "车辆不存在", |
| | | I18nKeyConstant.VEHICLE_NOT_EXIST |
| | | ); |
| | | } |
| | | |
| | | if (task.getTaskCategory()==1){ |
| | | // 常规任务 |
| | | |
| | | switch (task.getTaskTypeId()){ |
| | | case "1": |
| | | // 检测 |
| | | TaskManagementDetectionDetailVO taskManagementDetectionDetailVO = new TaskManagementDetectionDetailVO(); |
| | | break; |
| | | case "2": |
| | | // 充电 |
| | | TaskManagementChargingDetailVO taskManagementChargingDetailVO = new TaskManagementChargingDetailVO(); |
| | | break; |
| | | case "3": |
| | | // 整备 |
| | | TaskManagementPreparationDetailVO taskManagementPreparationDetailVO = new TaskManagementPreparationDetailVO(); |
| | | break; |
| | | case "4": |
| | | // 洗车 |
| | | TaskManagementCleanDetailVO taskManagementCleanDetailVO = new TaskManagementCleanDetailVO(); |
| | | break; |
| | | case "5": |
| | | // 维修 |
| | | TaskManagementRepairDetailVO taskManagementRepairDetailVO = new TaskManagementRepairDetailVO(); |
| | | break; |
| | | default: |
| | | // 保养、年检、保险、营运资质 |
| | | TaskManagementRoutineDetailVO res = new TaskManagementRoutineDetailVO(); |
| | | res.setId(task.getId()); |
| | | res.setTaskUrgencyLevel(task.getTaskUrgencyLevel()); |
| | | res.setPlateNumber(vehicle.getPlateNumber()); |
| | | res.setVehicleColor(vehicle.getVehicleColor()); |
| | | res.setVehicleCode(vehicle.getVehicleCode()); |
| | | res.setVehicleLocation(task.getVehicleLocation()); |
| | | res.setVehicleVin(vehicle.getVehicleVin()); |
| | | res.setTaskCode(task.getTaskCode()); |
| | | res.setTaskDescription(task.getTaskDescription()); |
| | | res.setTaskImage(task.getTaskImage()); |
| | | res.setHandleUserId(task.getHandleUserId()); |
| | | XpOperationsUser operationsUser = xpOperationUserClient.queryById(task.getHandleUserId()).getData(); |
| | | if (operationsUser != null){ |
| | | res.setHandleUserId(operationsUser.getId()); |
| | | res.setHandleUserName(operationsUser.getNickName()); |
| | | } |
| | | res.setHandleTime(task.getHandleTime()); |
| | | res.setId(id); |
| | | res.setTaskUrgencyLevel(task.getTaskUrgencyLevel()); |
| | | res.setPlateNumber(vehicle.getPlateNumber()); |
| | | res.setVehicleColor(vehicle.getVehicleColor()); |
| | | res.setVehicleCode(vehicle.getVehicleCode()); |
| | | res.setVehicleLocation(task.getVehicleLocation()); |
| | | res.setVehicleVin(vehicle.getVehicleVin()); |
| | | break; |
| | | } |
| | | |
| | | |
| | | }else{ |
| | | // 事故任务 |
| | | TaskManagementAccidentDetailVO res = new TaskManagementAccidentDetailVO(); |
| | | |
| | | Map<Long, List<XpErrorType>> errorType = errorTypeMapper.selectList(new LambdaQueryWrapper<XpErrorType>() |
| | | .in(XpErrorType::getId, Arrays.asList(task.getTaskTypeId().split(",")))) |
| | | .stream().collect(Collectors.groupingBy(XpErrorType::getParentId)); |
| | | 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()); |
| | | res.setId(id); |
| | | res.setVehicleId(vehicle.getId()); |
| | | res.setTaskUrgencyLevel(task.getTaskUrgencyLevel()); |
| | | res.setPlateNumber(vehicle.getPlateNumber()); |
| | | res.setVehicleColor(vehicle.getVehicleColor()); |
| | | res.setVehicleCode(vehicle.getVehicleCode()); |
| | | res.setVehicleLocation(task.getVehicleLocation()); |
| | | res.setVehicleVin(vehicle.getVehicleVin()); |
| | | List<Long> reportUserIds = new ArrayList<>(); |
| | | reportUserIds.add(task.getReportUserId()); |
| | | List<SysUser> sysUsers = sysUserClient.listByIds(reportUserIds).getData(); |
| | | if (sysUsers!=null && !sysUsers.isEmpty()){ |
| | | SysUser sysUser = sysUsers.get(0); |
| | | res.setReportUserId(sysUser.getId()); |
| | | res.setReportUserName(sysUser.getNickName()); |
| | | res.setReportUserPhone(sysUser.getPhoneNumber()); |
| | | res.setReportUserAvatar(sysUser.getAvatar()); |
| | | } |
| | | XpOperationsUser operationsUser = xpOperationUserClient.queryById(task.getHandleUserId()).getData(); |
| | | if (operationsUser != null){ |
| | | res.setHandleUserId(operationsUser.getId()); |
| | | res.setHandleUserName(operationsUser.getNickName()); |
| | | res.setHandleUserPhone(operationsUser.getPhoneNumber()); |
| | | res.setHandleUserAvatar(operationsUser.getAvatar()); |
| | | } |
| | | XpTaskHandleDetail xpTaskHandleDetail = xpTaskHandleDetailMapper.selectOne(new LambdaQueryWrapper<XpTaskHandleDetail>() |
| | | .eq(XpTaskHandleDetail::getTaskId, id)); |
| | | res.setDeathCount(xpTaskHandleDetail.getDeathCount()); |
| | | res.setSevereCount(xpTaskHandleDetail.getSevereCount()); |
| | | res.setMinorCount(xpTaskHandleDetail.getMinorCount()); |
| | | res.setResponsibilityJudgment(xpTaskHandleDetail.getResponsibilityJudgment()); |
| | | res.setResponsibleDescription(xpTaskHandleDetail.getResponsibleDescription()); |
| | | res.setResponsibleImage(xpTaskHandleDetail.getResponsibleImage()); |
| | | res.setDisposalDescription(xpTaskHandleDetail.getDisposalDescription()); |
| | | res.setDisposalImage(xpTaskHandleDetail.getDisposalImage()); |
| | | res.setSituationDescription(xpTaskHandleDetail.getSituationDescription()); |
| | | res.setSituationImage(xpTaskHandleDetail.getSituationImage()); |
| | | managementDetailVO.setAccidentDetailVO(res); |
| | | } |
| | | return R.ok(managementDetailVO); |
| | | } |
| | | |
| | | } |