Commit f2d2382b authored by Quxl's avatar Quxl

x

parent 1c14966b
package com.egolm.film.api.service;
import java.util.Map;
import javax.servlet.ServletOutputStream;
public interface ExportService {
void exportApplyList(ServletOutputStream outputStream);
Map<String, String> getApplyListColumns();
void exportApplyList(ServletOutputStream outputStream, String[] columns);
}
package com.egolm.film.api.service.impl;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -9,10 +11,13 @@ import javax.servlet.ServletOutputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.ExcelUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.service.CountryService;
import com.egolm.film.api.service.ExportService;
import com.egolm.film.api.web.ExportConstant;
@Service
public class ExportServiceImpl implements ExportService {
......@@ -27,9 +32,44 @@ public class ExportServiceImpl implements ExportService {
countryMap = countryService.queryCountryMapReverse();
}
public Map<String, String> getApplyListColumns() {
Map<String, String> columns = new LinkedHashMap<String, String>();
columns.put("film_no", "电影编号");
columns.put("en_name", "英文名称");
columns.put("cn_name", "中文片名");
columns.put("enroll_type_name", "影片类型");
columns.put("first_show_date", "首次上映时间");
columns.put("first_show_city", "首次上映城市");
columns.put("other_filmfest_name", "同时参加的电影节");
columns.put("film_medium", "色彩");
columns.put("film_format", "样片规格");
columns.put("completion_date", "完成日期");
columns.put("film_country", "制片国");
columns.put("film_country_cn", "制片国中文");
columns.put("co_production_country", "合拍国");
columns.put("co_production_country_cn", "合拍国中文");
columns.put("enroll_type_name", "报名性质");
columns.put("state", "状态");
columns.put("dialogue_lang", "对拍语言");
columns.put("dialogue_lang_cn", "对白语言中文");
columns.put("subtitle_lang", "字幕语言");
columns.put("subtitle_lang_cn", "字幕语言中文");
columns.put("play_shanghai", "该片在上海电影节放映是");
columns.put("film_total_time", "时长");
columns.put("film_apply_company", "申报公司");
columns.put("film_apply_realname", "申报人姓名");
columns.put("film_apply_email", "申报人邮箱");
columns.put("film_apply_mobile", "申报人手机");
columns.put("film_apply_country", "申报人国籍");
columns.put("film_format_url", "样片URL");
columns.put("film_format_passw", "样片URL密码");
columns.put("film_type_name_short", "区域类型");
columns.put("apply_state", "申报状态");
return columns;
}
@Override
public void exportApplyList(ServletOutputStream outputStream) {
public void exportApplyList(ServletOutputStream os, String[] columns) {
String sql = ""
+ "select "
+ "mf.film_no, "
......@@ -57,7 +97,8 @@ public class ExportServiceImpl implements ExportService {
+ "mf.film_apply_country, "
+ "mf.film_format_url, "
+ "mf.film_format_passw, "
+ "mf.film_type_name_short "
+ "mf.film_type_name_short, "
+ "mf.apply_state "
+ " from "
+ "fc_member_film mf "
+ "where "
......@@ -79,7 +120,45 @@ public class ExportServiceImpl implements ExportService {
String subtitle_lang = (String)map.get("subtitle_lang");
String subtitle_lang_cn = countryMap.get(subtitle_lang);
map.put("subtitle_lang_cn", subtitle_lang_cn);
map.replace("film_type_name", ExportConstant.filmTypes.get(map.get("film_type_name")));
map.replace("film_type_name_short", ExportConstant.filmShortTypes.get(map.get("film_type_name_short")));
map.replace("film_medium", ExportConstant.filmMedium.get(map.get("film_medium")));
map.replace("film_format", ExportConstant.filmFormat.get(map.get("film_format")));
map.replace("state", ExportConstant.states.get(String.valueOf(map.get("state"))));
map.replace("apply_state", ExportConstant.applyStates.get(String.valueOf(map.get("apply_state"))));
map.replace("play_shanghai", ExportConstant.playShanghai.get(String.valueOf(map.get("play_shanghai"))));
String enroll_type_name = (String)map.get("enroll_type_name");
if(StringUtil.isNotBlank(enroll_type_name)) {
List<String> enrolls = new ArrayList<String>();
for(String str : enroll_type_name.split(",")) {
enrolls.add(ExportConstant.enrollTypes.get(str.trim()));
}
map.put("enroll_type_name", StringUtil.join(",", enrolls));
}
}
Map<String, String> columnMap = this.getApplyListColumns();
List<String> titleList = new ArrayList<String>();
List<String> columnList = new ArrayList<String>();
if(columns == null || columns.length == 0) {
for(String key : columnMap.keySet()) {
columnList.add(key);
titleList.add(columnMap.get(key));
}
} else {
for(String column: columns) {
columnList.add(column);
String title = columnMap.get(column);
if(StringUtil.isNotBlank(title)) {
titleList.add(title);
} else {
titleList.add(column);
}
}
}
ExcelUtil.excel(os, columnList.toArray(new String[columnList.size()]), titleList.toArray(new String[titleList.size()]), null, list);
}
}
......@@ -191,13 +191,20 @@ public class FilmController {
return Rjx.jsonOk().set("id", filmBase.getId());
}
@ResponseBody
@PostMapping("getApplyListColumns")
@ApiOperation("获取报名列表导出列")
public Object getApplyListColumns() {
return Rjx.jsonOk().setData(exportService.getApplyListColumns());
}
@ResponseBody
@PostMapping("exportApplyList")
@ApiOperation("导出报名列表")
public void exportApplyList(HttpServletResponse response) throws IOException {
public void exportApplyList(HttpServletResponse response, 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.exportApplyList(response.getOutputStream());
exportService.exportApplyList(response.getOutputStream(), columns);
}
}
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