word转pdf
This commit is contained in:
+25
-13
@@ -180,7 +180,16 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
//
|
||||
for (String bookmark : bookmarkList) {
|
||||
if(columnValueMap.containsKey(bookmark)){
|
||||
datas.put(bookmark,columnValueMap.get(bookmark));
|
||||
if(bookmark.equals("resSex")){
|
||||
String responSex = columnValueMap.get(bookmark);
|
||||
if (responSex.equals("0")) {
|
||||
datas.put(bookmark, "男");
|
||||
} else {
|
||||
datas.put(bookmark, "女");
|
||||
}
|
||||
}else {
|
||||
datas.put(bookmark, columnValueMap.get(bookmark));
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
@@ -231,11 +240,11 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
// todo 线上仲裁/线下仲裁方式未选择
|
||||
//线上开庭时
|
||||
if (arbitratMethod == 1) {
|
||||
String replace = onLine.replace(onLineDate, hearDateStr);
|
||||
String replace = onLine.replace(onLineDate, Optional.ofNullable(hearDateStr).orElse(""));
|
||||
datas.put("onLine", replace);
|
||||
} else {
|
||||
//书面仲裁时
|
||||
String replace = written.replace(writtenDate, hearDateStr);
|
||||
String replace = written.replace(writtenDate, Optional.ofNullable(hearDateStr).orElse(""));
|
||||
datas.put("written", replace);
|
||||
|
||||
}
|
||||
@@ -252,7 +261,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
if (arbitratMethod == 1) {
|
||||
if (isAbsence != null && isAbsence == 1) {
|
||||
// 被申请人缺席
|
||||
String absentReplace = absent.replace("{{agentName}}", agentName);
|
||||
String absentReplace = absent.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
|
||||
datas.put("absent",absentReplace);
|
||||
// 被申请人缺席
|
||||
String resAbsentReplace=resAbsent;
|
||||
@@ -267,7 +276,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
datas.put("resAbsent",resAbsentReplace);
|
||||
} else {
|
||||
// 出席
|
||||
String attendReplace = attend.replace("{{agentName}}", agentName);
|
||||
String attendReplace = attend.replace("{{agentName}}", Optional.ofNullable(agentName).orElse(""));
|
||||
datas.put("attend",attend);
|
||||
// 被申请人证据
|
||||
if(caseAttachMap!=null && CollectionUtil.isNotEmpty(caseAttachMap.get(6))){
|
||||
@@ -281,7 +290,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
for (CaseAttach caseAttach : caseAttaches) {
|
||||
stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
||||
}
|
||||
resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", arbitrateRecordSelect.getApplicantOpinion());
|
||||
resFileRplace = resFile.replace("{{resFile}}", stringBuilder.toString()).replace("{{applicantOpinion}}", Optional.ofNullable(arbitrateRecordSelect.getApplicantOpinion()).orElse(""));
|
||||
}
|
||||
datas.put("resFile",resFileRplace);
|
||||
}else {
|
||||
@@ -296,7 +305,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
for (CaseAttach caseAttach : caseAttaches) {
|
||||
stringBuilder.append(caseAttach.getAnnexName()).append("\n");
|
||||
}
|
||||
resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion());
|
||||
resAttendOpinionReplace = resAttendOpinion.replace("{{applicantFile}}", stringBuilder.toString()).replace("{{respondentOpinion}}", arbitrateRecordSelect.getRespondentOpinion()==null?"":arbitrateRecordSelect.getRespondentOpinion());
|
||||
}
|
||||
|
||||
datas.put("resAttendOpinion",resAttendOpinionReplace);
|
||||
@@ -306,13 +315,16 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
|
||||
|
||||
String month = String.format("%02d", now.getMonthValue());
|
||||
String day = String.format("%02d", now.getDayOfMonth());
|
||||
String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
||||
// String modalFilePath = "D:/新裁决书模板.docx";
|
||||
// todo 服务器路径
|
||||
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
||||
// String saveFolderPath = "D:/";
|
||||
// todo
|
||||
// String modalFilePath = "/data/arbitrate-document/template/新裁决书模板.docx";
|
||||
String modalFilePath = templatePath;
|
||||
// todo
|
||||
// String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
||||
String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
|
||||
String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
|
||||
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||
// todo
|
||||
// String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||
String saveName = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day + "/" + fileName;
|
||||
String resultFilePath = saveFolderPath + "/" + fileName;
|
||||
// 创建日期目录
|
||||
File saveFolder = new File(saveFolderPath);
|
||||
|
||||
+12
-8
@@ -3016,7 +3016,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
||||
if (unzipSuccess) {
|
||||
// 查询抓取规则
|
||||
// todo 批次需要再上传压缩包时用户填写
|
||||
List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(17L);
|
||||
List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(18L);
|
||||
if (CollectionUtil.isEmpty(fatchRuleList)) {
|
||||
return error("未设置抓取规则");
|
||||
}
|
||||
@@ -3291,7 +3291,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
||||
//文件转成base64
|
||||
String base64 = OCRUtils.pdfConvertBase64(pdfUrl);
|
||||
if (base64 == null) {
|
||||
throw new ServiceException("文件转成base64,转码失败");
|
||||
throw new ServiceException("文件转成base64,转码失败pdfUrl:"+pdfUrl);
|
||||
// return false;
|
||||
}
|
||||
StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
|
||||
@@ -3468,12 +3468,16 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
|
||||
File outputFile = new File(pdfFilePath);
|
||||
|
||||
try {
|
||||
InputStream docxInputStream = new FileInputStream(inputWord);
|
||||
OutputStream outputStream = new FileOutputStream(outputFile);
|
||||
IConverter converter = LocalConverter.builder().build();
|
||||
converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
|
||||
docxInputStream.close();
|
||||
outputStream.close();
|
||||
LibreOfficeUtil.doc2pdf2(inputWord,outputFile);
|
||||
|
||||
|
||||
//
|
||||
// InputStream docxInputStream = new FileInputStream(inputWord);
|
||||
// OutputStream outputStream = new FileOutputStream(outputFile);
|
||||
// IConverter converter = LocalConverter.builder().build();
|
||||
// converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
|
||||
// docxInputStream.close();
|
||||
// outputStream.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e.getMessage()+"wordFilePath:"+wordFilePath+"pdfFilePath:"+pdfFilePath);
|
||||
|
||||
Reference in New Issue
Block a user