2023-11-07 09:32:12 +08:00
|
|
|
|
package com.zcloud.controller.filemanager;
|
|
|
|
|
|
2023-12-19 11:33:26 +08:00
|
|
|
|
import com.alibaba.fastjson.JSON;
|
2023-12-18 16:14:27 +08:00
|
|
|
|
import com.zcloud.aspect.DockAnnotation;
|
2023-11-07 09:32:12 +08:00
|
|
|
|
import net.sf.json.JSONArray;
|
|
|
|
|
|
|
|
|
|
import java.io.Console;
|
2023-12-20 17:16:37 +08:00
|
|
|
|
import java.util.*;
|
2023-11-07 09:32:12 +08:00
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import com.zcloud.controller.base.BaseController;
|
|
|
|
|
import com.zcloud.entity.Page;
|
|
|
|
|
import com.zcloud.entity.PageData;
|
|
|
|
|
import com.zcloud.service.filemanager.MfolderService;
|
|
|
|
|
import com.zcloud.util.Const;
|
|
|
|
|
import com.zcloud.util.DateUtil;
|
|
|
|
|
import com.zcloud.util.DelFileUtil;
|
|
|
|
|
import com.zcloud.util.FileDownload;
|
|
|
|
|
import com.zcloud.util.FileUpload;
|
|
|
|
|
import com.zcloud.util.FileUtil;
|
|
|
|
|
import com.zcloud.util.Jurisdiction;
|
|
|
|
|
import com.zcloud.util.PathUtil;
|
|
|
|
|
import com.zcloud.util.Smb;
|
|
|
|
|
import com.zcloud.util.Tools;
|
|
|
|
|
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
|
2023-12-18 16:14:27 +08:00
|
|
|
|
/**
|
2023-11-07 09:32:12 +08:00
|
|
|
|
* 说明:文件管理
|
2023-12-18 16:14:27 +08:00
|
|
|
|
* 作者:zCloud
|
2023-11-07 09:32:12 +08:00
|
|
|
|
* 官网:
|
|
|
|
|
*/
|
|
|
|
|
@Controller
|
|
|
|
|
@RequestMapping("/mfolder")
|
|
|
|
|
public class MfolderController extends BaseController {
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
private MfolderService mfolderService;
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**创建目录
|
|
|
|
|
* @param
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/add")
|
|
|
|
|
@RequiresPermissions("mfolder:add")
|
|
|
|
|
@ResponseBody
|
2023-12-25 14:42:45 +08:00
|
|
|
|
@DockAnnotation
|
2023-11-07 09:32:12 +08:00
|
|
|
|
public Object add() throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
pd.put("MFOLDER_ID", this.get32UUID()); //主键
|
|
|
|
|
pd.put("FILEPATH", ""); //路径
|
|
|
|
|
pd.put("CTIME", DateUtil.date2Str(new Date())); //创建时间
|
|
|
|
|
pd.put("UNAME", Jurisdiction.getName()); //上传者
|
|
|
|
|
pd.put("MASTER", Jurisdiction.getUsername()); //所属人
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
2023-12-18 16:14:27 +08:00
|
|
|
|
pd.put("FILESIZE", "");
|
|
|
|
|
pd.put("SHARE", "no");
|
2023-11-07 09:32:12 +08:00
|
|
|
|
mfolderService.save(pd);
|
|
|
|
|
map.put("result", errInfo);
|
2023-12-19 11:33:26 +08:00
|
|
|
|
map.put("dockData", JSON.toJSONString(pd));
|
2023-11-07 09:32:12 +08:00
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**上传文件
|
|
|
|
|
* @param
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/upload")
|
|
|
|
|
@RequiresPermissions("mfolder:add")
|
|
|
|
|
@ResponseBody
|
2023-12-20 17:16:37 +08:00
|
|
|
|
@DockAnnotation(hasAnnex = true)
|
2023-12-25 14:42:45 +08:00
|
|
|
|
public Object add(@RequestParam(value="FFILE",required=false) MultipartFile file, @RequestParam(value="NAME",required=false) String NAME, @RequestParam(value="PARENT_ID",required=false) String PARENT_ID, @RequestParam(value="REMARKS",required=false) String REMARKS, @RequestParam(value="SHARE",required=false) String SHARE) throws Exception{
|
2023-11-07 09:32:12 +08:00
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
2023-12-20 17:16:37 +08:00
|
|
|
|
ArrayList<String> pictureList = new ArrayList<>();
|
2023-11-07 09:32:12 +08:00
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
String ffile = DateUtil.getDays(), fileName = "";
|
|
|
|
|
if (null != file && !file.isEmpty()) {
|
|
|
|
|
String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
|
|
|
|
if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
map.put("msg", "文件格式不正确!");
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
Long size = file.getSize()/1024;
|
|
|
|
|
fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
|
|
Smb.sshSftp(file, fileName,Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|
|
|
|
pd.put("FILEPATH", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); //文件路径
|
|
|
|
|
pd.put("NAME", NAME); //文件名
|
|
|
|
|
pd.put("PARENT_ID", PARENT_ID); //目录ID
|
|
|
|
|
pd.put("CTIME", DateUtil.date2Str(new Date())); //创建时间
|
|
|
|
|
pd.put("UNAME", Jurisdiction.getName()); //上传者,当前用户的姓名
|
|
|
|
|
pd.put("MASTER", Jurisdiction.getUsername()); //用户名
|
|
|
|
|
// pd.put("FILESIZE", FileUtil.getFilesize(Const.FILEURL + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName)); //文件大小
|
|
|
|
|
pd.put("FILESIZE",size);
|
|
|
|
|
pd.put("SHARE", SHARE); //是否共享
|
|
|
|
|
pd.put("MFOLDER_ID", this.get32UUID()); //主键
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
|
|
|
|
mfolderService.save(pd); //存入数据库表
|
2023-12-21 08:56:30 +08:00
|
|
|
|
pictureList.add(Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName+
|
|
|
|
|
"@@"
|
|
|
|
|
+fileName);
|
2023-12-26 11:54:38 +08:00
|
|
|
|
map.put("dockData", JSON.toJSONString(pd)); //返回结果
|
|
|
|
|
map.put("sendPicturesList", JSON.toJSONString(pictureList)); //图片返回结果
|
2023-11-07 09:32:12 +08:00
|
|
|
|
}else{
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
}
|
|
|
|
|
map.put("result", errInfo); //返回结果
|
2023-12-29 11:26:41 +08:00
|
|
|
|
map.put("dockData", JSON.toJSONString(pd));
|
2023-11-07 09:32:12 +08:00
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 上传文件
|
2023-12-18 16:14:27 +08:00
|
|
|
|
*
|
2023-11-07 09:32:12 +08:00
|
|
|
|
* @param
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value = "/batchUpload")
|
|
|
|
|
@RequiresPermissions("mfolder:add")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object batchUpload(@RequestParam(value = "FFILE", required = false) MultipartFile[] files,
|
|
|
|
|
@RequestParam(value = "NAME", required = false) String NAME,
|
|
|
|
|
@RequestParam(value = "PARENT_ID", required = false) String PARENT_ID,
|
|
|
|
|
@RequestParam(value = "REMARKS", required = false) String REMARKS,
|
|
|
|
|
@RequestParam(value = "SHARE", required = false) String SHARE) throws Exception {
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
if (files != null && files.length > 0) {
|
|
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
|
|
String suffixName = files[i].getOriginalFilename().substring(files[i].getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
|
|
|
|
if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
map.put("msg", "文件格式不正确!");
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
|
|
MultipartFile file = files[i];
|
|
|
|
|
String ffile = DateUtil.getDays(), fileName = "";
|
|
|
|
|
if (null != file && !file.isEmpty()) {
|
|
|
|
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径
|
|
|
|
|
// fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|
|
|
|
Long size = file.getSize()/1024;
|
|
|
|
|
fileName = this.get32UUID()
|
|
|
|
|
+ file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
|
|
|
|
Smb.sshSftp(file, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
|
|
|
|
pd.put("FILEPATH",
|
|
|
|
|
Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); // 文件路径
|
|
|
|
|
String realName = file.getOriginalFilename();
|
|
|
|
|
String[] fileFullNames = realName.split("\\.");//上传文件全名
|
|
|
|
|
String extension =fileFullNames[fileFullNames.length-1];//上传文件文件后缀
|
|
|
|
|
String realName2 =realName.substring(0,realName.length()-extension.length()-1); //去除文件后缀名称
|
|
|
|
|
pd.put("FILESIZE",size);
|
|
|
|
|
pd.put("NAME", realName2); // 文件名
|
|
|
|
|
pd.put("PARENT_ID", PARENT_ID); // 目录ID
|
|
|
|
|
pd.put("CTIME", DateUtil.date2Str(new Date())); // 创建时间
|
|
|
|
|
pd.put("UNAME", Jurisdiction.getName()); // 上传者,当前用户的姓名
|
|
|
|
|
pd.put("MASTER", Jurisdiction.getUsername()); // 用户名
|
|
|
|
|
// pd.put("FILESIZE", FileUtil.getFilesize(Const.FILEURL + Const.FILEPATHFILE
|
|
|
|
|
// + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName)); // 文件大小
|
|
|
|
|
pd.put("REMARKS", REMARKS); // 备注
|
|
|
|
|
pd.put("SHARE", SHARE); // 是否共享
|
|
|
|
|
pd.put("MFOLDER_ID", this.get32UUID()); // 主键
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); // 企业
|
|
|
|
|
mfolderService.save(pd); // 存入数据库表
|
|
|
|
|
} else {
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
map.put("result", errInfo); // 返回结果
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**上传文件
|
|
|
|
|
* @param
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/uploadAll")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object uploadAll(
|
|
|
|
|
@RequestParam(value="file",required=false) MultipartFile file,
|
|
|
|
|
@RequestParam(value="FH_ID",required=false) String MFOLDER_ID
|
|
|
|
|
) throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
String ffile = DateUtil.getDays(), fileName = "";
|
|
|
|
|
if (null != file && !file.isEmpty()) {
|
|
|
|
|
String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase();
|
|
|
|
|
if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) {
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
map.put("msg", "文件格式不正确!");
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
// String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径
|
|
|
|
|
// fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传
|
|
|
|
|
fileName = this.get32UUID()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
2023-12-18 16:14:27 +08:00
|
|
|
|
Smb.sshSftp(file, fileName,Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
|
2023-11-07 09:32:12 +08:00
|
|
|
|
pd.put("FILEPATH", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName); //文件路径
|
|
|
|
|
String realName = file.getOriginalFilename();
|
|
|
|
|
String[] fileFullNames = realName.split("\\.");//上传文件全名
|
|
|
|
|
String extension =fileFullNames[fileFullNames.length-1];//上传文件文件后缀
|
|
|
|
|
String realName2 =realName.substring(0,realName.length()-extension.length()-1); //去除文件后缀名称
|
|
|
|
|
pd.put("NAME", realName2); //文件名
|
|
|
|
|
pd.put("PARENT_ID", MFOLDER_ID); //目录ID
|
|
|
|
|
pd.put("CTIME", DateUtil.date2Str(new Date())); //创建时间
|
|
|
|
|
pd.put("UNAME", Jurisdiction.getName()); //上传者,当前用户的姓名
|
|
|
|
|
pd.put("MASTER", Jurisdiction.getUsername()); //用户名
|
|
|
|
|
pd.put("FILESIZE", FileUtil.getFilesize(Const.FILEURL + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName)); //文件大小
|
|
|
|
|
pd.put("REMARKS", "无"); //备注
|
|
|
|
|
pd.put("SHARE", "no"); //是否共享
|
|
|
|
|
pd.put("MFOLDER_ID", this.get32UUID()); //主键
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
|
|
|
|
mfolderService.save(pd); //存入数据库表
|
|
|
|
|
}else{
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
}
|
|
|
|
|
map.put("result", errInfo); //返回结果
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**删除
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/delete")
|
|
|
|
|
@RequiresPermissions("mfolder:del")
|
|
|
|
|
@ResponseBody
|
2023-12-19 11:33:26 +08:00
|
|
|
|
@DockAnnotation
|
2023-11-07 09:32:12 +08:00
|
|
|
|
public Object delete(@RequestParam String MFOLDER_ID,@RequestParam String FILEPATH) throws Exception{
|
|
|
|
|
Map<String,String> map = new HashMap<String,String>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd.put("parentId", MFOLDER_ID);
|
|
|
|
|
if(mfolderService.listByParentId(pd).size() > 0){ //判断是否有子级,是:不允许删除
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
map.put("result", "errInfo"); //返回结果
|
|
|
|
|
map.put("msg","文件夹下有文件,请先删除文件夹中文件");
|
2023-12-29 11:26:41 +08:00
|
|
|
|
map.put("dockData", JSON.toJSONString(pd));
|
2023-11-07 09:32:12 +08:00
|
|
|
|
return map;
|
|
|
|
|
}else{
|
|
|
|
|
if(Tools.notEmpty(FILEPATH)){
|
|
|
|
|
DelFileUtil.delFolder(PathUtil.getProjectpath()+ FILEPATH.trim()); //删除文件
|
|
|
|
|
}
|
|
|
|
|
pd.put("MFOLDER_ID", MFOLDER_ID);
|
|
|
|
|
mfolderService.delete(pd);
|
2023-12-26 11:54:38 +08:00
|
|
|
|
map.put("dockData", JSON.toJSONString(pd)); //返回结果
|
2023-11-07 09:32:12 +08:00
|
|
|
|
}
|
|
|
|
|
map.put("result", errInfo); //返回结果
|
2023-12-29 11:26:41 +08:00
|
|
|
|
map.put("dockData", JSON.toJSONString(pd));
|
2023-11-07 09:32:12 +08:00
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**修改
|
|
|
|
|
* @param
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/edit")
|
|
|
|
|
@RequiresPermissions("mfolder:edit")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object edit() throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
mfolderService.edit(pd);
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**列表
|
|
|
|
|
* @param page
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/list")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object list(Page page) throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
|
|
|
|
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
|
|
|
|
|
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
|
|
|
|
|
String MFOLDER_ID = null;
|
|
|
|
|
if( pd.get("MFOLDER_ID")!=null && Tools.notEmpty( pd.get("MFOLDER_ID").toString())) {
|
|
|
|
|
MFOLDER_ID = null == pd.get("MFOLDER_ID")?"":pd.get("MFOLDER_ID").toString();
|
|
|
|
|
pd.put("MFOLDER_ID", MFOLDER_ID); //当作上级ID
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
// if(Tools.notEmpty(SHARE) && "yes".equals(SHARE)) {
|
|
|
|
|
// pd.put("SHARE", "yes");
|
|
|
|
|
// }else {
|
|
|
|
|
// pd.put("USERNAME", "admin".equals(Jurisdiction.getUsername())?"":Jurisdiction.getUsername()); //除admin用户外,只能查看自己的数据
|
|
|
|
|
// }
|
|
|
|
|
page.setPd(pd);
|
|
|
|
|
List<PageData> varList = mfolderService.list(page); //列出Mfolder列表
|
|
|
|
|
if(MFOLDER_ID==null || "0".equals(MFOLDER_ID)) {
|
|
|
|
|
map.put("PARENT_ID", "0"); //上级ID
|
|
|
|
|
}else {
|
|
|
|
|
map.put("PARENT_ID", mfolderService.findById(pd).getString("PARENT_ID")); //上级ID
|
|
|
|
|
}
|
|
|
|
|
for(int i=0;i<varList.size();i++){
|
|
|
|
|
String FILEPATH = varList.get(i).getString("FILEPATH");
|
|
|
|
|
if(Tools.isEmpty(FILEPATH))break;
|
|
|
|
|
String extension_name = FILEPATH.substring(FILEPATH.length()<85?59:92, FILEPATH.length());//文件拓展名
|
|
|
|
|
String fileType = "file";
|
|
|
|
|
int zindex1 = "java,php,jsp,html,css,txt,asp".indexOf(extension_name);
|
|
|
|
|
if(zindex1 != -1){
|
|
|
|
|
fileType = "wenben"; //文本类型
|
|
|
|
|
}
|
|
|
|
|
int zindex2 = "jpg,gif,bmp,png".indexOf(extension_name);
|
|
|
|
|
if(zindex2 != -1){
|
|
|
|
|
fileType = "tupian"; //图片文件类型
|
|
|
|
|
}
|
|
|
|
|
int zindex3 = "rar,zip,rar5".indexOf(extension_name);
|
|
|
|
|
if(zindex3 != -1){
|
|
|
|
|
fileType = "yasuo"; //压缩文件类型
|
|
|
|
|
}
|
|
|
|
|
int zindex4 = "doc,docx".indexOf(extension_name);
|
|
|
|
|
if(zindex4 != -1){
|
|
|
|
|
fileType = "doc"; //doc文件类型
|
|
|
|
|
}
|
|
|
|
|
int zindex5 = "xls,xlsx".indexOf(extension_name);
|
|
|
|
|
if(zindex5 != -1){
|
|
|
|
|
fileType = "xls"; //xls文件类型
|
|
|
|
|
}
|
|
|
|
|
int zindex6 = "ppt,pptx".indexOf(extension_name);
|
|
|
|
|
if(zindex6 != -1){
|
|
|
|
|
fileType = "ppt"; //ppt文件类型
|
|
|
|
|
}
|
|
|
|
|
int zindex7 = "pdf".indexOf(extension_name);
|
|
|
|
|
if(zindex7 != -1){
|
|
|
|
|
fileType = "pdf"; //ppt文件类型
|
|
|
|
|
}
|
|
|
|
|
int zindex8 = "fly,f4v,mp4,m3u8,webm,ogg,avi".indexOf(extension_name);
|
|
|
|
|
if(zindex8 != -1){
|
|
|
|
|
fileType = "video"; //视频文件类型
|
|
|
|
|
}
|
|
|
|
|
varList.get(i).put("extension_name", extension_name); //文件拓展名
|
2023-12-18 16:14:27 +08:00
|
|
|
|
varList.get(i).put("fileType", fileType); //用于文件图标
|
2023-11-07 09:32:12 +08:00
|
|
|
|
}
|
|
|
|
|
map.put("varList", varList);
|
|
|
|
|
map.put("page", page);
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 显示列表ztree
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/listTree")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object listTree()throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
this.initialize();
|
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
String SHARE = pd.getString("SHARE");
|
|
|
|
|
if(!(Tools.notEmpty(SHARE) && "yes".equals(SHARE))) {
|
|
|
|
|
pd.put("USERNAME", "admin".equals(Jurisdiction.getUsername())?"":Jurisdiction.getUsername()); //除admin用户外,只能查看自己的数据
|
|
|
|
|
}
|
|
|
|
|
pd.put("parentId", "0");
|
|
|
|
|
pd.put("SHARE", SHARE);
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
|
|
|
|
JSONArray arr = JSONArray.fromObject(mfolderService.listTree(pd,SHARE));
|
|
|
|
|
String json = arr.toString();
|
|
|
|
|
json = json.replaceAll("MFOLDER_ID", "id").replaceAll("PARENT_ID", "pId").replaceAll("NAME", "name").replaceAll("subMfolder", "nodes").replaceAll("hasMfolder", "checked").replaceAll("treeurl", "url");
|
|
|
|
|
map.put("zTreeNodes", json);
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**预览txt,java,php,等文本文件
|
2023-12-18 16:14:27 +08:00
|
|
|
|
* @return
|
2023-11-07 09:32:12 +08:00
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/viewTxt")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object viewTxt() throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
String encoding = pd.getString("encoding");
|
|
|
|
|
pd = mfolderService.findById(pd); //根据ID读取
|
|
|
|
|
String code = FileUtil.readTxtFileAll(PathUtil.getProjectpath() + pd.getString("FILEPATH"),encoding);
|
|
|
|
|
map.put("code", code);
|
|
|
|
|
map.put("result", errInfo);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**批量操作
|
|
|
|
|
* @param
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/makeAll")
|
|
|
|
|
@RequiresPermissions("mfolder:edit")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object deleteAll() throws Exception{
|
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
|
String errInfo = "success";
|
2023-12-18 16:14:27 +08:00
|
|
|
|
PageData pd = new PageData();
|
2023-11-07 09:32:12 +08:00
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
String DATA_IDS = pd.getString("DATA_IDS");
|
|
|
|
|
if(Tools.notEmpty(DATA_IDS)){
|
|
|
|
|
String ArrayDATA_IDS[] = DATA_IDS.split(",");
|
|
|
|
|
pd.put("IDS", ArrayDATA_IDS);
|
|
|
|
|
mfolderService.makeAll(pd);
|
|
|
|
|
errInfo = "success";
|
|
|
|
|
}else{
|
|
|
|
|
errInfo = "fail";
|
|
|
|
|
}
|
|
|
|
|
map.put("result", errInfo); //返回结果
|
|
|
|
|
return map;
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**下载
|
|
|
|
|
* @param response
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(value="/download")
|
|
|
|
|
public void download(HttpServletResponse response)throws NofileException {
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd = this.getPageData();
|
|
|
|
|
try {
|
|
|
|
|
pd = mfolderService.findById(pd);
|
|
|
|
|
String FILEPATH = pd.getString("FILEPATH");
|
|
|
|
|
// String fileName = pd.getString("NAME");
|
|
|
|
|
FileDownload.mfFileDownload(response, Const.HTTPFILEURL + FILEPATH, FILEPATH.substring(FILEPATH.length()<85?27:60, FILEPATH.length()));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new NofileException("=========要下载的文件已经没有了=========");
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 初始化标签
|
|
|
|
|
* 较大及以上等级风险管控方案
|
2023-12-18 16:14:27 +08:00
|
|
|
|
* @throws Exception
|
2023-11-07 09:32:12 +08:00
|
|
|
|
*/
|
|
|
|
|
public void initialize () throws Exception {
|
|
|
|
|
PageData pData = new PageData();
|
|
|
|
|
pData.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
|
|
|
|
|
pData.put("NAME", "较大及以上等级风险管控方案");
|
|
|
|
|
List<PageData> mfilder = mfolderService.findListByName(pData);
|
|
|
|
|
if(mfilder.size()<1) {
|
|
|
|
|
PageData pd = new PageData();
|
|
|
|
|
pd.put("MFOLDER_ID", this.get32UUID()); //主键
|
|
|
|
|
pd.put("PARENT_ID", "0"); //
|
|
|
|
|
pd.put("NAME", "较大及以上等级风险管控方案"); //
|
|
|
|
|
pd.put("REMARKS", "较大及以上等级风险管控方案"); //
|
|
|
|
|
pd.put("FILEPATH", ""); //路径
|
|
|
|
|
pd.put("CTIME", DateUtil.date2Str(new Date())); //创建时间
|
|
|
|
|
pd.put("UNAME", "init"); //上传者
|
|
|
|
|
pd.put("MASTER", Jurisdiction.getUsername()); //所属人
|
|
|
|
|
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID()); //企业
|
2023-12-18 16:14:27 +08:00
|
|
|
|
pd.put("FILESIZE", "");
|
|
|
|
|
pd.put("SHARE", "no");
|
2023-11-07 09:32:12 +08:00
|
|
|
|
mfolderService.save(pd);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 自定义异常类
|
|
|
|
|
*/
|
|
|
|
|
class NofileException extends Exception {
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
public NofileException() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NofileException(String message) {
|
|
|
|
|
super(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NofileException(String message, Throwable cause) {
|
|
|
|
|
super(message, cause);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NofileException(Throwable cause) {
|
|
|
|
|
super(cause);
|
|
|
|
|
}
|
2023-12-18 16:14:27 +08:00
|
|
|
|
|
2023-11-07 09:32:12 +08:00
|
|
|
|
}
|