增加pdf文书生成
This commit is contained in:
parent
7bc71b5abf
commit
54ac166cdc
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.entity.EBaseinfo;
|
import com.chinaweal.aiccs.aiccs.abnormal.entity.EBaseinfo;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSWrit;
|
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSWrit;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.service.EBaseinfoService;
|
import com.chinaweal.aiccs.aiccs.abnormal.service.EBaseinfoService;
|
||||||
|
import com.chinaweal.aiccs.aiccs.abnormal.service.IGzaiccodeService;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.service.TSWritService;
|
import com.chinaweal.aiccs.aiccs.abnormal.service.TSWritService;
|
||||||
import com.chinaweal.aiccs.aiccs.business.entity.XrTaskList;
|
import com.chinaweal.aiccs.aiccs.business.entity.XrTaskList;
|
||||||
import com.chinaweal.aiccs.aiccs.business.entity.vo.XrTaskListVo;
|
import com.chinaweal.aiccs.aiccs.business.entity.vo.XrTaskListVo;
|
||||||
|
|
@ -25,6 +26,7 @@ import com.chinaweal.aiccs.aiccs.force.service.IXrForceDeregisterService;
|
||||||
import com.chinaweal.aiccs.aiccs.force.service.IXrForceDeregisterSpeService;
|
import com.chinaweal.aiccs.aiccs.force.service.IXrForceDeregisterSpeService;
|
||||||
import com.chinaweal.aiccs.aiccs.force.service.IXrForceNoticeService;
|
import com.chinaweal.aiccs.aiccs.force.service.IXrForceNoticeService;
|
||||||
import com.chinaweal.aiccs.aiccs.inspect.service.TSWorkNoService;
|
import com.chinaweal.aiccs.aiccs.inspect.service.TSWorkNoService;
|
||||||
|
import com.chinaweal.aiccs.aiccs.revoke.service.CreateFileService;
|
||||||
import com.chinaweal.aiccs.aiccs.seriousillegalPerson.common.emnu.AuthEnum;
|
import com.chinaweal.aiccs.aiccs.seriousillegalPerson.common.emnu.AuthEnum;
|
||||||
import com.chinaweal.aiccs.aiccs.system.entity.TRBaseCode;
|
import com.chinaweal.aiccs.aiccs.system.entity.TRBaseCode;
|
||||||
import com.chinaweal.aiccs.aiccs.system.service.TRBaseCodeService;
|
import com.chinaweal.aiccs.aiccs.system.service.TRBaseCodeService;
|
||||||
|
|
@ -43,6 +45,7 @@ import com.chinaweal.youfool.framework.springboot.exception.custom.BusinessExcep
|
||||||
import com.chinaweal.youfool.framework.springboot.util.ExpiryMap;
|
import com.chinaweal.youfool.framework.springboot.util.ExpiryMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -80,6 +83,10 @@ public class XrForceDeregisterSpeServiceImpl extends ServiceImpl<XrForceDeregist
|
||||||
private TSWritService tsWritService;
|
private TSWritService tsWritService;
|
||||||
@Resource
|
@Resource
|
||||||
private TSWorkNoService tsWorkNoService;
|
private TSWorkNoService tsWorkNoService;
|
||||||
|
@Autowired
|
||||||
|
private CreateFileService createFileService;
|
||||||
|
@Autowired
|
||||||
|
private IGzaiccodeService gzaiccodeService;
|
||||||
|
|
||||||
private static final ExpiryMap<String, Collection<?>> EXPIRY_MAP = new ExpiryMap<>(15 * 60);
|
private static final ExpiryMap<String, Collection<?>> EXPIRY_MAP = new ExpiryMap<>(15 * 60);
|
||||||
|
|
||||||
|
|
@ -587,6 +594,18 @@ public class XrForceDeregisterSpeServiceImpl extends ServiceImpl<XrForceDeregist
|
||||||
tsWritService.save(tsWritModel);
|
tsWritService.save(tsWritModel);
|
||||||
iXrForceDeregisterResService.saveOrUpdate(xrForceDeregisterRes);
|
iXrForceDeregisterResService.saveOrUpdate(xrForceDeregisterRes);
|
||||||
iXrForceNoticeService.saveOrUpdate(xrForceNotice);
|
iXrForceNoticeService.saveOrUpdate(xrForceNotice);
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
String nameByCode = gzaiccodeService.getNameByCode(gzaiccodeService.getNameByCode(StringUtils.clearRegionZero(xrForceSpe.getRegOrg())));
|
||||||
|
data.put("areaName", StringUtils.trimToEmpty(nameByCode));
|
||||||
|
data.put("writNo", StringUtils.trimToEmpty(tsWritModel.getWritsno()));
|
||||||
|
data.put("writContent", StringUtils.trimToEmpty(replaceContent));
|
||||||
|
LocalDate now = LocalDate.now();
|
||||||
|
data.put("year", String.valueOf(now.getYear()));
|
||||||
|
data.put("month", String.valueOf(now.getMonthValue() > 9 ? now.getMonthValue() : "0" + now.getMonthValue()));
|
||||||
|
data.put("day", String.valueOf(now.getDayOfMonth() > 9 ? now.getDayOfMonth() : "0" + now.getDayOfMonth()));
|
||||||
|
// 2026年2月4日 生成pdf文书
|
||||||
|
createFileService.createPdfCommon(xrForceSpe.getBizSeqNo(), "决定书送达公告", "强制注销决定送达公告",
|
||||||
|
"force", ".pdf", "/static/template/commonWritTemplate.docx", data);
|
||||||
return xrForceSpe;
|
return xrForceSpe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.chinaweal.aiccs.aiccs.revoke.service;
|
||||||
import com.chinaweal.aiccs.aiccs.revoke.entity.BizRevEnt;
|
import com.chinaweal.aiccs.aiccs.revoke.entity.BizRevEnt;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -98,8 +97,24 @@ public interface CreateFileService {
|
||||||
*/
|
*/
|
||||||
String createPdf(String bizseq, String fileName, String attachtype, String path, Map<String, Object> map);
|
String createPdf(String bizseq, String fileName, String attachtype, String path, Map<String, Object> map);
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据模板生成pdf文件
|
* 根据模板生成pdf文件
|
||||||
|
*
|
||||||
|
* @param bizseq 业务号-作文件夹
|
||||||
|
* @param title 标题
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @param moduleType 业务模块类型
|
||||||
|
* @param attachtype 文书类型
|
||||||
|
* @param templatePath 模版路径
|
||||||
|
* @param data 渲染数据
|
||||||
|
*/
|
||||||
|
String createPdfCommon(String bizseq, String title, String fileName, String moduleType, String attachtype, String templatePath, Map<String, Object> data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据模板生成pdf文件
|
||||||
|
*
|
||||||
* @param bizseq 业务号-作文件夹
|
* @param bizseq 业务号-作文件夹
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
* @param attachtype 文书类型
|
* @param attachtype 文书类型
|
||||||
|
|
@ -139,6 +154,7 @@ public interface CreateFileService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据指定列生成主体Excel清单
|
* 根据指定列生成主体Excel清单
|
||||||
|
*
|
||||||
* @param bizRevEnts
|
* @param bizRevEnts
|
||||||
*/
|
*/
|
||||||
String createEntExcel(String bizseq, String attachtype, List<BizRevEnt> bizRevEnts);
|
String createEntExcel(String bizseq, String attachtype, List<BizRevEnt> bizRevEnts);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package com.chinaweal.aiccs.aiccs.revoke.service.impl;
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.entity.EBaseinfo;
|
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSAttachment;
|
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSAttachment;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.service.EBaseinfoService;
|
import com.chinaweal.aiccs.aiccs.abnormal.service.EBaseinfoService;
|
||||||
import com.chinaweal.aiccs.aiccs.abnormal.service.TSAttachmentService;
|
import com.chinaweal.aiccs.aiccs.abnormal.service.TSAttachmentService;
|
||||||
|
|
@ -37,16 +36,13 @@ import com.deepoove.poi.render.RenderContext;
|
||||||
import com.deepoove.poi.xwpf.NiceXWPFDocument;
|
import com.deepoove.poi.xwpf.NiceXWPFDocument;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.cxf.Bus;
|
|
||||||
import org.apache.poi.xwpf.usermodel.VerticalAlign;
|
import org.apache.poi.xwpf.usermodel.VerticalAlign;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
import org.ddr.poi.html.HtmlRenderPolicy;
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -962,6 +958,79 @@ public class CreateFileServiceImpl implements CreateFileService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createPdfCommon(String bizseq, String title, String fileName, String moduleType, String attachtype, String templatePath, Map<String, Object> data) {
|
||||||
|
if (StringUtils.isNotBlank(bizseq)) {
|
||||||
|
// 标题
|
||||||
|
String ext = ".pdf";
|
||||||
|
String urlFileName = UUID.randomUUID().toString() + ext;
|
||||||
|
if (StringUtils.isBlank(moduleType)) {
|
||||||
|
moduleType = "common";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ByteArrayOutputStream wordOs = new ByteArrayOutputStream(); // word输出流
|
||||||
|
String resource = CreateFileServiceImpl.class.getClassLoader().getResource(templatePath).getPath();
|
||||||
|
|
||||||
|
//配置
|
||||||
|
// html内容处理
|
||||||
|
String htmlContent = data.get("htmlContent").toString();
|
||||||
|
Document htmldoc = Jsoup.parse(htmlContent);
|
||||||
|
Elements links = htmldoc.getElementsByTag("p");
|
||||||
|
ArrayList<Object> list = new ArrayList<>();
|
||||||
|
for (Element link : links) {
|
||||||
|
if (link.getElementsByAttributeValue("style", "text-align:right;").size() > 0) {
|
||||||
|
Elements value = link.getElementsByAttributeValue("style", "text-align:right;");
|
||||||
|
HashMap<String, Object> map2 = new HashMap<>();
|
||||||
|
map2.put("rightContent", value.text().trim());
|
||||||
|
list.add(map2);
|
||||||
|
} else if (link.getElementsByAttributeValue("style", "text-align:left;").size() > 0) {
|
||||||
|
Elements value = link.getElementsByAttributeValue("style", "text-align:left;");
|
||||||
|
HashMap<String, Object> map3 = new HashMap<>();
|
||||||
|
map3.put("leftContent", value.text().trim());
|
||||||
|
list.add(map3);
|
||||||
|
} else {
|
||||||
|
HashMap<String, Object> map1 = new HashMap<>();
|
||||||
|
map1.put("pragraph", link.text().trim());
|
||||||
|
list.add(map1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.put("htmlContent", list);
|
||||||
|
String pdfPath = CommonConfig.getUploadPath() + File.separator + moduleType + File.separator + bizseq + File.separator + title + File.separator + urlFileName;
|
||||||
|
XWPFTemplate.compile(resource).render(data).write(wordOs);
|
||||||
|
PdfUtil.convertDocx2Pdf(wordOs, pdfPath);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("附件文书pdf生成失败", e);
|
||||||
|
throw new BusinessException("附件文书pdf生成失败");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(fileName)) {
|
||||||
|
fileName = urlFileName;
|
||||||
|
} else if (fileName.lastIndexOf(Constant.DOT) > -1) {
|
||||||
|
fileName = fileName.substring(0, fileName.lastIndexOf(Constant.DOT)) + ext;
|
||||||
|
} else {
|
||||||
|
fileName = fileName + ext;
|
||||||
|
}
|
||||||
|
String tempPath = CommonConfig.getUploadPath() + File.separator + moduleType + File.separator + bizseq + File.separator + title + File.separator + urlFileName;
|
||||||
|
TSAttachment tsAttachmentModel = new TSAttachment();
|
||||||
|
tsAttachmentModel.setCreatetype("1");// 文件为系统生成
|
||||||
|
tsAttachmentModel.setBizseq(bizseq);
|
||||||
|
tsAttachmentModel.setAttachtype(attachtype);
|
||||||
|
tsAttachmentModel.setPripid(StringUtils.tranObject(data.get("pripid")));
|
||||||
|
tsAttachmentModel.setFileext(ext);
|
||||||
|
tsAttachmentModel.setFilename(fileName);
|
||||||
|
tsAttachmentModel.setTemppath(tempPath);
|
||||||
|
tsAttachmentModel.setUploaddate(LocalDate.now());
|
||||||
|
tsAttachmentModel.setLauptime(LocalDateTime.now());
|
||||||
|
tsAttachmentModel.setAttachtype(attachtype);// 审批表
|
||||||
|
// 没有加上传者及id 要改
|
||||||
|
boolean save = attachmentService.save(tsAttachmentModel);
|
||||||
|
if (save) {
|
||||||
|
return tempPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServletOutputStream createPdfStream(String bizseq, String fileName, String attachtype, String path, Map<String, Object> map, ServletOutputStream os) {
|
public ServletOutputStream createPdfStream(String bizseq, String fileName, String attachtype, String path, Map<String, Object> map, ServletOutputStream os) {
|
||||||
if (StringUtils.isNotBlank(bizseq)) {
|
if (StringUtils.isNotBlank(bizseq)) {
|
||||||
|
|
@ -1158,10 +1227,11 @@ public class CreateFileServiceImpl implements CreateFileService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建测试用例过程记录的渲染策略:解析对应的html并输出到word
|
* 创建测试用例过程记录的渲染策略:解析对应的html并输出到word
|
||||||
* @author xuwangcheng
|
*
|
||||||
* @date 2019/7/26 10:10
|
|
||||||
* @param
|
* @param
|
||||||
* @return {@link AbstractRenderPolicy}
|
* @return {@link AbstractRenderPolicy}
|
||||||
|
* @author xuwangcheng
|
||||||
|
* @date 2019/7/26 10:10
|
||||||
*/
|
*/
|
||||||
private static AbstractRenderPolicy createHtmlRenderPolicy() {
|
private static AbstractRenderPolicy createHtmlRenderPolicy() {
|
||||||
return new AbstractRenderPolicy() {
|
return new AbstractRenderPolicy() {
|
||||||
|
|
@ -1202,12 +1272,13 @@ public class CreateFileServiceImpl implements CreateFileService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换整个html内容为word内容
|
* 转换整个html内容为word内容
|
||||||
* @author xuwangcheng
|
*
|
||||||
* @date 2019/7/29 18:46
|
|
||||||
* @param ele ele
|
* @param ele ele
|
||||||
* @param doc doc
|
* @param doc doc
|
||||||
* @param xwpfParagraph xwpfParagraph
|
* @param xwpfParagraph xwpfParagraph
|
||||||
* @return {@link XWPFParagraph}
|
* @return {@link XWPFParagraph}
|
||||||
|
* @author xuwangcheng
|
||||||
|
* @date 2019/7/29 18:46
|
||||||
*/
|
*/
|
||||||
private static XWPFParagraph parseHtmlToWord(Element ele, NiceXWPFDocument doc, XWPFParagraph xwpfParagraph
|
private static XWPFParagraph parseHtmlToWord(Element ele, NiceXWPFDocument doc, XWPFParagraph xwpfParagraph
|
||||||
, boolean isParent) throws Exception {
|
, boolean isParent) throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -232,4 +232,54 @@ public abstract class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
public static String getUUID() {
|
public static String getUUID() {
|
||||||
return UUID.randomUUID().toString().replace("-", "");
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除行政区划尾端的0
|
||||||
|
*
|
||||||
|
* @param regionCode 行政区划
|
||||||
|
* @return 清除后的0
|
||||||
|
* @author lroyia
|
||||||
|
* @since 2023年7月3日 14:02:52
|
||||||
|
*/
|
||||||
|
public static String clearRegionZero(String regionCode) {
|
||||||
|
if (isBlank(regionCode)) {
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
int maxLength = regionCode.length() / 2 > 3 ? 4 : (regionCode.length() / 2);
|
||||||
|
for (int i = maxLength; i > 0; i--) {
|
||||||
|
int startIndex = (i - 1) * 2;
|
||||||
|
int endIndex = i == 4 ? 9 : (i * 2);
|
||||||
|
if (clearSuffixZero(regionCode.substring(startIndex, endIndex)).isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return regionCode.substring(0, endIndex);
|
||||||
|
}
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除字符串尾部的0
|
||||||
|
*
|
||||||
|
* @param str 字符串
|
||||||
|
* @return 清除结果
|
||||||
|
* @author lroyia
|
||||||
|
* @since 2023年3月1日 09:22:43
|
||||||
|
*/
|
||||||
|
public static String clearSuffixZero(String str) {
|
||||||
|
if (isBlank(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
int index = -1;
|
||||||
|
for (int i = str.length() - 1; i > -1; i--) {
|
||||||
|
if (str.charAt(i) != '0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
if (index > -1) {
|
||||||
|
str = str.substring(0, index);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue