|
@@ -23,6 +23,7 @@ import java.util.LinkedHashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 2026-05-26:班主任请假后的海康临时权限同步服务。
|
|
* 2026-05-26:班主任请假后的海康临时权限同步服务。
|
|
@@ -193,6 +194,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (StringUtils.isBlank(ctx.jobNo)) {
|
|
if (StringUtils.isBlank(ctx.jobNo)) {
|
|
|
result.put("ok", false);
|
|
result.put("ok", false);
|
|
|
result.put("msg", "学生缺少人员号(jobNo/RYH),无法匹配海康人员。");
|
|
result.put("msg", "学生缺少人员号(jobNo/RYH),无法匹配海康人员。");
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -200,6 +202,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (hkConnParm == null) {
|
|
if (hkConnParm == null) {
|
|
|
result.put("ok", false);
|
|
result.put("ok", false);
|
|
|
result.put("msg", "缺少海康连接配置,请补齐 hk.host / hk.appKey / hk.appSecret。");
|
|
result.put("msg", "缺少海康连接配置,请补齐 hk.host / hk.appKey / hk.appSecret。");
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
result.put("hkConn", makeSafeHkConnResp(hkConnParm));
|
|
result.put("hkConn", makeSafeHkConnResp(hkConnParm));
|
|
@@ -212,6 +215,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (personInfo == null) {
|
|
if (personInfo == null) {
|
|
|
result.put("ok", false);
|
|
result.put("ok", false);
|
|
|
result.put("msg", "海康侧未找到对应人员。");
|
|
result.put("msg", "海康侧未找到对应人员。");
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
result.put("personInfo", makePersonInfoResp(personInfo));
|
|
result.put("personInfo", makePersonInfoResp(personInfo));
|
|
@@ -220,6 +224,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (StringUtils.isBlank(personId)) {
|
|
if (StringUtils.isBlank(personId)) {
|
|
|
result.put("ok", false);
|
|
result.put("ok", false);
|
|
|
result.put("msg", "海康人员缺少 personId。");
|
|
result.put("msg", "海康人员缺少 personId。");
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -501,6 +506,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (resourceInfoList.isEmpty()) {
|
|
if (resourceInfoList.isEmpty()) {
|
|
|
result.put("ok", false);
|
|
result.put("ok", false);
|
|
|
result.put("msg", "未找到可下发的有效门禁点。");
|
|
result.put("msg", "未找到可下发的有效门禁点。");
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -563,6 +569,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
if (StringUtils.isBlank(tagId)) {
|
|
if (StringUtils.isBlank(tagId)) {
|
|
|
result.put("skipReason", "缺少海康下发配置 tagId,暂不执行添加权限配置。");
|
|
result.put("skipReason", "缺少海康下发配置 tagId,暂不执行添加权限配置。");
|
|
|
result.put("mode", "preview");
|
|
result.put("mode", "preview");
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -571,6 +578,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
result.put("mode", "dryRun");
|
|
result.put("mode", "dryRun");
|
|
|
if (autoTrigger)
|
|
if (autoTrigger)
|
|
|
logDryRun(ctx, personInfo, payload);
|
|
logDryRun(ctx, personInfo, payload);
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -588,6 +596,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
logExecute(ctx, personInfo, payload, authSyncResp);
|
|
logExecute(ctx, personInfo, payload, authSyncResp);
|
|
|
|
|
+ persistLeaveAuthSyncResult(gdba, ctx, result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -597,7 +606,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
*/
|
|
*/
|
|
|
private static LeaveAuthSyncCtx selLeaveAuthSyncCtx(Db gdba, long rcid) throws Exception {
|
|
private static LeaveAuthSyncCtx selLeaveAuthSyncCtx(Db gdba, long rcid) throws Exception {
|
|
|
String sql = "select rc.RCID rcid,rc.BJID bjid,rc.FZRYID ryid,rc.RCLBM rclbm,rc.KSSJ kssj,rc.JSSJ jssj,"
|
|
String sql = "select rc.RCID rcid,rc.BJID bjid,rc.FZRYID ryid,rc.RCLBM rclbm,rc.KSSJ kssj,rc.JSSJ jssj,"
|
|
|
- + " ry.XM xm,ry.RYH ryh"
|
|
|
|
|
|
|
+ + " rc.MS ms,rc.MSWJ mswj,ry.XM xm,ry.RYH ryh"
|
|
|
+ " from RC rc"
|
|
+ " from RC rc"
|
|
|
+ " left join RY on ry.RYID=rc.FZRYID"
|
|
+ " left join RY on ry.RYID=rc.FZRYID"
|
|
|
+ " where rc.RCID=:rcid";
|
|
+ " where rc.RCID=:rcid";
|
|
@@ -616,7 +625,9 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
(Timestamp) row.get("kssj"),
|
|
(Timestamp) row.get("kssj"),
|
|
|
(Timestamp) row.get("jssj"),
|
|
(Timestamp) row.get("jssj"),
|
|
|
rdStr(row.get("xm")),
|
|
rdStr(row.get("xm")),
|
|
|
- rdStr(row.get("ryh")));
|
|
|
|
|
|
|
+ rdStr(row.get("ryh")),
|
|
|
|
|
+ rdStr(row.get("ms")),
|
|
|
|
|
+ rdStr(row.get("mswj")));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -918,6 +929,78 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
log4j.info("HkLeaveAuthServ.syncLeaveAuthAfterCommit() 已执行:{}", logRow);
|
|
log4j.info("HkLeaveAuthServ.syncLeaveAuthAfterCommit() 已执行:{}", logRow);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 2026-05-27:把请假海康同步结果同步写回 RC,便于上线后直接查单条请假记录的执行痕迹。
|
|
|
|
|
+ */
|
|
|
|
|
+ private static void persistLeaveAuthSyncResult(Db gdba,
|
|
|
|
|
+ LeaveAuthSyncCtx ctx,
|
|
|
|
|
+ Map<String, Object> result) throws Exception {
|
|
|
|
|
+ if (gdba == null || ctx == null || result == null || ctx.rcid <= 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ boolean shouldPersist = Boolean.TRUE.equals(result.get("autoTrigger"))
|
|
|
|
|
+ || "execute".equals(String.valueOf(result.get("mode")));
|
|
|
|
|
+ if (!shouldPersist)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ String ms = makeLeaveAuthLocalLogText(ctx, result);
|
|
|
|
|
+ if (StringUtils.isBlank(ms))
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ String mswj = HkKqDescU.upsertDescFile(ctx.mswj, ms);
|
|
|
|
|
+ RcPo rcPo = new RcPo();
|
|
|
|
|
+ rcPo.setRcid(ctx.rcid);
|
|
|
|
|
+ rcPo.setMs(ms);
|
|
|
|
|
+ rcPo.setMswj(mswj);
|
|
|
|
|
+ gdba.doUpdPo(rcPo, Set.of("ms", "mswj"));
|
|
|
|
|
+ result.put("rcMswj", mswj);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 2026-05-27:把结果整理成一行可读文本,同时兼容 `HkKqDescU` 的富文本落盘格式。
|
|
|
|
|
+ */
|
|
|
|
|
+ private static String makeLeaveAuthLocalLogText(LeaveAuthSyncCtx ctx, Map<String, Object> result) {
|
|
|
|
|
+ List<String> partList = new ArrayList<>();
|
|
|
|
|
+ partList.add("海康请假权限下发");
|
|
|
|
|
+ partList.add("mode=" + rdStr(result.get("mode")));
|
|
|
|
|
+ partList.add("autoTrigger=" + rdStr(result.get("autoTrigger")));
|
|
|
|
|
+ partList.add("ok=" + rdStr(result.get("ok")));
|
|
|
|
|
+ partList.add("rcid=" + ctx.rcid);
|
|
|
|
|
+ partList.add("ryid=" + ctx.ryid);
|
|
|
|
|
+ partList.add("bjid=" + ctx.bjid);
|
|
|
|
|
+ partList.add("jobNo=" + StringUtils.defaultString(ctx.jobNo));
|
|
|
|
|
+ partList.add("xm=" + StringUtils.defaultString(ctx.xm));
|
|
|
|
|
+ partList.add("leaveBeg=" + makeHkTime(ctx.kssj));
|
|
|
|
|
+ partList.add("leaveEnd=" + makeHkTime(ctx.jssj));
|
|
|
|
|
+ partList.add("tagId=" + rdStr(result.get("tagId")));
|
|
|
|
|
+ partList.add("templateId=" + rdStr(result.get("templateId")));
|
|
|
|
|
+ partList.add("templateDimension=" + rdStr(result.get("templateDimension")));
|
|
|
|
|
+ partList.add("resourceCount=" + rdStr(result.get("resourceCount")));
|
|
|
|
|
+ partList.add("authSyncResp=" + makeRespBrief(result.get("authSyncResp")));
|
|
|
|
|
+ partList.add("authDownloadResultQueryResp=" + makeRespBrief(result.get("authDownloadResultQueryResp")));
|
|
|
|
|
+ partList.add("msg=" + rdStr(result.get("msg")));
|
|
|
|
|
+ partList.add("skipReason=" + rdStr(result.get("skipReason")));
|
|
|
|
|
+ partList.add("executeApiPath=" + rdStr(result.get("executeApiPath")));
|
|
|
|
|
+ return String.join(";", partList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 2026-05-27:把海康返回对象压缩成简短描述,避免 RC 备注和描述文件过长。
|
|
|
|
|
+ */
|
|
|
|
|
+ private static String makeRespBrief(Object resp) {
|
|
|
|
|
+ if (!(resp instanceof Map<?, ?> map))
|
|
|
|
|
+ return rdStr(resp);
|
|
|
|
|
+ String code = rdStr(map.get("code"));
|
|
|
|
|
+ String msg = rdStr(map.get("msg"));
|
|
|
|
|
+ if (StringUtils.isAllBlank(code, msg))
|
|
|
|
|
+ return null;
|
|
|
|
|
+ if (StringUtils.isBlank(code))
|
|
|
|
|
+ return msg;
|
|
|
|
|
+ if (StringUtils.isBlank(msg))
|
|
|
|
|
+ return "code=" + code;
|
|
|
|
|
+ return "code=" + code + ", msg=" + msg;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 2026-05-26:把请假信息统一写成日志和响应都能直接读的结构。
|
|
* 2026-05-26:把请假信息统一写成日志和响应都能直接读的结构。
|
|
|
*/
|
|
*/
|
|
@@ -1290,6 +1373,8 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
private final Timestamp jssj;
|
|
private final Timestamp jssj;
|
|
|
private final String xm;
|
|
private final String xm;
|
|
|
private final String jobNo;
|
|
private final String jobNo;
|
|
|
|
|
+ private final String ms;
|
|
|
|
|
+ private final String mswj;
|
|
|
|
|
|
|
|
private LeaveAuthSyncCtx(long rcid,
|
|
private LeaveAuthSyncCtx(long rcid,
|
|
|
long bjid,
|
|
long bjid,
|
|
@@ -1298,7 +1383,9 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
Timestamp kssj,
|
|
Timestamp kssj,
|
|
|
Timestamp jssj,
|
|
Timestamp jssj,
|
|
|
String xm,
|
|
String xm,
|
|
|
- String jobNo) {
|
|
|
|
|
|
|
+ String jobNo,
|
|
|
|
|
+ String ms,
|
|
|
|
|
+ String mswj) {
|
|
|
this.rcid = rcid;
|
|
this.rcid = rcid;
|
|
|
this.bjid = bjid;
|
|
this.bjid = bjid;
|
|
|
this.ryid = ryid;
|
|
this.ryid = ryid;
|
|
@@ -1307,6 +1394,8 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
this.jssj = jssj;
|
|
this.jssj = jssj;
|
|
|
this.xm = xm;
|
|
this.xm = xm;
|
|
|
this.jobNo = jobNo;
|
|
this.jobNo = jobNo;
|
|
|
|
|
+ this.ms = ms;
|
|
|
|
|
+ this.mswj = mswj;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|