fix(X-Pack): 修复【数据填报】我的填报-已提交编辑数据会显示全部数据的问题

This commit is contained in:
ulleo 2024-07-10 16:01:43 +08:00
parent cc0fb330ef
commit 6c99deaaa2
2 changed files with 27 additions and 5 deletions

View File

@ -109,7 +109,16 @@ public class MysqlExtDDLProvider extends DefaultExtDDLProvider {
StringBuilder builder = new StringBuilder("WHERE 1 = 1 ");
for (TableField searchField : searchFields) {
//目前只考虑等于
builder.append("AND $Column_Field$ = ? ".replace("$Column_Field$", searchField.getFieldName()));
if (searchField.getInCount() > 1) {
List<String> pList = new ArrayList<>();
for (int i = 0; i < searchField.getInCount(); i++) {
pList.add("?");
}
String str = "AND $Column_Field$ IN (" + String.join(", ", pList) + ")";
builder.append(str.replace("$Column_Field$", searchField.getFieldName()));
} else {
builder.append("AND $Column_Field$ = ? ".replace("$Column_Field$", searchField.getFieldName()));
}
}
return builder.toString();
}

View File

@ -227,16 +227,29 @@ public class DataFillDataService {
String whereSql = "";
if (StringUtils.isNotBlank(searchRequest.getPrimaryKeyValue())) {
whereSql = extDDLProvider.whereSql(dataFillForm.getTableName(), List.of(pk));
}
String countSql = extDDLProvider.countSql(dataFillForm.getTableName(), searchFields, whereSql);
if (StringUtils.isNotBlank(searchRequest.getPrimaryKeyValue())) {
datasourceRequest.setTableFieldWithValues(List.of(new DatasourceRequest.TableFieldWithValue()
.setValue(searchRequest.getPrimaryKeyValue())
.setFiledName(pk.getFieldName())
.setTypeName(pk.getFieldType())
.setType(pk.getType())));
}
if (CollectionUtils.isNotEmpty(searchRequest.getPrimaryKeyValueList())) {
pk.setInCount(searchRequest.getPrimaryKeyValueList().size());
whereSql = extDDLProvider.whereSql(dataFillForm.getTableName(), List.of(pk));
List<DatasourceRequest.TableFieldWithValue> ids = new ArrayList<>();
for (String s : searchRequest.getPrimaryKeyValueList()) {
ids.add(new DatasourceRequest.TableFieldWithValue()
.setValue(s)
.setFiledName(pk.getFieldName())
.setTypeName(pk.getFieldType())
.setType(pk.getType()));
}
datasourceRequest.setTableFieldWithValues(ids);
}
String countSql = extDDLProvider.countSql(dataFillForm.getTableName(), searchFields, whereSql);
datasourceRequest.setQuery(countSql);
List<String[]> countData = datasourceProvider.getData(datasourceRequest);
long count = NumberUtils.toLong(countData.get(0)[0]);