|
|
@@ -2,6 +2,8 @@ package biz.bjpj;
|
|
|
|
|
|
import base.po.SqljcPo;
|
|
|
import base.po.SqljcmxPo;
|
|
|
+import biz.bj.BjC;
|
|
|
+import biz.rc.RcC;
|
|
|
import com.google.gson.Gson;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -20,8 +22,13 @@ import ss.user.UserU;
|
|
|
|
|
|
import java.io.Writer;
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.LinkedHashSet;
|
|
|
import java.util.List;
|
|
|
@@ -50,6 +57,17 @@ public class SqljcServ extends Serv {
|
|
|
|
|
|
private static final String SQL_bmMc = "select MC from BM where BMID=:bmid";
|
|
|
|
|
|
+ private static final String SQL_deptClasses =
|
|
|
+ "select b.BJID,b.MC,b.ZYID from BJ b"
|
|
|
+ + " inner join ZY z on z.ZYID=b.ZYID"
|
|
|
+ + " where z.FZBMID=:bmid and b.BJZTM<>:endState"
|
|
|
+ + " and b." + ObjC.JLZT_useStr
|
|
|
+ + " order by b.MC,b.BJID";
|
|
|
+
|
|
|
+ private static final DateTimeFormatter DATE_FMT =
|
|
|
+ DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ private static final ZoneId CN_ZONE = ZoneId.of("Asia/Shanghai");
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 初始化 PC 录入页:返回 13 个检查项目、部门名称、检查人姓名。
|
|
|
@@ -65,6 +83,7 @@ public class SqljcServ extends Serv {
|
|
|
|
|
|
try (Db gdba = Db.makeConn()) {
|
|
|
List<Map<String, Object>> jcxmList = rdJcxmList(gdba);
|
|
|
+ decorateJcxmList(jcxmList, 0, 0, 0);
|
|
|
|
|
|
String bmmc = null;
|
|
|
String jcryxm = null;
|
|
|
@@ -113,27 +132,8 @@ public class SqljcServ extends Serv {
|
|
|
if (bmid == null)
|
|
|
bmid = user.bmid;
|
|
|
|
|
|
- // 汇总评分项:有满分的按打分项(默认满分),无满分的按人数(默认 0)。Lin
|
|
|
- List<Map<String, Object>> jcxmList = rdJcxmList(gdba);
|
|
|
- Map<Integer, Integer> fsMap = new LinkedHashMap<>();
|
|
|
- long zfs = 0L;
|
|
|
- for (Map<String, Object> jcxm : jcxmList) {
|
|
|
- int sqljcxmm = rdIntValue(jcxm.get("sqljcxmm"), 0);
|
|
|
- Integer mfz = rdIntObj(jcxm.get("mfz"));
|
|
|
- int fs;
|
|
|
- if (mfz == null) { // 人数项。Lin
|
|
|
- fs = rdIntValue(request.getParameter("sqljcxmm"+ sqljcxmm), 0);
|
|
|
- if (fs < 0)
|
|
|
- throw new IllegalArgumentException("人数不能为负数");
|
|
|
- } else {
|
|
|
- String valStr = StringUtils.trimToNull(request.getParameter("sqljcxmm"+ sqljcxmm));
|
|
|
- fs = valStr == null ? mfz : Integer.parseInt(valStr);
|
|
|
- if (fs < 0 || fs > mfz)
|
|
|
- throw new IllegalArgumentException("评分项超出满分范围");
|
|
|
- zfs += fs;
|
|
|
- }
|
|
|
- fsMap.put(sqljcxmm, fs);
|
|
|
- }
|
|
|
+ Map<Integer, Integer> fsMap = rdJcxmValues(gdba, request);
|
|
|
+ SqljcC.Totals totals = SqljcC.calculate(fsMap);
|
|
|
|
|
|
Timestamp jcsj = new Timestamp(System.currentTimeMillis());
|
|
|
Set<String> sqljcFields = new LinkedHashSet<>(Arrays.asList(
|
|
|
@@ -146,12 +146,12 @@ public class SqljcServ extends Serv {
|
|
|
sqljc.setBjid(bjid);
|
|
|
sqljc.setJcryid(user.ryid);
|
|
|
sqljc.setJcsj(jcsj);
|
|
|
- sqljc.setZfs(zfs);
|
|
|
- sqljc.setKqfs(rdFloatValue(request.getParameter("kqfs"), 0F));
|
|
|
- sqljc.setDlfs(rdIntValue(request.getParameter("dlfs"), 0));
|
|
|
- sqljc.setFmfs(rdIntValue(request.getParameter("fmfs"), 0));
|
|
|
- sqljc.setJlfs(rdIntValue(request.getParameter("jlfs"), 0));
|
|
|
- sqljc.setCql(rdFloatValue(request.getParameter("cql"), 0F));
|
|
|
+ sqljc.setZfs(totals.totalScore);
|
|
|
+ sqljc.setKqfs(totals.attendanceRate);
|
|
|
+ sqljc.setDlfs(totals.queueScore);
|
|
|
+ sqljc.setFmfs(totals.demeanorScore);
|
|
|
+ sqljc.setJlfs(totals.disciplineScore);
|
|
|
+ sqljc.setCql(totals.attendanceRate);
|
|
|
sqljc.setMs(StringUtils.trimToEmpty(request.getParameter("ms")));
|
|
|
sqljc.setFjid(rdLongObj(request.getParameter("fjid")));
|
|
|
// 本版不启动审批,直接写生效状态。Lin
|
|
|
@@ -174,6 +174,7 @@ public class SqljcServ extends Serv {
|
|
|
}
|
|
|
|
|
|
gdba.commit();
|
|
|
+ request.setAttribute(ServC.REQ_msg, "保存成功,总分" + totals.totalScore);
|
|
|
} catch (Exception e) {
|
|
|
request.setAttribute(ServC.REQ_msg, "提交失败:"+ e.getMessage());
|
|
|
log4j.error("SqljcServ.submAdd() 异常,sqljcid="+ sqljcid, e);
|
|
|
@@ -184,8 +185,387 @@ public class SqljcServ extends Serv {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 部门批量评分初始化。
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unused")
|
|
|
+ public void deptInitByA() throws Exception {
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
+ super.resp.setCharacterEncoding("UTF-8");
|
|
|
+ super.resp.setContentType("application/json;charset=UTF-8");
|
|
|
+ Writer writer = super.resp.getWriter();
|
|
|
+ Gson gson = new Gson();
|
|
|
+
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
+ UserRunB user = UserU.rdUserByReq(request);
|
|
|
+ if (user == null)
|
|
|
+ throw new IllegalArgumentException("登录状态已失效,请重新登录");
|
|
|
+ long bmid = requireBmid(user);
|
|
|
+ LocalDate day = rdInspectionDate(request);
|
|
|
+ Timestamp inspectionAt = Timestamp.valueOf(day.atTime(8, 0));
|
|
|
+
|
|
|
+ List<Map<String, Object>> classes = rdDeptClassList(gdba, bmid);
|
|
|
+ if (classes.isEmpty())
|
|
|
+ throw new IllegalArgumentException("当前部门没有有效班级");
|
|
|
+
|
|
|
+ int total = rdDeptStudentCount(gdba, bmid);
|
|
|
+ int leave = rdLeaveCount(gdba, bmid, inspectionAt);
|
|
|
+ List<Map<String, Object>> jcxmList = rdJcxmList(gdba);
|
|
|
+ decorateJcxmList(jcxmList, total, Math.max(0, total - leave), leave);
|
|
|
+
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
+ data.put("bmid", bmid);
|
|
|
+ data.put("bmmc", rdBmMc(gdba, bmid));
|
|
|
+ data.put("jcryxm", user.xm);
|
|
|
+ data.put("jcsjDate", day.format(DATE_FMT));
|
|
|
+ data.put("classes", classes);
|
|
|
+ data.put("classCount", classes.size());
|
|
|
+ data.put("totalStudents", total);
|
|
|
+ data.put("leaveStudents", leave);
|
|
|
+ data.put("publicLeaveStudents", 0);
|
|
|
+ data.put("jcxmList", jcxmList);
|
|
|
+ data.put("formulaNote",
|
|
|
+ "出勤率×25% + 队列分×20% + 风貌分×40% + 纪律分×15%");
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("SqljcServ.deptInitByA() 异常", e);
|
|
|
+ ServU.wrErrMsgByWriter(null, "部门批量评分加载失败", writer, gson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按部门一次性保存所有有效班级。
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unused")
|
|
|
+ public void deptSaveByA() throws Exception {
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
+ super.resp.setCharacterEncoding("UTF-8");
|
|
|
+ super.resp.setContentType("application/json;charset=UTF-8");
|
|
|
+ Writer writer = super.resp.getWriter();
|
|
|
+ Gson gson = new Gson();
|
|
|
+
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
+ UserRunB user = UserU.rdUserByReq(request);
|
|
|
+ if (user == null)
|
|
|
+ throw new IllegalArgumentException("登录状态已失效,请重新登录");
|
|
|
+ long bmid = requireBmid(user);
|
|
|
+ LocalDate day = rdInspectionDate(request);
|
|
|
+ List<Map<String, Object>> classes = rdDeptClassList(gdba, bmid);
|
|
|
+ if (classes.isEmpty())
|
|
|
+ throw new IllegalArgumentException("当前部门没有有效班级");
|
|
|
+
|
|
|
+ Map<Integer, Integer> itemValues = rdJcxmValues(gdba, request);
|
|
|
+ SqljcC.Totals totals = SqljcC.calculate(itemValues);
|
|
|
+ String ms = StringUtils.trimToEmpty(request.getParameter("ms"));
|
|
|
+ Long fjid = rdLongObj(request.getParameter("fjid"));
|
|
|
+ Timestamp jcsj = Timestamp.valueOf(
|
|
|
+ day.atTime(LocalTime.now(CN_ZONE).withNano(0)));
|
|
|
+
|
|
|
+ Map<Long, Map<String, Object>> existing = new HashMap<>();
|
|
|
+ for (Map<String, Object> cls : classes) {
|
|
|
+ long bjid = rdLongValue(cls.get("bjid"));
|
|
|
+ Map<String, Object> record =
|
|
|
+ rdDeptSqljc(gdba, bmid, bjid, day);
|
|
|
+ if (record != null) {
|
|
|
+ if (rdIntValue(record.get("jlztm"), 0)
|
|
|
+ == ObjC.JLZT_onFile)
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ "该部门该日期已有归档记录,不能直接覆盖");
|
|
|
+ if (existing.containsKey(bjid))
|
|
|
+ throw new IllegalStateException("班级评分记录重复");
|
|
|
+ existing.put(bjid, record);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map<String, Object> cls : classes) {
|
|
|
+ long bjid = rdLongValue(cls.get("bjid"));
|
|
|
+ saveDeptSqljc(gdba, bmid, bjid, jcsj, totals,
|
|
|
+ itemValues, ms, fjid, user, existing.get(bjid));
|
|
|
+ }
|
|
|
+ gdba.commit();
|
|
|
+
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
+ data.put("bmid", bmid);
|
|
|
+ data.put("bmmc", rdBmMc(gdba, bmid));
|
|
|
+ data.put("jcsjDate", day.format(DATE_FMT));
|
|
|
+ data.put("classCount", classes.size());
|
|
|
+ data.put("zfs", totals.totalScore);
|
|
|
+ data.put("cql", totals.attendanceRate);
|
|
|
+ data.put("kqfs", totals.attendanceRate);
|
|
|
+ data.put("dlfs", totals.queueScore);
|
|
|
+ data.put("fmfs", totals.demeanorScore);
|
|
|
+ data.put("jlfs", totals.disciplineScore);
|
|
|
+ data.put("effectiveCount", totals.expected);
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("SqljcServ.deptSaveByA() 异常", e);
|
|
|
+ ServU.wrErrMsgByWriter(null,
|
|
|
+ StringUtils.defaultIfBlank(e.getMessage(),
|
|
|
+ "部门批量评分保存失败"), writer, gson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// ===
|
|
|
|
|
|
+ private long requireBmid(UserRunB user) {
|
|
|
+ if (user.bmid == null)
|
|
|
+ throw new IllegalArgumentException("当前账号未关联部门");
|
|
|
+ return user.bmid;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String rdBmMc(Db gdba, long bmid) throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(SQL_bmMc);
|
|
|
+ sqlc.wrLongParm("bmid", bmid);
|
|
|
+ gdba.doSelByC(sqlc);
|
|
|
+ return gdba.rowNum > 0 ? StringUtils.defaultString(gdba.rdStrCol("mc"))
|
|
|
+ : String.valueOf(bmid);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> rdDeptClassList(Db gdba, long bmid)
|
|
|
+ throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(SQL_deptClasses);
|
|
|
+ sqlc.wrLongParm("bmid", bmid);
|
|
|
+ sqlc.wrIntParm("endState", BjC.BJZT_end);
|
|
|
+ List<Map<String, Object>> rows = gdba.doSelMapListByC(sqlc);
|
|
|
+ if (rows == null)
|
|
|
+ return new ArrayList<>();
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ for (Map<String, Object> row : rows) {
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
+ item.put("bjid", rdLongValue(row.get("bjid")));
|
|
|
+ item.put("bjmc", row.get("mc") == null
|
|
|
+ ? "" : String.valueOf(row.get("mc")));
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int rdDeptStudentCount(Db gdba, long bmid) throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select count(distinct bc.RYID) CNT"
|
|
|
+ + " from BJCY bc inner join BJ b on b.BJID=bc.BJID"
|
|
|
+ + " inner join ZY z on z.ZYID=b.ZYID"
|
|
|
+ + " where z.FZBMID=:bmid and bc." + ObjC.JLZT_useStr
|
|
|
+ + " and nvl(bc.SFBY,0)=0 and b.BJZTM<>:endState"
|
|
|
+ + " and b." + ObjC.JLZT_useStr);
|
|
|
+ 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(
|
|
|
+ "select count(distinct rc.FZRYID) CNT from RC rc"
|
|
|
+ + " where rc.SFXYLX=" + 1
|
|
|
+ + " and rc.RCLBM in(" + RcC.RCLB_sj + ","
|
|
|
+ + RcC.RCLB_bj + ") and rc." + ObjC.JLZT_useStr
|
|
|
+ + " and rc.KSSJ<=:inspectionStart"
|
|
|
+ + " and rc.JSSJ>=:inspectionEnd"
|
|
|
+ + " 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"
|
|
|
+ + " where bc.RYID=rc.FZRYID and bc."
|
|
|
+ + ObjC.JLZT_useStr
|
|
|
+ + " and nvl(bc.SFBY,0)=0 and z.FZBMID=:bmid"
|
|
|
+ + " and b.BJZTM<>:endState"
|
|
|
+ + " and b." + ObjC.JLZT_useStr + ")");
|
|
|
+ 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 LocalDate rdInspectionDate(HttpServletRequest request) {
|
|
|
+ String value = StringUtils.trimToNull(request.getParameter("jcsjDate"));
|
|
|
+ if (value == null)
|
|
|
+ return LocalDate.now(CN_ZONE);
|
|
|
+ LocalDate date;
|
|
|
+ try {
|
|
|
+ date = LocalDate.parse(value, DATE_FMT);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new IllegalArgumentException("检查日期格式错误");
|
|
|
+ }
|
|
|
+ if (date.isAfter(LocalDate.now(CN_ZONE)))
|
|
|
+ throw new IllegalArgumentException("检查日期不能晚于今天");
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void decorateJcxmList(List<Map<String, Object>> jcxmList,
|
|
|
+ int total, int queue, int leave) {
|
|
|
+ Set<Integer> codes = new LinkedHashSet<>();
|
|
|
+ for (Map<String, Object> item : jcxmList)
|
|
|
+ codes.add(rdIntValue(item.get("sqljcxmm"), 0));
|
|
|
+ if (!codes.containsAll(SqljcC.REQUIRED_CODES))
|
|
|
+ throw new IllegalStateException("升旗礼检查项目配置不完整");
|
|
|
+
|
|
|
+ for (Map<String, Object> item : jcxmList) {
|
|
|
+ int code = rdIntValue(item.get("sqljcxmm"), 0);
|
|
|
+ boolean countItem = SqljcC.isCountItem(code);
|
|
|
+ Integer mfz = rdIntObj(item.get("mfz"));
|
|
|
+ Integer ckz = rdIntObj(item.get("ckz"));
|
|
|
+ item.put("valueType", countItem ? "count" : "score");
|
|
|
+ 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);
|
|
|
+ } else {
|
|
|
+ item.put("defaultValue", ckz != null ? ckz
|
|
|
+ : (mfz == null ? 0 : mfz));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<Integer, Integer> rdJcxmValues(Db gdba,
|
|
|
+ HttpServletRequest request)
|
|
|
+ throws Exception {
|
|
|
+ List<Map<String, Object>> jcxmList = rdJcxmList(gdba);
|
|
|
+ Map<Integer, Map<String, Object>> configMap = new LinkedHashMap<>();
|
|
|
+ for (Map<String, Object> item : jcxmList) {
|
|
|
+ int code = rdIntValue(item.get("sqljcxmm"), 0);
|
|
|
+ configMap.put(code, item);
|
|
|
+ }
|
|
|
+ if (!configMap.keySet().containsAll(SqljcC.REQUIRED_CODES))
|
|
|
+ throw new IllegalStateException("升旗礼检查项目配置不完整");
|
|
|
+
|
|
|
+ Map<Integer, Integer> values = new LinkedHashMap<>();
|
|
|
+ for (int code : SqljcC.REQUIRED_CODES) {
|
|
|
+ Map<String, Object> config = configMap.get(code);
|
|
|
+ String raw = StringUtils.trimToNull(
|
|
|
+ request.getParameter("sqljcxmm" + code));
|
|
|
+ if (SqljcC.isCountItem(code)) {
|
|
|
+ int value = raw == null ? 0 : Integer.parseInt(raw);
|
|
|
+ if (value < 0)
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ config.get("mc") + "不能为负数");
|
|
|
+ values.put(code, value);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer maxObj = rdIntObj(config.get("mfz"));
|
|
|
+ int max = maxObj == null ? 0 : maxObj;
|
|
|
+ Integer ckz = rdIntObj(config.get("ckz"));
|
|
|
+ int value = raw == null ? (ckz == null ? max : ckz)
|
|
|
+ : Integer.parseInt(raw);
|
|
|
+ if (value < 0 || value > max)
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ config.get("mc") + "必须在0到" + max + "之间");
|
|
|
+ values.put(code, value);
|
|
|
+ }
|
|
|
+ return values;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> rdDeptSqljc(Db gdba, long bmid,
|
|
|
+ long bjid, LocalDate day)
|
|
|
+ throws Exception {
|
|
|
+ SqlCmd sqlc = new SqlCmd(
|
|
|
+ "select SQLJCID,JLZTM from SQLJC where BMID=:bmid"
|
|
|
+ + " and BJID=:bjid and trunc(JCSJ)=to_date(:day,'YYYY-MM-DD')"
|
|
|
+ + " and JLZTM in(22,25,51,81)"
|
|
|
+ + " order by case when JLZTM=81 then 0 else 1 end,"
|
|
|
+ + " SQLJCID desc");
|
|
|
+ sqlc.wrLongParm("bmid", bmid);
|
|
|
+ sqlc.wrLongParm("bjid", bjid);
|
|
|
+ sqlc.wrStrParm("day", day.format(DATE_FMT));
|
|
|
+ List<Map<String, Object>> rows = gdba.doSelMapListByC(sqlc);
|
|
|
+ return rows == null || rows.isEmpty() ? null : rows.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveDeptSqljc(Db gdba, long bmid, long bjid,
|
|
|
+ Timestamp jcsj, SqljcC.Totals totals,
|
|
|
+ Map<Integer, Integer> itemValues,
|
|
|
+ String ms, Long fjid, UserRunB user,
|
|
|
+ Map<String, Object> existing) throws Exception {
|
|
|
+ long sqljcid;
|
|
|
+ if (existing == null) {
|
|
|
+ Set<String> fields = new LinkedHashSet<>(Arrays.asList(
|
|
|
+ "sqljcid", "bmid", "bjid", "jcryid", "jcsj", "zfs",
|
|
|
+ "kqfs", "dlfs", "fmfs", "jlfs", "cql", "ms", "fjid",
|
|
|
+ "jlztm"));
|
|
|
+ SqljcPo po = new SqljcPo();
|
|
|
+ po.setSqljcid(gdba.rdNextSeqVal("SQLJCID"));
|
|
|
+ po.setBmid(bmid);
|
|
|
+ po.setBjid(bjid);
|
|
|
+ po.setJcryid(user.ryid);
|
|
|
+ po.setJcsj(jcsj);
|
|
|
+ po.setZfs(totals.totalScore);
|
|
|
+ po.setKqfs(totals.attendanceRate);
|
|
|
+ po.setDlfs(totals.queueScore);
|
|
|
+ po.setFmfs(totals.demeanorScore);
|
|
|
+ po.setJlfs(totals.disciplineScore);
|
|
|
+ po.setCql(totals.attendanceRate);
|
|
|
+ po.setMs(ms);
|
|
|
+ po.setFjid(fjid);
|
|
|
+ po.setJlztm(ObjC.JLZT_inUse);
|
|
|
+ DbU.wrSsFieldByPo(po, fields, user, false);
|
|
|
+ sqljcid = gdba.doInsPo(po, fields);
|
|
|
+ } else {
|
|
|
+ sqljcid = rdLongValue(existing.get("sqljcid"));
|
|
|
+ SqlCmd update = new SqlCmd(
|
|
|
+ "update SQLJC set BMID=:bmid,ZFS=:zfs,CQL=:cql,"
|
|
|
+ + "KQFS=:kqfs,DLFS=:dlfs,FMFS=:fmfs,JLFS=:jlfs,"
|
|
|
+ + "MS=:ms,FJID=:fjid,JCSJ=:jcsj,"
|
|
|
+ + "JCRYID=:jcryid,GLRYID=:glryid,GLBMID=:glbmid"
|
|
|
+ + " where SQLJCID=:sqljcid"
|
|
|
+ + " and JLZTM in(22,25,51)");
|
|
|
+ update.wrLongParm("bmid", bmid);
|
|
|
+ update.wrFltParm("zfs", totals.totalScore);
|
|
|
+ update.wrFltParm("cql", totals.attendanceRate);
|
|
|
+ update.wrFltParm("kqfs", totals.attendanceRate);
|
|
|
+ update.wrIntParm("dlfs", totals.queueScore);
|
|
|
+ update.wrIntParm("fmfs", totals.demeanorScore);
|
|
|
+ update.wrIntParm("jlfs", totals.disciplineScore);
|
|
|
+ update.wrStrParm("ms", ms);
|
|
|
+ update.wrLongParm("fjid", fjid);
|
|
|
+ update.wrTimeParm("jcsj", jcsj);
|
|
|
+ update.wrLongParm("jcryid", user.ryid);
|
|
|
+ update.wrLongParm("glryid", user.ryid);
|
|
|
+ update.wrLongParm("glbmid", bmid);
|
|
|
+ update.wrLongParm("sqljcid", sqljcid);
|
|
|
+ if (gdba.doModByC(update) != 1)
|
|
|
+ throw new IllegalStateException("升旗礼记录更新失败");
|
|
|
+ }
|
|
|
+ replaceSqljcItems(gdba, sqljcid, itemValues, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void replaceSqljcItems(Db gdba, long sqljcid,
|
|
|
+ Map<Integer, Integer> values,
|
|
|
+ UserRunB user) throws Exception {
|
|
|
+ SqlCmd delete = new SqlCmd(
|
|
|
+ "delete from SQLJCMX where SQLJCID=:sqljcid");
|
|
|
+ delete.wrLongParm("sqljcid", sqljcid);
|
|
|
+ gdba.doModByC(delete);
|
|
|
+
|
|
|
+ Set<String> fields = new LinkedHashSet<>(Arrays.asList(
|
|
|
+ "sqljcmxid", "sqljcid", "sqljcxmm", "fs", "jlztm"));
|
|
|
+ for (Map.Entry<Integer, Integer> entry : values.entrySet()) {
|
|
|
+ SqljcmxPo po = new SqljcmxPo();
|
|
|
+ po.setSqljcmxid(gdba.rdNextSeqVal("SQLJCMXID"));
|
|
|
+ po.setSqljcid(sqljcid);
|
|
|
+ po.setSqljcxmm(entry.getKey());
|
|
|
+ po.setFs(entry.getValue());
|
|
|
+ po.setJlztm(ObjC.JLZT_inUse);
|
|
|
+ DbU.wrSsFieldByPo(po, fields, user, false);
|
|
|
+ gdba.doInsPo(po, fields);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** 读取检查项目。Lin */
|
|
|
private List<Map<String, Object>> rdJcxmList(Db gdba) throws Exception {
|
|
|
SqlCmd sqlc = new SqlCmd(SQL_jcxmList);
|
|
|
@@ -208,6 +588,13 @@ public class SqljcServ extends Serv {
|
|
|
return val == null ? null : Long.valueOf(val);
|
|
|
}
|
|
|
|
|
|
+ private long rdLongValue(Object valObj) {
|
|
|
+ if (valObj == null)
|
|
|
+ return 0L;
|
|
|
+ String val = StringUtils.trimToNull(String.valueOf(valObj));
|
|
|
+ return val == null ? 0L : Long.parseLong(val);
|
|
|
+ }
|
|
|
+
|
|
|
private Integer rdIntObj(Object valObj) {
|
|
|
if (valObj == null)
|
|
|
return null;
|