fanxp пре 1 недеља
родитељ
комит
d41740ce38

+ 12 - 1
src/main/java/com/xjrsoft/module/form/service/impl/FormExecuteServiceImpl.java

@@ -58,11 +58,13 @@ import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
 import net.sf.jsqlparser.expression.operators.relational.GreaterThanEquals;
 import net.sf.jsqlparser.expression.operators.relational.LikeExpression;
 import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals;
+import net.sf.jsqlparser.statement.select.OrderByElement;
 import net.sf.jsqlparser.statement.select.PlainSelect;
 import net.sf.jsqlparser.statement.select.Select;
 import net.sf.jsqlparser.util.SelectUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.tuple.ImmutableTriple;
 import org.apache.commons.lang3.tuple.Triple;
 import org.camunda.bpm.engine.impl.calendar.DateTimeUtil;
@@ -1887,7 +1889,16 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
         }
         plainSelect.setWhere(queryExpression);
 
-        com.baomidou.mybatisplus.extension.plugins.pagination.Page mybatisPage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page(page.getPageNumber() + 1, page.getPageSize());
+        // 排序字段
+        for (Order order :page.getOrders()){
+            OrderByElement orderByElement = new OrderByElement();
+            orderByElement.setExpression(new net.sf.jsqlparser.schema.Column(order.getField()));
+            orderByElement.setAsc(order.getDirection().equals(Direction.ASC));
+            if (ObjectUtils.isEmpty(plainSelect.getOrderByElements())){
+                plainSelect.setOrderByElements(new ArrayList<>());
+            }
+            plainSelect.getOrderByElements().add(orderByElement);
+        }
 
         IPage<Map<String, Object>> pageResult = SqlRunnerAdapter.db().
                 selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNumber() + 1, page.getPageSize()), plainSelect.toString());