Commit b73b2575 authored by Quxl's avatar Quxl

x

parent 2b70400f
package com.egolm.film.api.service;
public interface OssService {
String getOssPath(String relativePath, Integer expiryTime);
}
...@@ -3,6 +3,7 @@ package com.egolm.film.api.service.impl; ...@@ -3,6 +3,7 @@ package com.egolm.film.api.service.impl;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -10,7 +11,10 @@ import java.util.Map; ...@@ -10,7 +11,10 @@ import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -25,6 +29,9 @@ import com.egolm.film.api.service.CountryService; ...@@ -25,6 +29,9 @@ import com.egolm.film.api.service.CountryService;
import com.egolm.film.api.service.ExportService; import com.egolm.film.api.service.ExportService;
import com.egolm.film.api.service.FilmService; import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.LanguageService; import com.egolm.film.api.service.LanguageService;
import com.egolm.film.api.service.OssService;
import com.egolm.film.bean.Fc_member_film;
import com.egolm.film.bean.Fc_member_film_ext;
import com.egolm.film.config.XRException; import com.egolm.film.config.XRException;
@Service @Service
...@@ -544,14 +551,62 @@ public class ExportServiceImpl implements ExportService { ...@@ -544,14 +551,62 @@ public class ExportServiceImpl implements ExportService {
@Value("${template.publication.path}") @Value("${template.publication.path}")
private String publicationPath; private String publicationPath;
@Autowired
OssService ossService;
@Override @Override
public void exportPublication(ServletOutputStream os, Integer film_id) { public void exportPublication(ServletOutputStream os, Integer film_id) {
Fc_member_film film = filmService.queryMemberFilmById(film_id.longValue());
Fc_member_film_ext filmExt = filmService.queryFilmExt(film_id);
Map<String, String> vars = new HashMap<String, String>();
vars.put("1,0", film.getCn_name());
vars.put("2,0", film.getEn_name());
vars.put("3,0", filmExt.getDirector_en());
vars.put("6,0", film.getFilm_country());
vars.put("7,0", film.getCompletion_date());
vars.put("8,0", film.getFilm_total_time());
vars.put("9,0", filmExt.getFormat());
vars.put("11,0", filmExt.getScreenplay());
vars.put("13,0", filmExt.getDirector_of_photography());
vars.put("15,0", filmExt.getMusic());
vars.put("17,0", filmExt.getProduction_designer());
vars.put("19,0", filmExt.getExecutive_producer());
vars.put("21,0", filmExt.getEditor());
vars.put("23,0", filmExt.getProducer_en());
vars.put("25,0", filmExt.getCast());
vars.put("27,0", filmExt.getProduction_en());
vars.put("29,0", filmExt.getWorld_sales());
vars.put("30,0", filmExt.getResolution());
vars.put("31,0", filmExt.getAspect_ratio());
vars.put("32,0", filmExt.getSound_format());
vars.put("33,0", filmExt.getFrame_rate());
vars.put("34,0", filmExt.getKdm());
vars.put("6,3", filmExt.getSynopsis_cn());
vars.put("12,3", filmExt.getSynopsis_en());
vars.put("20,5", filmExt.getDirector_biography_cn());
vars.put("24,5", filmExt.getDirector_biography_en());
HSSFWorkbook wb = null; HSSFWorkbook wb = null;
FileInputStream fis =null; FileInputStream fis =null;
try { try {
fis = new FileInputStream(publicationPath); fis = new FileInputStream(publicationPath);
wb = new HSSFWorkbook(fis); wb = new HSSFWorkbook(fis);
//TODO 在这里修改单元格内容 HSSFSheet sheet = wb.getSheetAt(0);
for(String key : vars.keySet()) {
String value = vars.get(key);
String[] xyAry = key.split(",", 2);
Integer x = Integer.valueOf(xyAry[1]);
Integer y = Integer.valueOf(xyAry[0]);
Row row = sheet.getRow(y-1);
Cell cell = row.getCell(x-1);
String tplValue = cell.getStringCellValue();
if(StringUtil.isBlank(tplValue)) {
cell.setCellValue(value);
} else {
cell.setCellValue(tplValue.replaceFirst("_+", value));
}
}
wb.write(os); wb.write(os);
fis.close(); fis.close();
} catch (Exception e) { } catch (Exception e) {
......
package com.egolm.film.api.service.impl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.egolm.film.api.service.OssService;
import com.egolm.film.util.OSSUtils;
@Service
public class OssServiceImpl implements OssService {
@Value("${aliyun.sts.accessKeyId}")
private String accessKeyId;
@Value("${aliyun.sts.accessKeySecret}")
private String accessKeySecret;
@Value("${aliyun.oss.endpoint}")
private String endpoint;
@Value("${aliyun.oss.bucket}")
private String bucket;
@Override
public String getOssPath(String relativePath, Integer expiryTime) {
OSSUtils ossUtil = new OSSUtils(endpoint, accessKeyId, accessKeySecret);
String ossPicPath = ossUtil.urlSign(bucket, relativePath, expiryTime);
ossUtil.closeOssClient();
return ossPicPath;
}
}
...@@ -5,7 +5,6 @@ import java.util.List; ...@@ -5,7 +5,6 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -16,6 +15,7 @@ import com.egolm.common.bean.Rjx; ...@@ -16,6 +15,7 @@ import com.egolm.common.bean.Rjx;
import com.egolm.film.api.service.AdminTokenService; import com.egolm.film.api.service.AdminTokenService;
import com.egolm.film.api.service.FilmService; import com.egolm.film.api.service.FilmService;
import com.egolm.film.api.service.MemberTokenService; import com.egolm.film.api.service.MemberTokenService;
import com.egolm.film.api.service.OssService;
import com.egolm.film.api.service.OtherUploadService; import com.egolm.film.api.service.OtherUploadService;
import com.egolm.film.api.service.ReviewService; import com.egolm.film.api.service.ReviewService;
import com.egolm.film.bean.Fc_member_film; import com.egolm.film.bean.Fc_member_film;
...@@ -28,7 +28,6 @@ import com.egolm.film.bean.model.Fc_member_film_base_model; ...@@ -28,7 +28,6 @@ import com.egolm.film.bean.model.Fc_member_film_base_model;
import com.egolm.film.config.WebMvcConfig; import com.egolm.film.config.WebMvcConfig;
import com.egolm.film.config.XRException; import com.egolm.film.config.XRException;
import com.egolm.film.model.LoginToken; import com.egolm.film.model.LoginToken;
import com.egolm.film.util.OSSUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -55,6 +54,9 @@ public class FilmController { ...@@ -55,6 +54,9 @@ public class FilmController {
@Autowired @Autowired
OtherUploadService uploadService; OtherUploadService uploadService;
@Autowired
OssService ossService;
@ResponseBody @ResponseBody
@PostMapping("get_detail") @PostMapping("get_detail")
@ApiOperation("获取全部申报信息") @ApiOperation("获取全部申报信息")
...@@ -260,15 +262,6 @@ public class FilmController { ...@@ -260,15 +262,6 @@ public class FilmController {
return Rjx.jsonOk().setData(ext); return Rjx.jsonOk().setData(ext);
} }
@Value("${aliyun.sts.accessKeyId}")
private String accessKeyId;
@Value("${aliyun.sts.accessKeySecret}")
private String accessKeySecret;
@Value("${aliyun.oss.endpoint}")
private String endpoint;
@Value("${aliyun.oss.bucket}")
private String bucket;
@ResponseBody @ResponseBody
@Transactional @Transactional
@PostMapping("getOssMvPath") @PostMapping("getOssMvPath")
...@@ -277,10 +270,7 @@ public class FilmController { ...@@ -277,10 +270,7 @@ public class FilmController {
@ApiImplicitParam(paramType="query", dataType="string", required=true, name="relativePath", value="相对路径"), @ApiImplicitParam(paramType="query", dataType="string", required=true, name="relativePath", value="相对路径"),
}) })
public Object getOssMvPath(String relativePath){ public Object getOssMvPath(String relativePath){
OSSUtils ossUtil = new OSSUtils(endpoint, accessKeyId, accessKeySecret); return Rjx.jsonOk().setData(ossService.getOssPath(relativePath, 60*24));
String ossPicPath = ossUtil.urlSign(bucket, relativePath, 60*24);
ossUtil.closeOssClient();
return Rjx.jsonOk().setData(ossPicPath);
} }
} }
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