From 4a4176c908fcdd4b0c6c7999de3e9eace69b75ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Sun, 10 Dec 2023 11:26:16 +0800 Subject: [PATCH] fix:79097,79038 --- .../laws/common/constant/FieldCommon.java | 9 ++ .../service/impl/LawsCommonServiceImpl.java | 116 +++++++++++++----- 2 files changed, 94 insertions(+), 31 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 324cf755..8513940a 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 @@ -200,5 +200,14 @@ public class FieldCommon { public static final String ACQUISITION_DEGREE = "acquisition_degree"; // 采用国际标准号 public static final String INTERNATIONAL_STANDARD_NUM = "international_standard_num"; + // 主起草人 + public static final String MAIN_DRAFTING_USER = "main_drafting_user"; + // 主起草部门负责人 + public static final String MAIN_DRAFTING_UNIT_RESPONSIBLE_PERSON = "main_drafting_unit_responsible_person"; + // 标准推进人 + public static final String STANDARD_PROMOTER = "standard_promoter"; + + // 责任部门负责人 + public static final String RESPONSIBLE_DEPARTMENT_USER = "responsible_department_user"; } 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 efacfb07..f603e409 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 @@ -1,6 +1,7 @@ package com.jero.modules.laws.common.service.impl; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -65,6 +66,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.shiro.SecurityUtils; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -171,6 +173,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService { List fieldListCondition; // 首页高级检索使用 if(parameterMap.containsKey("home_search_key")){ + parameterMap.remove("home_search_key"); fieldListSelect = fieldList; fieldListCondition = fieldList.stream().filter(lawsTag -> Objects.equals(YesOrNoEnum.YES.getValue(), lawsTag.getIsShowSearch().toString())).collect(Collectors.toList()); @@ -1863,6 +1866,8 @@ public class LawsCommonServiceImpl implements ILawsCommonService { **/ private String getSelectCondition(Map parameterMap, List fieldList) { String module = (String) parameterMap.get("module"); + // 获取要操作的表名 + String tableName = TableNameEnum.getTableName(module); //查询条件 StringBuilder selectCondition = new StringBuilder("where 1 = 1"); // 拼接多表关联查询条件 @@ -1899,45 +1904,53 @@ public class LawsCommonServiceImpl implements ILawsCommonService { String replaceStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD); LambdaQueryWrapper replaceWrapper = new LambdaQueryWrapper<>(); if (StrUtil.isNotBlank(replaceStandard)) { - standNoSearch = true; +// standNoSearch = true; 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); - standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet())); +// standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplaced, s)); +// standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 1)); +// List replaceList = lawsReplacedStandardService.list(replaceWrapper); +// standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet())); + String sql = getLawsReplacedStandardSql(tableName, standardNo, " replaced ", "1"); + selectCondition.append(sql); parameterMap.remove(FieldCommon.REPLACED_STANDARD); } // 被代替标准号 String replacedByStandard = (String) parameterMap.get(FieldCommon.REPLACED_BY_STANDARD); if (StrUtil.isNotBlank(replacedByStandard)) { - standNoSearch = true; +// standNoSearch = true; 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); - standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplaced).collect(Collectors.toSet())); +// standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplacedBy, s)); +// standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 1)); +// List replaceList = lawsReplacedStandardService.list(replaceWrapper); +// standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplaced).collect(Collectors.toSet())); + String sql = getLawsReplacedStandardSql(tableName, standardNo, " replaced_by ", "2"); + selectCondition.append(sql); parameterMap.remove(FieldCommon.REPLACED_BY_STANDARD); } // 引用标准号 String referenceStandard = (String) parameterMap.get(FieldCommon.REFERENCE_STANDARD); if (StrUtil.isNotBlank(referenceStandard)) { - standNoSearch = true; +// standNoSearch = true; 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); - standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet())); +// standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplaced, s)); +// standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 2)); +// List replaceList = lawsReplacedStandardService.list(replaceWrapper); +// standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet())); + String sql = getLawsReplacedStandardSql(tableName, standardNo, " replaced ", "1"); + selectCondition.append(sql); parameterMap.remove(FieldCommon.REFERENCE_STANDARD); } // 被引用标准号 String referencedStandard = (String) parameterMap.get(FieldCommon.REFERENCED_STANDARD); if (StrUtil.isNotBlank(referencedStandard)) { - standNoSearch = true; +// standNoSearch = true; 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); - standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplaced).collect(Collectors.toSet())); +// standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplacedBy, s)); +// standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 2)); +// List replaceList = lawsReplacedStandardService.list(replaceWrapper); +// standNoSet.addAll(replaceList.stream().map(LawsReplacedStandard::getReplaced).collect(Collectors.toSet())); + String sql = getLawsReplacedStandardSql(tableName, standardNo, " replaced_by ", "2"); + selectCondition.append(sql); parameterMap.remove(FieldCommon.REFERENCED_STANDARD); } @@ -1962,6 +1975,16 @@ public class LawsCommonServiceImpl implements ILawsCommonService { selectCondition.append(sql).append(")"); parameterMap.remove(FieldCommon.BIDDING_COMMITTEE); } + // 主起草人 + getSysUserSql(parameterMap, tableName, selectCondition, FieldCommon.MAIN_DRAFTING_USER); + // 主起草部门负责人 + getSysUserSql(parameterMap, tableName, selectCondition, FieldCommon.MAIN_DRAFTING_UNIT_RESPONSIBLE_PERSON); + // 标准推进人 + getSysUserSql(parameterMap, tableName, selectCondition, FieldCommon.STANDARD_PROMOTER); + // 责任部门负责人 + getSysUserSql(parameterMap, tableName, selectCondition, FieldCommon.RESPONSIBLE_DEPARTMENT_USER); + + if (idSearch) { String idSql = idSet.stream() .map(item -> "'" + item + "'") @@ -1973,17 +1996,17 @@ public class LawsCommonServiceImpl implements ILawsCommonService { } selectCondition.append(idSql).append(")"); } - if (standNoSearch) { - String noSql = standNoSet.stream() - .map(item -> "'" + item + "'") - .collect(Collectors.joining(",")); - // 拼接SQL - selectCondition.append(" AND standard_number IN ("); - if (StrUtil.isBlank(noSql)) { - noSql = "''"; - } - selectCondition.append(noSql).append(")"); - } +// if (standNoSearch) { +// String noSql = standNoSet.stream() +// .map(item -> "'" + item + "'") +// .collect(Collectors.joining(",")); +// // 拼接SQL +// selectCondition.append(" AND standard_number IN ("); +// if (StrUtil.isBlank(noSql)) { +// noSql = "''"; +// } +// selectCondition.append(noSql).append(")"); +// } selectCondition.append(" AND del_flag = 0"); // 删除pageNo和pageSize,不参与条件查询 @@ -2038,6 +2061,37 @@ public class LawsCommonServiceImpl implements ILawsCommonService { return selectCondition.toString(); } + private void getSysUserSql(Map parameterMap, String tableName, StringBuilder selectCondition, String field) { + String mainDraftingUser = (String) parameterMap.get(field); + if (CharSequenceUtil.isNotBlank(mainDraftingUser)) { + List strData = Arrays.asList(mainDraftingUser.split(",")); + StringBuilder str = new StringBuilder(); + for (int i = 0; i < strData.size(); i++) { + str.append("realname").append(" like '%").append(strData.get(i)).append("%' "); + if (i != strData.size() - 1) { + str.append(" and "); + } + } + String sql = "and exists (select id from sys_user where " + tableName + "." + field + " = id" + + " and del_flag = 0 and " + str + ")"; + selectCondition.append(sql); + parameterMap.remove(field); + } + } + + @NotNull + private String getLawsReplacedStandardSql(String tableName, List standardNo, String replaced, String type) { + StringBuilder str = new StringBuilder(); + for (int i = 0; i < standardNo.size(); i++) { + str.append(replaced).append(" like '%").append(standardNo.get(i)).append("%' "); + if (i != standardNo.size() - 1) { + str.append(" and "); + } + } + return "and exists (select id from laws_replaced_standard where " + tableName + ".standard_number = replaced" + + " and type = " + type + " and " + str + ")"; + } + /** * @Author: liao * @Date: 2023/8/22 11:41