昨天 761a0be8107352275beceb634dac3b25f40300fd
fix(qrcode): 修复二维码生成时临时目录创建和异常处理问题

- 添加临时目录不存在时的创建逻辑并处理创建失败情况
- 统一异常处理,将WriterException和IOException合并处理
- 改进错误信息传递,保留原始异常堆栈信息
- 在调用层添加具体异常信息到服务异常中便于调试
- 更新AI助手配置以支持临时文件目录读取权限
已修改3个文件
17 ■■■■■ 文件已修改
.claude/settings.local.json 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/utils/MatrixToImageWriter.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionOperationTaskServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
.claude/settings.local.json
@@ -22,7 +22,9 @@
      "Bash(echo \"EXIT=$?\")",
      "Read(//tmp/**)",
      "Bash(npm install *)",
      "Bash(node -e \"require.resolve\\('html2canvas'\\) && console.log\\('html2canvas installed:', require\\('html2canvas/package.json'\\).version\\)\")"
      "Bash(node -e \"require.resolve\\('html2canvas'\\) && console.log\\('html2canvas installed:', require\\('html2canvas/package.json'\\).version\\)\")",
      "Read(//javaWork/product-inventory-management/file/temp/**)",
      "Read(//d/javaWork/product-inventory-management/file/temp/**)"
    ]
  },
  "enabledMcpjsonServers": [
src/main/java/com/ruoyi/common/utils/MatrixToImageWriter.java
@@ -54,14 +54,15 @@
            hints.put(EncodeHintType.MARGIN, 0);
            BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 400, 400, hints);
            File file1 = new File(path, codeName + "." + imageType);
            File parent = file1.getParentFile();
            if (parent != null && !parent.exists() && !parent.mkdirs()) {
                throw new IOException("临时目录创建失败:" + parent.getPath());
            }
            writeToFile(bitMatrix, imageType, file1);
            return file1.getPath();
        } catch (WriterException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (WriterException | IOException e) {
            throw new RuntimeException("二维码生成失败:" + e.getMessage(), e);
        }
        throw new RuntimeException("二维码生成失败");
    }
}
src/main/java/com/ruoyi/production/service/impl/ProductionOperationTaskServiceImpl.java
@@ -229,7 +229,7 @@
        try {
            codePath = new MatrixToImageWriter().code(taskDto.getId().toString(), tempDir);
        } catch (Exception e) {
            throw new ServiceException("生成二维码失败");
            throw new ServiceException("生成二维码失败:" + e.getMessage());
        }
        List<Map<String, Object>> images = buildTaskAttachmentImages(taskDto.getId());