From df3f9c9c9b28b97f8891e9560dd40ec5cca61000 Mon Sep 17 00:00:00 2001 From: caihaohan Date: Wed, 27 Sep 2023 17:14:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=81=E6=A0=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../laws/common/constant/FieldCommon.java | 2 + .../service/impl/LawsCommonServiceImpl.java | 39 +------- .../EnterpriseStandardAuthUserService.java | 5 + ...EnterpriseStandardAuthUserServiceImpl.java | 99 ++++++++++++++++++- 4 files changed, 108 insertions(+), 37 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java b/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java index 5b00394d..3dbc5454 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/common/constant/FieldCommon.java @@ -57,6 +57,8 @@ public class FieldCommon { public static final String STR_TO_DATE_SUFFIX = "','%Y-%m-%d %H:%i:%s')"; // 格式化时间格式的后缀 // 收藏标识 public static final String COLLECTION_FLAG = "collectionFlag"; + // 查看详情权限标识 + public static final String DETAIL_FLAG = "detailFlag"; // 我的收藏 public static final String MY_COLLECTION = "MyCollection"; // 主键 diff --git a/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java index 5f437f94..b326ee14 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/common/service/impl/LawsCommonServiceImpl.java @@ -20,6 +20,7 @@ import com.jero.modules.laws.common.service.ILawsCommonService; import com.jero.modules.laws.common.vo.ManyStandardSelectionBox; import com.jero.modules.laws.common.vo.ManyStandardSelectionBoxVO; import com.jero.modules.laws.enterprise.entity.EnterpriseStandardInspectContent; +import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthUserService; import com.jero.modules.laws.enterprise.service.EnterpriseStandardInspectContentService; import com.jero.modules.laws.enterprise.util.EnterpriseStandardUtil; import com.jero.modules.laws.standard.entity.LawsNodeRelation; @@ -113,6 +114,8 @@ public class LawsCommonServiceImpl implements ILawsCommonService { // 自我注入 @Autowired private ILawsCommonService commonService; + @Resource + private EnterpriseStandardAuthUserService esAuthUserService; /** * @Author: liao @@ -151,7 +154,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService { // 企标独有权限 if (module.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue())) { // 是否能查看详情 - this.detailFlag(infoPage.getRecords()); + esAuthUserService.detailFlagSet(infoPage.getRecords()); } // 是否收藏判断标识 collectionFlag(infoPage.getRecords()); @@ -240,40 +243,6 @@ public class LawsCommonServiceImpl implements ILawsCommonService { return fieldList; } - /** - * @Author: liao - * @Date: 2023/9/11 14:49 - * @Description: 是否能进入详情页判断 - **/ - private void detailFlag(List> records) { - // 获取全部id集合 - List ids = records.stream().map(kv -> - String.valueOf(kv.get("id"))).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(ids)) return; - // 获取登录用户 - LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - // 查询标准收藏表 - - - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(LawsStandardCollection::getCollectorId, loginUser.getId()); - queryWrapper.in(LawsStandardCollection::getStandardId, ids); - List standardCollectionList = lawsStandardCollectionService.list(queryWrapper); - if (CollectionUtils.isEmpty(standardCollectionList)) { - records.forEach(map -> map.put(FieldCommon.COLLECTION_FLAG, false)); - return; - } - List standardIdList = standardCollectionList.stream() - .map(LawsStandardCollection::getStandardId).collect(Collectors.toList()); - records.forEach(map -> { - if (standardIdList.contains(String.valueOf(map.get("id")))) { - map.put(FieldCommon.COLLECTION_FLAG, true); - } else { - map.put(FieldCommon.COLLECTION_FLAG, false); - } - }); - } - /** * @Author: liao * @Date: 2023/9/11 14:49 diff --git a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthUserService.java b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthUserService.java index 84156fa9..25b0d3d7 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthUserService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthUserService.java @@ -4,6 +4,9 @@ import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser; import com.baomidou.mybatisplus.extension.service.IService; import com.jero.modules.laws.standard.entity.LawsStandardTempPermission; +import java.util.List; +import java.util.Map; + /** * @author ThinkBook * @description 针对表【laws_enterprise_standard_temp_permission(企业标准)】的数据库操作Service @@ -12,4 +15,6 @@ import com.jero.modules.laws.standard.entity.LawsStandardTempPermission; public interface EnterpriseStandardAuthUserService extends IService { void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission); + + void detailFlagSet(List> records); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/impl/EnterpriseStandardAuthUserServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/impl/EnterpriseStandardAuthUserServiceImpl.java index cd6c467b..a74d6df3 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/impl/EnterpriseStandardAuthUserServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/impl/EnterpriseStandardAuthUserServiceImpl.java @@ -1,17 +1,33 @@ package com.jero.modules.laws.enterprise.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.jero.common.constant.enums.YesOrNoEnum; import com.jero.common.exception.JeroBootException; +import com.jero.modules.laws.common.constant.FieldCommon; +import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthDept; import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser; +import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthDeptService; import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthUserService; import com.jero.modules.laws.enterprise.mapper.EnterpriseStandardAuthUserMapper; +import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard; import com.jero.modules.laws.standard.entity.LawsStandardTempPermission; +import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService; +import com.jero.modules.sys.entity.LawsEnterpriseStandardLevel; +import com.jero.modules.sys.entity.LawsGrade; +import com.jero.modules.sys.service.ILawsEnterpriseStandardLevelService; +import com.jero.modules.sys.service.ILawsGradeService; +import com.jero.modules.sys.utils.UserUtils; +import com.jero.modules.system.entity.SysUser; +import com.jero.modules.system.service.ISysUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.List; +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author ThinkBook @@ -23,6 +39,18 @@ import java.util.List; @Slf4j public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl implements EnterpriseStandardAuthUserService { + @Resource + private EnterpriseStandardAuthDeptService authDeptService; + + @Resource + private ISysUserService sysUserService; + + @Resource + private ILawsEnterpriseStandardService enterpriseStandardService; + + @Resource + private ILawsEnterpriseStandardLevelService standardLevelService; + @Override public void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission) { List esAuthUsers = new ArrayList<>(); @@ -39,6 +67,73 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl> records) { + SysUser currentUser = sysUserService.getById(UserUtils.getUserId()); + String userId = currentUser.getId(); + String deptId = currentUser.getDepartIds(); + List standardIds = new ArrayList<>(); + records.forEach(kv -> standardIds.add(String.valueOf(kv.get(FieldCommon.ID)))); + List esList = enterpriseStandardService.list(new LambdaQueryWrapper() + .in(LawsEnterpriseStandard::getId, standardIds) + .eq(LawsEnterpriseStandard::getDelFlag, YesOrNoEnum.NO.getValue())); + Map esMap = esList.stream().collect(Collectors.toMap(LawsEnterpriseStandard::getId, e -> e)); + + // 查询临时授权人员 + Date date = new Date(); + LambdaQueryWrapper authUserWrapper = new LambdaQueryWrapper<>(); + authUserWrapper.in(EnterpriseStandardAuthUser::getStandardId, standardIds); + authUserWrapper.eq(EnterpriseStandardAuthUser::getAuthUser, userId); + authUserWrapper.ge(EnterpriseStandardAuthUser::getAuthExpireDate, date); + List authUserList = list(authUserWrapper); + Set authStandardIds = authUserList.stream().map(EnterpriseStandardAuthUser::getStandardId).collect(Collectors.toSet()); + + // 查询授权部门-和临时授权部门 + LambdaQueryWrapper authDeptWrapper = new LambdaQueryWrapper<>(); + authDeptWrapper.in(EnterpriseStandardAuthDept::getStandardId, standardIds); + authDeptWrapper.eq(EnterpriseStandardAuthDept::getAuthDept, deptId); + List authDeptList = authDeptService.list(authDeptWrapper); + authDeptWrapper.ge(EnterpriseStandardAuthDept::getAuthExpireDate, date); + authDeptList.addAll(authDeptService.list(authDeptWrapper)); + authStandardIds.addAll(authDeptList.stream().map(EnterpriseStandardAuthDept::getStandardId).collect(Collectors.toSet())); + + // 企标级别授权的部门 + List standardLevelList = standardLevelService.list(); + List levelDeptIds = standardLevelList.stream().map(LawsEnterpriseStandardLevel::getDeptId).collect(Collectors.toList()); + + for (Map map : records) { + String standardId = (String) map.get(FieldCommon.ID); + LawsEnterpriseStandard es = esMap.get(standardId); + // 等级分类 + String gradeClassification = es.getGradeClassification(); + // 全公司可以看 + if (gradeClassification.equals("1")) { + map.put(FieldCommon.DETAIL_FLAG, true); + continue; + } + // 企标等级分类级别可查看部门 + if (gradeClassification.equals("2") || gradeClassification.equals("3")) { + if (levelDeptIds.contains(deptId)) { + map.put(FieldCommon.DETAIL_FLAG, true); + continue; + } + } + // 授权部门和临时权限 + if (authStandardIds.contains(standardId)) { + map.put(FieldCommon.DETAIL_FLAG, true); + continue; + } + // 起草部门 + String mainDraftDeptId = es.getMainDraftingUnit(); + if (deptId.equals(mainDraftDeptId)) { + map.put(FieldCommon.DETAIL_FLAG, true); + continue; + } + map.put(FieldCommon.DETAIL_FLAG, false); + } + + } }