Commit 003562f4 authored by 曲欣红's avatar 曲欣红

1

parent 3f3296de
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -27,73 +28,49 @@ public class FilmReportServiceImpl implements FilmReportService {
@Override
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 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 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 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 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>> uploadCountDataLsit = jdbcTemplate.queryForList(uploadDateSql, start, end);
Calendar c = Calendar.getInstance();
List<Object> dataLsit = new ArrayList<>();
Map<String, Object> res = new HashMap<>();
Long totalCount = jdbcTemplate.queryForLong(totalCountSql, start, end);
res.put("total_count", totalCount);
Map<String, Object> data = new HashMap<>();
while (!start.equals(end)) {
c.setTime(end);
c.add(Calendar.DATE, -1);
end = c.getTime();
Map<String, Object> item = new HashMap<>();
Long createCount = 0L;
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");
}
}
Long uploadCount = 0L;
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");
}
}
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);
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());
item.put("date", DateUtil.format(end, DateUtil.FMT_DATE));
dataLsit.add(item);
}
res.put("list", dataLsit);
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