ソースを参照

feat(sqljc): 升旗礼部门批量评分自动带出值日/请假人数

harper 4 日 前
親
コミット
38e877459e

+ 109 - 0
docs/24_星级班班主任移动报表/2026-12-01_升旗礼部门批量评分人数自动带出实施方案.md

@@ -0,0 +1,109 @@
+# 2026-12-01 升旗礼部门批量评分「免出勤人数」自动带出实施方案
+
+## 1. 背景与目标
+
+「升旗礼检查 → 部门批量评分」页面(`sqljc_deptAdd`)选中部门后,目前只有
+「学员总人数」「请假人数」自动带出,其余免出勤人数需检查人员手工填写。
+
+本次目标:选中部门后,自动带出该部门下当天的:
+
+```text
+部门值日人数    = 信息技术部学生会 当天值班人员(RCCY)中属于该部门的人数
+学校值日人数    = 团委学生会      当天值班人员(RCCY)中属于该部门的人数
+国旗队人数      = 国旗队          当天值班人员(RCCY)中属于该部门的人数
+参与宿管人数    = 宿管            当天值班人员(RCCY)中属于该部门的人数
+请假人数        = 学生日程请假人员(已有逻辑)
+公假人数        = 暂不统计,固定 0
+队列人数        = 学员总人数 − 上述免出勤人数之和
+```
+
+值班人员取 `RCCY`,有则统计、没有则为 0。
+
+## 2. 现状
+
+相关代码在 `src/biz/bjpj/SqljcServ.java`:
+
+- `deptInitByA`:部门批量评分初始化,当前只算 `total`(学员总人数)和
+  `leave`(请假人数),队列人数默认 = `total - leave`。
+- `initAddByA`:单部门录入页初始化,同样只算 `total`、`leave`。
+- `decorateJcxmList`:把 total/queue/leave 写到检查项目默认值。
+- `rdDeptStudentCount`:按部门统计学员总人数。
+- `rdLeaveCount`:按部门 + 检查日 08:00 统计请假人数(事假 9 / 病假 11)。
+
+检查项目码定义在 `src/biz/bjpj/SqljcC.java`:
+
+```text
+1 总人数  2 队列人数  3 部门值日人数  4 学校值日人数
+5 国旗队人数  6 公假人数  7 参与宿管人数  8 请假人数
+```
+
+## 3. 方案
+
+### 3.1 常量(SqljcC)
+
+增加值班类别和 4 个固定团体名称:
+
+```java
+RCLB_ZB = 75                 // 值班
+DUTY_TT_BMZR = "信息技术部学生会"
+DUTY_TT_XXZR = "团委学生会"
+DUTY_TT_GQD  = "国旗队"
+DUTY_TT_SG   = "宿管"
+```
+
+团体按名称查 `TT.TTID`,不硬编码 ID(避免各环境 ID 不一致)。
+
+### 3.2 值班人数统计(SqljcServ 新增)
+
+`rdDutyCount(gdba, bmid, inspectionAt, ttid)`:
+
+```text
+RC(RCLBM=75, DXID=ttid, KSSJ<=检查日08:00<=JSSJ, 有效)
+  → RCCY(JLZTM=51, RCID=rc.RCID) 去重 RYID
+  → BJCY → BJ → ZY → FZBMID = bmid   (复用 rdLeaveCount 的部门口径)
+```
+
+`rdTtidByMc(gdba, mc)`:按团体名称查有效 `TT.TTID`,不存在返回 0(对应人数按 0)。
+
+### 3.3 默认值装饰改造
+
+`decorateJcxmList` 改为接收 `Map<Integer,Integer> countDefaults`,按码填默认值。
+
+`deptInitByA` / `initAddByA` 统一走新增的 `rdCountDefaults(gdba, bmid, inspectionAt)`:
+
+```text
+total   = rdDeptStudentCount
+bmzr    = rdDutyCount(信息技术部学生会)
+xxzr    = rdDutyCount(团委学生会)
+gqd     = rdDutyCount(国旗队)
+sg      = rdDutyCount(宿管)
+gj      = 0
+qj      = rdLeaveCount
+queue   = max(0, total - bmzr - xxzr - gqd - gj - sg - qj)
+```
+
+### 3.4 页面文案
+
+`sqljc_deptAdd.ss.jsp` 顶部提示改为:值日类与请假人数按检查日自动带出,公假暂不
+统计,检查人员可按实际调整。
+
+## 4. 改动文件
+
+```text
+src/biz/bjpj/SqljcC.java
+src/biz/bjpj/SqljcServ.java
+web/page/biz/sqljc_deptAdd.ss.jsp
+```
+
+## 5. 测试要点
+
+1. 选部门后,总人数、队列人数、4 个值日人数、请假人数自动带出,公假为 0。
+2. 队列人数 = 总人数 − 免出勤人数之和。
+3. 无值班人员时,值日人数为 0,不报错。
+4. 修改检查日期后重新加载,人数随日期变化。
+5. 单部门录入页(`sqljc_addInp`)同步生效。
+
+## 6. 回滚
+
+恢复 `SqljcC`、`SqljcServ`、`sqljc_deptAdd.ss.jsp` 三个文件并重新编译、`SerCfg.jsp`、
+页面编译、重启即可。无数据库结构变更。

+ 9 - 0
src/biz/bjpj/SqljcC.java

@@ -22,6 +22,15 @@ public final class SqljcC {
     public static final int JCXM_FZFS = 23;
     public static final int JCXM_JLFS = 31;
 
+    /** 值班日程类别(RC.RCLBM)。Lin */
+    public static final int RCLB_ZB = 75;
+
+    /** 免出勤值日人数对应的固定团体名称。Lin */
+    public static final String DUTY_TT_BMZR = "信息技术部学生会";
+    public static final String DUTY_TT_XXZR = "团委学生会";
+    public static final String DUTY_TT_GQD = "国旗队";
+    public static final String DUTY_TT_SG = "宿管";
+
     public static final Set<Integer> COUNT_CODES = Set.of(
             JCXM_ZRS, JCXM_DLRS, JCXM_BMZRRS, JCXM_XXZRRS,
             JCXM_GQDZRRS, JCXM_GJRS, JCXM_SGZRRS, JCXM_QJRS);

+ 81 - 18
src/biz/bjpj/SqljcServ.java

@@ -103,8 +103,7 @@ public class SqljcServ extends Serv {
 
             List<Map<String, Object>> departments = rdDeptList(gdba);
             Long bmid = rdLongObj(request.getParameter("bmid"));
-            int total = 0;
-            int leave = 0;
+            Map<Integer, Integer> countDefaults = new HashMap<>();
             String bmmc = null;
             int classCount = 0;
             if (bmid != null) {
@@ -116,13 +115,12 @@ public class SqljcServ extends Serv {
                 if (classes.isEmpty())
                     throw new IllegalArgumentException("所选部门没有有效班级");
                 classCount = classes.size();
-                total = rdDeptStudentCount(gdba, bmid);
-                leave = rdLeaveCount(gdba, bmid, inspectionAt);
+                countDefaults = rdCountDefaults(gdba, bmid, inspectionAt);
                 bmmc = rdBmMc(gdba, bmid);
             }
 
             List<Map<String, Object>> jcxmList = rdJcxmList(gdba);
-            decorateJcxmList(jcxmList, total, 0, leave);
+            decorateJcxmList(jcxmList, countDefaults);
 
             Map<String, Object> data = new LinkedHashMap<>();
             data.put("jcxmList", jcxmList);
@@ -242,6 +240,7 @@ public class SqljcServ extends Serv {
             int total = 0;
             int leave = 0;
             String bmmc = null;
+            Map<Integer, Integer> countDefaults = new HashMap<>();
             if (selectedBmid != null) {
                 requireSelectableDept(departments, bmid);
                 classes = rdDeptClassList(gdba, bmid);
@@ -249,11 +248,11 @@ public class SqljcServ extends Serv {
                     throw new IllegalArgumentException("所选部门没有有效班级");
 
                 Timestamp inspectionAt = Timestamp.valueOf(day.atTime(8, 0));
-                total = rdDeptStudentCount(gdba, bmid);
-                leave = rdLeaveCount(gdba, bmid, inspectionAt);
+                countDefaults = rdCountDefaults(gdba, bmid, inspectionAt);
+                total = countDefaults.getOrDefault(SqljcC.JCXM_ZRS, 0);
+                leave = countDefaults.getOrDefault(SqljcC.JCXM_QJRS, 0);
                 jcxmList = rdJcxmList(gdba);
-                decorateJcxmList(jcxmList, total,
-                        Math.max(0, total - leave), leave);
+                decorateJcxmList(jcxmList, countDefaults);
                 bmmc = rdBmMc(gdba, bmid);
             }
 
@@ -444,6 +443,77 @@ public class SqljcServ extends Serv {
         return gdba.rowNum > 0 ? gdba.rdIntCol("cnt") : 0;
     }
 
+    private Map<Integer, Integer> rdCountDefaults(Db gdba, long bmid,
+                                                  Timestamp inspectionAt)
+            throws Exception {
+        int total = rdDeptStudentCount(gdba, bmid);
+        int bmzr = rdDutyCount(gdba, bmid, inspectionAt,
+                rdTtidByMc(gdba, SqljcC.DUTY_TT_BMZR));
+        int xxzr = rdDutyCount(gdba, bmid, inspectionAt,
+                rdTtidByMc(gdba, SqljcC.DUTY_TT_XXZR));
+        int gqd = rdDutyCount(gdba, bmid, inspectionAt,
+                rdTtidByMc(gdba, SqljcC.DUTY_TT_GQD));
+        int sg = rdDutyCount(gdba, bmid, inspectionAt,
+                rdTtidByMc(gdba, SqljcC.DUTY_TT_SG));
+        int gj = 0;    // 公假暂不统计。Lin
+        int qj = rdLeaveCount(gdba, bmid, inspectionAt);
+        int queue = Math.max(0, total - bmzr - xxzr - gqd - gj - sg - qj);
+
+        Map<Integer, Integer> defaults = new HashMap<>();
+        defaults.put(SqljcC.JCXM_ZRS, total);
+        defaults.put(SqljcC.JCXM_DLRS, queue);
+        defaults.put(SqljcC.JCXM_BMZRRS, bmzr);
+        defaults.put(SqljcC.JCXM_XXZRRS, xxzr);
+        defaults.put(SqljcC.JCXM_GQDZRRS, gqd);
+        defaults.put(SqljcC.JCXM_GJRS, gj);
+        defaults.put(SqljcC.JCXM_SGZRRS, sg);
+        defaults.put(SqljcC.JCXM_QJRS, qj);
+        return defaults;
+    }
+
+    private long rdTtidByMc(Db gdba, String mc) throws Exception {
+        SqlCmd sqlc = new SqlCmd(
+                "select TTID from TT where MC=:mc and "
+                        + ObjC.JLZT_useStr + " order by TTID");
+        sqlc.wrStrParm("mc", mc);
+        gdba.doSelByC(sqlc);
+        return gdba.rowNum > 0 ? gdba.rdLongCol("ttid") : 0L;
+    }
+
+    private int rdDutyCount(Db gdba, long bmid, Timestamp inspectionAt,
+                            long ttid) throws Exception {
+        if (ttid <= 0)
+            return 0;
+        SqlCmd sqlc = new SqlCmd(
+                "select count(distinct cy.RYID) CNT from RCCY cy"
+                        + " inner join RC rc on rc.RCID=cy.RCID"
+                        + " where rc.RCLBM=" + SqljcC.RCLB_ZB
+                        + " and rc.DXID=:ttid"
+                        + " and rc.KSSJ<=:inspectionStart"
+                        + " and rc.JSSJ>=:inspectionEnd"
+                        + " and rc." + ObjC.JLZT_useStr
+                        + " and cy.JLZTM=" + ObjC.JLZT_inUse
+                        + " and exists(select 1 from BJCY bc"
+                        + " inner join BJ b on b.BJID=bc.BJID"
+                        + " inner join ZY z on z.ZYID=b.ZYID"
+                        + " inner join RY ry on ry.RYID=bc.RYID"
+                        + " where bc.RYID=cy.RYID and bc."
+                        + ObjC.JLZT_useStr
+                        + " and nvl(bc.SFBY,0)=0 and z.FZBMID=:bmid"
+                        + " and b.BJZTM<>:endState"
+                        + " and b." + ObjC.JLZT_useStr
+                        + " and ry.RYZTM=" + RyC.RYZT_zd
+                        + " and ry.RYLBM=" + RyC.RYLB_xy
+                        + " and ry." + ObjC.JLZT_useStr + ")");
+        sqlc.wrLongParm("ttid", ttid);
+        sqlc.wrTimeParm("inspectionStart", inspectionAt);
+        sqlc.wrTimeParm("inspectionEnd", inspectionAt);
+        sqlc.wrLongParm("bmid", bmid);
+        sqlc.wrIntParm("endState", BjC.BJZT_end);
+        gdba.doSelByC(sqlc);
+        return gdba.rowNum > 0 ? gdba.rdIntCol("cnt") : 0;
+    }
+
     private int rdLeaveCount(Db gdba, long bmid, Timestamp inspectionAt)
             throws Exception {
         SqlCmd sqlc = new SqlCmd(
@@ -489,7 +559,7 @@ public class SqljcServ extends Serv {
     }
 
     private void decorateJcxmList(List<Map<String, Object>> jcxmList,
-                                  int total, int queue, int leave) {
+                                  Map<Integer, Integer> countDefaults) {
         Set<Integer> codes = new LinkedHashSet<>();
         for (Map<String, Object> item : jcxmList)
             codes.add(rdIntValue(item.get("sqljcxmm"), 0));
@@ -505,14 +575,7 @@ public class SqljcServ extends Serv {
             item.put("minValue", 0);
             if (countItem) {
                 item.put("mfz", null);
-                int defaultValue = 0;
-                if (code == SqljcC.JCXM_ZRS)
-                    defaultValue = total;
-                else if (code == SqljcC.JCXM_DLRS)
-                    defaultValue = queue;
-                else if (code == SqljcC.JCXM_QJRS)
-                    defaultValue = leave;
-                item.put("defaultValue", defaultValue);
+                item.put("defaultValue", countDefaults.getOrDefault(code, 0));
             } else {
                 item.put("defaultValue", ckz != null ? ckz
                         : (mfz == null ? 0 : mfz));

+ 2 - 2
web/page/biz/sqljc_deptAdd.ss.jsp

@@ -35,8 +35,8 @@
 
 			<div style="padding: 10px 15px;color:#666;">
 				本部门所有有效班级将使用同一组评分。免出勤人数包括部门值日、学校值日、
-				国旗队、公假、宿管值日和请假;请假人数按检查日 08:00 自动带出,
-				其余值日人数由检查人员据实填写。
+				国旗队、公假、宿管值日和请假;部门值日、学校值日、国旗队、宿管值日和
+				请假人数按检查日自动带出,公假暂不统计,检查人员可按实际调整。
 			</div>
 
 			<div class="row" style="margin:10px 15px 4px;font-weight:600;color:#333;">