import java.io.*;
|
import java.nio.charset.StandardCharsets;
|
import java.sql.*;
|
|
public class Probe17 {
|
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("probe17.txt"), StandardCharsets.UTF_8))) {
|
run(c, out, "select config_key, config_value from sys_config where config_key='sys.authority.campus.all'");
|
run(c, out, "select d.dept_code, d.dept_name, d.campusid, count(*) dup from sys_dept d "
|
+ "inner join sys_user_dept ud on d.dept_code = ud.dept_code "
|
+ "where d.del_flag=0 and ud.del_flag=0 and d.orgid='20001001' and ud.orgid='20001001' "
|
+ "and ud.user_id=2609 and d.dept_type='2' group by d.dept_code, d.dept_name, d.campusid");
|
run(c, out, "select d.dept_code, d.dept_name, d.campusid from sys_dept d "
|
+ "inner join sys_user_dept ud on d.dept_code = ud.dept_code "
|
+ "where d.del_flag=0 and ud.del_flag=0 and d.orgid='20001001' and ud.orgid='20001001' "
|
+ "and d.campusid='30001002' and ud.user_id=2609 and d.dept_type='2' group by d.dept_code, d.dept_name, d.campusid");
|
run(c, out, "select leavehospitaldistrictcode, leavehospitaldistrictname, count(*) cnt from service_subtask "
|
+ "where del_flag='0' and service_type='2' and sendstate in (1,2,3,5,7) "
|
+ "and endtime>='2026-10-01' and endtime<'2026-11-01' and endtime <= DATE_SUB(CURDATE(), INTERVAL 7 DAY) "
|
+ "and leavehospitaldistrictcode in ('40003047','40003048') group by leavehospitaldistrictcode, leavehospitaldistrictname");
|
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 < 40) {
|
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());
|
}
|
}
|
}
|