From 4b96d2271c3bae1c3197e807819246a40ee551fe Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Fri, 13 Sep 2024 11:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=93=E5=8C=85=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/config/shiro/ShiroConfig.java | 1 + .../jeecg/modules/demo/utils/ZipFiles.java | 44 +++ .../controller/XxhbjwxtscwjxxController.java | 33 +- .../xxhbjwxtscwjxx/entity/Xxhbjwxtscwjxx.java | 15 +- .../service/IXxhbjwxtscwjxxService.java | 3 + .../impl/XxhbjwxtscwjxxServiceImpl.java | 141 ++++++++ .../controller/XxhbjwxtxsmdController.java | 15 +- .../xxhbjwxtxsmd/entity/Xxhbjwxtxsmd.java | 8 + .../mapper/xml/XxhbjwxtxsmdMapper.xml | 11 +- .../service/IXxhbjwxtxsmdService.java | 3 + .../service/impl/XxhbjwxtxsmdServiceImpl.java | 124 +++++++ .../system/controller/CommonController.java | 60 ++++ jeecgboot-vue3/.env.development | 4 +- jeecgboot-vue3/src/utils/common/compUtils.ts | 18 + .../src/utils/common/renderUtils.ts | 21 +- .../bl/xxhbjwxtjxrw/Xxhbjwxtjxrw.data.ts | 9 +- .../bl/xxhbjwxtjxrw/XxhbjwxtjxrwList3.vue | 5 +- .../bl/xxhbjwxtscwjxx/XxhbjwxtscwjxxList.vue | 70 ++-- .../bl/xxhbjwxtxsmd/XxhbjwxtxsmdList3.vue | 1 + .../bl/xxhbjwxtxsmd/XxhbjwxtxsmdList4.vue | 318 +++++++++--------- 20 files changed, 705 insertions(+), 199 deletions(-) create mode 100644 jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/utils/ZipFiles.java diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java index 2859048..6ba9036 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java @@ -102,6 +102,7 @@ public class ShiroConfig { filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码 filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码 filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token + filterChainDefinitionMap.put("/sys/common/staticLocal/**", "anon");//图片预览 &下载文件不限制token filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览 //filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/utils/ZipFiles.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/utils/ZipFiles.java new file mode 100644 index 0000000..28357c1 --- /dev/null +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/utils/ZipFiles.java @@ -0,0 +1,44 @@ +package org.jeecg.modules.demo.utils; + +import java.io.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ZipFiles { + public static void zipFiles(String zipFileName, String... files) throws IOException { + FileOutputStream fos = new FileOutputStream(zipFileName); + ZipOutputStream zos = new ZipOutputStream(fos); + + for (String file : files) { + File srcFile = new File(file); + FileInputStream fis = new FileInputStream(srcFile); + + ZipEntry zipEntry = new ZipEntry(srcFile.getName()); + zos.putNextEntry(zipEntry); + + byte[] buffer = new byte[1024]; + int length; + while ((length = fis.read(buffer)) > 0) { + zos.write(buffer, 0, length); + } + + fis.close(); + zos.closeEntry(); + } + + zos.close(); + } + + public static void main(String[] args) { + String[] files = {"d://file1.txt", "d://file2.txt", "d://file3.txt"}; + String zipFileName = "D://files.zip"; + + try { + zipFiles(zipFileName, files); + + System.out.println("Files zipped successfully!"); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/controller/XxhbjwxtscwjxxController.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/controller/XxhbjwxtscwjxxController.java index efb209f..206268e 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/controller/XxhbjwxtscwjxxController.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/controller/XxhbjwxtscwjxxController.java @@ -1,17 +1,21 @@ package org.jeecg.modules.demo.xxhbjwxtscwjxx.controller; +import java.io.*; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.demo.utils.ZipFiles; import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx; import org.jeecg.modules.demo.xxhbjwxtscwjxx.service.IXxhbjwxtscwjxxService; @@ -20,6 +24,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.utils.SFTPUtil; +import org.jeecg.modules.utils.SftpConfig; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; @@ -27,6 +33,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -50,7 +57,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; public class XxhbjwxtscwjxxController extends JeecgController { @Autowired private IXxhbjwxtscwjxxService xxhbjwxtscwjxxService; - + + @Value(value = "${jeecg.path.webapp}") + private String downloadpath; + + @Autowired + SftpConfig sftpConfig; +// @Autowired +// ZipFiles zipFiles; /** * 分页列表查询 * @@ -70,6 +84,9 @@ public class XxhbjwxtscwjxxController extends JeecgController queryWrapper = QueryGenerator.initQueryWrapper(xxhbjwxtscwjxx, req.getParameterMap()); Page page = new Page(pageNo, pageSize); IPage pageList = xxhbjwxtscwjxxService.page(page, queryWrapper); + pageList.getRecords().forEach(item->{ + item.setId(item.getPath()); + }); return Result.OK(pageList); } @@ -175,4 +192,14 @@ public class XxhbjwxtscwjxxController extends JeecgController getBatchDown(@RequestBody Xxhbjwxtscwjxx xxhbjwxtscwjxx,HttpServletResponse response) { + xxhbjwxtscwjxx = xxhbjwxtscwjxxService.getBatchDown(xxhbjwxtscwjxx,response); + return Result.ok(xxhbjwxtscwjxx); + } + + + + } diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/entity/Xxhbjwxtscwjxx.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/entity/Xxhbjwxtscwjxx.java index e6e9dc4..1ce5f0e 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/entity/Xxhbjwxtscwjxx.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/entity/Xxhbjwxtscwjxx.java @@ -4,10 +4,8 @@ import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.util.Date; import java.math.BigDecimal; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.TableLogic; + +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import com.fasterxml.jackson.annotation.JsonFormat; import org.springframework.format.annotation.DateTimeFormat; @@ -56,4 +54,13 @@ public class Xxhbjwxtscwjxx implements Serializable { @Excel(name = "附件类型", width = 15) @ApiModelProperty(value = "附件类型") private String fjtype; + + @TableField(exist = false) + private String id; + @TableField(exist = false) + private String downPath[]; + @TableField(exist = false) + private String downName; + + } diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/IXxhbjwxtscwjxxService.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/IXxhbjwxtscwjxxService.java index af3c262..711d258 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/IXxhbjwxtscwjxxService.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/IXxhbjwxtscwjxxService.java @@ -4,6 +4,7 @@ import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw; import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx; import com.baomidou.mybatisplus.extension.service.IService; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -15,4 +16,6 @@ import java.util.List; public interface IXxhbjwxtscwjxxService extends IService { void syncList(List outDataList); + + Xxhbjwxtscwjxx getBatchDown(Xxhbjwxtscwjxx xxhbjwxtscwjxx, HttpServletResponse response); } diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/impl/XxhbjwxtscwjxxServiceImpl.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/impl/XxhbjwxtscwjxxServiceImpl.java index 2041d01..e866920 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/impl/XxhbjwxtscwjxxServiceImpl.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtscwjxx/service/impl/XxhbjwxtscwjxxServiceImpl.java @@ -6,13 +6,22 @@ import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw; import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx; import org.jeecg.modules.demo.xxhbjwxtscwjxx.mapper.XxhbjwxtscwjxxMapper; import org.jeecg.modules.demo.xxhbjwxtscwjxx.service.IXxhbjwxtscwjxxService; +import org.jeecg.modules.utils.SFTPUtil; +import org.jeecg.modules.utils.SftpConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * @Description: 教务系统上传文件信息 @@ -24,12 +33,144 @@ import java.util.List; @DS("multi-datasource1") public class XxhbjwxtscwjxxServiceImpl extends ServiceImpl implements IXxhbjwxtscwjxxService { + @Value(value = "${jeecg.path.webapp}") + private String downloadpath; + + @Autowired + SftpConfig sftpConfig; + @Override public void syncList(List entityList) { syncList(entityList, true); } + @Override + public Xxhbjwxtscwjxx getBatchDown(Xxhbjwxtscwjxx xxhbjwxtscwjxx, HttpServletResponse response) { + Xxhbjwxtscwjxx par = new Xxhbjwxtscwjxx(); + String downPath[] = xxhbjwxtscwjxx.getDownPath(); + // 其余处理略 + InputStream inputStream = null; + OutputStream outputStream = null; + try{ + + for(String path22:downPath){ + String imgPath = path22; + +// SFTPUtil.writeFileToRes(sftpConfig,imgPath,response); + int index = imgPath.lastIndexOf("/"); + String path = "temp"; + if(index != -1){ + path = imgPath.substring(0,index); + } + //TODO 不确定是否有问题, + Map map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath(path)); +// if(!map.get("code").equals("0")){ +// response.setStatus(404); +// throw new RuntimeException(map.get("msg")); +// } +// String localFilePath = map.get("fileName"); +// File file = new File(localFilePath); +// if(!file.exists()){ +// response.setStatus(404); +// throw new RuntimeException("文件["+imgPath+"]不存在.."); +// } + // 设置强制下载不打开 +// response.setContentType("application/force-download"); +// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); +// inputStream = new BufferedInputStream(new FileInputStream(localFilePath)); +// outputStream = response.getOutputStream(); +// byte[] buf = new byte[1024]; +// int len; +// while ((len = inputStream.read(buf)) > 0) { +// outputStream.write(buf, 0, len); +// } +// response.flushBuffer(); + } + +// response.flushBuffer(); + }catch (Exception e){ +// e.printStackTrace(); + }finally { + SFTPUtil.disChannel(); + SFTPUtil.disSession(); + } + + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + + + String files[] = new String[downPath.length]; + String name = "/"+xxhbjwxtscwjxx.getDownName()+".zip"; + String zipFileName = downloadpath+name; + + for(int i=0;i 0) { + zos.write(buffer, 0, length); + } + + fis.close(); + zos.closeEntry(); + } + zos.close(); + } + @Transactional(rollbackFor = {Exception.class}) public boolean syncList(Collection entityList, boolean isDelete) { QueryWrapper dqw = new QueryWrapper(); diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/controller/XxhbjwxtxsmdController.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/controller/XxhbjwxtxsmdController.java index 3931dee..553dde7 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/controller/XxhbjwxtxsmdController.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/controller/XxhbjwxtxsmdController.java @@ -221,7 +221,7 @@ public class XxhbjwxtxsmdController extends JeecgController getBatchDown(@RequestBody Xxhbjwxtxsmd xxhbjwxtxsmd,HttpServletResponse response) { + xxhbjwxtxsmd = xxhbjwxtxsmdService.getBatchDown(xxhbjwxtxsmd,response); + return Result.ok(xxhbjwxtxsmd); + } + } diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/entity/Xxhbjwxtxsmd.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/entity/Xxhbjwxtxsmd.java index d89719f..2a0cf8c 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/entity/Xxhbjwxtxsmd.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/entity/Xxhbjwxtxsmd.java @@ -139,4 +139,12 @@ public class Xxhbjwxtxsmd implements Serializable { private String sort; @TableField(exist = false) private String fsshow; + @TableField(exist = false) + private String id; + @TableField(exist = false) + private String studentNo[]; + @TableField(exist = false) + private String downPath[]; + @TableField(exist = false) + private String downName; } diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/mapper/xml/XxhbjwxtxsmdMapper.xml b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/mapper/xml/XxhbjwxtxsmdMapper.xml index f91f5eb..0025ec6 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/mapper/xml/XxhbjwxtxsmdMapper.xml +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/mapper/xml/XxhbjwxtxsmdMapper.xml @@ -10,8 +10,17 @@ \ No newline at end of file diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/IXxhbjwxtxsmdService.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/IXxhbjwxtxsmdService.java index 12278f5..136e110 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/IXxhbjwxtxsmdService.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/IXxhbjwxtxsmdService.java @@ -7,6 +7,7 @@ import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw; import org.jeecg.modules.demo.xxhbjwxtxsmd.entity.Xxhbjwxtxsmd; import com.baomidou.mybatisplus.extension.service.IService; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -20,4 +21,6 @@ public interface IXxhbjwxtxsmdService extends IService { void syncList(List outDataList); IPage getXsmdxxByFjtype(Page page, Xxhbjwxtxsmd xxhbjwxtxsmd); + + Xxhbjwxtxsmd getBatchDown(Xxhbjwxtxsmd xxhbjwxtxsmd, HttpServletResponse response); } diff --git a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/impl/XxhbjwxtxsmdServiceImpl.java b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/impl/XxhbjwxtxsmdServiceImpl.java index 490b1f3..871327e 100644 --- a/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/impl/XxhbjwxtxsmdServiceImpl.java +++ b/jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/xxhbjwxtxsmd/service/impl/XxhbjwxtxsmdServiceImpl.java @@ -6,16 +6,26 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.commons.lang.StringUtils; import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw; +import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx; import org.jeecg.modules.demo.xxhbjwxtxsmd.entity.Xxhbjwxtxsmd; import org.jeecg.modules.demo.xxhbjwxtxsmd.mapper.XxhbjwxtxsmdMapper; import org.jeecg.modules.demo.xxhbjwxtxsmd.service.IXxhbjwxtxsmdService; +import org.jeecg.modules.utils.SFTPUtil; +import org.jeecg.modules.utils.SftpConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.util.Collection; import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * @Description: 教务系统学生名单 @@ -27,6 +37,11 @@ import java.util.List; @DS("multi-datasource1") public class XxhbjwxtxsmdServiceImpl extends ServiceImpl implements IXxhbjwxtxsmdService { + @Value(value = "${jeecg.path.webapp}") + private String downloadpath; + + @Autowired + SftpConfig sftpConfig; @Override public void syncList(List entityList) { @@ -53,6 +68,72 @@ public class XxhbjwxtxsmdServiceImpl extends ServiceImpl page = new Page(1, 1000); + IPage page1 = baseMapper.getXsmdxxByFjtype(page,xxhbjwxtxsmd); + xxhbjwxtxsmd.setDownPath(page1.getRecords().stream().map(Xxhbjwxtxsmd::getStudentPath).toArray(String[]::new)); + String downPath[] = xxhbjwxtxsmd.getDownPath(); + // 其余处理略 + InputStream inputStream = null; + OutputStream outputStream = null; + try{ + + for(String path22:downPath){ + String imgPath = path22; + + int index = imgPath.lastIndexOf("/"); + String path = "temp"; + if(index != -1){ + path = imgPath.substring(0,index); + } + //TODO 不确定是否有问题, + Map map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath(path)); + } + + }catch (Exception e){ + }finally { + SFTPUtil.disChannel(); + SFTPUtil.disSession(); + } + + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + + + String files[] = new String[downPath.length]; + String name = "/"+xxhbjwxtxsmd.getDownName()+".zip"; + String zipFileName = downloadpath+name; + + for(int i=0;i entityList, boolean isDelete) { QueryWrapper dqw = new QueryWrapper(); @@ -61,4 +142,47 @@ public class XxhbjwxtxsmdServiceImpl extends ServiceImpl 0) { + zos.write(buffer, 0, length); + } + + fis.close(); + zos.closeEntry(); + }catch (Exception e){ + e.printStackTrace(); + } + + } + zos.close(); + } } diff --git a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java index bdee88a..585afab 100644 --- a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -320,6 +320,66 @@ public class CommonController { } + @GetMapping(value = "/staticLocal/**") + public void staticLocal(HttpServletRequest request, HttpServletResponse response) { + // ISO-8859-1 ==> UTF-8 进行编码转换 + String imgPath = extractPathFromPattern(request); + if(oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)){ + return; + } + // 其余处理略 + InputStream inputStream = null; + OutputStream outputStream = null; + try { + imgPath = imgPath.replace("..", "").replace("../",""); + if (imgPath.endsWith(SymbolConstant.COMMA)) { + imgPath = imgPath.substring(0, imgPath.length() - 1); + } + //update-begin---author:liusq ---date:20230912 for:检查下载文件类型-------------- + SsrfFileTypeFilter.checkDownloadFileType(imgPath); + //update-end---author:liusq ---date:20230912 for:检查下载文件类型-------------- + String filePath = downloadpath + File.separator + imgPath; + File file = new File(filePath); + if(!file.exists()){ + response.setStatus(404); + log.error("文件["+imgPath+"]不存在.."); + return; + //throw new RuntimeException(); + } + // 设置强制下载不打开 + response.setContentType("application/force-download"); + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); + inputStream = new BufferedInputStream(new FileInputStream(filePath)); + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (IOException e) { + log.error("预览文件失败" + e.getMessage()); + response.setStatus(404); + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + } + + } + /** * 获取文件真实路径 * @param path diff --git a/jeecgboot-vue3/.env.development b/jeecgboot-vue3/.env.development index 3f710e4..5560e19 100644 --- a/jeecgboot-vue3/.env.development +++ b/jeecgboot-vue3/.env.development @@ -6,10 +6,10 @@ VITE_PUBLIC_PATH = / # 跨域代理,您可以配置多个 ,请注意,没有换行符 -VITE_PROXY = [["/jeecgboot","http://192.168.2.13:8080/jeecg-boot"],["/upload","http://192.168.2.13:3300/upload"]] +VITE_PROXY = [["/jeecgboot","http://localhost:8080/jeecg-boot"],["/upload","http://localhost:3300/upload"]] #后台接口全路径地址(必填) -VITE_GLOB_DOMAIN_URL=http://192.168.2.13:8080/jeecg-boot +VITE_GLOB_DOMAIN_URL=http://localhost:8080/jeecg-boot #后台接口父地址(必填) VITE_GLOB_API_URL=/jeecgboot diff --git a/jeecgboot-vue3/src/utils/common/compUtils.ts b/jeecgboot-vue3/src/utils/common/compUtils.ts index 5b64368..72678c5 100644 --- a/jeecgboot-vue3/src/utils/common/compUtils.ts +++ b/jeecgboot-vue3/src/utils/common/compUtils.ts @@ -35,6 +35,24 @@ export const getFileAccessHttpUrl = (fileUrl, prefix = 'http') => { return result; }; +export const getFileAccessHttpUrlLocal = (fileUrl, prefix = 'http') => { + let result = fileUrl; + try { + if (fileUrl && fileUrl.length > 0 && !fileUrl.startsWith(prefix)) { + //判断是否是数组格式 + let isArray = fileUrl.indexOf('[') != -1; + if (!isArray) { + let prefix = `${baseApiUrl}/sys/common/staticLocal/`; + // 判断是否已包含前缀 + if (!fileUrl.startsWith(prefix)) { + result = `${prefix}${fileUrl}`; + } + } + } + } catch (err) {} + return result; +}; + /** * 触发 window.resize */ diff --git a/jeecgboot-vue3/src/utils/common/renderUtils.ts b/jeecgboot-vue3/src/utils/common/renderUtils.ts index 87889a8..9efca05 100644 --- a/jeecgboot-vue3/src/utils/common/renderUtils.ts +++ b/jeecgboot-vue3/src/utils/common/renderUtils.ts @@ -1,6 +1,6 @@ import { h } from 'vue'; import { Avatar, Tag, Tooltip, Image } from 'ant-design-vue'; -import { getFileAccessHttpUrl } from '/@/utils/common/compUtils'; +import { getFileAccessHttpUrl,getFileAccessHttpUrlLocal } from '/@/utils/common/compUtils'; import { Tinymce } from '/@/components/Tinymce'; import Icon from '/@/components/Icon'; import { getDictItemsByCode } from '/@/utils/dict/index'; @@ -175,4 +175,21 @@ function downloadFile(url) { } } -export { render, downloadFile }; +/** + * 文件下载 + */ +function downloadFileLoacl(url) { + if (!url) { + createMessage.warning('未知的文件'); + return; + } + if (url.indexOf(',') > 0) { + url = url.substring(0, url.indexOf(',')); + } + url = getFileAccessHttpUrlLocal(url.split(',')[0]); + if (url) { + window.open(url); + } +} + +export { render, downloadFile,downloadFileLoacl }; diff --git a/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/Xxhbjwxtjxrw.data.ts b/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/Xxhbjwxtjxrw.data.ts index 9bd4b29..9c6d479 100644 --- a/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/Xxhbjwxtjxrw.data.ts +++ b/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/Xxhbjwxtjxrw.data.ts @@ -190,9 +190,14 @@ export const columns2: BasicColumn[] = [ //列表数据 export const columns3: BasicColumn[] = [ { - title: '学年学期', + title: '学年', align: "center", - dataIndex: 'xnxqdm' + dataIndex: 'xn' + }, + { + title: '学期', + align: "center", + dataIndex: 'xqmc' }, { title: '课程名称', diff --git a/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/XxhbjwxtjxrwList3.vue b/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/XxhbjwxtjxrwList3.vue index cec16ef..13793d9 100644 --- a/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/XxhbjwxtjxrwList3.vue +++ b/jeecgboot-vue3/src/views/bl/xxhbjwxtjxrw/XxhbjwxtjxrwList3.vue @@ -109,7 +109,7 @@
- +
@@ -328,6 +328,9 @@ function handleXsysclxq(record) { function handleFanhui() { init(); } +function init2(){ + +} //选课确认 function handleQueren(record) { diff --git a/jeecgboot-vue3/src/views/bl/xxhbjwxtscwjxx/XxhbjwxtscwjxxList.vue b/jeecgboot-vue3/src/views/bl/xxhbjwxtscwjxx/XxhbjwxtscwjxxList.vue index 24ed943..03f3042 100644 --- a/jeecgboot-vue3/src/views/bl/xxhbjwxtscwjxx/XxhbjwxtscwjxxList.vue +++ b/jeecgboot-vue3/src/views/bl/xxhbjwxtscwjxx/XxhbjwxtscwjxxList.vue @@ -4,7 +4,7 @@
- 考核评价材料 + 考核评价材料 返回 @@ -33,12 +33,14 @@
-
- + +