|
|
@@ -49,6 +49,8 @@ public class XjbFjjcServ extends Serv {
|
|
|
private static final ZoneId CN_ZONE = ZoneId.of("Asia/Shanghai");
|
|
|
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 OBJECT_NAME = "fjjc";
|
|
|
private static final String BPM_NAME = "fjjc_zj";
|
|
|
private static final int RESULT_NO_VIOLATION = 1;
|
|
|
@@ -84,6 +86,251 @@ public class XjbFjjcServ extends Serv {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 移动端列表:按检查日期分页查询当前账号可见的风纪检查批次。
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unused")
|
|
|
+ public void listByA() 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 db = Db.makeConn()) {
|
|
|
+ UserRunB user = requireUser(request);
|
|
|
+ LocalDate inspectionDate = rdDate(firstNotBlank(
|
|
|
+ request.getParameter("jcsjDate"),
|
|
|
+ request.getParameter("jcrq")));
|
|
|
+ int pageNo = Math.max(1, rdInt(request.getParameter("pageNo"), 1));
|
|
|
+ int pageSize = rdInt(request.getParameter("pageSize"), 20);
|
|
|
+ pageSize = Math.max(1, Math.min(100, pageSize));
|
|
|
+ long offset = (long) (pageNo - 1) * pageSize;
|
|
|
+ long maxRow = offset + pageSize;
|
|
|
+ long bmid = user.bmid == null ? 0L : user.bmid;
|
|
|
+ String scope = bmid > 0
|
|
|
+ ? "(h.BMID=:bmid or h.JCRYID=:ryid)"
|
|
|
+ : "h.JCRYID=:ryid";
|
|
|
+
|
|
|
+ SqlCmd countSql = new SqlCmd(
|
|
|
+ "select count(*) CNT from XJB_FJJC h"
|
|
|
+ + " where h.JCRQ=:jcrq and h.JLZTM in(21,51)"
|
|
|
+ + " and " + scope);
|
|
|
+ countSql.wrDateParm("jcrq", Date.valueOf(inspectionDate));
|
|
|
+ if (bmid > 0)
|
|
|
+ countSql.wrLongParm("bmid", bmid);
|
|
|
+ countSql.wrLongParm("ryid", user.ryid);
|
|
|
+ db.doSelByC(countSql);
|
|
|
+ int total = db.rowNum > 0 ? db.rdIntCol("cnt") : 0;
|
|
|
+
|
|
|
+ String sql = "select * from ("
|
|
|
+ + " select a.*,rownum RN from ("
|
|
|
+ + " select h.XJB_FJJCID,h.JCRQ,h.JCSJ,h.FJLX,h.JCRYID,"
|
|
|
+ + " h.BMID,h.FJFS,h.JFKF,nvl(h.MS,'') MS,h.JLZTM,"
|
|
|
+ + " nvl(ry.XM,'') JCRYXM,nvl(bm.MC,'') BMMC,"
|
|
|
+ + " (select count(*) from XJB_FJJCMX m"
|
|
|
+ + " where m.XJB_FJJCID=h.XJB_FJJCID"
|
|
|
+ + " and m.JLZTM in(21,51)) CLASSCNT,"
|
|
|
+ + " (select nvl(sum(nvl(m.WJRS,0)),0) from XJB_FJJCMX m"
|
|
|
+ + " where m.XJB_FJJCID=h.XJB_FJJCID"
|
|
|
+ + " and m.JLZTM in(21,51)) WJCNT"
|
|
|
+ + " from XJB_FJJC h"
|
|
|
+ + " left join RY ry on ry.RYID=h.JCRYID"
|
|
|
+ + " left join BM bm on bm.BMID=h.BMID"
|
|
|
+ + " where h.JCRQ=:jcrq and h.JLZTM in(21,51)"
|
|
|
+ + " and " + scope
|
|
|
+ + " order by h.JCSJ desc,h.XJB_FJJCID desc"
|
|
|
+ + " ) a"
|
|
|
+ + ") where RN>:offset and RN<=:maxRow";
|
|
|
+ SqlCmd sqlc = new SqlCmd(sql);
|
|
|
+ sqlc.wrDateParm("jcrq", Date.valueOf(inspectionDate));
|
|
|
+ if (bmid > 0)
|
|
|
+ sqlc.wrLongParm("bmid", bmid);
|
|
|
+ sqlc.wrLongParm("ryid", user.ryid);
|
|
|
+ sqlc.wrLongParm("offset", offset);
|
|
|
+ sqlc.wrLongParm("maxRow", maxRow);
|
|
|
+ List<Map<String, Object>> rows = db.doSelMapListByC(sqlc);
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ if (rows != null) {
|
|
|
+ for (Map<String, Object> row : rows) {
|
|
|
+ int inspectionType = rdInt(row.get("fjlx"), 0);
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
+ item.put("xjb_fjjcid", rdLong(row.get("xjb_fjjcid"), 0L));
|
|
|
+ item.put("jcrq", inspectionDate.format(DATE_FMT));
|
|
|
+ item.put("jcsj", formatTimestamp(row.get("jcsj")));
|
|
|
+ item.put("fjlx", inspectionType);
|
|
|
+ item.put("fjlxmc", inspectionTypeName(inspectionType));
|
|
|
+ item.put("jcryid", rdLong(row.get("jcryid"), 0L));
|
|
|
+ item.put("jcryxm", rdStr(row.get("jcryxm")));
|
|
|
+ item.put("bmid", rdLong(row.get("bmid"), 0L));
|
|
|
+ item.put("bmmc", rdStr(row.get("bmmc")));
|
|
|
+ item.put("fjfs", rdDouble(row.get("fjfs"), 0D));
|
|
|
+ item.put("jfkf", rdDouble(row.get("jfkf"), 0D));
|
|
|
+ item.put("ms", rdStr(row.get("ms")));
|
|
|
+ item.put("classCount", rdInt(row.get("classcnt"), 0));
|
|
|
+ item.put("violationCount", rdInt(row.get("wjcnt"), 0));
|
|
|
+ int status = rdInt(row.get("jlztm"), 0);
|
|
|
+ item.put("jlztm", status);
|
|
|
+ item.put("statusName", status == ObjC.JLZT_inUse
|
|
|
+ ? "已生效" : "审批中");
|
|
|
+ list.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
+ data.put("jcsjDate", inspectionDate.format(DATE_FMT));
|
|
|
+ data.put("pageNo", pageNo);
|
|
|
+ data.put("pageSize", pageSize);
|
|
|
+ data.put("total", total);
|
|
|
+ data.put("hasMore", maxRow < total);
|
|
|
+ data.put("list", list);
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("XjbFjjcServ.listByA() 异常", e);
|
|
|
+ ServU.wrErrMsgByWriter(null, "风纪检查记录加载失败", writer, gson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 移动端详情:风纪检查批次、班级检查结果和关联违纪记录。
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unused")
|
|
|
+ public void playByA() 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 db = Db.makeConn()) {
|
|
|
+ UserRunB user = requireUser(request);
|
|
|
+ long headerId = rdLong(request.getParameter("xjb_fjjcid"), 0L);
|
|
|
+ if (headerId <= 0)
|
|
|
+ throw new IllegalArgumentException("风纪检查记录编号不正确");
|
|
|
+ long bmid = user.bmid == null ? 0L : user.bmid;
|
|
|
+ String scope = bmid > 0
|
|
|
+ ? "(h.BMID=:bmid or h.JCRYID=:ryid)"
|
|
|
+ : "h.JCRYID=:ryid";
|
|
|
+ SqlCmd mainSql = new SqlCmd(
|
|
|
+ "select h.XJB_FJJCID,h.JCRQ,h.JCSJ,h.FJLX,h.JCRYID,"
|
|
|
+ + "h.BMID,h.FJFS,h.JFKF,nvl(h.MS,'') MS,h.JLZTM,"
|
|
|
+ + "nvl(ry.XM,'') JCRYXM,nvl(bm.MC,'') BMMC"
|
|
|
+ + " from XJB_FJJC h"
|
|
|
+ + " left join RY ry on ry.RYID=h.JCRYID"
|
|
|
+ + " left join BM bm on bm.BMID=h.BMID"
|
|
|
+ + " where h.XJB_FJJCID=:id"
|
|
|
+ + " and h.JLZTM in(21,51) and " + scope);
|
|
|
+ mainSql.wrLongParm("id", headerId);
|
|
|
+ if (bmid > 0)
|
|
|
+ mainSql.wrLongParm("bmid", bmid);
|
|
|
+ mainSql.wrLongParm("ryid", user.ryid);
|
|
|
+ List<Map<String, Object>> mainRows = db.doSelMapListByC(mainSql);
|
|
|
+ if (mainRows == null || mainRows.isEmpty())
|
|
|
+ throw new IllegalArgumentException("风纪检查记录不存在或无权查看");
|
|
|
+ Map<String, Object> header = mainRows.get(0);
|
|
|
+
|
|
|
+ SqlCmd classSql = new SqlCmd(
|
|
|
+ "select m.XJB_FJJCMXID,m.BJID,nvl(b.MC,'') BJMC,"
|
|
|
+ + "m.JCJG,m.FJFS,m.JFKF,m.WJRS,nvl(m.MS,'') MS,m.JLZTM"
|
|
|
+ + " from XJB_FJJCMX m"
|
|
|
+ + " left join BJ b on b.BJID=m.BJID"
|
|
|
+ + " where m.XJB_FJJCID=:id and m.JLZTM in(21,51)"
|
|
|
+ + " order by b.MC,m.BJID");
|
|
|
+ classSql.wrLongParm("id", headerId);
|
|
|
+ List<Map<String, Object>> classRows = db.doSelMapListByC(classSql);
|
|
|
+ if (classRows == null)
|
|
|
+ classRows = new ArrayList<>();
|
|
|
+
|
|
|
+ SqlCmd violationSql = new SqlCmd(
|
|
|
+ "select x.XJB_FJJCMXID,x.WJJLID,w.BJID,nvl(b.MC,'') BJMC,"
|
|
|
+ + "w.WJLBM,nvl(lb.MC,'') WJLBMC,w.WJSJ,"
|
|
|
+ + "nvl(ry.XM,'') XM,nvl(lb.BJKF,0) BJFK,nvl(w.MS,'') MS"
|
|
|
+ + " from XJB_FJJC_WJJL x"
|
|
|
+ + " inner join WJJL w on w.WJJLID=x.WJJLID and w.JLZTM=51"
|
|
|
+ + " left join WJLB lb on lb.WJLBM=w.WJLBM"
|
|
|
+ + " left join BJ b on b.BJID=w.BJID"
|
|
|
+ + " left join RY ry on ry.RYID=nvl(w.RYID,w.FZRYID)"
|
|
|
+ + " where x.XJB_FJJCID=:id"
|
|
|
+ + " order by w.WJSJ,w.WJJLID");
|
|
|
+ violationSql.wrLongParm("id", headerId);
|
|
|
+ List<Map<String, Object>> violationRows =
|
|
|
+ db.doSelMapListByC(violationSql);
|
|
|
+ Map<Long, List<Map<String, Object>>> violationsByClass =
|
|
|
+ new LinkedHashMap<>();
|
|
|
+ if (violationRows != null) {
|
|
|
+ for (Map<String, Object> row : violationRows) {
|
|
|
+ long resultId = rdLong(row.get("xjb_fjjcmxid"), 0L);
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
+ item.put("wjjlid", rdLong(row.get("wjjlid"), 0L));
|
|
|
+ item.put("wjlbm", rdInt(row.get("wjlbm"), 0));
|
|
|
+ item.put("wjlbmc", rdStr(row.get("wjlbmc")));
|
|
|
+ item.put("wjsj", formatTimestamp(row.get("wjsj")));
|
|
|
+ item.put("xm", rdStr(row.get("xm")));
|
|
|
+ item.put("bjfk", rdDouble(row.get("bjfk"), 0D));
|
|
|
+ item.put("ms", rdStr(row.get("ms")));
|
|
|
+ violationsByClass.computeIfAbsent(resultId,
|
|
|
+ key -> new ArrayList<>()).add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> classList = new ArrayList<>();
|
|
|
+ int totalViolations = 0;
|
|
|
+ for (Map<String, Object> row : classRows) {
|
|
|
+ long resultId = rdLong(row.get("xjb_fjjcmxid"), 0L);
|
|
|
+ int violationCount = rdInt(row.get("wjrs"), 0);
|
|
|
+ totalViolations += violationCount;
|
|
|
+ int resultCode = rdInt(row.get("jcjg"), 0);
|
|
|
+ Map<String, Object> item = new LinkedHashMap<>();
|
|
|
+ item.put("xjb_fjjcmxid", resultId);
|
|
|
+ item.put("bjid", rdLong(row.get("bjid"), 0L));
|
|
|
+ item.put("bjmc", rdStr(row.get("bjmc")));
|
|
|
+ item.put("jcjg", resultCode);
|
|
|
+ item.put("jcjgmc", resultCode == RESULT_HAS_VIOLATION
|
|
|
+ ? "有违纪" : "无违纪");
|
|
|
+ item.put("fjfs", rdDouble(row.get("fjfs"), 0D));
|
|
|
+ item.put("jfkf", rdDouble(row.get("jfkf"), 0D));
|
|
|
+ item.put("wjrs", violationCount);
|
|
|
+ item.put("ms", rdStr(row.get("ms")));
|
|
|
+ item.put("violations", violationsByClass.getOrDefault(
|
|
|
+ resultId, new ArrayList<>()));
|
|
|
+ classList.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ int inspectionType = rdInt(header.get("fjlx"), 0);
|
|
|
+ LocalDate inspectionDate = rdLocalDate(header.get("jcrq"));
|
|
|
+ Map<String, Object> record = new LinkedHashMap<>();
|
|
|
+ record.put("xjb_fjjcid", headerId);
|
|
|
+ record.put("jcrq", inspectionDate == null ? ""
|
|
|
+ : inspectionDate.format(DATE_FMT));
|
|
|
+ record.put("jcsj", formatTimestamp(header.get("jcsj")));
|
|
|
+ record.put("fjlx", inspectionType);
|
|
|
+ record.put("fjlxmc", inspectionTypeName(inspectionType));
|
|
|
+ record.put("jcryid", rdLong(header.get("jcryid"), 0L));
|
|
|
+ record.put("jcryxm", rdStr(header.get("jcryxm")));
|
|
|
+ record.put("bmid", rdLong(header.get("bmid"), 0L));
|
|
|
+ record.put("bmmc", rdStr(header.get("bmmc")));
|
|
|
+ record.put("fjfs", rdDouble(header.get("fjfs"), 0D));
|
|
|
+ record.put("jfkf", rdDouble(header.get("jfkf"), 0D));
|
|
|
+ record.put("ms", rdStr(header.get("ms")));
|
|
|
+ record.put("classCount", classList.size());
|
|
|
+ record.put("violationCount", totalViolations);
|
|
|
+ int status = rdInt(header.get("jlztm"), 0);
|
|
|
+ record.put("jlztm", status);
|
|
|
+ record.put("statusName", status == ObjC.JLZT_inUse
|
|
|
+ ? "已生效" : "审批中");
|
|
|
+
|
|
|
+ Map<String, Object> data = new LinkedHashMap<>();
|
|
|
+ data.put("record", record);
|
|
|
+ data.put("classList", classList);
|
|
|
+ ServU.wrOkDataByWriter(data, writer, gson);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ ServU.wrErrMsgByWriter(null, e.getMessage(), writer, gson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log4j.error("XjbFjjcServ.playByA() 异常", e);
|
|
|
+ ServU.wrErrMsgByWriter(null, "风纪检查详情加载失败", writer, gson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询本次检查可关联的风纪违纪记录。
|
|
|
*
|
|
|
@@ -308,6 +555,21 @@ public class XjbFjjcServ extends Serv {
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
+ private static String inspectionTypeName(int code) {
|
|
|
+ switch (code) {
|
|
|
+ case 1:
|
|
|
+ return "校门上午";
|
|
|
+ case 2:
|
|
|
+ return "校门下午";
|
|
|
+ case 3:
|
|
|
+ return "集队";
|
|
|
+ case 4:
|
|
|
+ return "政教月检";
|
|
|
+ default:
|
|
|
+ return "其他";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static void validateInspectionType(int value) {
|
|
|
if (value < 1 || value > 5)
|
|
|
throw new IllegalArgumentException("检查类型不正确");
|
|
|
@@ -723,6 +985,33 @@ public class XjbFjjcServ extends Serv {
|
|
|
DATE_FMT);
|
|
|
}
|
|
|
|
|
|
+ private static String formatTimestamp(Object value) {
|
|
|
+ Timestamp timestamp = null;
|
|
|
+ if (value instanceof Timestamp item)
|
|
|
+ timestamp = item;
|
|
|
+ else if (value instanceof Date item)
|
|
|
+ timestamp = new Timestamp(item.getTime());
|
|
|
+ else if (value instanceof java.util.Date item)
|
|
|
+ timestamp = new Timestamp(item.getTime());
|
|
|
+ else {
|
|
|
+ String text = StringUtils.trimToNull(
|
|
|
+ value == null ? null : String.valueOf(value));
|
|
|
+ if (text != null) {
|
|
|
+ try {
|
|
|
+ timestamp = Timestamp.valueOf(text.replace('T', ' '));
|
|
|
+ } catch (IllegalArgumentException ignored) {
|
|
|
+ // Keep malformed optional values out of the response.
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return timestamp == null ? ""
|
|
|
+ : timestamp.toLocalDateTime().format(DATETIME_FMT);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String rdStr(Object value) {
|
|
|
+ return value == null ? "" : StringUtils.trimToEmpty(String.valueOf(value));
|
|
|
+ }
|
|
|
+
|
|
|
private static long rdLong(Object value, long defaultValue) {
|
|
|
if (value == null)
|
|
|
return defaultValue;
|