anderx лет назад: 3
Родитель
Сommit
642cbbde7f

+ 0 - 5
pom.xml

@@ -403,11 +403,6 @@
 		</dependency>
 		<!--word文档操作-->
 		<dependency>
-			<groupId>com.sushengren</groupId>
-			<artifactId>easyword</artifactId>
-			<version>1.1.5</version>
-		</dependency>
-		<dependency>
 			<groupId>com.lowagie</groupId>
 			<artifactId>itext</artifactId>
 			<version>2.1.7</version>

+ 1 - 11
src/main/java/com/goafanti/RD/service/impl/RDServiceImpl.java

@@ -157,26 +157,15 @@ 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 {
             data.setStartEndTime("");
         }
-        WordUtils wordUtils=new WordUtils();
-        try {
-            wordUtils.download(response,data.getRdName(),data,uploadPath);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    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";
@@ -185,6 +174,7 @@ public class RDServiceImpl extends BaseMybatisDao<RdDetailsMapper> implements RD
         wordUtils.pushWord(data,response,tableName,attName,realFileName);
     }
 
+
     @Override
     public void pushDownloadDetailsPDF(Long id, HttpServletResponse response) {
         OutRdDetails bo = rdDetailsMapper.details(id);

+ 1 - 3
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -17,6 +17,7 @@ import com.goafanti.common.model.TOrderMid;
 import com.goafanti.common.model.TOrderTask;
 import com.goafanti.common.utils.excel.Excel;
 import com.goafanti.common.utils.pdf.PDFUtils;
+import com.goafanti.common.utils.word.WordUtils;
 import com.goafanti.order.bo.TOrderTaskBo;
 import com.goafanti.order.enums.NewProjectStatus;
 import com.goafanti.order.enums.OrderImgEnums;
@@ -785,7 +786,4 @@ public class PublicController extends CertifyApiController {
         	  NewExcelUtil<OutUser> excel=new NewExcelUtil<OutUser>(OutUser.class);
       		return excel.exportExcel(list, "客户列表",uploadPath);
           }
-
-
-
 }

+ 36 - 7
src/main/java/com/goafanti/common/utils/word/WordUtils.java

@@ -10,6 +10,7 @@ import com.goafanti.common.utils.excel.FileUtils;
 
 import com.goafanti.common.utils.pdf.PDFUtils;
 import com.lowagie.text.*;
+import com.lowagie.text.Font;
 import com.lowagie.text.pdf.BaseFont;
 import com.lowagie.text.rtf.RtfWriter2;
 import com.sushengren.easyword.EasyWord;
@@ -18,6 +19,7 @@ import org.springframework.http.MediaType;
 
 
 import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
 import java.io.*;
 import java.util.Date;
 import java.util.HashMap;
@@ -128,16 +130,43 @@ public class WordUtils {
     }
 
     private  Font setFont(int size, int style) {
-        BaseFont baseFont=null;
-        Font font=null;
+        Font font=new Font(Font.NORMAL, size, style, new Color(0, 0, 0));
+        return font;
+    }
+
+
+    public void test(){
+        // 创建word文档,并设置纸张的大小
+        Document document = new Document(PageSize.A4);
+        // 创建word文档
         try {
-            baseFont=BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
-            font=new Font(baseFont,size,style);
-        } catch (DocumentException e) {
+        RtfWriter2.getInstance(document, new FileOutputStream("D:/data/dbDetail.doc"));
+        document.open();// 设置文档标题
+//        Paragraph ph = new Paragraph();
+//        Font f = new Font();
+//        Paragraph p = new Paragraph("数据库表设计文档", new Font(Font.NORMAL, 24, Font.BOLDITALIC, new Color(0, 0, 0)));
+//        p.setAlignment(1);
+//        document.add(p);
+            Paragraph p=new Paragraph("data.getRdName()",new Font(Font.NORMAL, 24, Font.BOLDITALIC, new Color(0, 0, 0)));
+            p.setAlignment(1);
+            document.add(p);
+            addDocument(document,"项目起止时间: ","data.getRdName()");
+            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();
+        } catch (FileNotFoundException e) {
             e.printStackTrace();
-        } catch (IOException e) {
+        } catch (DocumentException e) {
             e.printStackTrace();
         }
-        return font;
     }
 }