|
|
@ -1,17 +1,27 @@ |
|
|
|
package com.kms.system.service; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.kms.common.utils.UserUtils; |
|
|
|
import com.kms.system.domain.SysRoleDept; |
|
|
|
import com.kms.system.domain.SysUserRole; |
|
|
|
import com.kms.system.domain.SysXzqh; |
|
|
|
import com.kms.system.mapper.SysXzqhMapper; |
|
|
|
import com.kms.system.mapper.*; |
|
|
|
import com.kms.yg.df.domain.BsSgcDfManateam; |
|
|
|
import com.kms.yg.df.domain.dto.RoleJudgeDto; |
|
|
|
import com.kms.yg.df.service.BsSgcDfManateamService; |
|
|
|
import com.shuili.common.core.domain.entity.SysDept; |
|
|
|
import com.shuili.common.core.domain.entity.SysRole; |
|
|
|
import com.shuili.common.core.domain.entity.SysUser; |
|
|
|
import com.shuili.common.core.service.BaseService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -29,7 +39,69 @@ public class SysXzqhService extends BaseService<SysXzqhMapper, SysXzqh> { |
|
|
|
private SysXzqhMapper sysXzqhMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysDeptService sysDeptService; |
|
|
|
private static SysDeptService sysDeptService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private static SysRoleService sysRoleService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private static SysUserRoleService sysUserRoleService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private static BsSgcDfManateamService bsSgcDfManateamService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取当前用户部门所属行政区划 |
|
|
|
* 如果当前登录用户角色编码属于(YW00143、YW00129、YW00164)则返回当前用户部门的行政区划代码 |
|
|
|
*如果当前登录用户角色编码属于(YW00352/YW00402)中,则通过当前用户手机号去BS_SGC_DF_MANATEAM(数据库表)找到他在工程对象代码进行数据过滤; |
|
|
|
* @return String |
|
|
|
*/ |
|
|
|
public static RoleJudgeDto getRoleDeptDistrictCode() { |
|
|
|
RoleJudgeDto dto=new RoleJudgeDto(); |
|
|
|
SysUser user = UserUtils.getUser(); |
|
|
|
List<SysUserRole> sysUserRoles = sysUserRoleService.list(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, user.getId())); |
|
|
|
if (!CollectionUtils.isEmpty(sysUserRoles)) { |
|
|
|
List<String> roleIds = sysUserRoles.stream() |
|
|
|
.map(SysUserRole::getRoleId) |
|
|
|
.filter(roleId -> !StringUtils.isEmpty(roleId)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if (!CollectionUtils.isEmpty(roleIds)) { |
|
|
|
List<SysRole> sysRoleIds = sysRoleService.list(new LambdaQueryWrapper<SysRole>() |
|
|
|
.in(SysRole::getId, roleIds) |
|
|
|
); |
|
|
|
if (!CollectionUtils.isEmpty(sysRoleIds)) { |
|
|
|
List<String> roleCodes = sysRoleIds.stream() |
|
|
|
.map(SysRole::getRoleKey) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
if (roleCodes.contains("YW00143") |
|
|
|
|| roleCodes.contains("YW00129") |
|
|
|
|| roleCodes.contains("YW00164")) { |
|
|
|
SysDept sysDept = sysDeptService.getById(user.getDeptId()); |
|
|
|
if (!Objects.isNull(sysDept)) { |
|
|
|
dto.setXzqhId(StringUtils.isEmpty(sysDept.getXzqhId()) |
|
|
|
? null:sysDept.getXzqhId()); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
} |
|
|
|
if (roleCodes.contains("YW00352") |
|
|
|
|| roleCodes.contains("YW00402")) { |
|
|
|
BsSgcDfManateam bsSgcDfManateam = bsSgcDfManateamService |
|
|
|
.getById(new LambdaQueryWrapper<BsSgcDfManateam>() |
|
|
|
.eq(!StringUtils.isEmpty(user.getPhonenumber()),BsSgcDfManateam::getPhone, user.getPhonenumber()) |
|
|
|
.orderByDesc(BsSgcDfManateam::getCreateTime) |
|
|
|
.last(" limit 1 ") |
|
|
|
); |
|
|
|
if (!Objects.isNull(bsSgcDfManateam)) { |
|
|
|
dto.setDikeCode(StringUtils.isEmpty(bsSgcDfManateam.getDikeCode()) |
|
|
|
? null:bsSgcDfManateam.getDikeCode()); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Map<String, SysXzqh> get(List<String> adcd) { |
|
|
|