Commit fbf88ba3 authored by Quxl's avatar Quxl

x

parent 66d226c7
...@@ -6,7 +6,24 @@ import java.util.Map; ...@@ -6,7 +6,24 @@ import java.util.Map;
public interface ExportService { public interface ExportService {
Map<String, String> getAllTitles(String[] columns); Map<String, String> getAllTitles(String[] columns);
void export(OutputStream os, String keyword, Integer state, Integer apply_state, Integer film_type, Integer upload_state, String film_country, String[] columns); void export(
OutputStream os,
String keyword,
Integer state,
Integer apply_state,
Integer film_type,
Integer enroll_type,
Integer upload_state,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
String[] columns);
void export(OutputStream os);
} }
...@@ -141,7 +141,20 @@ public class ExportServiceImpl implements ExportService { ...@@ -141,7 +141,20 @@ public class ExportServiceImpl implements ExportService {
playShanghai.put("4", "中国首映"); playShanghai.put("4", "中国首映");
} }
private List<Map<String, Object>> queryFilmDataList(String keyword, Integer state, Integer apply_state, Integer film_type, Integer upload_state, String film_country) { private List<Map<String, Object>> queryFilmDataList(
String keyword,
Integer state,
Integer apply_state,
Integer film_type,
Integer enroll_type,
Integer upload_state,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state) {
String sql0 = "select group_concat(fp.playactor_name) text, fp.film_id, fp.playactor_type from fc_member_film_playactor fp group by fp.film_id, fp.playactor_type"; String sql0 = "select group_concat(fp.playactor_name) text, fp.film_id, fp.playactor_type from fc_member_film_playactor fp group by fp.film_id, fp.playactor_type";
String sql1 = "select group_concat(fi.issuer_company) text, fi.film_id from fc_member_film_issuer fi group by fi.film_id"; String sql1 = "select group_concat(fi.issuer_company) text, fi.film_id from fc_member_film_issuer fi group by fi.film_id";
String sql2 = "select group_concat(fs.show_filmfest) text, fs.film_id from fc_member_film_show fs group by fs.film_id"; String sql2 = "select group_concat(fs.show_filmfest) text, fs.film_id from fc_member_film_show fs group by fs.film_id";
...@@ -179,8 +192,48 @@ public class ExportServiceImpl implements ExportService { ...@@ -179,8 +192,48 @@ public class ExportServiceImpl implements ExportService {
return list; return list;
} }
public void export(OutputStream os, String keyword, Integer state, Integer apply_state, Integer film_type, Integer upload_state, String film_country, String[] columns) { public void export(OutputStream os) {
List<Map<String, Object>> list = this.queryFilmDataList(keyword, state, apply_state, film_type, upload_state, film_country); List<Map<String, Object>> list = this.queryFilmDataList(null, null, null, null, null, null, null, null, null, null,null, null, null);
List<String> argsList = new ArrayList<String>();
List<String> titleList = new ArrayList<String>();
Map<String, String> map = this.getAllTitles(null);
for(String key : map.keySet()) {
argsList.add(key);
titleList.add(map.get(key));
}
ExcelUtil.excel(os, argsList.toArray(new String[argsList.size()]), titleList.toArray(new String[titleList.size()]), null, list);
}
public void export(
OutputStream os,
String keyword,
Integer state,
Integer apply_state,
Integer film_type,
Integer enroll_type,
Integer upload_state,
String film_country,
Integer film_type_short,
String play_shanghai,
Integer review_round,
Integer review_state,
Integer allot_atate,
Integer opt_state,
String[] columns) {
List<Map<String, Object>> list = this.queryFilmDataList(
keyword,
state,
apply_state,
film_type,
enroll_type,
upload_state,
film_country,
film_type_short,
play_shanghai,
review_round,
review_state,
allot_atate,
opt_state);
List<String> argsList = new ArrayList<String>(); List<String> argsList = new ArrayList<String>();
List<String> titleList = new ArrayList<String>(); List<String> titleList = new ArrayList<String>();
Map<String, String> map = this.getAllTitles(columns); Map<String, String> map = this.getAllTitles(columns);
......
...@@ -202,7 +202,7 @@ public class FilmController { ...@@ -202,7 +202,7 @@ public class FilmController {
public void exportExcel(HttpServletResponse response) throws IOException { public void exportExcel(HttpServletResponse response) throws IOException {
response.setContentType("application/octet-stream"); response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("影片列表[" + DateUtil.format(new Date(), "yyMMdd-HHmmss") + "].xls", "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("影片列表[" + DateUtil.format(new Date(), "yyMMdd-HHmmss") + "].xls", "UTF-8"));
exportService.export(response.getOutputStream(), null, null, null, null, null, null, null); exportService.export(response.getOutputStream());
} }
} }
package com.egolm.film.api.web.admin; package com.egolm.film.api.web.admin;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -16,6 +20,7 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -16,6 +20,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.DateUtil;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminTokenService; import com.egolm.film.api.service.AdminTokenService;
...@@ -77,6 +82,7 @@ public class AdminFirstController { ...@@ -77,6 +82,7 @@ public class AdminFirstController {
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="review_state", value="审片结论 1通过 2否决 3参赛 4参赛备选 5参展"), @ApiImplicitParam(paramType="query", dataType="int", required=false, name="review_state", value="审片结论 1通过 2否决 3参赛 4参赛备选 5参展"),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="allot_atate", value="评委分配状态 0未分配评委 1已分配评委评选中"), @ApiImplicitParam(paramType="query", dataType="int", required=false, name="allot_atate", value="评委分配状态 0未分配评委 1已分配评委评选中"),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="opt_state", value="评选状态 0未评选 1有争议 2管理员分配 3已完成"), @ApiImplicitParam(paramType="query", dataType="int", required=false, name="opt_state", value="评选状态 0未评选 1有争议 2管理员分配 3已完成"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="columns", value="数据导出时导出列" , allowMultiple=true),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="index", value="分页编号"), @ApiImplicitParam(paramType="query", dataType="long", required=true, name="index", value="分页编号"),
@ApiImplicitParam(paramType="query", dataType="long", required=true, name="limit", value="分页大小"), @ApiImplicitParam(paramType="query", dataType="long", required=true, name="limit", value="分页大小"),
}) })
...@@ -95,7 +101,11 @@ public class AdminFirstController { ...@@ -95,7 +101,11 @@ public class AdminFirstController {
Integer allot_atate, Integer allot_atate,
Integer opt_state, Integer opt_state,
Long index, Long index,
Long limit) { Long limit,
String[] columns,
HttpServletRequest request,
HttpServletResponse response) throws IOException {
if(request.getMethod().equalsIgnoreCase("POST")) {
index = index == null ? 1 : index; index = index == null ? 1 : index;
limit = limit == null ? 20 : limit; limit = limit == null ? 20 : limit;
Page page = new Page(index, limit); Page page = new Page(index, limit);
...@@ -112,8 +122,28 @@ public class AdminFirstController { ...@@ -112,8 +122,28 @@ public class AdminFirstController {
review_round, review_round,
review_state, review_state,
allot_atate, allot_atate,
opt_state, page); opt_state,
page);
return Rjx.jsonOk().setData(list).setPage(page); return Rjx.jsonOk().setData(list).setPage(page);
} else {
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("影片列表[" + DateUtil.format(new Date(), "yyMMdd-HHmmss") + "].xls", "UTF-8"));
exportService.export(response.getOutputStream(), keyword,
state,
apply_state,
film_type,
enroll_type,
upload_state,
film_country,
film_type_short,
play_shanghai,
review_round,
review_state,
allot_atate,
opt_state,
columns);
return null;
}
} }
@Transactional @Transactional
......
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