import java.io.*;
|
import java.nio.charset.StandardCharsets;
|
import java.sql.*;
|
|
public class Probe18 {
|
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("probe18.txt"), StandardCharsets.UTF_8))) {
|
String base = "from service_subtask where del_flag='0' and service_type='2' and sendstate in (1,2,3,5,7) "
|
+ "and leavehospitaldistrictcode='40003047' and endtime>='2026-10-01' ";
|
run(c, out, "select "
|
+ "(select count(*) " + base + "and endtime <= DATE_SUB(CURDATE(), INTERVAL 7 DAY)) old_cut, "
|
+ "(select count(*) " + base + "and endtime < DATE_ADD(DATE_SUB(CURDATE(), INTERVAL 7 DAY), INTERVAL 1 DAY)) new_cut, "
|
+ "(select count(*) " + base + "and endtime >= '2026-10-21' and endtime < '2026-10-22') on_1021");
|
run(c, out, "select DATE(endtime) d, count(*) cnt " + base + "and endtime < DATE_ADD(DATE_SUB(CURDATE(), INTERVAL 7 DAY), INTERVAL 1 DAY) group by DATE(endtime) order by d desc limit 6");
|
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());
|
}
|
}
|
}
|