|
|
@@ -46,6 +46,7 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
private static final String SOURCE_REAL = "real";
|
|
|
private static final String SOURCE_MISSING = "missing";
|
|
|
+ private static final String SOURCE_THIRD = "third";
|
|
|
private static final String FORMULA_VERSION = "SC-2024-10-V1";
|
|
|
private static final String SCOPE_SCHOOL = "XX";
|
|
|
private static final long SCHOOL_SCOPE_ID = 0L;
|
|
|
@@ -129,8 +130,12 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
if (user == null)
|
|
|
throw new IllegalArgumentException("登录状态已失效,请重新登录");
|
|
|
YearMonth month = rdMonth(request.getParameter("month"));
|
|
|
+ Long impid = rdLongOrNull(request.getParameter("impid"));
|
|
|
Map<String, Object> data = closeSchoolMonth(
|
|
|
- db, month, user, false, "星级班全校月结");
|
|
|
+ db, month, user, false,
|
|
|
+ impid == null ? "星级班全校月结"
|
|
|
+ : "第三方星级班导入验证",
|
|
|
+ impid);
|
|
|
if (Boolean.TRUE.equals(data.get("created")))
|
|
|
db.commit();
|
|
|
ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
@@ -324,6 +329,12 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
private Map<String, Object> closeSchoolMonth(
|
|
|
Db db, YearMonth month, UserRunB user, boolean correction,
|
|
|
String reason) throws Exception {
|
|
|
+ return closeSchoolMonth(db, month, user, correction, reason, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> closeSchoolMonth(
|
|
|
+ Db db, YearMonth month, UserRunB user, boolean correction,
|
|
|
+ String reason, Long impid) throws Exception {
|
|
|
if (!month.isBefore(YearMonth.now(CN_ZONE)))
|
|
|
throw new IllegalArgumentException("只能月结已经结束的月份");
|
|
|
|
|
|
@@ -340,15 +351,21 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
return skipped;
|
|
|
}
|
|
|
|
|
|
- List<ClassRow> classes = rdSchoolClasses(db);
|
|
|
+ List<ClassRow> classes = impid == null
|
|
|
+ ? rdSchoolClasses(db)
|
|
|
+ : rdImportedClasses(db, month, impid);
|
|
|
if (classes.isEmpty())
|
|
|
throw new IllegalArgumentException("没有可月结的在用班级");
|
|
|
|
|
|
- XjbJfServ teamSnapshot = new XjbJfServ();
|
|
|
- for (ClassRow cls : classes)
|
|
|
- teamSnapshot.rebuildTeamSnapshot(db, cls.bjid, month, user);
|
|
|
-
|
|
|
- List<ClassResult> results = calculate(db, classes, month);
|
|
|
+ List<ClassResult> results;
|
|
|
+ if (impid == null) {
|
|
|
+ XjbJfServ teamSnapshot = new XjbJfServ();
|
|
|
+ for (ClassRow cls : classes)
|
|
|
+ teamSnapshot.rebuildTeamSnapshot(db, cls.bjid, month, user);
|
|
|
+ results = calculate(db, classes, month);
|
|
|
+ } else {
|
|
|
+ results = calculateImported(db, classes, month, impid);
|
|
|
+ }
|
|
|
ensureComplete(results);
|
|
|
assignRanks(results);
|
|
|
|
|
|
@@ -417,6 +434,102 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
return rows;
|
|
|
}
|
|
|
|
|
|
+ private List<ClassRow> rdImportedClasses(Db db, YearMonth month, long impid)
|
|
|
+ throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select b.BJID,b.MC BJMC,b.DWID,b.ZYID,z.FZBMID DEPTID"
|
|
|
+ + " from XJB_IMP_WB w"
|
|
|
+ + " inner join BJ b on b.BJID=w.BJID"
|
|
|
+ + " inner join ZY z on z.ZYID=b.ZYID"
|
|
|
+ + " where w.IMPID=:impid and w.NDY=:ndy"
|
|
|
+ + " and b." + ObjC.JLZT_useStr
|
|
|
+ + " and b.BJZTM!=81"
|
|
|
+ + " order by b.MC,b.BJID");
|
|
|
+ sqlc.wrLongParm("impid", impid);
|
|
|
+ sqlc.wrStrParm("ndy", month.format(MONTH_FMT));
|
|
|
+ List<ClassRow> rows = new ArrayList<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
|
|
|
+ rows.add(new ClassRow(
|
|
|
+ rdLong(row.get("bjid"), 0L),
|
|
|
+ rdStr(row.get("bjmc")),
|
|
|
+ rdLongOrNull(row.get("dwid")),
|
|
|
+ rdLongOrNull(row.get("zyid")),
|
|
|
+ rdLongOrNull(row.get("deptid"))));
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ClassResult> calculateImported(
|
|
|
+ Db db, List<ClassRow> classes, YearMonth month, long impid)
|
|
|
+ throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select BJID,KQDF,FJDF,CSDF,SJDF,SSDF,KTDF,"
|
|
|
+ + "ZJF,KJF,ZJFCS,KJFCS,THIRD_ZF,THIRD_XJ"
|
|
|
+ + " from XJB_IMP_WB"
|
|
|
+ + " where IMPID=:impid and NDY=:ndy");
|
|
|
+ sqlc.wrLongParm("impid", impid);
|
|
|
+ sqlc.wrStrParm("ndy", month.format(MONTH_FMT));
|
|
|
+ Map<Long, Map<String, Object>> imported = new HashMap<>();
|
|
|
+ for (Map<String, Object> row : db.doSelMapListByC(sqlc))
|
|
|
+ imported.put(rdLong(row.get("bjid"), 0L), row);
|
|
|
+
|
|
|
+ List<ClassResult> result = new ArrayList<>();
|
|
|
+ for (ClassRow cls : classes) {
|
|
|
+ ClassResult item = new ClassResult(cls);
|
|
|
+ item.ndy = month.format(MONTH_FMT);
|
|
|
+ Map<String, Object> row = imported.get(cls.bjid);
|
|
|
+ if (row == null) {
|
|
|
+ item.dorm = component(null, "第三方月结快照");
|
|
|
+ item.classroom = component(null, "第三方月结快照");
|
|
|
+ item.flag = component(null, "第三方月结快照");
|
|
|
+ item.cleaning = component(null, "第三方月结快照");
|
|
|
+ item.discipline = component(null, "第三方月结快照");
|
|
|
+ item.attendance = component(null, "第三方月结快照");
|
|
|
+ } else {
|
|
|
+ item.dorm = importedComponent(row.get("ssdf"),
|
|
|
+ "第三方月结宿舍评分");
|
|
|
+ item.classroom = importedComponent(row.get("ktdf"),
|
|
|
+ "第三方月结课堂考核");
|
|
|
+ item.flag = importedComponent(row.get("sjdf"),
|
|
|
+ "第三方月结升旗礼");
|
|
|
+ item.cleaning = importedComponent(row.get("csdf"),
|
|
|
+ "第三方月结清洁卫生");
|
|
|
+ item.discipline = importedComponent(row.get("fjdf"),
|
|
|
+ "第三方月结风纪仪容");
|
|
|
+ item.attendance = importedComponent(row.get("kqdf"),
|
|
|
+ "第三方月结考勤");
|
|
|
+
|
|
|
+ item.adjust.otherBonus = Math.max(
|
|
|
+ 0.0, rdDouble(row.get("zjf")));
|
|
|
+ item.adjust.bonus = XjbJfServ.capBonus(
|
|
|
+ item.adjust.otherBonus, 0.0);
|
|
|
+ item.adjust.deduction = Math.max(
|
|
|
+ 0.0, rdDouble(row.get("kjf")));
|
|
|
+ item.adjust.bonusCount = rdInt(row.get("zjfcs"));
|
|
|
+ item.adjust.deductionCount = rdInt(row.get("kjfcs"));
|
|
|
+ }
|
|
|
+ addMissing(item, "宿舍评分", item.dorm);
|
|
|
+ addMissing(item, "课堂考核", item.classroom);
|
|
|
+ addMissing(item, "升旗礼", item.flag);
|
|
|
+ addMissing(item, "清洁卫生", item.cleaning);
|
|
|
+ addMissing(item, "风纪仪容", item.discipline);
|
|
|
+ addMissing(item, "考勤", item.attendance);
|
|
|
+ if (item.missing.isEmpty()) {
|
|
|
+ double weighted = item.dorm.value * 0.20
|
|
|
+ + item.classroom.value * 0.05
|
|
|
+ + item.flag.value * 0.14
|
|
|
+ + item.cleaning.value * 0.18
|
|
|
+ + item.discipline.value * 0.20
|
|
|
+ + item.attendance.value * 0.15;
|
|
|
+ item.total = round2(weighted
|
|
|
+ + Math.min(8.0, item.adjust.bonus)
|
|
|
+ - item.adjust.deduction);
|
|
|
+ }
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private void ensureComplete(List<ClassResult> results) {
|
|
|
List<ClassResult> missing = new ArrayList<>();
|
|
|
for (ClassResult result : results) {
|
|
|
@@ -795,6 +908,14 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
+ private Component importedComponent(Object value, String detail) {
|
|
|
+ Component item = new Component();
|
|
|
+ item.value = value == null ? null : round2(rdDouble(value));
|
|
|
+ item.source = value == null ? SOURCE_MISSING : SOURCE_THIRD;
|
|
|
+ item.detail = detail;
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+
|
|
|
private Component disciplineComponent(DisciplineScore score) {
|
|
|
Component item = new Component();
|
|
|
if (score == null)
|