Commit 9bfad430 authored by hongguangwu's avatar hongguangwu

MVP1.7.15-税友户配置拦截权限2

parent ee025262
......@@ -185,7 +185,7 @@ public class UpmsDaprUtils {
/**
* @param paramVo 用户IDList + 菜单Id
* @Description: 判断用户是否有菜单
* @Description: 判断用户的角色是否有菜单
* @Author: hgw
* @Date: 2025/9/4 16:09
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo>
......@@ -195,4 +195,16 @@ public class UpmsDaprUtils {
,"/user/inner/judgeDispatchAudit", paramVo, KeyValueReturnVo.class, SecurityConstants.FROM_IN);
}
/**
* @param paramVo 用户IDList + 菜单Id
* @Description: 判断用户的权限(用户拼接用户组)是否有菜单
* @Author: hgw
* @Date: 2025/9/4 16:09
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.admin.api.vo.AreaVo>
**/
public R<KeyValueReturnVo> judgeDiyAuthMenuByUserId(ListAndStringVo paramVo) {
return HttpDaprUtil.invokeMethodPost(daprUpmsProperties.getAppUrl(),daprUpmsProperties.getAppId()
,"/user/inner/judgeDiyAuthMenuByUserId", paramVo, KeyValueReturnVo.class, SecurityConstants.FROM_IN);
}
}
......@@ -23,7 +23,8 @@ public class HouseConfigConstants {
public static final String ERROR_TEMPLATE_THREE = "是否自动办理只能为【是】或者【否】";
public static final String ERROR_TEMPLATE_FOUR = "未找到对应的审核人或办理人的人员信息";
public static final String ERROR_TEMPLATE_AUDIT_USER = "未找到对应的审核人信息";
public static final String ERROR_TEMPLATE_HANDLE_USER = "未找到对应的办理人信息";
public static final String ERROR_TEMPLATE_FIVE = "社保账户,社保密码和医保账户,医保密码的账号和密码必须都填写或者都不填写";
......
......@@ -179,9 +179,6 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
**/
private String judgeAuditAndHandleAuth(String type, String auditUser, String auditUserName, String handleUser, String handleUserName) {
List<String> userIdList = new ArrayList<>();
userIdList.add(auditUser);
String returnStr = "";
String valueStr;
String typeName = "社保";
......@@ -189,61 +186,126 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
typeName = "公积金";
}
String auditNo = "审核人("+auditUserName+")账号没有派单审核角色,不能授权为审核人,";
String handleNo = "办理人("+auditUserName+")账号没有"+typeName+"的办理角色,不能授权为办理人,";
// 1:角色菜单
// 派单审核
String menuId = "1549677464986763265";
ListAndStringVo paramVo = new ListAndStringVo();
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
R<KeyValueReturnVo> returnVoR = upmsDaprUtils.judgeMenuByUserIdAndMenuId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(auditUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr = auditNo;
}
} else {
returnStr = auditNo;
}
List<String> userIdList = new ArrayList<>();
// 社保、公积金办理,换成用办理人查询:
userIdList = new ArrayList<>();
userIdList.add(handleUser);
// 社保办理
if (CommonConstants.ZERO_STRING.equals(type)) {
menuId = "1549678343483736066";
paramVo = new ListAndStringVo();
String menuId;
ListAndStringVo paramVo = new ListAndStringVo();
R<KeyValueReturnVo> returnVoR;
// 1审核人:
if (Common.isNotNull(auditUser)) {
userIdList.add(auditUser);
// 【角色】的【派单审核】菜单
menuId = "1549677464986763265";
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
returnVoR = upmsDaprUtils.judgeMenuByUserIdAndMenuId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(handleUser);
valueStr = returnVoR.getData().getKeyValueMap().get(auditUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr += handleNo;
returnStr = auditNo;
}
} else {
returnStr += handleNo;
returnStr = auditNo;
}
}
// 公积金办理
if (CommonConstants.ZERO_STRING.equals(type)) {
menuId = "1549678424018567170";
auditNo = "审核人("+auditUserName+")账号没有派单审核用户组权限,不能授权为审核人,";
// 【数据权限】的【派单审核】菜单
menuId = "1549677464986763265";
paramVo = new ListAndStringVo();
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
returnVoR = upmsDaprUtils.judgeMenuByUserIdAndMenuId(paramVo);
returnVoR = upmsDaprUtils.judgeDiyAuthMenuByUserId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(handleUser);
valueStr = returnVoR.getData().getKeyValueMap().get(auditUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr += handleNo;
returnStr += auditNo;
}
} else {
returnStr += handleNo;
returnStr += auditNo;
}
}
// TODO-2:数据权限菜单:
// 2办理人
if (Common.isNotNull(auditUser)) {
String handleNo = "办理人(" + handleUserName + ")账号没有" + typeName + "的办理角色,不能授权为办理人,";
// 1:角色菜单
// 社保、公积金办理,换成用办理人查询:
userIdList = new ArrayList<>();
userIdList.add(handleUser);
// 社保办理
if (CommonConstants.ZERO_STRING.equals(type)) {
menuId = "1549678343483736066";
paramVo = new ListAndStringVo();
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
returnVoR = upmsDaprUtils.judgeMenuByUserIdAndMenuId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(handleUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr += handleNo;
}
} else {
returnStr += handleNo;
}
}
// 公积金办理
if (CommonConstants.ZERO_STRING.equals(type)) {
menuId = "1549678424018567170";
paramVo = new ListAndStringVo();
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
returnVoR = upmsDaprUtils.judgeMenuByUserIdAndMenuId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(handleUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr += handleNo;
}
} else {
returnStr += handleNo;
}
}
handleNo = "办理人(" + handleUserName + ")账号没有" + typeName + "的用户组权限,不能授权为办理人,";
// 社保、公积金办理,换成用办理人查询:
userIdList = new ArrayList<>();
userIdList.add(handleUser);
// 社保办理
if (CommonConstants.ZERO_STRING.equals(type)) {
menuId = "1549678343483736066";
paramVo = new ListAndStringVo();
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
returnVoR = upmsDaprUtils.judgeDiyAuthMenuByUserId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(handleUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr += handleNo;
}
} else {
returnStr += handleNo;
}
}
// 公积金办理
if (CommonConstants.ZERO_STRING.equals(type)) {
menuId = "1549678424018567170";
paramVo = new ListAndStringVo();
paramVo.setIdList(userIdList);
paramVo.setIdString(menuId);
returnVoR = upmsDaprUtils.judgeDiyAuthMenuByUserId(paramVo);
if (returnVoR != null && returnVoR.getData() != null && returnVoR.getData().getKeyValueMap() != null && !returnVoR.getData().getKeyValueMap().isEmpty()) {
valueStr = returnVoR.getData().getKeyValueMap().get(handleUser);
if (Common.isEmpty(valueStr) || CommonConstants.ZERO_STRING.equals(valueStr)) {
returnStr += handleNo;
}
} else {
returnStr += handleNo;
}
}
}
if (Common.isNotNull(returnStr)) {
returnStr += "请找管理员协助补足权限后重新授权。";
......@@ -326,6 +388,13 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
if (isEdit && (Common.isEmpty(hold.getAuditUser()) || Common.isEmpty(hold.getHandleUser()))) {
return R.failed("审核人或办理人必填!");
}
// 判断审核人与办理人的权限:
String judgeAuth = this.judgeAuditAndHandleAuth(hold.getType()
, hold.getAuditUser(), hold.getAuditUserName()
, hold.getHandleUser(), hold.getHandleUserName());
if (Common.isNotNull(judgeAuth)) {
return R.failed(judgeAuth);
}
if (CommonConstants.ONE_STRING.equals(hold.getDelFlag())
&& baseSetInfoMapper.selectCount(Wrappers.<SysBaseSetInfo>query().lambda()
.eq(SysBaseSetInfo::getBaseType, holdInfo.getType())
......@@ -570,11 +639,15 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
String errorMsg;
// 个性化校验逻辑
// 执行数据插入操作组装
TSocialHouseholdInsertVo excel;
SysHouseHoldInfo household;
// 判断户的审核人与办理人是否有对应的菜单和数据权限,有才可以,没有则不行
String judgeAuth;
for (int i = 0; i < excelVOList.size(); i++) {
TSocialHouseholdInsertVo excel = excelVOList.get(i);
excel = excelVOList.get(i);
//所属机构去空
excel.setOrganName(excel.getOrganName().replace(" ",""));
SysHouseHoldInfo household = new SysHouseHoldInfo();
household = new SysHouseHoldInfo();
BeanCopyUtils.copyProperties(excel,household);
excel.setProvince(areaMap.get(excel.getProvince()).getAreaName());
excel.setCity(areaMap.get(excel.getCity()).getAreaName());
......@@ -628,8 +701,20 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
}
auditUser = userMap.get(excel.getAuditUserName());
handlerUser = userMap.get(excel.getHandleUserName());
if (Common.isEmpty(auditUser) || Common.isEmpty(handlerUser)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_FOUR,excel));
if (Common.isEmpty(auditUser)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_AUDIT_USER,excel));
continue;
}
if (Common.isEmpty(handlerUser)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_HANDLE_USER,excel));
continue;
}
// 判断审核人与办理人的权限:
judgeAuth = this.judgeAuditAndHandleAuth(CommonConstants.ZERO_STRING
, auditUser.getUserId(), excel.getAuditUserName()
, handlerUser.getUserId(), excel.getHandleUserName());
if (Common.isNotNull(judgeAuth)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), judgeAuth ,excel));
continue;
}
if(mobileCheck(excel.getPhone())) {
......@@ -696,6 +781,10 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
String errorMsg;
// 个性化校验逻辑
// 执行数据插入操作 组装
SysUser auditUser;
SysUser handlerUser;
// 判断户的审核人与办理人是否有对应的菜单和数据权限,有才可以,没有则不行
String judgeAuth;
for (int i = 0; i < excelVOList.size(); i++) {
TSocialHouseholdUpdateVo excel = excelVOList.get(i);
info = this.getOne(Wrappers.<SysHouseHoldInfo>query().lambda()
......@@ -770,11 +859,39 @@ public class SysHouseHoldInfoServiceImpl extends ServiceImpl<SysHouseHoldInfoMap
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_FIVE,excel));
continue;
}
if ((Common.isNotNull(excel.getAuditUserName()) && Common.isEmpty(userMap.get(excel.getAuditUserName())))
|| (Common.isNotNull(excel.getHandleUserName()) && Common.isEmpty(userMap.get(excel.getHandleUserName())))) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_FOUR, excel));
continue;
if (Common.isNotNull(excel.getAuditUserName())) {
auditUser = userMap.get(excel.getAuditUserName());
if (auditUser == null || Common.isEmpty(auditUser.getUserId())) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_AUDIT_USER, excel));
continue;
} else {
// 判断审核人与办理人的权限:
judgeAuth = this.judgeAuditAndHandleAuth(CommonConstants.ZERO_STRING
, auditUser.getUserId(), excel.getAuditUserName()
, null, null );
if (Common.isNotNull(judgeAuth)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), judgeAuth ,excel));
continue;
}
}
}
if (Common.isNotNull(excel.getHandleUserName())) {
handlerUser = userMap.get(excel.getHandleUserName());
if (handlerUser == null || Common.isEmpty(handlerUser.getUserId())) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_HANDLE_USER, excel));
continue;
} else {
// 判断审核人与办理人的权限:
judgeAuth = this.judgeAuditAndHandleAuth(CommonConstants.ZERO_STRING
, null, null
, handlerUser.getUserId(), excel.getHandleUserName() );
if (Common.isNotNull(judgeAuth)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), judgeAuth ,excel));
continue;
}
}
}
if(Common.isNotNull(excel.getPhone()) && mobileCheck(excel.getPhone())) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), HouseConfigConstants.ERROR_TEMPLATE_EIGHT,excel));
continue;
......
......@@ -770,11 +770,9 @@ public class UserController {
}
/**
* @Author huych
* @Description 根据项目id和用户id查询csp部门信息
* @Date 14:27 2025/3/10
* @Param
* @return
* @Author hgw
* @Description 判断用户的角色是否有菜单
* @Date 2025-9-5 10:00:19
**/
@Inner
@PostMapping("/inner/judgeDispatchAudit")
......@@ -782,4 +780,15 @@ public class UserController {
return userService.judgeDispatchAudit(paramVo);
}
/**
* @Author hgw
* @Description 判断用户的权限(用户拼接用户组)是否有菜单
* @Date 2025-9-5 10:00:34
**/
@Inner
@PostMapping("/inner/judgeDiyAuthMenuByUserId")
public KeyValueReturnVo judgeDiyAuthMenuByUserId(@RequestBody ListAndStringVo paramVo) {
return userService.judgeDiyAuthMenuByUserId(paramVo);
}
}
......@@ -109,6 +109,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
List<String> getCspUserByProjectNo(@Param("projectNo")String projectNo);
// 判断用户是否有菜单
// 判断用户的角色是否有菜单
List<KeyValueVo> judgeMenuByUserId(@Param("idList") List<String> idList, @Param("menuId") String menuId);
// 判断用户的权限(用户拼接用户组)是否有菜单
List<KeyValueVo> judgeDiyAuthMenuByUserId(@Param("idList") List<String> idList, @Param("menuId") String menuId);
}
......@@ -215,5 +215,9 @@ public interface SysUserService extends IService<SysUser> {
SysCspDeptVo selectCspDeptByUserDeptId(SysCspDeptVo vo);
// 判断用户的角色是否有菜单
KeyValueReturnVo judgeDispatchAudit(ListAndStringVo paramVo);
// 判断用户的权限(用户拼接用户组)是否有菜单
KeyValueReturnVo judgeDiyAuthMenuByUserId(ListAndStringVo paramVo);
}
......@@ -1024,6 +1024,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return vo;
}
/**
* @Description: 判断用户的角色是否有菜单
* @Author: hgw
* @Date: 2025/9/5 10:01
* @return: com.yifu.cloud.plus.v1.yifu.admin.api.vo.KeyValueReturnVo
**/
@Override
public KeyValueReturnVo judgeDispatchAudit(ListAndStringVo paramVo) {
List<String> idList = paramVo.getIdList();
......@@ -1034,6 +1040,29 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return vo;
}
List<KeyValueVo> voList = baseMapper.judgeMenuByUserId(idList, menuId);
return getKeyValueReturnVo(vo, voList);
}
/**
* @Description: 判断用户的权限(用户拼接用户组)是否有菜单
* @Author: hgw
* @Date: 2025/9/5 10:01
* @return: com.yifu.cloud.plus.v1.yifu.admin.api.vo.KeyValueReturnVo
**/
@Override
public KeyValueReturnVo judgeDiyAuthMenuByUserId(ListAndStringVo paramVo) {
List<String> idList = paramVo.getIdList();
// 派单审核 menuId = "1549677464986763265"
String menuId = paramVo.getIdString();
KeyValueReturnVo vo = new KeyValueReturnVo();
if (idList == null || idList.isEmpty() || Common.isEmpty(menuId)) {
return vo;
}
List<KeyValueVo> voList = baseMapper.judgeDiyAuthMenuByUserId(idList, menuId);
return getKeyValueReturnVo(vo, voList);
}
private KeyValueReturnVo getKeyValueReturnVo(KeyValueReturnVo vo, List<KeyValueVo> voList) {
if (voList != null && !voList.isEmpty()) {
Map<String, String> map = new HashMap<>();
for (KeyValueVo keyValueVo : voList) {
......
......@@ -415,7 +415,7 @@
) and a.del_flag='0'
</select>
<!-- 判断用户是否有菜单 -->
<!-- 判断用户是否有菜单 (用在户配置审核人办理人提交时的判断) -->
<select id="judgeMenuByUserId" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.vo.KeyValueVo">
select u.user_id keyStr,count(1) valueStr
from sys_user u
......@@ -431,4 +431,31 @@
and u.del_flag ='0' and r.del_flag='0' and m.del_flag='0'
GROUP BY u.user_id
</select>
<!-- 判断用户的数据权限是否有菜单(用在户配置审核人办理人提交时的判断) -->
<select id="judgeDiyAuthMenuByUserId" resultType="com.yifu.cloud.plus.v1.yifu.admin.api.vo.KeyValueVo">
select keyStr,count(1) valueStr from (
select
a.link_id keyStr
from sys_data_auth a
LEFT JOIN sys_diy_sql_menu_rel r on a.id=r.sys_data_auth_id
where a.link_type = '1' and r.menu_id = #{menuId}
and a.link_id in
<foreach collection="idList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
union all
select
u.user_id keyStr
from sys_data_auth a
LEFT JOIN sys_diy_sql_menu_rel r on a.id=r.sys_data_auth_id
LEFT JOIN sys_user u on u.user_group=a.link_id
where a.link_type = '0' and r.menu_id = #{menuId}
and u.user_id in
<foreach collection="idList" item="ids" open="(" separator="," close=")">
#{ids}
</foreach>
) a
GROUP BY a.keyStr
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment