Browse Source

feat(starclass): 补齐团体委类别与班级加分

apple 3 weeks ago
parent
commit
c321e9937c

+ 122 - 0
docs/24_星级班班主任移动报表/2026-11-02_团体委成员与班级加分迁移记录.md

@@ -0,0 +1,122 @@
+# 2026-11-02 团体委成员与班级加分迁移记录
+
+## 1. 核查结论
+
+### 第三方 ZHIXIN 本地快照
+
+原始 `FREEPDB1` 实际数据文件约 16.3GB,已经超过 Oracle Free 的 12GB
+上限,无法直接打开。因此新建了隔离的 `ZHIX_ANALYZE` 分析 PDB,只导入
+学生、组织和干部相关表。
+
+核查结果:
+
+| 表 | 行数 |
+|---|---:|
+| `TSTU_STUDENT` | 12,402 |
+| `TSTU_CLASS` | 252 |
+| `T_STUM_CO_STU_ORG` | 0 |
+| `T_STUM_CO_STU_CADRE` | 0 |
+| `T_STUM_OW_MEMBER_ARCHIVES` | 0 |
+| `T_STUM_OW_MEMBER_CADRE` | 0 |
+| `T_STUM_OW_ORGAN_COMMITTEE` | 0 |
+| `T_STUM_OW_ORGAN_DEPARTMENT` | 0 |
+| `T_STUM_OW_ORGAN_INSTITUTION` | 0 |
+| `T_STUM_DM_DUTY_TYPE` | 0 |
+| `T_STUM_DM_DUTY_PLAN` | 0 |
+
+第三方快照中没有学生会或国旗队成员名单。
+
+### 211 新版本系统
+
+211 的团体配置已存在,但成员数据为空:
+
+| 表 | 行数 |
+|---|---:|
+| `TTLB` | 6 |
+| `TTWCYLB` | 16 |
+| `TT` | 2 |
+| `TTCY` | 0 |
+| `TTWCY` | 0 |
+| `XSHY` | 0 |
+| `XSHYCY` | 0 |
+
+`TT` 中只有两条测试团体:
+
+```text
+测试_A部学生会
+测试_B部学生会
+```
+
+两条都是 `TTLBM=1`,没有成员,也没有国旗队团体。
+
+因此没有可迁移的真实学生会成员或国旗队成员。
+
+## 2. 已完成的测试库修改
+
+测试库原有 `TTLB` 和 `TTWCYLB`,本次按业务要求修正名称:
+
+| 编码 | 原名称 | 新名称 |
+|---:|---|---|
+| 1 | 学生会 | 团委学生会 |
+| 11 | 团总支 | 部门学生会 |
+| 21 | 国旗班 | 国旗队 |
+| 151 | 委员 | 成员 |
+| 1151 | 委员 | 成员 |
+
+同时补齐 `TTCY` 普通成员表和 `TTCYID` 序列。
+
+## 3. 已完成的正式库修改
+
+正式库原来没有团体结构,本次增量创建:
+
+```text
+TT
+TTCY
+TTWCY
+TTLB
+TTWCYLB
+序列 TTID
+序列 TTCYID
+序列 TTWCYID
+```
+
+正式库写入:
+
+- 6 个团体类别。
+- 16 个成员角色及班级加分。
+- 151、1151 均命名为“成员”。
+
+未写入测试团体和成员空记录。
+
+## 4. 一致性核验
+
+测试库和正式库比较结果:
+
+| 项目 | 测试库 | 正式库 |
+|---|---:|---:|
+| `TTLB` | 6 | 6 |
+| `TTWCYLB` | 16 | 16 |
+| 类别差异 | 0 | 0 |
+| 角色/加分差异 | 0 | 0 |
+| `TT` | 0 | 0 |
+| `TTCY` | 0 | 0 |
+| `TTWCY` | 0 | 0 |
+
+两套环境的表结构、主键、外键、序列和配置数据完全一致。
+
+## 5. 脚本
+
+```text
+docs/24_星级班班主任移动报表/sql/2026-11-02_团体委成员类别与班级加分.sql
+```
+
+脚本幂等,只新增结构或更新上述配置,不删除现有业务数据。
+
+## 6. 回滚
+
+本次没有修改任何既有业务数据。
+
+- 测试库如需回滚,只恢复 `TTLB`、`TTWCYLB` 的原名称。
+- 正式库本次新建的五张表和三个序列在确认无使用后可单独删除。
+- 删除前必须先确认没有 `TT/TTCY/TTWCY` 成员数据,并备份配置表。
+

+ 251 - 0
docs/24_星级班班主任移动报表/sql/2026-11-02_团体委成员类别与班级加分.sql

@@ -0,0 +1,251 @@
+-- 团体委成员类别、团体类别及班级加分配置
+-- 依据:用户提供的 TTWCYLB 截图,以及 PMS_TEST 已存在的同名配置
+-- 名称调整:
+--   1 学生会       -> 团委学生会
+--   11 团总支      -> 部门学生会
+--   21 国旗班      -> 国旗队
+--   151/1151 委员  -> 成员
+-- 本脚本可重复执行;只新增/更新上述配置,不修改成员关系和业务记录。
+
+declare
+    v_count number;
+
+    procedure create_table_if_absent(
+        p_table_name varchar2,
+        p_ddl varchar2
+    ) is
+    begin
+        select count(*)
+          into v_count
+          from all_tables
+         where owner = sys_context('USERENV', 'CURRENT_SCHEMA')
+           and table_name = upper(p_table_name);
+
+        if v_count = 0 then
+            execute immediate p_ddl;
+        end if;
+    end;
+
+    procedure create_sequence_if_absent(
+        p_sequence_name varchar2
+    ) is
+    begin
+        select count(*)
+          into v_count
+          from all_sequences
+         where sequence_owner = sys_context('USERENV', 'CURRENT_SCHEMA')
+           and sequence_name = upper(p_sequence_name);
+
+        if v_count = 0 then
+            execute immediate
+                'create sequence ' || p_sequence_name ||
+                ' start with 1 increment by 1 cache 20 nocycle';
+        end if;
+    end;
+
+    procedure create_index_if_absent(
+        p_index_name varchar2,
+        p_table_name varchar2,
+        p_columns varchar2
+    ) is
+    begin
+        select count(*)
+          into v_count
+          from all_indexes
+         where owner = sys_context('USERENV', 'CURRENT_SCHEMA')
+           and index_name = upper(p_index_name);
+
+        if v_count = 0 then
+            execute immediate
+                'create index ' || p_index_name ||
+                ' on ' || p_table_name || '(' || p_columns || ')';
+        end if;
+    end;
+
+    procedure create_fk_if_absent(
+        p_constraint_name varchar2,
+        p_child_table varchar2,
+        p_child_columns varchar2,
+        p_parent_table varchar2,
+        p_parent_columns varchar2
+    ) is
+    begin
+        select count(*)
+          into v_count
+          from all_constraints
+         where owner = sys_context('USERENV', 'CURRENT_SCHEMA')
+           and constraint_name = upper(p_constraint_name);
+
+        if v_count = 0 then
+            execute immediate
+                'alter table ' || p_child_table ||
+                ' add constraint ' || p_constraint_name ||
+                ' foreign key (' || p_child_columns || ')' ||
+                ' references ' || p_parent_table ||
+                '(' || p_parent_columns || ') enable novalidate';
+        end if;
+    end;
+begin
+    create_table_if_absent(
+        'TTLB',
+        q'[
+            create table TTLB (
+                TTLBM number(9) not null,
+                MC varchar2(16 char) not null,
+                constraint PK_TTLB primary key (TTLBM)
+            )
+        ]'
+    );
+
+    create_table_if_absent(
+        'TTWCYLB',
+        q'[
+            create table TTWCYLB (
+                TTWCYLBM number(9) not null,
+                TTLBM number(9) not null,
+                MC varchar2(16 char) not null,
+                BJJF number(6,2) default 0 not null,
+                constraint PK_TTWCYLB primary key (TTWCYLBM),
+                constraint FK_TTLB_TTWCYLB foreign key (TTLBM)
+                    references TTLB (TTLBM) enable novalidate
+            )
+        ]'
+    );
+
+    create_sequence_if_absent('TTID');
+    create_sequence_if_absent('TTCYID');
+    create_sequence_if_absent('TTWCYID');
+
+    create_table_if_absent(
+        'TT',
+        q'[
+            create table TT (
+                TTID number(16) not null,
+                FZRYID number(16) not null,
+                TTLBM number(9) not null,
+                FZBMID number(16) not null,
+                MC varchar2(128 char) not null,
+                MS varchar2(2048 char),
+                MSWJ varchar2(255 char),
+                FJID number(16),
+                JLZTM number(9) default 1 not null,
+                CJRYID number(16),
+                GLRYID number(16),
+                GLBMID number(16),
+                constraint PK_TT primary key (TTID),
+                constraint FK_TTLB_TT foreign key (TTLBM)
+                    references TTLB (TTLBM) enable novalidate
+            )
+        ]'
+    );
+
+    create_table_if_absent(
+        'TTCY',
+        q'[
+            create table TTCY (
+                TTCYID number(16) not null,
+                TTID number(16) not null,
+                RYID number(16) not null,
+                JLZTM number(9) default 1 not null,
+                CJRYID number(16),
+                GLRYID number(16),
+                GLBMID number(16),
+                constraint PK_TTCY primary key (TTCYID),
+                constraint FK_TT_TTCY foreign key (TTID)
+                    references TT (TTID) enable novalidate
+            )
+        ]'
+    );
+
+    create_table_if_absent(
+        'TTWCY',
+        q'[
+            create table TTWCY (
+                TTWCYID number(16) not null,
+                TTID number(16) not null,
+                TTWCYLBM number(9) not null,
+                RYID number(16) not null,
+                JLZTM number(9) default 1 not null,
+                CJRYID number(16),
+                GLRYID number(16),
+                GLBMID number(16),
+                constraint PK_TTWCY primary key (TTWCYID),
+                constraint FK_TT_TTWCY foreign key (TTID)
+                    references TT (TTID) enable novalidate,
+                constraint FK_TTWCYLB_TTWCY foreign key (TTWCYLBM)
+                    references TTWCYLB (TTWCYLBM) enable novalidate
+            )
+        ]'
+    );
+
+    create_index_if_absent('TTLB_TT_FK', 'TT', 'TTLBM');
+    create_index_if_absent('RY_TT_FZ_FK', 'TT', 'FZRYID');
+    create_index_if_absent('BM_TT_FZ_FK', 'TT', 'FZBMID');
+    create_index_if_absent('TT_TTCY_FK', 'TTCY', 'TTID');
+    create_index_if_absent('RY_TTCY_FK', 'TTCY', 'RYID');
+    create_index_if_absent('TT_TTWCY_FK', 'TTWCY', 'TTID');
+    create_index_if_absent('TTWCYLB_TTWCY_FK', 'TTWCY', 'TTWCYLBM');
+    create_index_if_absent('RY_TTWCY_FK', 'TTWCY', 'RYID');
+
+    create_fk_if_absent('FK_RY_TT_FZ', 'TT', 'FZRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_BM_TT_FZ', 'TT', 'FZBMID', 'BM', 'BMID');
+    create_fk_if_absent('FK_RY_TT_CJRYID', 'TT', 'CJRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_RY_TT_GLRYID', 'TT', 'GLRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_BM_TT_GLBMID', 'TT', 'GLBMID', 'BM', 'BMID');
+    create_fk_if_absent('FK_JLZT_TT_JLZTM', 'TT', 'JLZTM', 'JLZT', 'JLZTM');
+    create_fk_if_absent('FK_RY_TTCY', 'TTCY', 'RYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_RY_TTCY_CJRYID', 'TTCY', 'CJRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_RY_TTCY_GLRYID', 'TTCY', 'GLRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_BM_TTCY_GLBMID', 'TTCY', 'GLBMID', 'BM', 'BMID');
+    create_fk_if_absent('FK_JLZT_TTCY_JLZTM', 'TTCY', 'JLZTM', 'JLZT', 'JLZTM');
+    create_fk_if_absent('FK_RY_TTWCY', 'TTWCY', 'RYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_RY_TTWCY_CJRYID', 'TTWCY', 'CJRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_RY_TTWCY_GLRYID', 'TTWCY', 'GLRYID', 'RY', 'RYID');
+    create_fk_if_absent('FK_BM_TTWCY_GLBMID', 'TTWCY', 'GLBMID', 'BM', 'BMID');
+    create_fk_if_absent('FK_JLZT_TTWCY_JLZTM', 'TTWCY', 'JLZTM', 'JLZT', 'JLZTM');
+end;
+/
+
+merge into TTLB t
+using (
+    select 1 TTLBM, '团委学生会' MC from dual union all
+    select 11, '部门学生会' from dual union all
+    select 21, '国旗队' from dual union all
+    select 51, '宿管' from dual union all
+    select 61, '卫生督导' from dual union all
+    select 71, '社团' from dual
+) s
+   on (t.TTLBM = s.TTLBM)
+when matched then update set t.MC = s.MC
+when not matched then insert (TTLBM, MC) values (s.TTLBM, s.MC);
+/
+
+merge into TTWCYLB t
+using (
+    select 101 TTWCYLBM, 1 TTLBM, '主席团' MC, 1 BJJF from dual union all
+    select 111, 1, '部长', 0.5 from dual union all
+    select 151, 1, '成员', 0.25 from dual union all
+    select 1101, 11, '主席团', 0.5 from dual union all
+    select 1111, 11, '部长', 0.2 from dual union all
+    select 1151, 11, '成员', 0.1 from dual union all
+    select 2101, 21, '队长', 0.5 from dual union all
+    select 2111, 21, '旗手', 0.5 from dual union all
+    select 2151, 21, '成员', 0.25 from dual union all
+    select 5101, 51, '部长', 0.5 from dual union all
+    select 5151, 51, '成员', 0.25 from dual union all
+    select 6101, 61, '中队长', 1 from dual union all
+    select 6111, 61, '组长', 0.5 from dual union all
+    select 6151, 61, '成员', 0.25 from dual union all
+    select 7101, 71, '社长', 0.05 from dual union all
+    select 7151, 71, '成员', 0.05 from dual
+) s
+   on (t.TTWCYLBM = s.TTWCYLBM)
+when matched then
+     update set t.TTLBM = s.TTLBM, t.MC = s.MC, t.BJJF = s.BJJF
+when not matched then
+     insert (TTWCYLBM, TTLBM, MC, BJJF)
+     values (s.TTWCYLBM, s.TTLBM, s.MC, s.BJJF);
+/
+
+commit;
+/