Commit 92bed357 authored by yanzg's avatar yanzg

将源码打包进jar包

parent 78f3d1cd
package com.yanzuoguang.log;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* 统计对象
*
* @author 颜佐光
*/
public class LogCountResult {
/**
* 今日日志开始时间
*/
private String todayTime;
/**
* 日志记录
*/
private List<LogUrlCountVo> list = new ArrayList<>();
public LogCountResult() {
}
public LogCountResult(String todayTime, Collection<LogUrlCountVo> list) {
this.todayTime = todayTime;
this.list.addAll(list);
}
public String getTodayTime() {
return todayTime;
}
public void setTodayTime(String todayTime) {
this.todayTime = todayTime;
}
public List<LogUrlCountVo> getList() {
return list;
}
public void setList(List<LogUrlCountVo> list) {
this.list = list;
}
}
......@@ -29,12 +29,13 @@ public class LogCountTime {
*/
private String todayTime;
public MemoryCache<LogUrlCountVo> getTodayMemoryCache() {
return todayMemoryCache;
}
public String getTodayTime() {
return todayTime;
/**
* 获取日志结果
*
* @return
*/
public LogCountResult getTodayResult() {
return new LogCountResult(todayTime, todayMemoryCache.getValues());
}
private void initToday() {
......
......@@ -5,10 +5,8 @@ import com.yanzuoguang.util.thread.ThreadNext;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* 将请求次数日志输出
......@@ -34,16 +32,17 @@ public class LogPrint implements ThreadNext.Next, InitializingBean {
@Override
public boolean next() {
List<LogUrlCountVo> rowList = new ArrayList<>(logCountTime.getTodayMemoryCache().getValues());
if (rowList.isEmpty()) {
LogCountResult todayResult = logCountTime.getTodayResult();
if (todayResult.getList().isEmpty()) {
return true;
}
// 按照使用总时间升序排序
rowList.sort(Comparator.comparingLong(LogUrlCountVo::getTotalTime));
todayResult.getList().sort(Comparator.comparingLong(LogUrlCountVo::getTotalTime));
// 逆转排序
Collections.reverse(rowList);
Collections.reverse(todayResult.getList());
// 打印日志
System.out.println(CollectionString.getCollectionString("从" + logCountTime.getTodayTime() + "时执行次数:", rowList));
String tag = "从" + todayResult.getTodayTime() + "时执行次数:";
System.out.println(CollectionString.getCollectionString(tag, todayResult.getList()));
// 下次继续执行
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment