瀏覽代碼

生产端,时间问题1

wuweihao 2 年之前
父節點
當前提交
15375fbbfa

+ 7 - 0
720yun_fd_manage/gis_oss/pom.xml

@@ -70,6 +70,13 @@
             <scope>compile</scope>
         </dependency>
 
+        <!-- 中文转拼音 -->
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+            <version>2.5.1</version>
+        </dependency>
+
 
     </dependencies>
 

+ 4 - 6
720yun_fd_manage/gis_oss/src/main/java/com/gis/oss/util/FileUtils.java

@@ -55,6 +55,7 @@ public class FileUtils {
      * @return map
      */
     public Map<String, Object> uploadMap(MultipartFile file, String savePath, boolean isPinYinRename) {
+
         String newName = this.upload(file, savePath, isPinYinRename);
         HashMap<String, Object> result = new HashMap<>();
         result.put("fileName", file.getOriginalFilename());
@@ -72,6 +73,7 @@ public class FileUtils {
      */
     public String upload(MultipartFile file, String savePath, boolean isPinYinRename) {
 
+        log.info("执行文件写入服务器");
         // 检查非法文件上传
         boolean checkFile = this.checkFile(file);
         if (!checkFile) {
@@ -86,7 +88,8 @@ public class FileUtils {
             newName = RegexUtil.getPinyinName(fileName);
         } else {
             String suffix = StringUtils.substringAfterLast(fileName, ".");
-            newName =  this.getDateTime() + ATOMIC_INTEGER.incrementAndGet() + "." + suffix;
+            String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
+            newName =  time + ATOMIC_INTEGER.incrementAndGet() + "." + suffix;
         }
 
         savePath = configConstant.serverBasePath + savePath + "/" + newName;
@@ -103,11 +106,6 @@ public class FileUtils {
     }
 
 
-    private static String getDateTime(){
-        return DateUtil.format(LocalDateTime.now(), "YYYYMMDD_HHMMSSSSS");
-    }
-
-
     /**
      * 多文件上传
      * savePath 路径(目录)

+ 1 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -389,6 +389,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
      * @return
      */
     private String createThumb(String type, MultipartFile file){
+        log.info("run createThumb");
 
         // 写入文件
         String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSS");