diff --git a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthDeptService.java b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthDeptService.java index cb689d6c..bfdbc69a 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthDeptService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/service/EnterpriseStandardAuthDeptService.java @@ -1,8 +1,7 @@ package com.jero.modules.laws.enterprise.service; -import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthDept; import com.baomidou.mybatisplus.extension.service.IService; -import com.jero.modules.laws.standard.entity.LawsStandardTempPermission; +import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthDept; import java.util.List; @@ -13,7 +12,5 @@ import java.util.List; */ public interface EnterpriseStandardAuthDeptService extends IService { - void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission); - void batchInsertWithTransaction(List list, int batchSize); } 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 71773663..2d399995 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 @@ -1,10 +1,9 @@ package com.jero.modules.laws.enterprise.service; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser; import com.baomidou.mybatisplus.extension.service.IService; +import com.jero.modules.laws.enterprise.entity.EnterpriseStandardAuthUser; import com.jero.modules.laws.standard.controller.TempAuthRecordQueryDto; -import com.jero.modules.laws.standard.entity.LawsStandardTempPermission; import java.util.List; import java.util.Map; @@ -16,15 +15,6 @@ import java.util.Map; */ public interface EnterpriseStandardAuthUserService extends IService { - void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission); - - /** - * 不校验当前登陆人账号是否有权限 - * - * @param lawsStandardTempPermission - */ - void saveTempPermissionTwo(LawsStandardTempPermission lawsStandardTempPermission); - /** * 查看详情权限设置 * @@ -48,16 +38,6 @@ public interface EnterpriseStandardAuthUserService extends IService standardIds); - - /** - * 指定用户Id是否有指定企标的删除权限 - * @param standardId 企标Id - * @param userId 用户Id - */ - boolean hasDelAuth(String standardId, String userId); - /** * 指定用户Id是否有指定企标的删除权限 * @param standardId 企标Id @@ -97,10 +68,4 @@ public interface EnterpriseStandardAuthUserService extends IService implements EnterpriseStandardAuthDeptService{ - @Resource - private ILawsEnterpriseStandardService enterpriseStandardService; - - @Resource - private EnterpriseStandardAuthUserServiceImpl authUserService; - @Resource private SqlSessionFactory sqlSessionFactory; - @Override - public void saveTempPermission(LawsStandardTempPermission lawsStandardTempPermission) { - List standardIdList = lawsStandardTempPermission.getStandardIdList(); - for (String id : standardIdList) { - if (!authUserService.hasESAuth(UserUtils.getUserId(), Collections.singletonList(id))) { - LawsEnterpriseStandard es = enterpriseStandardService.getById(id); - throw new JeroBootException(MessageUtils.getMessage(ResultCommon.YOU_HAVE_NOT_DATA_AUTH, es.getStandardNumber())); - } - } - - List esAuthDepts = new ArrayList<>(); - for (String standardId : lawsStandardTempPermission.getStandardIdList()) { - for (String deptId : lawsStandardTempPermission.getDeptIdList()) { - EnterpriseStandardAuthDept enterpriseStandardAuthDept = new EnterpriseStandardAuthDept(); - enterpriseStandardAuthDept.setAuthDept(deptId); - enterpriseStandardAuthDept.setStandardId(standardId); - if (lawsStandardTempPermission.getAuthDate() != null) { - enterpriseStandardAuthDept.setAuthExpireDate(lawsStandardTempPermission.getAuthDate()); - } - esAuthDepts.add(enterpriseStandardAuthDept); - } - } - saveBatch(esAuthDepts); - } - @Override public void batchInsertWithTransaction(List list, int batchSize) { 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 2b037952..8cc30f1a 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 @@ -97,56 +97,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl standardIdList = lawsStandardTempPermission.getStandardIdList(); - for (String id : standardIdList) { - if (!this.hasESAuth(UserUtils.getUserId(), Collections.singletonList(id))) { - LawsEnterpriseStandard es = enterpriseStandardService.getById(id); - throw new JeroBootException(MessageUtils.getMessage(ResultCommon.YOU_HAVE_NOT_DATA_AUTH, es.getStandardNumber())); - } - } - - List esAuthUsers = new ArrayList<>(); - - for (String standardId : lawsStandardTempPermission.getStandardIdList()) { - for (String userId : lawsStandardTempPermission.getUserIdList()) { - EnterpriseStandardAuthUser enterpriseStandardAuthUser = new EnterpriseStandardAuthUser(); - enterpriseStandardAuthUser.setAuthUser(userId); - enterpriseStandardAuthUser.setStandardId(standardId); - if (lawsStandardTempPermission.getAuthDate() != null) { - Date authDate = lawsStandardTempPermission.getAuthDate(); - // 对authDate加一天 - Calendar c = Calendar.getInstance(); - c.setTime(authDate); - c.add(Calendar.DATE, 1); - authDate = c.getTime(); - enterpriseStandardAuthUser.setAuthExpireDate(authDate); - } - esAuthUsers.add(enterpriseStandardAuthUser); - } - } - saveBatch(esAuthUsers); - } - - @Override - public void saveTempPermissionTwo(LawsStandardTempPermission lawsStandardTempPermission) { - - List esAuthUsers = new ArrayList<>(); - - for (String standardId : lawsStandardTempPermission.getStandardIdList()) { - for (String userId : lawsStandardTempPermission.getUserIdList()) { - EnterpriseStandardAuthUser enterpriseStandardAuthUser = new EnterpriseStandardAuthUser(); - enterpriseStandardAuthUser.setAuthUser(userId); - enterpriseStandardAuthUser.setStandardId(standardId); - enterpriseStandardAuthUser.setAuthExpireDate(lawsStandardTempPermission.getAuthDate()); - esAuthUsers.add(enterpriseStandardAuthUser); - } - } - saveBatch(esAuthUsers); - } - @Override public void detailFlagSet(List> records) { if (true) { @@ -242,95 +192,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl standardIds) { - SysUser currentUser = sysUserService.getById(userId); - // 管理员有所有企标的权限 - List roleList = sysUserRoleService.getRole(currentUser.getUsername()); - if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList::contains)) { - return true; - } - - List> records = new ArrayList<>(); - for (String id : standardIds) { - Map map = new HashMap<>(); - map.put(FieldCommon.ID, id); - records.add(map); - } - List departIdModels = sysUserDepartService.queryDepartIdsOfUser(userId); - List departIds = departIdModels.stream().map(DepartIdModel::getKey).collect(Collectors.toList()); - List departNames = departIdModels.stream().map(DepartIdModel::getTitle).collect(Collectors.toList()); - - List esList = enterpriseStandardService.list(new LambdaQueryWrapper() - .in(CollUtil.isNotEmpty(standardIds), 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(CollUtil.isNotEmpty(standardIds), EnterpriseStandardAuthUser::getStandardId, standardIds); - authUserWrapper.eq(EnterpriseStandardAuthUser::getAuthUser, userId); - authUserWrapper.ge(EnterpriseStandardAuthUser::getAuthExpireDate, date); - List authUserList = list(authUserWrapper); - Set tempAuthStandardIds = authUserList.stream().map(EnterpriseStandardAuthUser::getStandardId).collect(Collectors.toSet()); - // 查询临时授权部门 - LambdaQueryWrapper tempAuthDeptWrapper = new LambdaQueryWrapper<>(); - tempAuthDeptWrapper.in(CollUtil.isNotEmpty(standardIds), EnterpriseStandardAuthDept::getStandardId, standardIds); - tempAuthDeptWrapper.in(CollUtil.isNotEmpty(departIds), EnterpriseStandardAuthDept::getAuthDept, departIds); - tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthExpireDate); - tempAuthDeptWrapper.isNotNull(EnterpriseStandardAuthDept::getAuthDept); - List tempAuthDeptList = authDeptService.list(tempAuthDeptWrapper); - tempAuthDeptWrapper.ge(EnterpriseStandardAuthDept::getAuthExpireDate, date); - tempAuthDeptList.addAll(authDeptService.list(tempAuthDeptWrapper)); - // 找出授权部门 和 临时授权部门 - tempAuthStandardIds.addAll(tempAuthDeptList.stream().map(EnterpriseStandardAuthDept::getStandardId).collect(Collectors.toSet())); - - // 查询授权部门 - LambdaQueryWrapper authDeptWrapper = new LambdaQueryWrapper<>(); - authDeptWrapper.in(CollUtil.isNotEmpty(standardIds), EnterpriseStandardAuthDept::getStandardId, standardIds); - authDeptWrapper.isNull(EnterpriseStandardAuthDept::getAuthExpireDate); - List authDeptList = authDeptService.list(authDeptWrapper); - authDeptList.addAll(authDeptService.list(authDeptWrapper)); - - // 企标级别授权的部门 - List standardLevelList = standardLevelService.list(); - List gradeList = gradeService.list(); - Map gradeMap = gradeList.stream().collect(Collectors.toMap(LawsGrade::getLevel, e -> e)); - - List levelOneDeptIds = standardLevelList.stream().filter(l -> l.getGradeId().equals(gradeMap.get(1).getId())) - .map(LawsEnterpriseStandardLevel::getDeptId).collect(Collectors.toList()); - List levelTwoDeptIds = standardLevelList.stream().filter(l -> l.getGradeId().equals(gradeMap.get(2).getId())) - .map(LawsEnterpriseStandardLevel::getDeptId).collect(Collectors.toList()); - - // 获取起草部门的Id - for (Map map : records) { - String standardId = (String) map.get(FieldCommon.ID); - LawsEnterpriseStandard es = esMap.get(standardId); - String mainDraftUnit = es.getMainDraftingUnit(); - Set curAuthSet = authDeptList.stream() - .filter(e -> e.getAuthDept() != null) - .filter(e -> StrUtil.isNotEmpty(e.getAuthDept())) - .filter(e -> e.getStandardId().equals(standardId)) - .filter(e -> !e.getAuthDept().equals(mainDraftUnit)) - .collect(Collectors.toSet()); - // 临时权限 - if (tempAuthStandardIds.contains(standardId)) { - map.put(FieldCommon.DETAIL_FLAG, true); - continue; - } - - map.put(FieldCommon.DETAIL_FLAG, false); - } - // 遍历map - for ( - Map map : records) { - if (!(boolean) map.get(FieldCommon.DETAIL_FLAG)) { - return false; - } - } - return true; - } @Override public void editFlagSet(List> records) { @@ -358,49 +219,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl roleList = sysUserRoleService.getRole(currentUser.getUsername()); - // 管理员能够删除所有试用期的企标 - if (roleList != null && roleList.stream().anyMatch(adminRoleCodeList::contains)) { - String tryFlag = es.getTryFlag(); - if (tryFlag.equals(YesOrNoEnum.NO.getValue())) { - return false; - } - - Date releaseDate = es.getReleaseDate(); - int trialPeriodMonths = Integer.parseInt(es.getTrialPeriod()); // 将试用周期转换为天数 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(releaseDate); - calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上 - Date trialEndDate = calendar.getTime(); // 获取试用期结束日期 - - // 在适用周期之内的可以删除 - return tryFlag.equals(YesOrNoEnum.YES.getValue()) && currentDate.compareTo(trialEndDate) <= 0; - } - - // 创建人只能删除自己的试用期的企标 - String createBy = es.getCreateBy(); - String tryFlag = es.getTryFlag(); - if (tryFlag.equals(YesOrNoEnum.NO.getValue())) { - return false; - } - Date releaseDate = es.getReleaseDate(); - int trialPeriodMonths = Integer.parseInt(es.getTrialPeriod()); // 将试用周期转换为天数 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(releaseDate); - calendar.add(Calendar.MONTH, trialPeriodMonths); // 将试用周期加到发布日期上 - Date trialEndDate = calendar.getTime(); // 获取试用期结束日期 - return username.equals(createBy) && tryFlag.equals(YesOrNoEnum.YES.getValue()) - && currentDate.compareTo(trialEndDate) <= 0; - } - @Override public boolean hasEditAuth(String standardId, String userId) { SysUser user = sysUserService.getById(userId); @@ -423,14 +241,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl> records) { if (true) { @@ -554,49 +364,6 @@ public class EnterpriseStandardAuthUserServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(EnterpriseStandardAuthDept::getStandardId, id); - authDeptService.remove(wrapper); - - List authDeptList = new ArrayList<>(); - if (authDeptIdList.length == 0) { - return; - } - for (String deptId : authDeptIdList) { - EnterpriseStandardAuthDept authDept1 = new EnterpriseStandardAuthDept(); - authDept1.setStandardId(id); - authDept1.setAuthDept(deptId); - authDeptList.add(authDept1); - } - authDeptService.saveBatch(authDeptList); - } - @Override @Cacheable(value = "tempAuthRecord", key = "{#tempAuthRecordQueryDto, #pageNo, #pageSize}") public IPage tempAuthRecord(TempAuthRecordQueryDto tempAuthRecordQueryDto, Integer pageNo, Integer pageSize) { diff --git a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java index c45a555c..f7a32186 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/enterprise/util/EnterpriseStandardUtil.java @@ -201,16 +201,16 @@ public class EnterpriseStandardUtil { if (dashIndex == -1) { dashIndex = standardNo.lastIndexOf('—'); } - if (dashIndex < 4) { - return null; // 如果没有找到'-',或者'-'前面的字符少于4个 + if (dashIndex < 3) { + return null; // 如果没有找到'-',或者'-'前面的字符少于3个 } int dotIndex = standardNo.lastIndexOf('.'); if (dotIndex > 0 && dotIndex < dashIndex) { // 确保小数点在破折号前且存在 - int start = Math.max(dotIndex - 4, 0); // 确保不会有负索引 + int start = Math.max(dotIndex - 3, 0); // 确保不会有负索引 return standardNo.substring(start, dashIndex); // 提取包含小数点的序列号部分 } else { - return standardNo.substring(dashIndex - 4, dashIndex); // 如果没有小数点,应用原有逻辑 + return standardNo.substring(dashIndex - 3, dashIndex); // 如果没有小数点,应用原有逻辑 } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/standard/controller/LawsEnterpriseController.java b/laws-modules/src/main/java/com/jero/modules/laws/standard/controller/LawsEnterpriseController.java index bc47043f..24467f30 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/standard/controller/LawsEnterpriseController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/standard/controller/LawsEnterpriseController.java @@ -15,7 +15,6 @@ import com.jero.modules.laws.enterprise.entity.EnterpriseStandardRmrEvaluateDeta import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthDeptService; import com.jero.modules.laws.enterprise.service.EnterpriseStandardAuthUserService; import com.jero.modules.laws.enterprise.service.EnterpriseStandardReviewMeetingRecordService; -import com.jero.modules.laws.standard.entity.LawsStandardTempPermission; import com.jero.modules.laws.standard.service.ILawsNodeRelationService; import com.jero.modules.personal.service.ILawsStandardCollectionService; import com.jero.modules.split.service.ISarFileSplitInfoService; @@ -35,7 +34,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; -import java.util.Objects; /** * @Author: liao @@ -181,8 +179,6 @@ public class LawsEnterpriseController { @ApiOperationSupport(order = 9) @RequiresPermissions("enterpriseStandard:delete") public Result singleDelete(@RequestBody @ApiParam(name = "ids", value = "主键(多个用逗号分隔)") Map parameterMap) { - // 水平越权校验 - esAuthUserService.isDeleteHorizontalOverstep((String) parameterMap.get("ids")); // 检查是否在企标更改流程中,如果在流程中则不允许删除 // esChangeService.delCheck((String) parameterMap.get("ids")); // 删除标准时同步删除这个标准的收藏数据 @@ -215,24 +211,6 @@ public class LawsEnterpriseController { return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); } - @AutoLog(value = "企业法规标准-临时权限设置") - @ApiOperation(value="企业法规标准-临时权限设置", notes="企业法规标准-临时权限设置") - @PostMapping(value = "/tempPermission") - @ApiOperationSupport(order = 13) - @RequiresPermissions("enterpriseStandard:temporaryPermissSet") - @CacheEvict(value = "tempAuthRecord", allEntries = true) - public Result tempPermission(@RequestBody LawsStandardTempPermission lawsStandardTempPermission) { - String userIds = lawsStandardTempPermission.getUserIds(); - String deptIds = lawsStandardTempPermission.getDeptIds(); - if (Objects.nonNull(userIds) && !userIds.isEmpty()) { - esAuthUserService.saveTempPermission(lawsStandardTempPermission); - } - if (Objects.nonNull(deptIds) && !deptIds.isEmpty()) { - esAuthDeptService.saveTempPermission(lawsStandardTempPermission); - } - return Result.OK(); - } - /** * 企标评价 *