Commit 9bc0af23 authored by linjian's avatar linjian

合同导出修改

parent 3b466121
...@@ -74,6 +74,17 @@ ...@@ -74,6 +74,17 @@
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>4.1.2</version> <version>4.1.2</version>
</dependency> </dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>xdocreport</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
</dependency>
......
...@@ -34,7 +34,7 @@ public class ContractWordServiceldImpl implements ContractWordServiceld { ...@@ -34,7 +34,7 @@ public class ContractWordServiceldImpl implements ContractWordServiceld {
for(int i = 0; i < request.getData().size(); i++) { for(int i = 0; i < request.getData().size(); i++) {
Contract obj = request.getData().get(i); Contract obj = request.getData().get(i);
String fileName = obj.getDESC1()+"-合同会签单.doc"; String fileName = obj.getDESC1()+"-合同会签单.docx";
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("DESC1", obj.getDESC1()); map.put("DESC1", obj.getDESC1());
map.put("DESC3", obj.getDESC3()); map.put("DESC3", obj.getDESC3());
...@@ -46,18 +46,18 @@ public class ContractWordServiceldImpl implements ContractWordServiceld { ...@@ -46,18 +46,18 @@ public class ContractWordServiceldImpl implements ContractWordServiceld {
map.put("handling_dept", obj.getHandling_dept()); map.put("handling_dept", obj.getHandling_dept());
map.put("leader", obj.getLeader()); map.put("leader", obj.getLeader());
try { try {
File catchFile = File.createTempFile(UUID.randomUUID().toString(), ".doc"); File catchFile = File.createTempFile(UUID.randomUUID().toString(), ".docx");
try ( try (
InputStream resource = ContractWordServiceldImpl.class.getClassLoader().getResourceAsStream("word/contract.doc"); InputStream resource = ContractWordServiceldImpl.class.getClassLoader().getResourceAsStream("word/contract.docx");
FileOutputStream fileOutputStream = new FileOutputStream(catchFile); FileOutputStream fileOutputStream = new FileOutputStream(catchFile);
FileInputStream fileInputStream = new FileInputStream(catchFile); FileInputStream fileInputStream = new FileInputStream(catchFile);
) { ) {
HWPFDocument word = new HWPFDocument(resource); XWPFDocument word = new XWPFDocument(resource);
Range range = word.getRange(); // Range range = word.getRange();
for (Map.Entry<String, Object> entry : map.entrySet()) { // for (Map.Entry<String, Object> entry : map.entrySet()) {
range.replaceText(entry.getKey(), String.valueOf(entry.getValue())); // range.replaceText(entry.getKey(), String.valueOf(entry.getValue()));
} // }
// WordExportUtil.exportWord07(word, map); WordExportUtil.exportWord07(word, map);
word.write(fileOutputStream); word.write(fileOutputStream);
String fileUrl = ossService.uploadOssObject(request.getTenantId(), System.currentTimeMillis() + "/" + fileName, fileInputStream); String fileUrl = ossService.uploadOssObject(request.getTenantId(), System.currentTimeMillis() + "/" + fileName, fileInputStream);
fileUrls.add(fileUrl); fileUrls.add(fileUrl);
......
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