|
@@ -26,7 +26,6 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -244,20 +243,42 @@ public class BusJcebController extends BaseController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 汇总结果按日期排序
|
|
// 汇总结果按日期排序
|
|
|
|
|
+ JcebCountComparator comparator = new JcebCountComparator();
|
|
|
if (null == sortType || sortType == SortTypeEnum.DESC) {
|
|
if (null == sortType || sortType == SortTypeEnum.DESC) {
|
|
|
- list.sort(
|
|
|
|
|
- Comparator.comparing(JcebCountVo::getOperationDate, Comparator.nullsLast(Date::compareTo))
|
|
|
|
|
- .reversed()
|
|
|
|
|
- .thenComparing(JcebCountVo::getCount).reversed()
|
|
|
|
|
- .thenComparing(JcebCountVo::getJcebType, Comparator.nullsLast(String::compareTo)));
|
|
|
|
|
|
|
+ comparator.setIsAsc(SortTypeEnum.DESC);
|
|
|
|
|
+ list.sort(comparator);
|
|
|
} else {
|
|
} else {
|
|
|
log.info("排序类型 - {}", sortType.getNotes());
|
|
log.info("排序类型 - {}", sortType.getNotes());
|
|
|
- list.sort(
|
|
|
|
|
- Comparator.comparing(JcebCountVo::getOperationDate, Comparator.nullsLast(Date::compareTo))
|
|
|
|
|
- .thenComparing(JcebCountVo::getCount)
|
|
|
|
|
- .thenComparing(JcebCountVo::getJcebType, Comparator.nullsLast(String::compareTo)));
|
|
|
|
|
|
|
+ comparator.setIsAsc(SortTypeEnum.ASC);
|
|
|
|
|
+ list.sort(comparator);
|
|
|
}
|
|
}
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ static class JcebCountComparator implements Comparator<JcebCountVo> {
|
|
|
|
|
+
|
|
|
|
|
+ private SortTypeEnum isAsc;
|
|
|
|
|
+
|
|
|
|
|
+ public void setIsAsc(SortTypeEnum isAsc) {
|
|
|
|
|
+ this.isAsc = isAsc;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(JcebCountVo jceb1, JcebCountVo jceb2) {
|
|
|
|
|
+ if (jceb1.getOperationDate() != null && jceb2.getOperationDate() != null) {
|
|
|
|
|
+ long t1 = jceb1.getOperationDate().getTime();
|
|
|
|
|
+ long t2 = jceb2.getOperationDate().getTime();
|
|
|
|
|
+ int ret = Long.compare(t1, t2);
|
|
|
|
|
+ if (isAsc == SortTypeEnum.DESC) {
|
|
|
|
|
+ ret *= -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return ret;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return jceb1.getOperationDate() == null ? 1 : -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|