From 5dfad30e157a35020d90c55d8b9b0729ecc3357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=E5=98=89=E9=98=B3?= Date: Mon, 26 Feb 2018 10:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=87=E4=BB=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=BB=93=E6=9E=84=EF=BC=8C=E5=AF=B9=E5=A4=87=E4=BB=BD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=BB=9F=E4=B8=80=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fjy/spring/controller/UpLoadController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fjy/spring/controller/UpLoadController.java b/src/main/java/com/fjy/spring/controller/UpLoadController.java index dee0388..c05801e 100644 --- a/src/main/java/com/fjy/spring/controller/UpLoadController.java +++ b/src/main/java/com/fjy/spring/controller/UpLoadController.java @@ -182,15 +182,21 @@ public class UpLoadController { File targetFile = new File(pathname); //若文件已存在则自动重命名 if (targetFile.exists()){ + String bakpathname; + if (rename) { + bakpathname = uploadUrl + "bak/" +user.getColstudentno() + user.getColrealname() + suffix; + } else { + bakpathname = uploadUrl +"bak/"+ filename; + } log.info("源文件路径:"+pathname); TbFile file1 = fileService.findByFilepath(pathname); - file1.setColfilepath(file1.getColfilepath()+"."+dateNowStr2+".bak"); + file1.setColfilepath(bakpathname+"."+dateNowStr2+".bak"); file1.setColfilename(file1.getColfilename()+"."+dateNowStr2+".bak"); if (fileService.addFile(file1)) log.info("重命名文件数据库更新成功"); else log.error("重命名文件数据库更新失败"); - File mvfile = new File(pathname+"."+dateNowStr2+".bak"); + File mvfile = new File(bakpathname+"."+dateNowStr2+".bak"); try { FileUtils.moveFile(targetFile, mvfile); log.info("源文件:"+targetFile.getName()+"已重命名为:"+ mvfile.getName());