commit
This commit is contained in:
@@ -48,7 +48,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
@Column
|
||||
@Comment("性别")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
@DataCenterColumn(name = "姓别", key = "sex", dict = "USER_SEX")
|
||||
@DataCenterColumn(name = "姓别", key = "sex")
|
||||
private String sex;
|
||||
|
||||
@Column
|
||||
@@ -178,7 +178,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
|
||||
@Column
|
||||
@Comment("来校时间")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 10)
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
@DataCenterColumn(name = "来校时间", key = "cjgzsj")
|
||||
private String arrivalAtSchoolDate;
|
||||
|
||||
@@ -260,7 +260,7 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
|
||||
@Column
|
||||
@ColDefine(type = ColType.VARCHAR, width = 32)
|
||||
@DataCenterColumn(name = "单位", key = "DWH")
|
||||
@DataCenterColumn(name = "单位", key = "dept_id")
|
||||
private String unitId;
|
||||
|
||||
@Column
|
||||
|
||||
+15
-17
@@ -195,23 +195,13 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
String salt = R.UU32();
|
||||
u.setSalt(salt);
|
||||
u.setPassword(PwdUtil.getPassword(PwdUtil.generate(12), salt));
|
||||
|
||||
/* if (u.getMember()) {
|
||||
addMemberUserIds.add(u.getId());
|
||||
}*/
|
||||
u.setMember(false);
|
||||
needInitUserList.add(u);
|
||||
} else {
|
||||
// 修改现有用户
|
||||
// 修改现有用户 - 根据工号判断是原有的人
|
||||
u.setId(user.getId());
|
||||
|
||||
// 更新会员状态
|
||||
boolean currentIsMember = user.getMember() != null && user.getMember();
|
||||
|
||||
if (!currentIsMember) {
|
||||
// addMemberUserIds.add(user.getId());
|
||||
} else{
|
||||
// removeMemberUserIds.add(user.getId());
|
||||
}
|
||||
// 保持原有会员身份不变
|
||||
u.setMember(user.getMember());
|
||||
|
||||
needDoUpdateList.add(u);
|
||||
}
|
||||
@@ -469,9 +459,17 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
|
||||
// 生成变更信息描述
|
||||
String changeInfos = changeList.stream()
|
||||
.map(v -> v.getString("fieldName") + ":" +
|
||||
HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + "→" +
|
||||
HtmlUtil.cleanHtmlTag(v.getString("newValue")))
|
||||
.map(v -> {
|
||||
String fieldName = v.getString("fieldName");
|
||||
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(";"));
|
||||
|
||||
// 设置历史记录信息
|
||||
|
||||
@@ -19,10 +19,7 @@ import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.annotation.DataCenterColumn;
|
||||
import com.budwk.app.sys.enums.Api2FinanceFiledMap;
|
||||
import com.budwk.app.sys.models.Sys_data_dict;
|
||||
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.models.*;
|
||||
import com.budwk.app.sys.services.SysDataUnitPullService;
|
||||
import com.budwk.app.sys.services.SysDataUserPullService;
|
||||
import com.budwk.app.sys.services.SysDictService;
|
||||
@@ -139,7 +136,6 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
||||
|
||||
Date nowDate = new Date();
|
||||
|
||||
// 赋值
|
||||
List<Sys_user_source> latestSourceList = rawDataList.stream().map(raw -> {
|
||||
Sys_user_source sysUser = new Sys_user_source();
|
||||
|
||||
@@ -148,31 +144,60 @@ public class SysDataUserPullServiceImpl extends BaseServiceImpl<Sys_user_source>
|
||||
try {
|
||||
// 根据字段类型设置值
|
||||
if (mapping.field.getType() == String.class) {
|
||||
String value = raw.getStr(mapping.key);
|
||||
|
||||
if (StrUtil.isNotBlank(mapping.dict)) {
|
||||
Sys_data_dict sysDataDict = dataDictMap.get(mapping.dict).stream()
|
||||
.filter(v -> raw.getStr(mapping.key)
|
||||
.equals(v.getCode())).findFirst().orElse(new Sys_data_dict());
|
||||
mapping.field.set(sysUser, sysDataDict.getName());
|
||||
List<Sys_data_dict> dictList = dataDictMap.get(mapping.dict);
|
||||
if (dictList != null && !dictList.isEmpty()) {
|
||||
String finalValue = value;
|
||||
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 {
|
||||
// 特殊处理 根据身份证号获取性别和出生年月
|
||||
if ("sfzh".equals(mapping.field.getName())) {
|
||||
String idCard = raw.getStr(mapping.key);
|
||||
// 设置出生年月
|
||||
try {
|
||||
sysUser.setBirthday(IdcardUtil.getBirthDate(idCard));
|
||||
} catch (Exception e) {
|
||||
sysUser.setBirthday(null);
|
||||
switch (mapping.field.getName()) {
|
||||
case "idCard" -> {
|
||||
// 设置出生年月
|
||||
if (StrUtil.isNotBlank(value)) {
|
||||
try {
|
||||
sysUser.setBirthday(IdcardUtil.getBirthDate(value));
|
||||
} catch (Exception e) {
|
||||
sysUser.setBirthday(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mapping.field.set(sysUser, raw.getStr(mapping.key));
|
||||
case "sex" -> {
|
||||
// 特殊处理性别字段:接口返回 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) {
|
||||
mapping.field.set(sysUser, raw.getDate(mapping.key));
|
||||
}
|
||||
} 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);
|
||||
|
||||
// 人员的单位数据和数据库的单位数据比较,如果人员里面有单位不存在,去更新单位数据
|
||||
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.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);
|
||||
// 找出系统中不存在的单位 ID
|
||||
List<String> newUnitIds = sourceUnitIds.stream()
|
||||
.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;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -51,7 +51,7 @@ layout("/layouts/platform.html"){
|
||||
<el-card shadow="never">
|
||||
<table-tool label="系统当前用户数据">
|
||||
<!--<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>
|
||||
</table-tool>
|
||||
<el-table :key="tableKey" :data="tableData" @sort-change="pageOrder" header-align="center">
|
||||
|
||||
Reference in New Issue
Block a user