|
|
@ -278,10 +278,63 @@ public class ServiceApplicationsService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PageResult<ServiceApplicationsVO> queryPageReport(@Valid ServiceApplicationsQueryForm queryForm) { |
|
|
public PageResult<ServiceApplicationsVO> queryPageReport(@Valid ServiceApplicationsQueryForm queryForm) { |
|
|
|
|
|
List<Long> longs = new ArrayList<>(); |
|
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm); |
|
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm); |
|
|
//根据用户角色的查询数据范围来查询数据
|
|
|
//根据用户角色的查询数据范围来查询数据
|
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
|
|
|
List<RoleVO> roleIdList = roleEmployeeService.getRoleIdList(requestUser.getUserId()); |
|
|
|
|
|
String roleCode = AdminRequestUtil.getRoleCode(roleIdList); |
|
|
|
|
|
|
|
|
|
|
|
// 检查角色类型
|
|
|
|
|
|
boolean isAssociationRole = AdminRequestUtil.isAssociationRole(roleIdList); |
|
|
|
|
|
boolean isFirmRole = AdminRequestUtil.isFirmRole(roleIdList); // 律所主任或行政
|
|
|
|
|
|
if (!UserTypeEnum.Admin.getDesc().equals(roleCode)) { |
|
|
|
|
|
if (isAssociationRole) { |
|
|
|
|
|
// 协会用户(CEO):可以看到所有律所提交的数据,但只显示associationAuditStatus为待审核(1)、通过(3)和拒绝(4)的数据和自己创建的数据
|
|
|
|
|
|
queryForm.setIncludeAssociationReviewed(true); |
|
|
|
|
|
} else if (isFirmRole) { |
|
|
|
|
|
// 律所主任或行政:能看到自己部门范围内的数据,但只显示firmAuditStatus为待审核、通过和拒绝的数据和自己创建的数据
|
|
|
|
|
|
Integer oneByRoleId = dataScopeViewService.getOneByRoleId(roleIdList.get(0).getRoleId()); |
|
|
|
|
|
// 获取自己部门范围内的数据
|
|
|
|
|
|
List<Long> departmentEmployees = new ArrayList<>(); |
|
|
|
|
|
if (DataScopeViewTypeEnum.ME.getValue().equals(oneByRoleId)) { |
|
|
|
|
|
departmentEmployees = dataScopeViewService.getCanViewEmployeeId(DataScopeViewTypeEnum.ME, requestUser.getUserId()); |
|
|
|
|
|
} else if (DataScopeViewTypeEnum.DEPARTMENT.getValue().equals(oneByRoleId)) { |
|
|
|
|
|
departmentEmployees = dataScopeViewService.getCanViewEmployeeId(DataScopeViewTypeEnum.DEPARTMENT, requestUser.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 确保包含当前用户ID,以便能看到自己创建的数据
|
|
|
|
|
|
if (departmentEmployees == null) { |
|
|
|
|
|
departmentEmployees = new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!departmentEmployees.contains(requestUser.getUserId())) { |
|
|
|
|
|
departmentEmployees.add(requestUser.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
queryForm.setEmployeeIdList(departmentEmployees); |
|
|
|
|
|
// 律所主任或行政可以查看部门内所有已审核数据以及自己创建的有效数据(明确排除未提交的草稿)
|
|
|
|
|
|
queryForm.setIncludeFirmReviewed(true); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 律所普通用户:只能看到自己提交的数据,包括所有firmAuditStatus状态
|
|
|
|
|
|
Integer oneByRoleId = dataScopeViewService.getOneByRoleId(roleIdList.get(0).getRoleId()); |
|
|
|
|
|
if (DataScopeViewTypeEnum.ME.getValue().equals(oneByRoleId)) { |
|
|
|
|
|
longs = dataScopeViewService.getCanViewEmployeeId(DataScopeViewTypeEnum.ME, requestUser.getUserId()); |
|
|
|
|
|
} else if (DataScopeViewTypeEnum.DEPARTMENT.getValue().equals(oneByRoleId)) { |
|
|
|
|
|
longs = dataScopeViewService.getCanViewEmployeeId(DataScopeViewTypeEnum.DEPARTMENT, requestUser.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
// 确保普通用户至少能看到自己的数据
|
|
|
|
|
|
if (longs == null) { |
|
|
|
|
|
longs = new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!longs.contains(requestUser.getUserId())) { |
|
|
|
|
|
longs.add(requestUser.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
queryForm.setEmployeeIdList(longs); |
|
|
|
|
|
// 普通用户不需要审核状态过滤,可以看到自己所有状态的数据
|
|
|
|
|
|
queryForm.setNoStatusFilter(true); |
|
|
|
|
|
} |
|
|
|
|
|
queryForm.setCurrentUserId(requestUser.getUserId()); |
|
|
|
|
|
} |
|
|
queryForm.setUserId(requestUser.getUserId()); |
|
|
queryForm.setUserId(requestUser.getUserId()); |
|
|
List<ServiceApplicationsVO> list = serviceApplicationsDao.queryPage(page, queryForm); |
|
|
List<ServiceApplicationsVO> list = serviceApplicationsDao.queryPage(page, queryForm); |
|
|
if (!CollectionUtils.isEmpty(list)) { |
|
|
if (!CollectionUtils.isEmpty(list)) { |
|
|
@ -755,7 +808,41 @@ public class ServiceApplicationsService { |
|
|
return ResponseDTO.ok(); |
|
|
return ResponseDTO.ok(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//RequestEmployee requestUser = AdminRequestUtil.getRequestUser();
|
|
|
// 获取当前用户信息
|
|
|
|
|
|
RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); |
|
|
|
|
|
List<RoleVO> roleIdList = roleEmployeeService.getRoleIdList(requestUser.getUserId()); |
|
|
|
|
|
|
|
|
|
|
|
// 检查是否是律所角色(主任或行政)
|
|
|
|
|
|
boolean isFirmRole = AdminRequestUtil.isFirmRole(roleIdList); |
|
|
|
|
|
if (!isFirmRole) { |
|
|
|
|
|
return ResponseDTO.error(UserErrorCode.NO_PERMISSION); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询这些记录的详细信息,进行权限和状态校验
|
|
|
|
|
|
for (Long id : idList) { |
|
|
|
|
|
ServiceApplicationsVO record = serviceApplicationsDao.queryById(id); |
|
|
|
|
|
if (record == null) { |
|
|
|
|
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST, "记录ID:" + id + "不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 校验1:只能上报本所的数据
|
|
|
|
|
|
if (!record.getFirmId().equals(requestUser.getDepartmentId())) { |
|
|
|
|
|
return ResponseDTO.error(UserErrorCode.NO_PERMISSION, "只能上报本所的数据"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 校验2:执业机构审核状态必须是已通过(3)
|
|
|
|
|
|
if (!ReviewEnum.PASS.getValue().equals(record.getFirmAuditStatus())) { |
|
|
|
|
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "记录ID:" + id + "未通过执业机构审核,无法上报"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 校验3:协会审核状态必须是未提交(0)或被驳回(4)
|
|
|
|
|
|
Integer associationStatus = record.getAssociationAuditStatus(); |
|
|
|
|
|
if (!ReviewEnum.NOSUBMIT.getValue().equals(associationStatus) && |
|
|
|
|
|
!ReviewEnum.REFUSE.getValue().equals(associationStatus)) { |
|
|
|
|
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "记录ID:" + id + "已上报或正在审核中,无法重复上报"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
serviceApplicationsDao.batchSubmitAsAssociation(idList, ReviewEnum.APPROVAL.getValue()); |
|
|
serviceApplicationsDao.batchSubmitAsAssociation(idList, ReviewEnum.APPROVAL.getValue()); |
|
|
|
|
|
|
|
|
return ResponseDTO.ok(); |
|
|
return ResponseDTO.ok(); |
|
|
|