online 代码优化
This commit is contained in:
@@ -78,16 +78,16 @@ public class OnlineController extends BaseController{
|
|||||||
public List<Map<String, Object>> listData(String isAllOnline, String isVisitor, String sessionId,
|
public List<Map<String, Object>> listData(String isAllOnline, String isVisitor, String sessionId,
|
||||||
String userCode, String userName, String userType, String orderBy) {
|
String userCode, String userName, String userType, String orderBy) {
|
||||||
List<Map<String, Object>> list = ListUtils.newArrayList();
|
List<Map<String, Object>> list = ListUtils.newArrayList();
|
||||||
boolean excludeLeave = isAllOnline==null || !Global.YES.equals(isAllOnline);
|
boolean excludeLeave = !Global.YES.equals(isAllOnline);
|
||||||
boolean excludeVisitor = isVisitor==null || !Global.YES.equals(isVisitor);
|
boolean excludeVisitor = !Global.YES.equals(isVisitor);
|
||||||
Collection<Session> sessions = sessionDAO.getActiveSessions(excludeLeave,
|
Collection<Session> sessions = sessionDAO.getActiveSessions(excludeLeave,
|
||||||
excludeVisitor, null, sessionId, userCode);
|
excludeVisitor, null, sessionId, userCode);
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
for (Session session : sessions){
|
for (Session session : sessions){
|
||||||
if (StringUtils.isNotBlank(userName) && ((String)session.getAttribute("userName")).contains(userName)){
|
if (StringUtils.isNotBlank(userName) && !StringUtils.contains((String)session.getAttribute("userName"), userName)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(userType) && ((String)session.getAttribute("userType")).equals(userType)){
|
if (StringUtils.isNotBlank(userType) && !StringUtils.equals((String)session.getAttribute("userType"), userType)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Map<String, Object> map = MapUtils.newLinkedHashMap();
|
Map<String, Object> map = MapUtils.newLinkedHashMap();
|
||||||
@@ -110,21 +110,19 @@ public class OnlineController extends BaseController{
|
|||||||
orderBy = "lastAccessTime desc";
|
orderBy = "lastAccessTime desc";
|
||||||
}
|
}
|
||||||
final String[] ss = orderBy.trim().split(" ");
|
final String[] ss = orderBy.trim().split(" ");
|
||||||
if (ss != null && ss.length == 2){
|
if (ss.length == 2){
|
||||||
Collections.sort(list, new Comparator<Map<String, Object>>() {
|
list.sort((o1, o2) -> {
|
||||||
@Override
|
String s1 = (String) o1.get(ss[0]);
|
||||||
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
String s2 = (String) o2.get(ss[0]);
|
||||||
String s1 = (String)o1.get(ss[0]);
|
if (s1 == null || s2 == null) {
|
||||||
String s2 = (String)o2.get(ss[0]);
|
return -1;
|
||||||
if (s1 == null || s2 == null){
|
}
|
||||||
return -1;
|
if ("asc".equals(ss[1])) {
|
||||||
}
|
return s1.compareTo(s2);
|
||||||
if ("asc".equals(ss[1])){
|
} else {
|
||||||
return s1.compareTo(s2);
|
return s2.compareTo(s1);
|
||||||
}else{
|
}
|
||||||
return s2.compareTo(s1);
|
});
|
||||||
}
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user