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

master
guoxin 1 year ago
parent d5d8dae881
commit 660cf20896
  1. 16
      shandan-browser/src/main/java/com/keyware/shandan/browser/service/MetadataSearchService.java
  2. 38
      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": case "metadataName":
if (StringUtils.hasText(item.getFieldValue())) { if (StringUtils.hasText(item.getFieldValue())) {
for (String value : item.getFieldValue().split(" ")) { 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; break;
case "markTag": case "markTag":
String tagIds = item.getFieldValue(); String tagIds = item.getFieldValue();
List<String> ids = Arrays.asList(tagIds.split(",")); 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"); 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()); List<String> andSqlList = ids.stream().map(id -> "tmp1.LABEL_IDS like '%" + id + "%'").collect(Collectors.toList());
existsSql.append(" where ").append(String.join(" and ", andSqlList)); existsSql.append(" where ").append(String.join(" and ", andSqlList));
@ -103,12 +109,12 @@ public class MetadataSearchService {
// 排序设置 // 排序设置
SearchResultSort sort = condition.getSort(); SearchResultSort sort = condition.getSort();
if(sort != null && sort.getSort() != null ){ if (sort != null && sort.getSort() != null) {
// 通过反射获取资源类字段注解中的数据库表相关的列名 // 通过反射获取资源类字段注解中的数据库表相关的列名
Field field = ReflectUtil.getField(DirectoryResource.class, sort.getField().trim()); Field field = ReflectUtil.getField(DirectoryResource.class, sort.getField().trim());
if(field != null){ if (field != null) {
TableField tableField = field.getAnnotation(TableField.class); TableField tableField = field.getAnnotation(TableField.class);
if(tableField != null && StringUtils.hasText(tableField.value())){ if (tableField != null && StringUtils.hasText(tableField.value())) {
queryWrapper.orderBy(true, sort.getSort().equalsIgnoreCase("asc"), tableField.value()); queryWrapper.orderBy(true, sort.getSort().equalsIgnoreCase("asc"), tableField.value());
} }
} }

@ -17,7 +17,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
DataLabel = layui.datalabel; DataLabel = layui.datalabel;
const tHeadSetLayer = new THeadSetLayer(layui); const tHeadSetLayer = new THeadSetLayer(layui);
let metaListTable, dirFileTable, tagSelector, tags = [], conditions = []; let metaListTable, dirFileTable, tagSelector, tags = [], conditions = [], preciseQuery = '';
const unchecked_tags = new Set(); const unchecked_tags = new Set();
// 初始化 // 初始化
initDirectoryTree(); initDirectoryTree();
@ -152,6 +152,9 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
if (_table.where.conditions && _table.where.conditions.length > 0) { if (_table.where.conditions && _table.where.conditions.length > 0) {
let formVal = form.val('search-form'); let formVal = form.val('search-form');
formVal = Object.assign(formVal, whereConditionToFormValue(_table.where)); formVal = Object.assign(formVal, whereConditionToFormValue(_table.where));
if(preciseQuery === 'eq'){
formVal['preciseQuery'] = 'eq';
}
form.val('search-form', formVal); form.val('search-form', formVal);
// $('div[lay-event="export"]').show(); // $('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}`, url: `${ctx}/search/full/file?metaId=${id}`,
height: 'full-110', height: 'full-110',
request: {pageName: 'page', limitName: 'size'}, request: {pageName: 'page', limitName: 'size'},
defaultToolbar: [ defaultToolbar: [{title: '列表配置', layEvent: 'theadSet2', icon: 'layui-icon-cols'}],
{title: '列表配置', layEvent: 'theadSet2', icon: 'layui-icon-cols'}
],
autoSort: false, autoSort: false,
limit: 30, limit: 30,
method: 'get', method: 'get',
@ -319,17 +320,26 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
, range: '至' , 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 () { $('#searchKeyInput').on('change', function () {
let value = $(this).val();
setSearchKeyCondition(value, preciseQuery === 'eq' ? 'eq' : 'like');
})
function setSearchKeyCondition(value, logic){
let where = metaListTable.where || {}; let where = metaListTable.where || {};
let conditions = where.conditions || []; let conditions = where.conditions || [];
let value = $(this).val();
conditions = conditions.filter(item => item.fieldName !== 'metadataName') conditions = conditions.filter(item => item.fieldName !== 'metadataName')
if (value && value.trim()) { 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; where.conditions = conditions;
metaListTable.where = where; metaListTable.where = where;
}) }
} }
function setMarkTagInputValue() { function setMarkTagInputValue() {
@ -364,7 +374,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
if (key === 'searchKeyInput') continue; if (key === 'searchKeyInput') continue;
let fieldName = key, fieldValue = formVal[key], logicJudgement; let fieldName = key, fieldValue = formVal[key], logicJudgement;
// 如果fieldName是条件下拉框,则跳过 // 如果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(); let hasText = fieldValue.trim();
if (hasText) { if (hasText) {
@ -565,7 +575,7 @@ class THeadSetLayer {
}) })
} }
static filterConfigData(tableId){ static filterConfigData(tableId) {
return theadConfig.filter(item => item.tableId === tableId); return theadConfig.filter(item => item.tableId === tableId);
} }
@ -583,7 +593,9 @@ class THeadSetLayer {
targetNumber: data => DICT.getText('target_type', data.targetNumber) || data.targetNumber || '', targetNumber: data => DICT.getText('target_type', data.targetNumber) || data.targetNumber || '',
secretLevel: data => DICT.getText('secret_level', data.secretLevel) || data.secretLevel || '', secretLevel: data => DICT.getText('secret_level', data.secretLevel) || data.secretLevel || '',
exerciseData: data => data.exerciseData ? '是' : '否', exerciseData: data => data.exerciseData ? '是' : '否',
resourceType: data => data.resourceType === 'file' ? '文件' : '数据库表' resourceType: data => data.resourceType === 'file' ? '文件' : '数据库表',
fileSize: data => {
}
} }
// 遍历配置项转换为列 // 遍历配置项转换为列
@ -591,7 +603,7 @@ class THeadSetLayer {
const {colName, colTitle, colWidth, isShow, isSort} = conf; const {colName, colTitle, colWidth, isShow, isSort} = conf;
const width = !colWidth ? undefined : (Number.isInteger(colWidth) ? parseInt(colWidth) : colWidth); const width = !colWidth ? undefined : (Number.isInteger(colWidth) ? parseInt(colWidth) : colWidth);
let col = {field: colName, title: colTitle, width, sort: isSort, hide: !isShow} let col = {field: colName, title: colTitle, width, sort: isSort, hide: !isShow}
if(templets[colName]){ if (templets[colName]) {
col['templet'] = templets[colName]; col['templet'] = templets[colName];
} }
return col; return col;
@ -599,9 +611,9 @@ class THeadSetLayer {
// 设置操作列 // 设置操作列
let operateCol = {fixed: 'right', title: '操作', toolbar: '', width: 100, align: 'center'}; let operateCol = {fixed: 'right', title: '操作', toolbar: '', width: 100, align: 'center'};
if(tableId === 'dirMetadataTable'){ if (tableId === 'dirMetadataTable') {
operateCol.toolbar = '#rowToolBar' operateCol.toolbar = '#rowToolBar'
}else if(tableId === 'dirFileTable'){ } else if (tableId === 'dirFileTable') {
operateCol.toolbar = '#fileRowToolBar' operateCol.toolbar = '#fileRowToolBar'
} }
cols.push(operateCol); cols.push(operateCol);

@ -90,6 +90,7 @@
<div class="layui-btn-container" <div class="layui-btn-container"
style="display: flex; justify-content: flex-start; margin-bottom: 0"> style="display: flex; justify-content: flex-start; margin-bottom: 0">
<div style="position: unset;"> <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" <input type="text" id="searchKeyInput" name="searchKeyInput"
autocomplete="off" autocomplete="off"
placeholder="请输入关键字查询" class="layui-input layui-btn-sm"> placeholder="请输入关键字查询" class="layui-input layui-btn-sm">