Commit 31dd95e7 authored by Quxl's avatar Quxl
parents cb194d6f 7459143c
...@@ -4,6 +4,7 @@ import java.util.ArrayList; ...@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
...@@ -27,73 +28,49 @@ public class FilmReportServiceImpl implements FilmReportService { ...@@ -27,73 +28,49 @@ public class FilmReportServiceImpl implements FilmReportService {
@Override @Override
public Map<String, Object> uploadReport(String start_date, String end_date) { public Map<String, Object> uploadReport(String start_date, String end_date) {
String createDateSql = "select count(id) count, DATE_FORMAT((select from_unixtime(create_time)),'%Y-%m-%d') date from fc_member_film where create_time >= ? and create_time <= ? group by date"; String createDateSql = "select count(id) count, DATE_FORMAT((select from_unixtime(create_time)),'%Y-%m-%d') date from fc_member_film where create_time >= ? and create_time < ? group by date";
String uploadDateSql = "select count(id) count, DATE_FORMAT(upload_time,'%Y-%m-%d') date from fc_member_film where upload_state = 1 and upload_time >= ? and upload_time <= ? group by date"; String uploadDateSql = "select count(id) count, DATE_FORMAT(upload_time,'%Y-%m-%d') date from fc_member_film where upload_state = 1 and upload_time >= ? and upload_time < ? group by date";
String totalCountSql = "select count(id) from fc_member_film where upload_state = 1 and upload_time >= ? and upload_time <= ?"; String totalCountSql = "select count(id) from fc_member_film where upload_state = 1 and upload_time >= ? and upload_time < ?";
Date start = DateUtil.parse(start_date, DateUtil.FMT_DATE); Date start = DateUtil.parse(start_date, DateUtil.FMT_DATE);
Date end = DateUtil.parse(end_date, DateUtil.FMT_DATE); Date end = DateUtil.parse(end_date, DateUtil.FMT_DATE);
end = new Date(end.getTime()+1000*60*60*24);
List<Map<String, Object>> createCountDataLsit = jdbcTemplate.queryForList(createDateSql, start.getTime()/1000, end.getTime()/1000); List<Map<String, Object>> createCountDataLsit = jdbcTemplate.queryForList(createDateSql, start.getTime()/1000, end.getTime()/1000);
List<Map<String, Object>> uploadCountDataLsit = jdbcTemplate.queryForList(uploadDateSql, start, end); List<Map<String, Object>> uploadCountDataLsit = jdbcTemplate.queryForList(uploadDateSql, start, end);
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
List<Object> dataLsit = new ArrayList<>();
Map<String, Object> res = new HashMap<>(); Map<String, Object> res = new HashMap<>();
Long totalCount = jdbcTemplate.queryForLong(totalCountSql, start, end); Long totalCount = jdbcTemplate.queryForLong(totalCountSql, start, end);
res.put("total_count", totalCount); res.put("total_count", totalCount);
Map<String, Object> data = new HashMap<>();
while (!start.equals(end)) { while (!start.equals(end)) {
c.setTime(end);
c.add(Calendar.DATE, -1);
end = c.getTime();
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
Long createCount = 0L; Long createCount = 0L;
for(Map<String, Object> map : createCountDataLsit) { for(Map<String, Object> map : createCountDataLsit) {
if(map.get("date").equals(DateUtil.format(start, DateUtil.FMT_DATE))) { if(map.get("date").equals(DateUtil.format(end, DateUtil.FMT_DATE))) {
createCount = (Long) map.get("count"); createCount = (Long) map.get("count");
} }
} }
Long uploadCount = 0L; Long uploadCount = 0L;
for(Map<String, Object> map : uploadCountDataLsit) { for(Map<String, Object> map : uploadCountDataLsit) {
if(map.get("date").equals(DateUtil.format(start, DateUtil.FMT_DATE))) { if(map.get("date").equals(DateUtil.format(end, DateUtil.FMT_DATE))) {
uploadCount = (Long) map.get("count"); uploadCount = (Long) map.get("count");
} }
} }
item.put("apply_count", createCount); item.put("apply_count", createCount);
item.put("upload_count", uploadCount); item.put("upload_count", uploadCount);
item.put("total_count", totalCount); item.put("total_count", totalCount);
item.put("date", DateUtil.format(start, DateUtil.FMT_DATE)); item.put("date", DateUtil.format(end, DateUtil.FMT_DATE));
data.put(DateUtil.format(start, DateUtil.FMT_DATE), item); dataLsit.add(item);
c.setTime(start);
c.add(Calendar.DATE, 1); // 日期加1天
start = c.getTime();
}
Map<String, Object> item = new HashMap<>();
Integer createCount = 0;
for(Map<String, Object> map : createCountDataLsit) {
if(map.get("date").equals(DateUtil.format(start, DateUtil.FMT_DATE))) {
createCount = (Integer) map.get("count");
}
}
Integer uploadCount = 0;
for(Map<String, Object> map : uploadCountDataLsit) {
if(map.get("date").equals(DateUtil.format(start, DateUtil.FMT_DATE))) {
uploadCount = (Integer) map.get("count");
}
}
item.put("apply_count", createCount);
item.put("upload_count", uploadCount);
item.put("total_count", totalCount);
item.put("date", DateUtil.format(start, DateUtil.FMT_DATE));
data.put(DateUtil.format(start, DateUtil.FMT_DATE), item);
List<Object> dataLsit = new ArrayList<>();
for(Entry<String, Object> entry : data.entrySet()) {
dataLsit.add(entry.getValue());
} }
res.put("list", dataLsit); res.put("list", dataLsit);
return res; return res;
......
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