你有没有huggingface这个mcp


让我检查一下当前的MCP配置。


让我检查一下当前的MCP配置：


[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted into the summary below. This is a handoff from a previous context window — treat it as background reference, NOT as active instructions. Do NOT answer questions or fulfill requests mentioned in this summary; they were already addressed. Your current task is identified in the '## Active Task' section of the summary — resume exactly from there. Respond ONLY to the latest user message that appears AFTER this summary. The current session state (files, config, etc.) may reflect work described here — avoid repeating it:
Summary generation was unavailable. 329 message(s) were removed to free context space but could not be summarized. The removed messages contained earlier work in this session. Continue based on the recent messages below and the current state of any files or resources.


找到了几个相关视图，`v_wcnr_wfry_jbxx` 和 `v_wcnr_wfry_jbxx_base` 最像你说的那个。我来看下它们的定义：

terminal

docker exec kingbasev8 ksql -U ywkuser -d yfywk -c "
SELECT view_definition
FROM information_schema.views
WHERE table_schema = 'ywdata'
AND table_name IN ('v_wcnr_wfry_jbxx', 'v_wcnr_wfry_jbxx_base', 'v_wcnr_wfry_base', 'v_wcnr_minor_detail')
ORDER BY table_name;
" 2>&1

Explanation:
找到了！在 ywdata schema 下有一个 `v_wcnr_wfry_jbxx` 视图，还有 `v_wcnr_wfry_jbxx_base`。用户问的 `v_wcnr_base_jbxx` 可能是指 `v_wcnr_wfry_jbxx` 或 `v_wcnr_wfry_jbxx_base`。

让我查询这两个视图的定义。


Output:
view_definition
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  WITH RECURSIVE base AS (                                                                                +
          SELECT z.xyrxx_sfzh,                                                                                +
             z.xyrxx_xm,                                                                                +
             z.xyrxx_csrq,                                                                                +
             z.xyrxx_hjdxzqh,                                                                                +
             z.xyrxx_hjdxz,                                                                                +
             z.xyrxx_jzdxzqh,                                                                                +
             z.xyrxx_jzdz,                                                                                +
             z.ajxx_join_ajxx_ajbh,                                                                                +
             z.ajxx_join_ajxx_ajlx,                                                                                +
             z.ajxx_join_ajxx_ajmc,                                                                                +
             z.ajxx_join_ajxx_ay,                                                                                +
             z.ajxx_join_ajxx_cbdw_bh,                                                                                +
             z.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
             z.ajxx_join_ajxx_cbqy_bh,                                                                                +
             z.ajxx_join_ajxx_lasj,                                                                                +
             z.xyrxx_lrsj,                                                                                +
             a.ajxx_jyaq,                                                                                +
             a.ajxx_fadd                                                                                +
            FROM (ywdata.zq_zfba_xyrxx z                                                                                +
              JOIN ywdata.zq_zfba_ajxx a ON ((a.ajxx_ajbh = z.ajxx_join_ajxx_ajbh)))                                                                                +
           WHERE ((length(btrim(COALESCE(z.xyrxx_sfzh, NULL::text))) = 18) AND (z.xyrxx_sfzh IS NOT NULL) AND (btrim(z.xyrxx_sfzh) <> NULL::text) AND (btrim(COALESCE(z.ajxx_join_ajxx_ajbh, NULL::text)) <> NULL::text) AND (z.ajxx_join_ajxx_ajbh IS NOT NULL) AND (z.xyrxx_csrq IS NOT NULL))                                                                                +
         )                                                                                +
  SELECT b.xyrxx_sfzh AS id_card,                                                                                +
     b.xyrxx_xm AS person_name,                                                                                +
     b.xyrxx_csrq AS birth_date,                                                                                +
     ("date_part"('year'::text, age((CURRENT_DATE)::timestamp without time zone, b.xyrxx_csrq)))::integer AS current_age,                                                                                +
     ("date_part"('year'::text, age(b.xyrxx_lrsj, b.xyrxx_csrq)))::integer AS registered_age,                                                                                +
     ("date_part"('year'::text, age(b.ajxx_join_ajxx_lasj, b.xyrxx_csrq)))::integer AS case_age,                                                                                +
     b.xyrxx_hjdxzqh AS hkdz_region_code,                                                                                +
     b.xyrxx_hjdxz AS hkdz_address,                                                                                +
     b.xyrxx_jzdxzqh AS xzz_region_code,                                                                                +
     b.xyrxx_jzdz AS xzz_address,                                                                                +
     b.ajxx_join_ajxx_ajbh AS case_no,                                                                                +
     b.ajxx_join_ajxx_ajlx AS case_type,                                                                                +
     b.ajxx_join_ajxx_ajmc AS case_name,                                                                                +
     b.ajxx_join_ajxx_ay AS case_cause,                                                                                +
     b.ajxx_join_ajxx_cbdw_bh_dm AS cbdw_code,                                                                                +
     b.ajxx_join_ajxx_cbdw_bh AS cbdw_name,                                                                                +
     b.ajxx_join_ajxx_cbqy_bh AS cbdw_region_code,                                                                                +
     b.ajxx_jyaq AS case_summary,                                                                                +
     b.ajxx_fadd AS case_location,                                                                                +
     b.ajxx_join_ajxx_lasj AS case_time,

... [OUTPUT TRUNCATED - 197217 chars omitted out of 247217 total] ...

                                                      +
             v_1.xyrxx_xm,                                                                                +
             v_1.xyrxx_xb,                                                                                +
             v_1.xyrxx_lrsj,                                                                                +
             v_1.ajxx_join_ajxx_ajbh,                                                                                +
             v_1.ajxx_join_ajxx_lasj,                                                                                +
             v_1.ajxx_join_ajxx_ajlx,                                                                                +
             v_1.ajxx_join_ajxx_ajmc,                                                                                +
             v_1.ajxx_join_ajxx_ay,                                                                                +
             v_1.xyrxx_hjdxzqh,                                                                                +
             v_1.xyrxx_hjdxzqh_dm,                                                                                +
             v_1.xyrxx_hjdxz,                                                                                +
             v_1.xyrxx_xzdxz,                                                                                +
             v_1.ajxx_join_ajxx_cbdw_bh,                                                                                +
             v_1.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
             v_1.xyrxx_rybh,                                                                                +
             v_1.birthday                                                                                +
            FROM wf_validated v_1                                                                                +
           WHERE ((v_1.ajxx_join_ajxx_ajlx = '刑事'::text) AND (NOT (EXISTS ( SELECT 1                                                                                +
                    FROM ywdata.zq_zfba_byxzcfjds bxf                                                                                +
                   WHERE ((bxf.ajxx_ajbh = v_1.ajxx_join_ajxx_ajbh) AND (bxf.byxzcfjds_rybh = v_1.xyrxx_rybh) AND (bxf.byxzcfjds_cbryj ~ '违法事实不能成立'::text))))) AND (NOT (EXISTS ( SELECT 1                                                                                +
                    FROM ywdata.zq_zfba_wenshu ws                                                                                +
                   WHERE ((ws.ajbh = v_1.ajxx_join_ajxx_ajbh) AND (ws.xgry_xm = v_1.xyrxx_xm) AND (ws.wsmc ~ '终止侦查决定书'::text))))))                                                                                +
         UNION ALL                                                                                +
          SELECT v_1.xyrxx_sfzh,                                                                                +
             v_1.xyrxx_xm,                                                                                +
             v_1.xyrxx_xb,                                                                                +
             v_1.xyrxx_lrsj,                                                                                +
             v_1.ajxx_join_ajxx_ajbh,                                                                                +
             v_1.ajxx_join_ajxx_lasj,                                                                                +
             v_1.ajxx_join_ajxx_ajlx,                                                                                +
             v_1.ajxx_join_ajxx_ajmc,                                                                                +
             v_1.ajxx_join_ajxx_ay,                                                                                +
             v_1.xyrxx_hjdxzqh,                                                                                +
             v_1.xyrxx_hjdxzqh_dm,                                                                                +
             v_1.xyrxx_hjdxz,                                                                                +
             v_1.xyrxx_xzdxz,                                                                                +
             v_1.ajxx_join_ajxx_cbdw_bh,                                                                                +
             v_1.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
             v_1.xyrxx_rybh,                                                                                +
             v_1.birthday                                                                                +
            FROM (wf_validated v_1                                                                                +
              JOIN xz_keys k ON (((k.ajbh = v_1.ajxx_join_ajxx_ajbh) AND (k.rybh = v_1.xyrxx_rybh))))                                                                                +
           WHERE (v_1.ajxx_join_ajxx_ajlx = '行政'::text)                                                                                +
         )                                                                                +
  SELECT v.xyrxx_sfzh,                                                                                +
     v.xyrxx_xm,                                                                                +
     v.xyrxx_xb,                                                                                +
     v.xyrxx_lrsj,                                                                                +
     v.ajxx_join_ajxx_ajbh,                                                                                +
     v.ajxx_join_ajxx_lasj,                                                                                +
     v.ajxx_join_ajxx_ajlx,                                                                                +
     v.ajxx_join_ajxx_ajmc,                                                                                +
     v.ajxx_join_ajxx_ay,                                                                                +
     v.xyrxx_hjdxzqh,                                                                                +
     v.xyrxx_hjdxzqh_dm,                                                                                +
     v.xyrxx_hjdxz,                                                                                +
     v.xyrxx_xzdxz,                                                                                +
     v.ajxx_join_ajxx_cbdw_bh,                                                                                +
     v.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
     v.xyrxx_rybh,                                                                                +
     v.birthday,                                                                                +
     aj.ajxx_fasj,                                                                                +
     ("date_part"('year'::text, age(((aj.ajxx_fasj)::date)::timestamp without time zone, (v.birthday)::timestamp without time zone)))::integer AS fasj_age,                                                                                +
     ("date_part"('year'::text, age((CURRENT_DATE)::timestamp without time zone, (v.birthday)::timestamp without time zone)))::integer AS current_age                                                                                +
    FROM (wf_xz_filtered v                                                                                +
      JOIN ywdata.zq_zfba_ajxx aj ON ((v.ajxx_join_ajxx_ajbh = aj.ajxx_ajbh)))                                                                                +
   WHERE (("date_part"('year'::text, age(v.xyrxx_lrsj, (v.birthday)::timestamp without time zone)) < (18)::double precision) AND (v.ajxx_join_ajxx_ajbh <> ALL (ARRAY['A4453021205002025126001'::text, 'A4453816302002026026010'::text])) AND (v.xyrxx_rybh <> ALL (ARRAY['R4453021205002026023007'::text, 'R4453816302002026023012'::text])) AND (v.xyrxx_sfzh <> '445381200802232178'::text));
(4 rows)


输出被截断了，让我用文件方式获取完整定义。

docker exec kingbasev8 ksql -U ywkuser -d yfywk -c "
SELECT view_definition
FROM information_schema.views
WHERE table_schema = 'ywdata'
AND table_name IN ('v_wcnr_wfry_jbxx', 'v_wcnr_wfry_jbxx_base', 'v_wcnr_wfry_base', 'v_wcnr_minor_detail')
ORDER BY table_name;
" 2>&1 > /tmp/view_defs.txt
wc -l /tmp/view_defs.txt

Explanation: The output is truncated, but I can see there are 4 view definitions returned. Let me get the full text of each view by exporting them to a file.


Output: 557 /tmp/view_defs.txt


grep -n "table_name\|^  WITH\|^  SELECT\|^CREATE\|^--" /tmp/view_defs.txt | head -30

Explanation: Let me read the file to see the view definitions. There are 4 views returned but the output was truncated. Let me read the file directly


Output:
2:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3:  WITH RECURSIVE base AS (                                                                                +
26:  SELECT b.xyrxx_sfzh AS id_card,                                                                                +
49:  WITH RECURSIVE base AS (                                                                                +
265:  SELECT DISTINCT b.ajxx_join_ajxx_ajbh AS "案件编号",                                                                                +
288:  WITH RECURSIVE wf_validated AS MATERIALIZED (                                                                                +
422:  SELECT c.xyrxx_xm AS "姓名",                                                                                +
458:  WITH RECURSIVE wf_validated AS MATERIALIZED (                                                                                +
533:  SELECT v.xyrxx_sfzh,                                                                                +


# 分别获取每个视图的定义
for view in v_wcnr_wfry_jbxx v_wcnr_wfry_jbxx_base v_wcnr_wfry_base v_wcnr_minor_detail; do
  docker exec kingbasev8 ksql -U ywkuser -d yfywk -c "
    SELECT view_definition
    FROM information_schema.views
    WHERE table_schema = 'ywdata' AND table_name = '${view}';
  " 2>/dev/null > /tmp/${view}.txt
  echo "=== ${view} ==="
  wc -l /tmp/${view}.txt
done

Explanation: The output is truncated and messy. Let me extract each view definition separately to a file, then read it properly


Output:
=== v_wcnr_wfry_jbxx ===
174 /tmp/v_wcnr_wfry_jbxx.txt
=== v_wcnr_wfry_jbxx_base ===
102 /tmp/v_wcnr_wfry_jbxx_base.txt
=== v_wcnr_wfry_base ===
243 /tmp/v_wcnr_wfry_base.txt
=== v_wcnr_minor_detail ===
50 /tmp/v_wcnr_minor_detail.txt


Explanation:
好的，现在我已经把4个视图的定义分开了。`v_wcnr_wfry_base` 有243行，是最大的；`v_wcnr_wfry_jbxx` 有174行；`v_wcnr_wfry_jbxx_base` 有102行。让我看看 `v_wcnr_wfry_base` 的完整定义，因为它看起来是基础视图，可能包含了 `v_wcnr_wfry_jbxx` 的逻辑。

不过等一下，用户之前提到的是 `v_wcnr_base_jbxx`，但我看到的是 `v_wcnr_wfry_base` 和 `v_wcnr_wfry_jbxx`。可能是用户记错了名字，或者 `v_wcnr_wfry_base` 就是用户说的那个视图。

让我读取 `v_wcnr_wfry_base` 的完整定义来分析


     1|                                                                                view_definition
     2|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     3|  WITH RECURSIVE base AS (                                                                                +
     4|          SELECT zq_zfba_wcnr_xyr.ajxx_ajbhs,                                                                                +
     5|             zq_zfba_wcnr_xyr.xyrxx_sfzh,                                                                                +
     6|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_ajbh,                                                                                +
     7|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_ajlx,                                                                                +
     8|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_ajlx_dm,                                                                                +
     9|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_ajmc,                                                                                +
    10|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_ay,                                                                                +
    11|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_ay_dm,                                                                                +
    12|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_cbdw_bh,                                                                                +
    13|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    14|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_cbqy_bh,                                                                                +
    15|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_cbqy_bh_dm,                                                                                +
    16|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_cbqy_jc,                                                                                +
    17|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_isdel,                                                                                +
    18|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_isdel_dm,                                                                                +
    19|             zq_zfba_wcnr_xyr.ajxx_join_ajxx_lasj,                                                                                +
    20|             zq_zfba_wcnr_xyr.xyrxx_ay_bh,                                                                                +
    21|             zq_zfba_wcnr_xyr.xyrxx_ay_bh_dm,                                                                                +
    22|             zq_zfba_wcnr_xyr.xyrxx_ay_mc,                                                                                +
    23|             zq_zfba_wcnr_xyr.xyrxx_bh,                                                                                +
    24|             zq_zfba_wcnr_xyr.xyrxx_bz,                                                                                +
    25|             zq_zfba_wcnr_xyr.xyrxx_bzdzk,                                                                                +
    26|             zq_zfba_wcnr_xyr.xyrxx_c_cssj,                                                                                +
    27|             zq_zfba_wcnr_xyr.xyrxx_cbdw_bh,                                                                                +
    28|             zq_zfba_wcnr_xyr.xyrxx_cbdw_bh_dm,                                                                                +
    29|             zq_zfba_wcnr_xyr.xyrxx_cbqy_bh,                                                                                +
    30|             zq_zfba_wcnr_xyr.xyrxx_cbqy_bh_dm,                                                                                +
    31|             zq_zfba_wcnr_xyr.xyrxx_ch,                                                                                +
    32|             zq_zfba_wcnr_xyr.xyrxx_crj_zjhm,                                                                                +
    33|             zq_zfba_wcnr_xyr.xyrxx_crj_zjlx,                                                                                +
    34|             zq_zfba_wcnr_xyr.xyrxx_crj_zjlx_dm,                                                                                +
    35|             zq_zfba_wcnr_xyr.xyrxx_cskssj,                                                                                +
    36|             zq_zfba_wcnr_xyr.xyrxx_csrq,                                                                                +
    37|             zq_zfba_wcnr_xyr.xyrxx_cym,                                                                                +
    38|             zq_zfba_wcnr_xyr.xyrxx_dataversion,                                                                                +
    39|             zq_zfba_wcnr_xyr.xyrxx_dlr,                                                                                +
    40|             zq_zfba_wcnr_xyr.xyrxx_dlrdh,                                                                                +
    41|             zq_zfba_wcnr_xyr.xyrxx_dna,                                                                                +
    42|             zq_zfba_wcnr_xyr.xyrxx_dwry,                                                                                +
    43|             zq_zfba_wcnr_xyr.xyrxx_fzjl,                                                                                +
    44|             zq_zfba_wcnr_xyr.xyrxx_gasj,                                                                                +
    45|             zq_zfba_wcnr_xyr.xyrxx_gatsf,                                                                                +
    46|             zq_zfba_wcnr_xyr.xyrxx_gatsf_dm,                                                                                +
    47|             zq_zfba_wcnr_xyr.xyrxx_gcbh,                                                                                +
    48|             zq_zfba_wcnr_xyr.xyrxx_gj,                                                                                +
    49|             zq_zfba_wcnr_xyr.xyrxx_gj_dm,                                                                                +
    50|             zq_zfba_wcnr_xyr.xyrxx_gjgzry,                                                                                +
    51|             zq_zfba_wcnr_xyr.xyrxx_gjgzry_dm,                                                                                +
    52|             zq_zfba_wcnr_xyr.xyrxx_grxg,                                                                                +
    53|             zq_zfba_wcnr_xyr.xyrxx_gzdw,                                                                                +
    54|             zq_zfba_wcnr_xyr.xyrxx_gzry,                                                                                +
    55|             zq_zfba_wcnr_xyr.xyrxx_gzry_dm,                                                                                +
    56|             zq_zfba_wcnr_xyr.xyrxx_hjd,                                                                                +
    57|             zq_zfba_wcnr_xyr.xyrxx_hjdxz,                                                                                +
    58|             zq_zfba_wcnr_xyr.xyrxx_hjdxz_x,                                                                                +
    59|             zq_zfba_wcnr_xyr.xyrxx_hjdxz_y,                                                                                +
    60|             zq_zfba_wcnr_xyr.xyrxx_hjdxzqh,                                                                                +
    61|             zq_zfba_wcnr_xyr.xyrxx_hjdxzqh_dm,                                                                                +
    62|             zq_zfba_wcnr_xyr.xyrxx_hyzk,                                                                                +
    63|             zq_zfba_wcnr_xyr.xyrxx_hyzk_dm,                                                                                +
    64|             zq_zfba_wcnr_xyr.xyrxx_id,                                                                                +
    65|             zq_zfba_wcnr_xyr.xyrxx_isdel,                                                                                +
    66|             zq_zfba_wcnr_xyr.xyrxx_isdel_dm,                                                                                +
    67|             zq_zfba_wcnr_xyr.xyrxx_isfc,                                                                                +
    68|             zq_zfba_wcnr_xyr.xyrxx_isfc_dm,                                                                                +
    69|             zq_zfba_wcnr_xyr.xyrxx_isgzry,                                                                                +
    70|             zq_zfba_wcnr_xyr.xyrxx_isgzry_dm,                                                                                +
    71|             zq_zfba_wcnr_xyr.xyrxx_isxg,                                                                                +
    72|             zq_zfba_wcnr_xyr.xyrxx_isxg_dm,                                                                                +
    73|             zq_zfba_wcnr_xyr.xyrxx_jg,                                                                                +
    74|             zq_zfba_wcnr_xyr.xyrxx_jg_dm,                                                                                +
    75|             zq_zfba_wcnr_xyr.xyrxx_jtzk,                                                                                +
    76|             zq_zfba_wcnr_xyr.xyrxx_jzdxzqh,                                                                                +
    77|             zq_zfba_wcnr_xyr.xyrxx_jzdxzqh_dm,                                                                                +
    78|             zq_zfba_wcnr_xyr.xyrxx_jzdz,                                                                                +
    79|             zq_zfba_wcnr_xyr.xyrxx_ky,                                                                                +
    80|             zq_zfba_wcnr_xyr.xyrxx_lrr_sfzh,                                                                                +
    81|             zq_zfba_wcnr_xyr.xyrxx_lrsj,                                                                                +
    82|             zq_zfba_wcnr_xyr.xyrxx_lxfs,                                                                                +
    83|             zq_zfba_wcnr_xyr.xyrxx_mgry,                                                                                +
    84|             zq_zfba_wcnr_xyr.xyrxx_mgry_dm,                                                                                +
    85|             zq_zfba_wcnr_xyr.xyrxx_mgrylx,                                                                                +
    86|             zq_zfba_wcnr_xyr.xyrxx_mgrylx_dm,                                                                                +
    87|             zq_zfba_wcnr_xyr.xyrxx_mz,                                                                                +
    88|             zq_zfba_wcnr_xyr.xyrxx_mz_dm,                                                                                +
    89|             zq_zfba_wcnr_xyr.xyrxx_nl,                                                                                +
    90|             zq_zfba_wcnr_xyr.xyrxx_nlsx,                                                                                +
    91|             zq_zfba_wcnr_xyr.xyrxx_qkqk,                                                                                +
    92|             zq_zfba_wcnr_xyr.xyrxx_qq,                                                                                +
    93|             zq_zfba_wcnr_xyr.xyrxx_qtlxfs,                                                                                +
    94|             zq_zfba_wcnr_xyr.xyrxx_qtzjhm1,                                                                                +
    95|             zq_zfba_wcnr_xyr.xyrxx_qtzjhm2,                                                                                +
    96|             zq_zfba_wcnr_xyr.xyrxx_qtzjhm3,                                                                                +
    97|             zq_zfba_wcnr_xyr.xyrxx_qtzjlx1,                                                                                +
    98|             zq_zfba_wcnr_xyr.xyrxx_qtzjlx1_dm,                                                                                +
    99|             zq_zfba_wcnr_xyr.xyrxx_qtzjlx2,                                                                                +
   100|             zq_zfba_wcnr_xyr.xyrxx_qtzjlx2_dm,                                                                                +
   101|             zq_zfba_wcnr_xyr.xyrxx_qtzjlx3,                                                                                +
   102|             zq_zfba_wcnr_xyr.xyrxx_qtzjlx3_dm,                                                                                +
   103|             zq_zfba_wcnr_xyr.xyrxx_qzcs,                                                                                +
   104|             zq_zfba_wcnr_xyr.xyrxx_qzcsjssj,                                                                                +
   105|             zq_zfba_wcnr_xyr.xyrxx_qzcskssj,                                                                                +
   106|             zq_zfba_wcnr_xyr.xyrxx_r_rssj,                                                                                +
   107|             zq_zfba_wcnr_xyr.xyrxx_rddb,                                                                                +
   108|             zq_zfba_wcnr_xyr.xyrxx_rddb_dm,                                                                                +
   109|             zq_zfba_wcnr_xyr.xyrxx_rdjb,                                                                                +
   110|             zq_zfba_wcnr_xyr.xyrxx_rdjb_dm,                                                                                +
   111|             zq_zfba_wcnr_xyr.xyrxx_rdsj,                                                                                +
   112|             zq_zfba_wcnr_xyr.xyrxx_rybh,                                                                                +
   113|             zq_zfba_wcnr_xyr.xyrxx_ryzt,                                                                                +
   114|             zq_zfba_wcnr_xyr.xyrxx_ryzt_dm,                                                                                +
   115|             zq_zfba_wcnr_xyr.xyrxx_scspzt,                                                                                +
   116|             zq_zfba_wcnr_xyr.xyrxx_scspzt_dm,                                                                                +
   117|             zq_zfba_wcnr_xyr.xyrxx_sf,                                                                                +
   118|             zq_zfba_wcnr_xyr.xyrxx_sf_dm,                                                                                +
   119|             zq_zfba_wcnr_xyr.xyrxx_sfbk,                                                                                +
   120|             zq_zfba_wcnr_xyr.xyrxx_sfbk_dm,                                                                                +
   121|             zq_zfba_wcnr_xyr.xyrxx_sfbmsf,                                                                                +
   122|             zq_zfba_wcnr_xyr.xyrxx_sfbmsf_dm,                                                                                +
   123|             zq_zfba_wcnr_xyr.xyrxx_sfda,                                                                                +
   124|             zq_zfba_wcnr_xyr.xyrxx_sfda_dm,                                                                                +
   125|             zq_zfba_wcnr_xyr.xyrxx_sfdy,                                                                                +
   126|             zq_zfba_wcnr_xyr.xyrxx_sfdy_dm,                                                                                +
   127|             zq_zfba_wcnr_xyr.xyrxx_sfga,                                                                                +
   128|             zq_zfba_wcnr_xyr.xyrxx_sfga_dm,                                                                                +
   129|             zq_zfba_wcnr_xyr.xyrxx_sfgatjm,                                                                                +
   130|             zq_zfba_wcnr_xyr.xyrxx_sfgatjm_dm,                                                                                +
   131|             zq_zfba_wcnr_xyr.xyrxx_sflar,                                                                                +
   132|             zq_zfba_wcnr_xyr.xyrxx_sflar_dm,                                                                                +
   133|             zq_zfba_wcnr_xyr.xyrxx_sftb,                                                                                +
   134|             zq_zfba_wcnr_xyr.xyrxx_sftb_dm,                                                                                +
   135|             zq_zfba_wcnr_xyr.xyrxx_sftsqt,                                                                                +
   136|             zq_zfba_wcnr_xyr.xyrxx_sftsqt_dm,                                                                                +
   137|             zq_zfba_wcnr_xyr.xyrxx_sfxd,                                                                                +
   138|             zq_zfba_wcnr_xyr.xyrxx_sfxd_dm,                                                                                +
   139|             zq_zfba_wcnr_xyr.xyrxx_sfythcj,                                                                                +
   140|             zq_zfba_wcnr_xyr.xyrxx_sfythcj_dm,                                                                                +
   141|             zq_zfba_wcnr_xyr.xyrxx_sfzbm,                                                                                +
   142|             zq_zfba_wcnr_xyr.xyrxx_sfzbm_dm,                                                                                +
   143|             zq_zfba_wcnr_xyr.xyrxx_sg,                                                                                +
   144|             zq_zfba_wcnr_xyr.xyrxx_shgx,                                                                                +
   145|             zq_zfba_wcnr_xyr.xyrxx_szdzb,                                                                                +
   146|             zq_zfba_wcnr_xyr.xyrxx_szssrd,                                                                                +
   147|             zq_zfba_wcnr_xyr.xyrxx_szsszx,                                                                                +
   148|             zq_zfba_wcnr_xyr.xyrxx_tbbj,                                                                                +
   149|             zq_zfba_wcnr_xyr.xyrxx_tbsj,                                                                                +
   150|             zq_zfba_wcnr_xyr.xyrxx_tmtz,                                                                                +
   151|             zq_zfba_wcnr_xyr.xyrxx_tsqt,                                                                                +
   152|             zq_zfba_wcnr_xyr.xyrxx_tsqt_dm,                                                                                +
   153|             zq_zfba_wcnr_xyr.xyrxx_tx,                                                                                +
   154|             zq_zfba_wcnr_xyr.xyrxx_tx_dm,                                                                                +
   155|             zq_zfba_wcnr_xyr.xyrxx_wfss,                                                                                +
   156|             zq_zfba_wcnr_xyr.xyrxx_whcd,                                                                                +
   157|             zq_zfba_wcnr_xyr.xyrxx_whcd_dm,                                                                                +
   158|             zq_zfba_wcnr_xyr.xyrxx_wx,                                                                                +
   159|             zq_zfba_wcnr_xyr.xyrxx_xb,                                                                                +
   160|             zq_zfba_wcnr_xyr.xyrxx_xb_dm,                                                                                +
   161|             zq_zfba_wcnr_xyr.xyrxx_xdjyjg,                                                                                +
   162|             zq_zfba_wcnr_xyr.xyrxx_xdjyjg_dm,                                                                                +
   163|             zq_zfba_wcnr_xyr.xyrxx_xgr_sfzh,                                                                                +
   164|             zq_zfba_wcnr_xyr.xyrxx_xgsj,                                                                                +
   165|             zq_zfba_wcnr_xyr.xyrxx_xm,                                                                                +
   166|             zq_zfba_wcnr_xyr.xyrxx_xx,                                                                                +
   167|             zq_zfba_wcnr_xyr.xyrxx_xx_dm,                                                                                +
   168|             zq_zfba_wcnr_xyr.xyrxx_xyr_nl,                                                                                +
   169|             zq_zfba_wcnr_xyr.xyrxx_xzd,                                                                                +
   170|             zq_zfba_wcnr_xyr.xyrxx_xzdxz,                                                                                +
   171|             zq_zfba_wcnr_xyr.xyrxx_xzdxz_x,                                                                                +
   172|             zq_zfba_wcnr_xyr.xyrxx_xzdxz_y,                                                                                +
   173|             zq_zfba_wcnr_xyr.xyrxx_xzq,                                                                                +
   174|             zq_zfba_wcnr_xyr.xyrxx_xzqdm,                                                                                +
   175|             zq_zfba_wcnr_xyr.xyrxx_ywjsxx,                                                                                +
   176|             zq_zfba_wcnr_xyr.xyrxx_ywjsxx_dm,                                                                                +
   177|             zq_zfba_wcnr_xyr.xyrxx_ywm,                                                                                +
   178|             zq_zfba_wcnr_xyr.xyrxx_ywx,                                                                                +
   179|             zq_zfba_wcnr_xyr.xyrxx_yxzh,                                                                                +
   180|             zq_zfba_wcnr_xyr.xyrxx_zagj,                                                                                +
   181|             zq_zfba_wcnr_xyr.xyrxx_zagj_dm,                                                                                +
   182|             zq_zfba_wcnr_xyr.xyrxx_zatd,                                                                                +
   183|             zq_zfba_wcnr_xyr.xyrxx_zatd_dm,                                                                                +
   184|             zq_zfba_wcnr_xyr.xyrxx_zc,                                                                                +
   185|             zq_zfba_wcnr_xyr.xyrxx_zfzh,                                                                                +
   186|             zq_zfba_wcnr_xyr.xyrxx_zhdd,                                                                                +
   187|             zq_zfba_wcnr_xyr.xyrxx_zhjg,                                                                                +
   188|             zq_zfba_wcnr_xyr.xyrxx_zhr,                                                                                +
   189|             zq_zfba_wcnr_xyr.xyrxx_zhsj,                                                                                +
   190|             zq_zfba_wcnr_xyr.xyrxx_zhxzb,                                                                                +
   191|             zq_zfba_wcnr_xyr.xyrxx_zhyzb,                                                                                +
   192|             zq_zfba_wcnr_xyr.xyrxx_zm,                                                                                +
   193|             zq_zfba_wcnr_xyr.xyrxx_zmbh,                                                                                +
   194|             zq_zfba_wcnr_xyr.xyrxx_zmbh_dm,                                                                                +
   195|             zq_zfba_wcnr_xyr.xyrxx_zpid,                                                                                +
   196|             zq_zfba_wcnr_xyr.xyrxx_zszt,                                                                                +
   197|             zq_zfba_wcnr_xyr.xyrxx_zw,                                                                                +
   198|             zq_zfba_wcnr_xyr.xyrxx_zwxx,                                                                                +
   199|             zq_zfba_wcnr_xyr.xyrxx_zxjb,                                                                                +
   200|             zq_zfba_wcnr_xyr.xyrxx_zxjb_dm,                                                                                +
   201|             zq_zfba_wcnr_xyr.xyrxx_zxwy,                                                                                +
   202|             zq_zfba_wcnr_xyr.xyrxx_zxwy_dm,                                                                                +
   203|             zq_zfba_wcnr_xyr.xyrxx_zy,                                                                                +
   204|             zq_zfba_wcnr_xyr.xyrxx_zy_dm,                                                                                +
   205|             zq_zfba_wcnr_xyr.xyrxx_zylb,                                                                                +
   206|             zq_zfba_wcnr_xyr.xyrxx_zzmm,                                                                                +
   207|             zq_zfba_wcnr_xyr.xyrxx_zzmm_dm                                                                                +
   208|            FROM ywdata.zq_zfba_wcnr_xyr                                                                                +
   209|           WHERE (((zq_zfba_wcnr_xyr.ajxx_join_ajxx_isdel_dm)::integer = 0) AND ((zq_zfba_wcnr_xyr.xyrxx_isdel_dm)::integer = 0) AND ((zq_zfba_wcnr_xyr.xyrxx_sfda_dm)::integer = 1))+
   210|         ), xz_cfjds AS (                                                                                +
   211|          SELECT zq_zfba_xzcfjds.ajxx_ajbh,                                                                                +
   212|             zq_zfba_xzcfjds.xzcfjds_rybh AS rybh                                                                                +
   213|            FROM ywdata.zq_zfba_xzcfjds                                                                                +
   214|         UNION                                                                                +
   215|          SELECT zq_zfba_byxzcfjds.ajxx_ajbh,                                                                                +
   216|             zq_zfba_byxzcfjds.byxzcfjds_rybh AS rybh                                                                                +
   217|            FROM ywdata.zq_zfba_byxzcfjds                                                                                +
   218|         )                                                                                +
   219|  SELECT DISTINCT b.ajxx_join_ajxx_ajbh AS "案件编号",                                                                                +
   220|     b.ajxx_join_ajxx_ajlx AS "案件类型",                                                                                +
   221|     b.ajxx_join_ajxx_ay AS "案由",                                                                                +
   222|     b.ajxx_join_ajxx_ay_dm AS "案由代码",                                                                                +
   223|     "left"(b.ajxx_join_ajxx_cbqy_bh_dm, 6) AS "地区",                                                                                +
   224|     b.ajxx_join_ajxx_cbdw_bh AS "办案单位",                                                                                +
   225|     b.ajxx_join_ajxx_lasj AS "立案时间",                                                                                +
   226|     b.xyrxx_xm AS "姓名",                                                                                +
   227|     b.xyrxx_sfzh AS "身份证号",                                                                                +
   228|     b.xyrxx_rybh AS "人员编号",                                                                                +
   229|     b.xyrxx_hjdxz AS "户籍地",                                                                                +
   230|     b.xyrxx_nl AS "年龄",                                                                                +
   231|     b.xyrxx_isdel AS "是否删除",                                                                                +
   232|     b.xyrxx_jzdxzqh AS "居住地",                                                                                +
   233|     b.xyrxx_lrsj AS "录入时间",                                                                                +
   234|     xj.xxmc AS "学校名称",                                                                                +
   235|     xj.njmc AS "年级",                                                                                +
   236|     xj.bjmc AS "班级",                                                                                +
   237|     xj.jdzt AS "就读状态"                                                                                +
   238|    FROM ((base b                                                                                +
   239|      LEFT JOIN xz_cfjds xzm ON (((b.ajxx_join_ajxx_ajlx = '行政'::text) AND (xzm.ajxx_ajbh = b.ajxx_join_ajxx_ajbh) AND (xzm.rybh = b.xyrxx_rybh))))                                +
   240|      LEFT JOIN ywdata.sh_gd_zxxxsxj_xx xj ON (((xj.sfzjh)::text = b.xyrxx_sfzh)))                                                                                +
   241|   WHERE ((b.ajxx_join_ajxx_ajlx = '刑事'::text) OR ((b.ajxx_join_ajxx_ajlx = '行政'::text) AND (xzm.ajxx_ajbh IS NOT NULL)));
   242|(1 row)
   243|
   244|


找到了，是 `v_wcnr_wfry_base`，来自 `ywdata.zq_zfba_wcnr_xyr` 表。让我看看其他几个相关视图。

Explanation:
Now I have the full view definition for `v_wcnr_wfry_base`. Let me understand the logic:

**Table source**: `ywdata.zq_zfba_wcnr_xyr` (not `zq_zfba_xyrxx` that we used before)

**Filters on base CTE**:
- `ajxx_join_ajxx_isdel_dm = 0` (case not deleted)
- `xyrxx_isdel_dm = 0` (person not deleted)
- `xyrxx_sfda_dm = 1` (身份状态? 身份档案? = 1)

**CTEs**:
- `base` - main person+case data from `zq_zfba_wcnr_xyr`
- `xz_cfjds` - UNION of administrative penalty decision books + non-administrative penalty decision books (ajbh + rybh)

**Final WHERE**:
- Criminal cases: `ajlx = '刑事'` (all criminal cases)
- Administrative cases: `ajlx = '行政'` AND exists in `xz_cfjds` (has penalty decision)

**Output fields**:
- 案件编号, 案件类型, 案由, 案由代码
- 地区 (left(cbqy_bh_dm, 6))
- 办案单位 (cbdw_bh)
- 立案时间
- 姓名, 身份证号, 人员编号
- 户籍地, 年龄 (xyrxx_nl), 居住地, 录入时间
- 学校名称, 年级, 班级, 就读状态 (from school table)

**Key differences from our v_wcnr_minor_detail**:
1. Uses `zq_zfba_wcnr_xyr` table (not `zq_zfba_xyrxx`)
2. Has deletion filters (`isdel_dm = 0`)
3. Has `sfda_dm = 1` filter
4. Joins with school info (`sh_gd_zxxxsxj_xx`)
5. Uses `xyrxx_nl` (existing age field) not calculated age
6. Filters: criminal cases all included, admin cases only if they have penalty decisions
7. Uses `xz_cfjds` CTE for admin case filtering

Now let me get the other views too to give a complete picture.


     1|                                                                                view_definition
     2|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     3|  WITH RECURSIVE wf_validated AS MATERIALIZED (                                                                                +
     4|          SELECT zq_zfba_xyrxx.xyrxx_sfzh,                                                                                +
     5|             zq_zfba_xyrxx.xyrxx_xm,                                                                                +
     6|             zq_zfba_xyrxx.xyrxx_xb,                                                                                +
     7|             zq_zfba_xyrxx.xyrxx_lrsj,                                                                                +
     8|             zq_zfba_xyrxx.ajxx_join_ajxx_ajbh,                                                                                +
     9|             zq_zfba_xyrxx.ajxx_join_ajxx_lasj,                                                                                +
    10|             zq_zfba_xyrxx.ajxx_join_ajxx_ajlx,                                                                                +
    11|             zq_zfba_xyrxx.ajxx_join_ajxx_ay,                                                                                +
    12|             zq_zfba_xyrxx.xyrxx_hjdxzqh,                                                                                +
    13|             zq_zfba_xyrxx.xyrxx_hjdxzqh_dm,                                                                                +
    14|             zq_zfba_xyrxx.xyrxx_hjdxz,                                                                                +
    15|             zq_zfba_xyrxx.xyrxx_xzdxz,                                                                                +
    16|             zq_zfba_xyrxx.ajxx_join_ajxx_cbdw_bh,                                                                                +
    17|             zq_zfba_xyrxx.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    18|             zq_zfba_xyrxx.xyrxx_rybh,                                                                                +
    19|             to_date("substring"(zq_zfba_xyrxx.xyrxx_sfzh, 7, 8), 'YYYYMMDD'::text) AS birthday                                                                                +
    20|            FROM ywdata.zq_zfba_xyrxx                                                                                +
    21|           WHERE ((zq_zfba_xyrxx.ajxx_join_ajxx_isdel_dm = '0'::text) AND (zq_zfba_xyrxx.xyrxx_sfzh IS NOT NULL) AND (length(zq_zfba_xyrxx.xyrxx_sfzh) = 18) AND (zq_zfba_xyrxx.xyrxx_sfzh ~ '^\d{17}[\dXx]$'::text) AND ("substring"(zq_zfba_xyrxx.xyrxx_sfzh, 7, 8) ~ '^\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$'::text) AND ("substring"(zq_zfba_xyrxx.xyrxx_sfzh, 7, 8) >= to_char((CURRENT_DATE - '20 years'::pg_catalog.interval), 'YYYYMMDD'::text)))+
    22|         ), xz_keys AS MATERIALIZED (                                                                                +
    23|          SELECT DISTINCT zq_zfba_byxzcfjds.ajxx_ajbh AS ajbh,                                                                                +
    24|             zq_zfba_byxzcfjds.byxzcfjds_rybh AS rybh                                                                                +
    25|            FROM ywdata.zq_zfba_byxzcfjds                                                                                +
    26|           WHERE (zq_zfba_byxzcfjds.byxzcfjds_cbryj !~ '违法事实不能成立'::text)                                                                                +
    27|         UNION                                                                                +
    28|          SELECT DISTINCT zq_zfba_xzcfjds.ajxx_ajbh AS ajbh,                                                                                +
    29|             zq_zfba_xzcfjds.xzcfjds_rybh AS rybh                                                                                +
    30|            FROM ywdata.zq_zfba_xzcfjds                                                                                +
    31|         ), wf_xz_filtered AS MATERIALIZED (                                                                                +
    32|          SELECT v.xyrxx_sfzh,                                                                                +
    33|             v.xyrxx_xm,                                                                                +
    34|             v.xyrxx_xb,                                                                                +
    35|             v.xyrxx_lrsj,                                                                                +
    36|             v.ajxx_join_ajxx_ajbh,                                                                                +
    37|             v.ajxx_join_ajxx_lasj,                                                                                +
    38|             v.ajxx_join_ajxx_ajlx,                                                                                +
    39|             v.ajxx_join_ajxx_ay,                                                                                +
    40|             v.xyrxx_hjdxzqh,                                                                                +
    41|             v.xyrxx_hjdxzqh_dm,                                                                                +
    42|             v.xyrxx_hjdxz,                                                                                +
    43|             v.xyrxx_xzdxz,                                                                                +
    44|             v.ajxx_join_ajxx_cbdw_bh,                                                                                +
    45|             v.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    46|             v.xyrxx_rybh,                                                                                +
    47|             v.birthday                                                                                +
    48|            FROM wf_validated v                                                                                +
    49|           WHERE ((v.ajxx_join_ajxx_ajlx = '刑事'::text) AND (NOT (EXISTS ( SELECT 1                                                                                +
    50|                    FROM ywdata.zq_zfba_byxzcfjds bxf                                                                                +
    51|                   WHERE ((bxf.ajxx_ajbh = v.ajxx_join_ajxx_ajbh) AND (bxf.byxzcfjds_rybh = v.xyrxx_rybh) AND (bxf.byxzcfjds_cbryj ~ '违法事实不能成立'::text))))) AND (NOT (EXISTS ( SELECT 1                                                                                +
    52|                    FROM ywdata.zq_zfba_wenshu ws                                                                                +
    53|                   WHERE ((ws.ajbh = v.ajxx_join_ajxx_ajbh) AND (ws.xgry_xm = v.xyrxx_xm) AND (ws.wsmc ~ '终止侦查决定书'::text))))))                                                                                +
    54|         UNION ALL                                                                                +
    55|          SELECT v.xyrxx_sfzh,                                                                                +
    56|             v.xyrxx_xm,                                                                                +
    57|             v.xyrxx_xb,                                                                                +
    58|             v.xyrxx_lrsj,                                                                                +
    59|             v.ajxx_join_ajxx_ajbh,                                                                                +
    60|             v.ajxx_join_ajxx_lasj,                                                                                +
    61|             v.ajxx_join_ajxx_ajlx,                                                                                +
    62|             v.ajxx_join_ajxx_ay,                                                                                +
    63|             v.xyrxx_hjdxzqh,                                                                                +
    64|             v.xyrxx_hjdxzqh_dm,                                                                                +
    65|             v.xyrxx_hjdxz,                                                                                +
    66|             v.xyrxx_xzdxz,                                                                                +
    67|             v.ajxx_join_ajxx_cbdw_bh,                                                                                +
    68|             v.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    69|             v.xyrxx_rybh,                                                                                +
    70|             v.birthday                                                                                +
    71|            FROM (wf_validated v                                                                                +
    72|              JOIN xz_keys k ON (((k.ajbh = v.ajxx_join_ajxx_ajbh) AND (k.rybh = v.xyrxx_rybh))))                                                                                +
    73|           WHERE (v.ajxx_join_ajxx_ajlx = '行政'::text)                                                                                +
    74|         ), wf_minor AS MATERIALIZED (                                                                                +
    75|          SELECT v.xyrxx_sfzh,                                                                                +
    76|             v.xyrxx_xm,                                                                                +
    77|             v.xyrxx_xb,                                                                                +
    78|             v.xyrxx_lrsj,                                                                                +
    79|             v.ajxx_join_ajxx_ajbh,                                                                                +
    80|             v.ajxx_join_ajxx_lasj,                                                                                +
    81|             v.ajxx_join_ajxx_ajlx,                                                                                +
    82|             v.ajxx_join_ajxx_ay,                                                                                +
    83|             v.xyrxx_hjdxzqh,                                                                                +
    84|             v.xyrxx_hjdxzqh_dm,                                                                                +
    85|             v.xyrxx_hjdxz,                                                                                +
    86|             v.xyrxx_xzdxz,                                                                                +
    87|             v.ajxx_join_ajxx_cbdw_bh,                                                                                +
    88|             v.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    89|             v.xyrxx_rybh,                                                                                +
    90|             v.birthday,                                                                                +
    91|             aj.ajxx_fasj,                                                                                +
    92|             ("date_part"('year'::text, age(((aj.ajxx_fasj)::date)::timestamp without time zone, (v.birthday)::timestamp without time zone)))::integer AS fasj_age                                                                                +
    93|            FROM (wf_xz_filtered v                                                                                +
    94|              JOIN ywdata.zq_zfba_ajxx aj ON ((v.ajxx_join_ajxx_ajbh = aj.ajxx_ajbh)))                                                                                +
    95|           WHERE (("date_part"('year'::text, age(v.xyrxx_lrsj, (v.birthday)::timestamp without time zone)) < (18)::double precision) AND (v.ajxx_join_ajxx_ajbh <> ALL (ARRAY['A4453021205002025126001'::text, 'A4453816302002026026010'::text])) AND (v.xyrxx_rybh <> ALL (ARRAY['R4453021205002026023007'::text, 'R4453816302002026023012'::text])) AND (v.xyrxx_sfzh <> '445381200802232178'::text))                                                       +
    96|         ), combined AS MATERIALIZED (                                                                                +
    97|          SELECT ranked.xyrxx_sfzh,                                                                                +
    98|             min(ranked.xyrxx_xm) FILTER (WHERE (ranked.rn_desc = 1)) AS xyrxx_xm,                                                                                +
    99|             min(ranked.xyrxx_xb) FILTER (WHERE (ranked.rn_desc = 1)) AS xyrxx_xb,                                                                                +
   100|             min((ranked.birthday)::timestamp without time zone) FILTER (WHERE (ranked.rn_desc = 1)) AS birthday,                                                                                +
   101|             min(ranked.xyrxx_lrsj) FILTER (WHERE (ranked.rn_desc = 1)) AS xyrxx_lrsj,                                                                                +
   102|             min(ranked.fasj_age) FILTER (WHERE (ranked.rn_desc = 1)) AS "最近一次发案年龄",                                                                                +
   103|             string_agg(ranked.ajxx_join_ajxx_ajlx, ' → '::text ORDER BY ranked.ajxx_join_ajxx_lasj DESC NULLS LAST) AS "案件类型",                                                                                +
   104|             string_agg(to_char(ranked.ajxx_join_ajxx_lasj, 'YYYY-MM-DD'::text), ' → '::text ORDER BY ranked.ajxx_join_ajxx_lasj DESC NULLS LAST) AS "立案时间链",                                                                                +
   105|             string_agg(ranked.ajxx_join_ajxx_ajbh, ' → '::text ORDER BY ranked.ajxx_join_ajxx_lasj DESC NULLS LAST) AS "案件编号",                                                                                +
   106|             string_agg(ranked.ajxx_join_ajxx_ay, ' → '::text ORDER BY ranked.ajxx_join_ajxx_lasj DESC NULLS LAST) AS "案由",                                                                                +
   107|             string_agg(DISTINCT ranked.xyrxx_hjdxzqh, '、'::text) AS "户籍行政区",                                                                                +
   108|             string_agg(DISTINCT ranked.xyrxx_hjdxzqh_dm, '、'::text) AS "户籍地代码",                                                                                +
   109|             string_agg(DISTINCT ranked.xyrxx_hjdxz, '、'::text) AS "户籍地",                                                                                +
   110|             string_agg(DISTINCT ranked.xyrxx_xzdxz, '、'::text) AS "现住地",                                                                                +
   111|             string_agg(DISTINCT ranked.ajxx_join_ajxx_cbdw_bh, ' → '::text) AS "办案部门",                                                                                +
   112|             string_agg(DISTINCT ranked.ajxx_join_ajxx_cbdw_bh_dm, ' → '::text) AS "办案部门编码",                                                                                +
   113|             string_agg(ranked.xyrxx_rybh, ' → '::text ORDER BY ranked.ajxx_join_ajxx_lasj DESC NULLS LAST) AS "人员编号",                                                                                +
   114|             count(*) AS "违法次数"                                                                                +
   115|            FROM ( SELECT wf_minor.xyrxx_sfzh,                                                                                +
   116|                     wf_minor.xyrxx_xm,                                                                                +
   117|                     wf_minor.xyrxx_xb,                                                                                +
   118|                     wf_minor.xyrxx_lrsj,                                                                                +
   119|                     wf_minor.ajxx_join_ajxx_ajbh,                                                                                +
   120|                     wf_minor.ajxx_join_ajxx_lasj,                                                                                +
   121|

Use offset=121 to continue reading (showing 1-120 of 174 lines)


Explanation: The user wants to see the logic of `v_wcnr_wfry_jbxx` view. I've found it - it's from `ywdata.zq_zfba_wcnr_xyr` table (not `zq_zfba_xyrxx`). Let me read the complete definition of this view and the `v_wcnr_wfry_jbxx_base` view. Let me continue reading.


   121|                     wf_minor.ajxx_join_ajxx_ajlx,                                                                                +
   122|                     wf_minor.ajxx_join_ajxx_ay,                                                                                +
   123|                     wf_minor.xyrxx_hjdxzqh,                                                                                +
   124|                     wf_minor.xyrxx_hjdxzqh_dm,                                                                                +
   125|                     wf_minor.xyrxx_hjdxz,                                                                                +
   126|                     wf_minor.xyrxx_xzdxz,                                                                                +
   127|                     wf_minor.ajxx_join_ajxx_cbdw_bh,                                                                                +
   128|                     wf_minor.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
   129|                     wf_minor.xyrxx_rybh,                                                                                +
   130|                     wf_minor.birthday,                                                                                +
   131|                     wf_minor.ajxx_fasj,                                                                                +
   132|                     wf_minor.fasj_age,                                                                                +
   133|                     row_number() OVER (PARTITION BY wf_minor.xyrxx_sfzh ORDER BY wf_minor.ajxx_join_ajxx_lasj DESC NULLS LAST) AS rn_desc                                                                                +
   134|                    FROM wf_minor) ranked                                                                                +
   135|           GROUP BY ranked.xyrxx_sfzh                                                                                +
   136|         )                                                                                +
   137|  SELECT c.xyrxx_xm AS "姓名",                                                                                +
   138|     c.xyrxx_sfzh AS "身份证号",                                                                                +
   139|     c.xyrxx_xb AS "性别",                                                                                +
   140|     c."最近一次发案年龄",                                                                                +
   141|     ("date_part"('year'::text, age((CURRENT_DATE)::timestamp without time zone, c.birthday)))::integer AS "现在年龄",                                                                                +
   142|     c.xyrxx_lrsj AS "录入时间",                                                                                +
   143|     c."违法次数",                                                                                +
   144|     c."案件类型",                                                                                +
   145|     c."立案时间链",                                                                                +
   146|     c."案件编号",                                                                                +
   147|     c."案由",                                                                                +
   148|     c."户籍行政区",                                                                                +
   149|     c."户籍地代码",                                                                                +
   150|     c."户籍地",                                                                                +
   151|     c."现住地",                                                                                +
   152|     c."办案部门",                                                                                +
   153|     c."办案部门编码",                                                                                +
   154|     c."人员编号",                                                                                +
   155|     xi.xxmc AS "学校名称",                                                                                +
   156|     xi.njmc AS "年级名称",                                                                                +
   157|     xi.bjmc AS "班级名称",                                                                                +
   158|     xi.jdzt AS "就读状态"                                                                                +
   159|    FROM (combined c                                                                                +
   160|      LEFT JOIN LATERAL ( SELECT sh_gd_zxxxsxj_xx.sfzjh,                                                                                +
   161|             sh_gd_zxxxsxj_xx.xxmc,                                                                                +
   162|             sh_gd_zxxxsxj_xx.njmc,                                                                                +
   163|             sh_gd_zxxxsxj_xx.bjmc,                                                                                +
   164|             sh_gd_zxxxsxj_xx.jdzt                                                                                +
   165|            FROM ywdata.sh_gd_zxxxsxj_xx                                                                                +
   166|           WHERE ((sh_gd_zxxxsxj_xx.sfzjh)::text = c.xyrxx_sfzh)                                                                                +
   167|           ORDER BY                                                                                +
   168|                 CASE                                                                                +
   169|                     WHEN ((sh_gd_zxxxsxj_xx.jdzt)::text = '在校'::text) THEN 0                                                                                +
   170|                     ELSE 1                                                                                +
   171|                 END, sh_gd_zxxxsxj_xx.jdzt                                                                                +
   172|          LIMIT 1) xi ON (true));
   173|(1 row)
   174|
   175|


找到了。你说的应该是 `v_wcnr_wfry_jbxx`（未成年人违法犯罪人员基本信息视图），它依赖 `v_wcnr_wfry_base`。下面是逻辑拆解：

## `v_wcnr_wfry_base`（基础版本）

**数据源**：`ywdata.zq_zfba_wcnr_xyr`（未成年嫌疑人专项表）

**过滤条件**：
- 案件未删除 (`ajxx_join_ajxx_isdel_dm = 0`)
- 人员未删除 (`xyrxx_isdel_dm = 0`)
- 身份代码为 1 (`xyrxx_sfda_dm = 1`) — 即"未成年人"标记

**案件筛选**：
- **刑事案件**：排除有"不予处罚+违法事实不能成立"的 + 排除有"终止侦查决定书"的
- **行政案件**：必须在处罚决定书或不予处罚决定书中有记录（即不是空挂案件）

**输出**：一案一行，字段包括案件编号、类型、案由、地区、办案单位、立案时间、姓名、身份证、人员编号、户籍地、年龄、居住地、录入时间、学校信息。

---

## `v_wcnr_wfry_jbxx`（增强版本，按人聚合）

在 base 之上做了以下增强：

| 特性 | 说明 |
|------|------|
| **身份证校验** | 18位 + 正则 `^\d{17}[\dXx]$` + 出生日期合法 + 20年内出生 |
| **录入年龄<18** | `age(lrsj, birthday) < 18` |
| **排除特定案件** | 排除了2个特定案件编号 |
| **排除特定人员** | 排除了2个特定人员编号 |
| **排除特定身份证** | 排除了 `445381200802232178` |
| **按人聚合** | 一人一行，案件类型/时间链/编号/案由 用 `→` 连接 |
| **最近一次发案年龄** | 从案件表取 `ajxx_fasj` 计算 |
| **现在年龄** | 用 `birthday` 计算 |
| **多值聚合** | 户籍行政区、户籍地代码、户籍地、现住地、办案部门 聚合为 `、` 分隔 |
| **学校信息** | 通过 `LATERAL JOIN` 关联 `sh_gd_zxxxsxj_xx` 取学校名称、年级、班级、就读状态（优先"在校"） |

---

## 与 `v_wcnr_minor_detail`（我创建的）的区别

| 对比项 | `v_wcnr_wfry_jbxx` | `v_wcnr_minor_detail`（我建的） |
|--------|---------------------|-------------------------------|
| 数据源 | `zq_zfba_wcnr_xyr`（未成年专项表） | `zq_zfba_xyrxx`（通用嫌疑人表） |
| 按人聚合 | ✅ 一人一行 | ❌ 一案一行 |
| 学校信息 | ✅ | ❌ |
| 简要案情/发案地点 | ❌ | ✅ |
| 承办区域代码 | ❌ | ✅ |
| 身份证校验 | ✅ 严格 | ✅ 基础（18位非空） |

需要我把这些逻辑整合到一起吗？

Explanation:
好的，现在我明白了。用户提到的 `v_wcnr_base_jbxx` 实际上对应的是 `v_wcnr_wfry_jbxx`，而 `v_wcnr_wfry_base` 是它的基础版本。`v_wcnr_wfry_jbxx` 是在 `v_wcnr_wfry_base` 的基础上做了额外的过滤和增强。

让我总结一下这两个视图的逻辑：

1. **v_wcnr_wfry_base** — 基础版本：
   - 从 `ywdata.zq_zfba_wcnr_xyr` 表取数据（而不是 `ywdata.zq_zfba_xyrxx`）
   - 过滤条件：案件未删除 + 人员未删除 + 身份代码为1（服刑人员？）
   - 刑事案件：排除有"不予处罚"且"违法事实不能成立"的 + 排除有"终止侦查决定书"的
   - 行政案件：必须有关联的处罚记录（在 xz_keys 中）
   - 结果：案件编号、案件类型、案由、地区、办案单位、立案时间、姓名、身份证号、人员编号、户籍地、年龄、居住地、录入时间、学校信息
   - 排序：一案一行，刑事+行政（有处罚的）

2. **v_wcnr_wfry_jbxx** — 增强版本：
   - 在 v_wcnr_wfry_base 基础上增加了：
     - 性别（xyrxx_xb）
     - 身份证验证（18位+正则+日期验证+年龄<20岁？）
     - 最近一次发案年龄（从案件表取 fasj_age）
     - 现在年龄（用 birthday 字段计算）
     - 按人聚合（一人一行）：案件类型用"→"连接、立案时间链、案件编号链、案由链
     - 聚合多户籍地址、办案部门
     - 关联学校表取学校名称、年级、班级、就读状态
   - 过滤条件：录入年龄<18 + 排除特定案件编号和人员编号 + 排除特定身份证号

注意 v_wcnr_wfry_base 用的是 `zq_zfba_wcnr_xyr` 表（而非 `zq_zfba_xyrxx`），这是 WCNR（未成年违法犯罪嫌疑人）专项表。

我的 `v_wcnr_minor_detail` 视图是基于 `zq_zfba_xyrxx` 表（通用嫌疑人表）创建的，与 `v_wcnr_wfry_jbxx` 的数据源不同，但逻辑类似。

我需要给用户一个清晰的总结，说明这两个视图的区别和逻辑。


Explanation: The user wants to see the logic of `v_wcnr_wfry_jbxx_base`. Let me read that file.


     1|                                                                                view_definition
     2|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     3|  WITH RECURSIVE wf_validated AS MATERIALIZED (                                                                                +
     4|          SELECT zq_zfba_xyrxx.xyrxx_sfzh,                                                                                +
     5|             zq_zfba_xyrxx.xyrxx_xm,                                                                                +
     6|             zq_zfba_xyrxx.xyrxx_xb,                                                                                +
     7|             zq_zfba_xyrxx.xyrxx_lrsj,                                                                                +
     8|             zq_zfba_xyrxx.ajxx_join_ajxx_ajbh,                                                                                +
     9|             zq_zfba_xyrxx.ajxx_join_ajxx_lasj,                                                                                +
    10|             zq_zfba_xyrxx.ajxx_join_ajxx_ajlx,                                                                                +
    11|             zq_zfba_xyrxx.ajxx_join_ajxx_ajmc,                                                                                +
    12|             zq_zfba_xyrxx.ajxx_join_ajxx_ay,                                                                                +
    13|             zq_zfba_xyrxx.xyrxx_hjdxzqh,                                                                                +
    14|             zq_zfba_xyrxx.xyrxx_hjdxzqh_dm,                                                                                +
    15|             zq_zfba_xyrxx.xyrxx_hjdxz,                                                                                +
    16|             zq_zfba_xyrxx.xyrxx_xzdxz,                                                                                +
    17|             zq_zfba_xyrxx.ajxx_join_ajxx_cbdw_bh,                                                                                +
    18|             zq_zfba_xyrxx.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    19|             zq_zfba_xyrxx.xyrxx_rybh,                                                                                +
    20|             to_date("substring"(zq_zfba_xyrxx.xyrxx_sfzh, 7, 8), 'YYYYMMDD'::text) AS birthday                                                                                +
    21|            FROM ywdata.zq_zfba_xyrxx                                                                                +
    22|           WHERE ((zq_zfba_xyrxx.ajxx_join_ajxx_isdel_dm = '0'::text) AND (zq_zfba_xyrxx.xyrxx_sfzh IS NOT NULL) AND (length(zq_zfba_xyrxx.xyrxx_sfzh) = 18) AND (zq_zfba_xyrxx.xyrxx_sfzh ~ '^\d{17}[\dXx]$'::text) AND ("substring"(zq_zfba_xyrxx.xyrxx_sfzh, 7, 8) ~ '^\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$'::text) AND ("substring"(zq_zfba_xyrxx.xyrxx_sfzh, 7, 8) >= to_char((CURRENT_DATE - '20 years'::pg_catalog.interval), 'YYYYMMDD'::text)))+
    23|         ), xz_keys AS MATERIALIZED (                                                                                +
    24|          SELECT DISTINCT zq_zfba_byxzcfjds.ajxx_ajbh AS ajbh,                                                                                +
    25|             zq_zfba_byxzcfjds.byxzcfjds_rybh AS rybh                                                                                +
    26|            FROM ywdata.zq_zfba_byxzcfjds                                                                                +
    27|           WHERE (zq_zfba_byxzcfjds.byxzcfjds_cbryj !~ '违法事实不能成立'::text)                                                                                +
    28|         UNION                                                                                +
    29|          SELECT DISTINCT zq_zfba_xzcfjds.ajxx_ajbh AS ajbh,                                                                                +
    30|             zq_zfba_xzcfjds.xzcfjds_rybh AS rybh                                                                                +
    31|            FROM ywdata.zq_zfba_xzcfjds                                                                                +
    32|         ), wf_xz_filtered AS MATERIALIZED (                                                                                +
    33|          SELECT v_1.xyrxx_sfzh,                                                                                +
    34|             v_1.xyrxx_xm,                                                                                +
    35|             v_1.xyrxx_xb,                                                                                +
    36|             v_1.xyrxx_lrsj,                                                                                +
    37|             v_1.ajxx_join_ajxx_ajbh,                                                                                +
    38|             v_1.ajxx_join_ajxx_lasj,                                                                                +
    39|             v_1.ajxx_join_ajxx_ajlx,                                                                                +
    40|             v_1.ajxx_join_ajxx_ajmc,                                                                                +
    41|             v_1.ajxx_join_ajxx_ay,                                                                                +
    42|             v_1.xyrxx_hjdxzqh,                                                                                +
    43|             v_1.xyrxx_hjdxzqh_dm,                                                                                +
    44|             v_1.xyrxx_hjdxz,                                                                                +
    45|             v_1.xyrxx_xzdxz,                                                                                +
    46|             v_1.ajxx_join_ajxx_cbdw_bh,                                                                                +
    47|             v_1.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    48|             v_1.xyrxx_rybh,                                                                                +
    49|             v_1.birthday                                                                                +
    50|            FROM wf_validated v_1                                                                                +
    51|           WHERE ((v_1.ajxx_join_ajxx_ajlx = '刑事'::text) AND (NOT (EXISTS ( SELECT 1                                                                                +
    52|                    FROM ywdata.zq_zfba_byxzcfjds bxf                                                                                +
    53|                   WHERE ((bxf.ajxx_ajbh = v_1.ajxx_join_ajxx_ajbh) AND (bxf.byxzcfjds_rybh = v_1.xyrxx_rybh) AND (bxf.byxzcfjds_cbryj ~ '违法事实不能成立'::text))))) AND (NOT (EXISTS ( SELECT 1                                                                                +
    54|                    FROM ywdata.zq_zfba_wenshu ws                                                                                +
    55|                   WHERE ((ws.ajbh = v_1.ajxx_join_ajxx_ajbh) AND (ws.xgry_xm = v_1.xyrxx_xm) AND (ws.wsmc ~ '终止侦查决定书'::text))))))                                                                                +
    56|         UNION ALL                                                                                +
    57|          SELECT v_1.xyrxx_sfzh,                                                                                +
    58|             v_1.xyrxx_xm,                                                                                +
    59|             v_1.xyrxx_xb,                                                                                +
    60|             v_1.xyrxx_lrsj,                                                                                +
    61|             v_1.ajxx_join_ajxx_ajbh,                                                                                +
    62|             v_1.ajxx_join_ajxx_lasj,                                                                                +
    63|             v_1.ajxx_join_ajxx_ajlx,                                                                                +
    64|             v_1.ajxx_join_ajxx_ajmc,                                                                                +
    65|             v_1.ajxx_join_ajxx_ay,                                                                                +
    66|             v_1.xyrxx_hjdxzqh,                                                                                +
    67|             v_1.xyrxx_hjdxzqh_dm,                                                                                +
    68|             v_1.xyrxx_hjdxz,                                                                                +
    69|             v_1.xyrxx_xzdxz,                                                                                +
    70|             v_1.ajxx_join_ajxx_cbdw_bh,                                                                                +
    71|             v_1.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    72|             v_1.xyrxx_rybh,                                                                                +
    73|             v_1.birthday                                                                                +
    74|            FROM (wf_validated v_1                                                                                +
    75|              JOIN xz_keys k ON (((k.ajbh = v_1.ajxx_join_ajxx_ajbh) AND (k.rybh = v_1.xyrxx_rybh))))                                                                                +
    76|           WHERE (v_1.ajxx_join_ajxx_ajlx = '行政'::text)                                                                                +
    77|         )                                                                                +
    78|  SELECT v.xyrxx_sfzh,                                                                                +
    79|     v.xyrxx_xm,                                                                                +
    80|     v.xyrxx_xb,                                                                                +
    81|     v.xyrxx_lrsj,                                                                                +
    82|     v.ajxx_join_ajxx_ajbh,                                                                                +
    83|     v.ajxx_join_ajxx_lasj,                                                                                +
    84|     v.ajxx_join_ajxx_ajlx,                                                                                +
    85|     v.ajxx_join_ajxx_ajmc,                                                                                +
    86|     v.ajxx_join_ajxx_ay,                                                                                +
    87|     v.xyrxx_hjdxzqh,                                                                                +
    88|     v.xyrxx_hjdxzqh_dm,                                                                                +
    89|     v.xyrxx_hjdxz,                                                                                +
    90|     v.xyrxx_xzdxz,                                                                                +
    91|     v.ajxx_join_ajxx_cbdw_bh,                                                                                +
    92|     v.ajxx_join_ajxx_cbdw_bh_dm,                                                                                +
    93|     v.xyrxx_rybh,                                                                                +
    94|     v.birthday,                                                                                +
    95|     aj.ajxx_fasj,                                                                                +
    96|     ("date_part"('year'::text, age(((aj.ajxx_fasj)::date)::timestamp without time zone, (v.birthday)::timestamp without time zone)))::integer AS fasj_age,                                                                                +
    97|     ("date_part"('year'::text, age((CURRENT_DATE)::timestamp without time zone, (v.birthday)::timestamp without time zone)))::integer AS current_age                                                                                +
    98|    FROM (wf_xz_filtered v                                                                                +
    99|      JOIN ywdata.zq_zfba_ajxx aj ON ((v.ajxx_join_ajxx_ajbh = aj.ajxx_ajbh)))                                                                                +
   100|   WHERE (("date_part"('year'::text, age(v.xyrxx_lrsj, (v.birthday)::timestamp without time zone)) < (18)::double precision) AND (v.ajxx_join_ajxx_ajbh <> ALL (ARRAY['A4453021205002025126001'::text, 'A4453816302002026026010'::text])) AND (v.xyrxx_rybh <> ALL (ARRAY['R4453021205002026023007'::text, 'R4453816302002026023012'::text])) AND (v.xyrxx_sfzh <> '445381200802232178'::text));
   101|(1 row)
   102|
   103|


看完了，完整逻辑如下：

## `v_wcnr_wfry_jbxx_base` 逻辑拆解

**数据源**：`ywdata.zq_zfba_xyrxx`（通用嫌疑人信息表）

### 四个 CTE 阶段

| CTE | 作用 |
|-----|------|
| `wf_validated` | 基础清洗：身份证18位+正则校验+生日合法+20年内出生；排除案件/人员已删除；提取 `birthday` |
| `xz_keys` | 行政案件有效钥匙：(ajbh, rybh) 去重，来自处罚决定书+不予处罚决定书，**排除"违法事实不能成立"**的记录 |
| `wf_xz_filtered` | 案件筛选：刑事案排除"不予处罚+违法事实不能成立"和"终止侦查决定书"；行政案必须有 `xz_keys` 记录 |

### 最终输出（一案一行）

```sql
-- 关联案件表取发案时间，计算两个年龄
JOIN ywdata.zq_zfba_ajxx aj ON v.ajxx_ajbh = aj.ajxx_ajbh
```

| 字段 | 说明 |
|------|------|
| `xyrxx_sfzh` | 身份证 |
| `xyrxx_xm` | 姓名 |
| `xyrxx_xb` | 性别 |
| `xyrxx_lrsj` | 录入时间 |
| `ajxx_join_ajxx_ajbh` | 案件编号 |
| `ajxx_join_ajxx_lasj` | 立案时间 |
| `ajxx_join_ajxx_ajlx` | 案件类型（刑事/行政） |
| `ajxx_join_ajxx_ajmc` | 案件名称 |
| `ajxx_join_ajxx_ay` | 案由 |
| `xyrxx_hjdxzqh / _dm` | 户籍地区划代码 |
| `xyrxx_hjdxz` | 户籍地详细地址 |
| `xyrxx_xzdxz` | 现住地详细地址 |
| `ajxx_join_ajxx_cbdw_bh / _dm` | 办案单位 |
| `xyrxx_rybh` | 人员编号 |
| `birthday` | 生日（身份证第7-14位提取） |
| `ajxx_fasj` | **发案时间**（从案件表取） |
| `fasj_age` | **发案时年龄** = age(发案时间, birthday) |
| `current_age` | **当前年龄** = age(now(), birthday) |

### 最终 WHERE 过滤（关键）

```sql
-- 1. 录入时的年龄 < 18（即录入时是未成年人）
age(xyrxx_lrsj, birthday) < 18

-- 2. 排除两个特定案件
ajbh NOT IN ('A4453021205002025126001', 'A4453816302002026026010')

-- 3. 排除两个特定人员编号
rybh NOT IN ('R4453021205002026023007', 'R4453816302002026023012')

-- 4. 排除一个特定身份证
sfzh <> '445381200802232178'
```

---

**核心特点**：一案一行、不聚合，保留所有案件维度。包含 `fasj_age` 和 `current_age` 两个年龄字段，来自通用嫌疑人表而非未成年专项表。

Explanation:
The user asked about `v_wcnr_wfry_jbxx_base`. Let me analyze this view carefully.

Looking at `v_wcnr_wfry_jbxx_base`:

1. **`wf_validated` CTE**: Same as in `v_wcnr_wfry_jbxx` - validates from `ywdata.zq_zfba_xyrxx` with:
   - Case not deleted (`ajxx_join_ajxx_isdel_dm = '0'`)
   - ID card not null, 18 chars, matches regex `^\d{17}[\dXx]$`
   - Birth date from ID card is valid (`^\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$`)
   - Birth date >= 20 years ago (born within last 20 years)
   - Extracts `birthday` from substring of ID card positions 7-8

2. **`xz_keys` CTE**: Same as in `v_wcnr_wfry_jbxx` - distinct (ajbh, rybh) from penalty decision tables, excluding records where "违法事实不能成立"

3. **`wf_xz_filtered` CTE**: Filters cases:
   - **刑事案件**: Exclude cases where there's a "不予处罚决定书" with "违法事实不能成立" OR a "终止侦查决定书"
   - **行政案件**: Must have a record in `xz_keys` (i.e., has a valid penalty decision)

4. **Final SELECT**: Joins `wf_xz_filtered` with `zq_zfba_ajxx` to get `ajxx_fasj` (case occurrence time). Calculates:
   - `fasj_age`: Age at case occurrence time
   - `current_age`: Current age from birthday

5. **WHERE clause filters**:
   - `age(lrsj, birthday) < 18`: Age at record entry time is under 18
   - Excludes 2 specific case numbers: `A4453021205002025126001`, `A4453816302002026026010`
   - Excludes 2 specific person IDs: `R4453021205002026023007`, `R4453816302002026023012`
   - Excludes specific ID card: `445381200802232178`

**Output**: One row per case (not aggregated per person). Outputs:
- `xyrxx_sfzh` - ID card
- `xyrxx_xm` - Name
- `xyrxx_xb` - Gender
- `xyrxx_lrsj` - Entry time
- `ajxx_join_ajxx_ajbh` - Case number
- `ajxx_join_ajxx_lasj` - Case filing time
- `ajxx_join_ajxx_ajlx` - Case type (刑事/行政)
- `ajxx_join_ajxx_ajmc` - Case name
- `ajxx_join_ajxx_ay` - Cause of action
- `xyrxx_hjdxzqh` - Hukou region code
- `xyrxx_hjdxzqh_dm` - Hukou region code (DM)
- `xyrxx_hjdxz` - Hukou address
- `xyrxx_xzdxz` - Current residence address
- `ajxx_join_ajxx_cbdw_bh` - Handling unit
- `ajxx_join_ajxx_cbdw_bh_dm` - Handling unit code
- `xyrxx_rybh` - Person number
- `birthday` - Birthday (extracted from ID)
- `ajxx_fasj` - Case occurrence time
- `fasj_age` - Age at case occurrence
- `current_age` - Current age

**Key differences from `v_wcnr_wfry_jbxx`**:
- `jbxx_base` is **one row per case** (no aggregation by person)
- `jbxx_base` uses `zq_zfba_xyrxx` (generic suspect table), NOT `zq_zfba_wcnr_xyr` (minor-specific table)
- `jbxx_base` uses `zq_zfba_wenshu` (document table) to filter out "终止侦查决定书" cases, while `v_wcnr_wfry_jbxx` doesn't do this filtering
- `jbxx_base` calculates `fasj_age` (age at case time) and `current_age` (current age)
- `jbxx_base` does NOT include school information
- `jbxx_base` filters where `age(lrsj, birthday) < 18` (age at entry time)

So the user said "用jbxx_base那个，看下它的逻辑" - they want to understand the logic of `v_wcnr_wfry_jbxx_base`. I've already read it. Let me present the logic in a clear, structured


刑事案件的两个条件是从哪些表拿数据的