|
|
@@ -2,6 +2,7 @@ package biz.bj;
|
|
|
|
|
|
import base.po.XjbJdPo;
|
|
|
import base.po.XjbJgPo;
|
|
|
+import base.po.XjbJgmxPo;
|
|
|
import base.po.XjbPmPo;
|
|
|
import com.google.gson.Gson;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
@@ -45,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 FORMULA_VERSION = "SC-2024-10-V1";
|
|
|
private static final String SCOPE_SCHOOL = "XX";
|
|
|
private static final long SCHOOL_SCOPE_ID = 0L;
|
|
|
private static final int JD_DRAFT = 1;
|
|
|
@@ -90,8 +92,10 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
deleteDraftBatch(db, month, bmid);
|
|
|
long jdid = insertBatch(db, month, "BM", bmid, 1,
|
|
|
null, "部门星级班月结", user);
|
|
|
- for (ClassResult result : results)
|
|
|
- insertResult(db, jdid, result, user);
|
|
|
+ for (ClassResult result : results) {
|
|
|
+ long jgid = insertResult(db, jdid, result, user);
|
|
|
+ insertResultDetail(db, jdid, jgid, result, user);
|
|
|
+ }
|
|
|
db.commit();
|
|
|
|
|
|
Map<String, Object> data = new LinkedHashMap<>();
|
|
|
@@ -358,8 +362,10 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
|
|
|
long jdid = insertBatch(db, month, SCOPE_SCHOOL, SCHOOL_SCOPE_ID,
|
|
|
version, previousId, reason, user);
|
|
|
- for (ClassResult result : results)
|
|
|
- insertResult(db, jdid, result, user);
|
|
|
+ for (ClassResult result : results) {
|
|
|
+ long jgid = insertResult(db, jdid, result, user);
|
|
|
+ insertResultDetail(db, jdid, jgid, result, user);
|
|
|
+ }
|
|
|
|
|
|
Map<String, Object> data = new LinkedHashMap<>();
|
|
|
data.put("month", month.format(MONTH_FMT));
|
|
|
@@ -507,11 +513,13 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
ClassResult item = new ClassResult(cls);
|
|
|
item.ndy = month.format(MONTH_FMT);
|
|
|
item.dorm = dormComponent(dorm.get(cls.bjid));
|
|
|
+ item.dormDetail = dorm.get(cls.bjid);
|
|
|
item.classroom = component(classroom.get(cls.bjid),
|
|
|
"课堂日志");
|
|
|
item.flag = component(flag.get(cls.bjid), "升旗礼");
|
|
|
item.cleaning = component(cleaning.get(cls.bjid), "场室卫生");
|
|
|
item.discipline = disciplineComponent(discipline.get(cls.bjid));
|
|
|
+ item.disciplineDetail = discipline.get(cls.bjid);
|
|
|
item.attendance = component(attendance.get(cls.bjid), "考勤");
|
|
|
item.adjust = adjustments.getOrDefault(cls.bjid,
|
|
|
new AdjustmentTotals());
|
|
|
@@ -765,9 +773,12 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
Map<Long, AdjustmentTotals> result = new HashMap<>();
|
|
|
for (Map<String, Object> row : db.doSelMapListByC(sqlc)) {
|
|
|
AdjustmentTotals total = new AdjustmentTotals();
|
|
|
+ total.otherBonus = Math.max(
|
|
|
+ 0.0, rdDouble(row.get("other_bonus")));
|
|
|
+ total.teamBonus = Math.max(
|
|
|
+ 0.0, rdDouble(row.get("team_bonus")));
|
|
|
total.bonus = XjbJfServ.capBonus(
|
|
|
- rdDouble(row.get("other_bonus")),
|
|
|
- rdDouble(row.get("team_bonus")));
|
|
|
+ total.otherBonus, total.teamBonus);
|
|
|
total.deduction = rdDouble(row.get("deduction"));
|
|
|
total.bonusCount = rdInt(row.get("bonus_cnt"));
|
|
|
total.deductionCount = rdInt(row.get("deduction_cnt"));
|
|
|
@@ -859,15 +870,15 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
}
|
|
|
|
|
|
private String starLevel(double score, int schoolRank) {
|
|
|
- if (schoolRank <= 10 && score >= 90.0)
|
|
|
+ if (schoolRank <= 10 && score > 90.0)
|
|
|
return "五星级";
|
|
|
- if (score >= 80.0)
|
|
|
+ if (score > 80.0)
|
|
|
return "四星级";
|
|
|
- if (score >= 75.0)
|
|
|
+ if (score > 75.0)
|
|
|
return "三星级";
|
|
|
- if (score >= 65.0)
|
|
|
+ if (score > 65.0)
|
|
|
return "二星级";
|
|
|
- if (score >= 55.0)
|
|
|
+ if (score > 55.0)
|
|
|
return "一星级";
|
|
|
return "无星级";
|
|
|
}
|
|
|
@@ -897,6 +908,7 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
return;
|
|
|
for (Map<String, Object> row : rows) {
|
|
|
long jdid = rdLong(row.get("xjb_jdid"), 0L);
|
|
|
+ deleteByJdId(db, "XJB_JGMX", jdid);
|
|
|
deleteByJdId(db, "XJB_PM", jdid);
|
|
|
deleteByJdId(db, "XJB_JG", jdid);
|
|
|
SqlCmd delete = new SqlCmd(
|
|
|
@@ -925,6 +937,7 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
po.setNdy(month.format(MONTH_FMT));
|
|
|
po.setFwlx(fwlx);
|
|
|
po.setFwid(fwid);
|
|
|
+ po.setPzid(rdFormulaPzId(db, month));
|
|
|
po.setBb(version);
|
|
|
po.setZt(JD_PUBLISHED);
|
|
|
po.setMs(StringUtils.defaultIfBlank(reason, "星级班月结"));
|
|
|
@@ -935,16 +948,17 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
po.setPrev_jdid(previousId);
|
|
|
po.setGzyy(StringUtils.trimToNull(reason));
|
|
|
Set<String> fields = new LinkedHashSet<>(Arrays.asList(
|
|
|
- "xjb_jdid", "ndy", "fwlx", "fwid", "bb", "zt", "ms",
|
|
|
+ "xjb_jdid", "ndy", "fwlx", "fwid", "pzid", "bb", "zt", "ms",
|
|
|
"cjsj", "fbsj", "jsryid", "jsbmid", "prev_jdid", "gzyy"));
|
|
|
db.doInsPo(po, fields);
|
|
|
return id;
|
|
|
}
|
|
|
|
|
|
- private void insertResult(Db db, long jdid, ClassResult result,
|
|
|
+ private long insertResult(Db db, long jdid, ClassResult result,
|
|
|
UserRunB user) throws Exception {
|
|
|
XjbJgPo jg = new XjbJgPo();
|
|
|
- jg.setXjb_jgid(db.rdNextSeqVal("XJB_JGID"));
|
|
|
+ long jgid = db.rdNextSeqVal("XJB_JGID");
|
|
|
+ jg.setXjb_jgid(jgid);
|
|
|
jg.setXjb_jdid(jdid);
|
|
|
jg.setNdy(result.ndy);
|
|
|
jg.setBjid(result.cls.bjid);
|
|
|
@@ -994,6 +1008,168 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
"xjb_pmid", "xjb_jdid", "bjid", "dwid",
|
|
|
"dwpm", "dwcs", "xxpm", "xxcs"));
|
|
|
db.doInsPo(pm, pmFields);
|
|
|
+ return jgid;
|
|
|
+ }
|
|
|
+
|
|
|
+ private long rdFormulaPzId(Db db, YearMonth month) throws Exception {
|
|
|
+ Timestamp start = Timestamp.valueOf(month.atDay(1).atStartOfDay());
|
|
|
+ Timestamp end = Timestamp.valueOf(
|
|
|
+ month.plusMonths(1).atDay(1).atStartOfDay());
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select PZID from XJB_PZ where PZBB=:pzbb and JLZTM=51"
|
|
|
+ + " and KSRQ<:end and (JSRQ is null or JSRQ>=:start)"
|
|
|
+ + " order by KSRQ desc,PZID desc");
|
|
|
+ sqlc.wrStrParm("pzbb", FORMULA_VERSION);
|
|
|
+ sqlc.wrTimeParm("start", start);
|
|
|
+ sqlc.wrTimeParm("end", end);
|
|
|
+ db.doSelByC(sqlc);
|
|
|
+ if (db.rowNum == 0)
|
|
|
+ throw new IllegalStateException(
|
|
|
+ "缺少星级班评分配置版本:" + FORMULA_VERSION);
|
|
|
+ return db.rdLongCol("pzid");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void insertResultDetail(Db db, long jdid, long jgid,
|
|
|
+ ClassResult result, UserRunB user)
|
|
|
+ throws Exception {
|
|
|
+ int sx = 1;
|
|
|
+ insertWeightedDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "DORM", "宿舍评分", result.dorm.value, 0.20,
|
|
|
+ result.dorm.source, "常规项按20%计入总分");
|
|
|
+ if (result.dormDetail != null) {
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DORM_INTERNAL", "宿舍内务月均分",
|
|
|
+ result.dormDetail.internal, SOURCE_REAL,
|
|
|
+ "有效内务检查平均分");
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DORM_ATTENDANCE", "住宿考勤分",
|
|
|
+ result.dormDetail.attendance, SOURCE_REAL,
|
|
|
+ "住校生在校考勤日平均分");
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DORM_VIOLATION", "宿舍违纪得分",
|
|
|
+ result.dormDetail.violation, SOURCE_REAL,
|
|
|
+ "100减当月去重宿舍违纪扣分");
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DORM_MANAGE", "宿舍管理增分",
|
|
|
+ result.dormDetail.managementBonus,
|
|
|
+ result.dormDetail.managementSource,
|
|
|
+ "到宿有效参与5至7次加3分,8次及以上加5分");
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DORM_MANAGE_VISITS", "宿舍管理有效次数",
|
|
|
+ result.dormDetail.managementVisits,
|
|
|
+ result.dormDetail.managementSource,
|
|
|
+ "单次进入离开间隔不少于10分钟");
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DORM_DEDUCTION", "宿舍其他减分", 0.0, "停",
|
|
|
+ "学校暂未提供扣分规则");
|
|
|
+ }
|
|
|
+ sx = insertWeightedDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "CLASSROOM", "课堂考核", result.classroom.value, 0.05,
|
|
|
+ result.classroom.source, "常规项按5%计入总分");
|
|
|
+ sx = insertWeightedDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "FLAG", "升旗礼", result.flag.value, 0.14,
|
|
|
+ result.flag.source, "常规项按14%计入总分");
|
|
|
+ sx = insertWeightedDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "CLEANING", "清洁卫生", result.cleaning.value, 0.18,
|
|
|
+ result.cleaning.source, "常规项按18%计入总分");
|
|
|
+ sx = insertWeightedDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "DISCIPLINE", "风纪仪容", result.discipline.value, 0.20,
|
|
|
+ result.discipline.source, "常规项按20%计入总分");
|
|
|
+ if (result.disciplineDetail != null) {
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DISCIPLINE_PENALTY", "风纪扣分合计",
|
|
|
+ result.disciplineDetail.violations, SOURCE_REAL,
|
|
|
+ "当月风纪仪容扣分合计");
|
|
|
+ sx = insertRawDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "DISCIPLINE_DAYS", "风纪违纪天数",
|
|
|
+ result.disciplineDetail.days, SOURCE_REAL,
|
|
|
+ "当月发生风纪违纪的日期数");
|
|
|
+ }
|
|
|
+ sx = insertWeightedDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "ATTENDANCE", "考勤", result.attendance.value, 0.15,
|
|
|
+ result.attendance.source, "常规项按15%计入总分");
|
|
|
+
|
|
|
+ double teamBonus = Math.max(0.0, result.adjust.teamBonus);
|
|
|
+ double otherBonus = Math.max(0.0, result.adjust.otherBonus);
|
|
|
+ sx = insertRawScoreDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "TEAM_BONUS", "学生团体原始增分",
|
|
|
+ teamBonus, Math.min(XjbJfServ.TEAM_BONUS_CAP, teamBonus),
|
|
|
+ "TT", "团体原始事件合计,汇总前先封顶");
|
|
|
+ sx = insertRawScoreDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "OTHER_BONUS", "其他增分",
|
|
|
+ otherBonus, otherBonus, "CALC", "非学生团体增分");
|
|
|
+ sx = insertRawScoreDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "BONUS_TOTAL", "增分合计",
|
|
|
+ teamBonus + otherBonus, result.adjust.bonus,
|
|
|
+ "CALC", "团体先封顶3分,总增分再封顶8分");
|
|
|
+ sx = insertRawScoreDetail(db, jdid, jgid, result, user, sx++,
|
|
|
+ "DEDUCTION", "减分合计",
|
|
|
+ result.adjust.deduction, -result.adjust.deduction,
|
|
|
+ "CALC", "来源减分合计");
|
|
|
+ sx = insertRawScoreDetail(db, jdid, jgid, result, user, sx,
|
|
|
+ "TOTAL", "月总分", result.total, result.total,
|
|
|
+ "CALC", "六项加权增分封顶后减分;不设0分下限");
|
|
|
+ }
|
|
|
+
|
|
|
+ private int insertWeightedDetail(Db db, long jdid, long jgid,
|
|
|
+ ClassResult result, UserRunB user,
|
|
|
+ int sx, String code, String name,
|
|
|
+ double raw, double weight,
|
|
|
+ String source, String note)
|
|
|
+ throws Exception {
|
|
|
+ insertJgmx(db, jdid, jgid, result, user, sx, code, name,
|
|
|
+ raw, weight, round2(raw * weight), source, note);
|
|
|
+ return sx + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int insertRawDetail(Db db, long jdid, long jgid,
|
|
|
+ ClassResult result, UserRunB user,
|
|
|
+ int sx, String code, String name,
|
|
|
+ double raw, String source, String note)
|
|
|
+ throws Exception {
|
|
|
+ insertJgmx(db, jdid, jgid, result, user, sx, code, name,
|
|
|
+ raw, null, null, source, note);
|
|
|
+ return sx + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int insertRawScoreDetail(Db db, long jdid, long jgid,
|
|
|
+ ClassResult result, UserRunB user,
|
|
|
+ int sx, String code, String name,
|
|
|
+ double raw, double score,
|
|
|
+ String source, String note)
|
|
|
+ throws Exception {
|
|
|
+ insertJgmx(db, jdid, jgid, result, user, sx, code, name,
|
|
|
+ raw, null, round2(score), source, note);
|
|
|
+ return sx + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void insertJgmx(Db db, long jdid, long jgid,
|
|
|
+ ClassResult result, UserRunB user, int sx,
|
|
|
+ String code, String name, double raw,
|
|
|
+ Double weight, Double score, String source,
|
|
|
+ String note) throws Exception {
|
|
|
+ XjbJgmxPo mx = new XjbJgmxPo();
|
|
|
+ mx.setJgmxid(db.rdNextSeqVal("XJB_JGMXID"));
|
|
|
+ mx.setXjb_jdid(jdid);
|
|
|
+ mx.setXjb_jgid(jgid);
|
|
|
+ mx.setBjid(result.cls.bjid);
|
|
|
+ mx.setNdy(result.ndy);
|
|
|
+ mx.setXmbm(code);
|
|
|
+ mx.setXmmc(name);
|
|
|
+ mx.setYsz(round2(raw));
|
|
|
+ mx.setQz(weight);
|
|
|
+ mx.setDf(score);
|
|
|
+ mx.setLylx(source);
|
|
|
+ mx.setSm(note);
|
|
|
+ mx.setSx(sx);
|
|
|
+ mx.setCjryid(user == null ? null : user.ryid);
|
|
|
+ mx.setCjbm_id(user == null ? null : user.bmid);
|
|
|
+ mx.setJlsj(new java.sql.Date(System.currentTimeMillis()));
|
|
|
+ Set<String> fields = new LinkedHashSet<>(Arrays.asList(
|
|
|
+ "jgmxid", "xjb_jdid", "xjb_jgid", "bjid", "ndy",
|
|
|
+ "xmbm", "xmmc", "ysz", "qz", "df", "lylx", "sm",
|
|
|
+ "sx", "cjryid", "cjbm_id", "jlsj"));
|
|
|
+ db.doInsPo(mx, fields);
|
|
|
}
|
|
|
|
|
|
private YearMonth rdLatestPublishedMonth(Db db) throws Exception {
|
|
|
@@ -1134,6 +1310,8 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
|
|
|
private static final class AdjustmentTotals {
|
|
|
double bonus;
|
|
|
+ double teamBonus;
|
|
|
+ double otherBonus;
|
|
|
double deduction;
|
|
|
int bonusCount;
|
|
|
int deductionCount;
|
|
|
@@ -1142,10 +1320,12 @@ public class XjbMonthCloseServ extends Serv {
|
|
|
private static final class ClassResult {
|
|
|
final ClassRow cls;
|
|
|
Component dorm;
|
|
|
+ DormScore dormDetail;
|
|
|
Component classroom;
|
|
|
Component flag;
|
|
|
Component cleaning;
|
|
|
Component discipline;
|
|
|
+ DisciplineScore disciplineDetail;
|
|
|
Component attendance;
|
|
|
AdjustmentTotals adjust = new AdjustmentTotals();
|
|
|
final List<String> missing = new ArrayList<>();
|