src/main/java/com/se/simu/utils/CsvToSQLiteUtils.java
@@ -230,4 +230,31 @@
        }
    }
    public static Double getTotal(String tableName) {
        // 1. 创建SQLite数据库连接
        try (Connection conn = DriverManager.getConnection("jdbc:sqlite:rainfall.db")) {
            if (conn != null) {
                // 2. 执行SQL查询
                String queryDataSql = "select sum(rainfall_difference) as total from(SELECT ABS( (SELECT rainfall FROM " + tableName + " WHERE station_name = s.station_name ORDER BY datetime ASC LIMIT 1) - (SELECT rainfall FROM " + tableName + " WHERE station_name = s.station_name ORDER BY datetime DESC LIMIT 1)) AS rainfall_difference FROM " + tableName + " s GROUP BY station_name)";
                // 3. 处理查询结果
                try (PreparedStatement pstmt = conn.prepareStatement(queryDataSql)) {
                    ResultSet rs = pstmt.executeQuery();
                    while (rs.next()) {
                        // 获取总和
                        return rs.getDouble("total");
                    }
                } catch (SQLException e) {
                    System.err.println("查询数据时出错: " + e.getMessage());
                }
            }
        } catch (SQLException e) {
            System.err.println("SQLite连接失败: " + e.getMessage());
        }
        return null;
    }
    public static Integer getDuration(String tableName) {
        return 1440;
    }
}