|
@@ -15,6 +15,7 @@ import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.*;
|
|
import com.izouma.wenlvju.repo.*;
|
|
|
import com.izouma.wenlvju.security.Authority;
|
|
import com.izouma.wenlvju.security.Authority;
|
|
|
import com.izouma.wenlvju.service.sms.NjwlSmsService;
|
|
import com.izouma.wenlvju.service.sms.NjwlSmsService;
|
|
|
|
|
+import com.izouma.wenlvju.service.storage.StorageService;
|
|
|
import com.izouma.wenlvju.utils.FileUtils;
|
|
import com.izouma.wenlvju.utils.FileUtils;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import com.izouma.wenlvju.utils.ObjUtils;
|
|
import com.izouma.wenlvju.utils.ObjUtils;
|
|
@@ -63,6 +64,8 @@ public class RateService {
|
|
|
private NjwlSmsService njwlSmsService;
|
|
private NjwlSmsService njwlSmsService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private OrganizationRepo organizationRepo;
|
|
private OrganizationRepo organizationRepo;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private StorageService storageService;
|
|
|
@Value("${storage.local_path}")
|
|
@Value("${storage.local_path}")
|
|
|
private String localPath;
|
|
private String localPath;
|
|
|
|
|
|
|
@@ -374,7 +377,9 @@ public class RateService {
|
|
|
|
|
|
|
|
public List<InputStream> upLoad1(Rate rate) throws UnsupportedEncodingException {
|
|
public List<InputStream> upLoad1(Rate rate) throws UnsupportedEncodingException {
|
|
|
List<InputStream> files = new ArrayList<>();
|
|
List<InputStream> files = new ArrayList<>();
|
|
|
- String uri = "http://10.188.236.2/word2pdf";
|
|
|
|
|
|
|
+// String uri = "http://10.188.236.2/word2pdf";
|
|
|
|
|
+
|
|
|
|
|
+ String uri = "http://convert.izouma.com/word2pdf";
|
|
|
|
|
|
|
|
// 表格
|
|
// 表格
|
|
|
String export = this.export(rate);
|
|
String export = this.export(rate);
|
|
@@ -399,6 +404,8 @@ public class RateService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void downloadFile1(List<InputStream> files, List<String> urls) {
|
|
public void downloadFile1(List<InputStream> files, List<String> urls) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
AtomicInteger num = new AtomicInteger(1);
|
|
AtomicInteger num = new AtomicInteger(1);
|
|
|
urls.forEach(privacy -> {
|
|
urls.forEach(privacy -> {
|
|
|
num.getAndIncrement();
|
|
num.getAndIncrement();
|
|
@@ -414,7 +421,7 @@ public class RateService {
|
|
|
throw new BusinessException("找不到文件");
|
|
throw new BusinessException("找不到文件");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- InputStream stream = HttpRequest.post("http://10.188.236.2/word2pdf")
|
|
|
|
|
|
|
+ InputStream stream = HttpRequest.post("http://convert.izouma.com/word2pdf")
|
|
|
.accept("*/*")
|
|
.accept("*/*")
|
|
|
.part("file", "审核材料.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", is1)
|
|
.part("file", "审核材料.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", is1)
|
|
|
.stream();
|
|
.stream();
|
|
@@ -440,6 +447,7 @@ public class RateService {
|
|
|
public List<File> upLoad(Rate rate) {
|
|
public List<File> upLoad(Rate rate) {
|
|
|
List<File> files = new ArrayList<>();
|
|
List<File> files = new ArrayList<>();
|
|
|
String uri = "http://10.188.236.2/word2pdf";
|
|
String uri = "http://10.188.236.2/word2pdf";
|
|
|
|
|
+
|
|
|
// 表格
|
|
// 表格
|
|
|
String export = this.export(rate);
|
|
String export = this.export(rate);
|
|
|
InputStream is = new ByteArrayInputStream(export.getBytes());
|
|
InputStream is = new ByteArrayInputStream(export.getBytes());
|
|
@@ -565,13 +573,14 @@ public class RateService {
|
|
|
}
|
|
}
|
|
|
List<InputStream> files = this.upLoad1(rate);
|
|
List<InputStream> files = this.upLoad1(rate);
|
|
|
|
|
|
|
|
- String targetPath = localPath + "/material" + rate.getId() + ".pdf";
|
|
|
|
|
|
|
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
|
+
|
|
|
// pdf合并工具类
|
|
// pdf合并工具类
|
|
|
PDFMergerUtility mergePdf = new PDFMergerUtility();
|
|
PDFMergerUtility mergePdf = new PDFMergerUtility();
|
|
|
|
|
|
|
|
mergePdf.addSources(files);
|
|
mergePdf.addSources(files);
|
|
|
// 设置合并生成pdf文件名称
|
|
// 设置合并生成pdf文件名称
|
|
|
- mergePdf.setDestinationFileName(targetPath);
|
|
|
|
|
|
|
+ mergePdf.setDestinationStream(bos);
|
|
|
try {
|
|
try {
|
|
|
mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
|
|
mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
|
|
|
for (InputStream is : files) {
|
|
for (InputStream is : files) {
|
|
@@ -580,7 +589,11 @@ public class RateService {
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- rate.setPdfUrl("http://yskj.njlyw.cn:8081/files/pdf/material" + rate.getId() + ".pdf");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String url = storageService.uploadFromInputStream(new ByteArrayInputStream(bos.toByteArray()),
|
|
|
|
|
+ "pdf/material" + rate.getId() + ".pdf");
|
|
|
|
|
+
|
|
|
|
|
+ rate.setPdfUrl(url);
|
|
|
rateRepo.save(rate);
|
|
rateRepo.save(rate);
|
|
|
}
|
|
}
|
|
|
|
|
|