diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/TSAttachmentService.java b/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/TSAttachmentService.java index a20d992..612a36f 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/TSAttachmentService.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/TSAttachmentService.java @@ -80,4 +80,12 @@ public interface TSAttachmentService extends BaseService { IPage selectWritsListzx(Page page, AttachmentWritDto dto); void getMaterial(HttpServletResponse response, String id, String bizSeqNo, String attachType) throws IOException; + + /** + * 通过bizseq和attachtype获取文件信息 + * @param bizseq + * @param attachtype + * @return + */ + TSAttachment getByBizseqAndType(String bizseq, String attachtype); } diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/impl/TSAttachmentServiceImpl.java b/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/impl/TSAttachmentServiceImpl.java index 79e983a..3261de2 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/impl/TSAttachmentServiceImpl.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/abnormal/service/impl/TSAttachmentServiceImpl.java @@ -38,13 +38,14 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Base64; import java.util.List; import java.util.Map; import java.util.UUID; @@ -374,4 +375,9 @@ public class TSAttachmentServiceImpl extends BaseServiceImpl().eq(TSAttachment::getBizseq, bizseq).eq(TSAttachment::getAttachtype, attachtype)); + } } diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/expelled/controller/EntBaseExpelledInfoController.java b/src/main/java/com/chinaweal/aiccs/aiccs/expelled/controller/EntBaseExpelledInfoController.java index 316f766..fa56877 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/expelled/controller/EntBaseExpelledInfoController.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/expelled/controller/EntBaseExpelledInfoController.java @@ -212,4 +212,11 @@ public class EntBaseExpelledInfoController extends BaseController { IPage data = expelledApplyInfoService.listRevokeAnnouncement(query); return RestResult.ok(data); } + + @ApiOperation(value = "23.下载文书", position = 23) + @GetMapping("/downloadDoc") + @ResponseBody + public void downloadDoc(HttpServletResponse response, String bizId, String attachType) { + expelledApplyInfoService.downloadDoc(response, bizId, attachType); + } } diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/IExpelledApplyInfoService.java b/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/IExpelledApplyInfoService.java index 145164c..ab55299 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/IExpelledApplyInfoService.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/IExpelledApplyInfoService.java @@ -12,6 +12,7 @@ import com.chinaweal.youfool.framework.springboot.base.query.BaseQuery; import com.chinaweal.youfool.framework.springboot.rest.RestResult; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; /** * @Description: 市场主体除名申请业务表接口类 @@ -79,4 +80,14 @@ public interface IExpelledApplyInfoService extends IService { * 分页查询撤销除名公告管理 */ IPage listRevokeAnnouncement(BaseQuery query); + + /** + * 生成审批表 + */ + void createDoc(ExpelledApplyInfo applyInfo, TSTaskList tsTaskList); + + /** + * 下载审批表 + */ + void downloadDoc(HttpServletResponse response, String bizId, String attachType); } diff --git a/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/impl/ExpelledApplyInfoServiceImpl.java b/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/impl/ExpelledApplyInfoServiceImpl.java index f3674de..98cf29b 100644 --- a/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/impl/ExpelledApplyInfoServiceImpl.java +++ b/src/main/java/com/chinaweal/aiccs/aiccs/expelled/service/impl/ExpelledApplyInfoServiceImpl.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.chinaweal.aiccs.aiccs.abnormal.entity.TSAttachment; +import com.chinaweal.aiccs.aiccs.abnormal.service.TSAttachmentService; import com.chinaweal.aiccs.aiccs.auditing.entity.TSOpinion; import com.chinaweal.aiccs.aiccs.auditing.service.TSOpinionService; import com.chinaweal.aiccs.aiccs.business.entity.TSTaskList; @@ -13,9 +15,11 @@ import com.chinaweal.aiccs.aiccs.business.rules.model.SequenceFlowModel; import com.chinaweal.aiccs.aiccs.business.service.TSTaskListService; import com.chinaweal.aiccs.aiccs.business.service.WorkFlowService; import com.chinaweal.aiccs.aiccs.expelled.entity.ExpelledApplyInfo; +import com.chinaweal.aiccs.aiccs.expelled.entity.ExpelledAuditInfo; import com.chinaweal.aiccs.aiccs.expelled.entity.ExpelledResultInfo; import com.chinaweal.aiccs.aiccs.expelled.mapper.ExpelledApplyInfoMapper; import com.chinaweal.aiccs.aiccs.expelled.service.IExpelledApplyInfoService; +import com.chinaweal.aiccs.aiccs.expelled.service.IExpelledAuditInfoService; import com.chinaweal.aiccs.aiccs.expelled.service.IExpelledResultInfoService; import com.chinaweal.aiccs.aiccs.expelled.vo.AuditInfoVo; import com.chinaweal.aiccs.aiccs.expelled.vo.RemoveApproveInfo; @@ -25,18 +29,27 @@ import com.chinaweal.aiccs.common.constant.Constant; import com.chinaweal.aiccs.common.util.FlowUtil; import com.chinaweal.aiccs.common.util.HandleWorkFlowUtil; import com.chinaweal.aiccs.common.util.WorkFlowUtil; +import com.chinaweal.aiccs.config.CommonConfig; import com.chinaweal.aiccs.utils.BeanUtil; import com.chinaweal.aicorg.model.AICUser; import com.chinaweal.youfool.framework.springboot.base.query.BaseQuery; import com.chinaweal.youfool.framework.springboot.exception.custom.BusinessException; import com.chinaweal.youfool.framework.springboot.rest.RestResult; import com.chinaweal.youfool.framework.springboot.rest.ResultCode; +import com.deepoove.poi.XWPFTemplate; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.util.HashMap; import java.util.List; @@ -60,6 +73,10 @@ public class ExpelledApplyInfoServiceImpl extends ServiceImpl startRepairBiz(AuditInfoVo query, HttpServletRequest request) { @@ -662,6 +679,8 @@ public class ExpelledApplyInfoServiceImpl extends ServiceImpl map = new HashMap<>(); + map.put("orgName", applyInfo.getRemoveOrgName()); + map.put("entName", applyInfo.getEntName()); + map.put("uscc", applyInfo.getUscc()); + map.put("lerepName", applyInfo.getLerepName()); + map.put("address", applyInfo.getAddress()); + ExpelledAuditInfo auditInfo = expelledAuditInfoService.getById(applyInfo.getAuditId()); + if (auditInfo != null) { + map.put("docNo", auditInfo.getAuditNo()); + } + map.put("approveDate", applyInfo.getApproveDate()); + map.put("applyReason", applyInfo.getApplyReason()); + // 获取历史审批意见 + LambdaQueryWrapper opinionWrapper = new LambdaQueryWrapper<>(); + opinionWrapper.eq(TSOpinion::getBizseq, applyInfo.getBizId()) + .in(TSOpinion::getOpiniontype,"0", "1", "2") + .orderByAsc(TSOpinion::getHandledate); + List tsOpinions = opinionService.list(opinionWrapper); + for (TSOpinion item : tsOpinions) { + int index = Integer.parseInt(item.getOpiniontype()) + 1; + map.put("opinion" + index, item.getOpinioncontent()); + map.put("handler" + index, item.getHandler()); + map.put("year" + index, item.getHandledate().getYear()); + map.put("month" + index, item.getHandledate().getMonthValue()); + map.put("day" + index, item.getHandledate().getDayOfMonth()); + } + try { + // 文书模板路径 + String wordTemplatePath = "static" + File.separator + "template" + File.separator + "expelled" + File.separator + "repairDoc.docx"; + if (StringUtils.equals("92", applyInfo.getState()) || StringUtils.equals("93", applyInfo.getState())) { + wordTemplatePath = "static" + File.separator + "template" + File.separator + "expelled" + File.separator + "revokeDoc.docx"; + } + String resource = ExpelledApplyInfoServiceImpl.class.getClassLoader().getResource(wordTemplatePath).getPath(); + // URL解码 + resource = URLDecoder.decode(resource, "UTF-8"); + String realPath = CommonConfig.getUploadPath(); + realPath += File.separator + applyInfo.getBizId(); + File dir = new File(realPath); + if (!dir.exists()) { + dir.mkdirs(); + } + // 生成 + String docName = UUID.randomUUID().toString(); + XWPFTemplate.compile(resource).render(map).writeToFile(realPath + File.separator + docName + ".docx"); + // 保存记录 + String ext = ".docx"; + String fileName = docName + ext; + String tempPath = applyInfo.getBizId() + File.separator + fileName; + TSAttachment tsAttachment = new TSAttachment(); + tsAttachment.setCreatetype("1"); // 文件为系统生成 + tsAttachment.setBizseq(applyInfo.getBizId()); + tsAttachment.setFileext(ext); + tsAttachment.setFilename(fileName); + tsAttachment.setTemppath(tempPath); + tsAttachment.setAttachtype("1"); // 审批表 + tsAttachment.setUploaddate(LocalDate.now()); + attachmentService.save(tsAttachment); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void downloadDoc(HttpServletResponse response, String bizId, String attachType) { + TSAttachment tsAttachment = attachmentService.getByBizseqAndType(bizId, attachType); + if (tsAttachment == null) { + return; + } + // 获取流 + InputStream is = null; + OutputStream os = null; + try { + // 获取文件 + String realPath = CommonConfig.getUploadPathByDate(tsAttachment.getUploaddate()) + File.separator + tsAttachment.getTemppath(); + is = new FileInputStream(realPath); + os = response.getOutputStream(); + String fileName = new String(tsAttachment.getFilename().getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1); + // 设置:当浏览器收到这份资源的时候,以下载的方式提醒用户,而不是直接显示 + response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + byte[] buffer = new byte[4096]; + int len; + while ((len = is.read(buffer)) != -1) { + os.write(buffer, 0, len); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("下载文书时发生异常:{}=", e); + return; + } finally { + try { + os.close(); + is.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/com/chinaweal/aiccs/config/CommonConfig.java b/src/main/java/com/chinaweal/aiccs/config/CommonConfig.java index 11b7868..bf4242d 100644 --- a/src/main/java/com/chinaweal/aiccs/config/CommonConfig.java +++ b/src/main/java/com/chinaweal/aiccs/config/CommonConfig.java @@ -65,6 +65,14 @@ public class CommonConfig { return uploadDrive + uploadPath + datePath; } + public static String getUploadPathByDate(LocalDate now) { + String dateStr = now.format(DateTimeFormatter.ofPattern("dd")); + String monthStr = now.format(DateTimeFormatter.ofPattern("MM")); + String yearStr = now.format(DateTimeFormatter.ofPattern("yyyy")); + String datePath = File.separator + yearStr + File.separator + monthStr + File.separator + dateStr; + return uploadDrive + uploadPath + datePath; + } + /** * 获取涉嫌冒用上传目录 * diff --git a/src/main/resources/static/template/expelled/repairDoc.docx b/src/main/resources/static/template/expelled/repairDoc.docx new file mode 100644 index 0000000..ea7c533 --- /dev/null +++ b/src/main/resources/static/template/expelled/repairDoc.docx @@ -0,0 +1,38 @@ + {{orgName}}除名修复审批表 + + 市场主体名称 +{{entName}} + 统一社会信用代码 +{{uscc}} + 法定代表人(负责人、经营者) +{{lerepName}} + 登记场所 + 或经营场所 +{{address}} + 除名决定书文号 +{{docNo}} + 除名决定日期 +{{approveDate}} + 除名修复理由 +{{applyReason}} + 经办人意见 +{{opinion1}} + + + + 签名: {{handler1}} + {{year1}}年 {{month1}}月 {{day1}}日 + 经办机构 + 负责人意见 +{{opinion2}} + + + 签名: {{handler2}} + {{year2}}年 {{month2}}月 {{day2}}日 + 分管负责人意见 +{{opinion3}} + + + 签名:{{handler3}} + {{year3}}年 {{month3}}月 {{day3}}日 + diff --git a/src/main/resources/static/template/expelled/revokeDoc.docx b/src/main/resources/static/template/expelled/revokeDoc.docx new file mode 100644 index 0000000..62ed36d --- /dev/null +++ b/src/main/resources/static/template/expelled/revokeDoc.docx @@ -0,0 +1,38 @@ + {{orgName}}除名撤销审批表 + + 市场主体名称 +{{entName}} + 统一社会信用代码 +{{uscc}} + 法定代表人(负责人、经营者) +{{lerepName}} + 登记场所 + 或经营场所 +{{address}} + 除名决定书文号 +{{docNo}} + 除名决定日期 +{{approveDate}} + 除名撤销理由 +{{applyReason}} + 经办人意见 +{{opinion1}} + + + + 签名: {{handler1}} + {{year1}}年 {{month1}}月 {{day1}}日 + 经办机构 + 负责人意见 +{{opinion2}} + + + 签名: {{handler2}} + {{year2}}年 {{month2}}月 {{day2}}日 + 分管负责人意见 +{{opinion3}} + + + 签名:{{handler3}} + {{year3}}年 {{month3}}月 {{day3}}日 +