feat: 代替被代替搜索
This commit is contained in:
+57
-15
@@ -754,7 +754,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 将更新数据库的标准体系字段设置为空
|
||||
parameterMap.put(FieldCommon.STANDARD_SYSTEM, "");
|
||||
// 处理新增和编辑时的代替标准、引用标准
|
||||
processReplaced(parameterMap, standardNumber);
|
||||
processReplaced(parameterMap, standardNumber, module);
|
||||
|
||||
// 获取要操作的表名
|
||||
String tableName = TableNameEnum.getTableName(module);
|
||||
@@ -929,7 +929,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
String standardNumber = singleStandard.getStandardNumber();
|
||||
|
||||
// 处理新增和编辑时的代替标准、引用标准
|
||||
processReplaced(parameterMap, standardNumber);
|
||||
processReplaced(parameterMap, standardNumber, module);
|
||||
// 处理零部件
|
||||
processPartName(parameterMap, id);
|
||||
|
||||
@@ -1026,9 +1026,11 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
* @Date: 2023/9/19 11:53
|
||||
* @Description: 处理新增和编辑时的代替标准、引用标准
|
||||
**/
|
||||
private void processReplaced(Map<String, Object> parameterMap, String standardNumber) {
|
||||
private void processReplaced(Map<String, Object> parameterMap, String standardNumber, String module) {
|
||||
// 代替标准
|
||||
String replacedStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD);
|
||||
// 获取标准状态
|
||||
String standardState = (String) parameterMap.get(FieldCommon.STANDARD_STATE);
|
||||
// 先删除已经存储的关联
|
||||
lawsReplacedStandardService.removeRelation(standardNumber, 1);
|
||||
if (StringUtils.isNotBlank(replacedStandard)) {
|
||||
@@ -2122,7 +2124,9 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
StringBuilder selectCondition = new StringBuilder("where 1 = 1");
|
||||
// 拼接多表关联查询条件
|
||||
Set<String> idSet = new HashSet<>();
|
||||
Set<String> snSet = new HashSet<>();
|
||||
boolean idSearch = false;
|
||||
boolean standardNumberSearch = false;
|
||||
// 体系
|
||||
String standardSystem = (String) parameterMap.get(FieldCommon.STANDARD_SYSTEM);
|
||||
if (StrUtil.isNotBlank(standardSystem)) {
|
||||
@@ -2137,33 +2141,59 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
// 代替标准号
|
||||
String replaceStandard = (String) parameterMap.get(FieldCommon.REPLACED_STANDARD);
|
||||
if (StrUtil.isNotBlank(replaceStandard)) {
|
||||
List<String> standardNo = Arrays.asList(replaceStandard.split(","));
|
||||
String sql = getLawsReplacedStandardSql(tableName, standardNo, " replaced ", "1");
|
||||
selectCondition.append(sql);
|
||||
standardNumberSearch = true;
|
||||
LambdaQueryWrapper<LawsReplacedStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.like(LawsReplacedStandard::getReplaced, replaceStandard);
|
||||
lambdaQueryWrapper.eq(LawsReplacedStandard::getType, "1");
|
||||
List<LawsReplacedStandard> replacedStandardList = lawsReplacedStandardService.list(lambdaQueryWrapper);
|
||||
snSet.addAll(replacedStandardList.stream().map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet()));
|
||||
parameterMap.remove(FieldCommon.REPLACED_STANDARD);
|
||||
}
|
||||
// 被代替标准号
|
||||
String replacedByStandard = (String) parameterMap.get(FieldCommon.REPLACED_BY_STANDARD);
|
||||
if (StrUtil.isNotBlank(replacedByStandard)) {
|
||||
List<String> standardNo = Arrays.asList(replacedByStandard.split(","));
|
||||
String sql = getLawsReplacedByStandardSql(tableName, standardNo, " replaced_by ", "1");
|
||||
selectCondition.append(sql);
|
||||
standardNumberSearch = true;
|
||||
LambdaQueryWrapper<LawsReplacedStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.like(LawsReplacedStandard::getReplacedBy, replacedByStandard);
|
||||
lambdaQueryWrapper.eq(LawsReplacedStandard::getType, "1");
|
||||
List<LawsReplacedStandard> standardList = lawsReplacedStandardService.list(lambdaQueryWrapper);
|
||||
snSet.addAll(standardList.stream().map(s -> {
|
||||
// 如果有书名号则只取书名号的前半部分
|
||||
if (s.getReplaced().contains("《")) {
|
||||
return s.getReplaced().substring(0, s.getReplaced().indexOf("《"));
|
||||
} else {
|
||||
return s.getReplaced();
|
||||
}
|
||||
}).collect(Collectors.toSet()));
|
||||
parameterMap.remove(FieldCommon.REPLACED_BY_STANDARD);
|
||||
}
|
||||
// 引用标准号
|
||||
String referenceStandard = (String) parameterMap.get(FieldCommon.REFERENCE_STANDARD);
|
||||
if (StrUtil.isNotBlank(referenceStandard)) {
|
||||
List<String> standardNo = Arrays.asList(referenceStandard.split(","));
|
||||
String sql = getLawsReplacedStandardSql(tableName, standardNo, " replaced ", "2");
|
||||
selectCondition.append(sql);
|
||||
standardNumberSearch = true;
|
||||
LambdaQueryWrapper<LawsReplacedStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.like(LawsReplacedStandard::getReplaced, referenceStandard);
|
||||
lambdaQueryWrapper.eq(LawsReplacedStandard::getType, "2");
|
||||
List<LawsReplacedStandard> replacedStandardList = lawsReplacedStandardService.list(lambdaQueryWrapper);
|
||||
snSet.addAll(replacedStandardList.stream().map(LawsReplacedStandard::getReplacedBy).collect(Collectors.toSet()));
|
||||
parameterMap.remove(FieldCommon.REFERENCE_STANDARD);
|
||||
}
|
||||
// 被引用标准号
|
||||
String referencedStandard = (String) parameterMap.get(FieldCommon.REFERENCED_STANDARD);
|
||||
if (StrUtil.isNotBlank(referencedStandard)) {
|
||||
List<String> standardNo = Arrays.asList(referencedStandard.split(","));
|
||||
String sql = getLawsReplacedByStandardSql(tableName, standardNo, " replaced_by ", "2");
|
||||
selectCondition.append(sql);
|
||||
standardNumberSearch = true;
|
||||
LambdaQueryWrapper<LawsReplacedStandard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.like(LawsReplacedStandard::getReplacedBy, referencedStandard);
|
||||
lambdaQueryWrapper.eq(LawsReplacedStandard::getType, "2");
|
||||
List<LawsReplacedStandard> standardList = lawsReplacedStandardService.list(lambdaQueryWrapper);
|
||||
snSet.addAll(standardList.stream().map(s -> {
|
||||
// 如果有书名号则只取书名号的前半部分
|
||||
if (s.getReplaced().contains("《")) {
|
||||
return s.getReplaced().substring(0, s.getReplaced().indexOf("《"));
|
||||
} else {
|
||||
return s.getReplaced();
|
||||
}
|
||||
}).collect(Collectors.toSet()));
|
||||
parameterMap.remove(FieldCommon.REFERENCED_STANDARD);
|
||||
}
|
||||
// 零部件名称
|
||||
@@ -2185,6 +2215,18 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}
|
||||
selectCondition.append(idSql).append(")");
|
||||
}
|
||||
|
||||
if (standardNumberSearch) {
|
||||
String snSql = snSet.stream()
|
||||
.map(item -> "'" + item + "'")
|
||||
.collect(Collectors.joining(","));
|
||||
// 拼接SQL
|
||||
selectCondition.append(" AND standard_number IN (");
|
||||
if (StrUtil.isBlank(snSql)) {
|
||||
snSql = "''";
|
||||
}
|
||||
selectCondition.append(snSql).append(")");
|
||||
}
|
||||
selectCondition.append(" AND del_flag = 0");
|
||||
|
||||
// 删除pageNo和pageSize,不参与条件查询
|
||||
|
||||
Reference in New Issue
Block a user