|
|
@@ -42,6 +42,7 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
private static final String CFG_APP_SECRET = "hk.appSecret";
|
|
|
private static final String CFG_AUTH_ITEM_NOS = "hk.leaveAuth.authItemNos";
|
|
|
private static final String CFG_DOOR_INDEX_CODES = "hk.leaveAuth.doorIndexCodes";
|
|
|
+ private static final String CFG_MJDIDS = "hk.leaveAuth.mjdids";
|
|
|
private static final int HK_DEF_PORT = 443;
|
|
|
private static final DateTimeFormatter HK_AUTH_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX");
|
|
|
|
|
|
@@ -139,8 +140,10 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
}
|
|
|
|
|
|
List<String> authItemNoList = rdAuthItemNoList(ctx.bjid);
|
|
|
- List<String> doorIndexCodeList = rdDoorIndexCodeList(ctx.bjid);
|
|
|
+ DoorConfig doorConfig = rdDoorConfig(gdba, ctx.bjid);
|
|
|
result.put("authItemNos", authItemNoList);
|
|
|
+ result.put("doorConfig", makeDoorConfigResp(doorConfig));
|
|
|
+ List<String> doorIndexCodeList = doorConfig.doorIndexCodeList;
|
|
|
result.put("doorIndexCodes", doorIndexCodeList);
|
|
|
if (authItemNoList.isEmpty()) {
|
|
|
result.put("ok", false);
|
|
|
@@ -240,11 +243,21 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return rdCsvCfg(CFG_AUTH_ITEM_NOS, "HK_LEAVE_AUTH_AUTH_ITEM_NOS");
|
|
|
}
|
|
|
|
|
|
- private static List<String> rdDoorIndexCodeList(long bjid) {
|
|
|
+ private static DoorConfig rdDoorConfig(Db gdba, long bjid) throws Exception {
|
|
|
+ List<Long> mjdidList = rdLongCsvCfg("hk.leaveAuth.bjid." + bjid + ".mjdids", null);
|
|
|
+ if (mjdidList.isEmpty())
|
|
|
+ mjdidList = rdLongCsvCfg(CFG_MJDIDS, "HK_LEAVE_AUTH_MJDIDS");
|
|
|
+ if (!mjdidList.isEmpty()) {
|
|
|
+ List<Map<String, Object>> mjdList = selMjdListById(gdba, mjdidList);
|
|
|
+ List<String> doorIndexCodeList = extDoorIndexCodeList(mjdList);
|
|
|
+ return new DoorConfig("mjdids", mjdidList, mjdList, doorIndexCodeList);
|
|
|
+ }
|
|
|
+
|
|
|
List<String> doorIndexCodeList = rdCsvCfg("hk.leaveAuth.bjid." + bjid + ".doorIndexCodes", null);
|
|
|
if (!doorIndexCodeList.isEmpty())
|
|
|
- return doorIndexCodeList;
|
|
|
- return rdCsvCfg(CFG_DOOR_INDEX_CODES, "HK_LEAVE_AUTH_DOOR_INDEX_CODES");
|
|
|
+ return new DoorConfig("doorIndexCodes", List.of(), List.of(), doorIndexCodeList);
|
|
|
+ doorIndexCodeList = rdCsvCfg(CFG_DOOR_INDEX_CODES, "HK_LEAVE_AUTH_DOOR_INDEX_CODES");
|
|
|
+ return new DoorConfig("doorIndexCodes", List.of(), List.of(), doorIndexCodeList);
|
|
|
}
|
|
|
|
|
|
private static String makeHkTime(Timestamp time) {
|
|
|
@@ -298,6 +311,24 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return new ArrayList<>(valueSet);
|
|
|
}
|
|
|
|
|
|
+ private static List<Long> rdLongCsvCfg(String propName, String envName) {
|
|
|
+ String csvStr = rdCfg(propName, envName);
|
|
|
+ if (StringUtils.isBlank(csvStr))
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ LinkedHashSet<Long> valueSet = new LinkedHashSet<>();
|
|
|
+ for (String item : csvStr.split(",")) {
|
|
|
+ String value = StringUtils.trimToEmpty(item);
|
|
|
+ if (StringUtils.isBlank(value))
|
|
|
+ continue;
|
|
|
+ try {
|
|
|
+ valueSet.add(Long.parseLong(value));
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ArrayList<>(valueSet);
|
|
|
+ }
|
|
|
+
|
|
|
private static void logDryRun(LeaveAuthSyncCtx ctx,
|
|
|
Map<String, Object> personInfo,
|
|
|
Map<String, Object> payload) {
|
|
|
@@ -377,6 +408,49 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
return row;
|
|
|
}
|
|
|
|
|
|
+ private static Map<String, Object> makeDoorConfigResp(DoorConfig doorConfig) {
|
|
|
+ Map<String, Object> row = new LinkedHashMap<>();
|
|
|
+ row.put("source", doorConfig.source);
|
|
|
+ row.put("mjdids", doorConfig.mjdidList);
|
|
|
+ row.put("doorIndexCodes", doorConfig.doorIndexCodeList);
|
|
|
+ row.put("mjdList", doorConfig.mjdList);
|
|
|
+ return row;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static List<Map<String, Object>> selMjdListById(Db gdba, List<Long> mjdidList) throws Exception {
|
|
|
+ if (mjdidList == null || mjdidList.isEmpty())
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ StringBuilder inSql = new StringBuilder();
|
|
|
+ for (int i = 0; i < mjdidList.size(); i++) {
|
|
|
+ if (i > 0)
|
|
|
+ inSql.append(",");
|
|
|
+ inSql.append(":id").append(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "select MJDID mjdid,MC mc,SBBS sbbs,CDID cdid,MJDLBM mjdlbm,JCFXM jcfxm,JLZTM jlztm"
|
|
|
+ + " from MJD where JLZTM in (21,22,25,51,81)"
|
|
|
+ + " and MJDID in (" + inSql + ")"
|
|
|
+ + " order by MJDID";
|
|
|
+ SqlCmd sqlCmd = new SqlCmd(sql);
|
|
|
+ for (int i = 0; i < mjdidList.size(); i++)
|
|
|
+ sqlCmd.wrLongParm("id" + i, mjdidList.get(i));
|
|
|
+ return gdba.doSelMapListByC(sqlCmd);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static List<String> extDoorIndexCodeList(List<Map<String, Object>> mjdList) {
|
|
|
+ if (mjdList == null || mjdList.isEmpty())
|
|
|
+ return List.of();
|
|
|
+
|
|
|
+ LinkedHashSet<String> codeSet = new LinkedHashSet<>();
|
|
|
+ for (Map<String, Object> mjd : mjdList) {
|
|
|
+ String sbbs = rdStr(mjd.get("sbbs"));
|
|
|
+ if (StringUtils.isNotBlank(sbbs))
|
|
|
+ codeSet.add(sbbs);
|
|
|
+ }
|
|
|
+ return new ArrayList<>(codeSet);
|
|
|
+ }
|
|
|
+
|
|
|
private static String rdStr(Object value) {
|
|
|
return value == null ? null : StringUtils.trimToNull(String.valueOf(value));
|
|
|
}
|
|
|
@@ -461,4 +535,21 @@ public class HkLeaveAuthServ extends Serv {
|
|
|
this.jobNo = jobNo;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private static final class DoorConfig {
|
|
|
+ private final String source;
|
|
|
+ private final List<Long> mjdidList;
|
|
|
+ private final List<Map<String, Object>> mjdList;
|
|
|
+ private final List<String> doorIndexCodeList;
|
|
|
+
|
|
|
+ private DoorConfig(String source,
|
|
|
+ List<Long> mjdidList,
|
|
|
+ List<Map<String, Object>> mjdList,
|
|
|
+ List<String> doorIndexCodeList) {
|
|
|
+ this.source = source;
|
|
|
+ this.mjdidList = mjdidList == null ? List.of() : mjdidList;
|
|
|
+ this.mjdList = mjdList == null ? List.of() : mjdList;
|
|
|
+ this.doorIndexCodeList = doorIndexCodeList == null ? List.of() : doorIndexCodeList;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|