|
|
@ -36,46 +36,22 @@ public enum DataSyncBasicEnum { |
|
|
|
ATT_DIKE_DBIABT("堤防工程效益", Constants.DF_ID_MAP), |
|
|
|
ATT_DIKE_DKHOS("堤防决溢记录", Constants.DF_DKHOS_MAP), |
|
|
|
ATT_WAGA_BASE("水闸基础信息", Constants.SZ_MAP), |
|
|
|
ATT_WAGA_CODE("水闸工程代码", Constants.SZ_MAP), |
|
|
|
ATT_WAGA_SLHYPR("水闸水文特征", Constants.SZ_ID_MAP), |
|
|
|
ATT_WAGA_SLIGVL("水闸工程结构", Constants.SZ_ID_MAP), |
|
|
|
ATT_WAGA_SLDNNT("水闸出险记录", Constants.SZ_DAWST_MAP), |
|
|
|
ATT_RV_BASE("河流基础信息", Constants.RV_MAP), |
|
|
|
ATT_DPDS_BASE("险工险峻信息", Constants.DPDS_MAP), |
|
|
|
ATT_BAS_BASE("流域基础信息", Constants.BAS_MAP), |
|
|
|
ATT_ST_BASE("水文水工程监测站基础信息", Constants.ST_MAP, records -> { |
|
|
|
Map<String, List<BsSgcStMon>> monMap = records.stream().map(JSONObject.class::cast) |
|
|
|
.map(JsonObjProxy::new) |
|
|
|
.collect(Collectors.toMap(obj -> obj.getString("stcd"), obj -> { |
|
|
|
String monProj = obj.getString("monProj"); |
|
|
|
if (StringUtils.isEmpty(monProj)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
String stcd = obj.getString("stcd"); |
|
|
|
return Arrays.stream(monProj.split(",")) |
|
|
|
.map(proj -> { |
|
|
|
BsSgcStMon monProjObj = new BsSgcStMon(); |
|
|
|
monProjObj.setStcd(stcd); |
|
|
|
monProjObj.setMonProj(proj); |
|
|
|
return monProjObj; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}, (a, b) -> a)); |
|
|
|
BsSgcStMonService monMapper = SpringUtils.getBean(BsSgcStMonService.class); |
|
|
|
monMapper.removeByIds(monMap.keySet()); |
|
|
|
monMapper.saveBatch(monMap.values().stream().flatMap(Collection::stream) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.toList()), 1000); |
|
|
|
}), |
|
|
|
SYS_XZQH("行政区划基础信息", new HashMap<String, Function<JsonObjProxy, Object>>() {{ |
|
|
|
put("id", obj -> obj.getString("adcd")); |
|
|
|
put("xzqhdm", obj -> obj.getString("adcd")); |
|
|
|
put("parentid", obj -> obj.getString("adupcd")); |
|
|
|
put("name", obj -> obj.getString("adnm")); |
|
|
|
put("layer", obj -> obj.getInteger("adlevel")); |
|
|
|
}}), |
|
|
|
ATT_ST_BASE("水文水工程监测站基础信息", Constants.ST_MAP, AfterHandler.ST_BASE), |
|
|
|
SYS_XZQH("行政区划基础信息", Constants.XZQH_MAP), |
|
|
|
; |
|
|
|
|
|
|
|
//中文名称
|
|
|
|
private final String zhName; |
|
|
|
//字段映射处理器,默认自动映射,如:wageCode匹配waga_code、wagaCode、WAGA_CODE
|
|
|
|
private final Map<String, Function<JsonObjProxy, Object>> valueHandler; |
|
|
|
//数据同步后处理器 默认空实现
|
|
|
|
private final Consumer<JSONArray> afterHandler; |
|
|
|
|
|
|
|
|
|
|
@ -103,7 +79,40 @@ public enum DataSyncBasicEnum { |
|
|
|
return "表[" + this.getZhName() + "](" + this.zhName + ")"; |
|
|
|
} |
|
|
|
|
|
|
|
public static class AfterHandler { |
|
|
|
public static final Consumer<JSONArray> ST_BASE = (records) -> { |
|
|
|
Map<String, List<BsSgcStMon>> monMap = records.stream().map(JSONObject.class::cast) |
|
|
|
.map(JsonObjProxy::new) |
|
|
|
.collect(Collectors.toMap(obj -> obj.getString("stcd"), obj -> { |
|
|
|
String monProj = obj.getString("monProj"); |
|
|
|
if (StringUtils.isEmpty(monProj)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
String stcd = obj.getString("stcd"); |
|
|
|
return Arrays.stream(monProj.split(",")) |
|
|
|
.map(proj -> { |
|
|
|
BsSgcStMon monProjObj = new BsSgcStMon(); |
|
|
|
monProjObj.setStcd(stcd); |
|
|
|
monProjObj.setMonProj(proj); |
|
|
|
return monProjObj; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}, (a, b) -> a)); |
|
|
|
BsSgcStMonService monMapper = SpringUtils.getBean(BsSgcStMonService.class); |
|
|
|
monMapper.removeByIds(monMap.keySet()); |
|
|
|
monMapper.saveBatch(monMap.values().stream().flatMap(Collection::stream) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.toList()), 1000); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public static class Constants { |
|
|
|
public static final Map<String, Function<JsonObjProxy, Object>> XZQH_MAP = new HashMap<String, Function<JsonObjProxy, Object>>() {{ |
|
|
|
put("id", obj -> obj.getString("adcd")); |
|
|
|
put("xzqhdm", obj -> obj.getString("adcd")); |
|
|
|
put("parentid", obj -> obj.getString("adupcd")); |
|
|
|
put("name", obj -> obj.getString("adnm")); |
|
|
|
put("layer", obj -> obj.getInteger("adlevel")); |
|
|
|
}}; |
|
|
|
|
|
|
|
public static final Map<String, Function<JsonObjProxy, Object>> SK_MAP = new HashMap<String, Function<JsonObjProxy, Object>>() {{ |
|
|
|
put("id", obj -> obj.getString("resCode")); |
|
|
|