refactor: 重构HealthDataOptimizer为DataUpload,优化包结构和命名

## 重构内容

### 1. 文件重命名和移动
- HealthDataOptimizer.java → DataUpload.java
- 包路径: optimizer → upload
- 类名: HealthDataOptimizer → DataUpload
- 构造函数和日志信息同步更新

### 2. 控制器引用更新
- DataUploadController中所有引用从HealthDataOptimizer改为DataUpload
- 统计API方法名优化为更准确的描述
- 线程名称从"health-data-optimizer"改为"data-upload"

### 3. 语义化改进
- 方法注释和描述更准确反映数据上传功能
- 日志信息统一使用"DataUpload"标识
- API文档描述优化

### 技术改进
- 更清晰的包结构组织
- 统一的命名规范
- 更准确的功能语义

🚀 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
BrunoGao
2025-09-23 13:06:37 +08:00
co-authored by Claude
parent 52104a5b81
commit ba255bb6b1
2 changed files with 21 additions and 21 deletions
@@ -20,7 +20,7 @@
package com.ljwx.modules.health.controller;
import com.ljwx.common.api.vo.Result;
import com.ljwx.modules.health.optimizer.HealthDataOptimizer;
import com.ljwx.modules.health.upload.DataUpload;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@@ -45,7 +45,7 @@ import java.util.Map;
public class DataUploadController {
@Autowired
private HealthDataOptimizer healthDataOptimizer;
private DataUpload dataUpload;
/**
* 健康数据上传 (替换upload_health_data)
@@ -59,7 +59,7 @@ public class DataUploadController {
try {
// 使用完整迁移的Python系统功能
return healthDataOptimizer.optimizedUploadHealthDataWithSeparation(healthData);
return dataUpload.optimizedUploadHealthDataWithSeparation(healthData);
} catch (Exception e) {
log.error("❌ 优化健康数据上传失败", e);
@@ -77,7 +77,7 @@ public class DataUploadController {
log.info("🚀 收到健康数据批量上传请求,数据量: {}", healthDataList.size());
try {
return healthDataOptimizer.uploadHealthData(healthDataList);
return dataUpload.uploadHealthData(healthDataList);
} catch (Exception e) {
log.error("❌ 传统批量健康数据上传失败", e);
@@ -95,7 +95,7 @@ public class DataUploadController {
log.info("🚀 收到设备信息批量上传请求,数据量: {}", deviceDataList.size());
try {
return healthDataOptimizer.uploadDeviceInfo(deviceDataList);
return dataUpload.uploadDeviceInfo(deviceDataList);
} catch (Exception e) {
log.error("❌ 设备信息批量上传失败", e);
@@ -113,7 +113,7 @@ public class DataUploadController {
log.info("🚀 收到通用事件上传请求");
try {
return healthDataOptimizer.uploadCommonEvent(eventData);
return dataUpload.uploadCommonEvent(eventData);
} catch (Exception e) {
log.error("❌ 通用事件上传失败", e);
@@ -122,17 +122,17 @@ public class DataUploadController {
}
/**
* 获取优化器统计信息
* 获取数据上传统计信息
*/
@GetMapping("/stats")
@Operation(summary = "获取优化器统计信息", description = "查看健康数据优化器的运行统计信息")
public Result<Map<String, Object>> getOptimizerStats() {
@Operation(summary = "获取数据上传统计信息", description = "查看数据上传处理器的运行统计信息")
public Result<Map<String, Object>> getUploadStats() {
try {
Map<String, Object> stats = healthDataOptimizer.getOptimizerStats();
Map<String, Object> stats = dataUpload.getOptimizerStats();
return Result.ok(stats);
} catch (Exception e) {
log.error("❌ 获取优化器统计信息失败", e);
log.error("❌ 获取数据上传统计信息失败", e);
return Result.error("获取统计信息失败: " + e.getMessage());
}
}
@@ -141,10 +141,10 @@ public class DataUploadController {
* 获取性能统计信息
*/
@GetMapping("/performance")
@Operation(summary = "获取性能统计信息", description = "查看健康数据处理的性能统计信息")
@Operation(summary = "获取性能统计信息", description = "查看数据处理的性能统计信息")
public Result<Map<String, Object>> getPerformanceStats() {
try {
Map<String, Object> stats = healthDataOptimizer.getPerformanceStats();
Map<String, Object> stats = dataUpload.getPerformanceStats();
return Result.ok(stats);
} catch (Exception e) {
@@ -17,7 +17,7 @@
* limitations under the License.
*/
package com.ljwx.modules.health.optimizer;
package com.ljwx.modules.health.upload;
import com.ljwx.common.api.vo.Result;
import com.ljwx.modules.health.domain.entity.TDeviceInfo;
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
/**
* 健康数据性能优化器
* 数据上传处理器
*
* 基于ljwx-bigscreen的HealthDataOptimizer优化算法,提供:
* - CPU自适应批处理
@@ -59,12 +59,12 @@ import java.util.stream.Collectors;
*
* @Author jjgao
* @ProjectName ljwx-boot
* @ClassName HealthDataOptimizer
* @ClassName DataUpload
* @CreateTime 2024-12-16
*/
@Slf4j
@Component
public class HealthDataOptimizer {
public class DataUpload {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@@ -116,7 +116,7 @@ public class HealthDataOptimizer {
private final List<Long> performanceWindow = Collections.synchronizedList(new ArrayList<>());
private volatile long lastAdjustmentTime = System.currentTimeMillis();
public HealthDataOptimizer(RedisTemplate<String, Object> redisTemplate) {
public DataUpload(RedisTemplate<String, Object> redisTemplate) {
this.redisTemplate = redisTemplate;
// 初始化线程池
@@ -126,10 +126,10 @@ public class HealthDataOptimizer {
60L, // 空闲时间
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(1000),
r -> new Thread(r, "health-data-optimizer-" + System.currentTimeMillis())
r -> new Thread(r, "data-upload-" + System.currentTimeMillis())
);
log.info("🚀 HealthDataOptimizer 初始化:");
log.info("🚀 DataUpload 初始化:");
log.info(" CPU核心: {}, 内存: {}MB", cpuCores, memoryMb);
log.info(" 批次大小: {}, 工作线程: {}", batchSize, maxWorkers);
@@ -1095,7 +1095,7 @@ public class HealthDataOptimizer {
executor.shutdownNow();
Thread.currentThread().interrupt();
}
log.info("🔒 HealthDataOptimizer 已关闭");
log.info("🔒 DataUpload 已关闭");
}
/**