commit
This commit is contained in:
+95
-3
@@ -14,10 +14,13 @@ import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.sys.models.User;
|
||||
import io.v.nutz.wakershome.model.WakesHomeDataRevel;
|
||||
import io.v.nutz.wakershome.service.WakesHomeInfoService;
|
||||
import io.v.nutz.web.commons.utils.FileUtil;
|
||||
import io.v.nutz.web.commons.utils.ShiroUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.boot.starter.ftp.FtpService;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
@@ -26,6 +29,7 @@ import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.random.R;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
@@ -34,6 +38,9 @@ import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -56,6 +63,9 @@ public class WakesHomeDataRevelController {
|
||||
@Inject
|
||||
private WakesHomeInfoService wakesHomeInfoService;
|
||||
|
||||
@Inject
|
||||
private FtpService ftpsService;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/wakeshome/data/revel.html")
|
||||
@RequiresPermissions("wakeshome.data.revel")
|
||||
@@ -202,14 +212,96 @@ public class WakesHomeDataRevelController {
|
||||
response.reset();
|
||||
response.setContentType("application/x-msdownload;charset=utf-8");
|
||||
|
||||
/**
|
||||
* 创建临时文件夹
|
||||
*/
|
||||
// 创建临时文件夹
|
||||
String tmpPath = "tmp/" + R.UU32();
|
||||
File tmpDir = new File(tmpPath + "/" + unionName + "附件汇总");
|
||||
tmpDir.mkdirs();
|
||||
|
||||
List<WakesHomeDataRevel> query = dao.query(WakesHomeDataRevel.class, Cnd.where("belongToUnionId", "=", unionId));
|
||||
|
||||
try {
|
||||
if (Lang.isNotEmpty(query)) {
|
||||
for (WakesHomeDataRevel revel : query) {
|
||||
// 创建资料名称的文件夹
|
||||
String fileName = revel.getRevelName();
|
||||
|
||||
File tDir = new File(tmpDir + "/" + fileName);
|
||||
tDir.mkdirs();
|
||||
|
||||
if (Lang.isNotEmpty(revel.getFiles())) {
|
||||
for (Sys_file file : revel.getFiles()) {
|
||||
FileOutputStream outputStream = new FileOutputStream(tDir.getPath() + "/" + file.getFilename());
|
||||
ftpsService.download(file.getFilepath(), outputStream);
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String aimsDir = "zipTmp/" + R.UU32();
|
||||
String aimsName = unionName + "附件汇总.zip";
|
||||
String aimsPath = aimsDir + "/" + aimsName;
|
||||
FileUtil.compressToZip(tmpDir.getPath(), aimsDir, aimsName);
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(aimsName, "UTF-8"));
|
||||
|
||||
File aimsFile = new File(aimsPath);
|
||||
FileInputStream inputStream = new FileInputStream(aimsFile);
|
||||
IOUtils.copy(inputStream, response.getOutputStream());
|
||||
inputStream.close();
|
||||
aimsFile.delete();
|
||||
|
||||
FileUtil.deleteDir(new File(tmpPath));
|
||||
FileUtil.deleteDir(new File(aimsDir));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("wakeshome.data.revel")
|
||||
public void exportAllFileById(String id, HttpServletResponse response) {
|
||||
response.reset();
|
||||
response.setContentType("application/x-msdownload;charset=utf-8");
|
||||
|
||||
WakesHomeDataRevel dataRevel = dao.fetch(WakesHomeDataRevel.class, Cnd.where("id", "=", id));
|
||||
|
||||
// 创建临时文件夹
|
||||
String tmpPath = "tmp/" + R.UU32();
|
||||
File tmpDir = new File(tmpPath + "/" + dataRevel.getBelongToUnionName() + dataRevel.getRevelName() + "附件汇总");
|
||||
tmpDir.mkdirs();
|
||||
|
||||
try {
|
||||
|
||||
if (Lang.isNotEmpty(dataRevel.getFiles())) {
|
||||
for (Sys_file file : dataRevel.getFiles()) {
|
||||
FileOutputStream outputStream = new FileOutputStream(tmpDir.getPath() + "/" + file.getFilename());
|
||||
ftpsService.download(file.getFilepath(), outputStream);
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
String aimsDir = "zipTmp/" + R.UU32();
|
||||
String aimsName = dataRevel.getBelongToUnionName() + dataRevel.getRevelName() + "附件汇总.zip";
|
||||
String aimsPath = aimsDir + "/" + aimsName;
|
||||
FileUtil.compressToZip(tmpDir.getPath(), aimsDir, aimsName);
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(aimsName, "UTF-8"));
|
||||
|
||||
File aimsFile = new File(aimsPath);
|
||||
FileInputStream inputStream = new FileInputStream(aimsFile);
|
||||
IOUtils.copy(inputStream, response.getOutputStream());
|
||||
inputStream.close();
|
||||
aimsFile.delete();
|
||||
|
||||
FileUtil.deleteDir(new File(tmpPath));
|
||||
FileUtil.deleteDir(new File(aimsDir));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ layout("/layouts/platform.html"){
|
||||
<el-card shadow="never" style="margin:10px 10px 0 10px">
|
||||
<table-tool :label="( checkData.unionname ? checkData.unionname : '全部分工会' ) + '资料列表'" :app="this">
|
||||
<template #func>
|
||||
<el-button v-if="checkData.unionname" type="primary" size="small" @click="exportAllFileByUnionId">导出全部资料</el-button>
|
||||
<el-button v-if="checkData.id" type="primary" size="small" @click="exportAllFileByUnionId">导出全部资料</el-button>
|
||||
</template>
|
||||
</table-tool>
|
||||
<el-table :data="tableData" @sort-change='pageOrder' height="626">
|
||||
@@ -102,13 +102,17 @@ layout("/layouts/platform.html"){
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="{type:'view',data:scope.row}">
|
||||
预览
|
||||
预览资料
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="(${@shiro.hasRole('sysadmin')||@shiro.hasRole('A06')})"
|
||||
:command="{type:'edit',data:scope.row}">
|
||||
编辑
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
:command="{type:'download',data:scope.row}">
|
||||
导出附件
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="(${@shiro.hasRole('sysadmin')||@shiro.hasRole('A06')})"
|
||||
:command="{type:'delete',data:scope.row}">
|
||||
@@ -140,8 +144,8 @@ layout("/layouts/platform.html"){
|
||||
<el-form-item label="上传人">
|
||||
<el-input readonly value="${@shiro.getPrincipalProperty('username')}"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属工会">
|
||||
<el-input readonly :value="checkData.unionname ? checkData.unionname : '${@shiro.getPrincipalProperty('union').getUnionname()}'"></el-input>
|
||||
<el-form-item label="资料归属工会">
|
||||
<el-input readonly :value="checkData.id ? checkData.unionname : '${@shiro.getPrincipalProperty('union').getUnionname()}'"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="revelName" label="资料名称">
|
||||
<el-input placeholder="请填写工作资料名称" v-model="formData.revelName"></el-input>
|
||||
@@ -167,9 +171,9 @@ layout("/layouts/platform.html"){
|
||||
</el-form>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="addDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doAdd">确 定</el-button>
|
||||
</span>
|
||||
<el-button @click="addDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doAdd">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="编辑资料" :visible.sync="editDialogVisible">
|
||||
@@ -177,6 +181,9 @@ layout("/layouts/platform.html"){
|
||||
<el-form-item label="上传人">
|
||||
<el-input readonly v-model="formData.username"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="资料归属工会">
|
||||
<el-input readonly v-model="formData.belongToUnionName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="revelName" label="资料名称">
|
||||
<el-input placeholder="请填写工作资料名称" v-model="formData.revelName"></el-input>
|
||||
</el-form-item>
|
||||
@@ -191,7 +198,12 @@ layout("/layouts/platform.html"){
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="files" label="附件上传">
|
||||
<file-upload :files.sync="formData.files"></file-upload>
|
||||
<file-upload :files.sync="formData.files" card
|
||||
:type="['doc','docx','xls','xlsx','pdf','ppt', 'jpg', 'png', 'jpeg']">
|
||||
<template #el-upload__tip>
|
||||
</template>
|
||||
</file-upload>
|
||||
<div class="el-upload__tip">可上传照片、文档等资料</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
@@ -288,6 +300,8 @@ layout("/layouts/platform.html"){
|
||||
const url = '/platform/wakeshome/data/revel/exportAllFileByUnionId?unionId=' + unionId + '&unionName=' + unionName
|
||||
window.open(url)
|
||||
},
|
||||
exportAllFileById(data) {
|
||||
window.open('/platform/wakeshome/data/revel/exportAllFileById?id=' + data.id)
|
||||
},
|
||||
async handleNodeClick(data, node) {
|
||||
this.checkData = data
|
||||
@@ -312,8 +326,8 @@ layout("/layouts/platform.html"){
|
||||
this.openEdit(data)
|
||||
} else if (type === 'delete') {
|
||||
this.doDelete(data.id)
|
||||
} else if (type === 'audit') {
|
||||
this.doAudit(data.id)
|
||||
} else if (type === 'download') {
|
||||
this.exportAllFileById(data)
|
||||
}
|
||||
},
|
||||
doDelete(id) {
|
||||
|
||||
Reference in New Issue
Block a user