commit
This commit is contained in:
@@ -12,6 +12,7 @@ import io.v.nutz.sys.models.Sys_unit;
|
||||
import io.v.nutz.zhgh.data.model.UserSource;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -30,22 +31,10 @@ import java.util.Map;
|
||||
*/
|
||||
public interface SourceData {
|
||||
|
||||
String APP_KEY = "20240919701618366869971844546564530";
|
||||
|
||||
String APP_SECRET = "9307335b784fd46be9f67d67ed0240747190ed28";
|
||||
|
||||
|
||||
String APP_TOKEN_URL = "https://dct.zufe.edu.cn/open_api/authentication/get_access_token";
|
||||
|
||||
/**
|
||||
* 获取用户数据的地址
|
||||
*/
|
||||
String USER_URL_TOTAL = "https://dct.zufe.edu.cn/open_api/customization/vgxjgqxjzgjbxx/full";
|
||||
|
||||
/**
|
||||
* 获取单位的地址
|
||||
*/
|
||||
String UNIT_URL = "https://dct.zufe.edu.cn/open_api/customization/tgxxxyxsdwxx/full";
|
||||
String DATA_URL = "https://zt.hmc.edu.cn/datacenter/dataServiceQuery";
|
||||
|
||||
/**
|
||||
* 断言是否成功
|
||||
@@ -53,9 +42,72 @@ public interface SourceData {
|
||||
* @param jsonResult 接口返回数据
|
||||
*/
|
||||
private static void checkSuccess(NutMap jsonResult) {
|
||||
Assert.isTrue(jsonResult.getInt("code") == 10000, jsonResult.getString("message"));
|
||||
Assert.isTrue(jsonResult.getBoolean("success"), jsonResult.getString("data"));
|
||||
}
|
||||
|
||||
/* *//**
|
||||
* 在职状态码
|
||||
*//*
|
||||
Map<String, String> USER_STATE_CODE = new HashMap<>() {{
|
||||
put("100", "在职状态");
|
||||
put("200", "不在职状态");
|
||||
}};*/
|
||||
/**
|
||||
* 性别码
|
||||
*/
|
||||
Map<String, String> SEX_CODE = new HashMap<>() {{
|
||||
put("0", "未知的性别");
|
||||
put("1", "男");
|
||||
put("2", "女");
|
||||
put("9", "未说明的性别");
|
||||
}};
|
||||
/**
|
||||
* 学历码
|
||||
*/
|
||||
Map<String, String> EDUCATION_CODE = new HashMap<>() {{
|
||||
put("1", "本科");
|
||||
put("2", "博士研究生");
|
||||
put("3", "初中");
|
||||
put("4", "大专");
|
||||
put("5", "高中");
|
||||
put("6", "硕士研究生");
|
||||
put("7", "小学");
|
||||
put("8", "中专");
|
||||
put("9", "无");
|
||||
}};
|
||||
/**
|
||||
* 人员状态码
|
||||
*/
|
||||
Map<String, String> USER_STATE_CODE = new HashMap<>() {{
|
||||
put("01", "退休");
|
||||
put("02", "离休");
|
||||
put("03", "死亡");
|
||||
put("04", "返聘");
|
||||
put("05", "调出");
|
||||
put("06", "辞职");
|
||||
put("07", "离职");
|
||||
put("08", "开除");
|
||||
put("09", "下落不明");
|
||||
put("11", "在职");
|
||||
put("12", "延聘");
|
||||
put("13", "待退休");
|
||||
put("14", "长病假");
|
||||
put("15", "因公出国");
|
||||
put("16", "停薪留职");
|
||||
put("17", "待岗");
|
||||
put("99", "其他");
|
||||
}};
|
||||
/**
|
||||
* 校区码
|
||||
*/
|
||||
Map<String, String> CAMPUS_CODE = new HashMap<>() {{
|
||||
put("01", "临安校区");
|
||||
put("02", "黄龙校区");
|
||||
put("03", "滨江校区");
|
||||
put("04", "青山湖科创中心");
|
||||
put("05", "不固定校区");
|
||||
}};
|
||||
|
||||
/**
|
||||
* 接口中的数据跟SourceUser的对应关系
|
||||
* <p>
|
||||
@@ -65,23 +117,31 @@ public interface SourceData {
|
||||
* 例:{'name':['username'],'code':['loginname']}
|
||||
*/
|
||||
Map<String, String[]> USER_FIELD_RELATION = new HashMap() {{
|
||||
put("ZGH", new String[]{"loginname"});
|
||||
put("GH", new String[]{"loginname"});
|
||||
put("XM", new String[]{"username"});
|
||||
put("XB", new String[]{"sex"});
|
||||
put("XBM", new String[]{"sex"});
|
||||
put("MZMC", new String[]{"nation"});
|
||||
put("SJ", new String[]{"mobile"});
|
||||
put("ZZMMM", new String[]{"political"});
|
||||
// put("ZZZTMC", new String[]{"userState"});
|
||||
put("DQZTM", new String[]{"userState"});
|
||||
put("RYFLMC", new String[]{"personType"});
|
||||
put("ZGXWM", new String[]{"education"});
|
||||
put("DWH", new String[]{"unitid"});
|
||||
put("CSRQ", new String[]{"birthday"});
|
||||
put("SZDWDM", new String[]{"unitid"});
|
||||
put("LXRQ", new String[]{"schoolTime"});
|
||||
put("BZLBMC", new String[]{"personType"});
|
||||
put("DQZTMC", new String[]{"userState"});
|
||||
put("XZZW", new String[]{"position"});
|
||||
put("LTRQ", new String[]{"retireDate"});
|
||||
|
||||
put("DZZWMC", new String[]{"position"});
|
||||
put("XQMC", new String[]{"campus"});
|
||||
}};
|
||||
|
||||
/**
|
||||
* 字段插件
|
||||
*/
|
||||
Map<String, Exp4> USER_FIELD_PLUGIN = new HashMap<String, Exp4>() {{
|
||||
// put("ZZZTMC", v -> Strings.sBlank(USER_STATE_CODE.get(v), ""));
|
||||
put("XBM", v -> Strings.sBlank(SEX_CODE.get(v), ""));
|
||||
put("DQZTM", v -> Strings.sBlank(USER_STATE_CODE.get(v), ""));
|
||||
put("ZGXWM", v -> Strings.sBlank(EDUCATION_CODE.get(v), ""));
|
||||
put("XQMC", v -> Strings.sBlank(CAMPUS_CODE.get(v), ""));
|
||||
}};
|
||||
|
||||
/**
|
||||
@@ -91,17 +151,17 @@ public interface SourceData {
|
||||
*/
|
||||
static List<UserSource> users() {
|
||||
List<UserSource> users = new ArrayList<>();
|
||||
String token = getToken();
|
||||
int page = 1;
|
||||
boolean hasRecords = true;
|
||||
int maxPage;
|
||||
while (hasRecords) {
|
||||
String body = HttpUtil.get(USER_URL_TOTAL, new NutMap().addv("access_token", token).addv("page", page).addv("per_page", 1000));
|
||||
String body = HttpUtil.createPost(DATA_URL).body(JSON.toJSONString(new NutMap().addv("address", "jzgjbxx").addv("params", new NutMap())
|
||||
.addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 1000))).execute().body();
|
||||
// String body = HttpUtil.get(DATA_URL, new NutMap().addv("address", "jzgjbxx").addv("params", new NutMap())
|
||||
// .addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 1000));
|
||||
NutMap map = Json.fromJson(NutMap.class, body);
|
||||
checkSuccess(map);
|
||||
NutMap result = map.getAs("result", NutMap.class);
|
||||
maxPage = result.getInt("max_page");
|
||||
List<NutMap> data = result.getAsList("data", NutMap.class);
|
||||
List<NutMap> data = map.getAsList("data", NutMap.class);
|
||||
for (NutMap row : data) {
|
||||
Map entity = new HashMap(1000);
|
||||
|
||||
@@ -118,6 +178,8 @@ public interface SourceData {
|
||||
});
|
||||
users.add(BeanUtil.mapToBean(entity, UserSource.class, true));
|
||||
}
|
||||
int totalCount = map.getInt("totalCount");
|
||||
maxPage = (int) Math.ceil((double) totalCount / page);
|
||||
page++;
|
||||
if (page > maxPage) {
|
||||
hasRecords = false;
|
||||
@@ -130,9 +192,9 @@ public interface SourceData {
|
||||
* 单位对应接口字段
|
||||
*/
|
||||
Map<String, String[]> UNIT_FIELD_RELATION = new HashMap() {{
|
||||
put("DWDM", new String[]{"id", "unitcode"});
|
||||
put("DWH", new String[]{"id", "unitcode"});
|
||||
put("DWMC", new String[]{"name"});
|
||||
put("LSDWH", new String[]{"parentId"});
|
||||
put("SJDWH", new String[]{"parentId"});
|
||||
}};
|
||||
|
||||
/**
|
||||
@@ -147,14 +209,15 @@ public interface SourceData {
|
||||
* @return units
|
||||
*/
|
||||
static List<Sys_unit> units() {
|
||||
String token = getToken();
|
||||
List<Sys_unit> units = new ArrayList<>();
|
||||
int page = 1;
|
||||
String body = HttpUtil.get(UNIT_URL, new NutMap().addv("DWYXBS", "1").addv("page", page).addv("per_page", 100).addv("access_token", token));
|
||||
String body = HttpUtil.createPost(DATA_URL).body(JSON.toJSONString(new NutMap().addv("address", "rsxt_dwjbsj").addv("params", new NutMap())
|
||||
.addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 1000))).execute().body();
|
||||
// String body = HttpUtil.get(DATA_URL, new NutMap().addv("address", "rsxt_dwjbsj").addv("params", new NutMap())
|
||||
// .addv("token", "3318a5a9-c2f2-4c8b-a8ea-e99dd68c165c").addv("pageIndex", page).addv("pageSize", 1000));
|
||||
NutMap map = Json.fromJson(NutMap.class, body);
|
||||
checkSuccess(map);
|
||||
NutMap result = map.getAs("result", NutMap.class);
|
||||
List<NutMap> data = result.getAsList("data", NutMap.class);
|
||||
List<NutMap> data = map.getAsList("data", NutMap.class);
|
||||
|
||||
for (NutMap row : data) {
|
||||
Map entity = new HashMap(5);
|
||||
@@ -174,17 +237,4 @@ public interface SourceData {
|
||||
return units;
|
||||
}
|
||||
|
||||
|
||||
static String getToken() {
|
||||
String body = HttpUtil.get(APP_TOKEN_URL, new NutMap().addv("key", APP_KEY).addv("secret", APP_SECRET));
|
||||
NutMap map = Json.fromJson(NutMap.class, body);
|
||||
if (map.getInt("code") == 10000) {
|
||||
NutMap result = map.getAs("result", NutMap.class);
|
||||
String accessToken = result.getString("access_token");
|
||||
return accessToken;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public enum UserChangeType {
|
||||
UNIT_CHANGE(1, "单位异动"),
|
||||
NEW(2, "新入职"),
|
||||
RESIGN(3, "离校"),
|
||||
// DIE(4, "去世"),
|
||||
DIE(4, "去世"),
|
||||
RETIREMENT(5, "离退休"),
|
||||
// EXPELLED(6, "开除"),
|
||||
RESTORE(7, "入会"),
|
||||
@@ -28,8 +28,8 @@ public enum UserChangeType {
|
||||
// NONE(9, "不变"),
|
||||
BASIC_CHANGE(10, "基本信息异动"),
|
||||
WORK(11, "在职"),
|
||||
NOT_WELFARE_LIST(12, "不在本次发放福利内"),
|
||||
NEW_WELFARE_LIST(13, "添加会员到本次名单");
|
||||
CARD_CHANGE(12, "身份证号异动"),
|
||||
MOBILE_CHANGE(13, "手机号码异动");
|
||||
|
||||
|
||||
private int code;
|
||||
|
||||
Reference in New Issue
Block a user