Jelajahi Sumber

fix: 补充班级报表根模板配置

apple 1 bulan lalu
induk
melakukan
0b89bddacf

+ 8 - 5
docs/17_升旗礼_宿舍内务检查小程序开发/2026-10-22_星级文明班级评比总表迁移到班级页右侧栏.md

@@ -57,13 +57,15 @@ GRTJ.DXM=bj
 | `BGMB` | `BGMBLBM/BGMBLXM/FWSBLBM` | `51/1/1` |
 | `BGMB` | `DXM` | `bj` |
 | `BGMB` | `BJM` | `ssnwjc_starClassSummary` |
-| `GRTJ` | `DXM/GRTJMBID/GRTJLBM` | `bj/5712/51` |
+| `GRTJ` | `DXM/GRTJMBID/GRTJLBM` | `bj/5712/51` 和 `bj/null/51` |
 | `GRTJ` | `YYRYID` | `null` |
 | `GRTJMX` | `MC` | `星级文明班级评比总表` |
 | `GRTJMX` | `XH` | `1` |
 
 选择 `GRTJMBID=5712` 是因为它与现有班级、德育、教务和宿管岗位一致,避免新增岗位模板关联。若后续需要限制为更小范围,应另建独立 `GRTJMB` 并调整 `GW.GRTJMBID`,不在本次混做。
 
+同时增加一套 `GRTJMBID is null` 的根报表配置,供岗位未设置报表模板的用户回退使用。两套配置引用同一个 `BGMB` 页面,避免用户因岗位模板为空而看不到报表。
+
 ## 4. 代码和页面配置
 
 - 在 `web/cfg/biz/bj/bj.page.xml` 注册 `ssnwjc_starClassSummary` 页面。
@@ -114,7 +116,7 @@ docs/17_升旗礼_宿舍内务检查小程序开发/sql/
 | 回滚 SQL dry-run | 安装后回滚并恢复旧菜单语义 | 通过 |
 | 页面注册 | 运行时 `pageMap` 检查 | `ssnwjc_starClassSummary=true` |
 | 临时对象移除 | 运行时 `objMap` 检查 | `ssnwjcStarClassSummary=false` |
-| 班级报表查询 | `GRTJ/GRTJMX/BGMB` 联合查询 | `GRTJID=572131`、`GRTJMXID=575159`、`BGMBID=51186` |
+| 班级报表查询 | `GRTJ/GRTJMX/BGMB` 联合查询 | 模板组 `572131/575159`;根组 `572133/575161`;共用 `BGMBID=51186` |
 | 旧菜单移除 | `GRCD` 精确查询 | 0 行 |
 | 页面响应 | 两个报表页面路径 HTTP 200 | 两个路径均 200,17178 字节 |
 | 班级右侧栏 | 运行态调用 `StatU.rdGrtj("bj")` | `reports=1`,报表项 `572131 / 51186` |
@@ -173,10 +175,11 @@ cfg/biz/xyss/ssnwjc.page.xml
 
 ```text
 BGMBID=51186
-GRTJID=572131
-GRTJMXID=575159
+模板组 GRTJID=572131 / GRTJMXID=575159
+根组 GRTJID=572133 / GRTJMXID=575161
 DXM=bj
-GRTJMBID=5712
+GRTJMBID=5712(模板组)
+GRTJMBID=null(根组)
 GRTJLBM=51
 BJM=ssnwjc_starClassSummary
 旧独立菜单=0

+ 28 - 0
docs/17_升旗礼_宿舍内务检查小程序开发/sql/2026-10-22_星级班报表迁至班级右侧栏_回滚.sql

@@ -5,6 +5,7 @@ set feedback on
 declare
     v_bgmbid number;
     v_grtjid number;
+    v_root_grtjid number;
     v_count number;
     c_name constant varchar2(64) := '星级文明班级评比总表';
 begin
@@ -21,6 +22,21 @@ begin
         v_bgmbid := null;
     end if;
 
+    select count(*) into v_root_grtjid
+      from GRTJ
+     where DXM='bj' and GRTJMBID is null and YYRYID is null
+       and GRTJLBM=51 and MC=c_name;
+    if v_root_grtjid > 1 then
+        raise_application_error(-20013, 'root GRTJ duplicate');
+    elsif v_root_grtjid = 1 then
+        select max(GRTJID) into v_root_grtjid
+          from GRTJ
+         where DXM='bj' and GRTJMBID is null and YYRYID is null
+           and GRTJLBM=51 and MC=c_name;
+    else
+        v_root_grtjid := null;
+    end if;
+
     select count(*) into v_grtjid
       from GRTJ
      where DXM='bj' and GRTJMBID=5712 and YYRYID is null
@@ -42,6 +58,17 @@ begin
            and (v_bgmbid is null or BGMBID=v_bgmbid);
     end if;
 
+    if v_root_grtjid is not null then
+        delete from GRTJMX
+         where GRTJID=v_root_grtjid
+           and (v_bgmbid is null or BGMBID=v_bgmbid);
+    end if;
+
+    select count(*) into v_count from GRTJMX where GRTJID=v_root_grtjid;
+    if v_root_grtjid is not null and v_count=0 then
+        delete from GRTJ where GRTJID=v_root_grtjid;
+    end if;
+
     select count(*) into v_count from GRTJMX where GRTJID=v_grtjid;
     if v_grtjid is not null and v_count=0 then
         delete from GRTJ where GRTJID=v_grtjid;
@@ -88,6 +115,7 @@ begin
 
     dbms_output.put_line('removed BGMBID=' || nvl(to_char(v_bgmbid),'none'));
     dbms_output.put_line('removed GRTJID=' || nvl(to_char(v_grtjid),'none'));
+    dbms_output.put_line('removed ROOT_GRTJID=' || nvl(to_char(v_root_grtjid),'none'));
     dbms_output.put_line('restored legacy menu templates=1011,10141,101223');
 end;
 /

+ 57 - 1
docs/17_升旗礼_宿舍内务检查小程序开发/sql/2026-10-22_星级班报表迁至班级右侧栏_安装.sql

@@ -6,6 +6,8 @@ declare
     v_bgmbid    number;
     v_grtjid    number;
     v_grtjmxid  number;
+    v_root_grtjid   number;
+    v_root_grtjmxid number;
     v_count     number;
     v_menu_count number;
     c_name constant varchar2(64) := '星级文明班级评比总表';
@@ -95,6 +97,58 @@ begin
         returning GRTJMXID into v_grtjmxid;
     end if;
 
+    select count(*) into v_count
+      from GRTJ
+     where DXM='bj'
+       and GRTJMBID is null
+       and YYRYID is null
+       and GRTJLBM=51
+       and MC=c_name;
+    if v_count > 1 then
+        raise_application_error(-20004, 'root GRTJ duplicate');
+    elsif v_count = 1 then
+        select max(GRTJID) into v_root_grtjid
+          from GRTJ
+         where DXM='bj'
+           and GRTJMBID is null
+           and YYRYID is null
+           and GRTJLBM=51
+           and MC=c_name;
+        update GRTJ
+           set XH=1,KD=0,GD=0,JLZTM=51
+         where GRTJID=v_root_grtjid;
+    else
+        insert into GRTJ
+            (YYRYID,TJTLBM,GRTJMBID,YJTJZBM,MC,DXM,
+             XH,KD,GD,JLZTM,GRTJLBM)
+        values
+            (null,null,null,null,c_name,'bj',
+             1,0,0,51,51)
+        returning GRTJID into v_root_grtjid;
+    end if;
+
+    select count(*) into v_count
+      from GRTJMX
+     where GRTJID=v_root_grtjid
+       and BGMBID=v_bgmbid;
+    if v_count > 1 then
+        raise_application_error(-20005, 'root GRTJMX duplicate');
+    elsif v_count = 1 then
+        select max(GRTJMXID) into v_root_grtjmxid
+          from GRTJMX
+         where GRTJID=v_root_grtjid
+           and BGMBID=v_bgmbid;
+        update GRTJMX
+           set MC=c_name,XH=1,JLZTM=51
+         where GRTJMXID=v_root_grtjmxid;
+    else
+        insert into GRTJMX
+            (GRTJID,TJZBM,SJGRTJMXID,MC,XH,JLZTM,BGMBID)
+        values
+            (v_root_grtjid,null,null,c_name,1,51,v_bgmbid)
+        returning GRTJMXID into v_root_grtjmxid;
+    end if;
+
     delete from GRCD
      where GRCDID in (1025936,1025937,1025938)
        and DXM='ssnwjcStarClassSummary'
@@ -104,6 +158,8 @@ begin
     dbms_output.put_line('BGMBID=' || v_bgmbid);
     dbms_output.put_line('GRTJID=' || v_grtjid);
     dbms_output.put_line('GRTJMXID=' || v_grtjmxid);
+    dbms_output.put_line('ROOT_GRTJID=' || v_root_grtjid);
+    dbms_output.put_line('ROOT_GRTJMXID=' || v_root_grtjmxid);
     dbms_output.put_line('removed_legacy_menus=' || v_menu_count);
 end;
 /
@@ -116,7 +172,7 @@ select g.GRTJID,g.GRTJMBID,g.DXM,g.GRTJLBM,g.MC grtj_mc,m.GRTJMXID,
   join GRTJMX m on m.GRTJID=g.GRTJID
   join BGMB b on b.BGMBID=m.BGMBID
  where g.DXM='bj'
-   and g.GRTJMBID=5712
+   and (g.GRTJMBID=5712 or g.GRTJMBID is null)
    and g.GRTJLBM=51
    and b.BJM='ssnwjc_starClassSummary';