diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/force/service/impl/XrForceDeregisterSpeServiceImpl.java b/src/main/java/com/chinaweal/aiccs/aiccs/force/service/impl/XrForceDeregisterSpeServiceImpl.java index eddc178..0d21520 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/force/service/impl/XrForceDeregisterSpeServiceImpl.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/force/service/impl/XrForceDeregisterSpeServiceImpl.java @@ -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.TSWrit; 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.business.entity.XrTaskList; 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.IXrForceNoticeService; 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.system.entity.TRBaseCode; 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.google.common.collect.Lists; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -80,6 +83,10 @@ public class XrForceDeregisterSpeServiceImpl extends ServiceImpl> EXPIRY_MAP = new ExpiryMap<>(15 * 60); @@ -587,6 +594,18 @@ public class XrForceDeregisterSpeServiceImpl extends ServiceImpl 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; } diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/CreateFileService.java b/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/CreateFileService.java index dcb6096..ddda8ef 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/CreateFileService.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/CreateFileService.java @@ -3,12 +3,11 @@ package com.chinaweal.aiccs.aiccs.revoke.service; import com.chinaweal.aiccs.aiccs.revoke.entity.BizRevEnt; import javax.servlet.ServletOutputStream; -import java.io.ByteArrayOutputStream; import java.util.List; import java.util.Map; /** - * 批吊审批流程生成文件创建 + * 批吊审批流程生成文件创建 * * @Author Lee * @Since 2021/5/17 18:02 @@ -18,118 +17,134 @@ public interface CreateFileService { /** * 生成立案/不予立案审批表 * - * @param bizseq 业务号 - * @param pripid 主体id - * @param areaName 区名称 - * @param workflowId 工作流id + * @param bizseq 业务号 + * @param pripid 主体id + * @param areaName 区名称 + * @param workflowId 工作流id */ - void createCaseApprovalDocx(String bizseq,String areaName, String pripid,String workflowId) throws Exception; + void createCaseApprovalDocx(String bizseq, String areaName, String pripid, String workflowId) throws Exception; /** - * 生成听证告知审批表 + * 生成听证告知审批表 * - * @param bizseq 业务号 - * @param workflowId 流程id + * @param bizseq 业务号 + * @param workflowId 流程id */ - void createHearingApprovalDocx(String bizseq,String entname,String workflowId); + void createHearingApprovalDocx(String bizseq, String entname, String workflowId); /** - * 生成行政处罚建议审批表 + * 生成行政处罚建议审批表 * - * @param bizseq 业务号 - * @param workflowId 流程id + * @param bizseq 业务号 + * @param workflowId 流程id */ - void createPunishAdviceApprDocx(String bizseq, String areaName,String workflowId)throws Exception; + void createPunishAdviceApprDocx(String bizseq, String areaName, String workflowId) throws Exception; /** - * 生成行政处罚决定审批表 + * 生成行政处罚决定审批表 * - * @param bizseq 业务号 - * @param workflowId 流程id + * @param bizseq 业务号 + * @param workflowId 流程id */ - void createPunishDecisionApprDocx(String bizseq, String areaName,String workflowId)throws Exception; + void createPunishDecisionApprDocx(String bizseq, String areaName, String workflowId) throws Exception; /** - * 生成决定审批表 + * 生成决定审批表 * - * @param bizseq 业务号 - * @param workflowId 流程id + * @param bizseq 业务号 + * @param workflowId 流程id */ - void createDecisionApprovalDocx(String bizseq,String entname,String workflowId); + void createDecisionApprovalDocx(String bizseq, String entname, String workflowId); /** - * 生成送达审批表 + * 生成送达审批表 * - * @param bizseq 业务号 - * @param workflowId 流程id + * @param bizseq 业务号 + * @param workflowId 流程id */ - void createSendApprovalDocx(String bizseq,String workflowId); + void createSendApprovalDocx(String bizseq, String workflowId); /** - * 生成调查审批表 + * 生成调查审批表 * - * @param bizseq 业务号 - * @param workflowId 流程id - * @param areaName 区名称 - * @param entname 主体名称 + * @param bizseq 业务号 + * @param workflowId 流程id + * @param areaName 区名称 + * @param entname 主体名称 */ - void createInvestigateApprovalDocx(String bizseq,String areaName, String entname,String workflowId); + void createInvestigateApprovalDocx(String bizseq, String areaName, String entname, String workflowId); /** - * 根据模板生成文件 + * 根据模板生成文件 * - * @param bizseq 业务号-作文件夹 - * @param fileName 文件名 - * @param attachtype 文书类型 - * @param path 模板文件路径 - * @param map 模板参数 + * @param bizseq 业务号-作文件夹 + * @param fileName 文件名 + * @param attachtype 文书类型 + * @param path 模板文件路径 + * @param map 模板参数 */ - String createDocx(String bizseq,String fileName,String attachtype, String path, Map map); + String createDocx(String bizseq, String fileName, String attachtype, String path, Map map); /** - * 根据模板生成pdf文件 + * 根据模板生成pdf文件 * - * @param bizseq 业务号-作文件夹 - * @param fileName 文件名 - * @param attachtype 文书类型 - * @param path 模板文件路径 - * @param map 模板参数 + * @param bizseq 业务号-作文件夹 + * @param fileName 文件名 + * @param attachtype 文书类型 + * @param path 模板文件路径 + * @param map 模板参数 */ - String createPdf(String bizseq,String fileName,String attachtype, String path, Map map); + String createPdf(String bizseq, String fileName, String attachtype, String path, Map map); + + ; /** - * 根据模板生成pdf文件 - * @param bizseq 业务号-作文件夹 - * @param fileName 文件名 - * @param attachtype 文书类型 - * @param path 模板文件路径 - * @param map 模板参数 + * 根据模板生成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 data); + + /** + * 根据模板生成pdf文件 + * + * @param bizseq 业务号-作文件夹 + * @param fileName 文件名 + * @param attachtype 文书类型 + * @param path 模板文件路径 + * @param map 模板参数 * @param os */ - ServletOutputStream createPdfStream(String bizseq, String fileName, String attachtype, String path, Map map, ServletOutputStream os); + ServletOutputStream createPdfStream(String bizseq, String fileName, String attachtype, String path, Map map, ServletOutputStream os); /** - * 根据模板生成文件 对象参数 + * 根据模板生成文件 对象参数 * - * @param bizseq 业务号-作文件夹 - * @param fileName 文件名 - * @param attachtype 文书类型 - * @param path 模板文件路径 - * @param map 模板数据集合 + * @param bizseq 业务号-作文件夹 + * @param fileName 文件名 + * @param attachtype 文书类型 + * @param path 模板文件路径 + * @param map 模板数据集合 */ - void createDocxWithModel(String bizseq,String fileName,String attachtype, String path, Map map); + void createDocxWithModel(String bizseq, String fileName, String attachtype, String path, Map map); /** - * 根据模板生成案件终结调查报告文件 + * 根据模板生成案件终结调查报告文件 * - * @param bizseq 业务号-作文件夹 - * @param fileName 文件名 - * @param attachtype 文书类型 - * @param path 模板文件路径 - * @param map 模板数据集合 + * @param bizseq 业务号-作文件夹 + * @param fileName 文件名 + * @param attachtype 文书类型 + * @param path 模板文件路径 + * @param map 模板数据集合 */ - void createCasePdfWithModel(String bizseq,String fileName,String attachtype, String path, Map map); + void createCasePdfWithModel(String bizseq, String fileName, String attachtype, String path, Map map); // /** // * 根据指定列生成主体Excel清单 @@ -138,10 +153,11 @@ public interface CreateFileService { // String createEntExcel(String bizseq,String attachtype,List pripids); /** - * 根据指定列生成主体Excel清单 + * 根据指定列生成主体Excel清单 + * * @param bizRevEnts */ - String createEntExcel(String bizseq,String attachtype,List bizRevEnts); + String createEntExcel(String bizseq, String attachtype, List bizRevEnts); String createPdfZx(String bizseq, String fileName, String number, String path, Map map); } diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/impl/CreateFileServiceImpl.java b/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/impl/CreateFileServiceImpl.java index a915197..a3f924d 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/impl/CreateFileServiceImpl.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/revoke/service/impl/CreateFileServiceImpl.java @@ -3,7 +3,6 @@ package com.chinaweal.aiccs.aiccs.revoke.service.impl; import cn.hutool.core.util.ReUtil; import com.alibaba.excel.EasyExcel; 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.service.EBaseinfoService; 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 lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; -import org.apache.cxf.Bus; import org.apache.poi.xwpf.usermodel.VerticalAlign; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; -import org.ddr.poi.html.HtmlRenderPolicy; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -61,7 +57,7 @@ import java.time.LocalDateTime; import java.util.*; /** - * 批吊审批流程生成文件创建 + * 批吊审批流程生成文件创建 * * @Author Lee * @Since 2021/5/17 18:02 @@ -100,45 +96,45 @@ public class CreateFileServiceImpl implements CreateFileService { // map.put("uniscid",eBaseinfo.getUniscid()); // map.put("name",eBaseinfo.getName()); // map.put("dom",eBaseinfo.getDom()); - map.put("areaName",areaName); + map.put("areaName", areaName); // String entname = eBaseinfo.getEntname(); Map caseFromMap = baseCodeService.getBaseCodeMapFormCache("CE03"); // map.put("caseFrom", caseFromMap.get(tsCase.getCaseFrom()).getName()); - map.put("situation",tsCase.getSituation()); - map.put("registTime", DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(),"yyyy年MM月dd日") ); - map.put("caseName",tsCase.getCaseName()); - map.put("remarks",tsCase.getRemarks()); + map.put("situation", tsCase.getSituation()); + map.put("registTime", DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(), "yyyy年MM月dd日")); + map.put("caseName", tsCase.getCaseName()); + map.put("remarks", tsCase.getRemarks()); // 立案或不予立案 标题 - String type = tsCase.getIsRegister().equals("1")? "立案":"不予立案"; - map.put("type",type); - String title = tsCase.getIsRegister().equals("1")? "立案审批表": "不予立案审批表"; - map.put("title",title); + String type = tsCase.getIsRegister().equals("1") ? "立案" : "不予立案"; + map.put("type", type); + String title = tsCase.getIsRegister().equals("1") ? "立案审批表" : "不予立案审批表"; + map.put("title", title); //获取按时间降序,立案意见标识1 2 3排序好的意见列表 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"1","2","3") + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "1", "2", "3") .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("1".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("handler1",item.getHandler()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("handler1", item.getHandler()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("2".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("handler2",item.getHandler()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("handler2", item.getHandler()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("3".equals(item.getOpiniontype()) && !flag2) { @@ -155,7 +151,7 @@ public class CreateFileServiceImpl implements CreateFileService { String urlFileName = UUID.randomUUID().toString() + "caseApproval" + ext; try { ByteArrayOutputStream wordOs = new ByteArrayOutputStream(); // word输出流 - String wordPath = "static" + File.separator+ "template" + File.separator + "caseApproval.docx"; + String wordPath = "static" + File.separator + "template" + File.separator + "caseApproval.docx"; String resource = CreateFileServiceImpl.class.getClassLoader().getResource(wordPath).getPath(); // String realPath = CommonConfig.getUploadPath(); @@ -189,7 +185,7 @@ public class CreateFileServiceImpl implements CreateFileService { @Override public void createPunishAdviceApprDocx(String bizseq, String areaName, String workflowId) throws Exception { - if(StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { + if (StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { AICUser user = SSOUtil.getUser(); String userOrg = StringUtils.substring(user.getRegionID(), 0, 6); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -207,37 +203,37 @@ public class CreateFileServiceImpl implements CreateFileService { // 标题 String title = "行政处罚建议审批表"; - map.put("title",title); - map.put("areaName",areaName); + map.put("title", title); + map.put("areaName", areaName); //获取按时间降序,调查意见标识4 8 9排序好的意见列表 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"4","8","9") + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "4", "8", "9") .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("4".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("handler1",item.getHandler()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("handler1", item.getHandler()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("8".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("handler2",item.getHandler()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("handler2", item.getHandler()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("9".equals(item.getOpiniontype()) && !flag2) { - map.put("approvalOpinion",item.getOpinioncontent()); + map.put("approvalOpinion", item.getOpinioncontent()); map.put("handler3", item.getHandler()); map.put("year3", item.getHandledate().getYear()); map.put("month3", item.getHandledate().getMonthValue()); @@ -251,7 +247,7 @@ public class CreateFileServiceImpl implements CreateFileService { String urlFileName = UUID.randomUUID().toString() + "punishAdviceAppr" + ext; try { ByteArrayOutputStream wordOs = new ByteArrayOutputStream(); // word输出流 - String wordPath = "static" + File.separator+ "template" + File.separator + "punishAdviceAppr.docx"; + String wordPath = "static" + File.separator + "template" + File.separator + "punishAdviceAppr.docx"; String resource = CreateFileServiceImpl.class.getClassLoader().getResource(wordPath).getPath(); // String realPath = CommonConfig.getUploadPath(); @@ -285,7 +281,7 @@ public class CreateFileServiceImpl implements CreateFileService { @Override public void createPunishDecisionApprDocx(String bizseq, String areaName, String workflowId) throws Exception { - if(StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { + if (StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { AICUser user = SSOUtil.getUser(); String userOrg = StringUtils.substring(user.getRegionID(), 0, 6); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -298,53 +294,53 @@ public class CreateFileServiceImpl implements CreateFileService { map.put("caseName", tsCase.getCaseName()); map.put("registTime", DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(), "yyyy年MM月dd日")); if (StringUtils.isNotBlank(tsCase.getIsReviewHearing())) { - if(tsCase.getIsReviewHearing().equals("1")){ - map.put("isReviewHearing","当事人未提出陈述、申辩意见或者未申请听证"); - }else if(tsCase.getIsReviewHearing().equals("2")){ - map.put("isReviewHearing","案件经复核或者听证"); - }else { - map.put("isReviewHearing",StringUtils.EMPTY); + if (tsCase.getIsReviewHearing().equals("1")) { + map.put("isReviewHearing", "当事人未提出陈述、申辩意见或者未申请听证"); + } else if (tsCase.getIsReviewHearing().equals("2")) { + map.put("isReviewHearing", "案件经复核或者听证"); + } else { + map.put("isReviewHearing", StringUtils.EMPTY); } - }else { - map.put("isReviewHearing",StringUtils.EMPTY); + } else { + map.put("isReviewHearing", StringUtils.EMPTY); } - map.put("advicePunishContent",tsCase.getAdvicePunishContent()); - map.put("pleadOpinion",tsCase.getPleadOpinion()); - map.put("reviewHearingOpinion",tsCase.getReviewHearingOpinion()); + map.put("advicePunishContent", tsCase.getAdvicePunishContent()); + map.put("pleadOpinion", tsCase.getPleadOpinion()); + map.put("reviewHearingOpinion", tsCase.getReviewHearingOpinion()); // 标题 String title = "行政处理决定审批表"; - map.put("title",title); - map.put("areaName",areaName); + map.put("title", title); + map.put("areaName", areaName); //获取按时间降序,决定意见标识10 11 13排序好的意见列表 29为法规负责人,11为办案负责人 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"10","11","13")//29为法规负责人,11为办案负责人 + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "10", "11", "13")//29为法规负责人,11为办案负责人 .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("10".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("handler1",item.getHandler()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("handler1", item.getHandler()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("11".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("handler2",item.getHandler()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("handler2", item.getHandler()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("13".equals(item.getOpiniontype()) && !flag2) { - map.put("approvalOpinion",item.getOpinioncontent()); + map.put("approvalOpinion", item.getOpinioncontent()); map.put("handler3", item.getHandler()); map.put("year3", item.getHandledate().getYear()); map.put("month3", item.getHandledate().getMonthValue()); @@ -358,7 +354,7 @@ public class CreateFileServiceImpl implements CreateFileService { String urlFileName = UUID.randomUUID().toString() + "punishDecisionAppr" + ext; try { ByteArrayOutputStream wordOs = new ByteArrayOutputStream(); // word输出流 - String wordPath = "static" + File.separator+ "template" + File.separator + "punishDecisionAppr.docx"; + String wordPath = "static" + File.separator + "template" + File.separator + "punishDecisionAppr.docx"; String resource = CreateFileServiceImpl.class.getClassLoader().getResource(wordPath).getPath(); // String realPath = CommonConfig.getUploadPath(); // realPath += File.separator + bizseq+ File.separator + "punishDecisionAppr"; @@ -374,7 +370,7 @@ public class CreateFileServiceImpl implements CreateFileService { e.printStackTrace(); throw new BusinessException("行政处理决定审批表附件生成出错"); } - String tempPath = "BatchRevocation" + File.separator + bizseq + File.separator + "punishDecisionAppr" + File.separator + urlFileName; + String tempPath = "BatchRevocation" + File.separator + bizseq + File.separator + "punishDecisionAppr" + File.separator + urlFileName; TSAttachment tsAttachmentModel = new TSAttachment(); tsAttachmentModel.setCreatetype("1");// 文件为系统生成 tsAttachmentModel.setBizseq(bizseq); @@ -391,58 +387,58 @@ public class CreateFileServiceImpl implements CreateFileService { } @Override - public void createHearingApprovalDocx(String bizseq,String entname, String workflowId) { - if(StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { + public void createHearingApprovalDocx(String bizseq, String entname, String workflowId) { + if (StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TsCase::getBizseq,bizseq); + wrapper.eq(TsCase::getBizseq, bizseq); TsCase tsCase = caseService.getOne(wrapper); // 案件信息 - if(tsCase != null){ + if (tsCase != null) { Map map = new HashMap<>(); - map.put("caseName",tsCase.getCaseName()); - map.put("caseNo",tsCase.getCaseNo()); + map.put("caseName", tsCase.getCaseName()); + map.put("caseNo", tsCase.getCaseNo()); // map.put("place",tsCase.getPlace()); Map caseFromMap = baseCodeService.getBaseCodeMapFormCache("CE03"); // map.put("caseFrom", caseFromMap.get(tsCase.getCaseFrom()).getName()); - map.put("registTime",DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(),"yyyy年MM月dd日")); + map.put("registTime", DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(), "yyyy年MM月dd日")); // 标题 String title = "听证告知审批表"; - map.put("title",title); + map.put("title", title); //获取按时间降序,调查意见标识7 8 9排序好的意见列表 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"7","8","9") + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "7", "8", "9") .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("7".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("handler1",item.getHandler()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("handler1", item.getHandler()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("8".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("handler2",item.getHandler()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("handler2", item.getHandler()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("9".equals(item.getOpiniontype()) && !flag2) { - map.put("approvalOpinion",item.getOpinioncontent()); - map.put("handler3",item.getHandler()); - map.put("year3",item.getHandledate().getYear()); - map.put("month3",item.getHandledate().getMonthValue()); - map.put("day3",item.getHandledate().getDayOfMonth()); + map.put("approvalOpinion", item.getOpinioncontent()); + map.put("handler3", item.getHandler()); + map.put("year3", item.getHandledate().getYear()); + map.put("month3", item.getHandledate().getMonthValue()); + map.put("day3", item.getHandledate().getDayOfMonth()); flag2 = true; } } @@ -451,7 +447,7 @@ public class CreateFileServiceImpl implements CreateFileService { String fileName = entname + "-" + title + ext; String urlFileName = UUID.randomUUID().toString() + "hearingAppr" + ext; try { - String wordPath = "static" + File.separator+ "template" + File.separator + "hearingAppr.docx"; + String wordPath = "static" + File.separator + "template" + File.separator + "hearingAppr.docx"; String resource = CreateFileServiceImpl.class.getClassLoader().getResource(wordPath).getPath(); String realPath = CommonConfig.getUploadPath(); @@ -480,66 +476,66 @@ public class CreateFileServiceImpl implements CreateFileService { } @Override - public void createDecisionApprovalDocx(String bizseq,String entname, String workflowId) { - if(StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { + public void createDecisionApprovalDocx(String bizseq, String entname, String workflowId) { + if (StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TsCase::getBizseq,bizseq); + wrapper.eq(TsCase::getBizseq, bizseq); TsCase tsCase = caseService.getOne(wrapper); // 案件信息 - if(tsCase != null){ + if (tsCase != null) { Map map = new HashMap<>(); - map.put("caseName",tsCase.getCaseName()); - map.put("caseNo",tsCase.getCaseNo()); + map.put("caseName", tsCase.getCaseName()); + map.put("caseNo", tsCase.getCaseNo()); // map.put("place",tsCase.getPlace()); Map caseFromMap = baseCodeService.getBaseCodeMapFormCache("CE03"); // map.put("caseFrom", caseFromMap.get(tsCase.getCaseFrom()).getName()); - map.put("registTime",DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(),"yyyy年MM月dd日")); + map.put("registTime", DateUtils.localDateFormat(tsCase.getRegistTime().toLocalDate(), "yyyy年MM月dd日")); // 标题 String title = "行政处理决定审批表"; - map.put("title",title); + map.put("title", title); //获取按时间降序,决定意见标识10 11 12 13排序好的意见列表 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"10","11","12","13") + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "10", "11", "12", "13") .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("10".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("handler1",item.getHandler()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("handler1", item.getHandler()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("11".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("handler2",item.getHandler()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("handler2", item.getHandler()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("12".equals(item.getOpiniontype()) && !flag1) { - map.put("departOpinion",item.getOpinioncontent()); - map.put("handler3",item.getHandler()); - map.put("year3",item.getHandledate().getYear()); - map.put("month3",item.getHandledate().getMonthValue()); - map.put("day3",item.getHandledate().getDayOfMonth()); + map.put("departOpinion", item.getOpinioncontent()); + map.put("handler3", item.getHandler()); + map.put("year3", item.getHandledate().getYear()); + map.put("month3", item.getHandledate().getMonthValue()); + map.put("day3", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("13".equals(item.getOpiniontype()) && !flag2) { - map.put("approvalOpinion",item.getOpinioncontent()); - map.put("handler4",item.getHandler()); - map.put("year4",item.getHandledate().getYear()); - map.put("month4",item.getHandledate().getMonthValue()); - map.put("day4",item.getHandledate().getDayOfMonth()); + map.put("approvalOpinion", item.getOpinioncontent()); + map.put("handler4", item.getHandler()); + map.put("year4", item.getHandledate().getYear()); + map.put("month4", item.getHandledate().getMonthValue()); + map.put("day4", item.getHandledate().getDayOfMonth()); flag2 = true; } } @@ -547,10 +543,10 @@ public class CreateFileServiceImpl implements CreateFileService { String fileName = entname + "-" + title + ext; String urlFileName = UUID.randomUUID().toString() + "decisionAppr" + ext; try { - String wordPath = "static" + File.separator+ "template" + File.separator + "decisionAppr.docx"; + String wordPath = "static" + File.separator + "template" + File.separator + "decisionAppr.docx"; String resource = CreateFileServiceImpl.class.getClassLoader().getResource(wordPath).getPath(); String realPath = CommonConfig.getUploadPath(); - realPath += File.separator + bizseq+ File.separator + "decisionAppr"; + realPath += File.separator + bizseq + File.separator + "decisionAppr"; File dir = new File(realPath); dir.mkdirs(); XWPFTemplate.compile(resource).render(map).writeToFile(realPath + File.separator + urlFileName); @@ -576,54 +572,54 @@ public class CreateFileServiceImpl implements CreateFileService { @Override public void createSendApprovalDocx(String bizseq, String workflowId) { - if(StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { + if (StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TsCase::getBizseq,bizseq); + wrapper.eq(TsCase::getBizseq, bizseq); TsCase tsCase = caseService.getOne(wrapper); // 案件信息 - if(tsCase != null){ + if (tsCase != null) { Map map = new HashMap<>(); - map.put("caseName",tsCase.getCaseName()); - map.put("caseNo",tsCase.getCaseNo()); + map.put("caseName", tsCase.getCaseName()); + map.put("caseNo", tsCase.getCaseNo()); // map.put("place",tsCase.getPlace()); Map caseFromMap = baseCodeService.getBaseCodeMapFormCache("CE03"); // map.put("caseFrom", caseFromMap.get(tsCase.getCaseFrom()).getName()); - map.put("registTime",tsCase.getRegistTime()); + map.put("registTime", tsCase.getRegistTime()); // 标题 String title = "送达审批表"; - map.put("title",title); + map.put("title", title); //获取按时间降序,调查意见标识14 15 16排序好的意见列表 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"14","15","16") + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "14", "15", "16") .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("14".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("15".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("16".equals(item.getOpiniontype()) && !flag2) { - map.put("approvalOpinion",item.getOpinioncontent()); - map.put("year3",item.getHandledate().getYear()); - map.put("month3",item.getHandledate().getMonthValue()); - map.put("day3",item.getHandledate().getDayOfMonth()); + map.put("approvalOpinion", item.getOpinioncontent()); + map.put("year3", item.getHandledate().getYear()); + map.put("month3", item.getHandledate().getMonthValue()); + map.put("day3", item.getHandledate().getDayOfMonth()); flag2 = true; } } @@ -660,16 +656,16 @@ public class CreateFileServiceImpl implements CreateFileService { } @Override - public void createInvestigateApprovalDocx(String bizseq,String areaName, String entname, String workflowId) { - if(StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { + public void createInvestigateApprovalDocx(String bizseq, String areaName, String entname, String workflowId) { + if (StringUtils.isNotBlank(bizseq) && StringUtils.isNotBlank(workflowId)) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(TsCase::getBizseq,bizseq); + wrapper.eq(TsCase::getBizseq, bizseq); TsCase tsCase = caseService.getOne(wrapper); // 案件信息 - if(tsCase != null){ + if (tsCase != null) { Map map = new HashMap<>(); - map.put("caseName",tsCase.getCaseName()); + map.put("caseName", tsCase.getCaseName()); map.put("areaName", areaName); // map.put("caseNo",tsCase.getCaseNo()); // Map caseFromMap = baseCodeService.getBaseCodeMapFormCache("CE03"); @@ -678,7 +674,7 @@ public class CreateFileServiceImpl implements CreateFileService { // 标题 String title = "调查审批表"; - map.put("title",title); + map.put("title", title); String ext = ".docx"; // String fileName = entname + "-" + title + ext; String fileName = title + ext; @@ -687,42 +683,42 @@ public class CreateFileServiceImpl implements CreateFileService { //获取按时间降序,调查意见标识4 5 6排序好的意见列表 List list = opinionService.list(new LambdaQueryWrapper() .eq(TSOpinion::getWorkflowid, workflowId) - .eq(TSOpinion::getIsagree,"1") - .in(TSOpinion::getOpiniontype,"4","8","9") + .eq(TSOpinion::getIsagree, "1") + .in(TSOpinion::getOpiniontype, "4", "8", "9") .orderByAsc(TSOpinion::getOpiniontype).orderByDesc(TSOpinion::getLauptime)); boolean flag0 = false; boolean flag1 = false; boolean flag2 = false; for (TSOpinion item : list) { if ("4".equals(item.getOpiniontype()) && !flag0) { - map.put("enterOpinion",item.getOpinioncontent()); - map.put("handler1",item.getHandler()); - map.put("year1",item.getHandledate().getYear()); - map.put("month1",item.getHandledate().getMonthValue()); - map.put("day1",item.getHandledate().getDayOfMonth()); + map.put("enterOpinion", item.getOpinioncontent()); + map.put("handler1", item.getHandler()); + map.put("year1", item.getHandledate().getYear()); + map.put("month1", item.getHandledate().getMonthValue()); + map.put("day1", item.getHandledate().getDayOfMonth()); flag0 = true; } if ("8".equals(item.getOpiniontype()) && !flag1) { - map.put("handleOpinion",item.getOpinioncontent()); - map.put("handler2",item.getHandler()); - map.put("year2",item.getHandledate().getYear()); - map.put("month2",item.getHandledate().getMonthValue()); - map.put("day2",item.getHandledate().getDayOfMonth()); + map.put("handleOpinion", item.getOpinioncontent()); + map.put("handler2", item.getHandler()); + map.put("year2", item.getHandledate().getYear()); + map.put("month2", item.getHandledate().getMonthValue()); + map.put("day2", item.getHandledate().getDayOfMonth()); flag1 = true; } if ("9".equals(item.getOpiniontype()) && !flag2) { - map.put("approvalOpinion",item.getOpinioncontent()); - map.put("handler3",item.getHandler()); - map.put("year3",item.getHandledate().getYear()); - map.put("month3",item.getHandledate().getMonthValue()); - map.put("day3",item.getHandledate().getDayOfMonth()); + map.put("approvalOpinion", item.getOpinioncontent()); + map.put("handler3", item.getHandler()); + map.put("year3", item.getHandledate().getYear()); + map.put("month3", item.getHandledate().getMonthValue()); + map.put("day3", item.getHandledate().getDayOfMonth()); flag2 = true; } } try { ByteArrayOutputStream wordOs = new ByteArrayOutputStream(); // word输出流 - String wordPath = "static" + File.separator+ "template" + File.separator + "investigateAppr.docx"; + String wordPath = "static" + File.separator + "template" + File.separator + "investigateAppr.docx"; String resource = CreateFileServiceImpl.class.getClassLoader().getResource(wordPath).getPath(); // String realPath = CommonConfig.getUploadPath(); @@ -754,10 +750,10 @@ public class CreateFileServiceImpl implements CreateFileService { } @Override - public String createDocx(String bizseq, String fileName,String attachtype, String path, Map map) { - if(StringUtils.isNotBlank(bizseq)) { + public String createDocx(String bizseq, String fileName, String attachtype, String path, Map map) { + if (StringUtils.isNotBlank(bizseq)) { // 标题 - String title = path.substring(path.lastIndexOf(File.separator) + 1,path.lastIndexOf(Constant.DOT)); + String title = path.substring(path.lastIndexOf(File.separator) + 1, path.lastIndexOf(Constant.DOT)); String ext = ".docx"; String urlFileName = UUID.randomUUID().toString() + ext; try { @@ -776,23 +772,23 @@ public class CreateFileServiceImpl implements CreateFileService { Elements links = htmldoc.getElementsByTag("p"); ArrayList list = new ArrayList<>(); for (Element link : links) { - if(link.getElementsByAttributeValue("style","text-align:right;").size() > 0){ + if (link.getElementsByAttributeValue("style", "text-align:right;").size() > 0) { Elements value = link.getElementsByAttributeValue("style", "text-align:right;"); HashMap map2 = new HashMap<>(); - map2.put("rightContent",value.text().trim()); + map2.put("rightContent", value.text().trim()); list.add(map2); - }else if(link.getElementsByAttributeValue("style","text-align:left;").size() > 0){ + } else if (link.getElementsByAttributeValue("style", "text-align:left;").size() > 0) { Elements value = link.getElementsByAttributeValue("style", "text-align:left;"); HashMap map3 = new HashMap<>(); - map3.put("leftContent",value.text().trim()); + map3.put("leftContent", value.text().trim()); list.add(map3); - }else { + } else { HashMap map1 = new HashMap<>(); map1.put("pragraph", link.text().trim()); list.add(map1); } } - map.put("htmlContent",list); + map.put("htmlContent", list); String wordpath = bizseq + File.separator + title + File.separator + urlFileName; XWPFTemplate.compile(resource).render(map).write(wordOs); FileStorageService fileStorageService = SpringUtil.getBean(FileStorageService.class); @@ -805,28 +801,28 @@ public class CreateFileServiceImpl implements CreateFileService { } if (StringUtils.isBlank(fileName)) { fileName = title + ext; - }else if(fileName.lastIndexOf(Constant.DOT) > -1){ + } else if (fileName.lastIndexOf(Constant.DOT) > -1) { fileName = fileName.substring(0, fileName.lastIndexOf(Constant.DOT)) + ext; - }else { + } else { fileName = fileName + ext; } String tempPath = bizseq + File.separator + title + File.separator + urlFileName; - if( map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")){ + if (map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")) { return tempPath; } boolean save = false; - if("20".equals(attachtype)){// 针对批吊业务的处罚决定书预览附件 + if ("20".equals(attachtype)) {// 针对批吊业务的处罚决定书预览附件 TSAttachment tsAttachment = new TSAttachment(); tsAttachment.setBizseq(bizseq).setAttachtype("20"); List tsAttachments = attachmentService.selectwritByPage(tsAttachment); - if(CollectionUtils.isNotEmpty(tsAttachments)){ + if (CollectionUtils.isNotEmpty(tsAttachments)) { TSAttachment attachment = tsAttachments.get(0); attachment.setTemppath(tempPath); attachment.setUploaddate(LocalDate.now()); attachment.setLauptime(LocalDateTime.now()); save = attachmentService.updateById(attachment); - }else { + } else { TSAttachment tsAttachmentModel = new TSAttachment(); tsAttachmentModel.setCreatetype("1");// 文件为系统生成 tsAttachmentModel.setBizseq(bizseq); @@ -840,7 +836,7 @@ public class CreateFileServiceImpl implements CreateFileService { // 没有加上传者及id 要改 save = attachmentService.save(tsAttachmentModel); } - }else { + } else { TSAttachment tsAttachmentModel = new TSAttachment(); tsAttachmentModel.setCreatetype("1");// 文件为系统生成 tsAttachmentModel.setBizseq(bizseq); @@ -854,7 +850,7 @@ public class CreateFileServiceImpl implements CreateFileService { // 没有加上传者及id 要改 save = attachmentService.save(tsAttachmentModel); } - if(save){ + if (save) { return tempPath; } } @@ -863,9 +859,9 @@ public class CreateFileServiceImpl implements CreateFileService { @Override public String createPdf(String bizseq, String fileName, String attachtype, String path, Map map) { - if(StringUtils.isNotBlank(bizseq)) { + if (StringUtils.isNotBlank(bizseq)) { // 标题 - String title = path.substring(path.lastIndexOf(File.separator) + 1,path.lastIndexOf(Constant.DOT)); + String title = path.substring(path.lastIndexOf(File.separator) + 1, path.lastIndexOf(Constant.DOT)); String ext = ".pdf"; String urlFileName = UUID.randomUUID().toString() + ext; try { @@ -879,26 +875,26 @@ public class CreateFileServiceImpl implements CreateFileService { Elements links = htmldoc.getElementsByTag("p"); ArrayList list = new ArrayList<>(); for (Element link : links) { - if(link.getElementsByAttributeValue("style","text-align:right;").size() > 0){ + if (link.getElementsByAttributeValue("style", "text-align:right;").size() > 0) { Elements value = link.getElementsByAttributeValue("style", "text-align:right;"); HashMap map2 = new HashMap<>(); - map2.put("rightContent",value.text().trim()); + map2.put("rightContent", value.text().trim()); list.add(map2); - }else if(link.getElementsByAttributeValue("style","text-align:left;").size() > 0){ + } else if (link.getElementsByAttributeValue("style", "text-align:left;").size() > 0) { Elements value = link.getElementsByAttributeValue("style", "text-align:left;"); HashMap map3 = new HashMap<>(); - map3.put("leftContent",value.text().trim()); + map3.put("leftContent", value.text().trim()); list.add(map3); - }else { + } else { HashMap map1 = new HashMap<>(); map1.put("pragraph", link.text().trim()); list.add(map1); } } - map.put("htmlContent",list); + map.put("htmlContent", list); String pdfPath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + bizseq + File.separator + title + File.separator + urlFileName; XWPFTemplate.compile(resource).render(map).write(wordOs); - PdfUtil.convertDocx2Pdf(wordOs,pdfPath); + PdfUtil.convertDocx2Pdf(wordOs, pdfPath); } catch (Exception e) { e.printStackTrace(); @@ -906,28 +902,28 @@ public class CreateFileServiceImpl implements CreateFileService { } if (StringUtils.isBlank(fileName)) { fileName = urlFileName; - }else if(fileName.lastIndexOf(Constant.DOT) > -1){ + } else if (fileName.lastIndexOf(Constant.DOT) > -1) { fileName = fileName.substring(0, fileName.lastIndexOf(Constant.DOT)) + ext; - }else { + } else { fileName = fileName + ext; } String tempPath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + bizseq + File.separator + title + File.separator + urlFileName; - if( map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")){ + if (map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")) { return tempPath; } boolean save = false; - if("20".equals(attachtype)){// 针对批吊业务的处罚决定书预览附件 + if ("20".equals(attachtype)) {// 针对批吊业务的处罚决定书预览附件 TSAttachment tsAttachment = new TSAttachment(); tsAttachment.setBizseq(bizseq).setAttachtype("20"); List tsAttachments = attachmentService.selectwritByPage(tsAttachment); - if(CollectionUtils.isNotEmpty(tsAttachments)){ + if (CollectionUtils.isNotEmpty(tsAttachments)) { TSAttachment attachment = tsAttachments.get(0); attachment.setTemppath(tempPath); attachment.setUploaddate(LocalDate.now()); attachment.setLauptime(LocalDateTime.now()); save = attachmentService.updateById(attachment); - }else { + } else { TSAttachment tsAttachmentModel = new TSAttachment(); tsAttachmentModel.setCreatetype("1");// 文件为系统生成 tsAttachmentModel.setBizseq(bizseq); @@ -941,7 +937,7 @@ public class CreateFileServiceImpl implements CreateFileService { // 没有加上传者及id 要改 save = attachmentService.save(tsAttachmentModel); } - }else { + } else { TSAttachment tsAttachmentModel = new TSAttachment(); tsAttachmentModel.setCreatetype("1");// 文件为系统生成 tsAttachmentModel.setBizseq(bizseq); @@ -955,7 +951,80 @@ public class CreateFileServiceImpl implements CreateFileService { // 没有加上传者及id 要改 save = attachmentService.save(tsAttachmentModel); } - if(save){ + if (save) { + return tempPath; + } + } + return null; + } + + @Override + public String createPdfCommon(String bizseq, String title, String fileName, String moduleType, String attachtype, String templatePath, Map 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 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 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 map3 = new HashMap<>(); + map3.put("leftContent", value.text().trim()); + list.add(map3); + } else { + HashMap 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; } } @@ -1004,10 +1073,10 @@ public class CreateFileServiceImpl implements CreateFileService { } @Override - public void createDocxWithModel(String bizseq, String fileName, String attachtype, String path, Map map) { - if(StringUtils.isNotBlank(bizseq)) { + public void createDocxWithModel(String bizseq, String fileName, String attachtype, String path, Map map) { + if (StringUtils.isNotBlank(bizseq)) { // 标题 - String title = path.substring(path.lastIndexOf(File.separator) + 1,path.lastIndexOf(Constant.DOT)); + String title = path.substring(path.lastIndexOf(File.separator) + 1, path.lastIndexOf(Constant.DOT)); String ext = ".docx"; String urlFileName = UUID.randomUUID().toString() + ext; try { @@ -1021,18 +1090,18 @@ public class CreateFileServiceImpl implements CreateFileService { Elements links = htmldoc.getElementsByTag("p"); ArrayList list = new ArrayList<>(); for (Element link : links) { - if(link.getElementsByAttributeValue("style","text-align:right;").size() > 0){ + if (link.getElementsByAttributeValue("style", "text-align:right;").size() > 0) { Elements value = link.getElementsByAttributeValue("style", "text-align:right;"); HashMap map2 = new HashMap<>(); - map2.put("rightContent",value.text().trim()); + map2.put("rightContent", value.text().trim()); list.add(map2); - }else { + } else { HashMap map1 = new HashMap<>(); map1.put("pragraph", link.text().trim()); list.add(map1); } } - map.put("htmlContent",list); + map.put("htmlContent", list); HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); Configure config = Configure.newBuilder() @@ -1041,14 +1110,14 @@ public class CreateFileServiceImpl implements CreateFileService { // XWPFTemplate.compile(resource).render(map).writeToFile(realPath + File.separator + title + File.separator + urlFileName); String wordpath = bizseq + File.separator + title + File.separator + urlFileName; - XWPFTemplate.compile(resource,config).render(map).write(wordOs); - String filePath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + wordpath; + XWPFTemplate.compile(resource, config).render(map).write(wordOs); + String filePath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + wordpath; // 案件终结报告可能存在多次修改更新,更新时覆盖原来的文件,使用map的oldPath - if(map.get("oldPath") != null && StringUtils.isNotEmpty(map.get("oldPath").toString())){ + if (map.get("oldPath") != null && StringUtils.isNotEmpty(map.get("oldPath").toString())) { filePath = map.get("oldPath").toString(); } fileStorageService.writeFromStream(filePath, new ByteArrayInputStream(wordOs.toByteArray())); - if( map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")){ + if (map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")) { return; } } catch (Exception e) { @@ -1056,9 +1125,9 @@ public class CreateFileServiceImpl implements CreateFileService { } if (StringUtils.isBlank(fileName)) { fileName = title + ext; - }else if(fileName.lastIndexOf(Constant.DOT) > -1){ + } else if (fileName.lastIndexOf(Constant.DOT) > -1) { fileName = fileName.substring(0, fileName.lastIndexOf(Constant.DOT)) + ext; - }else { + } else { fileName = fileName + ext; } String tempPath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + bizseq + File.separator + title + File.separator + urlFileName; @@ -1079,9 +1148,9 @@ public class CreateFileServiceImpl implements CreateFileService { @Override public void createCasePdfWithModel(String bizseq, String fileName, String attachtype, String path, Map map) { - if(StringUtils.isNotBlank(bizseq)) { + if (StringUtils.isNotBlank(bizseq)) { // 标题 - String title = path.substring(path.lastIndexOf(File.separator) + 1,path.lastIndexOf(Constant.DOT)); + String title = path.substring(path.lastIndexOf(File.separator) + 1, path.lastIndexOf(Constant.DOT)); String ext = ".pdf"; String urlFileName = UUID.randomUUID().toString() + ext; try { @@ -1095,18 +1164,18 @@ public class CreateFileServiceImpl implements CreateFileService { Elements links = htmldoc.getElementsByTag("p"); ArrayList list = new ArrayList<>(); for (Element link : links) { - if(link.getElementsByAttributeValue("style","text-align:right;").size() > 0){ + if (link.getElementsByAttributeValue("style", "text-align:right;").size() > 0) { Elements value = link.getElementsByAttributeValue("style", "text-align:right;"); HashMap map2 = new HashMap<>(); - map2.put("rightContent",value.text().trim()); + map2.put("rightContent", value.text().trim()); list.add(map2); - }else { + } else { HashMap map1 = new HashMap<>(); map1.put("pragraph", link.text().trim()); list.add(map1); } } - map.put("htmlContent",list); + map.put("htmlContent", list); // HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy(); @@ -1118,15 +1187,15 @@ public class CreateFileServiceImpl implements CreateFileService { // XWPFTemplate.compile(resource).render(map).writeToFile(realPath + File.separator + title + File.separator + urlFileName); String pdfPath = bizseq + File.separator + title + File.separator + urlFileName; - XWPFTemplate.compile(resource,config).render(map).write(wordOs); + XWPFTemplate.compile(resource, config).render(map).write(wordOs); - String filePath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + pdfPath; + String filePath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + pdfPath; // 案件终结报告可能存在多次修改更新,更新时覆盖原来的文件,使用map的oldPath - if(map.get("oldPath") != null && StringUtils.isNotEmpty(map.get("oldPath").toString())){ + if (map.get("oldPath") != null && StringUtils.isNotEmpty(map.get("oldPath").toString())) { filePath = map.get("oldPath").toString(); } - PdfUtil.convertDocx2Pdf(wordOs,filePath); - if( map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")){ + PdfUtil.convertDocx2Pdf(wordOs, filePath); + if (map.get("noAttach") != null && map.get("noAttach").toString().equals("noAttach")) { return; } } catch (Exception e) { @@ -1135,9 +1204,9 @@ public class CreateFileServiceImpl implements CreateFileService { } if (StringUtils.isBlank(fileName)) { fileName = title + ext; - }else if(fileName.lastIndexOf(Constant.DOT) > -1){ + } else if (fileName.lastIndexOf(Constant.DOT) > -1) { fileName = fileName.substring(0, fileName.lastIndexOf(Constant.DOT)) + ext; - }else { + } else { fileName = fileName + ext; } String tempPath = CommonConfig.getUploadPath() + File.separator + "BatchRevocation" + File.separator + bizseq + File.separator + title + File.separator + urlFileName; @@ -1158,10 +1227,11 @@ public class CreateFileServiceImpl implements CreateFileService { /** * 创建测试用例过程记录的渲染策略:解析对应的html并输出到word - * @author xuwangcheng - * @date 2019/7/26 10:10 + * * @param * @return {@link AbstractRenderPolicy} + * @author xuwangcheng + * @date 2019/7/26 10:10 */ private static AbstractRenderPolicy createHtmlRenderPolicy() { return new AbstractRenderPolicy() { @@ -1202,12 +1272,13 @@ public class CreateFileServiceImpl implements CreateFileService { /** * 转换整个html内容为word内容 - * @author xuwangcheng - * @date 2019/7/29 18:46 - * @param ele ele - * @param doc doc + * + * @param ele ele + * @param doc doc * @param xwpfParagraph xwpfParagraph * @return {@link XWPFParagraph} + * @author xuwangcheng + * @date 2019/7/29 18:46 */ private static XWPFParagraph parseHtmlToWord(Element ele, NiceXWPFDocument doc, XWPFParagraph xwpfParagraph , boolean isParent) throws Exception { @@ -1278,13 +1349,13 @@ public class CreateFileServiceImpl implements CreateFileService { @Override public String createEntExcel(String bizseq, String attachtype, List bizRevEnts) { - if(CollectionUtils.isNotEmpty(bizRevEnts)){ + if (CollectionUtils.isNotEmpty(bizRevEnts)) { String ext = ".xlsx"; String urlFileName = UUID.randomUUID().toString() + ext; - String tempPath = "BatchRevocation" + File.separator + bizseq + File.separator + urlFileName; + String tempPath = "BatchRevocation" + File.separator + bizseq + File.separator + urlFileName; ArrayList list = new ArrayList<>(); - for (BizRevEnt bizRevEnt : bizRevEnts) { + for (BizRevEnt bizRevEnt : bizRevEnts) { TsbizrevlistExcelVo excelVo = new TsbizrevlistExcelVo(); excelVo.setUniscid(bizRevEnt.getUniscid()); excelVo.setRegno(bizRevEnt.getRegno()); @@ -1294,7 +1365,7 @@ public class CreateFileServiceImpl implements CreateFileService { } TsCase aCase = caseService.getByBizseq(bizseq); String caseName = null; - if(aCase != null) { + if (aCase != null) { caseName = aCase.getCaseName(); } @@ -1311,7 +1382,7 @@ public class CreateFileServiceImpl implements CreateFileService { break; case "23": sheetname = "行政处罚决定名单"; - fileName = caseName + "-" + sheetname + ext; + fileName = caseName + "-" + sheetname + ext; break; } List includeColumnFiledNames = new ArrayList<>(); @@ -1325,7 +1396,7 @@ public class CreateFileServiceImpl implements CreateFileService { .sheet(sheetname).doWrite(list); FileStorageService fileStorageService = SpringUtil.getBean(FileStorageService.class); fileStorageService.writeFromStream(CommonConfig.getUploadPath() + File.separator + tempPath, new ByteArrayInputStream(excelOs.toByteArray())); - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } @@ -1342,7 +1413,7 @@ public class CreateFileServiceImpl implements CreateFileService { tsAttachmentModel.setAttachtype(attachtype);// // 没有加上传者及id 要改 boolean save = attachmentService.save(tsAttachmentModel); - if(save){ + if (save) { return tempPath; } } diff --git a/src/main/java/com/chinaweal/aiccs/common/util/StringUtils.java b/src/main/java/com/chinaweal/aiccs/common/util/StringUtils.java index acaf8be..d8a2d73 100644 --- a/src/main/java/com/chinaweal/aiccs/common/util/StringUtils.java +++ b/src/main/java/com/chinaweal/aiccs/common/util/StringUtils.java @@ -232,4 +232,54 @@ public abstract class StringUtils extends org.apache.commons.lang3.StringUtils { public static String getUUID() { 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; + } }