|
|
@@ -103,8 +103,7 @@ public class SqljcServ extends Serv {
|
|
|
|
|
|
List<Map<String, Object>> departments = rdDeptList(gdba);
|
|
|
Long bmid = rdLongObj(request.getParameter("bmid"));
|
|
|
- int total = 0;
|
|
|
- int leave = 0;
|
|
|
+ Map<Integer, Integer> countDefaults = new HashMap<>();
|
|
|
String bmmc = null;
|
|
|
int classCount = 0;
|
|
|
if (bmid != null) {
|
|
|
@@ -116,13 +115,12 @@ public class SqljcServ extends Serv {
|
|
|
if (classes.isEmpty())
|
|
|
throw new IllegalArgumentException("所选部门没有有效班级");
|
|
|
classCount = classes.size();
|
|
|
- total = rdDeptStudentCount(gdba, bmid);
|
|
|
- leave = rdLeaveCount(gdba, bmid, inspectionAt);
|
|
|
+ countDefaults = rdCountDefaults(gdba, bmid, inspectionAt);
|
|
|
bmmc = rdBmMc(gdba, bmid);
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> jcxmList = rdJcxmList(gdba);
|
|
|
- decorateJcxmList(jcxmList, total, 0, leave);
|
|
|
+ decorateJcxmList(jcxmList, countDefaults);
|
|
|
|
|
|
Map<String, Object> data = new LinkedHashMap<>();
|
|
|
data.put("jcxmList", jcxmList);
|
|
|
@@ -242,6 +240,7 @@ public class SqljcServ extends Serv {
|
|
|
int total = 0;
|
|
|
int leave = 0;
|
|
|
String bmmc = null;
|
|
|
+ Map<Integer, Integer> countDefaults = new HashMap<>();
|
|
|
if (selectedBmid != null) {
|
|
|
requireSelectableDept(departments, bmid);
|
|
|
classes = rdDeptClassList(gdba, bmid);
|
|
|
@@ -249,11 +248,11 @@ public class SqljcServ extends Serv {
|
|
|
throw new IllegalArgumentException("所选部门没有有效班级");
|
|
|
|
|
|
Timestamp inspectionAt = Timestamp.valueOf(day.atTime(8, 0));
|
|
|
- total = rdDeptStudentCount(gdba, bmid);
|
|
|
- leave = rdLeaveCount(gdba, bmid, inspectionAt);
|
|
|
+ countDefaults = rdCountDefaults(gdba, bmid, inspectionAt);
|
|
|
+ total = countDefaults.getOrDefault(SqljcC.JCXM_ZRS, 0);
|
|
|
+ leave = countDefaults.getOrDefault(SqljcC.JCXM_QJRS, 0);
|
|
|
jcxmList = rdJcxmList(gdba);
|
|
|
- decorateJcxmList(jcxmList, total,
|
|
|
- Math.max(0, total - leave), leave);
|
|
|
+ decorateJcxmList(jcxmList, countDefaults);
|
|
|
bmmc = rdBmMc(gdba, bmid);
|
|
|
}
|
|
|
|
|
|
@@ -444,6 +443,77 @@ public class SqljcServ extends Serv {
|
|
|
return gdba.rowNum > 0 ? gdba.rdIntCol("cnt") : 0;
|
|
|
}
|
|
|
|
|
|
+ private Map<Integer, Integer> rdCountDefaults(Db gdba, long bmid,
|
|
|
+ Timestamp inspectionAt)
|
|
|
+ throws Exception {
|
|
|
+ int total = rdDeptStudentCount(gdba, bmid);
|
|
|
+ int bmzr = rdDutyCount(gdba, bmid, inspectionAt,
|
|
|
+ rdTtidByMc(gdba, SqljcC.DUTY_TT_BMZR));
|
|
|
+ int xxzr = rdDutyCount(gdba, bmid, inspectionAt,
|
|
|
+ rdTtidByMc(gdba, SqljcC.DUTY_TT_XXZR));
|
|
|
+ int gqd = rdDutyCount(gdba, bmid, inspectionAt,
|
|
|
+ rdTtidByMc(gdba, SqljcC.DUTY_TT_GQD));
|
|
|
+ int sg = rdDutyCount(gdba, bmid, inspectionAt,
|
|
|
+ rdTtidByMc(gdba, SqljcC.DUTY_TT_SG));
|
|
|
+ int gj = 0; // 公假暂不统计。Lin
|
|
|
+ int qj = rdLeaveCount(gdba, bmid, inspectionAt);
|
|
|
+ int queue = Math.max(0, total - bmzr - xxzr - gqd - gj - sg - qj);
|
|
|
+
|
|
|
+ Map<Integer, Integer> defaults = new HashMap<>();
|
|
|
+ defaults.put(SqljcC.JCXM_ZRS, total);
|
|
|
+ defaults.put(SqljcC.JCXM_DLRS, queue);
|
|
|
+ defaults.put(SqljcC.JCXM_BMZRRS, bmzr);
|
|
|
+ defaults.put(SqljcC.JCXM_XXZRRS, xxzr);
|
|
|
+ defaults.put(SqljcC.JCXM_GQDZRRS, gqd);
|
|
|
+ defaults.put(SqljcC.JCXM_GJRS, gj);
|
|
|
+ defaults.put(SqljcC.JCXM_SGZRRS, sg);
|
|
|
+ defaults.put(SqljcC.JCXM_QJRS, qj);
|
|
|
+ return defaults;
|
|
|
+ }
|
|
|
+
|
|
|
+ private long rdTtidByMc(Db gdba, String mc) throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select TTID from TT where MC=:mc and "
|
|
|
+ + ObjC.JLZT_useStr + " order by TTID");
|
|
|
+ sqlc.wrStrParm("mc", mc);
|
|
|
+ gdba.doSelByC(sqlc);
|
|
|
+ return gdba.rowNum > 0 ? gdba.rdLongCol("ttid") : 0L;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int rdDutyCount(Db gdba, long bmid, Timestamp inspectionAt,
|
|
|
+ long ttid) throws Exception {
|
|
|
+ if (ttid <= 0)
|
|
|
+ return 0;
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select count(distinct cy.RYID) CNT from RCCY cy"
|
|
|
+ + " inner join RC rc on rc.RCID=cy.RCID"
|
|
|
+ + " where rc.RCLBM=" + SqljcC.RCLB_ZB
|
|
|
+ + " and rc.DXID=:ttid"
|
|
|
+ + " and rc.KSSJ<=:inspectionStart"
|
|
|
+ + " and rc.JSSJ>=:inspectionEnd"
|
|
|
+ + " and rc." + ObjC.JLZT_useStr
|
|
|
+ + " and cy.JLZTM=" + ObjC.JLZT_inUse
|
|
|
+ + " and exists(select 1 from BJCY bc"
|
|
|
+ + " inner join BJ b on b.BJID=bc.BJID"
|
|
|
+ + " inner join ZY z on z.ZYID=b.ZYID"
|
|
|
+ + " inner join RY ry on ry.RYID=bc.RYID"
|
|
|
+ + " where bc.RYID=cy.RYID and bc."
|
|
|
+ + ObjC.JLZT_useStr
|
|
|
+ + " and nvl(bc.SFBY,0)=0 and z.FZBMID=:bmid"
|
|
|
+ + " and b.BJZTM<>:endState"
|
|
|
+ + " and b." + ObjC.JLZT_useStr
|
|
|
+ + " and ry.RYZTM=" + RyC.RYZT_zd
|
|
|
+ + " and ry.RYLBM=" + RyC.RYLB_xy
|
|
|
+ + " and ry." + ObjC.JLZT_useStr + ")");
|
|
|
+ sqlc.wrLongParm("ttid", ttid);
|
|
|
+ sqlc.wrTimeParm("inspectionStart", inspectionAt);
|
|
|
+ sqlc.wrTimeParm("inspectionEnd", inspectionAt);
|
|
|
+ sqlc.wrLongParm("bmid", bmid);
|
|
|
+ sqlc.wrIntParm("endState", BjC.BJZT_end);
|
|
|
+ gdba.doSelByC(sqlc);
|
|
|
+ return gdba.rowNum > 0 ? gdba.rdIntCol("cnt") : 0;
|
|
|
+ }
|
|
|
+
|
|
|
private int rdLeaveCount(Db gdba, long bmid, Timestamp inspectionAt)
|
|
|
throws Exception {
|
|
|
SqlCmd sqlc = new SqlCmd(
|
|
|
@@ -489,7 +559,7 @@ public class SqljcServ extends Serv {
|
|
|
}
|
|
|
|
|
|
private void decorateJcxmList(List<Map<String, Object>> jcxmList,
|
|
|
- int total, int queue, int leave) {
|
|
|
+ Map<Integer, Integer> countDefaults) {
|
|
|
Set<Integer> codes = new LinkedHashSet<>();
|
|
|
for (Map<String, Object> item : jcxmList)
|
|
|
codes.add(rdIntValue(item.get("sqljcxmm"), 0));
|
|
|
@@ -505,14 +575,7 @@ public class SqljcServ extends Serv {
|
|
|
item.put("minValue", 0);
|
|
|
if (countItem) {
|
|
|
item.put("mfz", null);
|
|
|
- int defaultValue = 0;
|
|
|
- if (code == SqljcC.JCXM_ZRS)
|
|
|
- defaultValue = total;
|
|
|
- else if (code == SqljcC.JCXM_DLRS)
|
|
|
- defaultValue = queue;
|
|
|
- else if (code == SqljcC.JCXM_QJRS)
|
|
|
- defaultValue = leave;
|
|
|
- item.put("defaultValue", defaultValue);
|
|
|
+ item.put("defaultValue", countDefaults.getOrDefault(code, 0));
|
|
|
} else {
|
|
|
item.put("defaultValue", ckz != null ? ckz
|
|
|
: (mfz == null ? 0 : mfz));
|