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