ApplyLobsterExecutionConfig.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.ResultSet;
  4. import java.sql.Statement;
  5. /** Ensure lobster_execution_config exists and seed company 338 defaults. */
  6. public class ApplyLobsterExecutionConfig {
  7. private static final String URL = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/ylrz_saas"
  8. + "?useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true";
  9. private static final String USER = "root";
  10. private static final String PWD = "Ylrz_1q2w3e4r5t6y";
  11. private static final String DDL =
  12. "CREATE TABLE IF NOT EXISTS `lobster_execution_config` ("
  13. + "`id` bigint NOT NULL AUTO_INCREMENT,"
  14. + "`company_id` bigint NOT NULL,"
  15. + "`default_execution_mode` varchar(16) NOT NULL DEFAULT 'HYBRID',"
  16. + "`auto_start_instance_on_tag` tinyint NOT NULL DEFAULT 0,"
  17. + "`quality_gate_enabled` tinyint NOT NULL DEFAULT 1,"
  18. + "`quality_pass_score_percent` int NOT NULL DEFAULT 75,"
  19. + "`quality_target_score_percent` int NOT NULL DEFAULT 75,"
  20. + "`quality_min_node_score_percent` int NOT NULL DEFAULT 60,"
  21. + "`quality_min_e2e_avg_score_percent` int NOT NULL DEFAULT 75,"
  22. + "`quality_multiturn_min_avg_score_percent` int NOT NULL DEFAULT 45,"
  23. + "`message_dedup_enabled` tinyint NOT NULL DEFAULT 1,"
  24. + "`message_dedup_exact_window_size` int NOT NULL DEFAULT 5,"
  25. + "`message_dedup_semantic_threshold` decimal(4,2) NOT NULL DEFAULT 0.85,"
  26. + "`message_dedup_window_duration_seconds` int NOT NULL DEFAULT 300,"
  27. + "`create_by` varchar(64) DEFAULT NULL,"
  28. + "`create_time` datetime DEFAULT CURRENT_TIMESTAMP,"
  29. + "`update_by` varchar(64) DEFAULT NULL,"
  30. + "`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
  31. + "PRIMARY KEY (`id`),"
  32. + "UNIQUE KEY `uk_company_id` (`company_id`)"
  33. + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
  34. public static void main(String[] args) throws Exception {
  35. try (Connection c = DriverManager.getConnection(URL, USER, PWD);
  36. Statement st = c.createStatement()) {
  37. st.execute(DDL);
  38. st.execute("INSERT IGNORE INTO lobster_execution_config (company_id) VALUES (338)");
  39. try (ResultSet rs = st.executeQuery(
  40. "SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA='ylrz_saas'"
  41. + " AND TABLE_NAME='lobster_execution_config'")) {
  42. rs.next();
  43. System.out.println("lobster_execution_config exists: " + (rs.getInt(1) > 0));
  44. }
  45. try (ResultSet rs = st.executeQuery(
  46. "SELECT company_id FROM lobster_execution_config WHERE company_id=338")) {
  47. System.out.println("company 338 row: " + (rs.next() ? "OK" : "MISSING"));
  48. }
  49. }
  50. }
  51. }