From 93d9e33cfbb7f5c63ec2ea54be9780266fc78e2e Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 29 五月 2023 11:59:29 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/service/data/UploadService.java |  181 +++++++++++++++++++--------------------------
 1 files changed, 76 insertions(+), 105 deletions(-)

diff --git a/src/main/java/com/lf/server/service/data/UploadService.java b/src/main/java/com/lf/server/service/data/UploadService.java
index 5c05c6b..2dccb6e 100644
--- a/src/main/java/com/lf/server/service/data/UploadService.java
+++ b/src/main/java/com/lf/server/service/data/UploadService.java
@@ -22,6 +22,7 @@
 
 /**
  * 鏁版嵁涓婁紶鏈嶅姟绫�
+ *
  * @author WWW
  */
 @Service
@@ -66,10 +67,13 @@
      */
     public void insertFiles(UserEntity ue, List<MetaFileEntity> list, HttpServletRequest req) {
         checkMetaFiles(ue, list);
-        excelLoader(list, req);
+        List<MetaFileEntity> xlsList = getExcelFiles(list);
         loadData(list);
         copyFiles(list);
         insertMetas(list);
+        if (xlsList.size() > 0) {
+            String guid = excelLoader(xlsList, req);
+        }
     }
 
     /**
@@ -93,29 +97,9 @@
 
             MetaEntity old = metaService.selectByGuid(mf.getGuid(), null);
             if (null != old) {
-                mf.setMsg("宸插叆搴�");
+                mf.setMsg("宸插瓨鍦�");
             }
         }
-    }
-
-    /**
-     * Excel鍏ュ簱
-     */
-    private String excelLoader(List<MetaFileEntity> list, HttpServletRequest req) {
-        List<MetaFileEntity> xlsList = getExcelFiles(list);
-        if (xlsList.isEmpty()) {
-            return "";
-        }
-
-        String guid = null;
-        try {
-            MetaFileEntity meta = getExcelMeta(xlsList);
-            guid = fmeService.excelLoader(meta, req);
-        } catch (Exception ex) {
-            log.error(ex.getMessage(), ex);
-        }
-
-        return guid;
     }
 
     /**
@@ -124,48 +108,29 @@
     private List<MetaFileEntity> getExcelFiles(List<MetaFileEntity> list) {
         List<MetaFileEntity> xlsList = new ArrayList<>();
         for (MetaFileEntity mf : list) {
-            if (null != mf.getMsg()) {
-                continue;
-            }
-            if (StaticData.XLS.equals(mf.getExtName()) || StaticData.XLSX.equals(mf.getExtName()) || mf.getName().contains("WBS")) {
+            if (null == mf.getMsg() && isExcel(mf)) {
                 xlsList.add(mf);
             }
+        }
+        if (xlsList.isEmpty()) {
+            return xlsList;
+        }
+
+        String xlsBasePath = getXlsPath(xlsList.get(0).getPath());
+        for (int i = 0, c = xlsList.size(); i < c; i++) {
+            MetaFileEntity mf = xlsList.get(i);
+            String xlsPath = copyXlsFile(xlsBasePath, i, mf);
+            mf.setXlsPath(xlsPath);
         }
 
         return xlsList;
     }
 
     /**
-     * 鑾峰彇Excel鐨勫厓鏁版嵁
+     * 鏄�/鍚︿负Excel
      */
-    private MetaFileEntity getExcelMeta(List<MetaFileEntity> xlsList) {
-        List<String> pathList = new ArrayList<>();
-        List<String> dirList = new ArrayList<>();
-        List<String> pidList = new ArrayList<>();
-
-        String xlsBasePath = getXlsPath(xlsList.get(0).getPath());
-        for (int i = 0, c = xlsList.size(); i < c; i++) {
-            MetaFileEntity mf = xlsList.get(i);
-
-            String path = copyXlsFile(xlsBasePath, i, mf);
-            if (null != path) {
-                pathList.add(path);
-                dirList.add(mf.getDircode());
-                pidList.add(mf.getEventid());
-            }
-        }
-
-        MetaFileEntity first = xlsList.get(0);
-        MetaFileEntity meta = new MetaFileEntity();
-        meta.setPath(StringHelper.join(pathList, ","));
-        meta.setEpsgCode(first.getEpsgCode());
-        meta.setName(StringHelper.join(dirList, ";"));
-        meta.setDepcode(first.getDepcode());
-        meta.setVerid(first.getVerid());
-        meta.setCreateUser(first.getCreateUser());
-        meta.setEventid(StringHelper.join(pidList, ";"));
-
-        return meta;
+    private boolean isExcel(MetaFileEntity mf) {
+        return StaticData.XLS.equals(mf.getExtName()) || StaticData.XLSX.equals(mf.getExtName());
     }
 
     /**
@@ -245,7 +210,7 @@
 
         MetaEntity old = metaService.selectByGuid(mf.getGuid(), tabName);
         if (null != old) {
-            mf.setMsg("宸插叆搴�");
+            mf.setMsg("宸插瓨鍦�");
             return;
         }
 
@@ -306,6 +271,9 @@
                 case StaticData.MPT:
                     copyMultiFile(mf, StaticData.MPT_EXT);
                     break;
+                case StaticData.JPG:
+                    copyMultiFile(mf, StaticData.JPG_EXT);
+                    break;
                 case StaticData.IMG:
                     copyMultiFile(mf, StaticData.IMG_EXT);
                     break;
@@ -349,7 +317,7 @@
 
         MetaEntity old = metaService.selectByGuid(mf.getGuid(), null);
         if (null != old) {
-            mf.setMsg("宸插叆搴�");
+            mf.setMsg("宸插瓨鍦�");
             file.delete();
             return 0;
         }
@@ -418,7 +386,7 @@
 
         MetaEntity old = metaService.selectByGuid(mf.getGuid(), null);
         if (null != old) {
-            mf.setMsg("宸插叆搴�");
+            mf.setMsg("宸插瓨鍦�");
             FileHelper.deleteFiles(file);
             return;
         }
@@ -458,53 +426,6 @@
         }
 
         return null;
-    }
-
-    /**
-     * 鍙戝竷鏂囦欢
-     */
-    private void publishFiles(List<MetaFileEntity> list) {
-        for (MetaFileEntity mf : list) {
-            if (null != mf.getMsg()) {
-                continue;
-            }
-            switch (mf.getExtName()) {
-                case StaticData.MPT:
-                    linkFiles(mf, StaticData.MPT_EXT, pathHelper.getConfig().getUploadPath() + File.separator + "SG");
-                    break;
-                case StaticData.D3DML:
-                    linkFiles(mf, null, pathHelper.getConfig().getUploadPath() + File.separator + "SG");
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    /**
-     * 閾炬帴鏂囦欢
-     */
-    private void linkFiles(MetaFileEntity mf, List<String> exts, String publishPath) {
-        String uploadPath = pathHelper.getConfig().getUploadPath();
-        String source = uploadPath + File.separator + mf.getPath();
-        String target = publishPath + File.separator + mf.getName();
-
-        File sourceFile = new File(source);
-        if (!sourceFile.exists() || sourceFile.isDirectory()) {
-            return;
-        }
-
-        createFileLink(source, target);
-        if (null == exts) {
-            return;
-        }
-
-        for (String ext : exts) {
-            File f = new File(source.replace(mf.getExtName(), ext));
-            if (f.exists() && !f.isDirectory()) {
-                createFileLink(source.replace(mf.getExtName(), ext), target.replace(mf.getExtName(), ext));
-            }
-        }
     }
 
     /**
@@ -579,4 +500,54 @@
 
         return 0;
     }
+
+    /**
+     * Excel鍏ュ簱
+     */
+    private String excelLoader(List<MetaFileEntity> xlsList, HttpServletRequest req) {
+        try {
+            MetaFileEntity xlsMeta = getExcelMeta(xlsList);
+            if (null != xlsMeta) {
+                return fmeService.excelLoader(xlsMeta, req);
+            }
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
+
+        return null;
+    }
+
+    /**
+     * 鑾峰彇Excel鐨勫厓鏁版嵁
+     */
+    private MetaFileEntity getExcelMeta(List<MetaFileEntity> xlsList) {
+        if (null == xlsList || xlsList.isEmpty()) {
+            return null;
+        }
+
+        List<String> pathList = new ArrayList<>();
+        List<String> dirList = new ArrayList<>();
+        List<String> pidList = new ArrayList<>();
+
+        for (int i = 0, c = xlsList.size(); i < c; i++) {
+            MetaFileEntity mf = xlsList.get(i);
+            if ("鎴愬姛".equals(mf.getMsg()) && null != mf.getXlsPath()) {
+                pathList.add(mf.getXlsPath());
+                dirList.add(mf.getDircode());
+                pidList.add(mf.getEventid());
+            }
+        }
+
+        MetaFileEntity first = xlsList.get(0);
+        MetaFileEntity meta = new MetaFileEntity();
+        meta.setPath(StringHelper.join(pathList, ","));
+        meta.setEpsgCode(first.getEpsgCode());
+        meta.setName(StringHelper.join(dirList, ";"));
+        meta.setDepcode(first.getDepcode());
+        meta.setVerid(first.getVerid());
+        meta.setCreateUser(first.getCreateUser());
+        meta.setEventid(StringHelper.join(pidList, ";"));
+
+        return meta;
+    }
 }

--
Gitblit v1.9.3