fix:79097,79038

This commit is contained in:
梁琦涛
2023-12-10 11:26:16 +08:00
parent 4092c6125a
commit 4a4176c908
2 changed files with 94 additions and 31 deletions
@@ -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";
}
@@ -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<LawsTag> 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<String, Object> parameterMap, List<LawsTag> 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<LawsReplacedStandard> replaceWrapper = new LambdaQueryWrapper<>();
if (StrUtil.isNotBlank(replaceStandard)) {
standNoSearch = true;
// standNoSearch = true;
List<String> standardNo = Arrays.asList(replaceStandard.split(","));
standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplaced, s));
standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 1));
List<LawsReplacedStandard> 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<LawsReplacedStandard> 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<String> standardNo = Arrays.asList(replacedByStandard.split(","));
standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplacedBy, s));
standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 1));
List<LawsReplacedStandard> 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<LawsReplacedStandard> 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<String> standardNo = Arrays.asList(referenceStandard.split(","));
standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplaced, s));
standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 2));
List<LawsReplacedStandard> 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<LawsReplacedStandard> 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<String> standardNo = Arrays.asList(referencedStandard.split(","));
standardNo.forEach(s -> replaceWrapper.like(LawsReplacedStandard::getReplacedBy, s));
standardNo.forEach(s -> replaceWrapper.eq(LawsReplacedStandard::getType, 2));
List<LawsReplacedStandard> 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<LawsReplacedStandard> 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<String, Object> parameterMap, String tableName, StringBuilder selectCondition, String field) {
String mainDraftingUser = (String) parameterMap.get(field);
if (CharSequenceUtil.isNotBlank(mainDraftingUser)) {
List<String> 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<String> 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