13 小时以前 9bad721754fe8bbe2e5f459d0706e0fefac569f3
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/purchase/ai/ErpPurchaseInvoiceAiServiceImpl.java
@@ -90,7 +90,6 @@
    @Override
    public ErpPurchaseInvoiceOcrRespVO ocrInvoice(ErpPurchaseInvoiceOcrReqVO reqVO) {
        File tempFile = null;
        try {
            // 1. 下载文件
            SystemStorageBlobDO blob = blobService.getStorageBlob(reqVO.getBlobId());
@@ -105,12 +104,12 @@
                return errorResp("不支持的文件类型,请上传 PDF/图片文件");
            }
            // 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()) {
                return errorResp("文件读取失败");
            }
            byte[] fileBytes = Files.readAllBytes(tempFile.toPath());
            byte[] fileBytes = Files.readAllBytes(blobFile.toPath());
            if (fileBytes.length == 0) {
                return errorResp("文件内容为空,无法识别");
            }
@@ -139,10 +138,6 @@
        } catch (Exception e) {
            log.warn("AI OCR 识别发票失败,blobId={}", reqVO.getBlobId(), e);
            return errorResp("AI 识别暂时不可用,请手动录入");
        } finally {
            if (tempFile != null && tempFile.exists()) {
                tempFile.delete();
            }
        }
    }