浏览代码

feat(starclass): unify discipline scoring with school violations

apple 3 周之前
父节点
当前提交
5129964337
共有 4 个文件被更改,包括 330 次插入 和 44 次删除
  1. 184 22
      src/biz/bj/BjStarClassMpServ.java
  2. 35 7
      src/biz/bj/XjbJfServ.java
  3. 92 15
      src/biz/bj/XjbMonthCloseServ.java
  4. 19 0
      src/biz/bj/XjbWjlbC.java

+ 184 - 22
src/biz/bj/BjStarClassMpServ.java

@@ -421,7 +421,7 @@ public class BjStarClassMpServ extends Serv {
         book.attendance = computeAttendanceScores(
                 classes, schoolDays, attendancePenalty);
         book.dorm = rdDormScores(db, classes, period, book.attendance);
-        book.discipline = rdDisciplineScores(db, period);
+        book.discipline = rdDisciplineScores(db, classes, schoolDays, period);
         book.adjustments = rdAdjustmentTotals(db, period.month);
 
         for (ClassInfo cls : classes) {
@@ -508,8 +508,10 @@ public class BjStarClassMpServ extends Serv {
                         + "case when w.WJLXM=5 then 0 else w.WJJLID end"
                         + " order by w.WJJLID) RN"
                         + " from WJJL w inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DORM + " and wm.JLZTM=51"
                         + " where w.WJSJ>=:start and w.WJSJ<:end"
-                        + " and w.WJLBM>=20 and w.JLZTM=51)"
+                        + " and w.JLZTM=51)"
                         + " where RN=1 group by BJID");
         violationCmd.wrTimeParm("start", period.start);
         violationCmd.wrTimeParm("end", period.end);
@@ -536,15 +538,80 @@ public class BjStarClassMpServ extends Serv {
 
 
     private static Map<Long, Double> rdDisciplineScores(
-            Db db, MonthPeriod period) throws Exception {
-        SqlCmd sqlc = new SqlCmd(
-                "select BJID,avg(case when WJRS>=100 then 0"
-                        + " else 100-WJRS end) SCORE from XJB_FJRY"
-                        + " where JCRQ>=:start and JCRQ<:end"
-                        + " and JLZTM=51 group by BJID");
-        sqlc.wrTimeParm("start", period.start);
-        sqlc.wrTimeParm("end", period.end);
-        return rdScoreMap(db.doSelMapListByC(sqlc));
+            Db db, List<ClassInfo> classes, Set<LocalDate> schoolDays,
+            MonthPeriod period) throws Exception {
+        Map<Long, Double> result = new HashMap<>();
+        if (schoolDays.isEmpty())
+            return result;
+        DisciplinePenalties penalties = rdDisciplinePenalties(
+                db, null, period.start, period.end);
+        for (ClassInfo cls : classes) {
+            Map<LocalDate, Double> mapped = penalties.mapped.getOrDefault(
+                    cls.bjid, Collections.emptyMap());
+            Map<LocalDate, Double> legacy = penalties.legacy.getOrDefault(
+                    cls.bjid, Collections.emptyMap());
+            double total = 0.0;
+            for (LocalDate day : schoolDays)
+                total += Math.max(0.0, 100.0
+                        - disciplinePenalty(mapped, legacy, day));
+            result.put(cls.bjid, round2(total / schoolDays.size()));
+        }
+        return result;
+    }
+
+    private static DisciplinePenalties rdDisciplinePenalties(
+            Db db, Long bjid, Timestamp start, Timestamp end) throws Exception {
+        DisciplinePenalties result = new DisciplinePenalties();
+        String bjFilter = bjid == null ? "" : " and w.BJID=:bjid";
+
+        SqlCmd current = new SqlCmd(
+                "select w.BJID,trunc(w.WJSJ) D,sum(nvl(lb.BJKF,0)) PENALTY"
+                        + " from WJJL w"
+                        + " inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DISCIPLINE
+                        + " and wm.JLZTM=51"
+                        + " where w.WJSJ>=:start and w.WJSJ<:end"
+                        + " and w.JLZTM=51" + bjFilter
+                        + " group by w.BJID,trunc(w.WJSJ)");
+        current.wrTimeParm("start", start);
+        current.wrTimeParm("end", end);
+        if (bjid != null)
+            current.wrLongParm("bjid", bjid);
+        for (Map<String, Object> row : db.doSelMapListByC(current)) {
+            long classId = rdLong(row.get("bjid"));
+            LocalDate day = rdLocalDate(row.get("d"));
+            if (day != null)
+                result.mapped.computeIfAbsent(classId, key -> new HashMap<>())
+                        .put(day, rdDouble(row.get("penalty")));
+        }
+
+        SqlCmd legacy = new SqlCmd(
+                "select BJID,JCRQ D,sum(WJRS) PENALTY from XJB_FJRY"
+                        + " where JCRQ>=:start and JCRQ<:end and JLZTM=51"
+                        + (bjid == null ? "" : " and BJID=:bjid")
+                        + " group by BJID,JCRQ");
+        legacy.wrTimeParm("start", start);
+        legacy.wrTimeParm("end", end);
+        if (bjid != null)
+            legacy.wrLongParm("bjid", bjid);
+        for (Map<String, Object> row : db.doSelMapListByC(legacy)) {
+            long classId = rdLong(row.get("bjid"));
+            LocalDate day = rdLocalDate(row.get("d"));
+            if (day != null)
+                result.legacy.computeIfAbsent(classId, key -> new HashMap<>())
+                        .put(day, rdDouble(row.get("penalty")));
+        }
+        return result;
+    }
+
+    private static double disciplinePenalty(
+            Map<LocalDate, Double> mapped, Map<LocalDate, Double> legacy,
+            LocalDate day) {
+        Double penalty = mapped.get(day);
+        if (penalty == null)
+            penalty = legacy.get(day);
+        return penalty == null ? 0.0 : penalty;
     }
 
 
@@ -750,15 +817,17 @@ public class BjStarClassMpServ extends Serv {
         MonthPeriod fullMonth = MonthPeriod.of(period.month);
         Map<Long, Double> monthClean = rdAvgScoreByClass(db, "CSWSJC", fullMonth);
         Map<Long, Double> monthFlag = rdFlagScoreByClass(db, fullMonth);
+        Set<LocalDate> monthSchoolDays = rdSchoolDays(db, fullMonth);
         Map<Long, Double> monthAttendance = computeAttendanceScores(
-                List.of(cls), rdSchoolDays(db, fullMonth),
+                List.of(cls), monthSchoolDays,
                 rdAttendancePenalty(db, fullMonth));
         Map<Long, Double> monthDorm = rdDormScores(db, List.of(cls),
                 fullMonth, monthAttendance);
         Map<Long, Double> monthClassroom =
                 rdAvgKtjlScoreByClass(db, fullMonth);
         Map<Long, Double> monthDiscipline =
-                rdDisciplineScores(db, fullMonth);
+                rdDisciplineScores(db, List.of(cls), monthSchoolDays,
+                        fullMonth);
         result.sources.put("dorm", monthDorm.containsKey(cls.bjid)
                 ? SOURCE_REAL : SOURCE_MISSING);
         result.sources.put("classroom",
@@ -825,8 +894,10 @@ public class BjStarClassMpServ extends Serv {
                         + "case when w.WJLXM=5 then 0 else w.WJJLID end"
                         + " order by w.WJJLID) RN"
                         + " from WJJL w inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DORM + " and wm.JLZTM=51"
                         + " where w.BJID=:bjid and w.WJSJ>=:start"
-                        + " and w.WJSJ<:end and w.WJLBM>=20 and w.JLZTM=51)"
+                        + " and w.WJSJ<:end and w.JLZTM=51)"
                         + " where RN=1 group by D");
         violationCmd.wrLongParm("bjid", cls.bjid);
         violationCmd.wrTimeParm("start", start);
@@ -859,14 +930,21 @@ public class BjStarClassMpServ extends Serv {
     private static Map<LocalDate, DailyPoint> rdDailyDisciplineScore(
             Db db, long bjid, Timestamp start, Timestamp end)
             throws Exception {
-        SqlCmd sqlc = new SqlCmd(
-                "select JCRQ D,case when WJRS>=100 then 0 else 100-WJRS end"
-                        + " SCORE,1 CNT from XJB_FJRY where BJID=:bjid"
-                        + " and JCRQ>=:start and JCRQ<:end and JLZTM=51");
-        sqlc.wrLongParm("bjid", bjid);
-        sqlc.wrTimeParm("start", start);
-        sqlc.wrTimeParm("end", end);
-        return rdDailyPoints(db.doSelMapListByC(sqlc));
+        DisciplinePenalties penalties = rdDisciplinePenalties(
+                db, bjid, start, end);
+        Map<LocalDate, Double> mapped = penalties.mapped.getOrDefault(
+                bjid, Collections.emptyMap());
+        Map<LocalDate, Double> legacy = penalties.legacy.getOrDefault(
+                bjid, Collections.emptyMap());
+        Set<LocalDate> dates = new LinkedHashSet<>(mapped.keySet());
+        dates.addAll(legacy.keySet());
+        Map<LocalDate, DailyPoint> result = new HashMap<>();
+        for (LocalDate day : dates) {
+            double penalty = disciplinePenalty(mapped, legacy, day);
+            result.put(day, new DailyPoint(day,
+                    Math.max(0.0, 100.0 - penalty), 1));
+        }
+        return result;
     }
 
 
@@ -1026,6 +1104,45 @@ public class BjStarClassMpServ extends Serv {
 
     private static List<Map<String, Object>> rdDisciplineDetail(
             Db db, long bjid, LocalDate day) throws Exception {
+        Timestamp start = Timestamp.valueOf(day.atStartOfDay());
+        Timestamp end = Timestamp.valueOf(day.plusDays(1).atStartOfDay());
+        SqlCmd sqlc = new SqlCmd(
+                "select w.WJJLID,w.RYID,ry.XM,lb.WJLBM,lb.MC WJLBMC,"
+                        + "lb.BJKF,w.WJSJ,w.MS,w.WJLXM"
+                        + " from WJJL w inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DISCIPLINE
+                        + " and wm.JLZTM=51"
+                        + " left join RY ry on ry.RYID=w.RYID"
+                        + " where w.BJID=:bjid and w.WJSJ>=:start"
+                        + " and w.WJSJ<:end and w.JLZTM=51"
+                        + " order by w.WJSJ,w.WJJLID");
+        sqlc.wrLongParm("bjid", bjid);
+        sqlc.wrTimeParm("start", start);
+        sqlc.wrTimeParm("end", end);
+        List<Map<String, Object>> result = new ArrayList<>();
+        for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
+            Map<String, Object> item = baseDetail(day, SOURCE_REAL);
+            item.put("id", rdLong(row.get("wjjlid")));
+            item.put("sourceId", rdLong(row.get("wjjlid")));
+            item.put("category", "discipline");
+            item.put("traceable", true);
+            item.put("itemName", rdStr(row.get("wjlbmc")));
+            item.put("studentName", rdStr(row.get("xm")));
+            item.put("title", rdStr(row.get("wjlbmc")));
+            item.put("remark", rdStr(row.get("ms")));
+            item.put("delta", -rdDouble(row.get("bjkf")));
+            item.put("scoreText", "");
+            item.put("sortTime", formatTimestamp(row.get("wjsj")));
+            result.add(item);
+        }
+        if (result.isEmpty())
+            result.addAll(rdLegacyDisciplineDetail(db, bjid, day));
+        return result;
+    }
+
+    private static List<Map<String, Object>> rdLegacyDisciplineDetail(
+            Db db, long bjid, LocalDate day) throws Exception {
         SqlCmd sqlc = new SqlCmd(
                 "select XJB_FJRYID,WJRS,MS from XJB_FJRY"
                         + " where BJID=:bjid and JCRQ=:jcrq and JLZTM=51");
@@ -1212,6 +1329,45 @@ public class BjStarClassMpServ extends Serv {
     private static Map<String, Object> rdDisciplineTrace(
             Db db, ClassInfo cls, LocalDate day,
             CategoryDef category, long sourceId) throws Exception {
+        SqlCmd current = new SqlCmd(
+                "select w.WJJLID,w.WJSJ,w.MS,w.WJLBM,lb.MC WJLBMC,"
+                        + "lb.BJKF,ry.XM RYXM,cj.XM CJRYXM"
+                        + " from WJJL w inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DISCIPLINE
+                        + " and wm.JLZTM=51"
+                        + " left join RY ry on ry.RYID=w.RYID"
+                        + " left join RY cj on cj.RYID=w.CJRYID"
+                        + " where w.WJJLID=:id and w.BJID=:bjid"
+                        + " and w.JLZTM=51");
+        current.wrLongParm("id", sourceId);
+        current.wrLongParm("bjid", cls.bjid);
+        List<Map<String, Object>> currentRows =
+                db.doSelMapListByC(current);
+        if (currentRows != null && !currentRows.isEmpty()) {
+            Map<String, Object> row = currentRows.get(0);
+            double deducted = rdDouble(row.get("bjkf"));
+            Map<String, Object> record = new LinkedHashMap<>();
+            record.put("time", formatTimestamp(row.get("wjsj")));
+            record.put("className", cls.bjmc);
+            record.put("inspectorName", rdStr(row.get("cjryxm")));
+            record.put("studentName", rdStr(row.get("ryxm")));
+            record.put("description", rdStr(row.get("ms")));
+            List<Map<String, Object>> items = new ArrayList<>();
+            Map<String, Object> item = new LinkedHashMap<>();
+            item.put("itemName", rdStr(row.get("wjlbmc")));
+            item.put("deducted", deducted);
+            item.put("remark", rdStr(row.get("ms")));
+            items.add(item);
+            return traceResult(cls, day, category, SOURCE_REAL,
+                    "风纪仪容扣分详情", record, items, "");
+        }
+        return rdLegacyDisciplineTrace(db, cls, day, category, sourceId);
+    }
+
+    private static Map<String, Object> rdLegacyDisciplineTrace(
+            Db db, ClassInfo cls, LocalDate day,
+            CategoryDef category, long sourceId) throws Exception {
         SqlCmd sqlc = new SqlCmd(
                 "select XJB_FJRYID,JCRQ,WJRS,MS from XJB_FJRY"
                         + " where XJB_FJRYID=:id and BJID=:bjid and JLZTM=51");
@@ -1974,6 +2130,12 @@ public class BjStarClassMpServ extends Serv {
     }
 
 
+    private static final class DisciplinePenalties {
+        final Map<Long, Map<LocalDate, Double>> mapped = new HashMap<>();
+        final Map<Long, Map<LocalDate, Double>> legacy = new HashMap<>();
+    }
+
+
     private static final class Adjustment {
         final long id;
         final LocalDate date;

+ 35 - 7
src/biz/bj/XjbJfServ.java

@@ -259,9 +259,12 @@ public class XjbJfServ extends Serv {
                 "select w.WJJLID ID,w.RYID,w.WJSJ FSSJ,w.WJLBM LYLB,"
                         + "l.MC LBMC,l.BJKF JFZ,w.MS DESCRIPTION,r.XM RYXM"
                         + " from WJJL w inner join WJLB l on l.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_SCHOOL
+                        + " and wm.JLZTM=51"
                         + " left join RY r on r.RYID=w.RYID"
                         + " where w.BJID=:bjid and w.JLZTM=51"
-                        + " and w.WJLBM<20 and w.WJSJ>=:start and w.WJSJ<:end"
+                        + " and w.WJSJ>=:start and w.WJSJ<:end"
                         + " and nvl(l.BJKF,0)>0 order by w.WJJLID");
         sqlc.wrLongParm("bjid", bjid);
         sqlc.wrTimeParm("start", start);
@@ -345,12 +348,25 @@ public class XjbJfServ extends Serv {
                 .atStartOfDay());
         SqlCmd countCmd = new SqlCmd(
                 "select count(*) CNT from WJJL w"
-                        + " where w.BJID=:bjid and w.JLZTM=51 and w.WJLBM<20"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM in(" + XjbWjlbC.YTM_DISCIPLINE
+                        + "," + XjbWjlbC.YTM_SCHOOL + ") and wm.JLZTM=51"
+                        + " where w.BJID=:bjid and w.JLZTM=51"
                         + " and w.WJSJ>=:start and w.WJSJ<:end");
         countCmd.wrLongParm("bjid", bjid);
         countCmd.wrTimeParm("start", start);
         countCmd.wrTimeParm("end", end);
         db.doSelByC(countCmd);
+        if (db.rowNum > 0 && db.rdIntCol("cnt") > 0)
+            return 0;
+        SqlCmd legacyCmd = new SqlCmd(
+                "select count(*) CNT from XJB_FJRY"
+                        + " where BJID=:bjid and JCRQ>=:start and JCRQ<:end"
+                        + " and JLZTM=51 and WJRS>0");
+        legacyCmd.wrLongParm("bjid", bjid);
+        legacyCmd.wrTimeParm("start", start);
+        legacyCmd.wrTimeParm("end", end);
+        db.doSelByC(legacyCmd);
         if (db.rowNum > 0 && db.rdIntCol("cnt") > 0)
             return 0;
 
@@ -369,15 +385,27 @@ public class XjbJfServ extends Serv {
         Timestamp end = Timestamp.valueOf(month.plusMonths(1).atDay(1)
                 .atStartOfDay());
         SqlCmd countCmd = new SqlCmd(
-                "select count(*) DAYS,nvl(sum(WJRS),0) WJRS from XJB_FJRY"
-                        + " where BJID=:bjid and JCRQ>=:start and JCRQ<:end"
-                        + " and JLZTM=51");
+                "select count(*) CNT from WJJL w"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DISCIPLINE
+                        + " and wm.JLZTM=51"
+                        + " where w.BJID=:bjid and w.JLZTM=51"
+                        + " and w.WJSJ>=:start and w.WJSJ<:end");
         countCmd.wrLongParm("bjid", bjid);
         countCmd.wrTimeParm("start", start);
         countCmd.wrTimeParm("end", end);
         db.doSelByC(countCmd);
-        if (db.rowNum == 0 || db.rdIntCol("days") == 0
-                || db.rdIntCol("wjrs") > 0)
+        if (db.rowNum > 0 && db.rdIntCol("cnt") > 0)
+            return 0;
+        SqlCmd legacyCmd = new SqlCmd(
+                "select count(*) CNT from XJB_FJRY"
+                        + " where BJID=:bjid and JCRQ>=:start and JCRQ<:end"
+                        + " and JLZTM=51 and WJRS>0");
+        legacyCmd.wrLongParm("bjid", bjid);
+        legacyCmd.wrTimeParm("start", start);
+        legacyCmd.wrTimeParm("end", end);
+        db.doSelByC(legacyCmd);
+        if (db.rowNum > 0 && db.rdIntCol("cnt") > 0)
             return 0;
 
         long syntheticId = month.getYear() * 100L + month.getMonthValue();

+ 92 - 15
src/biz/bj/XjbMonthCloseServ.java

@@ -272,8 +272,9 @@ public class XjbMonthCloseServ extends Serv {
                 "select BJID,avg(FS) SCORE from CSWSJC"
                         + " where JCSJ>=:start and JCSJ<:end and "
                         + ObjC.JLZT_useStr + " group by BJID", start, end);
+        Set<LocalDate> schoolDays = rdSchoolDays(db, start, end);
         Map<Long, DisciplineScore> discipline =
-                rdDisciplineScores(db, start, end);
+                rdDisciplineScores(db, classes, schoolDays, start, end);
         Map<Long, Double> attendance = rdAttendanceScores(db, classes,
                 start, end);
         Map<Long, DormScore> dorm = rdDormScores(db, classes, start, end);
@@ -330,22 +331,91 @@ public class XjbMonthCloseServ extends Serv {
     }
 
     private Map<Long, DisciplineScore> rdDisciplineScores(
+            Db db, List<ClassRow> classes, Set<LocalDate> schoolDays,
+            Timestamp start, Timestamp end) throws Exception {
+        Map<Long, DisciplineScore> result = new HashMap<>();
+        if (schoolDays.isEmpty())
+            return result;
+        DisciplinePenalties penalties = rdDisciplinePenalties(
+                db, start, end);
+        for (ClassRow cls : classes) {
+            Map<LocalDate, Double> mapped = penalties.mapped.getOrDefault(
+                    cls.bjid, Collections.emptyMap());
+            Map<LocalDate, Double> legacy = penalties.legacy.getOrDefault(
+                    cls.bjid, Collections.emptyMap());
+            Set<LocalDate> violationDays = new LinkedHashSet<>(mapped.keySet());
+            violationDays.addAll(legacy.keySet());
+            double totalScore = 0.0;
+            double totalPenalty = 0.0;
+            for (LocalDate day : schoolDays) {
+                Double dayPenalty = mapped.get(day);
+                if (dayPenalty == null)
+                    dayPenalty = legacy.get(day);
+                if (dayPenalty == null)
+                    dayPenalty = 0.0;
+                totalPenalty += dayPenalty;
+                totalScore += Math.max(0.0, 100.0 - dayPenalty);
+            }
+            DisciplineScore score = new DisciplineScore();
+            score.value = round2(totalScore / schoolDays.size());
+            score.violations = round2(totalPenalty);
+            score.days = violationDays.size();
+            result.put(cls.bjid, score);
+        }
+        return result;
+    }
+
+    private Set<LocalDate> rdSchoolDays(
             Db db, Timestamp start, Timestamp end) throws Exception {
         SqlCmd sqlc = new SqlCmd(
-                "select BJID,avg(case when WJRS>=100 then 0"
-                        + " else 100-WJRS end) SCORE,sum(WJRS) WJRS,"
-                        + "count(*) DAYS from XJB_FJRY"
-                        + " where JCRQ>=:start and JCRQ<:end"
-                        + " and JLZTM=51 group by BJID");
+                "select distinct trunc(KSSJ) D from KQJL"
+                        + " where KSSJ>=:start and KSSJ<:end"
+                        + " and KQJLZTM=51 and " + ObjC.JLZT_useStr);
         sqlc.wrTimeParm("start", start);
         sqlc.wrTimeParm("end", end);
-        Map<Long, DisciplineScore> result = new HashMap<>();
+        Set<LocalDate> result = new LinkedHashSet<>();
         for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
-            DisciplineScore score = new DisciplineScore();
-            score.value = rdDouble(row.get("score"));
-            score.violations = rdInt(row.get("wjrs"));
-            score.days = rdInt(row.get("days"));
-            result.put(rdLong(row.get("bjid"), 0L), score);
+            LocalDate day = rdLocalDate(row.get("d"));
+            if (day != null)
+                result.add(day);
+        }
+        return result;
+    }
+
+    private DisciplinePenalties rdDisciplinePenalties(
+            Db db, Timestamp start, Timestamp end) throws Exception {
+        DisciplinePenalties result = new DisciplinePenalties();
+        SqlCmd current = new SqlCmd(
+                "select w.BJID,trunc(w.WJSJ) D,sum(nvl(lb.BJKF,0)) PENALTY"
+                        + " from WJJL w"
+                        + " inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DISCIPLINE
+                        + " and wm.JLZTM=51"
+                        + " where w.WJSJ>=:start and w.WJSJ<:end"
+                        + " and w.JLZTM=51 group by w.BJID,trunc(w.WJSJ)");
+        current.wrTimeParm("start", start);
+        current.wrTimeParm("end", end);
+        for (Map<String, Object> row : db.doSelMapListByC(current)) {
+            long bjid = rdLong(row.get("bjid"), 0L);
+            LocalDate day = rdLocalDate(row.get("d"));
+            if (day != null)
+                result.mapped.computeIfAbsent(bjid, key -> new HashMap<>())
+                        .put(day, rdDouble(row.get("penalty")));
+        }
+
+        SqlCmd legacy = new SqlCmd(
+                "select BJID,JCRQ D,sum(WJRS) PENALTY from XJB_FJRY"
+                        + " where JCRQ>=:start and JCRQ<:end"
+                        + " and JLZTM=51 group by BJID,JCRQ");
+        legacy.wrTimeParm("start", start);
+        legacy.wrTimeParm("end", end);
+        for (Map<String, Object> row : db.doSelMapListByC(legacy)) {
+            long bjid = rdLong(row.get("bjid"), 0L);
+            LocalDate day = rdLocalDate(row.get("d"));
+            if (day != null)
+                result.legacy.computeIfAbsent(bjid, key -> new HashMap<>())
+                        .put(day, rdDouble(row.get("penalty")));
         }
         return result;
     }
@@ -428,8 +498,10 @@ public class XjbMonthCloseServ extends Serv {
                         + "case when w.WJLXM=5 then 0 else w.WJJLID end"
                         + " order by w.WJJLID) RN"
                         + " from WJJL w inner join WJLB lb on lb.WJLBM=w.WJLBM"
+                        + " inner join XJB_WJLBMAP wm on wm.WJLBM=w.WJLBM"
+                        + " and wm.YTM=" + XjbWjlbC.YTM_DORM + " and wm.JLZTM=51"
                         + " where w.WJSJ>=:start and w.WJSJ<:end"
-                        + " and w.WJLBM>=20 and w.JLZTM=51)"
+                        + " and w.JLZTM=51)"
                         + " where RN=1 group by BJID");
         violationCmd.wrTimeParm("start", start);
         violationCmd.wrTimeParm("end", end);
@@ -497,7 +569,7 @@ public class XjbMonthCloseServ extends Serv {
             return item;
         item.value = round2(score.value);
         item.source = SOURCE_REAL;
-        item.detail = "违纪" + score.violations + "人次,登记"
+        item.detail = "扣分" + score.violations + ",登记"
                 + score.days + "天";
         return item;
     }
@@ -804,10 +876,15 @@ public class XjbMonthCloseServ extends Serv {
 
     private static final class DisciplineScore {
         double value;
-        int violations;
+        double violations;
         int days;
     }
 
+    private static final class DisciplinePenalties {
+        final Map<Long, Map<LocalDate, Double>> mapped = new HashMap<>();
+        final Map<Long, Map<LocalDate, Double>> legacy = new HashMap<>();
+    }
+
     private static final class DormScore {
         double value;
         double internal;

+ 19 - 0
src/biz/bj/XjbWjlbC.java

@@ -0,0 +1,19 @@
+package biz.bj;
+
+/**
+ * 违纪类别的星级班计分用途。
+ */
+public final class XjbWjlbC {
+
+    /** 风纪仪容。 */
+    public static final int YTM_DISCIPLINE = 1;
+
+    /** 学校行政处分。 */
+    public static final int YTM_SCHOOL = 2;
+
+    /** 宿舍违纪。 */
+    public static final int YTM_DORM = 3;
+
+    private XjbWjlbC() {
+    }
+}