This commit is contained in:
zhouhefeng
2026-04-27 08:42:06 +08:00
parent dcbb1904c2
commit 48892370c0
14 changed files with 1890 additions and 463 deletions
@@ -311,10 +311,7 @@ public class ActivityBasicScopeController {
cnd.orderBy(activityUserScopePageParam.getPageOrderName(), activityUserScopePageParam.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC");
}
if (activityUserScopePageParam.getActivityGroupId() != null) {
Sql sqlx = activityBasicScopeService.buildGroupUserIdSubSql(activityUserScopePageParam.getActivityGroupId());
cnd.and("u.id", activityUserScopePageParam.getReverseSelection() ? "IN" : "NOT IN", sqlx);
}
appendActivityGroupCondition(cnd, activityUserScopePageParam);
cnd.andEX("u.id", IN_OR_NIN_OP, activityUserScopePageParam.getUserId());
@@ -326,7 +323,7 @@ public class ActivityBasicScopeController {
cnd.and("u.welfareMember", EQ_OR_NEQ_OP, 1);
}
if (ArrayUtils.contains(activityUserScopePageParam.getMemberTypes(), "基金会员")) {
cnd.and(new Static(" u.loginname " + IN_OR_NIN_OP + " (select loginname from sick_fund_member)"));
cnd.and("u.aidFundMember", EQ_OR_NEQ_OP, 1);
}
}
@@ -351,8 +348,12 @@ public class ActivityBasicScopeController {
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())){
cnd.andEX("u.unionid", "=", SecurityUtil.getUnionId());
}
cnd.andEX("u.unionid", EQ_OR_NEQ_OP, activityUserScopePageParam.getUnionId());
cnd.andEX("u.unitid", EQ_OR_NEQ_OP, activityUserScopePageParam.getUnitId());
String[] unionIds = getUnionIds(activityUserScopePageParam);
if (Lang.isNotEmpty(unionIds)) {
cnd.andEX("u.unionid", IN_OR_NIN_OP, unionIds);
} else {
cnd.andEX("u.unionid", EQ_OR_NEQ_OP, activityUserScopePageParam.getUnionId());
}
cnd.andEX("u.personType", IN_OR_NIN_OP, activityUserScopePageParam.getPersonTypes());
cnd.andEX("u.userState", IN_OR_NIN_OP, activityUserScopePageParam.getUserStates());
cnd.andEX("u.sex", IN_OR_NIN_OP, activityUserScopePageParam.getSexTypes());
@@ -367,6 +368,34 @@ public class ActivityBasicScopeController {
}
private void appendActivityGroupCondition(Cnd cnd, ActivityUserScopePageParam activityUserScopePageParam) {
Integer activityGroupId = activityUserScopePageParam.getActivityGroupId();
if (activityGroupId == null) {
return;
}
boolean reverseSelection = Boolean.TRUE.equals(activityUserScopePageParam.getReverseSelection());
Integer groupType = activityBasicScopeService.getGroupType(activityGroupId);
if (GROUP_TYPE_RESULT == groupType) {
String existsSql = """
EXISTS (
SELECT 1
FROM activity_user_scope aus
WHERE aus.groupId = %d
AND aus.userId = u.id
)
""".formatted(activityGroupId);
cnd.and(new Static(reverseSelection ? existsSql : "NOT " + existsSql));
return;
}
ActivityUserScope groupInfo = activityBasicScopeService.getGroupInfo(activityGroupId);
if (groupInfo == null || StrUtil.isBlank(groupInfo.getGroupSql())) {
return;
}
String groupSql = "(" + groupInfo.getGroupSql() + ")";
cnd.and(new Static(reverseSelection ? groupSql : "NOT " + groupSql));
}
/**
* 结果分组会把当前筛选出的用户快照保存下来,因此只落 userId 明细数据。
*/
@@ -550,7 +579,7 @@ public class ActivityBasicScopeController {
conditionList.add("u.welfareMember " + eqOrNeq + " 1");
}
if (ArrayUtils.contains(activityUserScopePageParam.getMemberTypes(), "基金会员")) {
conditionList.add("u.loginname " + inOrNotIn + " (select loginname from sick_fund_member)");
conditionList.add("u.aidFundMember " + eqOrNeq + " 1");
}
}
@@ -574,8 +603,12 @@ public class ActivityBasicScopeController {
conditionList.add("u.unionid = " + wrapSqlValue(SecurityUtil.getUnionId()));
}
addSingleValueCondition(conditionList, "u.unionid", eqOrNeq, activityUserScopePageParam.getUnionId());
addSingleValueCondition(conditionList, "u.unitid", eqOrNeq, activityUserScopePageParam.getUnitId());
String[] unionIds = getUnionIds(activityUserScopePageParam);
if (Lang.isNotEmpty(unionIds)) {
addArrayCondition(conditionList, "u.unionid", inOrNotIn, unionIds);
} else {
addSingleValueCondition(conditionList, "u.unionid", eqOrNeq, activityUserScopePageParam.getUnionId());
}
addArrayCondition(conditionList, "u.personType", inOrNotIn, activityUserScopePageParam.getPersonTypes());
addArrayCondition(conditionList, "u.userState", inOrNotIn, activityUserScopePageParam.getUserStates());
addArrayCondition(conditionList, "u.sex", inOrNotIn, activityUserScopePageParam.getSexTypes());
@@ -610,6 +643,16 @@ public class ActivityBasicScopeController {
}
}
private String[] getUnionIds(ActivityUserScopePageParam activityUserScopePageParam) {
if (Lang.isNotEmpty(activityUserScopePageParam.getUnionIds())) {
return activityUserScopePageParam.getUnionIds();
}
if (StrUtil.isNotBlank(activityUserScopePageParam.getUnionId())) {
return new String[]{activityUserScopePageParam.getUnionId()};
}
return null;
}
private void addArrayCondition(List<String> conditionList, String columnName, String operator, String[] values) {
if (Lang.isNotEmpty(values)) {
conditionList.add(columnName + " " + operator + " (" + buildSqlStringList(values) + ")");
@@ -20,7 +20,8 @@ import java.io.Serializable;
@Comment("活动人员范围设置")
@TableIndexes({
@Index(name = "INDEX_ACTIVITY_USER_SCOPE_GROUPID", fields = {"groupId"}, unique = false),
@Index(name = "INDEX_ACTIVITY_USER_SCOPE_USERID", fields = {"userId"}, unique = false)
@Index(name = "INDEX_ACTIVITY_USER_SCOPE_USERID", fields = {"userId"}, unique = false),
@Index(name = "INDEX_ACTIVITY_USER_SCOPE_GROUPID_USERID", fields = {"groupId", "userId"}, unique = false)
})
public class ActivityUserScope extends BaseModel implements Serializable {
@@ -16,6 +16,7 @@ public class ActivityUserScopePageParam extends PageForm {
// 工会id
private String unionId;
private String[] unionIds;
// 单位id
private String unitId;
// 人类型