Files
server/HARD_CODED_PATHS_ANALYSIS.md
2025-11-22 14:22:36 +08:00

94 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🚨 项目硬编码路径分析报告
## ✅ **已正确配置化的路径**
以下路径已正确使用配置文件,不再硬编码:
### 1. **基础文件路径** ✅
- `@Value("${img.upload}")` - 图片上传路径
- `@Value("${temp.path}")` - 临时文件路径
- `@Value("${upload.path}")` - 上传根路径
- `@Value("${report.path}")` - 报表路径
- `@Value("${unzip.path}")` - 解压路径
### 2. **使用配置的主要文件** ✅
- `ImportService.java` - tempPath已配置
- `CompactShelvingController.java` - tempPath已配置
- `ReportTemplateService.java` - reportPath已配置
- `OADockingIml.java` - unzipPath已配置
## ❌ **发现的问题路径**
### 1. **UReport文件下载路径硬编码** 🚨
#### **文件**: `src/main/java/com/point/strategy/docSimpleArrange/controller/DocSimpleController.java`
```java
String fileName = "创建文书简化pdf文件.pdf";
String downLoadPath = "D:\\\\ureportfiles\\\\"+fileName; // ❌ 硬编码
```
#### **文件**: `src/main/java/com/point/strategy/oaDocking/controller/DocTraditionVolumeOaController.java`
```java
String downLoadPath = "C:\\\\ureportfiles\\\\"+fileName; // ❌ 硬编码
outputStream = new FileOutputStream(new File("C:\\ureportfiles\\"+fileName)); // ❌ 硬编码
```
### 2. **测试代码中的硬编码** ⚠️
#### **文件**: `src/main/java/com/point/strategy/oaDocking/service/YcjSystemIntegration.java`
```java
// main方法中的测试代码
new FileInputStream(new File("D:\\2\\222.pdf")); // ⚠️ 测试代码硬编码
new File("D:\\2\\222.pdf").length(); // ⚠️ 测试代码硬编码
```
### 3. **注释中的示例路径** 💡
```java
// 这些是注释和示例,通常不影响运行
// DbOperate.dbBackUp("root", "123456", "zaizhi", "d:/3", backName);
// if (exportDatabaseTool("192.168.1.112", "3306","root", "123456", "d:/3", "zaizhi.sql", "zaizhi")) {
```
## 🔧 **修复建议**
### 1. **立即修复: UReport下载路径**
#### **方案A: 添加配置项**
```yaml
# application-prod.yml 中添加
ureport:
download:
path: ${UREPORT_DOWNLOAD_PATH:/app/data/ureport}
```
#### **方案B: 使用report.path**
```java
// 建议修改为
@Value("${report.path}")
private String reportPath;
String downLoadPath = reportPath + File.separator + fileName;
```
### 2. **清理测试代码**
```java
// 移除main方法中的硬编码路径或改为配置化
```
## 📊 **风险评估**
| 问题类型 | 影响程度 | 修复难度 | 优先级 |
|----------|----------|----------|--------|
| UReport下载路径 | 🔴 高 | 🟢 低 | **P0** |
| 测试代码硬编码 | 🟡 中 | 🟢 低 | P2 |
| 注释示例路径 | 🟢 低 | 🟢 低 | P3 |
## 🎯 **推荐修复顺序**
1. **第一步**: 修复UReport下载路径硬编码 (P0)
2. **第二步**: 清理YcjSystemIntegration测试代码 (P2)
3. **第三步**: 统一路径处理工具类 (P1)
---
**总结**: 主要问题是UReport文件下载使用了Windows硬编码路径需要立即修复以支持Linux/Mac环境部署。