Просмотр исходного кода

更新从ERP批量下载附件的方法

hejq 8 лет назад
Родитель
Сommit
ed1cf6f8b8
1 измененных файлов с 8 добавлено и 5 удалено
  1. 8 5
      src/main/java/com/uas/platform/b2b/controller/FileController.java

+ 8 - 5
src/main/java/com/uas/platform/b2b/controller/FileController.java

@@ -115,27 +115,30 @@ public class FileController {
            for (Attach attach : attaches) {
                if (attach.getPath().startsWith("http://dfs.ubtob.com")) {// 存储在dfs存储服务器,去dfs存储服务器下载
                 // TODO dfs服务器上打包下载
-               } else if (attach.getPath().startsWith("http://") || attach.getPath().startsWith("https://") || attach.getPath().startsWith("ftp://") || attach.getPath().startsWith("sftp://")) {
+               } else if ((attach.getPath().startsWith("http://") || attach.getPath().startsWith("https://") || attach.getPath().startsWith("ftp://") || attach.getPath().startsWith("sftp://"))
+                       && !attach.getPath().contains("downloadbyId.action")) {
                    // 存放在其他网络资源中,直接跳转至链接地址
                    response.sendRedirect(attach.getPath());
                } else {
                    // 其他的当做是存放在本地服务器上,去本地服务器根据文件路径去获取
-                   if (idString.length() > 0) {
-                       idString.append(";");
-                   }
                    if (attach.getPath().contains("=")) {
                        String atId = attach.getPath().substring(attach.getPath().lastIndexOf("id=") + 3);
+                       if (idString.length() > 0) {
+                           idString.append(";");
+                       }
                        idString.append(atId);
                    }
                    // 各个ERP对应的路径不一样,采用将单个文件下载路径替换成批量文件下载路径的方法
                    url = attach.getPath().replace("downloadbyId.action?id=", "downloadbyIds.action?ids=");
+                   String atId = url.substring(url.lastIndexOf("ids=") + 4);
+                   url = url.replace("ids=" + atId, "ids=");
                }
            }
         } else {
            throw new NotFoundException("暂未找到相关附件");
         }
          if (idString.length() > 0 && null != url && null != orderAll) {
-           response.sendRedirect(url + idString + "&zipName=" + orderAll.getCode() + "采购明细附件");
+           response.sendRedirect(url + idString + "&zipName=" + orderAll.getCode());
         }
     }