Commit 2874e2d5 authored by Quxl's avatar Quxl

x

parent 4f2ec5bd
package com.egolm.film.api.service;
import java.io.OutputStream;
import java.util.Map;
public interface ExportService {
public void export(OutputStream os);
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);
}
......@@ -4,6 +4,7 @@ import java.io.OutputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -16,7 +17,9 @@ import com.egolm.common.ExcelUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.ExportService;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.bean.Fc_member_film;
@Service
......@@ -25,6 +28,9 @@ public class ExportServiceImpl implements ExportService {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
FilmService filmService;
private static final String[] exclude = new String[] {
"origion_name",
"type",
......@@ -47,6 +53,7 @@ public class ExportServiceImpl implements ExportService {
"plays_is_agree",
"plays_is_agree1"};
private static final Map<String, String> titles = new HashMap<String, String>();
private static final Map<String, String> playactorTypes = new HashMap<String, String>();
static {
......@@ -58,6 +65,7 @@ public class ExportServiceImpl implements ExportService {
playactorTypes.put("actress", "女演员");
playactorTypes.put("issuser", "发行方");
playactorTypes.put("show", "参加过的电视节");
titles.putAll(playactorTypes);
}
private static final Map<String, String> filmTypes = new HashMap<String, String>();
static {
......@@ -133,12 +141,11 @@ public class ExportServiceImpl implements ExportService {
playShanghai.put("4", "中国首映");
}
private List<Map<String, Object>> queryFilmDataList() {
String sql = "select t.* from fc_member_film t where state = 2";
private List<Map<String, Object>> queryFilmDataList(String keyword, Integer state, Integer apply_state, Integer film_type, Integer upload_state, String film_country) {
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 sql2 = "select group_concat(fs.show_filmfest) text, fs.film_id from fc_member_film_show fs group by fs.film_id";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
List<Map<String, Object>> list = filmService.queryChuShenList(keyword, upload_state, apply_state, upload_state, film_type, null, film_country, null, null, null, null, null, null, new Page(1L, 9999999999L));
List<Map<String, Object>> playactors = jdbcTemplate.queryForList(sql0);
List<Map<String, Object>> issuers = jdbcTemplate.queryForList(sql1);
List<Map<String, Object>> shows = jdbcTemplate.queryForList(sql2);
......@@ -172,10 +179,20 @@ public class ExportServiceImpl implements ExportService {
return list;
}
public void export(OutputStream os) {
List<Map<String, Object>> list = this.queryFilmDataList();
public void export(OutputStream os, String keyword, Integer state, Integer apply_state, Integer film_type, Integer upload_state, String film_country, String[] columns) {
List<Map<String, Object>> list = this.queryFilmDataList(keyword, state, apply_state, film_type, upload_state, film_country);
List<String> argsList = new ArrayList<String>();
List<String> titleList = new ArrayList<String>();
Map<String, String> map = this.getAllTitles(columns);
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 Map<String, String> getAllTitles(String[] columns) {
Map<String, String> map = new LinkedHashMap<String, String>();
Class<?> clz = Fc_member_film.class;
Field[] fs = clz.getDeclaredFields();
for(Field f : fs) {
......@@ -196,16 +213,23 @@ public class ExportServiceImpl implements ExportService {
}
}
}
if(!StringUtil.contains(exclude, columnName)) {
argsList.add(columnName);
titleList.add(columnComment);
if(!StringUtil.contains(exclude, columnName) && (columns == null || columns.length == 0 || StringUtil.contains(columns, columnName))) {
map.put(columnName, columnComment);
}
}
for(String key : playactorTypes.keySet()) {
argsList.add(key);
titleList.add(playactorTypes.get(key));
for(String key : titles.keySet()) {
if(columns == null || columns.length == 0 || StringUtil.contains(columns, key)) {
String title = titles.get(key);
if(StringUtil.isBlank(title)) {
title = key;
}
ExcelUtil.excel(os, argsList.toArray(new String[argsList.size()]), titleList.toArray(new String[titleList.size()]), null, list);
map.put(key, title);
}
}
for(String key : map.keySet()) {
map.put(key, map.get(key).split("\\s+")[0]);
}
return map;
}
private void replaceEnumValue(Map<String, Object> map, String columnName, Map<String, String> values) {
......
......@@ -202,7 +202,7 @@ public class FilmController {
public void exportExcel(HttpServletResponse response) throws IOException {
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());
exportService.export(response.getOutputStream(), null, null, null, null, null, null, null);
}
}
package com.egolm.film.api.web.admin;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.MessageFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.DateUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.EmailService;
import com.egolm.film.api.service.ExportService;
import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.ReviewService;
import com.egolm.film.bean.Fc_member_film;
......@@ -54,6 +61,9 @@ public class AdminFirstController {
@Autowired
ReviewService reviewService;
@Autowired
ExportService exportService;
@ResponseBody
@PostMapping("list")
@ApiOperation("影片列表")
......@@ -110,6 +120,31 @@ public class AdminFirstController {
return Rjx.jsonOk().setData(list).setPage(page);
}
@Transactional
@ResponseBody
@PostMapping("exportColumns")
@ApiOperation("查看导出列")
public Object exportColumns() {
return Rjx.jsonOk().setData(exportService.getAllTitles(null));
}
@Transactional
@GetMapping("exportExcel")
@ApiOperation("导出Excel")
@ApiImplicitParams({
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="keyword", value="关键字"),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="state", value="影片状态 1未提交 2 已提交"),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="apply_state", value="初审状态 1 未受理, 2 初审通过,3 初审否决 "),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="film_type", value="影片类型"),
@ApiImplicitParam(paramType="query", dataType="string", required=false, name="film_country", value="影片国家地区"),
@ApiImplicitParam(paramType="query", dataType="int", required=false, name="upload_state", value="影片文件上传状态(0,1)"),
})
public void exportExcel(HttpServletResponse response, String keyword, Integer state, Integer apply_state, Integer film_type, Integer upload_state, String film_country, String[] columns) throws IOException {
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, upload_state, film_country, columns);
}
@ResponseBody
@Transactional
@PostMapping("pass")
......
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