Selaa lähdekoodia

平台采购明细附件批量下载方法更新

hejq 8 vuotta sitten
vanhempi
commit
d190f48bde
1 muutettua tiedostoa jossa 15 lisäystä ja 10 poistoa
  1. 15 10
      src/main/java/com/uas/platform/b2b/controller/FileController.java

+ 15 - 10
src/main/java/com/uas/platform/b2b/controller/FileController.java

@@ -106,24 +106,29 @@ public class FileController {
     @RequestMapping("/batch/{id}")
     public void batchDownload(@PathVariable("id") long id, HttpServletResponse response) throws IOException {
         PurchaseOrderAll orderAll = purchaseOrderService.findById(id);
-        String sql = " select at_path path from attachs left join purc$prod$attach on attachs.at_id = purc$prod$attach.at_id " +
+        String sql = " select at_path path,attachs.at_id id from attachs left join purc$prod$attach on attachs.at_id = purc$prod$attach.at_id " +
                "left join purc$orderitems on purc$orderitems.pd_id = purc$prod$attach.pd_id where purc$orderitems.pd_puid = " + id;
         List<Attach> attaches = commonDao.query(sql, Attach.class);
-        StringBuffer idString = null;
+        StringBuffer idString = new StringBuffer();
         String url = null;
         if (!CollectionUtils.isEmpty(attaches)) {
            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://")) {
-                    if (idString.length() > 0) {
-                        idString.append(";");
-                    }
-                    JSONObject jsonObject = JSONObject.parseObject(attach.getPath());
-                    String atId = jsonObject.get("id").toString();
-                    idString.append(atId);
-                    // 各个ERP对应的路径不一样,采用将单个文件下载路径替换成批量文件下载路径的方法
-                    url = attach.getPath().replace("downloadbyId.action?id=", "downloadbyIds.action?ids=");
+                   // 存放在其他网络资源中,直接跳转至链接地址
+                   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);
+                       idString.append(atId);
+                   }
+                   // 各个ERP对应的路径不一样,采用将单个文件下载路径替换成批量文件下载路径的方法
+                   url = attach.getPath().replace("downloadbyId.action?id=", "downloadbyIds.action?ids=");
                }
            }
         } else {