fix(文档拆分): 动态字段排序完善
This commit is contained in:
+4
@@ -24,6 +24,10 @@ public class DocumentSplitCommon {
|
||||
* 日期格式化
|
||||
*/
|
||||
public static final String DATE_FORMAT_END = " , '%Y-%m-%d') ";
|
||||
/**
|
||||
* 字符转日期
|
||||
*/
|
||||
public static final String STR_TO_DATE_BEGIN = "str_to_date(";
|
||||
/**
|
||||
* between
|
||||
*/
|
||||
|
||||
+29
-9
@@ -169,7 +169,8 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
String selectColumn = getSelectColumn(fieldListSelect);
|
||||
// sql where条件拼接
|
||||
String selectCondition = getSelectCondition(parameter, fieldListCondition);
|
||||
|
||||
// 排序
|
||||
selectCondition = orderBy(parameter, selectCondition, fieldListSelect);
|
||||
// 查询数据
|
||||
IPage<Map<String, Object>> mapIPage = documentSplitMapper.queryDocumentSplitDetail(new Page<>(pageNo, pageSize), selectColumn, selectCondition);
|
||||
// 翻译
|
||||
@@ -177,6 +178,31 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
return mapIPage;
|
||||
}
|
||||
|
||||
private String orderBy(Map<String, Object> parameter, String selectCondition, List<LawsTag> fieldListSelect) {
|
||||
StringBuilder sb = new StringBuilder(selectCondition);
|
||||
if (parameter.containsKey("column")){
|
||||
sb.append(" order by ");
|
||||
String column = (String) parameter.get("column");
|
||||
String order = (String) parameter.get("order");
|
||||
// 匹配参数和字段
|
||||
Optional<LawsTag> lawsTag = fieldListSelect.stream().filter(o -> column.equals(o.getDbFieldName())).findFirst();
|
||||
lawsTag.ifPresent(l -> {
|
||||
// 多日期特殊处理
|
||||
if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())){
|
||||
sb.append(DocumentSplitCommon.STR_TO_DATE_BEGIN + "substring_index(")
|
||||
.append(l.getDbFieldName()).append(", ',', -1)").append(",'%Y-%m-%d')");
|
||||
}else {
|
||||
sb.append(column);
|
||||
}
|
||||
});
|
||||
sb.append(" ").append(order);
|
||||
}else {
|
||||
// 默认排序
|
||||
sb.append(" order by display_seq asc, sort_number is null, sort_number asc");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> queryDocumentSplitDetailByList(Map<String, Object> parameter) {
|
||||
// 查询全部字段列表
|
||||
@@ -192,7 +218,8 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
String selectColumn = getSelectColumn(fieldListSelect);
|
||||
// sql where条件拼接
|
||||
String selectCondition = getSelectCondition(parameter, fieldListCondition);
|
||||
|
||||
// 排序
|
||||
selectCondition = orderBy(parameter, selectCondition, fieldListSelect);
|
||||
// 查询数据
|
||||
List<Map<String, Object>> list = documentSplitMapper.queryDocumentSplitDetail(selectColumn, selectCondition);
|
||||
// 翻译
|
||||
@@ -439,7 +466,6 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
String selectCondition = "where del_flag = 0 and s.id in ('" + String.join("','", idList) + "')";
|
||||
// 排序
|
||||
StringBuilder strSelectCondition = new StringBuilder(selectCondition);
|
||||
orderBy(strSelectCondition);
|
||||
// 查询数据
|
||||
List<Map<String, Object>> listMap = documentSplitMapper.queryDocumentSplitDetail(selectColumn, strSelectCondition.toString());
|
||||
// 第一条数据
|
||||
@@ -945,15 +971,9 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
defaultCondition(parameter, selectCondition);
|
||||
// 动态查询字段
|
||||
dynamicStateCondition(parameter, fieldListCondition, selectCondition);
|
||||
// 排序
|
||||
orderBy(selectCondition);
|
||||
return selectCondition.toString();
|
||||
}
|
||||
|
||||
private void orderBy(StringBuilder selectCondition) {
|
||||
selectCondition.append(" order by display_seq asc, sort_number is null, sort_number asc");
|
||||
}
|
||||
|
||||
private void dynamicStateCondition(Map<String, Object> parameter, List<LawsTag> fieldListCondition, StringBuilder selectCondition) {
|
||||
parameter.forEach((k, v) -> {
|
||||
// 匹配参数和字段
|
||||
|
||||
Reference in New Issue
Block a user