diff --git a/pom.xml b/pom.xml index c382d7b..4eccc36 100644 --- a/pom.xml +++ b/pom.xml @@ -724,6 +724,26 @@ + + + + com.luhuiguo + aspose-words + 23.1 + + + + com.luhuiguo + aspose-cells + 23.1 + + + + com.luhuiguo + aspose-slides + 23.1 + + diff --git a/src/main/java/io/v/nutz/base/utils/OfficePlusUtil.java b/src/main/java/io/v/nutz/base/utils/OfficePlusUtil.java new file mode 100644 index 0000000..720ded4 --- /dev/null +++ b/src/main/java/io/v/nutz/base/utils/OfficePlusUtil.java @@ -0,0 +1,98 @@ +package io.v.nutz.base.utils; + +import cn.hutool.core.io.FileUtil; +import com.aspose.cells.PdfSaveOptions; +import com.aspose.cells.Workbook; +import com.aspose.words.Document; +import com.aspose.words.SaveFormat; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * 文档转换 + */ +@Slf4j +public class OfficePlusUtil { + + /** + * 转换 + * + * @param sourcePath 源文件路径 + * @param targetPath 目标文件路径 + */ + public static void convert(String sourcePath, String targetPath) { + String suffix = FileUtil.getSuffix(sourcePath); + if (suffix.equals("doc") || suffix.equals("docx")) { + wordConvertPdf(sourcePath, targetPath); + } else if (suffix.equals("xls") || suffix.equals("xlsx")) { + excelConvertPdf(sourcePath, targetPath); + } else { + throw new RuntimeException("不支持的文档格式"); + } + } + + /** + * excel转pdf + * + * @param sourcePath 源文件路径 + * @param targetPath 目标文件路径 + */ + public static void excelConvertPdf(String sourcePath, String targetPath) { + FileOutputStream fileOS = null; + try { + Workbook wb = new Workbook(sourcePath); + fileOS = new FileOutputStream(targetPath); + PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); + pdfSaveOptions.setOnePagePerSheet(true); +// for (int i = 0; i < 3; i++) { +// wb.getWorksheets().get(i).getHorizontalPageBreaks().clear(); +// wb.getWorksheets().get(i).getVerticalPageBreaks().clear(); +// } +// for (int i = 1; i < wb.getWorksheets().getCount(); i++) { +// wb.getWorksheets().get(i).setVisible(false); +// } + wb.getWorksheets().get(0).setVisible(true); + wb.save(fileOS, pdfSaveOptions); + fileOS.flush(); + } catch (Exception e) { + log.info("转换pdf报错", e); + } finally { + if (fileOS != null) { + try { + fileOS.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + /** + * word转pdf + * + * @param sourcePath 源文件路径 + * @param targetPath 目标文件路径 + */ + public static void wordConvertPdf(String sourcePath, String targetPath) { + FileOutputStream os = null; + try { + File file = new File(targetPath); + os = new FileOutputStream(file); + Document doc = new Document(sourcePath); + doc.save(os, SaveFormat.PDF); + } catch (Exception e) { + log.info("转换pdf报错", e); + } finally { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + +} diff --git a/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysFileController.java b/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysFileController.java index 44426a7..750b10c 100644 --- a/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysFileController.java +++ b/src/main/java/io/v/nutz/sys/controllers/platform/sys/SysFileController.java @@ -2,8 +2,10 @@ package io.v.nutz.sys.controllers.platform.sys; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.query.PageForm; +import io.v.nutz.sys.services.SysFileService; import io.v.nutz.sys.services.SysUserService; import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.nutz.dao.Cnd; import org.nutz.dao.Sqls; @@ -13,6 +15,10 @@ import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.Ok; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + /** * 文件管理 * @@ -26,6 +32,8 @@ public class SysFileController { @Inject private SysUserService sysUserService; + @Inject + private SysFileService sysFileService; @At("") @Ok("beetl:/platform/sys/file/index.html") @@ -51,4 +59,11 @@ public class SysFileController { } + @At + @Ok("void") + @ViReturn + @RequiresAuthentication + public void convertPDF(String id, HttpServletRequest request, HttpServletResponse response) throws IOException { + sysFileService.convertPDF(id, request, response); + } } diff --git a/src/main/java/io/v/nutz/sys/services/SysFileService.java b/src/main/java/io/v/nutz/sys/services/SysFileService.java new file mode 100644 index 0000000..53fa24c --- /dev/null +++ b/src/main/java/io/v/nutz/sys/services/SysFileService.java @@ -0,0 +1,22 @@ +package io.v.nutz.sys.services; + +import cn.wizzer.framework.base.service.BaseService; +import io.v.nutz.sys.models.Sys_file; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @version 1.0 + * @Author zzr + * @name:SysFileService + * @Date 2024/12/17 11:40 + * @注释 + */ +public interface SysFileService extends BaseService { + /** + * 转换为PDF + */ + void convertPDF(String id, HttpServletRequest request, HttpServletResponse response); +} diff --git a/src/main/java/io/v/nutz/sys/services/impl/SysFileServiceImpl.java b/src/main/java/io/v/nutz/sys/services/impl/SysFileServiceImpl.java new file mode 100644 index 0000000..1048213 --- /dev/null +++ b/src/main/java/io/v/nutz/sys/services/impl/SysFileServiceImpl.java @@ -0,0 +1,93 @@ +package io.v.nutz.sys.services.impl; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.URLUtil; +import cn.hutool.http.ContentType; +import cn.wizzer.framework.base.Result; +import cn.wizzer.framework.base.service.BaseServiceImpl; +import io.v.nutz.base.utils.OfficePlusUtil; +import io.v.nutz.sys.models.Sys_file; +import io.v.nutz.sys.services.SysFileService; +import lombok.extern.slf4j.Slf4j; +import org.nutz.boot.starter.ftp.FtpService; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +import org.nutz.dao.util.cri.SqlExpressionGroup; +import org.nutz.ioc.loader.annotation.Inject; +import org.nutz.ioc.loader.annotation.IocBean; +import org.nutz.json.Json; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +/** + * @version 1.0 + * @Author zzr + * @name:SysFileServiceImpl + * @Date 2024/12/17 11:40 + * @注释 + */ +@Slf4j +@IocBean(args = {"refer:dao"}) +public class SysFileServiceImpl extends BaseServiceImpl implements SysFileService { + + @Inject + private FtpService ftpService; + + public SysFileServiceImpl(Dao dao) { + super(dao); + } + + @Override + public void convertPDF(String id, HttpServletRequest request, HttpServletResponse response) { + try { + SqlExpressionGroup seg = new SqlExpressionGroup(); + seg.or("id", "=", id); + seg.or("filepath", "=", id); + Sys_file sys_file = dao().fetch(Sys_file.class, Cnd.where(seg).desc("id")); + if (ObjectUtil.isEmpty(sys_file)) { + sendErrorResponse(response, "文件记录不存在"); + return; + } + + //文件扩展名 + String extName = FileUtil.extName(sys_file.getFilename()); + File localSourcePath = File.createTempFile("file_convert", "." + extName); + FileOutputStream localOutPutStream = new FileOutputStream(localSourcePath.getPath()); + ftpService.download(sys_file.getFilepath(), localOutPutStream); + + //要转换的pdf本地临时路径 + File localPdfPath = File.createTempFile("file_convert", ".pdf"); + OfficePlusUtil.convert(localSourcePath.getPath(), localPdfPath.getPath()); + + byte[] bytes = IoUtil.readBytes(FileUtil.getInputStream(localPdfPath)); + response.setHeader("Content-Disposition", "attachment;filename=" + URLUtil.encode(sys_file.getFilename())); + response.addHeader("Content-Length", "" + bytes.length); + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + response.setContentType("application/octet-stream;charset=UTF-8"); + IoUtil.write(response.getOutputStream(), true, bytes); + //删除临时文件 + FileUtil.del(localPdfPath); + FileUtil.del(localSourcePath); + + } catch (Exception e) { + log.error("文件转换异常", e); + } + } + + + private void sendErrorResponse(HttpServletResponse response, String message) throws IOException { + response.setCharacterEncoding(CharsetUtil.UTF_8); + response.setContentType(ContentType.JSON.toString()); + response.getWriter().write(Json.toJson(Result.error(message))); + } +} diff --git a/src/main/resources/static/assets/mobile/js/basic.js b/src/main/resources/static/assets/mobile/js/basic.js index be4098b..448d313 100644 --- a/src/main/resources/static/assets/mobile/js/basic.js +++ b/src/main/resources/static/assets/mobile/js/basic.js @@ -63,8 +63,12 @@ const preview = async (filename, id) => { let viewer = new Viewer(image); viewer.show(); } else { - let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + id) //将路径转码 - window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, filename) + // let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + id) //将路径转码 + // window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, filename) + window.open( + "/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent("/platform/sys/file/convertPDF?id=" + id), + filename + ) } } diff --git a/src/main/resources/static/assets/platform/module/basics/basics.js b/src/main/resources/static/assets/platform/module/basics/basics.js index 4b8d7c3..60844f9 100644 --- a/src/main/resources/static/assets/platform/module/basics/basics.js +++ b/src/main/resources/static/assets/platform/module/basics/basics.js @@ -14,8 +14,12 @@ const preview = async (filename, id) => { let viewer = new Viewer(image); viewer.show(); } else { - let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + id) //将路径转码 - window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, filename) + // let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + id) //将路径转码 + // window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, filename) + window.open( + "/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent("/platform/sys/file/convertPDF?id=" + id), + filename + ) } } diff --git a/src/main/resources/views/platform/jf/reimbursement/apply.html b/src/main/resources/views/platform/jf/reimbursement/apply.html new file mode 100644 index 0000000..2ac7992 --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/apply.html @@ -0,0 +1,674 @@ + + + + +
+ + + + + + + + +   1、智慧工会“基层活动”提交活动申请,审核通过后开展活动。活动结束后在系统中提交活动内容,导出报销凭据到工会财务处报销。
+   2、活动报销所需材料如下:
+     ①.活动方案(含预算),校工会主席签字;
+     ②.活动新闻稿/照片;
+     ③.如发放奖品/纪念品,需附领奖人签字名单;
+     ④.如购买服装、道具等,需附领用人签字名单。
+   3.发票。抬头为“中国药科大学工会”,纳税人识别号(81320000782716328E)。发票上应注明品名、数量、单价和金额,加附购物清单。电子发票打印件由经办人签名承诺“本人承诺只使用一次”。汇款给个人且发票金额大于1000元,需附付款记录。
+   4.《中国药科大学报销凭证》。报销凭证应有附件,如所有参与人员名单、奖金物品发放签领单、用餐人员名单等。报销凭证须由经办人、证明人(基层工会主席)、负责人(校工会主席)签字。
+   5.本年度基层工会的活动经费需在当年12月15日前使用,如有结余不累计到下一年度。
+ +
+ + + 同意 + +
+ +
+ + + diff --git a/src/main/resources/views/platform/jf/reimbursement/board.html b/src/main/resources/views/platform/jf/reimbursement/board.html new file mode 100644 index 0000000..170d718 --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/board.html @@ -0,0 +1,644 @@ + + +
+
+ +
+ +
+ + + - + + +
+ +
校工会活动总人数
+
{{numData.schoolSignNum?numData.schoolSignNum:'0'}}
+
+
+ +
分工会活动总人数
+
{{numData.unionSignNum?numData.unionSignNum:'0'}}
+
+
+ +
协会活动总人数
+
{{numData.clubSignNum?numData.clubSignNum:'0'}}
+
+
+ +
校工会活动经费(元) + + + +
+ +
{{numData.schoolActivityMoney?numData.schoolActivityMoney:'0'}}
+
+
+ +
分工会活动经费(元) + + + +
+ +
{{numData.unionActivityMoney?numData.unionActivityMoney:'0'}}
+
+
+ +
社团活动经费(元) + + + +
+
{{numData.clubActivityMoney?numData.clubActivityMoney:'0'}}
+
+
+
+ + +
+ + + - + + +
+ +
活动类型
+
+
+ +
活动类型占比
+
+
+
+ + +
+ + + - + + +
+ +
活动经费
+
+
+ +
活动经费占比
+
+
+
+ + + +
+ + +
+ +
{{allUnionYear}}年工会经费及活动情况 + + + +
+
+
+
+ + + +
+ + +
+ +
{{allClubYear}}年社团经费及活动情况 + + + +
+
+
+
+ +
+
+
+ + + + diff --git a/src/main/resources/views/platform/jf/reimbursement/clubChairman.html b/src/main/resources/views/platform/jf/reimbursement/clubChairman.html new file mode 100644 index 0000000..5450529 --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/clubChairman.html @@ -0,0 +1,259 @@ + + +
+ + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/jf/reimbursement/mine.html b/src/main/resources/views/platform/jf/reimbursement/mine.html new file mode 100644 index 0000000..813ae6b --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/mine.html @@ -0,0 +1,278 @@ + + +
+ + + + + +
+ + + + diff --git a/src/main/resources/views/platform/jf/reimbursement/schoolChairman.html b/src/main/resources/views/platform/jf/reimbursement/schoolChairman.html new file mode 100644 index 0000000..65750de --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/schoolChairman.html @@ -0,0 +1,293 @@ + + +
+ + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/jf/reimbursement/schoolDirector.html b/src/main/resources/views/platform/jf/reimbursement/schoolDirector.html new file mode 100644 index 0000000..0bd4e0e --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/schoolDirector.html @@ -0,0 +1,293 @@ + + +
+ + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/jf/reimbursement/statistics.html b/src/main/resources/views/platform/jf/reimbursement/statistics.html new file mode 100644 index 0000000..0f7c6db --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/statistics.html @@ -0,0 +1,277 @@ + + +
+ + + + + +
+ + + + diff --git a/src/main/resources/views/platform/jf/reimbursement/unionChairman.html b/src/main/resources/views/platform/jf/reimbursement/unionChairman.html new file mode 100644 index 0000000..f55d53f --- /dev/null +++ b/src/main/resources/views/platform/jf/reimbursement/unionChairman.html @@ -0,0 +1,269 @@ + + +
+ + + + + + + + +
+ + + + diff --git a/src/main/resources/views/platform/swufeDifficultSubsidy/process/apply.html b/src/main/resources/views/platform/swufeDifficultSubsidy/process/apply.html index 35740ba..6311502 100644 --- a/src/main/resources/views/platform/swufeDifficultSubsidy/process/apply.html +++ b/src/main/resources/views/platform/swufeDifficultSubsidy/process/apply.html @@ -524,8 +524,12 @@ layout("/layouts/platform.html"){ } }, viewSubsidyProgramme() { - let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=cad5418aafd749b68c59946589dda6f0') //将路径转码 - this.subsidyProgrammeUrl = '/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl + window.open( + "/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent("/platform/sys/file/convertPDF?id=" + "cad5418aafd749b68c59946589dda6f0"), + "123" + ) + // let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=cad5418aafd749b68c59946589dda6f0') //将路径转码 + // this.subsidyProgrammeUrl = '/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl this.subsidyProgrammeDialogVisible = true }, subsidyTypeChange(val) { @@ -548,4 +552,4 @@ layout("/layouts/platform.html"){ \ No newline at end of file +#--> diff --git a/src/main/resources/views/platform/sys/club/manage/clubManagePersonAudit.html b/src/main/resources/views/platform/sys/club/manage/clubManagePersonAudit.html index 1182bef..7051f52 100644 --- a/src/main/resources/views/platform/sys/club/manage/clubManagePersonAudit.html +++ b/src/main/resources/views/platform/sys/club/manage/clubManagePersonAudit.html @@ -128,8 +128,12 @@ layout("/layouts/platform.html"){ showDoc(row) { if(row.replaceReport) { const file = JSON.parse(row.replaceReport) - let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + file[0].id) //将路径转码 - window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, file[0].filename) + window.open( + "/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent("/platform/sys/file/convertPDF?id=" + file[0].id), + file[0].filename + ) + // let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + file[0].id) //将路径转码 + // window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, file[0].filename) } }, getFileName(row) { diff --git a/src/main/resources/views/platform/sys/club/manage/ruleUpdate.html b/src/main/resources/views/platform/sys/club/manage/ruleUpdate.html index 37c128f..9ec2986 100644 --- a/src/main/resources/views/platform/sys/club/manage/ruleUpdate.html +++ b/src/main/resources/views/platform/sys/club/manage/ruleUpdate.html @@ -136,8 +136,12 @@ layout("/layouts/platform.html"){ showDoc(row) { if(row.afterRulesFile) { const file = JSON.parse(row.afterRulesFile) - let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + file[0].id) //将路径转码 - window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, file[0].filename) + window.open( + "/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent("/platform/sys/file/convertPDF?id=" + file[0].id), + file[0].filename + ) + // let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + file[0].id) //将路径转码 + // window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, file[0].filename) } }, getFileName(row) { diff --git a/src/main/resources/views/platform/sys/club/manage/schoolAuditRule.html b/src/main/resources/views/platform/sys/club/manage/schoolAuditRule.html index bd4886f..ce7c568 100644 --- a/src/main/resources/views/platform/sys/club/manage/schoolAuditRule.html +++ b/src/main/resources/views/platform/sys/club/manage/schoolAuditRule.html @@ -144,8 +144,12 @@ layout("/layouts/platform.html"){ showDoc(row) { if(row.afterRulesFile) { const file = JSON.parse(row.afterRulesFile) - let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + file[0].id) //将路径转码 - window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, file[0].filename) + window.open( + "/assets/platform/plugins/pdfJs/web/viewer.html?file=" + encodeURIComponent("/platform/sys/file/convertPDF?id=" + file[0].id), + file[0].filename + ) + // let pdfStreamUrl = encodeURIComponent(FILE_STREAM_PREVIEW_ADDRESS + '?id=' + file[0].id) //将路径转码 + // window.open('/assets/platform/plugins/pdfJs/web/viewer.html?file=' + pdfStreamUrl, file[0].filename) } }, getFileName(row) { diff --git a/src/main/resources/views/platform/sys/unit/unitMange.html b/src/main/resources/views/platform/sys/unit/unitMange.html index 5ce01b3..06b1032 100644 --- a/src/main/resources/views/platform/sys/unit/unitMange.html +++ b/src/main/resources/views/platform/sys/unit/unitMange.html @@ -221,6 +221,96 @@ layout("/layouts/platform.html"){
+ +
+ + + + + + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
- + @@ -413,7 +503,7 @@ layout("/layouts/platform.html"){
-
+
{ + sublime.closeLoadingbar();//关闭loading + this.tabLoading = false + if (data.code == 0) { + this.table2Data = data.data.list; + this.page2Form.totalCount = data.data.totalCount; + } else { + this.$message({ + message: data.msg, + type: 'error' + }); + } + }, "json"); + }, async loadTree(flush) { this.treeLoading = true const {code, data, msg} = await $.get("/platform/sys/unit/getUnitTreeData")