This commit is contained in:
2026-05-26 14:49:44 +08:00
parent 2dc7ea8a3d
commit 944d8e4621
10 changed files with 225 additions and 122 deletions
+10 -3
View File
@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.budwk</groupId>
<artifactId>v4</artifactId>
<artifactId>zhgh_zjipc</artifactId>
<version>5.6.0-plus</version>
<build>
<resources>
@@ -130,6 +130,13 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.wisedu.casp</groupId>
<artifactId>casp-sdk</artifactId>
<version>latest</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/casp-sdk-java_20260114.jar</systemPath>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
@@ -159,11 +166,11 @@
<slf4j.version>2.0.8</slf4j.version>
<poitl.version>1.12.2</poitl.version>
<poi.version>4.1.2</poi.version>
<commons-lang3.version>3.8.1</commons-lang3.version>
<commons-lang3.version>3.18.0</commons-lang3.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pinyin4j.veision>2.5.1</pinyin4j.veision>
<nutzboot.version>2.6.0-SNAPSHOT</nutzboot.version>
<logback.version>1.5.8</logback.version>
<logback.version>1.5.13</logback.version>
<nutz.version>1.r.70-SNAPSHOT</nutz.version>
<tencentcloud-sdk-java.version>4.0.11</tencentcloud-sdk-java.version>
</properties>
@@ -5,6 +5,7 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.aspose.slides.internal.og.all;
import com.budwk.app.base.constant.RedisConstant;
import com.budwk.app.base.exception.BaseException;
import lombok.AllArgsConstructor;
@@ -36,17 +37,19 @@ public class DataCenterProperties {
@Inject
private RedisService redisService;
private String appId;
private String tokenUrl;
private Map<String, String> codes = new HashMap<>();
private String compId;
private String key;
private String secret;
private String dataUrl;
private Map<String, String> urls = new HashMap<>();
public void init() {
Map<String, String> all = conf.toMap();
appId = all.get("data-center.app-id");
tokenUrl = all.get("data-center.token-url");
extract(all, "data-center.codes.", codes);
extract(all, "data-center.urls.", urls);
compId = all.get("data-center.compId");
key = all.get("data-center.key");
secret = all.get("data-center.secret");
dataUrl = all.get("data-center.dataUrl");
extract(all, "data-center.", urls);
}
/**
@@ -68,12 +71,8 @@ public class DataCenterProperties {
* @return 相关配置
*/
public Credential credential(String key) {
String code = codes.get(key);
String url = urls.get(key);
if (code == null || url == null) {
throw new BaseException("未知业务: " + key);
}
String token = getToken(Integer.parseInt(code), key);
String token = getToken(key);
return new Credential(url, token);
}
@@ -87,30 +86,23 @@ public class DataCenterProperties {
/**
* 获取token
* @param code
* @param keyPrefix
* @return token
*/
private String getToken(Integer code, String keyPrefix) {
private String getToken(String keyPrefix) {
String dateCenterPrefix = RedisConstant.DATE_CENTER_PREFIX + keyPrefix;
String token = redisService.get(dateCenterPrefix);
if (StrUtil.isNotBlank(token)) {
return token;
} else {
HttpRequest httpRequest = HttpUtil.createPost(tokenUrl);
Map<String, Object> reqBody = Map.of(
"appId", appId,
"code", code
);
httpRequest.body(JSONUtil.toJsonStr(reqBody));
HttpRequest httpRequest = HttpUtil.createPost(dataUrl + "/token?compId=" + compId + "&appId=" + key + "&appSecret=" + secret);
JSONObject resp = JSONUtil.parseObj(httpRequest.execute().body());
if (resp.getInt("code") != 200) {
throw new BaseException("获取token失败: " + resp.getStr("msg"));
if (!resp.getBool("success")) {
throw new BaseException("获取token失败: " + resp.getStr("message"));
} else {
JSONObject data = resp.getJSONObject("data");
String tokenStr = data.getStr("token");
Integer expire = data.getInt("expire");
JSONObject data = resp.getJSONObject("result");
String tokenStr = data.getStr("access_token");
Integer expire = data.getInt("expires_in");
redisService.setex(dateCenterPrefix, expire, tokenStr);
return tokenStr;
}
@@ -12,9 +12,9 @@ import lombok.Getter;
@Getter
public enum Api2UnitFiledMap {
ZZJGDM("dwdm", "id"),
ZZJGDM("dwh", "id"),
ZZJGMC("dwmc", "name"),
BMLB("bmflmc", "unitType");
LSDWH("lsdwm", "parentId");
public final String apiField;
public final String dbColumn;
@@ -36,19 +36,19 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("工号")
@ColDefine(type = ColType.VARCHAR, width = 120)
@DataCenterColumn(name = "工号", key = "ZGH")
@DataCenterColumn(name = "工号", key = "gh")
private String loginname;
@Column
@Comment("姓名")
@ColDefine(type = ColType.VARCHAR, width = 100)
@DataCenterColumn(name = "姓名", key = "XM")
@DataCenterColumn(name = "姓名", key = "xm")
private String username;
@Column
@Comment("性别")
@ColDefine(type = ColType.VARCHAR, width = 10)
@DataCenterColumn(name = "性别", key = "XB")
@DataCenterColumn(name = "性别", key = "xbmc")
private String sex;
@Column
@@ -64,13 +64,13 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("出生日期")
@ColDefine(type = ColType.DATE)
@DataCenterColumn(name = "出生日期", key = "CSRQ")
@DataCenterColumn(name = "出生日期", key = "csrq")
private Date birthday;
@Column
@Comment("政治面貌")
@ColDefine(type = ColType.VARCHAR, width = 100)
@DataCenterColumn(name = "政治面貌", key = "ZZMM")
@DataCenterColumn(name = "政治面貌", key = "zzmmmc")
private String political;
@Column
@@ -81,12 +81,13 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("民族")
@ColDefine(type = ColType.VARCHAR, width = 20)
@DataCenterColumn(name = "民族", key = "MZ")
@DataCenterColumn(name = "民族", key = "mzmc")
private String nation;
@Column
@Comment("籍贯")
@ColDefine(type = ColType.VARCHAR, width = 100)
@DataCenterColumn(name = "籍贯", key = "jgmc")
private String nativePlace;
@Column
@@ -103,7 +104,7 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("证件号码")
@ColDefine(type = ColType.VARCHAR, width = 30)
@DataCenterColumn(name = "证件号码", key = "SFZJH")
@DataCenterColumn(name = "证件号码", key = "sfzjh")
private String idCard;
@Column
@@ -121,6 +122,7 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("婚姻状况")
@ColDefine(type = ColType.VARCHAR, width = 20)
@DataCenterColumn(name = "婚姻状况", key = "hyzkmc")
private String marriage;
@Column
@@ -174,7 +176,7 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("来校时间")
@ColDefine(type = ColType.VARCHAR, width = 10)
@DataCenterColumn(name = "来校时间", key = "RXRQ")
@DataCenterColumn(name = "来校时间", key = "lxrq")
private String arrivalAtSchoolDate;
@Column
@@ -185,18 +187,19 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@Comment("在职状态")
@ColDefine(type = ColType.VARCHAR, width = 30)
@DataCenterColumn(name = "在岗状态", key = "DQZT")
@DataCenterColumn(name = "在岗状态", key = "dqztmc")
private String userState;
@Column
@Comment("教职工类别码")
@ColDefine(type = ColType.VARCHAR, width = 30)
@DataCenterColumn(name = "教职工类别码", key = "JZGRYLB")
@DataCenterColumn(name = "教职工类别码", key = "bzlbmc")
private String personType;
@Column
@Comment("编制类别码")
@ColDefine(type = ColType.VARCHAR, width = 30)
@DataCenterColumn(name = "编制类型", key = "BZLB")
private String preparedBy;
@Column
@@ -247,7 +250,7 @@ public class Sys_user extends BaseModel implements Serializable {
@Column
@ColDefine(type = ColType.VARCHAR, width = 32)
@DataCenterColumn(name = "单位代码", key = "DWDM")
@DataCenterColumn(name = "单位代码", key = "dwh")
private String unitId;
@Column
@@ -333,6 +336,9 @@ public class Sys_user extends BaseModel implements Serializable {
@One(field = "unitId")
private Sys_unit unit;
@DataCenterColumn(name = "单位名称", key = "dwmc")
private String unitName;
//分工会
private Sys_union union;
@@ -15,6 +15,11 @@ public interface SysDataUserPullService extends BaseService<Sys_user_source> {
*/
Date pull();
/**
* 拉取人员博士后的信息
*/
Map<String, Date> pullPostDoctoral();
/**
* 获取下拉框数据(单位、在职状态、编制类别、教职工类别)
*/
@@ -26,4 +31,11 @@ public interface SysDataUserPullService extends BaseService<Sys_user_source> {
* @return
*/
List<NutMap> pullTimeOptions();
/**
* 获取财务数据
* @return
*/
Map<String, NutMap> pullFinance();
}
@@ -12,7 +12,9 @@ import com.budwk.app.sys.enums.Api2UnitFiledMap;
import com.budwk.app.sys.models.Sys_unit;
import com.budwk.app.sys.services.SysDataUnitPullService;
import com.budwk.app.sys.utils.DataCenterUtil;
import com.budwk.app.web.commons.base.Globals;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nutz.aop.interceptor.ioc.TransAop;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
@@ -64,23 +66,70 @@ public class SysDataUnitPullServiceImpl extends BaseServiceImpl<Sys_unit> implem
@Override
@Aop(TransAop.READ_COMMITTED)
public void updateUnits(List<String> unitIds) {
// 中间表数据
List<Record> unitMiddleList = dao().query("unit_middle", Cnd.NEW());
// 判断有没有父节点
/*Sys_unit parentUnit = dao().fetch(Sys_unit.class, Cnd.where(Sys_unit::getUnitcode, "=", "0000"));
if(parentUnit == null) {
Sys_unit pu = new Sys_unit();
pu.setId("0000");
pu.setName(Globals.AppName.replace("智慧工会", ""));
pu.setUnitcode("0000");
pu.setHasChildren(true);
pu.setUnitLevel(1);
pu.setUnitType("根目录");
pu.setUnitTypeCode(0);
dao().insert(pu);
}*/
// 获取配置
DataCenterProperties.Credential credential = dcPro.credential("dataUrl");
String url = credential.getUrl();
String token = credential.getToken();
log.info("获取配置文件 接口地址 和 token:{},{}", url, token);
// 请求数据
HttpRequest httpRequest = HttpUtil.createPost(url + "/data/getOpenDataList/v2?token=" + token);
log.info("访问组织单位信息");
log.info("访问接口URL:{}", url + "/data/getOpenDataList/v2?token=" + token);
httpRequest.header("Content-Type", "application/json");
httpRequest.body(JSONUtil.toJsonStr(Map.of("tag", "844", "current", "1", "size", "1000")));
String resBody = httpRequest.execute().body();
log.info("接口返回接口:{}", resBody);
JSONObject jsonBody = JSONUtil.parseObj(resBody);
if (!jsonBody.getBool("success")) {
throw new BaseException("获取单位数据失败,错误码: " + jsonBody.getInt("code") + ";错误原因:" + jsonBody.getStr("description"));
}
// 需要新增的单位
List<Sys_unit> insertList = new ArrayList<>();
// 需要更新的单位
List<Sys_unit> updateList = new ArrayList<>();
JSONObject result = jsonBody.getJSONObject("result");
List<JSONObject> data = result.getJSONArray("records").stream()
.map(o -> (JSONObject) o)
.toList();
Map<String, String> api2db = Arrays.stream(Api2UnitFiledMap.values())
.collect(Collectors.toMap(e -> e.apiField, e -> e.dbColumn));
for (Record row : unitMiddleList) {
JSONObject jsonRow = JSONUtil.parseObj(JSONUtil.toJsonStr(row));
Sys_unit unit = DataCenterUtil.mapJsonToBean(jsonRow, Sys_unit.class, api2db);
for (JSONObject row : data) {
JSONObject jsonRow = JSONUtil.parseObj(JSONUtil.toJsonStr(row));
Sys_unit unit = DataCenterUtil.mapJsonToBean(jsonRow, Sys_unit.class, api2db);
if(StringUtils.isBlank(unit.getParentId())) {
unit.setParentId("00");
unit.setUnitLevel(2);
unit.setUnitType("子部门");
unit.setUnitTypeCode(0);
} else {
unit.setUnitLevel(3);
unit.setUnitType("子部门");
unit.setUnitTypeCode(1);
}
unit.setUnitcode(unit.getId());
unit.setUnitTypeCode(1);
unit.setParentId("0000");
unit.setUnitLevel(2);
if (unitIds.contains(unit.getId())) {
// 存在则更新
@@ -108,64 +108,96 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
@Override
@Aop(TransAop.READ_COMMITTED)
public Date pull() {
try {
// 中间表数据
List<NutMap> userMiddleList = sysDataUnitPullService.listMap(Sqls.create("select * from user_middle"));
// 获取配置文件 接口地址 和 token
DataCenterProperties.Credential credential = dataCenterProperties.credential("dataUrl");
String url = credential.getUrl();
String token = credential.getToken();
log.info("获取配置文件 接口地址 和 token:{},{}", url, token);
List<JSONObject> rawDataList = new ArrayList<>();
if (!userMiddleList.isEmpty()) {
List<JSONObject> rawDataList = new ArrayList<>();
Integer page = 1;
int maxPage;
do {
// 请求数据
HttpRequest httpRequest = HttpUtil.createPost(url + "/data/getOpenDataList/v2?token=" + token);
log.info("访问教职工信息");
log.info("访问接口URL:{}", url + "/data/getOpenDataList/v2");
httpRequest.header("Content-Type", "application/json");
httpRequest.body(JSONUtil.toJsonStr(Map.of("tag", "843", "current", page.toString(), "size", "1000")));
String resBody = httpRequest.execute().body();
log.info("接口返回接口:{}", resBody);
JSONObject jsonBody = JSONUtil.parseObj(resBody);
if (!jsonBody.getBool("success")) {
throw new BaseException("获取人员数据失败,错误码: " + jsonBody.getInt("code") + ";错误原因:" + jsonBody.getStr("message"));
}
JSONObject result = jsonBody.getJSONObject("result");
maxPage = result.getInt("pages");
int total = result.getInt("total");
JSONArray data = result.getJSONArray("records");
if (!data.isEmpty()) {
// 先收集所有原始数据
rawDataList = userMiddleList.stream().map(v -> JSONUtil.parseObj(JSONUtil.toJsonStr(v))).toList();
log.info("数据拉取进度: {}/{}", rawDataList.size(), userMiddleList.size());
rawDataList.addAll(data.stream().map(v -> JSONUtil.parseObj(JSONUtil.toJsonStr(v))).toList());
log.info("数据拉取进度: 总数据量:{},已经拉取{},本次拉取:{}", total, rawDataList.size(), data.size());
} else {
log.warn("当前未获取到数据");
}
Date nowDate = new Date();
page++;
} while (page <= maxPage);
// 赋值
List<Sys_user_source> latestSourceList = rawDataList.stream().map(raw -> {
Sys_user_source sysUser = new Sys_user_source();
Date nowDate = new Date();
// 使用缓存的字段映射
for (FieldMapping mapping : getFieldMappings()) {
try {
// 根据字段类型设置值
if (mapping.field.getType() == String.class) {
mapping.field.set(sysUser, raw.getStr(mapping.key));
} else if (mapping.field.getType() == Date.class) {
mapping.field.set(sysUser, raw.getDate(mapping.key));
// 赋值
List<Sys_user_source> latestSourceList = rawDataList.stream().map(raw -> {
Sys_user_source sysUser = new Sys_user_source();
// 使用缓存的字段映射
for (FieldMapping mapping : getFieldMappings()) {
try {
// 根据字段类型设置值
if (mapping.field.getType() == String.class) {
mapping.field.set(sysUser, raw.getStr(mapping.key));
if ("XBMC".equals(mapping.key) && StrUtil.isNotBlank(raw.getStr(mapping.key))) {
mapping.field.set(sysUser, raw.getStr(mapping.key).replace("性", ""));
}
} catch (IllegalAccessException e) {
log.error("设置字段值失败: {}", mapping.field.getName(), e);
} else if (mapping.field.getType() == Date.class) {
mapping.field.set(sysUser, raw.getDate(mapping.key));
}
} catch (IllegalAccessException e) {
log.error("设置字段值失败: {}", mapping.field.getName(), e);
}
sysUser.setPullTime(nowDate);
return sysUser;
}).toList();
log.info("用户数据初始化完成,等待插入,当前数据条数{}", latestSourceList.size());
// 插入到数据库
dao().insert(latestSourceList);
// 更新字典数据
this.updateDict(latestSourceList);
// 人员的单位数据和数据库的单位数据比较,如果人员里面有单位不存在,去更新单位数据
List<String> sourceUnitIds = latestSourceList.stream().map(Sys_user_source::getUnitId).distinct().toList();
Sql sql = Sqls.create("select id from sys_unit group by id");
sql.setCallback(Sqls.callback.strList());
dao().execute(sql);
List<String> unitIds = sql.getList(String.class);
if (!new HashSet<>(unitIds).containsAll(sourceUnitIds)) {
log.info("单位需要更新,正在同步更新");
sysDataUnitPullService.updateUnits(unitIds);
}
return nowDate;
} catch (Exception e) {
throw new BaseException("数据拉取失败,{}", e.getMessage());
sysUser.setPullTime(nowDate);
return sysUser;
}).toList();
log.info("用户数据初始化完成,等待插入,当前数据条数{}", latestSourceList.size());
// 插入到数据库
dao().insert(latestSourceList);
// 更新字典数据
this.updateDict(latestSourceList);
// 人员的单位数据和数据库的单位数据比较,如果人员里面有单位不存在,去更新单位数据
List<String> sourceUnitIds = latestSourceList.stream().map(Sys_user_source::getUnitId).distinct().toList();
Sql sql = Sqls.create("select id from sys_unit group by id");
sql.setCallback(Sqls.callback.strList());
dao().execute(sql);
List<String> unitIds = sql.getList(String.class);
if (!new HashSet<>(unitIds).containsAll(sourceUnitIds)) {
log.info("单位需要更新,正在同步更新");
sysDataUnitPullService.updateUnits(unitIds);
}
return nowDate;
}
@Override
public Map<String, Date> pullPostDoctoral() {
return null;
}
@Async
@@ -209,12 +241,12 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
return dict;
}).toList();
List<Sys_dict> insertPersonTypes = sourcePersonTypes.stream().filter(personType -> sysPersonTypes.stream().noneMatch(dict -> dict.getCode().equals(personType))).map(personType -> {
Sys_dict dict = new Sys_dict();
dict.setCode(personType);
dict.setName(personType);
return dict;
}).toList();
List<Sys_dict> insertPersonTypes = sourcePersonTypes.stream().filter(personType -> sysPersonTypes.stream().noneMatch(dict -> dict.getCode().equals(personType))).map(personType -> {
Sys_dict dict = new Sys_dict();
dict.setCode(personType);
dict.setName(personType);
return dict;
}).toList();
for (Sys_dict dict : insertUserStates) {
sysDictService.saveByParentCode(dict, "USER_STATE");
@@ -225,9 +257,9 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
for (Sys_dict dict : insertAcademicDegrees) {
sysDictService.saveByParentCode(dict, "USER_ACADEMIC_DEGREE");
}
for (Sys_dict dict : insertPersonTypes) {
sysDictService.saveByParentCode(dict, "USER_PERSON_TYPE");
}
for (Sys_dict dict : insertPersonTypes) {
sysDictService.saveByParentCode(dict, "USER_PERSON_TYPE");
}
sysDictService.clearCache();
}
@@ -278,4 +310,9 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
""");
return listMap(sql);
}
@Override
public Map<String, NutMap> pullFinance() {
return null;
}
}
@@ -9,22 +9,22 @@ package com.budwk.app.todo.platform;
*/
public class TodoPlatformConfig {
// token 获取
public static final String TOKEN_URL = "https://gateway.jshvc.edu.cn/token/gateway/accessToken";
// 待办平台基础地址
public static final String TODO_PLATFORM_BASE_URL = "https://gateway.jshvc.edu.cn";
// 待办平台新增或者修改
public static final String TODO_PLATFORM_SAVE_OR_UPDATE_URL = "https://gateway.jshvc.edu.cn/casp-tdc/task/saveOrUpdate";
// 待办平台修改地址
public static final String TODO_PLATFORM_MODIFY_URL = "https://gateway.jshvc.edu.cn/casp-tdc/task/modifyInfo";
// 待办平台删除任务地址
public static final String TODO_PLATFORM_DELETE_TASK_URL = "https://gateway.jshvc.edu.cn/casp-tdc/task/delete";
// 待办平台删除实例地址
public static final String TODO_PLATFORM_DELETE_INSTANCE_URL = "https://gateway.jshvc.edu.cn/casp-tdc/processInstance/realDelete";
// token 获取
public static final String TOKEN_URL = "";
// 待办平台基础地址
public static final String TODO_PLATFORM_BASE_URL = "";
// 待办平台新增或者修改
public static final String TODO_PLATFORM_SAVE_OR_UPDATE_URL = "";
// 待办平台修改地址
public static final String TODO_PLATFORM_MODIFY_URL = "";
// 待办平台删除任务地址
public static final String TODO_PLATFORM_DELETE_TASK_URL = "";
// 待办平台删除实例地址
public static final String TODO_PLATFORM_DELETE_INSTANCE_URL = "";
public static final String TODO_APP_ID = "1430576717768122368";
public static final String TODO_APP_SECRET = "19A0ACB03FBQHL4R4XQD";
public static final String REDIS_KEY_TODO_ACCESS_TOKEN = "todo:token:";
public static final Long TODO_REQUEST_TIMEOUT = 5000L;
public static final String TODO_APP_ID = "";
public static final String TODO_APP_SECRET = "";
public static final String REDIS_KEY_TODO_ACCESS_TOKEN = "";
public static final Long TODO_REQUEST_TIMEOUT = 5000L;
}
@@ -86,7 +86,7 @@ layout("/layouts/v4/baseLayout.html"){
</div>
</div>
<jcdt :list="websiteNews.grassroots"></jcdt>
<!-- <jcdt :list="websiteNews.grassroots"></jcdt>-->
</div>
</div>
+1 -1
View File
@@ -78,7 +78,7 @@ public class JugTest {
@Test
public void sendMsg() {
smsService.send("20182040", "这是一条由智慧工会系统发出的测试消息。");
// smsService.send("20182040", "这是一条由智慧工会系统发出的测试消息。");
}
@Test