|
@@ -2,6 +2,7 @@ package com.persagy.apm.dmpalarm.service.impl;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -47,6 +48,13 @@ public class ShardingServiceImpl implements IShardingService {
|
|
|
private static final String COUNT_SQL = "SELECT COUNT(*) total";
|
|
|
|
|
|
private static final String ALL_FIELD_SQL = "SELECT * ";
|
|
|
+
|
|
|
+ public static final String SHARDING_COLUMN = "trigger_time";
|
|
|
+
|
|
|
+ private static final String ASC = "asc";
|
|
|
+
|
|
|
+ private static final String DESC = "desc";
|
|
|
+
|
|
|
@Autowired
|
|
|
private ShardingMapper shardingMapper;
|
|
|
|
|
@@ -95,6 +103,21 @@ public class ShardingServiceImpl implements IShardingService {
|
|
|
if (customSqlSegment.contains(ORDER_BY)) {
|
|
|
orderBySql = customSqlSegment.substring(customSqlSegment.lastIndexOf(ORDER_BY), customSqlSegment.length());
|
|
|
}
|
|
|
+ if (orderBySql.contains(SHARDING_COLUMN)) {
|
|
|
+ String[] orderBys = orderBySql.split(",");
|
|
|
+ for (String string : orderBys) {
|
|
|
+ if(!string.contains(SHARDING_COLUMN)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int lastIndex = string.lastIndexOf(",");
|
|
|
+ lastIndex=lastIndex == -1?string.length():lastIndex;
|
|
|
+ int index = string.indexOf(SHARDING_COLUMN);
|
|
|
+ String orderByString = string.substring(index, lastIndex);
|
|
|
+ if (orderByString.toUpperCase().contains(ASC.toUpperCase()) || !orderByString.toUpperCase().contains(DESC.toUpperCase())) {
|
|
|
+ Collections.reverse(tableNameList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
Map<String, Object> oldParamValueMap = queryWrapper.getParamNameValuePairs();
|
|
|
for (int i = 0; i < tableNameList.size(); i++) {
|
|
|
ShardingEntity shardingEntity = tableNameList.get(i);
|