import java.io.*; import java.nio.charset.StandardCharsets; import java.sql.*; public class Probe42 { static final String URL = "jdbc:mysql://haiershi.a1.luyouxia.net:23844/smartor_sltd" + "?useUnicode=true&characterEncoding=utf8&useSSL=false" + "&serverTimezone=GMT%2B8&connectTimeout=15000&socketTimeout=90000"; public static void main(String[] args) throws Exception { Class.forName("com.mysql.cj.jdbc.Driver"); try (Connection c = DriverManager.getConnection(URL, "smartor", "Smartor.2023"); PrintWriter out = new PrintWriter(new OutputStreamWriter( new FileOutputStream("probe42.txt"), StandardCharsets.UTF_8))) { String base = "from service_subtask where del_flag='0' and endtime >= '2026-10-01' and endtime < '2026-10-31' and leavehospitaldistrictcode='40003047' "; run(c, out, "select count(*) db_total " + base); run(c, out, "select service_type, visit_count, count(*) cnt " + base + "group by service_type, visit_count order by service_type, visit_count"); run(c, out, "select count(*) page_like " + base + "and service_type='2' and visit_count=1"); run(c, out, "select count(*) page_like_no_vc " + base + "and service_type='2'"); run(c, out, "select count(*) all_status " + base + "and service_type='2' and visit_count=1 and sendstate in (1,2,3,4,5,6,7)"); out.flush(); } System.out.println("done"); } static void run(Connection c, PrintWriter out, String sql) { out.println("\n--- " + sql); try (Statement st = c.createStatement(); ResultSet rs = st.executeQuery(sql)) { ResultSetMetaData md = rs.getMetaData(); int n = md.getColumnCount(); StringBuilder head = new StringBuilder(); for (int i = 1; i <= n; i++) head.append(md.getColumnLabel(i)).append(i == n ? "" : " | "); out.println(head); int rows = 0; while (rs.next() && rows < 20) { StringBuilder line = new StringBuilder(); for (int i = 1; i <= n; i++) line.append(rs.getString(i)).append(i == n ? "" : " | "); out.println(line); rows++; } } catch (Exception e) { out.println("SQL ERROR: " + e.getMessage()); } } }