增加:综合浏览资源查询增加全字符匹配

master
guoxin 1 year ago
parent d5d8dae881
commit 660cf20896
  1. 10
      shandan-browser/src/main/java/com/keyware/shandan/browser/service/MetadataSearchService.java
  2. 30
      shandan-browser/src/main/resources/static/js/browser.js
  3. 1
      shandan-browser/src/main/resources/view/browser.html

@ -81,14 +81,20 @@ public class MetadataSearchService {
case "metadataName":
if (StringUtils.hasText(item.getFieldValue())) {
for (String value : item.getFieldValue().split(" ")) {
wrapper.and(StringUtils.hasText(value.trim()), qw -> qw.like("RESOURCE_NAME", value.trim()).or().like("RESOURCE_COMMENT", value.trim()));
wrapper.and(StringUtils.hasText(value.trim()), qw -> {
if ("eq".equals(item.getLogicJudgement())) {
qw.eq("RESOURCE_NAME", value.trim())/*.or().eq("RESOURCE_COMMENT", value.trim())*/;
}else{
qw.like("RESOURCE_NAME", value.trim())/*.or().like("RESOURCE_COMMENT", value.trim())*/;
}
});
}
}
break;
case "markTag":
String tagIds = item.getFieldValue();
List<String> ids = Arrays.asList(tagIds.split(","));
if (ids.size() > 0) {
if (!ids.isEmpty()) {
StringBuilder existsSql = new StringBuilder("select 1 from (select ENTITY_ID, WM_CONCAT(LABEL_ID) LABEL_IDS from B_DATA_LABEL_ENTITY DLN where DLN.ENTITY_ID = V_DIRECTORY_RESOURCE.ID group by ENTITY_ID) tmp1");
List<String> andSqlList = ids.stream().map(id -> "tmp1.LABEL_IDS like '%" + id + "%'").collect(Collectors.toList());
existsSql.append(" where ").append(String.join(" and ", andSqlList));

@ -17,7 +17,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
DataLabel = layui.datalabel;
const tHeadSetLayer = new THeadSetLayer(layui);
let metaListTable, dirFileTable, tagSelector, tags = [], conditions = [];
let metaListTable, dirFileTable, tagSelector, tags = [], conditions = [], preciseQuery = '';
const unchecked_tags = new Set();
// 初始化
initDirectoryTree();
@ -152,6 +152,9 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
if (_table.where.conditions && _table.where.conditions.length > 0) {
let formVal = form.val('search-form');
formVal = Object.assign(formVal, whereConditionToFormValue(_table.where));
if(preciseQuery === 'eq'){
formVal['preciseQuery'] = 'eq';
}
form.val('search-form', formVal);
// $('div[lay-event="export"]').show();
}
@ -219,9 +222,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
url: `${ctx}/search/full/file?metaId=${id}`,
height: 'full-110',
request: {pageName: 'page', limitName: 'size'},
defaultToolbar: [
{title: '列表配置', layEvent: 'theadSet2', icon: 'layui-icon-cols'}
],
defaultToolbar: [{title: '列表配置', layEvent: 'theadSet2', icon: 'layui-icon-cols'}],
autoSort: false,
limit: 30,
method: 'get',
@ -319,17 +320,26 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
, range: '至'
});
form.on('checkbox(precise-query)', function ({value, othis}) {
preciseQuery = othis.hasClass('layui-form-checked') ? value : '';
setSearchKeyCondition($('#searchKeyInput').val(), preciseQuery === 'eq' ? 'eq' : 'like');
});
$('#searchKeyInput').on('change', function () {
let value = $(this).val();
setSearchKeyCondition(value, preciseQuery === 'eq' ? 'eq' : 'like');
})
function setSearchKeyCondition(value, logic){
let where = metaListTable.where || {};
let conditions = where.conditions || [];
let value = $(this).val();
conditions = conditions.filter(item => item.fieldName !== 'metadataName')
if (value && value.trim()) {
conditions.push({fieldName: 'metadataName', fieldValue: value.trim(), logicJudgement: 'like'})
conditions.push({fieldName: 'metadataName', fieldValue: value.trim(), logicJudgement: logic})
}
where.conditions = conditions;
metaListTable.where = where;
})
}
}
function setMarkTagInputValue() {
@ -364,7 +374,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
if (key === 'searchKeyInput') continue;
let fieldName = key, fieldValue = formVal[key], logicJudgement;
// 如果fieldName是条件下拉框,则跳过
if (fieldName.startsWith('logic-') || fieldName === 'directoryId' || fieldName === 'metadataId') continue;
if (fieldName.startsWith('logic-') || fieldName === 'directoryId' || fieldName === 'metadataId' || fieldName === 'preciseQuery') continue;
let hasText = fieldValue.trim();
if (hasText) {
@ -583,7 +593,9 @@ class THeadSetLayer {
targetNumber: data => DICT.getText('target_type', data.targetNumber) || data.targetNumber || '',
secretLevel: data => DICT.getText('secret_level', data.secretLevel) || data.secretLevel || '',
exerciseData: data => data.exerciseData ? '是' : '否',
resourceType: data => data.resourceType === 'file' ? '文件' : '数据库表'
resourceType: data => data.resourceType === 'file' ? '文件' : '数据库表',
fileSize: data => {
}
}
// 遍历配置项转换为列

@ -90,6 +90,7 @@
<div class="layui-btn-container"
style="display: flex; justify-content: flex-start; margin-bottom: 0">
<div style="position: unset;">
<input type="checkbox" name="preciseQuery" title="全字符匹配" lay-skin="primary" value="eq" lay-filter="precise-query">
<input type="text" id="searchKeyInput" name="searchKeyInput"
autocomplete="off"
placeholder="请输入关键字查询" class="layui-input layui-btn-sm">