commit
This commit is contained in:
@@ -48,7 +48,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
|||||||
@Column
|
@Column
|
||||||
@Comment("性别")
|
@Comment("性别")
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||||
@DataCenterColumn(name = "姓别", key = "sex", dict = "USER_SEX")
|
@DataCenterColumn(name = "姓别", key = "sex")
|
||||||
private String sex;
|
private String sex;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
@@ -178,7 +178,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
|||||||
|
|
||||||
@Column
|
@Column
|
||||||
@Comment("来校时间")
|
@Comment("来校时间")
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||||
@DataCenterColumn(name = "来校时间", key = "cjgzsj")
|
@DataCenterColumn(name = "来校时间", key = "cjgzsj")
|
||||||
private String arrivalAtSchoolDate;
|
private String arrivalAtSchoolDate;
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
|||||||
|
|
||||||
@Column
|
@Column
|
||||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||||
@DataCenterColumn(name = "单位", key = "DWH")
|
@DataCenterColumn(name = "单位", key = "dept_id")
|
||||||
private String unitId;
|
private String unitId;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
|
|||||||
+15
-17
@@ -195,23 +195,13 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
|||||||
String salt = R.UU32();
|
String salt = R.UU32();
|
||||||
u.setSalt(salt);
|
u.setSalt(salt);
|
||||||
u.setPassword(PwdUtil.getPassword(PwdUtil.generate(12), salt));
|
u.setPassword(PwdUtil.getPassword(PwdUtil.generate(12), salt));
|
||||||
|
u.setMember(false);
|
||||||
/* if (u.getMember()) {
|
|
||||||
addMemberUserIds.add(u.getId());
|
|
||||||
}*/
|
|
||||||
needInitUserList.add(u);
|
needInitUserList.add(u);
|
||||||
} else {
|
} else {
|
||||||
// 修改现有用户
|
// 修改现有用户 - 根据工号判断是原有的人
|
||||||
u.setId(user.getId());
|
u.setId(user.getId());
|
||||||
|
// 保持原有会员身份不变
|
||||||
// 更新会员状态
|
u.setMember(user.getMember());
|
||||||
boolean currentIsMember = user.getMember() != null && user.getMember();
|
|
||||||
|
|
||||||
if (!currentIsMember) {
|
|
||||||
// addMemberUserIds.add(user.getId());
|
|
||||||
} else{
|
|
||||||
// removeMemberUserIds.add(user.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
needDoUpdateList.add(u);
|
needDoUpdateList.add(u);
|
||||||
}
|
}
|
||||||
@@ -469,9 +459,17 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
|||||||
|
|
||||||
// 生成变更信息描述
|
// 生成变更信息描述
|
||||||
String changeInfos = changeList.stream()
|
String changeInfos = changeList.stream()
|
||||||
.map(v -> v.getString("fieldName") + ":" +
|
.map(v -> {
|
||||||
HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + "→" +
|
String fieldName = v.getString("fieldName");
|
||||||
HtmlUtil.cleanHtmlTag(v.getString("newValue")))
|
String sourceValue = v.getString("sourceValue");
|
||||||
|
String newValue = v.getString("newValue");
|
||||||
|
|
||||||
|
// 空值处理,防止 NullPointerException
|
||||||
|
String cleanSourceValue = sourceValue == null ? "" : HtmlUtil.cleanHtmlTag(sourceValue);
|
||||||
|
String cleanNewValue = newValue == null ? "" : HtmlUtil.cleanHtmlTag(newValue);
|
||||||
|
|
||||||
|
return fieldName + ":" + cleanSourceValue + "→" + cleanNewValue;
|
||||||
|
})
|
||||||
.collect(Collectors.joining(";"));
|
.collect(Collectors.joining(";"));
|
||||||
|
|
||||||
// 设置历史记录信息
|
// 设置历史记录信息
|
||||||
|
|||||||
@@ -19,10 +19,7 @@ import com.budwk.app.base.exception.BaseException;
|
|||||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||||
import com.budwk.app.sys.annotation.DataCenterColumn;
|
import com.budwk.app.sys.annotation.DataCenterColumn;
|
||||||
import com.budwk.app.sys.enums.Api2FinanceFiledMap;
|
import com.budwk.app.sys.enums.Api2FinanceFiledMap;
|
||||||
import com.budwk.app.sys.models.Sys_data_dict;
|
import com.budwk.app.sys.models.*;
|
||||||
import com.budwk.app.sys.models.Sys_dict;
|
|
||||||
import com.budwk.app.sys.models.Sys_user;
|
|
||||||
import com.budwk.app.sys.models.Sys_user_source;
|
|
||||||
import com.budwk.app.sys.services.SysDataUnitPullService;
|
import com.budwk.app.sys.services.SysDataUnitPullService;
|
||||||
import com.budwk.app.sys.services.SysDataUserPullService;
|
import com.budwk.app.sys.services.SysDataUserPullService;
|
||||||
import com.budwk.app.sys.services.SysDictService;
|
import com.budwk.app.sys.services.SysDictService;
|
||||||
@@ -139,7 +136,6 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
|
|
||||||
Date nowDate = new Date();
|
Date nowDate = new Date();
|
||||||
|
|
||||||
// 赋值
|
|
||||||
List<Sys_user_source> latestSourceList = rawDataList.stream().map(raw -> {
|
List<Sys_user_source> latestSourceList = rawDataList.stream().map(raw -> {
|
||||||
Sys_user_source sysUser = new Sys_user_source();
|
Sys_user_source sysUser = new Sys_user_source();
|
||||||
|
|
||||||
@@ -148,31 +144,60 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
try {
|
try {
|
||||||
// 根据字段类型设置值
|
// 根据字段类型设置值
|
||||||
if (mapping.field.getType() == String.class) {
|
if (mapping.field.getType() == String.class) {
|
||||||
|
String value = raw.getStr(mapping.key);
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(mapping.dict)) {
|
if (StrUtil.isNotBlank(mapping.dict)) {
|
||||||
Sys_data_dict sysDataDict = dataDictMap.get(mapping.dict).stream()
|
List<Sys_data_dict> dictList = dataDictMap.get(mapping.dict);
|
||||||
.filter(v -> raw.getStr(mapping.key)
|
if (dictList != null && !dictList.isEmpty()) {
|
||||||
.equals(v.getCode())).findFirst().orElse(new Sys_data_dict());
|
String finalValue = value;
|
||||||
mapping.field.set(sysUser, sysDataDict.getName());
|
Sys_data_dict sysDataDict = dictList.stream()
|
||||||
|
.filter(v -> finalValue != null && finalValue.equals(v.getCode())).findFirst().orElse(new Sys_data_dict());
|
||||||
|
mapping.field.set(sysUser, sysDataDict.getName());
|
||||||
|
} else {
|
||||||
|
// 如果找不到对应的字典,直接使用原始值
|
||||||
|
mapping.field.set(sysUser, value);
|
||||||
|
log.warn("未找到字典编码:{},使用原始值:{}", mapping.dict, value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 特殊处理 根据身份证号获取性别和出生年月
|
// 特殊处理 根据身份证号获取性别和出生年月
|
||||||
if ("sfzh".equals(mapping.field.getName())) {
|
switch (mapping.field.getName()) {
|
||||||
String idCard = raw.getStr(mapping.key);
|
case "idCard" -> {
|
||||||
// 设置出生年月
|
// 设置出生年月
|
||||||
try {
|
if (StrUtil.isNotBlank(value)) {
|
||||||
sysUser.setBirthday(IdcardUtil.getBirthDate(idCard));
|
try {
|
||||||
} catch (Exception e) {
|
sysUser.setBirthday(IdcardUtil.getBirthDate(value));
|
||||||
sysUser.setBirthday(null);
|
} catch (Exception e) {
|
||||||
|
sysUser.setBirthday(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
case "sex" -> {
|
||||||
mapping.field.set(sysUser, raw.getStr(mapping.key));
|
// 特殊处理性别字段:接口返回 0=男,1=女
|
||||||
|
if ("0".equals(value)) {
|
||||||
|
mapping.field.set(sysUser, "男");
|
||||||
|
} else if ("1".equals(value)) {
|
||||||
|
mapping.field.set(sysUser, "女");
|
||||||
|
} else {
|
||||||
|
mapping.field.set(sysUser, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "arrivalAtSchoolDate" -> {
|
||||||
|
// 来校时间字段特殊处理:截断时间部分,只保留日期(yyyy-MM-dd)
|
||||||
|
if (StrUtil.isNotBlank(value)) {
|
||||||
|
if (value.length() > 10) {
|
||||||
|
value = value.substring(0, 10);
|
||||||
|
}
|
||||||
|
mapping.field.set(sysUser, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default -> mapping.field.set(sysUser, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mapping.field.getType() == Date.class) {
|
} else if (mapping.field.getType() == Date.class) {
|
||||||
mapping.field.set(sysUser, raw.getDate(mapping.key));
|
mapping.field.set(sysUser, raw.getDate(mapping.key));
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
log.error("设置字段值失败: {}", mapping.field.getName(), e);
|
log.error("设置字段值失败:{}", mapping.field.getName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,15 +212,40 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
|||||||
dao().insert(latestSourceList);
|
dao().insert(latestSourceList);
|
||||||
|
|
||||||
// 人员的单位数据和数据库的单位数据比较,如果人员里面有单位不存在,去更新单位数据
|
// 人员的单位数据和数据库的单位数据比较,如果人员里面有单位不存在,去更新单位数据
|
||||||
List<String> sourceUnitIds = latestSourceList.stream().map(Sys_user_source::getUnitId).distinct().toList();
|
List<String> sourceUnitIds = latestSourceList.stream()
|
||||||
|
.map(Sys_user_source::getUnitId)
|
||||||
|
.filter(Objects::nonNull) // 过滤掉 null 值
|
||||||
|
.filter(StrUtil::isNotBlank) // 过滤掉空字符串
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
Sql sql = Sqls.create("select id from sys_unit group by id");
|
Sql sql = Sqls.create("select id from sys_unit group by id");
|
||||||
sql.setCallback(Sqls.callback.strList());
|
sql.setCallback(Sqls.callback.strList());
|
||||||
dao().execute(sql);
|
dao().execute(sql);
|
||||||
List<String> unitIds = sql.getList(String.class);
|
List<String> unitIds = sql.getList(String.class);
|
||||||
|
|
||||||
if (!new HashSet<>(unitIds).containsAll(sourceUnitIds)) {
|
// 找出系统中不存在的单位 ID
|
||||||
log.info("单位需要更新,正在同步更新");
|
List<String> newUnitIds = sourceUnitIds.stream()
|
||||||
sysDataUnitPullService.updateUnits(unitIds);
|
.filter(id -> !unitIds.contains(id))
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!newUnitIds.isEmpty()) {
|
||||||
|
log.info("发现 {} 个新单位,正在自动创建:{}", newUnitIds.size(), newUnitIds);
|
||||||
|
|
||||||
|
// 直接插入新单位,id 为单位号,name 为 "未知单位"
|
||||||
|
List<Sys_unit> newUnits = newUnitIds.stream().map(unitId -> {
|
||||||
|
Sys_unit unit = new Sys_unit();
|
||||||
|
unit.setId(unitId);
|
||||||
|
unit.setUnitcode(unitId);
|
||||||
|
unit.setName("未知单位-" + unitId);
|
||||||
|
unit.setUnitTypeCode(1); // 默认设置为部门类
|
||||||
|
unit.setParentId("root");
|
||||||
|
unit.setUnitLevel(2);
|
||||||
|
return unit;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
dao().insert(newUnits);
|
||||||
|
log.info("成功创建 {} 个新单位", newUnits.size());
|
||||||
}
|
}
|
||||||
return nowDate;
|
return nowDate;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ layout("/layouts/platform.html"){
|
|||||||
<el-card shadow="never">
|
<el-card shadow="never">
|
||||||
<table-tool label="系统当前用户数据">
|
<table-tool label="系统当前用户数据">
|
||||||
<!--<el-button type="primary" size="mini" @click="updateDataDict" icon="el-icon-refresh">更新【码表】数据</el-button>-->
|
<!--<el-button type="primary" size="mini" @click="updateDataDict" icon="el-icon-refresh">更新【码表】数据</el-button>-->
|
||||||
<el-button type="primary" size="mini" @click="updateUnits" icon="el-icon-refresh">更新【单位】数据</el-button>
|
<!-- <el-button type="primary" size="mini" @click="updateUnits" icon="el-icon-refresh">更新【单位】数据</el-button>-->
|
||||||
<el-button type="primary" size="mini" @click="openUpdate" icon="el-icon-refresh">更新【人员】数据</el-button>
|
<el-button type="primary" size="mini" @click="openUpdate" icon="el-icon-refresh">更新【人员】数据</el-button>
|
||||||
</table-tool>
|
</table-tool>
|
||||||
<el-table :key="tableKey" :data="tableData" @sort-change="pageOrder" header-align="center">
|
<el-table :key="tableKey" :data="tableData" @sort-change="pageOrder" header-align="center">
|
||||||
|
|||||||
Reference in New Issue
Block a user