Explorar o código

批量下载,在文件名后+时间戳或存储名称,防止文件名相同只下载单个

user5 %!s(int64=4) %!d(string=hai) anos
pai
achega
f34aad3c53

+ 1 - 1
src/main/java/com/jeeplus/common/bos/BosController.java

@@ -31,7 +31,7 @@ public class BosController {
             try {
                 //MultipartFile转File
                 File srcFile = transformMultipartFile(file);
-                String path = directory+"/"+storeAs+datePath()+"/"+ UUID.randomUUID().toString().replaceAll("-","")+"/"+srcFile.getName();
+                String path = directory+"/"+storeAs+datePath()+"/"+ System.currentTimeMillis()+srcFile.getName();
                 BOSClientUtil bosClientUtil = new BOSClientUtil();
                 InputStream inputStream = file.getInputStream();
                 String upload = bosClientUtil.upload(path, inputStream);

+ 8 - 20
src/main/java/com/jeeplus/modules/utils/SftpClientUtil.java

@@ -68,7 +68,7 @@ public class SftpClientUtil {
             if (!dir.exists()) {
                 dir.mkdirs();
             }
-            String filePath = path +"/" + UUID.randomUUID().toString().replaceAll("-", "") + file.getName();
+            String filePath = path +"/" + System.currentTimeMillis() + file.getName();
             //File转MultipartFile文件
             MultipartFile multipartFile = transformFile(file);
             //保存文件
@@ -94,7 +94,7 @@ public class SftpClientUtil {
             sftp.cd(remoteFolder);
         }catch (SftpException e){
         }
-        String remoteName = UUID.randomUUID().toString().replaceAll("-", "") + remoteFileName;
+        String remoteName = System.currentTimeMillis() + remoteFileName;
         sftp.put(fileStream, remoteName);
         disconnect(sftp);
         logger.info("文件上传成功!! 耗时:{"+(System.currentTimeMillis() - start)+"}ms");
@@ -261,7 +261,7 @@ public class SftpClientUtil {
                 //将文件读入文件流
                 InputStream inStream = new FileInputStream(fileurl);
                 //判断浏览器代理并分别设置响应给浏览器的编码格式(并去除文件服务器中文件的UUID头展示信息)
-                String finalFileName = URLEncoder.encode(downloadFile.substring(32, downloadFile.length()),"UTF8");
+                String finalFileName = URLEncoder.encode(downloadFile.substring(13, downloadFile.length()),"UTF8");
                 //设置HTTP响应头
                 response.reset();//重置 响应头
                 response.setContentType("application/x-download");//告知浏览器下载文件,而不是直接打开,浏览器默认为打开
@@ -280,7 +280,7 @@ public class SftpClientUtil {
                 if(path != null && !"".equals(path)){
                     sftp.cd(path);
                 }
-                String fileName = URLEncoder.encode(downloadFile.substring(32, downloadFile.length()),"UTF-8");
+                String fileName = URLEncoder.encode(downloadFile.substring(13, downloadFile.length()),"UTF-8");
                 OutputStream out = null;
                 InputStream in = sftp.get(downloadFile);
                 response.reset();//重置 响应头
@@ -308,25 +308,13 @@ public class SftpClientUtil {
      *
      * @param directory     SFTP服务器的文件路径
      * @param downloadFile  SFTP服务器上的文件名
-     * @param downLoadFilePath   保存路径
-     * @param finalFileName   准备生成的文件名
-     * @return
-     * @throws IOException
+     * @return              字节数组
      */
     public byte[] downloadRuralProject(String directory, String downloadFile,String downLoadFilePath,String finalFileName) throws IOException {
         File dirFile = new File(downLoadFilePath);
         if (!dirFile.exists()) {
             dirFile.mkdirs();
         }
-        //睡眠1毫秒 用来防止相同文件名被替换
-        try {
-            Thread.sleep(1);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        //文件名处理(将文件名拆分为名称和后缀名为之后添加时间戳做准备)
-        String headName = finalFileName.substring(0,finalFileName.lastIndexOf("."));
-        String endName = finalFileName.substring(finalFileName.lastIndexOf("."),finalFileName.length());
         if("1".equals(uploadMode)){
             OutputStream out = null;
             InputStream in = null;
@@ -345,7 +333,7 @@ public class SftpClientUtil {
                     downLoadFilePath += "/";
                 }
                 //写入到文件(注意文件保存路径的后面一定要加上文件的名称)
-                fileOut = new FileOutputStream(downLoadFilePath + headName + System.currentTimeMillis() + endName);
+                fileOut = new FileOutputStream(downLoadFilePath + downloadFile);
                 BufferedOutputStream bos = new BufferedOutputStream(fileOut);
                 byte[] buf = new byte[4096];
                 int length = bis.read(buf);
@@ -376,7 +364,7 @@ public class SftpClientUtil {
                     //将文件读入文件流
                     InputStream inStream = new FileInputStream(fileurl);
 
-                    File file = new File(downLoadFilePath,headName + System.currentTimeMillis() + endName);
+                    File file = new File(downLoadFilePath,downloadFile);
                     //将下载保存到文件。
                     FileOutputStream out = new FileOutputStream(file);
                     Streams.copy(inStream, out, true);
@@ -389,7 +377,7 @@ public class SftpClientUtil {
 
                     BufferedInputStream bis = new BufferedInputStream(inputStream);
                     //写入到文件(注意文件保存路径的后面一定要加上文件的名称)
-                    FileOutputStream  fileOut = new FileOutputStream(downLoadFilePath + "/" + headName + System.currentTimeMillis() + endName);
+                    FileOutputStream  fileOut = new FileOutputStream(downLoadFilePath + "/" + downloadFile);
                     BufferedOutputStream bos = new BufferedOutputStream(fileOut);
 
                     byte[] buf = new byte[4096];

+ 5 - 1
src/main/java/com/jeeplus/modules/workfullmanage/web/WorkFullManageController.java

@@ -896,7 +896,11 @@ public class WorkFullManageController extends BaseController {
 		//咨询类别
 		data.put("consultType",consultType);
 		//委托单位
-		data.put("entrustUnit",workContractInfo.getClient().getName());
+		if (null != workContractInfo.getClient()) {
+			data.put("entrustUnit",workContractInfo.getClient().getName());
+		}else{
+			data.put("entrustUnit","");
+		}
 		data.put("contractNumber",workContractInfo.getContractNum());
 		//约定作业期
 		data.put("promiseTime",promiseTime);

+ 1 - 0
src/main/resources/mappings/modules/ruralprojectrecords/RuralProjectRecordsDao.xml

@@ -93,6 +93,7 @@
 		wct.name AS "workContractInfo.client.name",
 		o.top_company AS "office.name"
 		,ifnull(prr.status ,0) as "projectReportRecordStatus"
+		,ifnull(prd.status ,0) as "projectReportStatus"
 		FROM rural_project_records a
 		<include refid="projectRecordsJoins"/>
 

+ 2 - 2
src/main/webapp/webpage/modules/ruralprojectrecords/cost/ruralCostProjectRecordsList.jsp

@@ -399,14 +399,14 @@
 					<shiro:hasPermission name="ruralProject:ruralCostProjectRecords:accessory">
 						,"recordStatus":
 							<c:choose>
-								<c:when test="${projectRecords.projectStatus == 5 && '5' != projectRecords.projectReportRecordStatus}">"1"</c:when>
+								<c:when test="${projectRecords.projectStatus == 5 && '0' != projectRecords.projectReportStatus && '5' != projectRecords.projectReportRecordStatus}">"1"</c:when>
 								<c:otherwise>"0"</c:otherwise>
 							</c:choose>
 					</shiro:hasPermission>
 					<shiro:hasPermission name="ruralProject:ruralCostProjectRecords:adminAccessory">
 					,"adminAccessory":
 							<c:choose>
-							<c:when test="${projectRecords.projectStatus == 5}">"1"</c:when>
+							<c:when test="${projectRecords.projectStatus == 5 && '0' != projectRecords.projectReportStatus}">"1"</c:when>
 					<c:otherwise>"0"</c:otherwise>
 					</c:choose>
 					</shiro:hasPermission>

+ 2 - 2
src/main/webapp/webpage/modules/ruralprojectrecords/ruralProjectRecordsList.jsp

@@ -427,14 +427,14 @@
 					<shiro:hasPermission name="ruralProject:ruralProjectRecords:accessory">
 					,"recordStatus":
 							<c:choose>
-							<c:when test="${'5' != projectRecords.projectReportRecordStatus && projectRecords.projectStatus == 5}">"1"</c:when>
+							<c:when test="${projectRecords.projectStatus == 5 && '0' != projectRecords.projectReportStatus && '5' != projectRecords.projectReportRecordStatus}">"1"</c:when>
 					<c:otherwise>"0"</c:otherwise>
 					</c:choose>
 					</shiro:hasPermission>
 					<shiro:hasPermission name="ruralProject:ruralProjectRecords:adminAccessory">
 					,"adminAccessory":
 							<c:choose>
-							<c:when test="${projectRecords.projectStatus == 5}">"1"</c:when>
+							<c:when test="${projectRecords.projectStatus == 5 && '0' != projectRecords.projectReportStatus}">"1"</c:when>
 					<c:otherwise>"0"</c:otherwise>
 					</c:choose>
 					</shiro:hasPermission>