|
|
@@ -16,6 +16,7 @@ import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.itextpdf.text.*;
|
|
|
import com.itextpdf.text.pdf.*;
|
|
|
+import com.lowagie.text.rtf.RtfWriter2;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@@ -156,10 +157,12 @@ public class RDServiceImpl extends BaseMybatisDao<RdDetailsMapper> implements RD
|
|
|
|
|
|
@Override
|
|
|
public void pushDownloadDetailsWord(Long id, HttpServletResponse response) {
|
|
|
+
|
|
|
OutRdDetails bo = rdDetailsMapper.details(id);
|
|
|
// rdDetailsMapper.updateBrowseOrDownload(id, 1);
|
|
|
OutWordRdDetails data =new OutWordRdDetails();
|
|
|
BeanUtils.copyProperties(bo,data);
|
|
|
+// pushDetailsWord(data,response);
|
|
|
if (bo.getRdStartStr()!=null&&bo.getRdEndStr()!=null){
|
|
|
data.setStartEndTime(bo.getRdStartStr()+"~"+bo.getRdEndStr());
|
|
|
}else {
|
|
|
@@ -173,6 +176,15 @@ public class RDServiceImpl extends BaseMybatisDao<RdDetailsMapper> implements RD
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void pushDetailsWord(OutWordRdDetails data, HttpServletResponse response) {
|
|
|
+ String tableName = data.getRdName();
|
|
|
+ String realFileName = uploadPath+"/tmp/"+new Date().getTime() + ".doc";
|
|
|
+ String attName = data.getRdName()+new Date().getTime() + ".doc";
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ WordUtils wordUtils=new WordUtils();
|
|
|
+ wordUtils.pushWord(data,response,tableName,attName,realFileName);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void pushDownloadDetailsPDF(Long id, HttpServletResponse response) {
|
|
|
OutRdDetails bo = rdDetailsMapper.details(id);
|
|
|
@@ -188,52 +200,9 @@ public class RDServiceImpl extends BaseMybatisDao<RdDetailsMapper> implements RD
|
|
|
String realFileName = uploadPath+"/tmp/"+new Date().getTime() + ".pdf";
|
|
|
String attName = data.getRdName()+new Date().getTime() + ".pdf";
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
-
|
|
|
- Document document=new Document();
|
|
|
- try {
|
|
|
- FileUtils.setAttachmentResponseHeader(response, tableName,attName);
|
|
|
- FileOutputStream outputStream = new FileOutputStream(realFileName);
|
|
|
- PdfWriter writer = PdfWriter.getInstance(document, outputStream);
|
|
|
- document.open();
|
|
|
- Paragraph paragraph = new Paragraph(data.getRdName(), PDFUtils.getTitleFont());
|
|
|
- paragraph.setAlignment(1);
|
|
|
- document.add(paragraph);
|
|
|
- addDocument(document,"项目起止时间: ",data.getStartEndTime());
|
|
|
- addDocument(document,"公司名称: ",data.getUserName());
|
|
|
- addDocument(document,"项目负责人: ",data.getConsultantName());
|
|
|
- addDocument(document,"技术领域: ",data.getTechnicalField());
|
|
|
- addDocument(document,"技术来源: ",data.getTechnologySource());
|
|
|
- addDocument(document,"研发费用总预计: ",data.getTotalAmount().toEngineeringString()+" 万元");
|
|
|
- addDocument(document,"研发目的/立项目的/实施方式",null);
|
|
|
- addContent(document," "+data.getRdObjective());
|
|
|
- addDocument(document,"核心技术/创新点",null);
|
|
|
- addContent(document," "+data.getCoreTechnology());
|
|
|
- addDocument(document,"成果",null);
|
|
|
- addContent(document," "+data.getAchieveResults());
|
|
|
- document.close();
|
|
|
- outputStream.close();
|
|
|
- FileUtils.writeBytes(realFileName, response.getOutputStream());
|
|
|
- FileUtils.deleteFile(realFileName);
|
|
|
- } catch (DocumentException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ PDFUtils pdfUtils=new PDFUtils();
|
|
|
+ pdfUtils.pushPDF(data,response,tableName,attName,realFileName);
|
|
|
}
|
|
|
|
|
|
- private void addDocument(Document document, String key, String value) throws DocumentException {
|
|
|
- if(key!=null)document.add(new Chunk(key,PDFUtils.getBigFont()));
|
|
|
- Phrase phrase = new Phrase(value, PDFUtils.getFont());
|
|
|
- phrase.setLeading(40);
|
|
|
- if(value!=null)document.add(phrase);
|
|
|
- document.add(Chunk.NEWLINE);
|
|
|
- }
|
|
|
- private void addContent(Document document, String value) throws DocumentException {
|
|
|
- Phrase phrase = new Phrase(value, PDFUtils.getFont());
|
|
|
- phrase.setLeading(25);
|
|
|
- if(value!=null)document.add(phrase);
|
|
|
- document.add(Chunk.NEWLINE);
|
|
|
- }
|
|
|
+
|
|
|
}
|