Prechádzať zdrojové kódy

新增: 补充6月19日后请假结束无进出探针

1. 新增 tmp/prod_leave_after_0619_no_gate_probe.java,用于按学生筛选 2026-06-19 之后最新一条已结束请假且结束后没有任何进出记录的名单,并输出 RC、RCHKLA 头表与明细汇总。

2. 统一结束时间判断为 sysdate/date 口径,兼容 Oracle interval 与线上 RCHKLA 真实表结构差异,补充动态字段读取与非基础类型序列化处理,避免脚本运行时报错。

3. 验证:已执行 javac 编译与 java 运行,当前结果为 latestEndedLeaveStudentCount=107、noGateAfterLatestEndedLeaveStudentCount=7。
“gaohp” 5 mesiacov pred
rodič
commit
52e18b74fd
1 zmenil súbory, kde vykonal 177 pridanie a 0 odobranie
  1. 177 0
      tmp/prod_leave_after_0619_no_gate_probe.java

+ 177 - 0
tmp/prod_leave_after_0619_no_gate_probe.java

@@ -0,0 +1,177 @@
+import com.google.gson.Gson;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class prod_leave_after_0619_no_gate_probe {
+    private static final String JDBC_URL = "jdbc:oracle:thin:@192.168.69.26:31521/ORCLPDB";
+    private static final String JDBC_USER = "C##DC";
+    private static final String JDBC_PWD = "6bcb4bd7bbhbgz9cb44";
+    private static final Timestamp START_TIME = Timestamp.valueOf("2026-06-19 00:00:00");
+
+    public static void main(String[] args) throws Exception {
+        try (Connection conn = DriverManager.getConnection(JDBC_URL, JDBC_USER, JDBC_PWD)) {
+            Map<String, Object> root = new LinkedHashMap<>();
+            root.put("summary", loadSummary(conn));
+            root.put("studentList", loadNoGateStudentList(conn));
+            System.out.println(new Gson().toJson(root));
+        }
+    }
+
+    private static Map<String, Object> loadSummary(Connection conn) throws Exception {
+        Map<String, Object> row = new LinkedHashMap<>();
+        row.put("latestEndedLeaveStudentCount", queryLong(conn,
+                "with latest_leave as ("
+                        + " select rc.fzryid,rc.jssj,"
+                        + " row_number() over(partition by rc.fzryid order by rc.kssj desc, rc.rcid desc) rn"
+                        + " from rc rc"
+                        + " where rc.rclbm in(9,11)"
+                        + "   and rc.jlztm in(51,22,25)"
+                        + "   and rc.kssj>=?"
+                        + "   and cast(rc.jssj as date)<sysdate"
+                        + " )"
+                        + " select count(*) cnt from latest_leave where rn=1"));
+        row.put("noGateAfterLatestEndedLeaveStudentCount", queryLong(conn,
+                "with latest_leave as ("
+                        + " select rc.rcid,rc.fzryid,rc.kssj,rc.jssj,"
+                        + " row_number() over(partition by rc.fzryid order by rc.kssj desc, rc.rcid desc) rn"
+                        + " from rc rc"
+                        + " where rc.rclbm in(9,11)"
+                        + "   and rc.jlztm in(51,22,25)"
+                        + "   and rc.kssj>=?"
+                        + "   and cast(rc.jssj as date)<sysdate"
+                        + " )"
+                        + " select count(*) cnt"
+                        + " from latest_leave ll"
+                        + " where ll.rn=1"
+                        + "   and not exists (select 1 from jcjl jc where jc.ryid=ll.fzryid and jc.jlztm in(51,22,25) and jc.jcsj>ll.jssj)"));
+        return row;
+    }
+
+    private static List<Map<String, Object>> loadNoGateStudentList(Connection conn) throws Exception {
+        String sql = ""
+                + "with latest_leave as ("
+                + " select rc.rcid,rc.fzryid,rc.kssj,rc.jssj,rc.cjryid,rc.wcmswj,"
+                + " row_number() over(partition by rc.fzryid order by rc.kssj desc, rc.rcid desc) rn"
+                + " from rc rc"
+                + " where rc.rclbm in(9,11)"
+                + "   and rc.jlztm in(51,22,25)"
+                + "   and rc.kssj>=?"
+                + "   and cast(rc.jssj as date)<sysdate"
+                + " )"
+                + " select ll.rcid, ll.fzryid ryid, ll.kssj, ll.jssj, ll.cjryid, ll.wcmswj,"
+                + " ry.xm, ry.ryh, ry.jlztm ry_jlztm,"
+                + " nvl(bjcy.sfzs,-1) sfzs, nvl(bjcy.sfby,-1) sfby,"
+                + " round((sysdate - cast(ll.jssj as date)) * 24 * 60) gap_minutes"
+                + " from latest_leave ll"
+                + " join ry on ry.ryid=ll.fzryid"
+                + " left join bjcy on bjcy.ryid=ry.ryid and bjcy.sfby=0 and bjcy.jlztm in(51,22,25)"
+                + " where ll.rn=1"
+                + "   and not exists (select 1 from jcjl jc where jc.ryid=ll.fzryid and jc.jlztm in(51,22,25) and jc.jcsj>ll.jssj)"
+                + " order by ll.jssj desc, ll.rcid desc";
+        List<Map<String, Object>> out = new ArrayList<>();
+        try (PreparedStatement ps = conn.prepareStatement(sql)) {
+            ps.setTimestamp(1, START_TIME);
+            try (ResultSet rs = ps.executeQuery()) {
+                while (rs.next()) {
+                    Map<String, Object> row = new LinkedHashMap<>();
+                    long rcid = rs.getLong("rcid");
+                    long ryid = rs.getLong("ryid");
+                    row.put("rcid", rcid);
+                    row.put("ryid", ryid);
+                    row.put("xm", rs.getString("xm"));
+                    row.put("ryh", rs.getString("ryh"));
+                    row.put("sfzs", rs.getObject("sfzs"));
+                    row.put("sfby", rs.getObject("sfby"));
+                    row.put("leaveBeg", ts(rs.getTimestamp("kssj")));
+                    row.put("leaveEnd", ts(rs.getTimestamp("jssj")));
+                    row.put("gapMinutesSinceLeaveEnd", rs.getLong("gap_minutes"));
+                    row.put("creatorRyid", rs.getObject("cjryid"));
+                    row.put("wcmswjBrief", cut(rs.getString("wcmswj"), 400));
+                    row.put("rchkla", loadHeadState(conn, rcid));
+                    row.put("itemSummary", loadItemSummary(conn, rcid));
+                    out.add(row);
+                }
+            }
+        }
+        return out;
+    }
+
+    private static Map<String, Object> loadHeadState(Connection conn, long rcid) throws Exception {
+        return queryOneDynamic(conn, "select * from rchkla where rcid=?", rcid);
+    }
+
+    private static Map<String, Object> loadItemSummary(Connection conn, long rcid) throws Exception {
+        String sql = "select count(*) item_cnt,"
+                + " sum(case when delete_confirmed=1 then 1 else 0 end) delete_ok_cnt,"
+                + " sum(case when item_type='school_leave_auth' then 1 else 0 end) school_cnt,"
+                + " sum(case when item_type='dorm_return_auth' then 1 else 0 end) dorm_cnt"
+                + " from rchkla_item where rcid=?";
+        try (PreparedStatement ps = conn.prepareStatement(sql)) {
+            ps.setLong(1, rcid);
+            try (ResultSet rs = ps.executeQuery()) {
+                rs.next();
+                Map<String, Object> row = new LinkedHashMap<>();
+                row.put("itemCount", rs.getLong("item_cnt"));
+                row.put("deleteOkCount", rs.getLong("delete_ok_cnt"));
+                row.put("schoolCount", rs.getLong("school_cnt"));
+                row.put("dormCount", rs.getLong("dorm_cnt"));
+                return row;
+            }
+        }
+    }
+
+    private static long queryLong(Connection conn, String sql) throws Exception {
+        try (PreparedStatement ps = conn.prepareStatement(sql)) {
+            ps.setTimestamp(1, START_TIME);
+            try (ResultSet rs = ps.executeQuery()) {
+                rs.next();
+                return rs.getLong(1);
+            }
+        }
+    }
+
+    private static Map<String, Object> queryOneDynamic(Connection conn, String sql, long rcid) throws Exception {
+        try (PreparedStatement ps = conn.prepareStatement(sql)) {
+            ps.setLong(1, rcid);
+            try (ResultSet rs = ps.executeQuery()) {
+                if (!rs.next())
+                    return null;
+                ResultSetMetaData md = rs.getMetaData();
+                Map<String, Object> row = new LinkedHashMap<>();
+                for (int i = 1; i <= md.getColumnCount(); i++) {
+                    row.put(md.getColumnLabel(i), normalizeValue(rs.getObject(i)));
+                }
+                return row;
+            }
+        }
+    }
+
+    private static String ts(Timestamp ts) {
+        return ts == null ? null : ts.toString();
+    }
+
+    private static Object normalizeValue(Object val) {
+        if (val == null)
+            return null;
+        if (val instanceof Timestamp ts)
+            return ts(ts);
+        if (val instanceof Number || val instanceof Boolean || val instanceof String)
+            return val;
+        return cut(String.valueOf(val), 800);
+    }
+
+    private static String cut(String text, int maxLen) {
+        if (text == null)
+            return null;
+        return text.length() <= maxLen ? text : text.substring(0, maxLen);
+    }
+}