bug
This commit is contained in:
+19
@@ -109,6 +109,25 @@ public class DateUtilCustom {
|
|||||||
return add(date,Calendar.DATE,amount);
|
return add(date,Calendar.DATE,amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定日期昨天的时间范围
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String, String> getYesterday(int addDay) {
|
||||||
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
DateTime dt = new DateTime();
|
||||||
|
// 昨天
|
||||||
|
DateTime yesterday = dt.minusDays(addDay);
|
||||||
|
String start = yesterday.toString("yyyy-MM-dd") + " 00:00:00";
|
||||||
|
|
||||||
|
DateTime day = dt.minusDays(addDay-1);
|
||||||
|
String end = day.toString("yyyy-MM-dd") + " 00:00:00";
|
||||||
|
map.put("start", start);
|
||||||
|
map.put("end", end);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.err.println(JsonUtils.toJson(getLatelyDate(3)));
|
System.err.println(JsonUtils.toJson(getLatelyDate(3)));
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-24
@@ -153,33 +153,42 @@ public class EnterpriseStatJob implements SimpleJob {
|
|||||||
|
|
||||||
private void processPageStat(){
|
private void processPageStat(){
|
||||||
|
|
||||||
Date date = DateUtilCustom.add(new Date(), -1);
|
int startNum = 1;
|
||||||
String fDate = DateUtilCustom.formatByPattern(date, "yyyy-MM-dd");
|
// while(startNum<=10){
|
||||||
//删除老数据
|
Date date = DateUtilCustom.add(new Date(), -1*startNum);
|
||||||
pageStatService.deleteByParams(fDate);
|
String fDate = DateUtilCustom.formatByPattern(date, "yyyy-MM-dd");
|
||||||
|
|
||||||
Map<String, String> dateMap = DateUtilCustom.getYesterday();
|
//删除老数据
|
||||||
String start = dateMap.get("start");
|
pageStatService.deleteByParams(fDate);
|
||||||
String end = dateMap.get("end");
|
|
||||||
List<Map<String, Object>> result = visitLogService.queryPvList(start, end);
|
//Map<String, String> dateMap = DateUtilCustom.getYesterday(startNum);
|
||||||
if(result.size() > 0){
|
Map<String, String> dateMap = DateUtilCustom.getYesterday();
|
||||||
List<PageStat> list = new ArrayList<PageStat>();
|
String start = dateMap.get("start");
|
||||||
for(Map<String, Object> m : result){
|
String end = dateMap.get("end");
|
||||||
String city = (String) m.get("city");
|
|
||||||
if(StringUtils.isNotBlank(city)){
|
List<Map<String, Object>> result = visitLogService.queryPvList(start, end);
|
||||||
PageStat stat = new PageStat();
|
if(result.size() > 0){
|
||||||
stat.setCity((String) m.get("city"));
|
List<PageStat> list = new ArrayList<PageStat>();
|
||||||
stat.setEid((Long) m.get("eid"));
|
for(Map<String, Object> m : result){
|
||||||
stat.setUri((String) m.get("uri"));
|
String city = (String) m.get("city");
|
||||||
stat.setPv((Long) m.get("pv"));
|
if(StringUtils.isNotBlank(city)){
|
||||||
stat.setUv((Long) m.get("uv"));
|
PageStat stat = new PageStat();
|
||||||
stat.setCreateDate(date);
|
stat.setCity((String) m.get("city"));
|
||||||
stat.setFormatDate(fDate);
|
stat.setEid((Long) m.get("eid"));
|
||||||
list.add(stat);
|
stat.setUri((String) m.get("uri"));
|
||||||
|
stat.setPv((Long) m.get("pv"));
|
||||||
|
stat.setUv((Long) m.get("uv"));
|
||||||
|
stat.setCreateDate(date);
|
||||||
|
stat.setFormatDate(fDate);
|
||||||
|
list.add(stat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pageStatService.saveAll(list);
|
||||||
}
|
}
|
||||||
pageStatService.saveAll(list);
|
|
||||||
}
|
//startNum = startNum + 1;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ public class VisitLogServiceImpl extends EntityService<VisitLog> implements Visi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> queryPvList(String start, String end) {
|
public List<Map<String, Object>> queryPvList(String start, String end) {
|
||||||
String sql = "SELECT eid,city, uri,COUNT(uri) as pv,COUNT(DISTINCT(ip)) as uv FROM visit_log WHERE visit_time BETWEEN ? AND ? GROUP BY eid,city,uri";
|
String sql = "SELECT eid,city, uri,COUNT(uri) as pv,COUNT(DISTINCT(uid)) as uv FROM visit_log WHERE visit_time BETWEEN ? AND ? GROUP BY eid,city,uri";
|
||||||
List<Map<String, Object>> list = super.getJdbcTemplate().queryForPage(0, Integer.MAX_VALUE, sql, new Object[] {start, end});
|
List<Map<String, Object>> list = super.getJdbcTemplate().queryForPage(0, Integer.MAX_VALUE, sql, new Object[] {start, end});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user