|
|
@@ -126,6 +126,8 @@ public class BjStarClassMpServ extends Serv {
|
|
|
ClassScore classScore = scores.classScores.get(selected.bjid);
|
|
|
if (classScore == null)
|
|
|
throw new IllegalStateException("班级评分未生成");
|
|
|
+ PublishedSnapshot snapshot = rdPublishedSnapshot(
|
|
|
+ db, selected.bjid, month);
|
|
|
|
|
|
int pageNo = Math.max(1, rdIntParam(request, "pageNo", 1));
|
|
|
int pageSize = clampPageSize(rdIntParam(request, "pageSize",
|
|
|
@@ -145,19 +147,45 @@ public class BjStarClassMpServ extends Serv {
|
|
|
data.put("dwid", selected.dwid);
|
|
|
data.put("dwmc", selected.dwmc);
|
|
|
data.put("month", month.format(MONTH_FMT));
|
|
|
- data.put("score", round2(classScore.total));
|
|
|
- data.put("starLevel", starLevel(classScore.total));
|
|
|
- data.put("departmentRank", ranks.departmentRank.get(selected.bjid));
|
|
|
- data.put("departmentClassCount", ranks.departmentClassCount.getOrDefault(
|
|
|
- selected.dwid, 0));
|
|
|
- data.put("schoolRank", ranks.schoolRank.get(selected.bjid));
|
|
|
- data.put("schoolClassCount", classes.size());
|
|
|
- data.put("bonusTotal", round2(classScore.adjust.bonus));
|
|
|
- data.put("deductionTotal", round2(classScore.adjust.deduction));
|
|
|
- data.put("bonusCount", classScore.adjust.bonusEvents);
|
|
|
- data.put("deductionCount", classScore.adjust.deductionEvents);
|
|
|
- data.put("rankingPreview", classScore.hasMock);
|
|
|
- data.put("categorySources", scores.categorySources(selected.bjid));
|
|
|
+ if (snapshot != null) {
|
|
|
+ data.put("score", snapshot.total);
|
|
|
+ data.put("starLevel", snapshot.starLevel);
|
|
|
+ data.put("departmentRank", snapshot.departmentRank);
|
|
|
+ data.put("departmentClassCount", snapshot.departmentClassCount);
|
|
|
+ data.put("schoolRank", snapshot.schoolRank);
|
|
|
+ data.put("schoolClassCount", snapshot.schoolClassCount);
|
|
|
+ data.put("bonusTotal", snapshot.bonus);
|
|
|
+ data.put("deductionTotal", snapshot.deduction);
|
|
|
+ data.put("bonusCount", snapshot.bonusCount);
|
|
|
+ data.put("deductionCount", snapshot.deductionCount);
|
|
|
+ data.put("rankingPreview", false);
|
|
|
+ data.put("snapshotPublished", true);
|
|
|
+ data.put("categorySources", snapshot.sources);
|
|
|
+ } else {
|
|
|
+ data.put("score", classScore.hasMissing
|
|
|
+ ? null : round2(classScore.total));
|
|
|
+ data.put("starLevel", classScore.hasMissing
|
|
|
+ ? "待评分" : starLevel(classScore.total,
|
|
|
+ ranks.schoolRank.getOrDefault(selected.bjid, 0)));
|
|
|
+ data.put("departmentRank", classScore.hasMissing
|
|
|
+ ? null : ranks.departmentRank.get(selected.bjid));
|
|
|
+ data.put("departmentClassCount",
|
|
|
+ ranks.departmentClassCount.getOrDefault(
|
|
|
+ selected.dwid, 0));
|
|
|
+ data.put("schoolRank", classScore.hasMissing
|
|
|
+ ? null : ranks.schoolRank.get(selected.bjid));
|
|
|
+ data.put("schoolClassCount", classes.size());
|
|
|
+ data.put("bonusTotal", round2(classScore.adjust.bonus));
|
|
|
+ data.put("deductionTotal",
|
|
|
+ round2(classScore.adjust.deduction));
|
|
|
+ data.put("bonusCount", classScore.adjust.bonusEvents);
|
|
|
+ data.put("deductionCount", classScore.adjust.deductionEvents);
|
|
|
+ data.put("rankingPreview", classScore.hasMissing);
|
|
|
+ data.put("snapshotPublished", false);
|
|
|
+ data.put("categorySources",
|
|
|
+ scores.categorySources(selected.bjid));
|
|
|
+ data.put("missingItems", classScore.missing);
|
|
|
+ }
|
|
|
data.put("pageNo", pageNo);
|
|
|
data.put("pageSize", pageSize);
|
|
|
data.put("total", allDays.size());
|
|
|
@@ -385,7 +413,6 @@ public class BjStarClassMpServ extends Serv {
|
|
|
private static ScoreBook rdScoreBook(Db db, List<ClassInfo> classes,
|
|
|
MonthPeriod period) throws Exception {
|
|
|
ScoreBook book = new ScoreBook();
|
|
|
- book.dorm = rdAvgScoreByClass(db, "SSNWJC", period);
|
|
|
book.cleaning = rdAvgScoreByClass(db, "CSWSJC", period);
|
|
|
book.flag = rdFlagScoreByClass(db, period);
|
|
|
book.classroom = rdAvgKtjlScoreByClass(db, period);
|
|
|
@@ -394,47 +421,50 @@ public class BjStarClassMpServ extends Serv {
|
|
|
rdAttendancePenalty(db, period);
|
|
|
book.attendance = computeAttendanceScores(
|
|
|
classes, schoolDays, attendancePenalty);
|
|
|
+ book.dorm = rdDormScores(db, classes, period, book.attendance);
|
|
|
+ book.discipline = rdDisciplineScores(db, period);
|
|
|
book.adjustments = rdAdjustmentTotals(db, period.month);
|
|
|
|
|
|
for (ClassInfo cls : classes) {
|
|
|
ClassScore score = new ClassScore();
|
|
|
- score.values.put("dorm", scoreOrMock(book.dorm, cls.bjid,
|
|
|
- period.month, "dorm", period.maxDay));
|
|
|
- score.values.put("classroom", scoreOrMissing(
|
|
|
- book.classroom, cls.bjid));
|
|
|
- score.values.put("flag", scoreOrMock(book.flag, cls.bjid,
|
|
|
- period.month, "flag", period.maxDay));
|
|
|
- score.values.put("cleaning", scoreOrMock(book.cleaning, cls.bjid,
|
|
|
- period.month, "cleaning", period.maxDay));
|
|
|
- score.values.put("discipline", mockMonthlyScore(
|
|
|
- cls.bjid, period.month, "discipline", period.maxDay));
|
|
|
- score.values.put("attendance", scoreOrMock(book.attendance,
|
|
|
- cls.bjid, period.month, "attendance", period.maxDay));
|
|
|
- score.sources.put("dorm", book.dorm.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
- score.sources.put("classroom", book.classroom.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MISSING);
|
|
|
- score.sources.put("flag", book.flag.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
- score.sources.put("cleaning", book.cleaning.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
- score.sources.put("discipline", SOURCE_MOCK);
|
|
|
- score.sources.put("attendance", book.attendance.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
+ putScore(score, "dorm", "宿舍评分", book.dorm.get(cls.bjid));
|
|
|
+ putScore(score, "classroom", "课堂考核",
|
|
|
+ book.classroom.get(cls.bjid));
|
|
|
+ putScore(score, "flag", "升旗礼", book.flag.get(cls.bjid));
|
|
|
+ putScore(score, "cleaning", "清洁卫生",
|
|
|
+ book.cleaning.get(cls.bjid));
|
|
|
+ putScore(score, "discipline", "风纪仪容",
|
|
|
+ book.discipline.get(cls.bjid));
|
|
|
+ putScore(score, "attendance", "考勤",
|
|
|
+ book.attendance.get(cls.bjid));
|
|
|
score.adjust = book.adjustments.getOrDefault(
|
|
|
cls.bjid, new AdjustmentTotals());
|
|
|
- double weighted = 0.0;
|
|
|
- for (CategoryDef def : CATEGORY_DEFS)
|
|
|
- weighted += score.values.get(def.code) * def.weight;
|
|
|
- score.total = round2(
|
|
|
- weighted + score.adjust.bonus - score.adjust.deduction);
|
|
|
- score.hasMock = score.sources.containsValue(SOURCE_MOCK)
|
|
|
- || score.sources.containsValue(SOURCE_MISSING);
|
|
|
+ if (score.missing.isEmpty()) {
|
|
|
+ double weighted = 0.0;
|
|
|
+ for (CategoryDef def : CATEGORY_DEFS)
|
|
|
+ weighted += score.values.get(def.code) * def.weight;
|
|
|
+ score.total = round2(weighted
|
|
|
+ + Math.min(8.0, score.adjust.bonus)
|
|
|
+ - score.adjust.deduction);
|
|
|
+ }
|
|
|
+ score.hasMissing = !score.missing.isEmpty();
|
|
|
book.classScores.put(cls.bjid, score);
|
|
|
}
|
|
|
return book;
|
|
|
}
|
|
|
|
|
|
+ private static void putScore(ClassScore score, String code, String label,
|
|
|
+ Double value) {
|
|
|
+ if (value == null) {
|
|
|
+ score.values.put(code, 0.0);
|
|
|
+ score.sources.put(code, SOURCE_MISSING);
|
|
|
+ score.missing.add(label);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ score.values.put(code, round2(value));
|
|
|
+ score.sources.put(code, SOURCE_REAL);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private static Map<Long, Double> rdAvgScoreByClass(Db db, String table,
|
|
|
MonthPeriod period)
|
|
|
@@ -451,6 +481,68 @@ public class BjStarClassMpServ extends Serv {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private static Map<Long, Double> rdDormScores(
|
|
|
+ Db db, List<ClassInfo> classes, MonthPeriod period,
|
|
|
+ Map<Long, Double> attendanceScores) throws Exception {
|
|
|
+ SqlCmd internalCmd = new SqlCmd(
|
|
|
+ "select BJID,"
|
|
|
+ + "avg(case when extract(hour from JCSJ)<12 then FS end) AM,"
|
|
|
+ + "avg(case when extract(hour from JCSJ)>=12 then FS end) PM"
|
|
|
+ + " from SSNWJC where JCSJ>=:start and JCSJ<:end"
|
|
|
+ + " and " + ObjC.JLZT_useStr + " group by BJID");
|
|
|
+ internalCmd.wrTimeParm("start", period.start);
|
|
|
+ internalCmd.wrTimeParm("end", period.end);
|
|
|
+ Map<Long, double[]> internal = new HashMap<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(internalCmd)) {
|
|
|
+ internal.put(rdLong(row.get("bjid")), new double[]{
|
|
|
+ row.get("am") == null ? -1 : rdDouble(row.get("am")),
|
|
|
+ row.get("pm") == null ? -1 : rdDouble(row.get("pm"))
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ SqlCmd violationCmd = new SqlCmd(
|
|
|
+ "select w.BJID,sum(nvl(lb.BJKF,0)) PENALTY from WJJL w"
|
|
|
+ + " inner join WJLB lb on lb.WJLBM=w.WJLBM"
|
|
|
+ + " where w.WJSJ>=:start and w.WJSJ<:end"
|
|
|
+ + " and w.WJLBM>=20 and w.JLZTM=51 group by w.BJID");
|
|
|
+ violationCmd.wrTimeParm("start", period.start);
|
|
|
+ violationCmd.wrTimeParm("end", period.end);
|
|
|
+ Map<Long, Double> violations = new HashMap<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(violationCmd))
|
|
|
+ violations.put(rdLong(row.get("bjid")),
|
|
|
+ rdDouble(row.get("penalty")));
|
|
|
+
|
|
|
+ Map<Long, Double> result = new HashMap<>();
|
|
|
+ for (ClassInfo cls : classes) {
|
|
|
+ double[] values = internal.get(cls.bjid);
|
|
|
+ Double attendance = attendanceScores.get(cls.bjid);
|
|
|
+ if (values == null || values[0] < 0 || values[1] < 0
|
|
|
+ || attendance == null)
|
|
|
+ continue;
|
|
|
+ double internalScore = (values[0] + values[1]) / 2.0;
|
|
|
+ double violationScore = Math.max(0.0,
|
|
|
+ 100.0 - violations.getOrDefault(cls.bjid, 0.0));
|
|
|
+ double base = internalScore * 0.35 + attendance * 0.15
|
|
|
+ + violationScore * 0.35;
|
|
|
+ result.put(cls.bjid, round2(base + base / 85.0 * 10.0));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static Map<Long, Double> rdFlagScoreByClass(Db db,
|
|
|
MonthPeriod period)
|
|
|
throws Exception {
|
|
|
@@ -507,7 +599,7 @@ public class BjStarClassMpServ extends Serv {
|
|
|
Db db, MonthPeriod period) throws Exception {
|
|
|
SqlCmd sqlc = new SqlCmd(
|
|
|
"select BJID,trunc(KSSJ) D,sum(case KQLBM"
|
|
|
- + " when 1 then 3 when 21 then 1 when 51 then 2"
|
|
|
+ + " when 1 then 3 when 21 then 1 when 51 then 1"
|
|
|
+ " when 52 then 1 when 61 then 2 else 0 end) PENALTY"
|
|
|
+ " from KQJL where KSSJ>=:start and KSSJ<:end"
|
|
|
+ " and KQJLZTM=51 and " + ObjC.JLZT_useStr
|
|
|
@@ -550,7 +642,12 @@ public class BjStarClassMpServ extends Serv {
|
|
|
|
|
|
private static RankBook rdRanks(List<ClassInfo> classes, ScoreBook book) {
|
|
|
RankBook ranks = new RankBook();
|
|
|
- List<ClassInfo> school = new ArrayList<>(classes);
|
|
|
+ List<ClassInfo> school = new ArrayList<>();
|
|
|
+ for (ClassInfo cls : classes) {
|
|
|
+ ClassScore score = book.classScores.get(cls.bjid);
|
|
|
+ if (score != null && !score.hasMissing)
|
|
|
+ school.add(cls);
|
|
|
+ }
|
|
|
school.sort(Comparator
|
|
|
.comparingDouble((ClassInfo cls) ->
|
|
|
-book.classScores.get(cls.bjid).total)
|
|
|
@@ -558,7 +655,7 @@ public class BjStarClassMpServ extends Serv {
|
|
|
assignRanks(school, book, ranks.schoolRank, "school");
|
|
|
|
|
|
Map<Long, List<ClassInfo>> departments = new LinkedHashMap<>();
|
|
|
- for (ClassInfo cls : classes)
|
|
|
+ for (ClassInfo cls : school)
|
|
|
departments.computeIfAbsent(cls.dwid, key -> new ArrayList<>()).add(cls);
|
|
|
for (Map.Entry<Long, List<ClassInfo>> entry : departments.entrySet()) {
|
|
|
entry.getValue().sort(Comparator
|
|
|
@@ -594,7 +691,7 @@ public class BjStarClassMpServ extends Serv {
|
|
|
Map<LocalDate, DailyAccumulator> days = new HashMap<>();
|
|
|
|
|
|
for (CategoryDef def : CATEGORY_DEFS) {
|
|
|
- String source = sources.getOrDefault(def.code, SOURCE_MOCK);
|
|
|
+ String source = sources.getOrDefault(def.code, SOURCE_MISSING);
|
|
|
Map<LocalDate, DailyPoint> actual = daily.actual.get(def.code);
|
|
|
for (LocalDate date = period.month.atDay(1);
|
|
|
!date.isAfter(period.maxDate);
|
|
|
@@ -602,11 +699,6 @@ public class BjStarClassMpServ extends Serv {
|
|
|
DailyPoint point = null;
|
|
|
if (SOURCE_REAL.equals(source)) {
|
|
|
point = actual == null ? null : actual.get(date);
|
|
|
- } else if (mockHasEvent(cls.bjid, monthKey(period.month),
|
|
|
- def.code, date.getDayOfMonth())) {
|
|
|
- point = new DailyPoint(date,
|
|
|
- mockDailyScore(cls.bjid, monthKey(period.month),
|
|
|
- def.code, date.getDayOfMonth()), 1);
|
|
|
}
|
|
|
if (point == null)
|
|
|
continue;
|
|
|
@@ -614,8 +706,6 @@ public class BjStarClassMpServ extends Serv {
|
|
|
DailyAccumulator::new);
|
|
|
acc.regularDeduction += Math.max(0.0, 100.0 - point.score);
|
|
|
acc.hasRegular = true;
|
|
|
- if (SOURCE_MOCK.equals(source))
|
|
|
- acc.hasMock = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -636,8 +726,8 @@ public class BjStarClassMpServ extends Serv {
|
|
|
Timestamp end = onlyDay == null ? period.end
|
|
|
: Timestamp.valueOf(onlyDay.plusDays(1).atStartOfDay());
|
|
|
|
|
|
- result.actual.put("dorm", rdDailyAvgScore(db, "SSNWJC",
|
|
|
- cls.bjid, start, end));
|
|
|
+ result.actual.put("dorm", rdDailyDormScore(db, cls,
|
|
|
+ onlyDay, period));
|
|
|
result.actual.put("cleaning", rdDailyAvgScore(db, "CSWSJC",
|
|
|
cls.bjid, start, end));
|
|
|
result.actual.put("flag", rdDailyFlagScore(db, cls.bjid, start, end));
|
|
|
@@ -645,28 +735,35 @@ public class BjStarClassMpServ extends Serv {
|
|
|
db, cls.bjid, start, end));
|
|
|
result.actual.put("attendance", rdDailyAttendanceScore(db,
|
|
|
cls.bjid, start, end));
|
|
|
+ result.actual.put("discipline", rdDailyDisciplineScore(
|
|
|
+ db, cls.bjid, start, end));
|
|
|
|
|
|
MonthPeriod fullMonth = MonthPeriod.of(period.month);
|
|
|
- Map<Long, Double> monthDorm = rdAvgScoreByClass(db, "SSNWJC", fullMonth);
|
|
|
Map<Long, Double> monthClean = rdAvgScoreByClass(db, "CSWSJC", fullMonth);
|
|
|
Map<Long, Double> monthFlag = rdFlagScoreByClass(db, fullMonth);
|
|
|
Map<Long, Double> monthAttendance = computeAttendanceScores(
|
|
|
List.of(cls), rdSchoolDays(db, fullMonth),
|
|
|
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);
|
|
|
result.sources.put("dorm", monthDorm.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
+ ? SOURCE_REAL : SOURCE_MISSING);
|
|
|
result.sources.put("classroom",
|
|
|
monthClassroom.containsKey(cls.bjid)
|
|
|
? SOURCE_REAL : SOURCE_MISSING);
|
|
|
result.sources.put("flag", monthFlag.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
+ ? SOURCE_REAL : SOURCE_MISSING);
|
|
|
result.sources.put("cleaning", monthClean.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
- result.sources.put("discipline", SOURCE_MOCK);
|
|
|
+ ? SOURCE_REAL : SOURCE_MISSING);
|
|
|
+ result.sources.put("discipline",
|
|
|
+ monthDiscipline.containsKey(cls.bjid)
|
|
|
+ ? SOURCE_REAL : SOURCE_MISSING);
|
|
|
result.sources.put("attendance", monthAttendance.containsKey(cls.bjid)
|
|
|
- ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
+ ? SOURCE_REAL : SOURCE_MISSING);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -686,6 +783,78 @@ public class BjStarClassMpServ extends Serv {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private static Map<LocalDate, DailyPoint> rdDailyDormScore(
|
|
|
+ Db db, ClassInfo cls, LocalDate onlyDay, MonthPeriod period)
|
|
|
+ throws Exception {
|
|
|
+ Timestamp start = onlyDay == null ? period.start
|
|
|
+ : Timestamp.valueOf(onlyDay.atStartOfDay());
|
|
|
+ Timestamp end = onlyDay == null ? period.end
|
|
|
+ : Timestamp.valueOf(onlyDay.plusDays(1).atStartOfDay());
|
|
|
+ SqlCmd itemCmd = new SqlCmd(
|
|
|
+ "select trunc(JCSJ) D,"
|
|
|
+ + "avg(case when extract(hour from JCSJ)<12 then FS end) AM,"
|
|
|
+ + "avg(case when extract(hour from JCSJ)>=12 then FS end) PM"
|
|
|
+ + " from SSNWJC where BJID=:bjid and JCSJ>=:start"
|
|
|
+ + " and JCSJ<:end and " + ObjC.JLZT_useStr
|
|
|
+ + " group by trunc(JCSJ)");
|
|
|
+ itemCmd.wrLongParm("bjid", cls.bjid);
|
|
|
+ itemCmd.wrTimeParm("start", start);
|
|
|
+ itemCmd.wrTimeParm("end", end);
|
|
|
+ Map<LocalDate, double[]> internal = new HashMap<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(itemCmd))
|
|
|
+ internal.put(rdLocalDate(row.get("d")), new double[]{
|
|
|
+ row.get("am") == null ? -1 : rdDouble(row.get("am")),
|
|
|
+ row.get("pm") == null ? -1 : rdDouble(row.get("pm"))
|
|
|
+ });
|
|
|
+
|
|
|
+ SqlCmd violationCmd = new SqlCmd(
|
|
|
+ "select trunc(w.WJSJ) D,sum(nvl(lb.BJKF,0)) PENALTY"
|
|
|
+ + " from WJJL w inner join WJLB lb on lb.WJLBM=w.WJLBM"
|
|
|
+ + " where w.BJID=:bjid and w.WJSJ>=:start"
|
|
|
+ + " and w.WJSJ<:end and w.WJLBM>=20 and w.JLZTM=51"
|
|
|
+ + " group by trunc(w.WJSJ)");
|
|
|
+ violationCmd.wrLongParm("bjid", cls.bjid);
|
|
|
+ violationCmd.wrTimeParm("start", start);
|
|
|
+ violationCmd.wrTimeParm("end", end);
|
|
|
+ Map<LocalDate, Double> violations = new HashMap<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(violationCmd))
|
|
|
+ violations.put(rdLocalDate(row.get("d")),
|
|
|
+ rdDouble(row.get("penalty")));
|
|
|
+
|
|
|
+ Map<LocalDate, DailyPoint> attendance =
|
|
|
+ rdDailyAttendanceScore(db, cls.bjid, start, end);
|
|
|
+ Map<LocalDate, DailyPoint> result = new HashMap<>();
|
|
|
+ for (Map.Entry<LocalDate, double[]> entry : internal.entrySet()) {
|
|
|
+ DailyPoint attend = attendance.get(entry.getKey());
|
|
|
+ double[] values = entry.getValue();
|
|
|
+ if (values[0] < 0 || values[1] < 0 || attend == null)
|
|
|
+ continue;
|
|
|
+ double internalScore = (values[0] + values[1]) / 2.0;
|
|
|
+ double violationScore = Math.max(0.0,
|
|
|
+ 100.0 - violations.getOrDefault(entry.getKey(), 0.0));
|
|
|
+ double base = internalScore * 0.35 + attend.score * 0.15
|
|
|
+ + violationScore * 0.35;
|
|
|
+ result.put(entry.getKey(), new DailyPoint(entry.getKey(),
|
|
|
+ round2(base + base / 85.0 * 10.0), attend.count));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static Map<LocalDate, DailyPoint> rdDailyFlagScore(
|
|
|
Db db, long bjid, Timestamp start, Timestamp end) throws Exception {
|
|
|
SqlCmd sqlc = new SqlCmd(
|
|
|
@@ -726,7 +895,7 @@ public class BjStarClassMpServ extends Serv {
|
|
|
Db db, long bjid, Timestamp start, Timestamp end) throws Exception {
|
|
|
SqlCmd sqlc = new SqlCmd(
|
|
|
"select trunc(KSSJ) D,sum(case KQLBM"
|
|
|
- + " when 1 then 3 when 21 then 1 when 51 then 2"
|
|
|
+ + " when 1 then 3 when 21 then 1 when 51 then 1"
|
|
|
+ " when 52 then 1 when 61 then 2 else 0 end) PENALTY,"
|
|
|
+ "count(*) CNT from KQJL where BJID=:bjid"
|
|
|
+ " and KSSJ>=:start and KSSJ<:end"
|
|
|
@@ -766,7 +935,8 @@ public class BjStarClassMpServ extends Serv {
|
|
|
Db db, ClassInfo cls, LocalDate day, MonthPeriod period,
|
|
|
CategoryDef category) throws Exception {
|
|
|
CategoryDaily monthly = rdCategoryDaily(db, cls, day, period);
|
|
|
- String source = monthly.sources.getOrDefault(category.code, SOURCE_MOCK);
|
|
|
+ String source = monthly.sources.getOrDefault(
|
|
|
+ category.code, SOURCE_MISSING);
|
|
|
List<Map<String, Object>> rows;
|
|
|
if (SOURCE_REAL.equals(source)) {
|
|
|
if ("attendance".equals(category.code))
|
|
|
@@ -779,10 +949,10 @@ public class BjStarClassMpServ extends Serv {
|
|
|
rows = rdItemDetail(db, cls.bjid, day, "cleaning");
|
|
|
else if ("classroom".equals(category.code))
|
|
|
rows = rdKtjlDetail(db, cls.bjid, day);
|
|
|
+ else if ("discipline".equals(category.code))
|
|
|
+ rows = rdDisciplineDetail(db, cls.bjid, day);
|
|
|
else
|
|
|
- rows = mockDayDetail(cls, day, category.code);
|
|
|
- } else if (SOURCE_MOCK.equals(source)) {
|
|
|
- rows = mockDayDetail(cls, day, category.code);
|
|
|
+ rows = new ArrayList<>();
|
|
|
} else {
|
|
|
rows = new ArrayList<>();
|
|
|
}
|
|
|
@@ -830,6 +1000,34 @@ public class BjStarClassMpServ extends Serv {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private static List<Map<String, Object>> rdDisciplineDetail(
|
|
|
+ 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");
|
|
|
+ sqlc.wrLongParm("bjid", bjid);
|
|
|
+ sqlc.wrTimeParm("jcrq", Timestamp.valueOf(day.atStartOfDay()));
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
|
|
|
+ int count = rdInt(row.get("wjrs"));
|
|
|
+ Map<String, Object> item = baseDetail(day, SOURCE_REAL);
|
|
|
+ item.put("id", rdLong(row.get("xjb_fjryid")));
|
|
|
+ item.put("sourceId", rdLong(row.get("xjb_fjryid")));
|
|
|
+ item.put("category", "discipline");
|
|
|
+ item.put("traceable", true);
|
|
|
+ item.put("itemName", "风纪仪容违纪");
|
|
|
+ item.put("studentName", "");
|
|
|
+ item.put("title", "风纪仪容违纪 " + count + "人次");
|
|
|
+ item.put("remark", rdStr(row.get("ms")));
|
|
|
+ item.put("delta", -count);
|
|
|
+ item.put("scoreText", Math.max(0, 100 - count) + "/100");
|
|
|
+ item.put("sortTime", day.format(DATE_FMT));
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static List<Map<String, Object>> rdItemDetail(
|
|
|
Db db, long bjid, LocalDate day, String category) throws Exception {
|
|
|
Timestamp start = Timestamp.valueOf(day.atStartOfDay());
|
|
|
@@ -983,10 +1181,46 @@ public class BjStarClassMpServ extends Serv {
|
|
|
return rdCheckTrace(db, cls, day, category, sourceId, "cleaning");
|
|
|
if ("classroom".equals(category.code))
|
|
|
return rdKtjlTrace(db, cls, day, category, sourceId);
|
|
|
+ if ("discipline".equals(category.code))
|
|
|
+ return rdDisciplineTrace(db, cls, day, category, sourceId);
|
|
|
return rdMockTraceDetail(cls, day, category);
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private static Map<String, Object> rdDisciplineTrace(
|
|
|
+ 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");
|
|
|
+ sqlc.wrLongParm("id", sourceId);
|
|
|
+ sqlc.wrLongParm("bjid", cls.bjid);
|
|
|
+ List<Map<String, Object>> rows = db.doSelMapListByC(sqlc);
|
|
|
+ if (rows == null || rows.isEmpty())
|
|
|
+ throw new IllegalArgumentException("风纪仪容记录不存在或已不可查看");
|
|
|
+ Map<String, Object> row = rows.get(0);
|
|
|
+ int violations = rdInt(row.get("wjrs"));
|
|
|
+ Map<String, Object> record = new LinkedHashMap<>();
|
|
|
+ record.put("time", day.format(DATE_FMT));
|
|
|
+ record.put("className", cls.bjmc);
|
|
|
+ record.put("inspectorName", "风纪检查");
|
|
|
+ record.put("violationCount", violations);
|
|
|
+ record.put("description", rdStr(row.get("ms")));
|
|
|
+
|
|
|
+ List<Map<String, Object>> items = new ArrayList<>();
|
|
|
+ if (violations > 0) {
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
+ item.put("itemName", "风纪仪容违纪");
|
|
|
+ item.put("deducted", violations);
|
|
|
+ item.put("remark", "违纪" + violations + "人次,每人次扣1分");
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ return traceResult(cls, day, category, SOURCE_REAL,
|
|
|
+ "风纪仪容扣分详情", record, items,
|
|
|
+ violations == 0 ? "当日无风纪仪容扣分" : "");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static Map<String, Object> rdCheckTrace(Db db, ClassInfo cls,
|
|
|
LocalDate day,
|
|
|
CategoryDef category,
|
|
|
@@ -1435,6 +1669,51 @@ public class BjStarClassMpServ extends Serv {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private static PublishedSnapshot rdPublishedSnapshot(
|
|
|
+ Db db, long bjid, YearMonth month) throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select jg.ZF,jg.XJ,jg.ZJF,jg.KJF,jg.ZJFCS,jg.KJFCS,"
|
|
|
+ + "jg.SSLY,jg.KTLY,jg.SJLY,jg.CSLY,jg.FJLY,jg.KQLY,"
|
|
|
+ + "pm.DWPM,pm.DWCS,pm.XXPM,pm.XXCS from XJB_JG jg"
|
|
|
+ + " inner join XJB_JD jd on jd.XJB_JDID=jg.XJB_JDID"
|
|
|
+ + " inner join XJB_PM pm on pm.XJB_JDID=jg.XJB_JDID"
|
|
|
+ + " and pm.BJID=jg.BJID"
|
|
|
+ + " where jg.BJID=:bjid and jg.NDY=:ndy"
|
|
|
+ + " and jg.ZT=5 and jd.ZT=5"
|
|
|
+ + " order by jd.BB desc,jd.XJB_JDID desc");
|
|
|
+ sqlc.wrLongParm("bjid", bjid);
|
|
|
+ sqlc.wrStrParm("ndy", month.format(MONTH_FMT));
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> rows = db.doSelMapListByC(sqlc);
|
|
|
+ if (rows == null || rows.isEmpty())
|
|
|
+ return null;
|
|
|
+ Map<String, Object> row = rows.get(0);
|
|
|
+ PublishedSnapshot snapshot = new PublishedSnapshot();
|
|
|
+ snapshot.total = rdDouble(row.get("zf"));
|
|
|
+ snapshot.starLevel = rdStr(row.get("xj"));
|
|
|
+ snapshot.bonus = rdDouble(row.get("zjf"));
|
|
|
+ snapshot.deduction = rdDouble(row.get("kjf"));
|
|
|
+ snapshot.bonusCount = rdInt(row.get("zjfcs"));
|
|
|
+ snapshot.deductionCount = rdInt(row.get("kjfcs"));
|
|
|
+ snapshot.departmentRank = rdInt(row.get("dwpm"));
|
|
|
+ snapshot.departmentClassCount = rdInt(row.get("dwcs"));
|
|
|
+ snapshot.schoolRank = rdInt(row.get("xxpm"));
|
|
|
+ snapshot.schoolClassCount = rdInt(row.get("xxcs"));
|
|
|
+ snapshot.sources.put("dorm", rdStr(row.get("ssly")));
|
|
|
+ snapshot.sources.put("classroom", rdStr(row.get("ktly")));
|
|
|
+ snapshot.sources.put("flag", rdStr(row.get("sjly")));
|
|
|
+ snapshot.sources.put("cleaning", rdStr(row.get("csly")));
|
|
|
+ snapshot.sources.put("discipline", rdStr(row.get("fjly")));
|
|
|
+ snapshot.sources.put("attendance", rdStr(row.get("kqly")));
|
|
|
+ return snapshot;
|
|
|
+ } catch (SQLException e) {
|
|
|
+ if (isMissingTable(e, "XJB_JG"))
|
|
|
+ return null;
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private static List<Adjustment> rdAdjustments(
|
|
|
Db db, long bjid, YearMonth month) throws Exception {
|
|
|
SqlCmd sqlc = new SqlCmd(
|
|
|
@@ -1487,14 +1766,18 @@ public class BjStarClassMpServ extends Serv {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static String starLevel(double score) {
|
|
|
- if (score >= 90.0)
|
|
|
+ private static String starLevel(double score, int schoolRank) {
|
|
|
+ if (schoolRank <= 10 && score >= 90.0)
|
|
|
return "五星级";
|
|
|
if (score >= 80.0)
|
|
|
return "四星级";
|
|
|
- if (score >= 70.0)
|
|
|
+ if (score >= 75.0)
|
|
|
return "三星级";
|
|
|
- return "二星级";
|
|
|
+ if (score >= 65.0)
|
|
|
+ return "二星级";
|
|
|
+ if (score >= 55.0)
|
|
|
+ return "一星级";
|
|
|
+ return "无星级";
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1502,7 +1785,7 @@ public class BjStarClassMpServ extends Serv {
|
|
|
return switch (kqlbm) {
|
|
|
case 1 -> 3;
|
|
|
case 21 -> 1;
|
|
|
- case 51 -> 2;
|
|
|
+ case 51 -> 1;
|
|
|
case 52 -> 1;
|
|
|
case 61 -> 2;
|
|
|
default -> 0;
|
|
|
@@ -1746,21 +2029,12 @@ public class BjStarClassMpServ extends Serv {
|
|
|
}
|
|
|
|
|
|
Map<String, Object> toMap(CategoryDef def, LocalDate date) {
|
|
|
- String source = sources.getOrDefault(def.code, SOURCE_MOCK);
|
|
|
+ String source = sources.getOrDefault(def.code, SOURCE_MISSING);
|
|
|
DailyPoint point = null;
|
|
|
if (SOURCE_REAL.equals(source)) {
|
|
|
Map<LocalDate, DailyPoint> values = actual.get(def.code);
|
|
|
point = values == null ? null : values.get(date);
|
|
|
}
|
|
|
- if (point == null && SOURCE_MOCK.equals(source)) {
|
|
|
- if (mockHasEvent(cls.bjid,
|
|
|
- monthKey(YearMonth.from(date)), def.code,
|
|
|
- date.getDayOfMonth())) {
|
|
|
- point = new DailyPoint(date, mockDailyScore(cls.bjid,
|
|
|
- monthKey(YearMonth.from(date)), def.code,
|
|
|
- date.getDayOfMonth()), 1);
|
|
|
- }
|
|
|
- }
|
|
|
boolean available;
|
|
|
double score;
|
|
|
double deduction;
|
|
|
@@ -1768,15 +2042,10 @@ public class BjStarClassMpServ extends Serv {
|
|
|
available = true;
|
|
|
score = point.score;
|
|
|
deduction = Math.max(0.0, 100.0 - score);
|
|
|
- } else if (SOURCE_REAL.equals(source)
|
|
|
- || SOURCE_MISSING.equals(source)) {
|
|
|
+ } else {
|
|
|
available = false;
|
|
|
score = 0.0;
|
|
|
deduction = 0.0;
|
|
|
- } else {
|
|
|
- available = true;
|
|
|
- score = 100.0;
|
|
|
- deduction = 0.0;
|
|
|
}
|
|
|
Map<String, Object> row = new LinkedHashMap<>();
|
|
|
row.put("code", def.code);
|
|
|
@@ -1806,6 +2075,7 @@ public class BjStarClassMpServ extends Serv {
|
|
|
Map<Long, Double> flag = new HashMap<>();
|
|
|
Map<Long, Double> cleaning = new HashMap<>();
|
|
|
Map<Long, Double> attendance = new HashMap<>();
|
|
|
+ Map<Long, Double> discipline = new HashMap<>();
|
|
|
Map<Long, AdjustmentTotals> adjustments = new HashMap<>();
|
|
|
Map<Long, ClassScore> classScores = new HashMap<>();
|
|
|
|
|
|
@@ -1819,9 +2089,10 @@ public class BjStarClassMpServ extends Serv {
|
|
|
private static final class ClassScore {
|
|
|
final Map<String, Double> values = new LinkedHashMap<>();
|
|
|
final Map<String, String> sources = new LinkedHashMap<>();
|
|
|
+ final List<String> missing = new ArrayList<>();
|
|
|
AdjustmentTotals adjust = new AdjustmentTotals();
|
|
|
double total;
|
|
|
- boolean hasMock;
|
|
|
+ boolean hasMissing;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1863,4 +2134,19 @@ public class BjStarClassMpServ extends Serv {
|
|
|
int bonusEvents;
|
|
|
int deductionEvents;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private static final class PublishedSnapshot {
|
|
|
+ double total;
|
|
|
+ String starLevel;
|
|
|
+ double bonus;
|
|
|
+ double deduction;
|
|
|
+ int bonusCount;
|
|
|
+ int deductionCount;
|
|
|
+ int departmentRank;
|
|
|
+ int departmentClassCount;
|
|
|
+ int schoolRank;
|
|
|
+ int schoolClassCount;
|
|
|
+ final Map<String, String> sources = new LinkedHashMap<>();
|
|
|
+ }
|
|
|
}
|