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 d0cbccfa..ff2351e2 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 @@ -1861,8 +1861,108 @@ public class LawsCommonServiceImpl implements ILawsCommonService { * @Description: 封装查询条件 **/ private String getSelectCondition(Map parameterMap, List fieldList) { + String module = (String) parameterMap.get("module"); //查询条件 - StringBuilder selectCondition = new StringBuilder("where del_flag = 0"); + StringBuilder selectCondition = new StringBuilder("where 1 = 1"); + // 拼接多表关联查询条件 + Set idSet = new HashSet<>(); + Set standNoSet = new HashSet<>(); + // 企标独有权限 + if (module.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue())) { + // 授权部门 + String authDept = (String) parameterMap.get(FieldCommon.AUTH_DEPT); + if (StrUtil.isNotBlank(authDept)) { + LambdaQueryWrapper authDeptWrapper = new LambdaQueryWrapper<>(); + List authDeptIdList = Arrays.asList(authDept.split(",")); + authDeptWrapper.in(EnterpriseStandardAuthDept::getAuthDept, authDeptIdList); + List authList = enterpriseAuthDeptService.list(authDeptWrapper); + String sql = authList.stream() + .map(item -> "'" + item.getStandardId() + "'") + .collect(Collectors.joining(",")); + // 拼接SQL + selectCondition.append(" AND id IN ("); + if (StrUtil.isBlank(sql)) { + sql = "''"; + } + selectCondition.append(sql).append(")"); + parameterMap.remove(FieldCommon.AUTH_DEPT); + } + } + // 代替标准号 + String replaceStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD); + LambdaQueryWrapper replaceWrapper = new LambdaQueryWrapper<>(); + if (StrUtil.isNotBlank(replaceStandard)) { + List standardNo = Arrays.asList(replaceStandard.split(",")); + standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplaced, s)); + standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 1)); + List replaceList = lawsReplacedStandardService.list(replaceWrapper); + String sql = replaceList.stream() + .map(item -> "'" + item.getReplacedBy() + "'") + .collect(Collectors.joining(",")); + // 拼接SQL + selectCondition.append(" AND standard_number IN ("); + if (StrUtil.isBlank(sql)) { + sql = "''"; + } + selectCondition.append(sql).append(")"); + parameterMap.remove(FieldCommon.REPLACED_STANDARD); + } + // 被代替标准号 + String replacedByStandard = (String) parameterMap.get(FieldCommon.REPLACED_BY_STANDARD); + if (StrUtil.isNotBlank(replacedByStandard)) { + List standardNo = Arrays.asList(replacedByStandard.split(",")); + standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplacedBy, s)); + standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 1)); + List replaceList = lawsReplacedStandardService.list(replaceWrapper); + String sql = replaceList.stream() + .map(item -> "'" + item.getReplaced() + "'") + .collect(Collectors.joining(",")); + // 拼接SQL + selectCondition.append(" AND standard_number IN ("); + if (StrUtil.isBlank(sql)) { + sql = "''"; + } + selectCondition.append(sql).append(")"); + parameterMap.remove(FieldCommon.REPLACED_BY_STANDARD); + } + // 引用标准号 + String referenceStandard = (String) parameterMap.get(FieldCommon.REFERENCE_STANDARD); + if (StrUtil.isNotBlank(referenceStandard)) { + List standardNo = Arrays.asList(referenceStandard.split(",")); + standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplaced, s)); + standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 2)); + List replaceList = lawsReplacedStandardService.list(replaceWrapper); + String sql = replaceList.stream() + .map(item -> "'" + item.getReplacedBy() + "'") + .collect(Collectors.joining(",")); + // 拼接SQL + selectCondition.append(" AND standard_number IN ("); + if (StrUtil.isBlank(sql)) { + sql = "''"; + } + selectCondition.append(sql).append(")"); + parameterMap.remove(FieldCommon.REFERENCE_STANDARD); + } + // 被引用标准号 + String referencedStandard = (String) parameterMap.get(FieldCommon.REFERENCED_STANDARD); + if (StrUtil.isNotBlank(referencedStandard)) { + List standardNo = Arrays.asList(referencedStandard.split(",")); + standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplacedBy, s)); + standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 2)); + List replaceList = lawsReplacedStandardService.list(replaceWrapper); + String sql = replaceList.stream() + .map(item -> "'" + item.getReplaced() + "'") + .collect(Collectors.joining(",")); + // 拼接SQL + selectCondition.append(" AND standard_number IN ("); + if (StrUtil.isBlank(sql)) { + sql = "''"; + } + selectCondition.append(sql).append(")"); + parameterMap.remove(FieldCommon.REFERENCED_STANDARD); + } + selectCondition.append(" AND del_flag = 0"); + // 删除pageNo和pageSize,不参与条件查询 parameterMap.remove("pageNo"); parameterMap.remove("pageSize");