-- ============================================================================ -- D 类报表服务流识别 SQL(EIP3报表迁移方案 D 节口径) -- ---------------------------------------------------------------------------- -- 库:192.168.20.68:5435/postgres,schema=eip3,只读账户 ceshi/ceshi -- 口径:报表模板 = view_template.type=200(根元素 ,337/339 含脚本); -- 报表取数服务流 = 报表模板 XML 内 selectservice="XXX" 属性所引服务流。 -- 去重后 = D 类「79 个 selectservice 服务流」。 -- 注意:servicename/selectservice 值有的是真实 sys_serviceflow_id, -- 有的是 Java 服务方法 FQN 或已失效引用(orphan);需 left join sys_serviceflow 鉴别。 -- ============================================================================ set search_path to eip3; -- 1) D 类去重总数(= 79) with raw as ( select unnest(regexp_matches(xml::text, 'selectservice="([^"]+)"', 'g')) as svc from view_template where type = 200 ) select count(distinct trim(svc)) as d_class_distinct from raw where trim(svc) <> ''; -- 2) D 类逐条:是否在 sys_serviceflow 中存在、是否活跃、是否受控 with raw as ( select distinct trim(unnest(regexp_matches(xml::text, 'selectservice="([^"]+)"', 'g'))) as flowid from view_template where type = 200 ), d as (select flowid from raw where flowid <> '') select d.flowid, case when sf.sys_serviceflow_id is null then 'MISSING' else 'EXISTS' end as in_sysflow, sf.isactive, sf.iscontrol, sf.displayname from d left join sys_serviceflow sf on trim(sf.sys_serviceflow_id) = d.flowid order by (case when sf.sys_serviceflow_id is null then 1 else 0 end), d.flowid; -- 3) 汇总:存在 40(非受控 38 + 受控 2)/ 缺失 orphan 39 with raw as ( select distinct trim(unnest(regexp_matches(xml::text, 'selectservice="([^"]+)"', 'g'))) as flowid from view_template where type = 200 ), d as (select flowid from raw where flowid <> '') select count(*) as d_total, count(sf.sys_serviceflow_id) as exists_cnt, count(*) - count(sf.sys_serviceflow_id) as missing_orphan_cnt, count(*) filter (where sf.iscontrol = 0) as exists_noncontrol, count(*) filter (where sf.iscontrol = 1) as exists_control from d left join sys_serviceflow sf on trim(sf.sys_serviceflow_id) = d.flowid;