| | |
| | | select * from lf.sys_attach where tab != 'bd.b_borehole' order by id desc limit 50; -- 358042 |
| | | select * from lf.sys_meta where tab is not null order by id desc |
| | | |
| | | select * from bs.m_pipeline where parentid in ('fdac47da-8879-478d-b67c-9624e8b79d6c') |
| | | select * from lf.sys_attach where tab='bs.m_pipeline' and tab_guid in (select eventid from bs.m_pipeline where parentid in ('fdac47da-8879-478d-b67c-9624e8b79d6c')) |
| | | |
| | | |
| | | |
| | |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.data.DirEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.data.DirService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载目录结构") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "目录ID", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/downloadDir") |
| | | public void downloadDir(int id, HttpServletResponse res) { |
| | | try { |
| | | DirEntity entity = dirService.selectDir(id); |
| | | if (null == entity || entity.getPid() > 0) { |
| | | return; |
| | | } |
| | | |
| | | String zipFile = dirService.createDirs(id); |
| | | if (null == zipFile) { |
| | | return; |
| | | } |
| | | |
| | | WebHelper.download(zipFile, entity.getName() + ".zip", res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 获取ZipParameters |
| | | */ |
| | | public static ZipParameters getZipParams(boolean flag) { |
| | | public static ZipParameters getZipParams(boolean hasPwd) { |
| | | // 设置压缩文件参数 |
| | | ZipParameters params = new ZipParameters(); |
| | | // 压缩方式 |
| | |
| | | // 压缩级别 |
| | | params.setCompressionLevel(CompressionLevel.MAXIMUM); |
| | | |
| | | if (flag) { |
| | | if (hasPwd) { |
| | | // 是否设置加密文件 |
| | | params.setEncryptFiles(true); |
| | | // 设置AES加密强度:KEY_STRENGTH_256 |
| | |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.lf.server.entity.data.DirEntity; |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.Zip4jHelper; |
| | | import com.lf.server.mapper.data.DirMapper; |
| | | import net.lingala.zip4j.ZipFile; |
| | | import net.lingala.zip4j.model.ZipParameters; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Service |
| | | public class DirService implements DirMapper { |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | DirMapper dirMapper; |
| | | |
| | |
| | | public List<DirEntity> selectDirsForPrj() { |
| | | return dirMapper.selectDirsForPrj(); |
| | | } |
| | | |
| | | /** |
| | | * 创建数据目录 |
| | | */ |
| | | public String createDirs(int id) throws Exception { |
| | | List<DirEntity> list = selectRecursiveById(id); |
| | | if (null == list || list.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | String tempPath = pathHelper.getTempPath(); |
| | | for (DirEntity dir : list) { |
| | | String path = tempPath + File.separator + dir.getFullName(); |
| | | File f = new File(path); |
| | | if (f.exists() && f.isDirectory()) { |
| | | continue; |
| | | } |
| | | |
| | | f.mkdirs(); |
| | | } |
| | | |
| | | File file = new File(tempPath + File.separator + list.get(0).getName()); |
| | | if (!file.exists() || !file.isDirectory()) { |
| | | file.mkdirs(); |
| | | } |
| | | |
| | | String zipFile = tempPath + File.separator + list.get(0).getName() + ".zip"; |
| | | ZipFile zip = Zip4jHelper.createZipFile(zipFile, null); |
| | | ZipParameters params = Zip4jHelper.getZipParams(false); |
| | | zip.addFolder(file, params); |
| | | |
| | | return zipFile; |
| | | } |
| | | } |
| | |
| | | |
| | | <select id="selectDirRecursive" resultType="com.lf.server.entity.data.DirEntity"> |
| | | with recursive rs as( |
| | | select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a where name = #{name} |
| | | union |
| | | select b.*, fn_get_fullname(b.code, 2) fullName from lf.sys_dir b, rs c where b.pid = c.id |
| | | ) |
| | | select * from rs order by order_num; |
| | | select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a where name = #{name} |
| | | union |
| | | select b.*, fn_get_fullname(b.code, 2) fullName from lf.sys_dir b, rs c where b.pid = c.id) |
| | | select * from rs |
| | | order by order_num; |
| | | </select> |
| | | |
| | | <select id="selectRecursiveById" resultType="com.lf.server.entity.data.DirEntity"> |
| | | with recursive rs as( |
| | | select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a where id = #{id} |
| | | union |
| | | select b.*, fn_get_fullname(b.code, 2) fullName from lf.sys_dir b, rs c where b.pid = c.id |
| | | ) |
| | | select * from rs order by order_num; |
| | | select a.*, fn_get_fullname(a.code, 2) fullName from lf.sys_dir a where id = #{id} |
| | | union |
| | | select b.*, fn_get_fullname(b.code, 2) fullName from lf.sys_dir b, rs c where b.pid = c.id) |
| | | select * from rs |
| | | order by code; |
| | | </select> |
| | | |
| | | <select id="selectDirsForPrj" resultType="com.lf.server.entity.data.DirEntity"> |