人员
This commit is contained in:
@@ -284,6 +284,8 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
sysRoleService.clearCache();
|
||||
|
||||
} else {
|
||||
List<String> loginNameList = middleTables.stream().map(SourceChangeMiddleTable::getLoginname).toList();
|
||||
dao().clear(SourceChangeMiddleTable.class, Cnd.where("loginname", "in", loginNameList).and("isOperate", "=", false));
|
||||
manyAddOrRenewUtil.asyncExecuteFastInsert(middleTables, 200);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -316,48 +318,39 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
boolean shouldAdd = false;
|
||||
boolean shouldRemove = false;
|
||||
|
||||
// 提前检查 userState 条件(如果存在)
|
||||
boolean userStateConditionMet = true;
|
||||
if ("userState".equals(siftName)) {
|
||||
userStateConditionMet = checkListCondition(siftValue, source, "userState");
|
||||
}
|
||||
|
||||
switch (siftName) {
|
||||
case "userState":
|
||||
if (siftValue instanceof List<?> && source != null && source.getUserState() != null) {
|
||||
List<String> userStateList = (List<String>) siftValue;
|
||||
shouldAdd = userStateList.contains(source.getUserState());
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
// 如果 userState 不满足条件,则直接设置 shouldRemove
|
||||
shouldAdd = userStateConditionMet;
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
break;
|
||||
|
||||
case "personType":
|
||||
if (siftValue instanceof List<?> && source != null && source.getPersonType() != null) {
|
||||
List<String> personTypeList = (List<String>) siftValue;
|
||||
shouldAdd = personTypeList.contains(source.getPersonType());
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
// 检查 personType 条件
|
||||
// 必须同时满足 userState 和 personType 条件
|
||||
shouldAdd = checkListCondition(siftValue, source, "personType");
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
break;
|
||||
|
||||
case "loginNameStart":
|
||||
if (siftValue instanceof String && source != null && source.getLoginname() != null) {
|
||||
String loginNameStart = (String) siftValue;
|
||||
shouldAdd = source.getLoginname().startsWith(loginNameStart);
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
break;
|
||||
case "loginNameEnd":
|
||||
if (siftValue instanceof String && source != null && source.getLoginname() != null) {
|
||||
String loginNameEnd = (String) siftValue;
|
||||
shouldAdd = source.getLoginname().endsWith(loginNameEnd);
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
shouldAdd = checkLoginNameCondition(siftValue, source, siftName);
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
break;
|
||||
|
||||
case "userQuery":
|
||||
if (siftValue instanceof List<?> && user != null) {
|
||||
List<String> userIds = (List<String>) siftValue;
|
||||
shouldAdd = userIds.contains(user.getId()) && user.getMember() != 1;
|
||||
}
|
||||
shouldAdd = checkUserQueryCondition(siftValue, user);
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldAdd) {
|
||||
if (user == null) {
|
||||
addMemberUserIds.add(source.getId());
|
||||
} else if (user.getMember() != 1) {
|
||||
addMemberUserIds.add(user.getId());
|
||||
}
|
||||
addUserToMemberList(user, source, addMemberUserIds);
|
||||
source.setMember(1);
|
||||
} else if (shouldRemove) {
|
||||
deleteMemberUserIds.add(user.getId());
|
||||
@@ -365,13 +358,22 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (config.getWelfareMemberSiftList() == null) {
|
||||
return;
|
||||
}
|
||||
config.getWelfareMemberSiftList().forEach(welfareMember -> {
|
||||
String siftName = welfareMember.getSiftName();
|
||||
Object siftValue = welfareMember.getSiftValue();
|
||||
boolean shouldAdd = false;
|
||||
boolean shouldRemove = false;
|
||||
|
||||
// 提前检查 userState 条件(如果存在)
|
||||
boolean userStateConditionMet = true;
|
||||
if ("userState".equals(siftName) && siftValue instanceof List<?>) {
|
||||
List<String> userStateList = (List<String>) siftValue;
|
||||
userStateConditionMet = source != null && source.getUserState() != null && userStateList.contains(source.getUserState());
|
||||
}
|
||||
|
||||
switch (siftName) {
|
||||
case "member":
|
||||
if ((user != null && addMemberUserIds.contains(user.getId())) || addMemberUserIds.contains(source.getId())) {
|
||||
@@ -380,34 +382,36 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
shouldRemove = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "userState":
|
||||
if (siftValue instanceof List<?> && source != null && source.getUserState() != null) {
|
||||
List<String> userStateList = (List<String>) siftValue;
|
||||
shouldAdd = userStateList.contains(source.getUserState());
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
shouldAdd = userStateConditionMet;
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
break;
|
||||
|
||||
case "personType":
|
||||
if (siftValue instanceof List<?> && source != null && source.getPersonType() != null) {
|
||||
List<String> personTypeList = (List<String>) siftValue;
|
||||
shouldAdd = personTypeList.contains(source.getPersonType());
|
||||
boolean personTypeConditionMet = personTypeList.contains(source.getPersonType());
|
||||
// 必须同时满足 userState 和 personType 条件
|
||||
shouldAdd = userStateConditionMet && personTypeConditionMet;
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "loginNameStart":
|
||||
if (siftValue instanceof String && source != null && source.getLoginname() != null) {
|
||||
String loginNameStart = (String) siftValue;
|
||||
if (siftValue instanceof String loginNameStart && source != null && source.getLoginname() != null) {
|
||||
shouldAdd = source.getLoginname().startsWith(loginNameStart);
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "loginNameEnd":
|
||||
if (siftValue instanceof String && source != null && source.getLoginname() != null) {
|
||||
String loginNameEnd = (String) siftValue;
|
||||
if (siftValue instanceof String loginNameEnd && source != null && source.getLoginname() != null) {
|
||||
shouldAdd = source.getLoginname().endsWith(loginNameEnd);
|
||||
shouldRemove = !shouldAdd && user != null && user.getMember() == 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "userQuery":
|
||||
if (siftValue instanceof List<?> && user != null) {
|
||||
List<String> userIds = (List<String>) siftValue;
|
||||
@@ -415,6 +419,7 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (shouldAdd) {
|
||||
if (user == null) {
|
||||
addWelfareMemberUserIds.add(source.getId());
|
||||
@@ -422,7 +427,7 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
addWelfareMemberUserIds.add(user.getId());
|
||||
}
|
||||
source.setWelfareMember(1);
|
||||
} else if (shouldRemove) {
|
||||
} else if (shouldRemove && user != null) {
|
||||
deleteWelfareMemberUserIds.add(user.getId());
|
||||
source.setWelfareMember(0);
|
||||
}
|
||||
@@ -430,6 +435,41 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
|
||||
}
|
||||
|
||||
// 提取公共方法
|
||||
private boolean checkListCondition(Object siftValue, UserSource source, String siftName) {
|
||||
if (!(siftValue instanceof List) || source == null) {
|
||||
return false;
|
||||
}
|
||||
List<String> list = (List<String>) siftValue;
|
||||
return "userState".equals(siftName) ? list.contains(source.getUserState()) :
|
||||
"personType".equals(siftName) && list.contains(source.getPersonType());
|
||||
}
|
||||
|
||||
private boolean checkLoginNameCondition(Object siftValue, UserSource source, String siftName) {
|
||||
if (!(siftValue instanceof String) || source == null || source.getLoginname() == null) {
|
||||
return false;
|
||||
}
|
||||
String loginName = source.getLoginname();
|
||||
String condition = (String) siftValue;
|
||||
return "loginNameStart".equals(siftName) ? loginName.startsWith(condition) :
|
||||
"loginNameEnd".equals(siftName) && loginName.endsWith(condition);
|
||||
}
|
||||
|
||||
private boolean checkUserQueryCondition(Object siftValue, Sys_user user) {
|
||||
if (!(siftValue instanceof List) || user == null) {
|
||||
return false;
|
||||
}
|
||||
List<String> userIds = (List<String>) siftValue;
|
||||
return userIds.contains(user.getId()) && user.getMember() != 1;
|
||||
}
|
||||
|
||||
private void addUserToMemberList(Sys_user user, UserSource source, List<String> addMemberUserIds) {
|
||||
if (user == null) {
|
||||
addMemberUserIds.add(source.getId());
|
||||
} else if (user.getMember() != 1) {
|
||||
addMemberUserIds.add(user.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于人工操作,不自动更新,不改变数据库数据
|
||||
@@ -469,7 +509,7 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
return null;
|
||||
}
|
||||
String changeInfos = changeList.stream().map(v -> {
|
||||
return "(变更字段:" + v.getString("fieldName") + ",变更前:" + HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + ",变更后:" + HtmlUtil.cleanHtmlTag(v.getString("newValue")) + ")";
|
||||
return v.getString("fieldName") + ":" + HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + "->" + HtmlUtil.cleanHtmlTag(v.getString("newValue")) + ";";
|
||||
}).collect(Collectors.joining(";"));
|
||||
|
||||
// 比较变更数据
|
||||
@@ -515,7 +555,7 @@ public class SourceUserServiceImpl extends ViServiceImpl<UserSource> implements
|
||||
return null;
|
||||
}
|
||||
String changeInfos = changeList.stream().map(v -> {
|
||||
return "(变更字段:" + v.getString("fieldName") + ",变更前:" + HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + ",变更后:" + HtmlUtil.cleanHtmlTag(v.getString("newValue")) + ")";
|
||||
return v.getString("fieldName") + ":" + HtmlUtil.cleanHtmlTag(v.getString("sourceValue")) + "->" + HtmlUtil.cleanHtmlTag(v.getString("newValue")) + ";";
|
||||
}).collect(Collectors.joining(";"));
|
||||
// 比较变更数据
|
||||
commonCompareChange(source, user, changeTypes);
|
||||
|
||||
Reference in New Issue
Block a user