|
@@ -3142,6 +3142,7 @@ public class DatabaseInitializer implements CommandLineRunner {
|
|
|
// ==================== 健康维度 Phase 1: health_dimension_score / health_data_source_record / health_norm_reference ====================
|
|
// ==================== 健康维度 Phase 1: health_dimension_score / health_data_source_record / health_norm_reference ====================
|
|
|
migrateHealthDimensionsTable();
|
|
migrateHealthDimensionsTable();
|
|
|
seedHealthNorms();
|
|
seedHealthNorms();
|
|
|
|
|
+ seedMindActionWealthNorms();
|
|
|
runLateMigrations();
|
|
runLateMigrations();
|
|
|
migration102();
|
|
migration102();
|
|
|
// 迁移226-247: 原seedFullRegionData内的DDL迁移,确保不因省市区数据已存在而跳过
|
|
// 迁移226-247: 原seedFullRegionData内的DDL迁移,确保不因省市区数据已存在而跳过
|
|
@@ -3572,6 +3573,157 @@ public class DatabaseInitializer implements CommandLineRunner {
|
|
|
ensureColumn("focus_sessions", "task_id", "BIGINT NULL COMMENT '关联的任务ID(专注任务挂钩)'");
|
|
ensureColumn("focus_sessions", "task_id", "BIGINT NULL COMMENT '关联的任务ID(专注任务挂钩)'");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void seedMindActionWealthNorms() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Integer count = jdbcTemplate.queryForObject(
|
|
|
|
|
+ "SELECT COUNT(*) FROM health_norm_reference WHERE dimension LIKE 'bigFive%' OR dimension LIKE 'emotion%' OR dimension LIKE 'drive%' OR dimension LIKE 'selfConcept%' OR dimension LIKE 'action%' OR dimension LIKE 'wealth%'",
|
|
|
|
|
+ Integer.class);
|
|
|
|
|
+ if (count != null && count > 0) {
|
|
|
|
|
+ log.info("mind/action/wealth 常模数据已存在 ({}条), 跳过", count);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ java.util.List<String> sqls = new java.util.ArrayList<>();
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('bigFiveOpenness','all',0,84,20,27,35,45,55,63,70,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveOpenness','all',84,144,27,34,42,52,62,70,77,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveOpenness','all',144,216,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveOpenness','all',216,1200,25,32,40,50,60,68,75,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('bigFiveConscientiousness','all',0,84,15,22,30,40,50,58,65,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveConscientiousness','all',84,144,23,30,38,48,58,66,73,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveConscientiousness','all',144,216,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveConscientiousness','all',216,1200,33,40,48,58,68,76,83,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('bigFiveExtraversion','all',0,84,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveExtraversion','all',84,144,27,34,42,52,62,70,77,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveExtraversion','all',144,216,25,32,40,50,60,68,75,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveExtraversion','all',216,1200,25,32,40,50,60,68,75,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('bigFiveAgreeableness','all',0,84,33,40,48,58,68,76,83,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveAgreeableness','all',84,144,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveAgreeableness','all',144,216,28,35,43,53,63,71,78,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveAgreeableness','all',216,1200,30,37,45,55,65,73,80,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('bigFiveNeuroticism','all',0,84,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveNeuroticism','all',84,144,23,30,38,48,58,66,73,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveNeuroticism','all',144,216,20,27,35,45,55,63,70,'心理常模'),\n" +
|
|
|
|
|
+ "('bigFiveNeuroticism','all',216,1200,30,37,45,55,65,73,80,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('emotionStability','all',0,84,17,24,32,42,52,60,67,'心理常模'),\n" +
|
|
|
|
|
+ "('emotionStability','all',84,144,27,34,42,52,62,70,77,'心理常模'),\n" +
|
|
|
|
|
+ "('emotionStability','all',144,216,33,40,48,58,68,76,83,'心理常模'),\n" +
|
|
|
|
|
+ "('emotionStability','all',216,1200,37,44,52,62,72,80,87,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('driveAutonomy','all',0,84,10,17,25,35,45,53,60,'心理常模'),\n" +
|
|
|
|
|
+ "('driveAutonomy','all',84,144,25,32,40,50,60,68,75,'心理常模'),\n" +
|
|
|
|
|
+ "('driveAutonomy','all',144,216,37,44,52,62,72,80,87,'心理常模'),\n" +
|
|
|
|
|
+ "('driveAutonomy','all',216,1200,43,50,58,68,78,86,93,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('driveCompetence','all',0,84,15,22,30,40,50,58,65,'心理常模'),\n" +
|
|
|
|
|
+ "('driveCompetence','all',84,144,27,34,42,52,62,70,77,'心理常模'),\n" +
|
|
|
|
|
+ "('driveCompetence','all',144,216,35,42,50,60,70,78,85,'心理常模'),\n" +
|
|
|
|
|
+ "('driveCompetence','all',216,1200,37,44,52,62,72,80,87,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('driveRelatedness','all',0,84,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('driveRelatedness','all',84,144,27,34,42,52,62,70,77,'心理常模'),\n" +
|
|
|
|
|
+ "('driveRelatedness','all',144,216,25,32,40,50,60,68,75,'心理常模'),\n" +
|
|
|
|
|
+ "('driveRelatedness','all',216,1200,30,37,45,55,65,73,80,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('selfConceptOverall','all',0,84,20,27,35,45,55,63,70,'心理常模'),\n" +
|
|
|
|
|
+ "('selfConceptOverall','all',84,144,30,37,45,55,65,73,80,'心理常模'),\n" +
|
|
|
|
|
+ "('selfConceptOverall','all',144,216,33,40,48,58,68,76,83,'心理常模'),\n" +
|
|
|
|
|
+ "('selfConceptOverall','all',216,1200,33,40,48,58,68,76,83,'心理常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionChildParentChild','all',0,84,35,42,50,60,70,78,85,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionChildParentChild','all',84,144,33,40,48,58,68,76,83,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionChildParentChild','all',144,216,30,37,45,55,65,73,80,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionSibling','all',0,84,20,27,35,45,55,63,70,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionSibling','all',84,144,25,32,40,50,60,68,75,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionSibling','all',144,216,30,37,45,55,65,73,80,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionRelative','all',0,84,25,32,40,50,60,68,75,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionRelative','all',84,144,30,37,45,55,65,73,80,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionRelative','all',144,216,33,40,48,58,68,76,83,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionTeacherStudent','all',0,84,25,32,40,50,60,68,75,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionTeacherStudent','all',84,144,35,42,50,60,70,78,85,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionTeacherStudent','all',144,216,37,44,52,62,72,80,87,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionChildSociality','all',0,84,23,30,38,48,58,66,73,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionChildSociality','all',84,144,30,37,45,55,65,73,80,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionChildSociality','all',144,216,35,42,50,60,70,78,85,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionChildInterpersonal','all',0,84,20,27,35,45,55,63,70,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionChildInterpersonal','all',84,144,27,34,42,52,62,70,77,'关系质量常模'),\n" +
|
|
|
|
|
+ "('actionChildInterpersonal','all',144,216,33,40,48,58,68,76,83,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionParentChild','all',216,1200,33,40,48,58,68,76,83,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionMarital','all',216,1200,30,37,45,55,65,73,80,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionParental','all',216,1200,27,34,42,52,62,70,77,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionLeadership','all',216,1200,30,37,45,55,65,73,80,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionSociality','all',216,1200,35,42,50,60,70,78,85,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('actionInterpersonal','all',216,1200,33,40,48,58,68,76,83,'关系质量常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('wealthSkill','all',0,84,10,17,25,35,45,53,60,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthSkill','all',84,144,20,27,35,45,55,63,70,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthSkill','all',144,216,30,37,45,55,65,73,80,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthSkill','all',216,1200,35,42,50,60,70,78,85,'财富素养常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('wealthAltruism','all',0,84,5,12,20,30,40,48,55,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthAltruism','all',84,144,15,22,30,40,50,58,65,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthAltruism','all',144,216,25,32,40,50,60,68,75,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthAltruism','all',216,1200,30,37,45,55,65,73,80,'财富素养常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('wealthIncome','all',0,84,0,7,15,25,35,43,50,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthIncome','all',84,144,10,17,25,35,45,53,60,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthIncome','all',144,216,20,27,35,45,55,63,70,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthIncome','all',216,1200,30,37,45,55,65,73,80,'财富素养常模')");
|
|
|
|
|
+
|
|
|
|
|
+sqls.add("INSERT IGNORE INTO health_norm_reference (dimension, gender, age_min, age_max, percentile_5, percentile_15, percentile_25, percentile_50, percentile_75, percentile_85, percentile_95, source) VALUES \n" +
|
|
|
|
|
+ "('wealthFx','all',0,84,0,2,10,20,30,38,45,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthFx','all',84,144,5,12,20,30,40,48,55,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthFx','all',144,216,15,22,30,40,50,58,65,'财富素养常模'),\n" +
|
|
|
|
|
+ "('wealthFx','all',216,1200,25,32,40,50,60,68,75,'财富素养常模')");
|
|
|
|
|
+ for (String sql : sqls) {
|
|
|
|
|
+ jdbcTemplate.execute(sql);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("mind/action/wealth 常模种子数据已加载 ({}条)", sqls.size());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("mind/action/wealth 常模种子数据初始化失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void modifyColumnToText(String table, String column, String comment) {
|
|
private void modifyColumnToText(String table, String column, String comment) {
|
|
|
if (!tableExists(table)) {
|
|
if (!tableExists(table)) {
|
|
|
return;
|
|
return;
|