diff --git a/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/health/HealthFeatureController.java b/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/health/HealthFeatureController.java index 89148c4..edf2c7b 100644 --- a/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/health/HealthFeatureController.java +++ b/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/health/HealthFeatureController.java @@ -56,7 +56,17 @@ public class HealthFeatureController { @GetMapping(value = "/base") public Result>> getBaseFeatures(@RequestParam("customerId") Long customerId) { try { - List configs = healthDataConfigService.getBaseConfigsByOrgId(customerId); + log.info("📈 获取基础健康特征配置 - customerId: {}", customerId); + + // 直接使用customerId查询t_health_data_config表获取基础体征配置 + List configs = healthDataConfigService.getBaseConfigsByCustomerId(customerId); + + log.info("✅ 查询到 {} 个基础体征配置", configs.size()); + configs.forEach(config -> + log.debug(" - {}: {} (enabled: {}, weight: {})", + config.getDataType(), getDataTypeLabel(config.getDataType()), + config.getIsEnabled(), config.getWeight()) + ); List> features = configs.stream() .map(config -> { @@ -70,7 +80,7 @@ public class HealthFeatureController { return Result.data(features); } catch (Exception e) { - log.error("Failed to get base features for customerId: {}", customerId, e); + log.error("❌ 获取基础健康特征失败 - customerId: {}", customerId, e); return Result.failure("获取健康特征失败"); } } @@ -79,7 +89,12 @@ public class HealthFeatureController { @GetMapping(value = "/full") public Result>> getFullFeatures(@RequestParam("customerId") Long customerId) { try { - List configs = healthDataConfigService.getEnabledConfigsByOrgId(customerId); + log.info("📈 获取全量健康特征配置 - customerId: {}", customerId); + + // 直接使用customerId查询t_health_data_config表获取所有启用的特征配置 + List configs = healthDataConfigService.getEnabledConfigsByCustomerId(customerId); + + log.info("✅ 查询到 {} 个全量特征配置", configs.size()); List> features = configs.stream() .map(config -> { @@ -93,7 +108,7 @@ public class HealthFeatureController { return Result.data(features); } catch (Exception e) { - log.error("Failed to get full features for customerId: {}", customerId, e); + log.error("❌ 获取全量健康特征失败 - customerId: {}", customerId, e); return Result.failure("获取健康特征失败"); } } diff --git a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/ITHealthDataConfigService.java b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/ITHealthDataConfigService.java index e0b9a48..c88e0fc 100644 --- a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/ITHealthDataConfigService.java +++ b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/ITHealthDataConfigService.java @@ -49,6 +49,26 @@ public interface ITHealthDataConfigService extends IService { */ IPage listTHealthDataConfigPage(PageQuery pageQuery, THealthDataConfigBO tHealthDataConfigBO); + /** + * 根据 customerId 查询启用的健康数据配置 + * + * @param customerId 客户ID + * @return {@link List} 启用的健康数据配置列表 + * @author jjgao + * @CreateTime 2025-01-15 + */ + List getEnabledConfigsByCustomerId(Long customerId); + + /** + * 根据 customerId 查询基础健康数据配置(t_user_health_data主表字段) + * + * @param customerId 客户ID + * @return {@link List} 基础健康数据配置列表 + * @author jjgao + * @CreateTime 2025-01-15 + */ + List getBaseConfigsByCustomerId(Long customerId); + /** * 根据 orgId 查询启用的健康数据配置 * diff --git a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/THealthDataConfigServiceImpl.java b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/THealthDataConfigServiceImpl.java index d5829ad..e14d041 100644 --- a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/THealthDataConfigServiceImpl.java +++ b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/THealthDataConfigServiceImpl.java @@ -66,6 +66,36 @@ public class THealthDataConfigServiceImpl extends ServiceImpl getEnabledConfigsByCustomerId(Long customerId) { + return list(new LambdaQueryWrapper() + .eq(THealthDataConfig::getIsEnabled, 1) + .eq(THealthDataConfig::getCustomerId, customerId) + .orderByDesc(THealthDataConfig::getWeight)); + } + + @Override + public List getBaseConfigsByCustomerId(Long customerId) { + // 定义t_user_health_data主表的基础体征字段(排除复杂的分表数据) + List baseMetrics = Arrays.asList( + "heart_rate", // 心率 + "blood_oxygen", // 血氧 + "temperature", // 体温 + "pressure_high", // 收缩压 + "pressure_low", // 舒张压 + "step", // 步数 + "stress", // 压力 + "calorie", // 卡路里 + "distance" // 距离 + ); + + return list(new LambdaQueryWrapper() + .eq(THealthDataConfig::getIsEnabled, 1) + .eq(THealthDataConfig::getCustomerId, customerId) + .in(THealthDataConfig::getDataType, baseMetrics) + .orderByDesc(THealthDataConfig::getWeight)); + } + @Override public List getEnabledConfigsByOrgId(Long orgId) { // 获取顶级部门ID用于查询配置