| | |
| | | |
| | | @Override |
| | | public CrmSaleQuotationOcrRespVO ocrQuotation(CrmSaleQuotationOcrReqVO reqVO) { |
| | | File tempFile = null; |
| | | try { |
| | | // 1. 下载文件 |
| | | SystemStorageBlobDO blob = blobService.getStorageBlob(reqVO.getBlobId()); |
| | |
| | | return error; |
| | | } |
| | | |
| | | // 3. 获取文件字节 |
| | | tempFile = blobService.getPublicFile(blob.getUidFilename(), blob.getResourceKey()); |
| | | if (tempFile == null || !tempFile.exists()) { |
| | | // 3. 获取文件字节。这里是磁盘上真实存储的那份 blob,不是临时副本,读完不能删。 |
| | | File blobFile = blobService.getPublicFile(blob.getUidFilename(), blob.getResourceKey()); |
| | | if (blobFile == null || !blobFile.exists()) { |
| | | CrmSaleQuotationOcrRespVO error = new CrmSaleQuotationOcrRespVO(); |
| | | error.setRawText("文件读取失败"); |
| | | return error; |
| | | } |
| | | byte[] fileBytes = Files.readAllBytes(tempFile.toPath()); |
| | | byte[] fileBytes = Files.readAllBytes(blobFile.toPath()); |
| | | |
| | | // 4. AI 识别(图片走多模态,文本走纯文本) |
| | | boolean isImage = IMAGE_EXTENSIONS.contains(ext); |
| | |
| | | CrmSaleQuotationOcrRespVO fallback = new CrmSaleQuotationOcrRespVO(); |
| | | fallback.setRawText("AI 识别暂时不可用,请手动录入"); |
| | | return fallback; |
| | | } finally { |
| | | if (tempFile != null && tempFile.exists()) { |
| | | tempFile.delete(); |
| | | } |
| | | } |
| | | } |
| | | |