|
|
@@ -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;
|