• 导出下载备份


    //导出下载方法
                        long time = System.currentTimeMillis();
                        String realpath1 = this.getClass().getClassLoader().getResource("").getPath();// classes 目录的物理路径
                        String parent = new File(realpath1).getParent();// WEB-INF 目录的物理路径
                        String parent2 = new File(parent).getParent()+"/upload/files/"+time+"xbl.pdf";// WebRoot 目录的物理路径
                        String fileUrl = "./upload/files/"+time+"xbl.pdf";
    
                        //生成附件
                        File file = new File(parent2);
                        file.createNewFile();
                        //附件 存入附件表
                        TSAttachment tsAttachment = new TSAttachment();
                        if (org.jeecgframework.core.util.StringUtil.isNotEmpty(time+"xbl")) {
                            tsAttachment.setNote(time+"xbl");
                        }
                        tsAttachment.setExtend("pdf");
                        tsAttachment.setSubclassname(MyClassLoader.getPackPath(tsAttachment));
                        tsAttachment.setCreatedate(DateUtils.gettimestamp());
                        tsAttachment.setAttachmenttitle(time+"_print");
                        tsAttachment.setRealpath(fileUrl);
                        systemService.save(tsAttachment);
    
                        TSDocument document = new TSDocument();
                        document.setId(tsAttachment.getId());
                        systemService.save(document);
    
                        TSTypegroup tsTypegroup=systemService.getTypeGroup("fieltype","文档分类");
                        TSType tsType = systemService.getType("files","附件", tsTypegroup);
    
    
                        //设置其可在线预览
                        ReflectHelper reflectHelper = new ReflectHelper(tsAttachment);
                        reflectHelper.setMethodValue("swfpath", "upload/files/" + FileUtils.getFilePrefix(time+"xbl.pdf") + ".swf");
                        SwfToolsUtil.convert2SWF(parent2);
    
                        FileOutputStream out = new FileOutputStream(file);
                        out.write(byteStream.toByteArray());
                        out.close();
    
                        //用jeecg框架的方法下载刚刚生成的附件
                        UploadFile uploadFile = new UploadFile(request, response);
                        String contentfield = oConvertUtils.getString(request.getParameter("contentfield"), uploadFile.getByteField());
                        byte[] content = (byte[]) reflectHelper.getMethodValue(contentfield);
                        String extend = oConvertUtils.getString(reflectHelper.getMethodValue("extend"));
                        String attachmenttitle = oConvertUtils.getString(reflectHelper.getMethodValue("attachmenttitle"));
                        uploadFile.setExtend(extend);
                        uploadFile.setTitleField(attachmenttitle);
                        uploadFile.setRealPath(fileUrl);
                        uploadFile.setContent(content);
                        //uploadFile.setView(true);
                        systemService.viewOrDownloadFile(uploadFile);
  • 相关阅读:
    Ubuntu JDK 安装及环境配置
    流式计算之Storm简介
    Amcharts 提示 字体找不到解决方法
    Amcharts 入门教程
    JavaMail 发送邮件简单 Demo
    JavaMail 发送邮件,以及sina、163、QQ服务器不同的解析结果(附图)
    MyEclipse 搭建 hadoop 环境
    淘宝主搜索体验
    【转】Net中VSS实现版本控制管理的一些使用方法
    IIS配置PHP环境(快速最新版)
  • 原文地址:https://www.cnblogs.com/xueblvip/p/15910764.html
Copyright © 2020-2023  润新知