|
@@ -0,0 +1,1606 @@
|
|
|
|
|
+package biz.bj;
|
|
|
|
|
+
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
|
|
+import ss.db.Db;
|
|
|
|
|
+import ss.db.SqlCmd;
|
|
|
|
|
+import ss.obj.ObjC;
|
|
|
|
|
+import ss.serv.Serv;
|
|
|
|
|
+import ss.serv.ServU;
|
|
|
|
|
+import ss.user.UserRunB;
|
|
|
|
|
+import ss.user.UserU;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.Writer;
|
|
|
|
|
+import java.sql.Date;
|
|
|
|
|
+import java.sql.Timestamp;
|
|
|
|
|
+import java.time.DayOfWeek;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.YearMonth;
|
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.time.format.DateTimeParseException;
|
|
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.Comparator;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
|
|
+import java.util.LinkedHashSet;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 班主任星级班移动报表。
|
|
|
|
|
+ */
|
|
|
|
|
+public class BjStarClassMpServ extends Serv {
|
|
|
|
|
+
|
|
|
|
|
+ private static final Logger log4j = LogManager.getLogger(BjStarClassMpServ.class);
|
|
|
|
|
+ private static final ZoneId CN_ZONE = ZoneId.of("Asia/Shanghai");
|
|
|
|
|
+ private static final DateTimeFormatter MONTH_FMT = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
|
|
+ private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ private static final DateTimeFormatter DATETIME_FMT =
|
|
|
|
|
+ DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
|
|
+ private static final String SOURCE_REAL = "real";
|
|
|
|
|
+ private static final String SOURCE_MOCK = "mock";
|
|
|
|
|
+ private static final int DEFAULT_PAGE_SIZE = 20;
|
|
|
|
|
+ private static final int DETAIL_PAGE_SIZE = 30;
|
|
|
|
|
+
|
|
|
|
|
+ private static final String[] BONUS_ITEMS = {
|
|
|
|
|
+ "文明班集体加分", "活动表现优秀", "宿舍管理协助", "校园志愿服务"
|
|
|
|
|
+ };
|
|
|
|
|
+ private static final String[] DEDUCTION_ITEMS = {
|
|
|
|
|
+ "班级管理扣分", "材料迟交", "临时纪律扣分", "公共区域责任扣分"
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ private static final List<CategoryDef> CATEGORY_DEFS = List.of(
|
|
|
|
|
+ new CategoryDef("dorm", "宿舍评分", 0.20),
|
|
|
|
|
+ new CategoryDef("classroom", "课堂考核", 0.05),
|
|
|
|
|
+ new CategoryDef("flag", "升旗礼", 0.14),
|
|
|
|
|
+ new CategoryDef("cleaning", "清洁卫生", 0.18),
|
|
|
|
|
+ new CategoryDef("discipline", "风纪仪容", 0.20),
|
|
|
|
|
+ new CategoryDef("attendance", "考勤", 0.15)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 班主任、本人班级和默认月份。
|
|
|
|
|
+ */
|
|
|
|
|
+ @SuppressWarnings("unused")
|
|
|
|
|
+ public void initByA() throws Exception {
|
|
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
|
|
+ prepareJson();
|
|
|
|
|
+ Writer writer = super.resp.getWriter();
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+
|
|
|
|
|
+ try (Db db = Db.makeConn()) {
|
|
|
|
|
+ UserRunB user = requireUser(request);
|
|
|
|
|
+ List<ClassInfo> classes = rdTeacherClasses(db, user.ryid);
|
|
|
|
|
+ if (classes.isEmpty())
|
|
|
|
|
+ throw new IllegalArgumentException("当前账号未关联班主任班级");
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> classList = new ArrayList<>();
|
|
|
|
|
+ for (ClassInfo item : classes) {
|
|
|
|
|
+ Map<String, Object> classRow = new LinkedHashMap<>();
|
|
|
|
|
+ classRow.put("bjid", item.bjid);
|
|
|
|
|
+ classRow.put("bjmc", item.bjmc);
|
|
|
|
|
+ classRow.put("dwid", item.dwid);
|
|
|
|
|
+ classRow.put("dwmc", item.dwmc);
|
|
|
|
|
+ classList.add(classRow);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
|
|
+ data.put("teacherName", user.xm);
|
|
|
|
|
+ data.put("defaultBjid", classes.get(0).bjid);
|
|
|
|
|
+ data.put("defaultMonth", YearMonth.now(CN_ZONE).format(MONTH_FMT));
|
|
|
|
|
+ data.put("classes", classList);
|
|
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log4j.error("BjStarClassMpServ.initByA() 异常", e);
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, "星级班信息加载失败", writer, gson);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 月度汇总和每日列表。
|
|
|
|
|
+ */
|
|
|
|
|
+ @SuppressWarnings("unused")
|
|
|
|
|
+ public void summaryByA() throws Exception {
|
|
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
|
|
+ prepareJson();
|
|
|
|
|
+ Writer writer = super.resp.getWriter();
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+
|
|
|
|
|
+ try (Db db = Db.makeConn()) {
|
|
|
|
|
+ UserRunB user = requireUser(request);
|
|
|
|
|
+ ClassInfo selected = requireTeacherClass(db, user.ryid,
|
|
|
|
|
+ rdLongParam(request, "bjid", false));
|
|
|
|
|
+ YearMonth month = rdMonth(request);
|
|
|
|
|
+ MonthPeriod period = MonthPeriod.of(month);
|
|
|
|
|
+
|
|
|
|
|
+ List<ClassInfo> classes = rdActiveClasses(db);
|
|
|
|
|
+ ScoreBook scores = rdScoreBook(db, classes, period);
|
|
|
|
|
+ RankBook ranks = rdRanks(classes, scores);
|
|
|
|
|
+ ClassScore classScore = scores.classScores.get(selected.bjid);
|
|
|
|
|
+ if (classScore == null)
|
|
|
|
|
+ throw new IllegalStateException("班级评分未生成");
|
|
|
|
|
+
|
|
|
|
|
+ int pageNo = Math.max(1, rdIntParam(request, "pageNo", 1));
|
|
|
|
|
+ int pageSize = clampPageSize(rdIntParam(request, "pageSize",
|
|
|
|
|
+ DEFAULT_PAGE_SIZE));
|
|
|
|
|
+ List<DailyAccumulator> allDays = rdDailyList(db, selected, period,
|
|
|
|
|
+ scores.categorySources(selected.bjid));
|
|
|
|
|
+ int from = Math.min(allDays.size(), (pageNo - 1) * pageSize);
|
|
|
|
|
+ int to = Math.min(allDays.size(), from + pageSize);
|
|
|
|
|
+ List<Map<String, Object>> dayRows = new ArrayList<>();
|
|
|
|
|
+ for (int i = from; i < to; i++) {
|
|
|
|
|
+ dayRows.add(allDays.get(i).toMap());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
|
|
+ data.put("bjid", selected.bjid);
|
|
|
|
|
+ data.put("bjmc", selected.bjmc);
|
|
|
|
|
+ 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));
|
|
|
|
|
+ data.put("pageNo", pageNo);
|
|
|
|
|
+ data.put("pageSize", pageSize);
|
|
|
|
|
+ data.put("total", allDays.size());
|
|
|
|
|
+ data.put("hasMore", to < allDays.size());
|
|
|
|
|
+ data.put("days", dayRows);
|
|
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log4j.error("BjStarClassMpServ.summaryByA() 异常", e);
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, "星级班月度数据加载失败", writer, gson);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 指定日期的六项得分。
|
|
|
|
|
+ */
|
|
|
|
|
+ @SuppressWarnings("unused")
|
|
|
|
|
+ public void dayByA() throws Exception {
|
|
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
|
|
+ prepareJson();
|
|
|
|
|
+ Writer writer = super.resp.getWriter();
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+
|
|
|
|
|
+ try (Db db = Db.makeConn()) {
|
|
|
|
|
+ UserRunB user = requireUser(request);
|
|
|
|
|
+ ClassInfo selected = requireTeacherClass(db, user.ryid,
|
|
|
|
|
+ rdLongParam(request, "bjid", false));
|
|
|
|
|
+ LocalDate day = rdDate(request, "date");
|
|
|
|
|
+ if (day.isAfter(LocalDate.now(CN_ZONE)))
|
|
|
|
|
+ throw new IllegalArgumentException("不能查询未来日期");
|
|
|
|
|
+ YearMonth month = YearMonth.from(day);
|
|
|
|
|
+ MonthPeriod period = MonthPeriod.of(month);
|
|
|
|
|
+ CategoryDaily daily = rdCategoryDaily(db, selected, day, period);
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> categories = new ArrayList<>();
|
|
|
|
|
+ for (CategoryDef def : CATEGORY_DEFS)
|
|
|
|
|
+ categories.add(daily.toMap(def, day));
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
|
|
+ data.put("bjid", selected.bjid);
|
|
|
|
|
+ data.put("bjmc", selected.bjmc);
|
|
|
|
|
+ data.put("date", day.format(DATE_FMT));
|
|
|
|
|
+ data.put("weekday", weekdayCn(day));
|
|
|
|
|
+ data.put("categories", categories);
|
|
|
|
|
+ data.put("regularDeduction", round2(daily.regularDeduction(day)));
|
|
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
|
|
+ } catch (DateTimeParseException e) {
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, "日期格式错误", writer, gson);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log4j.error("BjStarClassMpServ.dayByA() 异常", e);
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, "单日星级班数据加载失败", writer, gson);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 项目扣分明细,或月度增分/减分明细。
|
|
|
|
|
+ */
|
|
|
|
|
+ @SuppressWarnings("unused")
|
|
|
|
|
+ public void detailByA() throws Exception {
|
|
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
|
|
+ prepareJson();
|
|
|
|
|
+ Writer writer = super.resp.getWriter();
|
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
|
+
|
|
|
|
|
+ try (Db db = Db.makeConn()) {
|
|
|
|
|
+ UserRunB user = requireUser(request);
|
|
|
|
|
+ ClassInfo selected = requireTeacherClass(db, user.ryid,
|
|
|
|
|
+ rdLongParam(request, "bjid", false));
|
|
|
|
|
+ String mode = StringUtils.defaultIfBlank(
|
|
|
|
|
+ request.getParameter("mode"), "dayItem");
|
|
|
|
|
+
|
|
|
|
|
+ if ("trace".equals(mode)) {
|
|
|
|
|
+ LocalDate day = rdDate(request, "date");
|
|
|
|
|
+ if (day.isAfter(LocalDate.now(CN_ZONE)))
|
|
|
|
|
+ throw new IllegalArgumentException("不能查询未来日期");
|
|
|
|
|
+ String categoryCode = StringUtils.trimToNull(
|
|
|
|
|
+ request.getParameter("category"));
|
|
|
|
|
+ CategoryDef category = requireCategory(categoryCode);
|
|
|
|
|
+ long sourceId = rdLongParam(request, "id", true);
|
|
|
|
|
+ String source = StringUtils.defaultIfBlank(
|
|
|
|
|
+ request.getParameter("source"), SOURCE_REAL);
|
|
|
|
|
+ Map<String, Object> trace = rdTraceDetail(db, selected, day,
|
|
|
|
|
+ category, sourceId, source);
|
|
|
|
|
+ ServU.wrOkDataByWriter(trace, writer, gson);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int pageNo = Math.max(1, rdIntParam(request, "pageNo", 1));
|
|
|
|
|
+ int pageSize = clampPageSize(rdIntParam(request, "pageSize",
|
|
|
|
|
+ DETAIL_PAGE_SIZE));
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> rows;
|
|
|
|
|
+ String title;
|
|
|
|
|
+ String monthText = null;
|
|
|
|
|
+ String dateText = null;
|
|
|
|
|
+ String categoryCode = null;
|
|
|
|
|
+
|
|
|
|
|
+ if ("bonus".equals(mode) || "deduction".equals(mode)) {
|
|
|
|
|
+ YearMonth month = rdMonth(request);
|
|
|
|
|
+ MonthPeriod period = MonthPeriod.of(month);
|
|
|
|
|
+ List<Adjustment> adjustments = mockAdjustments(
|
|
|
|
|
+ selected.bjid, month, period.maxDay);
|
|
|
|
|
+ List<Adjustment> selectedAdjustments = new ArrayList<>();
|
|
|
|
|
+ for (Adjustment item : adjustments) {
|
|
|
|
|
+ if ((("bonus".equals(mode) && item.score > 0)
|
|
|
|
|
+ || ("deduction".equals(mode) && item.score < 0)))
|
|
|
|
|
+ selectedAdjustments.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ selectedAdjustments.sort(Comparator
|
|
|
|
|
+ .comparing((Adjustment item) -> item.date).reversed()
|
|
|
|
|
+ .thenComparingLong(item -> item.id).reversed());
|
|
|
|
|
+ rows = rdAdjustmentRows(selectedAdjustments);
|
|
|
|
|
+ title = "bonus".equals(mode) ? "当月增分明细" : "当月减分明细";
|
|
|
|
|
+ monthText = month.format(MONTH_FMT);
|
|
|
|
|
+ } else if ("dayItem".equals(mode)) {
|
|
|
|
|
+ LocalDate day = rdDate(request, "date");
|
|
|
|
|
+ if (day.isAfter(LocalDate.now(CN_ZONE)))
|
|
|
|
|
+ throw new IllegalArgumentException("不能查询未来日期");
|
|
|
|
|
+ categoryCode = StringUtils.trimToNull(request.getParameter("category"));
|
|
|
|
|
+ CategoryDef category = requireCategory(categoryCode);
|
|
|
|
|
+ YearMonth month = YearMonth.from(day);
|
|
|
|
|
+ MonthPeriod period = MonthPeriod.of(month);
|
|
|
|
|
+ rows = rdDayDetail(db, selected, day, period, category);
|
|
|
|
|
+ title = category.label + " · " + day.format(DATE_FMT);
|
|
|
|
|
+ dateText = day.format(DATE_FMT);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new IllegalArgumentException("明细模式参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int from = Math.min(rows.size(), (pageNo - 1) * pageSize);
|
|
|
|
|
+ int to = Math.min(rows.size(), from + pageSize);
|
|
|
|
|
+ List<Map<String, Object>> pageRows = rows.subList(from, to);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
|
|
+ data.put("bjid", selected.bjid);
|
|
|
|
|
+ data.put("bjmc", selected.bjmc);
|
|
|
|
|
+ data.put("mode", mode);
|
|
|
|
|
+ data.put("title", title);
|
|
|
|
|
+ data.put("month", monthText);
|
|
|
|
|
+ data.put("date", dateText);
|
|
|
|
|
+ data.put("category", categoryCode);
|
|
|
|
|
+ data.put("pageNo", pageNo);
|
|
|
|
|
+ data.put("pageSize", pageSize);
|
|
|
|
|
+ data.put("total", rows.size());
|
|
|
|
|
+ data.put("hasMore", to < rows.size());
|
|
|
|
|
+ data.put("list", pageRows);
|
|
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
|
|
+ } catch (DateTimeParseException e) {
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, "日期格式错误", writer, gson);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log4j.error("BjStarClassMpServ.detailByA() 异常", e);
|
|
|
|
|
+ ServU.wrErrMsgByWriter(null, "星级班明细加载失败", writer, gson);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private void prepareJson() throws Exception {
|
|
|
|
|
+ super.resp.setCharacterEncoding("UTF-8");
|
|
|
|
|
+ super.resp.setContentType("application/json;charset=UTF-8");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static UserRunB requireUser(HttpServletRequest request) {
|
|
|
|
|
+ UserRunB user = UserU.rdUserByReq(request);
|
|
|
|
|
+ if (user == null)
|
|
|
|
|
+ throw new IllegalArgumentException("登录状态已失效,请重新进入");
|
|
|
|
|
+ return user;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<ClassInfo> rdTeacherClasses(Db db, long ryid)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
|
|
+ "select b.BJID,b.MC,b.DWID,d.MC DWMC"
|
|
|
|
|
+ + " from BJ b left join DW d on d.DWID=b.DWID"
|
|
|
|
|
+ + " where b.BZRID=:ryid and b." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and b.BJZTM!=81 order by b.MC,b.BJID");
|
|
|
|
|
+ sqlc.wrLongParm("ryid", ryid);
|
|
|
|
|
+ return rdClasses(db.doSelMapListByC(sqlc));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<ClassInfo> rdActiveClasses(Db db) throws Exception {
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
|
|
+ "select b.BJID,b.MC,b.DWID,d.MC DWMC"
|
|
|
|
|
+ + " from BJ b left join DW d on d.DWID=b.DWID"
|
|
|
|
|
+ + " where b." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and b.BJZTM!=81 order by b.BJID");
|
|
|
|
|
+ return rdClasses(db.doSelMapListByC(sqlc));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<ClassInfo> rdClasses(List<Map<String, Object>> rows) {
|
|
|
|
|
+ List<ClassInfo> list = new ArrayList<>();
|
|
|
|
|
+ for (Map<String, Object> row : rows)
|
|
|
|
|
+ list.add(new ClassInfo(rdLong(row.get("bjid")),
|
|
|
|
|
+ rdStr(row.get("mc")), rdLongObj(row.get("dwid")),
|
|
|
|
|
+ rdStr(row.get("dwmc"))));
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static ClassInfo requireTeacherClass(Db db, long ryid, long bjid)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ List<ClassInfo> classes = rdTeacherClasses(db, ryid);
|
|
|
|
|
+ if (classes.isEmpty())
|
|
|
|
|
+ throw new IllegalArgumentException("当前账号未关联班主任班级");
|
|
|
|
|
+ if (bjid <= 0)
|
|
|
|
|
+ return classes.get(0);
|
|
|
|
|
+ for (ClassInfo item : classes) {
|
|
|
|
|
+ if (item.bjid == bjid)
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new IllegalArgumentException("无权查看该班级");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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);
|
|
|
|
|
+ Set<LocalDate> schoolDays = rdSchoolDays(db, period);
|
|
|
|
|
+ Map<Long, Map<LocalDate, Double>> attendancePenalty =
|
|
|
|
|
+ rdAttendancePenalty(db, period);
|
|
|
|
|
+ book.attendance = computeAttendanceScores(
|
|
|
|
|
+ classes, schoolDays, attendancePenalty);
|
|
|
|
|
+
|
|
|
|
|
+ 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", mockMonthlyScore(
|
|
|
|
|
+ cls.bjid, period.month, "classroom", period.maxDay));
|
|
|
|
|
+ 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", SOURCE_MOCK);
|
|
|
|
|
+ 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);
|
|
|
|
|
+ score.adjust = adjustmentTotals(mockAdjustments(
|
|
|
|
|
+ cls.bjid, period.month, period.maxDay));
|
|
|
|
|
+ double weighted = 0.0;
|
|
|
|
|
+ for (CategoryDef def : CATEGORY_DEFS)
|
|
|
|
|
+ weighted += score.values.get(def.code) * def.weight;
|
|
|
|
|
+ score.total = round2(Math.max(0.0,
|
|
|
|
|
+ weighted + score.adjust.bonus - score.adjust.deduction));
|
|
|
|
|
+ score.hasMock = score.sources.containsValue(SOURCE_MOCK);
|
|
|
|
|
+ book.classScores.put(cls.bjid, score);
|
|
|
|
|
+ }
|
|
|
|
|
+ return book;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<Long, Double> rdAvgScoreByClass(Db db, String table,
|
|
|
|
|
+ MonthPeriod period)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ if (!"SSNWJC".equals(table) && !"CSWSJC".equals(table))
|
|
|
|
|
+ throw new IllegalArgumentException("评分表参数错误");
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
|
|
+ "select BJID,avg(FS) SCORE from " + table
|
|
|
|
|
+ + " where JCSJ>=:start and JCSJ<:end and "
|
|
|
|
|
+ + ObjC.JLZT_useStr + " 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 {
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
|
|
+ "select s.BJID,avg(case when q.MAX_SUM>0"
|
|
|
|
|
+ + " then q.SCORE_SUM*100/q.MAX_SUM else 0 end) SCORE"
|
|
|
|
|
+ + " from SQLJC s inner join ("
|
|
|
|
|
+ + " select m.SQLJCID,sum(m.FS) SCORE_SUM,sum(x.MFZ) MAX_SUM"
|
|
|
|
|
+ + " from SQLJCMX m inner join SQLJCXM x"
|
|
|
|
|
+ + " on x.SQLJCXMM=m.SQLJCXMM"
|
|
|
|
|
+ + " where m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m.FS is not null and x.MFZ is not null"
|
|
|
|
|
+ + " group by m.SQLJCID"
|
|
|
|
|
+ + " ) q on q.SQLJCID=s.SQLJCID"
|
|
|
|
|
+ + " where s.JCSJ>=:start and s.JCSJ<:end and s."
|
|
|
|
|
+ + ObjC.JLZT_useStr + " group by s.BJID");
|
|
|
|
|
+ sqlc.wrTimeParm("start", period.start);
|
|
|
|
|
+ sqlc.wrTimeParm("end", period.end);
|
|
|
|
|
+ return rdScoreMap(db.doSelMapListByC(sqlc));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Set<LocalDate> rdSchoolDays(Db db, MonthPeriod period)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
|
|
+ "select distinct trunc(KSSJ) D from KQJL"
|
|
|
|
|
+ + " where KSSJ>=:start and KSSJ<:end"
|
|
|
|
|
+ + " and KQJLZTM=51 and " + ObjC.JLZT_useStr);
|
|
|
|
|
+ sqlc.wrTimeParm("start", period.start);
|
|
|
|
|
+ sqlc.wrTimeParm("end", period.end);
|
|
|
|
|
+ Set<LocalDate> days = new LinkedHashSet<>();
|
|
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
|
|
|
|
|
+ LocalDate day = rdLocalDate(row.get("d"));
|
|
|
|
|
+ if (day != null && !day.isAfter(period.maxDate))
|
|
|
|
|
+ days.add(day);
|
|
|
|
|
+ }
|
|
|
|
|
+ return days;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<Long, Map<LocalDate, Double>> rdAttendancePenalty(
|
|
|
|
|
+ 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 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
|
|
|
|
|
+ + " group by BJID,trunc(KSSJ)");
|
|
|
|
|
+ sqlc.wrTimeParm("start", period.start);
|
|
|
|
|
+ sqlc.wrTimeParm("end", period.end);
|
|
|
|
|
+ Map<Long, Map<LocalDate, Double>> result = new HashMap<>();
|
|
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
|
|
|
|
|
+ long bjid = rdLong(row.get("bjid"));
|
|
|
|
|
+ LocalDate day = rdLocalDate(row.get("d"));
|
|
|
|
|
+ if (day == null || day.isAfter(period.maxDate))
|
|
|
|
|
+ continue;
|
|
|
|
|
+ result.computeIfAbsent(bjid, key -> new HashMap<>())
|
|
|
|
|
+ .put(day, rdDouble(row.get("penalty")));
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<Long, Double> computeAttendanceScores(
|
|
|
|
|
+ List<ClassInfo> classes, Set<LocalDate> schoolDays,
|
|
|
|
|
+ Map<Long, Map<LocalDate, Double>> penalties) {
|
|
|
|
|
+ Map<Long, Double> result = new HashMap<>();
|
|
|
|
|
+ if (schoolDays.isEmpty())
|
|
|
|
|
+ return result;
|
|
|
|
|
+ List<LocalDate> days = new ArrayList<>(schoolDays);
|
|
|
|
|
+ for (ClassInfo cls : classes) {
|
|
|
|
|
+ Map<LocalDate, Double> classPenalties = penalties.getOrDefault(
|
|
|
|
|
+ cls.bjid, Collections.emptyMap());
|
|
|
|
|
+ double total = 0.0;
|
|
|
|
|
+ for (LocalDate day : days) {
|
|
|
|
|
+ double penalty = classPenalties.getOrDefault(day, 0.0);
|
|
|
|
|
+ total += Math.max(0.0, 100.0 - penalty);
|
|
|
|
|
+ }
|
|
|
|
|
+ result.put(cls.bjid, round2(total / days.size()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static RankBook rdRanks(List<ClassInfo> classes, ScoreBook book) {
|
|
|
|
|
+ RankBook ranks = new RankBook();
|
|
|
|
|
+ List<ClassInfo> school = new ArrayList<>(classes);
|
|
|
|
|
+ school.sort(Comparator
|
|
|
|
|
+ .comparingDouble((ClassInfo cls) ->
|
|
|
|
|
+ -book.classScores.get(cls.bjid).total)
|
|
|
|
|
+ .thenComparingLong(cls -> cls.bjid));
|
|
|
|
|
+ assignRanks(school, book, ranks.schoolRank, "school");
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, List<ClassInfo>> departments = new LinkedHashMap<>();
|
|
|
|
|
+ for (ClassInfo cls : classes)
|
|
|
|
|
+ departments.computeIfAbsent(cls.dwid, key -> new ArrayList<>()).add(cls);
|
|
|
|
|
+ for (Map.Entry<Long, List<ClassInfo>> entry : departments.entrySet()) {
|
|
|
|
|
+ entry.getValue().sort(Comparator
|
|
|
|
|
+ .comparingDouble((ClassInfo cls) ->
|
|
|
|
|
+ -book.classScores.get(cls.bjid).total)
|
|
|
|
|
+ .thenComparingLong(cls -> cls.bjid));
|
|
|
|
|
+ assignRanks(entry.getValue(), book, ranks.departmentRank, "department");
|
|
|
|
|
+ ranks.departmentClassCount.put(entry.getKey(), entry.getValue().size());
|
|
|
|
|
+ }
|
|
|
|
|
+ return ranks;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static void assignRanks(List<ClassInfo> sorted, ScoreBook book,
|
|
|
|
|
+ Map<Long, Integer> rankMap, String type) {
|
|
|
|
|
+ double prev = Double.NaN;
|
|
|
|
|
+ int rank = 0;
|
|
|
|
|
+ for (int i = 0; i < sorted.size(); i++) {
|
|
|
|
|
+ ClassInfo cls = sorted.get(i);
|
|
|
|
|
+ double score = book.classScores.get(cls.bjid).total;
|
|
|
|
|
+ if (i == 0 || Double.compare(prev, score) != 0)
|
|
|
|
|
+ rank = i + 1;
|
|
|
|
|
+ rankMap.put(cls.bjid, rank);
|
|
|
|
|
+ prev = score;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<DailyAccumulator> rdDailyList(
|
|
|
|
|
+ Db db, ClassInfo cls, MonthPeriod period,
|
|
|
|
|
+ Map<String, String> sources) throws Exception {
|
|
|
|
|
+ CategoryDaily daily = rdCategoryDaily(db, cls, null, period);
|
|
|
|
|
+ Map<LocalDate, DailyAccumulator> days = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (CategoryDef def : CATEGORY_DEFS) {
|
|
|
|
|
+ String source = sources.getOrDefault(def.code, SOURCE_MOCK);
|
|
|
|
|
+ Map<LocalDate, DailyPoint> actual = daily.actual.get(def.code);
|
|
|
|
|
+ for (LocalDate date = period.month.atDay(1);
|
|
|
|
|
+ !date.isAfter(period.maxDate);
|
|
|
|
|
+ date = date.plusDays(1)) {
|
|
|
|
|
+ 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;
|
|
|
|
|
+ DailyAccumulator acc = days.computeIfAbsent(date,
|
|
|
|
|
+ DailyAccumulator::new);
|
|
|
|
|
+ acc.regularDeduction += Math.max(0.0, 100.0 - point.score);
|
|
|
|
|
+ acc.hasRegular = true;
|
|
|
|
|
+ if (SOURCE_MOCK.equals(source))
|
|
|
|
|
+ acc.hasMock = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<DailyAccumulator> result = new ArrayList<>(days.values());
|
|
|
|
|
+ result.sort(Comparator.comparing(
|
|
|
|
|
+ (DailyAccumulator item) -> item.date).reversed());
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static CategoryDaily rdCategoryDaily(Db db, ClassInfo cls,
|
|
|
|
|
+ LocalDate onlyDay,
|
|
|
|
|
+ MonthPeriod period)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ CategoryDaily result = new CategoryDaily(cls);
|
|
|
|
|
+ Timestamp start = onlyDay == null ? period.start
|
|
|
|
|
+ : Timestamp.valueOf(onlyDay.atStartOfDay());
|
|
|
|
|
+ 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("cleaning", rdDailyAvgScore(db, "CSWSJC",
|
|
|
|
|
+ cls.bjid, start, end));
|
|
|
|
|
+ result.actual.put("flag", rdDailyFlagScore(db, cls.bjid, start, end));
|
|
|
|
|
+ result.actual.put("attendance", rdDailyAttendanceScore(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));
|
|
|
|
|
+ result.sources.put("dorm", monthDorm.containsKey(cls.bjid)
|
|
|
|
|
+ ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
|
|
+ result.sources.put("classroom", SOURCE_MOCK);
|
|
|
|
|
+ result.sources.put("flag", monthFlag.containsKey(cls.bjid)
|
|
|
|
|
+ ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
|
|
+ result.sources.put("cleaning", monthClean.containsKey(cls.bjid)
|
|
|
|
|
+ ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
|
|
+ result.sources.put("discipline", SOURCE_MOCK);
|
|
|
|
|
+ result.sources.put("attendance", monthAttendance.containsKey(cls.bjid)
|
|
|
|
|
+ ? SOURCE_REAL : SOURCE_MOCK);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<LocalDate, DailyPoint> rdDailyAvgScore(
|
|
|
|
|
+ Db db, String table, long bjid, Timestamp start, Timestamp end)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
|
|
+ "select trunc(JCSJ) D,avg(FS) SCORE,count(*) CNT from "
|
|
|
|
|
+ + table + " where BJID=:bjid and JCSJ>=:start"
|
|
|
|
|
+ + " and JCSJ<:end and " + ObjC.JLZT_useStr
|
|
|
|
|
+ + " group by trunc(JCSJ)");
|
|
|
|
|
+ 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(
|
|
|
|
|
+ "select trunc(s.JCSJ) D,avg(case when q.MAX_SUM>0"
|
|
|
|
|
+ + " then q.SCORE_SUM*100/q.MAX_SUM else 0 end) SCORE,"
|
|
|
|
|
+ + "count(*) CNT from SQLJC s inner join ("
|
|
|
|
|
+ + " select m.SQLJCID,sum(m.FS) SCORE_SUM,sum(x.MFZ) MAX_SUM"
|
|
|
|
|
+ + " from SQLJCMX m inner join SQLJCXM x"
|
|
|
|
|
+ + " on x.SQLJCXMM=m.SQLJCXMM"
|
|
|
|
|
+ + " where m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m.FS is not null and x.MFZ is not null"
|
|
|
|
|
+ + " group by m.SQLJCID"
|
|
|
|
|
+ + ") q on q.SQLJCID=s.SQLJCID"
|
|
|
|
|
+ + " where s.BJID=:bjid and s.JCSJ>=:start"
|
|
|
|
|
+ + " and s.JCSJ<:end and s." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " group by trunc(s.JCSJ)");
|
|
|
|
|
+ sqlc.wrLongParm("bjid", bjid);
|
|
|
|
|
+ sqlc.wrTimeParm("start", start);
|
|
|
|
|
+ sqlc.wrTimeParm("end", end);
|
|
|
|
|
+ return rdDailyPoints(db.doSelMapListByC(sqlc));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<LocalDate, DailyPoint> rdDailyAttendanceScore(
|
|
|
|
|
+ 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 52 then 1 when 61 then 2 else 0 end) PENALTY,"
|
|
|
|
|
+ + "count(*) CNT from KQJL where BJID=:bjid"
|
|
|
|
|
+ + " and KSSJ>=:start and KSSJ<:end"
|
|
|
|
|
+ + " and KQJLZTM=51 and " + ObjC.JLZT_useStr
|
|
|
|
|
+ + " group by trunc(KSSJ)");
|
|
|
|
|
+ sqlc.wrLongParm("bjid", bjid);
|
|
|
|
|
+ sqlc.wrTimeParm("start", start);
|
|
|
|
|
+ sqlc.wrTimeParm("end", end);
|
|
|
|
|
+ Map<LocalDate, DailyPoint> points = new HashMap<>();
|
|
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
|
|
|
|
|
+ LocalDate day = rdLocalDate(row.get("d"));
|
|
|
|
|
+ if (day == null)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ double penalty = rdDouble(row.get("penalty"));
|
|
|
|
|
+ points.put(day, new DailyPoint(day,
|
|
|
|
|
+ Math.max(0.0, 100.0 - penalty),
|
|
|
|
|
+ rdInt(row.get("cnt"))));
|
|
|
|
|
+ }
|
|
|
|
|
+ return points;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<LocalDate, DailyPoint> rdDailyPoints(
|
|
|
|
|
+ List<Map<String, Object>> rows) {
|
|
|
|
|
+ Map<LocalDate, DailyPoint> points = new HashMap<>();
|
|
|
|
|
+ for (Map<String, Object> row : rows) {
|
|
|
|
|
+ LocalDate day = rdLocalDate(row.get("d"));
|
|
|
|
|
+ if (day != null)
|
|
|
|
|
+ points.put(day, new DailyPoint(day,
|
|
|
|
|
+ rdDouble(row.get("score")), rdInt(row.get("cnt"))));
|
|
|
|
|
+ }
|
|
|
|
|
+ return points;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<Map<String, Object>> rdDayDetail(
|
|
|
|
|
+ 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);
|
|
|
|
|
+ List<Map<String, Object>> rows;
|
|
|
|
|
+ if (SOURCE_REAL.equals(source)) {
|
|
|
|
|
+ if ("attendance".equals(category.code))
|
|
|
|
|
+ rows = rdAttendanceDetail(db, cls.bjid, day);
|
|
|
|
|
+ else if ("dorm".equals(category.code))
|
|
|
|
|
+ rows = rdItemDetail(db, cls.bjid, day, "dorm");
|
|
|
|
|
+ else if ("flag".equals(category.code))
|
|
|
|
|
+ rows = rdItemDetail(db, cls.bjid, day, "flag");
|
|
|
|
|
+ else if ("cleaning".equals(category.code))
|
|
|
|
|
+ rows = rdItemDetail(db, cls.bjid, day, "cleaning");
|
|
|
|
|
+ else
|
|
|
|
|
+ rows = mockDayDetail(cls, day, category.code);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ rows = mockDayDetail(cls, day, category.code);
|
|
|
|
|
+ }
|
|
|
|
|
+ rows.sort(Comparator.comparing(
|
|
|
|
|
+ (Map<String, Object> row) -> String.valueOf(
|
|
|
|
|
+ row.getOrDefault("sortTime", ""))).reversed());
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<Map<String, Object>> rdAttendanceDetail(
|
|
|
|
|
+ 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 k.KQJLID,k.KQLBM,lb.MC KQLBMC,k.RYID,ry.XM,k.MC,"
|
|
|
|
|
+ + "k.MS,k.KSSJ from KQJL k"
|
|
|
|
|
+ + " left join KQLB lb on lb.KQLBM=k.KQLBM"
|
|
|
|
|
+ + " left join RY ry on ry.RYID=k.RYID"
|
|
|
|
|
+ + " where k.BJID=:bjid and k.KSSJ>=:start"
|
|
|
|
|
+ + " and k.KSSJ<:end and k.KQJLZTM=51 and k."
|
|
|
|
|
+ + ObjC.JLZT_useStr
|
|
|
|
|
+ + " order by k.KSSJ desc,k.KQJLID desc");
|
|
|
|
|
+ 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)) {
|
|
|
|
|
+ int kqlbm = rdInt(row.get("kqlbm"));
|
|
|
|
|
+ Map<String, Object> item = baseDetail(day, SOURCE_REAL);
|
|
|
|
|
+ item.put("id", rdLong(row.get("kqjlid")));
|
|
|
|
|
+ item.put("sourceId", rdLong(row.get("kqjlid")));
|
|
|
|
|
+ item.put("category", "attendance");
|
|
|
|
|
+ item.put("traceable", true);
|
|
|
|
|
+ item.put("itemName", rdStr(row.get("kqlbmc")));
|
|
|
|
|
+ item.put("studentName", rdStr(row.get("xm")));
|
|
|
|
|
+ item.put("title", rdStr(row.get("mc")));
|
|
|
|
|
+ item.put("remark", rdStr(row.get("ms")));
|
|
|
|
|
+ item.put("delta", -attendancePenalty(kqlbm));
|
|
|
|
|
+ item.put("scoreText", "");
|
|
|
|
|
+ item.put("sortTime", formatTimestamp(row.get("kssj")));
|
|
|
|
|
+ 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());
|
|
|
|
|
+ Timestamp end = Timestamp.valueOf(day.plusDays(1).atStartOfDay());
|
|
|
|
|
+ String sql;
|
|
|
|
|
+ if ("dorm".equals(category)) {
|
|
|
|
|
+ sql = "select s.SSNWJCID ID,s.KFID,cd.MC KFMC,"
|
|
|
|
|
+ + "m.SSNWJCXMM XMM,m.FS,x.MFZ,x.MC XMMC,s.JCSJ"
|
|
|
|
|
+ + " from SSNWJC s inner join SSNWJCMX m"
|
|
|
|
|
+ + " on m.SSNWJCID=s.SSNWJCID"
|
|
|
|
|
+ + " inner join SSNWJCXM x on x.SSNWJCXMM=m.SSNWJCXMM"
|
|
|
|
|
+ + " left join CD cd on cd.CDID=s.KFID"
|
|
|
|
|
+ + " where s.BJID=:bjid and s.JCSJ>=:start"
|
|
|
|
|
+ + " and s.JCSJ<:end and s." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m.FS<x.MFZ"
|
|
|
|
|
+ + " order by s.JCSJ desc,m.SSNWJCMXID";
|
|
|
|
|
+ } else if ("flag".equals(category)) {
|
|
|
|
|
+ sql = "select s.SQLJCID ID,m.SQLJCXMM XMM,m.FS,x.MFZ,"
|
|
|
|
|
+ + "x.MC XMMC,s.JCSJ from SQLJC s"
|
|
|
|
|
+ + " inner join SQLJCMX m on m.SQLJCID=s.SQLJCID"
|
|
|
|
|
+ + " inner join SQLJCXM x on x.SQLJCXMM=m.SQLJCXMM"
|
|
|
|
|
+ + " where s.BJID=:bjid and s.JCSJ>=:start"
|
|
|
|
|
+ + " and s.JCSJ<:end and s." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and x.MFZ is not null and m.FS is not null"
|
|
|
|
|
+ + " and m.FS<x.MFZ order by s.JCSJ desc,m.SQLJCMXID";
|
|
|
|
|
+ } else if ("cleaning".equals(category)) {
|
|
|
|
|
+ sql = "select s.CSWSJCID ID,m.CSWSJCXMM XMM,m.FS,x.MFZ,"
|
|
|
|
|
+ + "x.MC XMMC,s.JCSJ from CSWSJC s"
|
|
|
|
|
+ + " inner join CSWSJCMX m on m.CSWSJCID=s.CSWSJCID"
|
|
|
|
|
+ + " inner join CSWSJCXM x on x.CSWSJCXMM=m.CSWSJCXMM"
|
|
|
|
|
+ + " where s.BJID=:bjid and s.JCSJ>=:start"
|
|
|
|
|
+ + " and s.JCSJ<:end and s." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and m.FS<x.MFZ order by s.JCSJ desc,m.CSWSJCMXID";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new IllegalArgumentException("明细类型参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ SqlCmd sqlc = new SqlCmd(sql);
|
|
|
|
|
+ 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)) {
|
|
|
|
|
+ int score = rdInt(row.get("fs"));
|
|
|
|
|
+ int maxScore = rdInt(row.get("mfz"));
|
|
|
|
|
+ Map<String, Object> item = baseDetail(day, SOURCE_REAL);
|
|
|
|
|
+ item.put("id", rdLong(row.get("id")));
|
|
|
|
|
+ item.put("sourceId", rdLong(row.get("id")));
|
|
|
|
|
+ item.put("category", category);
|
|
|
|
|
+ item.put("traceable", true);
|
|
|
|
|
+ item.put("itemName", rdStr(row.get("xmmc")));
|
|
|
|
|
+ item.put("studentName", "");
|
|
|
|
|
+ item.put("roomName", rdStr(row.get("kfmc")));
|
|
|
|
|
+ item.put("title", rdStr(row.get("xmmc")));
|
|
|
|
|
+ item.put("remark", "得分 " + score + " / " + maxScore);
|
|
|
|
|
+ item.put("delta", -(maxScore - score));
|
|
|
|
|
+ item.put("scoreText", score + "/" + maxScore);
|
|
|
|
|
+ item.put("sortTime", formatTimestamp(row.get("jcsj")));
|
|
|
|
|
+ result.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> rdTraceDetail(Db db, ClassInfo cls,
|
|
|
|
|
+ LocalDate day,
|
|
|
|
|
+ CategoryDef category,
|
|
|
|
|
+ long sourceId,
|
|
|
|
|
+ String source)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ if (SOURCE_MOCK.equals(source))
|
|
|
|
|
+ return rdMockTraceDetail(cls, day, category);
|
|
|
|
|
+ if (!SOURCE_REAL.equals(source))
|
|
|
|
|
+ throw new IllegalArgumentException("扣分来源参数错误");
|
|
|
|
|
+
|
|
|
|
|
+ if ("attendance".equals(category.code))
|
|
|
|
|
+ return rdAttendanceTrace(db, cls, day, category, sourceId);
|
|
|
|
|
+ if ("dorm".equals(category.code))
|
|
|
|
|
+ return rdCheckTrace(db, cls, day, category, sourceId, "dorm");
|
|
|
|
|
+ if ("flag".equals(category.code))
|
|
|
|
|
+ return rdCheckTrace(db, cls, day, category, sourceId, "flag");
|
|
|
|
|
+ if ("cleaning".equals(category.code))
|
|
|
|
|
+ return rdCheckTrace(db, cls, day, category, sourceId, "cleaning");
|
|
|
|
|
+ return rdMockTraceDetail(cls, day, category);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> rdCheckTrace(Db db, ClassInfo cls,
|
|
|
|
|
+ LocalDate day,
|
|
|
|
|
+ CategoryDef category,
|
|
|
|
|
+ long sourceId,
|
|
|
|
|
+ String type)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ String mainSql;
|
|
|
|
|
+ String itemSql;
|
|
|
|
|
+ if ("dorm".equals(type)) {
|
|
|
|
|
+ mainSql = "select s.SSNWJCID ID,s.JCSJ,s.FS,s.MS,s.KFID,"
|
|
|
|
|
+ + "cd.MC KFMC,b.MC BJMC,jc.XM JCRYXM from SSNWJC s"
|
|
|
|
|
+ + " left join CD cd on cd.CDID=s.KFID"
|
|
|
|
|
+ + " left join BJ b on b.BJID=s.BJID"
|
|
|
|
|
+ + " left join RY jc on jc.RYID=s.JCRYID"
|
|
|
|
|
+ + " where s.SSNWJCID=:id and s.BJID=:bjid and s."
|
|
|
|
|
+ + ObjC.JLZT_useStr;
|
|
|
|
|
+ itemSql = "select x.MC ITEM_NAME,m.FS CURRENT_SCORE,x.MFZ MAX_SCORE"
|
|
|
|
|
+ + " from SSNWJCMX m inner join SSNWJCXM x"
|
|
|
|
|
+ + " on x.SSNWJCXMM=m.SSNWJCXMM"
|
|
|
|
|
+ + " where m.SSNWJCID=:id and m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " order by x.SSNWJCXMM";
|
|
|
|
|
+ } else if ("flag".equals(type)) {
|
|
|
|
|
+ mainSql = "select s.SQLJCID ID,s.JCSJ,s.ZFS FS,s.MS,s.BMID,"
|
|
|
|
|
+ + "bm.MC BMMC,b.MC BJMC,jc.XM JCRYXM from SQLJC s"
|
|
|
|
|
+ + " left join BM bm on bm.BMID=s.BMID"
|
|
|
|
|
+ + " left join BJ b on b.BJID=s.BJID"
|
|
|
|
|
+ + " left join RY jc on jc.RYID=s.JCRYID"
|
|
|
|
|
+ + " where s.SQLJCID=:id and s.BJID=:bjid and s."
|
|
|
|
|
+ + ObjC.JLZT_useStr;
|
|
|
|
|
+ itemSql = "select x.MC ITEM_NAME,m.FS CURRENT_SCORE,x.MFZ MAX_SCORE"
|
|
|
|
|
+ + " from SQLJCMX m inner join SQLJCXM x"
|
|
|
|
|
+ + " on x.SQLJCXMM=m.SQLJCXMM"
|
|
|
|
|
+ + " where m.SQLJCID=:id and m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " order by x.SQLJCXMM";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mainSql = "select s.CSWSJCID ID,s.JCSJ,s.FS,s.MS,"
|
|
|
|
|
+ + "b.MC BJMC,jc.XM JCRYXM from CSWSJC s"
|
|
|
|
|
+ + " left join BJ b on b.BJID=s.BJID"
|
|
|
|
|
+ + " left join RY jc on jc.RYID=s.JCRYID"
|
|
|
|
|
+ + " where s.CSWSJCID=:id and s.BJID=:bjid and s."
|
|
|
|
|
+ + ObjC.JLZT_useStr;
|
|
|
|
|
+ itemSql = "select x.MC ITEM_NAME,m.FS CURRENT_SCORE,x.MFZ MAX_SCORE"
|
|
|
|
|
+ + " from CSWSJCMX m inner join CSWSJCXM x"
|
|
|
|
|
+ + " on x.CSWSJCXMM=m.CSWSJCXMM"
|
|
|
|
|
+ + " where m.CSWSJCID=:id and m." + ObjC.JLZT_useStr
|
|
|
|
|
+ + " order by x.CSWSJCXMM";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ SqlCmd mainCmd = new SqlCmd(mainSql);
|
|
|
|
|
+ mainCmd.wrLongParm("id", sourceId);
|
|
|
|
|
+ mainCmd.wrLongParm("bjid", cls.bjid);
|
|
|
|
|
+ List<Map<String, Object>> mainRows = db.doSelMapListByC(mainCmd);
|
|
|
|
|
+ if (mainRows == null || mainRows.isEmpty())
|
|
|
|
|
+ throw new IllegalArgumentException("扣分记录不存在或已不可查看");
|
|
|
|
|
+ Map<String, Object> main = mainRows.get(0);
|
|
|
|
|
+
|
|
|
|
|
+ SqlCmd itemCmd = new SqlCmd(itemSql);
|
|
|
|
|
+ itemCmd.wrLongParm("id", sourceId);
|
|
|
|
|
+ List<Map<String, Object>> itemRows = db.doSelMapListByC(itemCmd);
|
|
|
|
|
+ if (itemRows == null)
|
|
|
|
|
+ itemRows = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> items = new ArrayList<>();
|
|
|
|
|
+ for (Map<String, Object> row : itemRows) {
|
|
|
|
|
+ int current = rdInt(row.get("current_score"));
|
|
|
|
|
+ int max = rdInt(row.get("max_score"));
|
|
|
|
|
+ int deducted = Math.max(0, max - current);
|
|
|
|
|
+ if (deducted <= 0)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
|
|
+ item.put("itemName", rdStr(row.get("item_name")));
|
|
|
|
|
+ item.put("currentScore", current);
|
|
|
|
|
+ item.put("maxScore", max);
|
|
|
|
|
+ item.put("deducted", deducted);
|
|
|
|
|
+ item.put("remark", "得分 " + current + " / " + max);
|
|
|
|
|
+ items.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> record = new LinkedHashMap<>();
|
|
|
|
|
+ record.put("time", formatTimestamp(main.get("jcsj")));
|
|
|
|
|
+ record.put("className", defaultText(main.get("bjmc"), cls.bjmc));
|
|
|
|
|
+ record.put("roomName", defaultText(main.get("kfmc"), ""));
|
|
|
|
|
+ record.put("departmentName", defaultText(main.get("bmmc"), ""));
|
|
|
|
|
+ record.put("inspectorName", defaultText(main.get("jcryxm"), "未记录"));
|
|
|
|
|
+ record.put("totalScore", rdDouble(main.get("fs")));
|
|
|
|
|
+ record.put("description", defaultText(main.get("ms"), ""));
|
|
|
|
|
+ return traceResult(cls, day, category, SOURCE_REAL,
|
|
|
|
|
+ category.label + "扣分详情", record, items, "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> rdAttendanceTrace(Db db, ClassInfo cls,
|
|
|
|
|
+ LocalDate day,
|
|
|
|
|
+ CategoryDef category,
|
|
|
|
|
+ long sourceId)
|
|
|
|
|
+ throws Exception {
|
|
|
|
|
+ SqlCmd cmd = new SqlCmd(
|
|
|
|
|
+ "select k.KQJLID,k.KQLBM,lb.MC KQLBMC,k.RYID,ry.XM,"
|
|
|
|
|
+ + "k.MC,k.MS,k.KSSJ,k.JSSJ,k.BJID,b.MC BJMC"
|
|
|
|
|
+ + " from KQJL k left join KQLB lb on lb.KQLBM=k.KQLBM"
|
|
|
|
|
+ + " left join RY ry on ry.RYID=k.RYID"
|
|
|
|
|
+ + " left join BJ b on b.BJID=k.BJID"
|
|
|
|
|
+ + " where k.KQJLID=:id and k.BJID=:bjid"
|
|
|
|
|
+ + " and k.KQJLZTM=51 and k." + ObjC.JLZT_useStr);
|
|
|
|
|
+ cmd.wrLongParm("id", sourceId);
|
|
|
|
|
+ cmd.wrLongParm("bjid", cls.bjid);
|
|
|
|
|
+ List<Map<String, Object>> rows = db.doSelMapListByC(cmd);
|
|
|
|
|
+ if (rows == null || rows.isEmpty())
|
|
|
|
|
+ throw new IllegalArgumentException("考勤扣分记录不存在或已不可查看");
|
|
|
|
|
+ Map<String, Object> main = rows.get(0);
|
|
|
|
|
+ int kqlbm = rdInt(main.get("kqlbm"));
|
|
|
|
|
+ double deducted = attendancePenalty(kqlbm);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> record = new LinkedHashMap<>();
|
|
|
|
|
+ record.put("time", formatTimestamp(main.get("kssj")));
|
|
|
|
|
+ record.put("className", defaultText(main.get("bjmc"), cls.bjmc));
|
|
|
|
|
+ record.put("studentName", defaultText(main.get("xm"), ""));
|
|
|
|
|
+ record.put("inspectorName", "考勤系统");
|
|
|
|
|
+ record.put("description", defaultText(main.get("ms"), ""));
|
|
|
|
|
+ record.put("period", formatTimestamp(main.get("kssj")) + " - "
|
|
|
|
|
+ + formatTimestamp(main.get("jssj")));
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> items = new ArrayList<>();
|
|
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
|
|
+ item.put("itemName", defaultText(main.get("kqlbmc"), "考勤异常"));
|
|
|
|
|
+ item.put("deducted", deducted);
|
|
|
|
|
+ item.put("remark", defaultText(main.get("mc"), ""));
|
|
|
|
|
+ items.add(item);
|
|
|
|
|
+ return traceResult(cls, day, category, SOURCE_REAL,
|
|
|
|
|
+ category.label + "扣分详情", record, items, "");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> rdMockTraceDetail(ClassInfo cls,
|
|
|
|
|
+ LocalDate day,
|
|
|
|
|
+ CategoryDef category) {
|
|
|
|
|
+ double deduction = round2(Math.max(0.0, 100.0 - mockDailyScore(
|
|
|
|
|
+ cls.bjid, monthKey(YearMonth.from(day)), category.code,
|
|
|
|
|
+ day.getDayOfMonth())));
|
|
|
|
|
+ String[] names = mockBreakdownNames(category.code);
|
|
|
|
|
+ double first = round2(deduction * 0.6);
|
|
|
|
|
+ double second = round2(deduction - first);
|
|
|
|
|
+ List<Map<String, Object>> items = new ArrayList<>();
|
|
|
|
|
+ addMockTraceItem(items, names[0], first);
|
|
|
|
|
+ addMockTraceItem(items, names[1], second);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> record = new LinkedHashMap<>();
|
|
|
|
|
+ record.put("time", day.format(DATE_FMT));
|
|
|
|
|
+ record.put("className", cls.bjmc);
|
|
|
|
|
+ record.put("inspectorName", "模拟检查");
|
|
|
|
|
+ record.put("description", mockItemName(category.code));
|
|
|
|
|
+ return traceResult(cls, day, category, SOURCE_MOCK,
|
|
|
|
|
+ category.label + "模拟扣分详情", record, items,
|
|
|
|
|
+ "当前模块正式扣分数据尚未完善,以下为模拟扣分明细。");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static void addMockTraceItem(List<Map<String, Object>> items,
|
|
|
|
|
+ String name, double deducted) {
|
|
|
|
|
+ if (deducted <= 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
|
|
+ item.put("itemName", name);
|
|
|
|
|
+ item.put("deducted", round2(deducted));
|
|
|
|
|
+ item.put("remark", "模拟扣分");
|
|
|
|
|
+ items.add(item);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String[] mockBreakdownNames(String category) {
|
|
|
|
|
+ if ("dorm".equals(category))
|
|
|
|
|
+ return new String[]{"床铺与物品摆放", "地面及区域卫生"};
|
|
|
|
|
+ if ("flag".equals(category))
|
|
|
|
|
+ return new String[]{"队列纪律", "仪容仪表"};
|
|
|
|
|
+ if ("cleaning".equals(category))
|
|
|
|
|
+ return new String[]{"教室地面卫生", "桌面与角落卫生"};
|
|
|
|
|
+ if ("classroom".equals(category))
|
|
|
|
|
+ return new String[]{"课堂纪律", "课堂参与"};
|
|
|
|
|
+ if ("discipline".equals(category))
|
|
|
|
|
+ return new String[]{"校服着装", "发型与仪容"};
|
|
|
|
|
+ return new String[]{"考勤异常", "其他扣分"};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> traceResult(
|
|
|
|
|
+ ClassInfo cls, LocalDate day, CategoryDef category, String source,
|
|
|
|
|
+ String title, Map<String, Object> record,
|
|
|
|
|
+ List<Map<String, Object>> items, String notice) {
|
|
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
|
|
+ data.put("bjid", cls.bjid);
|
|
|
|
|
+ data.put("bjmc", cls.bjmc);
|
|
|
|
|
+ data.put("date", day.format(DATE_FMT));
|
|
|
|
|
+ data.put("category", category.code);
|
|
|
|
|
+ data.put("categoryLabel", category.label);
|
|
|
|
|
+ data.put("source", source);
|
|
|
|
|
+ data.put("title", title);
|
|
|
|
|
+ data.put("record", record);
|
|
|
|
|
+ data.put("items", items);
|
|
|
|
|
+ data.put("notice", notice);
|
|
|
|
|
+ return data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String defaultText(Object value, String defaultValue) {
|
|
|
|
|
+ String text = rdStr(value);
|
|
|
|
|
+ return StringUtils.isBlank(text) ? defaultValue : text;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<Map<String, Object>> rdAdjustmentRows(
|
|
|
|
|
+ List<Adjustment> adjustments) {
|
|
|
|
|
+ List<Map<String, Object>> rows = new ArrayList<>();
|
|
|
|
|
+ for (Adjustment item : adjustments) {
|
|
|
|
|
+ Map<String, Object> row = baseDetail(item.date, SOURCE_MOCK);
|
|
|
|
|
+ row.put("id", item.id);
|
|
|
|
|
+ row.put("itemName", item.itemName);
|
|
|
|
|
+ row.put("studentName", "");
|
|
|
|
|
+ row.put("title", item.itemName);
|
|
|
|
|
+ row.put("remark", item.remark);
|
|
|
|
|
+ row.put("delta", item.score);
|
|
|
|
|
+ row.put("scoreText", "");
|
|
|
|
|
+ row.put("sortTime", item.date.format(DATE_FMT));
|
|
|
|
|
+ rows.add(row);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<Map<String, Object>> mockDayDetail(
|
|
|
|
|
+ ClassInfo cls, LocalDate day, String category) {
|
|
|
|
|
+ List<Map<String, Object>> rows = new ArrayList<>();
|
|
|
|
|
+ String itemName = mockItemName(category);
|
|
|
|
|
+ double deduction = Math.max(0.0, 100.0 - mockDailyScore(
|
|
|
|
|
+ cls.bjid, monthKey(YearMonth.from(day)), category,
|
|
|
|
|
+ day.getDayOfMonth()));
|
|
|
|
|
+ if (deduction <= 0.0)
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ Map<String, Object> row = baseDetail(day, SOURCE_MOCK);
|
|
|
|
|
+ row.put("id", stableHash(cls.bjid + "|" + day + "|" + category));
|
|
|
|
|
+ row.put("sourceId", stableHash(cls.bjid + "|" + day + "|" + category));
|
|
|
|
|
+ row.put("category", category);
|
|
|
|
|
+ row.put("traceable", true);
|
|
|
|
|
+ row.put("itemName", itemName);
|
|
|
|
|
+ row.put("studentName", "");
|
|
|
|
|
+ row.put("title", itemName);
|
|
|
|
|
+ row.put("remark", "当前模块正式数据未完善,使用模拟扣分明细");
|
|
|
|
|
+ row.put("delta", -round2(deduction));
|
|
|
|
|
+ row.put("scoreText", round2(100.0 - deduction) + "/100");
|
|
|
|
|
+ row.put("sortTime", day.format(DATE_FMT));
|
|
|
|
|
+ rows.add(row);
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> baseDetail(LocalDate day, String source) {
|
|
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
|
|
+ item.put("date", day.format(DATE_FMT));
|
|
|
|
|
+ item.put("source", source);
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String mockItemName(String category) {
|
|
|
|
|
+ if ("classroom".equals(category))
|
|
|
|
|
+ return "课堂纪律";
|
|
|
|
|
+ if ("discipline".equals(category))
|
|
|
|
|
+ return "校服仪容";
|
|
|
|
|
+ if ("dorm".equals(category))
|
|
|
|
|
+ return "宿舍内务模拟扣分";
|
|
|
|
|
+ if ("flag".equals(category))
|
|
|
|
|
+ return "升旗礼队列模拟扣分";
|
|
|
|
|
+ if ("cleaning".equals(category))
|
|
|
|
|
+ return "清洁卫生模拟扣分";
|
|
|
|
|
+ if ("attendance".equals(category))
|
|
|
|
|
+ return "考勤模拟扣分";
|
|
|
|
|
+ return "模拟扣分";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static CategoryDef requireCategory(String code) {
|
|
|
|
|
+ for (CategoryDef def : CATEGORY_DEFS) {
|
|
|
|
|
+ if (def.code.equals(code))
|
|
|
|
|
+ return def;
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new IllegalArgumentException("评分项目参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static double scoreOrMock(Map<Long, Double> source, long bjid,
|
|
|
|
|
+ YearMonth month, String category, int maxDay) {
|
|
|
|
|
+ Double value = source.get(bjid);
|
|
|
|
|
+ return value == null ? mockMonthlyScore(bjid, month, category, maxDay)
|
|
|
|
|
+ : round2(value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static double mockMonthlyScore(long bjid, YearMonth month,
|
|
|
|
|
+ String category, int maxDay) {
|
|
|
|
|
+ double total = 0.0;
|
|
|
|
|
+ int count = 0;
|
|
|
|
|
+ for (int day = 1; day <= maxDay; day++) {
|
|
|
|
|
+ if (!mockHasEvent(bjid, monthKey(month), category, day))
|
|
|
|
|
+ continue;
|
|
|
|
|
+ total += mockDailyScore(bjid, monthKey(month), category, day);
|
|
|
|
|
+ count++;
|
|
|
|
|
+ }
|
|
|
|
|
+ return count == 0 ? 95.0 : round2(total / count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static boolean mockHasEvent(long bjid, String month,
|
|
|
|
|
+ String category, int day) {
|
|
|
|
|
+ int hash = stableHash(bjid + "|" + month + "|" + category + "|" + day);
|
|
|
|
|
+ return Math.floorMod(hash, 100) < 28;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static double mockDailyScore(long bjid, String month,
|
|
|
|
|
+ String category, int day) {
|
|
|
|
|
+ int hash = stableHash(bjid + "|" + month + "|" + category
|
|
|
|
|
+ + "|score|" + day);
|
|
|
|
|
+ return round2(84.0 + Math.floorMod(hash, 1600) / 100.0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static List<Adjustment> mockAdjustments(long bjid, YearMonth month,
|
|
|
|
|
+ int maxDay) {
|
|
|
|
|
+ List<Adjustment> list = new ArrayList<>();
|
|
|
|
|
+ String prefix = bjid + "|" + monthKey(month) + "|adjust|";
|
|
|
|
|
+ addMockAdjustment(list, bjid, month, maxDay, "bonus", 1, prefix);
|
|
|
|
|
+ addMockAdjustment(list, bjid, month, maxDay, "bonus", 2, prefix);
|
|
|
|
|
+ addMockAdjustment(list, bjid, month, maxDay, "deduction", 1, prefix);
|
|
|
|
|
+ addMockAdjustment(list, bjid, month, maxDay, "deduction", 2, prefix);
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static void addMockAdjustment(List<Adjustment> list, long bjid,
|
|
|
|
|
+ YearMonth month, int maxDay,
|
|
|
|
|
+ String type, int seq, String prefix) {
|
|
|
|
|
+ int hash = stableHash(prefix + type + "|" + seq);
|
|
|
|
|
+ if (Math.floorMod(hash, 100) >= 72)
|
|
|
|
|
+ return;
|
|
|
|
|
+ int day = 1 + Math.floorMod(hash, maxDay);
|
|
|
|
|
+ double score = round2(0.5 + Math.floorMod(hash >>> 7, 250) / 100.0);
|
|
|
|
|
+ boolean bonus = "bonus".equals(type);
|
|
|
|
|
+ String[] names = bonus ? BONUS_ITEMS : DEDUCTION_ITEMS;
|
|
|
|
|
+ String itemName = names[Math.floorMod(hash >>> 11, names.length)];
|
|
|
|
|
+ list.add(new Adjustment(
|
|
|
|
|
+ stableHash(prefix + type + "|" + seq + "|id"),
|
|
|
|
|
+ month.atDay(day), bonus ? score : -score, itemName,
|
|
|
|
|
+ bonus ? "班级表现优秀,使用模拟增分"
|
|
|
|
|
+ : "班级管理事项,使用模拟减分"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static AdjustmentTotals adjustmentTotals(
|
|
|
|
|
+ List<Adjustment> adjustments) {
|
|
|
|
|
+ AdjustmentTotals total = new AdjustmentTotals();
|
|
|
|
|
+ for (Adjustment item : adjustments) {
|
|
|
|
|
+ if (item.score > 0) {
|
|
|
|
|
+ total.bonus += item.score;
|
|
|
|
|
+ total.bonusEvents++;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ total.deduction += Math.abs(item.score);
|
|
|
|
|
+ total.deductionEvents++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ total.bonus = round2(total.bonus);
|
|
|
|
|
+ total.deduction = round2(total.deduction);
|
|
|
|
|
+ return total;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String starLevel(double score) {
|
|
|
|
|
+ if (score >= 90.0)
|
|
|
|
|
+ return "五星级";
|
|
|
|
|
+ if (score >= 80.0)
|
|
|
|
|
+ return "四星级";
|
|
|
|
|
+ if (score >= 70.0)
|
|
|
|
|
+ return "三星级";
|
|
|
|
|
+ return "二星级";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static int attendancePenalty(int kqlbm) {
|
|
|
|
|
+ return switch (kqlbm) {
|
|
|
|
|
+ case 1 -> 3;
|
|
|
|
|
+ case 21 -> 1;
|
|
|
|
|
+ case 51 -> 2;
|
|
|
|
|
+ case 52 -> 1;
|
|
|
|
|
+ case 61 -> 2;
|
|
|
|
|
+ default -> 0;
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static YearMonth rdMonth(HttpServletRequest request) {
|
|
|
|
|
+ String value = StringUtils.trimToNull(request.getParameter("month"));
|
|
|
|
|
+ YearMonth now = YearMonth.now(CN_ZONE);
|
|
|
|
|
+ YearMonth month = value == null ? now : YearMonth.parse(value, MONTH_FMT);
|
|
|
|
|
+ if (month.isAfter(now))
|
|
|
|
|
+ throw new IllegalArgumentException("不能查询未来月份");
|
|
|
|
|
+ return month;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static LocalDate rdDate(HttpServletRequest request, String name) {
|
|
|
|
|
+ String value = StringUtils.trimToNull(request.getParameter(name));
|
|
|
|
|
+ if (value == null)
|
|
|
|
|
+ throw new IllegalArgumentException("缺少参数:" + name);
|
|
|
|
|
+ return LocalDate.parse(value, DATE_FMT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static long rdLongParam(HttpServletRequest request, String name,
|
|
|
|
|
+ boolean required) {
|
|
|
|
|
+ String value = StringUtils.trimToNull(request.getParameter(name));
|
|
|
|
|
+ if (value == null) {
|
|
|
|
|
+ if (required)
|
|
|
|
|
+ throw new IllegalArgumentException("缺少参数:" + name);
|
|
|
|
|
+ return 0L;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ return Long.parseLong(value);
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ throw new IllegalArgumentException("参数格式错误:" + name);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static int rdIntParam(HttpServletRequest request, String name,
|
|
|
|
|
+ int defaultValue) {
|
|
|
|
|
+ String value = StringUtils.trimToNull(request.getParameter(name));
|
|
|
|
|
+ if (value == null)
|
|
|
|
|
+ return defaultValue;
|
|
|
|
|
+ try {
|
|
|
|
|
+ return Integer.parseInt(value);
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ throw new IllegalArgumentException("参数格式错误:" + name);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static int clampPageSize(int value) {
|
|
|
|
|
+ return Math.max(1, Math.min(100, value));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<Long, Double> rdScoreMap(
|
|
|
|
|
+ List<Map<String, Object>> rows) {
|
|
|
|
|
+ Map<Long, Double> result = new HashMap<>();
|
|
|
|
|
+ for (Map<String, Object> row : rows)
|
|
|
|
|
+ result.put(rdLong(row.get("bjid")), round2(
|
|
|
|
|
+ rdDouble(row.get("score"))));
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static LocalDate rdLocalDate(Object value) {
|
|
|
|
|
+ if (value instanceof Date)
|
|
|
|
|
+ return ((Date) value).toLocalDate();
|
|
|
|
|
+ if (value instanceof Timestamp)
|
|
|
|
|
+ return ((Timestamp) value).toLocalDateTime().toLocalDate();
|
|
|
|
|
+ if (value == null)
|
|
|
|
|
+ return null;
|
|
|
|
|
+ String text = String.valueOf(value);
|
|
|
|
|
+ if (text.length() >= 10)
|
|
|
|
|
+ return LocalDate.parse(text.substring(0, 10), DATE_FMT);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String formatTimestamp(Object value) {
|
|
|
|
|
+ if (value instanceof Timestamp)
|
|
|
|
|
+ return ((Timestamp) value).toLocalDateTime().format(DATETIME_FMT);
|
|
|
|
|
+ return value == null ? "" : String.valueOf(value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String weekdayCn(LocalDate date) {
|
|
|
|
|
+ DayOfWeek day = date.getDayOfWeek();
|
|
|
|
|
+ return switch (day) {
|
|
|
|
|
+ case MONDAY -> "星期一";
|
|
|
|
|
+ case TUESDAY -> "星期二";
|
|
|
|
|
+ case WEDNESDAY -> "星期三";
|
|
|
|
|
+ case THURSDAY -> "星期四";
|
|
|
|
|
+ case FRIDAY -> "星期五";
|
|
|
|
|
+ case SATURDAY -> "星期六";
|
|
|
|
|
+ case SUNDAY -> "星期日";
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String monthKey(YearMonth month) {
|
|
|
|
|
+ return month.format(MONTH_FMT);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static int stableHash(String value) {
|
|
|
|
|
+ int hash = 17;
|
|
|
|
|
+ for (int i = 0; i < value.length(); i++)
|
|
|
|
|
+ hash = 31 * hash + value.charAt(i);
|
|
|
|
|
+ return hash;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static long rdLong(Object value) {
|
|
|
|
|
+ return value == null ? 0L : Long.parseLong(String.valueOf(value));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static Long rdLongObj(Object value) {
|
|
|
|
|
+ return value == null ? null : Long.valueOf(String.valueOf(value));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static int rdInt(Object value) {
|
|
|
|
|
+ return value == null ? 0 : Integer.parseInt(String.valueOf(value));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static double rdDouble(Object value) {
|
|
|
|
|
+ return value == null ? 0.0 : Double.parseDouble(String.valueOf(value));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static String rdStr(Object value) {
|
|
|
|
|
+ return value == null ? null : String.valueOf(value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static double round2(double value) {
|
|
|
|
|
+ return Math.round(value * 100.0) / 100.0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class MonthPeriod {
|
|
|
|
|
+ final YearMonth month;
|
|
|
|
|
+ final Timestamp start;
|
|
|
|
|
+ final Timestamp end;
|
|
|
|
|
+ final LocalDate maxDate;
|
|
|
|
|
+ final int maxDay;
|
|
|
|
|
+
|
|
|
|
|
+ private MonthPeriod(YearMonth month) {
|
|
|
|
|
+ this.month = month;
|
|
|
|
|
+ LocalDate first = month.atDay(1);
|
|
|
|
|
+ LocalDate today = LocalDate.now(CN_ZONE);
|
|
|
|
|
+ LocalDate monthEnd = month.atEndOfMonth();
|
|
|
|
|
+ this.maxDate = month.equals(YearMonth.from(today))
|
|
|
|
|
+ ? today : monthEnd;
|
|
|
|
|
+ this.maxDay = maxDate.getDayOfMonth();
|
|
|
|
|
+ this.start = Timestamp.valueOf(first.atStartOfDay());
|
|
|
|
|
+ this.end = Timestamp.valueOf(maxDate.plusDays(1).atStartOfDay());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static MonthPeriod of(YearMonth month) {
|
|
|
|
|
+ return new MonthPeriod(month);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class ClassInfo {
|
|
|
|
|
+ final long bjid;
|
|
|
|
|
+ final String bjmc;
|
|
|
|
|
+ final Long dwid;
|
|
|
|
|
+ final String dwmc;
|
|
|
|
|
+
|
|
|
|
|
+ ClassInfo(long bjid, String bjmc, Long dwid, String dwmc) {
|
|
|
|
|
+ this.bjid = bjid;
|
|
|
|
|
+ this.bjmc = bjmc;
|
|
|
|
|
+ this.dwid = dwid;
|
|
|
|
|
+ this.dwmc = dwmc;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private record CategoryDef(String code, String label, double weight) {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class DailyPoint {
|
|
|
|
|
+ final LocalDate date;
|
|
|
|
|
+ final double score;
|
|
|
|
|
+ final int count;
|
|
|
|
|
+
|
|
|
|
|
+ DailyPoint(LocalDate date, double score, int count) {
|
|
|
|
|
+ this.date = date;
|
|
|
|
|
+ this.score = score;
|
|
|
|
|
+ this.count = count;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class DailyAccumulator {
|
|
|
|
|
+ final LocalDate date;
|
|
|
|
|
+ double regularDeduction;
|
|
|
|
|
+ boolean hasRegular;
|
|
|
|
|
+ boolean hasMock;
|
|
|
|
|
+
|
|
|
|
|
+ DailyAccumulator(LocalDate date) {
|
|
|
|
|
+ this.date = date;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> toMap() {
|
|
|
|
|
+ Map<String, Object> row = new LinkedHashMap<>();
|
|
|
|
|
+ row.put("date", date.format(DATE_FMT));
|
|
|
|
|
+ row.put("weekday", weekdayCn(date));
|
|
|
|
|
+ row.put("regularDeduction", round2(regularDeduction));
|
|
|
|
|
+ row.put("totalDeduction", round2(regularDeduction));
|
|
|
|
|
+ row.put("hasRegular", hasRegular);
|
|
|
|
|
+ row.put("hasMock", hasMock);
|
|
|
|
|
+ return row;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class CategoryDaily {
|
|
|
|
|
+ final ClassInfo cls;
|
|
|
|
|
+ final Map<String, Map<LocalDate, DailyPoint>> actual = new HashMap<>();
|
|
|
|
|
+ final Map<String, String> sources = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ CategoryDaily(ClassInfo cls) {
|
|
|
|
|
+ this.cls = cls;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> toMap(CategoryDef def, LocalDate date) {
|
|
|
|
|
+ String source = sources.getOrDefault(def.code, SOURCE_MOCK);
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ double score = point == null ? 100.0 : point.score;
|
|
|
|
|
+ Map<String, Object> row = new LinkedHashMap<>();
|
|
|
|
|
+ row.put("code", def.code);
|
|
|
|
|
+ row.put("label", def.label);
|
|
|
|
|
+ row.put("score", round2(score));
|
|
|
|
|
+ row.put("deduction", round2(Math.max(0.0, 100.0 - score)));
|
|
|
|
|
+ row.put("source", source);
|
|
|
|
|
+ row.put("count", point == null ? 0 : point.count);
|
|
|
|
|
+ return row;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ double regularDeduction(LocalDate date) {
|
|
|
|
|
+ double total = 0.0;
|
|
|
|
|
+ for (CategoryDef def : CATEGORY_DEFS) {
|
|
|
|
|
+ Map<String, Object> row = toMap(def, date);
|
|
|
|
|
+ total += rdDouble(row.get("deduction"));
|
|
|
|
|
+ }
|
|
|
|
|
+ return total;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class ScoreBook {
|
|
|
|
|
+ Map<Long, Double> dorm = new HashMap<>();
|
|
|
|
|
+ Map<Long, Double> flag = new HashMap<>();
|
|
|
|
|
+ Map<Long, Double> cleaning = new HashMap<>();
|
|
|
|
|
+ Map<Long, Double> attendance = new HashMap<>();
|
|
|
|
|
+ Map<Long, ClassScore> classScores = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> categorySources(long bjid) {
|
|
|
|
|
+ ClassScore score = classScores.get(bjid);
|
|
|
|
|
+ return score == null ? Collections.emptyMap() : score.sources;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class ClassScore {
|
|
|
|
|
+ final Map<String, Double> values = new LinkedHashMap<>();
|
|
|
|
|
+ final Map<String, String> sources = new LinkedHashMap<>();
|
|
|
|
|
+ AdjustmentTotals adjust = new AdjustmentTotals();
|
|
|
|
|
+ double total;
|
|
|
|
|
+ boolean hasMock;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class RankBook {
|
|
|
|
|
+ final Map<Long, Integer> schoolRank = new HashMap<>();
|
|
|
|
|
+ final Map<Long, Integer> departmentRank = new HashMap<>();
|
|
|
|
|
+ final Map<Long, Integer> departmentClassCount = new HashMap<>();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class Adjustment {
|
|
|
|
|
+ final long id;
|
|
|
|
|
+ final LocalDate date;
|
|
|
|
|
+ final double score;
|
|
|
|
|
+ final String itemName;
|
|
|
|
|
+ final String remark;
|
|
|
|
|
+
|
|
|
|
|
+ Adjustment(long id, LocalDate date, double score,
|
|
|
|
|
+ String itemName, String remark) {
|
|
|
|
|
+ this.id = id;
|
|
|
|
|
+ this.date = date;
|
|
|
|
|
+ this.score = score;
|
|
|
|
|
+ this.itemName = itemName;
|
|
|
|
|
+ this.remark = remark;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private static final class AdjustmentTotals {
|
|
|
|
|
+ double bonus;
|
|
|
|
|
+ double deduction;
|
|
|
|
|
+ int bonusEvents;
|
|
|
|
|
+ int deductionEvents;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|