Commit 89126d4c authored by linjian's avatar linjian

合同导出修改

parent 69e4a878
......@@ -10,6 +10,8 @@ import com.yundong.third.ht.api.database.ContractWordServiceld;
import com.yundong.third.ht.api.database.dto.request.Contract;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import javax.validation.Valid;
......@@ -32,7 +34,7 @@ public class ContractWordServiceldImpl implements ContractWordServiceld {
for(int i = 0; i < request.getData().size(); i++) {
Contract obj = request.getData().get(i);
String fileName = obj.getDESC1()+"-合同会签单.docx";
String fileName = obj.getDESC1()+"-合同会签单.doc";
HashMap<String, Object> map = new HashMap<>();
map.put("DESC1", obj.getDESC1());
map.put("DESC3", obj.getDESC3());
......@@ -44,20 +46,21 @@ public class ContractWordServiceldImpl implements ContractWordServiceld {
map.put("handling_dept", obj.getHandling_dept());
map.put("leader", obj.getLeader());
try {
File catchFile = File.createTempFile(UUID.randomUUID().toString(), ".docx");
File catchFile = File.createTempFile(UUID.randomUUID().toString(), ".doc");
try (
InputStream resource = ContractWordServiceldImpl.class.getClassLoader().getResourceAsStream("word/contract.docx");
InputStream resource = ContractWordServiceldImpl.class.getClassLoader().getResourceAsStream("word/contract.doc");
FileOutputStream fileOutputStream = new FileOutputStream(catchFile);
FileInputStream fileInputStream = new FileInputStream(catchFile);
) {
XWPFDocument word = null;
if (resource != null) {
word = new XWPFDocument(resource);
WordExportUtil.exportWord07(word, map);
HWPFDocument word = new HWPFDocument(resource);
Range range = word.getRange();
for (Map.Entry<String, Object> entry : map.entrySet()) {
range.replaceText(entry.getKey(), String.valueOf(entry.getValue()));
}
// WordExportUtil.exportWord07(word, map);
word.write(fileOutputStream);
String fileUrl = ossService.uploadOssObject(request.getTenantId(), System.currentTimeMillis() + "/" + fileName, fileInputStream);
fileUrls.add(fileUrl);
}
}
} catch (Exception e) {
......
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