Parcourir la source

文件名称优化

liuj il y a 5 mois
Parent
commit
fcc6181e0e

+ 15 - 15
src/main/java/com/sunxung/factoring/service/financing/contract/impl/ContractMakingServiceImpl.java

@@ -824,21 +824,21 @@ public class ContractMakingServiceImpl implements ContractMakingService {
                 id = Long.parseLong(split[1]);
             }
             File newFile = newContractMakingService.createContractDocument(type, id, contractInfo);
-            File renameFile = null;
-            for (File file : fileList) {
-                if (file.getName().equals(newFile.getName())) {
-                    String fileName = newFile.getName().substring(0, newFile.getName().lastIndexOf("."));
-                    String extension = newFile.getName().substring(newFile.getName().lastIndexOf("."));
-                    renameFile = new File(newFile.getParentFile(), fileName + UUID.randomUUID() + extension);
-                    newFile.renameTo(renameFile);
-                }
-            }
-            if (renameFile != null && renameFile.exists()) {
-                fileList.add(renameFile);
-            } else {
-                fileList.add(newFile);
-            }
-
+            fileList.add(newFile);
+//            File renameFile = null;
+//            for (File file : fileList) {
+//                if (file.getName().equals(newFile.getName())) {
+//                    String fileName = newFile.getName().substring(0, newFile.getName().lastIndexOf("."));
+//                    String extension = newFile.getName().substring(newFile.getName().lastIndexOf("."));
+//                    renameFile = new File(newFile.getParentFile(), fileName + UUID.randomUUID() + extension);
+//                    newFile.renameTo(renameFile);
+//                }
+//            }
+//            if (renameFile != null && renameFile.exists()) {
+//                fileList.add(renameFile);
+//            } else {
+//
+//            }
         }
         if (CollectionUtil.isNotEmpty(fileList)) {
             // 打包成zip文件

+ 5 - 5
src/main/java/com/sunxung/factoring/service/financing/contract/impl/NewContractMakingServiceImpl.java

@@ -701,7 +701,7 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                                 .bind("vehicleList", policy).bind("equityList", policy)
                                 .bind("otherList", policy).build();
                         XWPFTemplate template = XWPFTemplate.compile(absolutePath, config).render(propertyMap);
-                        String path = FileUtil.getAbsolutePath("财产清单(公司)" + guarantorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                        String path = FileUtil.getAbsolutePath("财产清单(公司)" + guarantorName + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                         File estateFile = new File(path);
                         if (!estateFile.exists()) {
                             FileUtils.createParentDirectories(estateFile);
@@ -878,9 +878,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                             NumberFormatUtil.THOUSAND_SEPARATOR_TWO_DECIMAL));
                     String path = null;
                     if (type.equals(ConstantConversionUtil.IDENTITY_TYPE1)) {
-                        path = FileUtil.getAbsolutePath("动产抵押合同(个人)" + mortgagorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                        path = FileUtil.getAbsolutePath("动产抵押合同(个人)" + mortgagorName + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                     } else if (type.equals(ConstantConversionUtil.IDENTITY_TYPE2)) {
-                        path = FileUtil.getAbsolutePath("动产抵押合同(公司)" + mortgagorName, ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                        path = FileUtil.getAbsolutePath("动产抵押合同(公司)" + mortgagorName + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                     }
                     XWPFTemplate template = XWPFTemplate.compile(absolutePath, config).render(map);
                     File file = new File(path);
@@ -997,9 +997,9 @@ public class NewContractMakingServiceImpl implements INewContractMakingService {
                     map.put("financingAmountCname", financingAmountCname);
                     String path = null;
                     if (type.equals(ConstantConversionUtil.IDENTITY_TYPE1)) {
-                        path = FileUtil.getAbsolutePath("股权质押合同(个人)" + mortgageBasicInfo.getMortgagorName(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                        path = FileUtil.getAbsolutePath("股权质押合同(个人)" + mortgageBasicInfo.getMortgagorName() + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                     } else if (type.equals(ConstantConversionUtil.IDENTITY_TYPE2)) {
-                        path = FileUtil.getAbsolutePath("股权质押合同(公司)" + mortgageBasicInfo.getMortgagorName(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
+                        path = FileUtil.getAbsolutePath("股权质押合同(公司)" + mortgageBasicInfo.getMortgagorName() + UUID.randomUUID(), ".docx", FileModuleDict.ChildEnum.CONTRACT_FILE_PREVIEW);
                     }
                     File file = new File(path);
                     if (!file.exists()) {