|
|
|
@ -60,7 +60,11 @@ import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.biutag.supervision.constants.AppConstants.ROOTID; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author weipeng |
|
|
|
* @author weipeng |
|
|
|
@ -238,38 +242,32 @@ public class ReportProjectController { |
|
|
|
wrapper.groupBy("p.id"); |
|
|
|
wrapper.groupBy("p.id"); |
|
|
|
wrapper.eq("p.delete_flag", DeleteStatusEnum.NO.getCode()); |
|
|
|
wrapper.eq("p.delete_flag", DeleteStatusEnum.NO.getCode()); |
|
|
|
|
|
|
|
|
|
|
|
// 鉴权逻辑
|
|
|
|
// 账号鉴权
|
|
|
|
UserAuth user = UserContextHolder.getCurrentUser(); |
|
|
|
UserAuth user = UserContextHolder.getCurrentUser(); |
|
|
|
boolean superAuth = AppConstants.USER_TYPE_SUPER.equals(user.getUserType()); |
|
|
|
boolean superAuth = AppConstants.USER_TYPE_SUPER.equals(user.getUserType()); |
|
|
|
boolean firstAuth = superAuth || user.getRoleCodes().contains(RoleCodeEnum.FIRST_ADMIN.getCode()); |
|
|
|
boolean firstAuth = superAuth || user.getRoleCodes().contains(RoleCodeEnum.FIRST_ADMIN.getCode()); |
|
|
|
// 获取用户的权限部门及其所有子部门
|
|
|
|
List<String> userAuthOrgIds = firstAuth |
|
|
|
List<String> userAuthOrgIds = !user.getAuthDepartIds().isEmpty() |
|
|
|
? departService.getAllNodeIds(ROOTID) |
|
|
|
? departService.getAllNodeIds(user.getAuthDepartIds()) |
|
|
|
: (user.getAuthDepartIds().isEmpty() ? departService.getAllNodeIds(user.getDepartId()) : departService.getAllNodeIds(user.getAuthDepartIds())); |
|
|
|
: departService.getAllNodeIds(user.getDepartId()); |
|
|
|
if (!superAuth) { |
|
|
|
|
|
|
|
wrapper.and(p -> p.in("p.audit_unit_id", userAuthOrgIds).or().in("p.project_unit_id", userAuthOrgIds)); |
|
|
|
// 根据code参数应用不同的鉴权规则
|
|
|
|
|
|
|
|
String code = queryParam.getCode(); |
|
|
|
|
|
|
|
if (firstAuth) { |
|
|
|
|
|
|
|
// 超级管理员和市级管理员
|
|
|
|
|
|
|
|
if ("dszd".equals(code)) { |
|
|
|
|
|
|
|
// 只显示督审支队及以下单位的数据
|
|
|
|
|
|
|
|
List<String> dszdOrgIds = departService.getAllNodeIds(AppConstants.DSZD); |
|
|
|
|
|
|
|
wrapper.and(w -> w.in("p.audit_unit_id", dszdOrgIds).or().in("p.project_unit_id", dszdOrgIds)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// 其他情况(firstAuth + 无code或self)显示全部数据
|
|
|
|
// 页面鉴权
|
|
|
|
} else { |
|
|
|
Map<String, Consumer<QueryWrapper<ReportProject>>> authStrategy = Map.of( |
|
|
|
// 非市级管理员,根据code应用不同规则
|
|
|
|
// “审计单位”为督审支队的项目
|
|
|
|
if ("dszd".equals(code)) { |
|
|
|
"dszd", w -> { |
|
|
|
// 只显示审计单位或项目单位为督审支队及以下单位的数据
|
|
|
|
|
|
|
|
List<String> dszdOrgIds = departService.getAllNodeIds(AppConstants.DSZD); |
|
|
|
List<String> dszdOrgIds = departService.getAllNodeIds(AppConstants.DSZD); |
|
|
|
wrapper.and(w -> w.in("p.audit_unit_id", dszdOrgIds).or().in("p.project_unit_id", dszdOrgIds)); |
|
|
|
w.and(p -> p.in("p.audit_unit_id", dszdOrgIds)); |
|
|
|
} else if ("self".equals(code)) { |
|
|
|
}, |
|
|
|
// 只显示审计单位或项目单位为自己的权限机构的数据
|
|
|
|
// 内“审计单位”为各分县市局内审的项目
|
|
|
|
wrapper.and(w -> w.eq("p.audit_unit_id", user.getDepartId()).or().eq("p.project_unit_id", user.getDepartId())); |
|
|
|
"self", w -> { |
|
|
|
} else { |
|
|
|
w.and(p -> p.in("p.audit_unit_id", userAuthOrgIds)); |
|
|
|
// 默认显示权限范围内的所有数据
|
|
|
|
// w.and(p -> p.in("p.audit_unit_id", userAuthOrgIds).or().in("p.project_unit_id", userAuthOrgIds));
|
|
|
|
wrapper.and(w -> w.in("p.audit_unit_id", userAuthOrgIds).or().in("p.project_unit_id", userAuthOrgIds)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
String code = queryParam.getCode(); |
|
|
|
|
|
|
|
if (code != null && authStrategy.containsKey(code)) { |
|
|
|
|
|
|
|
authStrategy.get(code).accept(wrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Page<ConditionVo> conditionPage = reportProjectService.getConditionPage(new Page<>(queryParam.getCurrent(), queryParam.getSize()), wrapper); |
|
|
|
Page<ConditionVo> conditionPage = reportProjectService.getConditionPage(new Page<>(queryParam.getCurrent(), queryParam.getSize()), wrapper); |
|
|
|
|