|  |  | 
 |  |  |         try { | 
 |  |  |             // 下载Excel文件到本地临时文件 | 
 |  |  |             File tempFile = File.createTempFile("temp", ".xlsx"); | 
 |  |  |             ossClient.getObject(new GetObjectRequest(bucketName, smsTaskDTO.getFileUrl()), tempFile); | 
 |  |  |             String fileUrl = smsTaskDTO.getFileUrl(); | 
 |  |  |             String objectKey = fileUrl.replaceFirst("^https?://[^/]+/", ""); // 去掉协议部分 | 
 |  |  |             ossClient.getObject(new GetObjectRequest(bucketName, objectKey), tempFile); | 
 |  |  |  | 
 |  |  |             // 解析Excel文件 | 
 |  |  |             try (FileInputStream inputStream = new FileInputStream(tempFile); Workbook workbook = new XSSFWorkbook(inputStream)) { | 
 |  |  |             try (FileInputStream inputStream = new FileInputStream(tempFile); | 
 |  |  |                  Workbook workbook = new XSSFWorkbook(inputStream)) { | 
 |  |  |  | 
 |  |  |                 Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表 | 
 |  |  |                 int rowCount = sheet.getPhysicalNumberOfRows(); | 
 |  |  | 
 |  |  |                     Row row = sheet.getRow(i); | 
 |  |  |                     if (row != null) { | 
 |  |  |                         Cell cell = row.getCell(0); // 假设手机号在第一列 | 
 |  |  |                         if (cell != null && cell.getCellType() == CellType.STRING) { | 
 |  |  |                             String phoneNumber = cell.getStringCellValue(); | 
 |  |  |                         if (cell != null ) { | 
 |  |  |                             String phoneNumber = ""; | 
 |  |  |                             if (cell.getCellType() == CellType.STRING) { | 
 |  |  |                                 phoneNumber = cell.getStringCellValue(); | 
 |  |  |                             } else if (cell.getCellType() == CellType.NUMERIC) { | 
 |  |  |                                 // 将数字类型的手机号转换为字符串 | 
 |  |  |                                 phoneNumber = String.valueOf((long) cell.getNumericCellValue()); | 
 |  |  |                             } | 
 |  |  |                             if (!PHONE_NUMBER_PATTERN.matcher(phoneNumber).matches()) { | 
 |  |  |                                 message.append("第" + (i + 1) + "行手机号" + phoneNumber + "格式不正确"); | 
 |  |  |                                 isValid = false; | 
 |  |  | 
 |  |  |                                 phones.append(phoneNumber).append("\n"); | 
 |  |  |                             } | 
 |  |  |                         } else { | 
 |  |  |                             message.append("行上的单元格为空或无效 " + (i + 1)); | 
 |  |  |                             message.append("第" + (i + 1)+ "行上的单元格为空或无效 "); | 
 |  |  |                             isValid = false; | 
 |  |  |                             break; // 退出循环 | 
 |  |  |                         } | 
 |  |  | 
 |  |  |                     throw new ValidationException(message.toString()); | 
 |  |  |                 } else { | 
 |  |  |                     smsTaskDTO.setPhones(phones.toString()); | 
 |  |  |                     smsTaskDTO.setNum((long) rowCount); | 
 |  |  |                     smsTaskDTO.setNum((long) rowCount - 1); | 
 |  |  |                 } | 
 |  |  |             } catch (IOException e) { | 
 |  |  |                 e.printStackTrace(); |