From 256c59555e2a5dffdd6d127a519d4f0944b80e7f Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 14 五月 2025 16:29:38 +0800
Subject: [PATCH] #物料表动态字段搜索
---
rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java | 34 ++++++++++++++++
rsf-server/src/main/java/com/vincent/rsf/server/common/domain/BaseParam.java | 23 +++++++++++
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java | 1
rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx | 10 +++++
rsf-server/src/main/java/com/vincent/rsf/server/common/domain/PageParam.java | 2 +
5 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
index fa639b7..ff9084c 100644
--- a/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
+++ b/rsf-admin/src/page/basicInfo/matnr/MatnrList.jsx
@@ -210,6 +210,16 @@
<PrintButton />
</WrapperField>
setColumns([...arr, ...fields, opt]);
+ //filters娣诲姞杩囨护瀛楁
+ data.map(el => {
+ var i =0;
+ filters.map((item) =>{
+ if(item.key === el.fields){
+ i = 1;
+ }
+ })
+ i===0 && filters.push(<TextInput key={el.fields} source={el.fields} label={el.fieldsAlise} />)
+ })
} else {
notify(msg);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/BaseParam.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/BaseParam.java
index e39e208..6ee5310 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/BaseParam.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/BaseParam.java
@@ -1,10 +1,16 @@
package com.vincent.rsf.server.common.domain;
import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.vincent.rsf.common.utils.Utils;
+import com.vincent.rsf.framework.common.SpringUtils;
+import com.vincent.rsf.server.system.entity.Fields;
+import com.vincent.rsf.server.system.service.FieldsService;
import lombok.Data;
import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -36,6 +42,9 @@
@TableField(exist = false)
private Map<String, Object> map;
+
+ @TableField(exist = false)
+ private Map<String, Object> fields = new HashMap<>();
public void syncMap(Map<String, Object> map) {
if (null == map) {
@@ -69,6 +78,20 @@
this.setCondition(String.valueOf(map.get("condition")));
map.remove("condition");
}
+
+ FieldsService fieldsService = SpringUtils.getBean(FieldsService.class);
+ List<Fields> fields = fieldsService.list(new LambdaQueryWrapper<Fields>().eq(Fields::getFlagEnable, 1).eq(Fields::getStatus, 1));
+ if (!fields.isEmpty()) {
+ for (Fields fields1 : fields) {
+ if (null !=map.get(fields1.getFields())){
+ this.fields.put(fields1.getFields(), map.get(fields1.getFields()));
+ map.entrySet().removeIf(next -> next.getKey().equals(fields1.getFields())
+ );
+ }
+ }
+
+ }
+
this.setMap(map);
}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/PageParam.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/PageParam.java
index e116812..b513578 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/PageParam.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/domain/PageParam.java
@@ -7,6 +7,7 @@
import com.vincent.rsf.common.utils.Utils;
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.DateUtils;
+import lombok.Getter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -21,6 +22,7 @@
private static final long serialVersionUID = 1L;
public static final String ORDER_DESC_VALUE = "desc";
+ @Getter
private final U where;
/**
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
index 46490ab..039e485 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/common/utils/FieldsUtils.java
@@ -1,8 +1,14 @@
package com.vincent.rsf.server.common.utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.SpringUtils;
import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.common.domain.BaseParam;
+import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.system.entity.Fields;
import com.vincent.rsf.server.system.entity.FieldsItem;
import com.vincent.rsf.server.system.service.FieldsItemService;
@@ -174,4 +180,30 @@
saveFields(params, params.get("index").toString());
}
}
-}
+
+ public static <T> QueryWrapper<T> setFieldsFilters(QueryWrapper<T> queryWrapper, PageParam<T, BaseParam> pageParam, Class<T> entityClass) {
+ // 鍔ㄦ�佽幏鍙栬〃鍚�
+ TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
+ String tableName = tableInfo.getTableName();
+
+ FieldsService fieldsService = SpringUtils.getBean(FieldsService.class);
+ Map<String, Object> map = pageParam.getWhere().getFields();
+
+ for (String key : map.keySet()) {
+ Object val = map.get(key);
+ Fields fields = fieldsService.getOne(new LambdaQueryWrapper<Fields>().eq(Fields::getFields, key));
+ if (!Cools.isEmpty(fields)) {
+ String applySql = String.format(
+ "EXISTS (SELECT 1 FROM sys_fields_item fie " +
+ "WHERE %s.fields_index IS NOT NULL " +
+ "AND fie.uuid = %s.fields_index " +
+ "AND fie.fields_id = '%s' " +
+ "AND fie.value = '%s')",
+ tableName, tableName, fields.getId(), val
+ );
+ queryWrapper.apply(applySql);
+ }
+ }
+ return queryWrapper;
+ }
+}
\ No newline at end of file
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
index 6c5fa1b..52bc2c6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/MatnrServiceImpl.java
@@ -119,6 +119,7 @@
}
}
}
+ FieldsUtils.setFieldsFilters(queryWrapper,pageParam,Matnr.class);
/**鎷兼帴鎵╁睍瀛楁*/
PageParam<Matnr, BaseParam> page = this.page(pageParam, queryWrapper);
List<Matnr> records = page.getRecords();
--
Gitblit v1.9.1