Commit b3650156 by 宋祥

1.下载文件报错问题修复

parent 64b09b2e
......@@ -3,6 +3,7 @@ package com.baosight.hggp.controller;
import com.baosight.hggp.core.constant.S3Constant;
import com.baosight.hggp.core.utils.Iplat4jUtils;
import com.baosight.hggp.core.utils.S3Utils;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.FileUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
......@@ -64,22 +65,13 @@ public class FileDownloadController {
@RequestMapping({"/{docId}"})
public void download(@PathVariable String docId, HttpServletResponse response) throws IOException {
try {
if ("s3".equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
Teudm05 dbDm05 = S3Utils.buildUrl(docId);
// S3地址有公网
response.sendRedirect(dbDm05.getUrl());
// S3地址无公网
// FileUtils.downloadUrlFile(dbDm05.getUrl(), dbDm05.getResCname(), false, response);
} else {
Map dbDm02 = Iplat4jUtils.getDoc02ById(docId);
String returnUrl = MapUtils.getString(dbDm02, "url");
String fileName = MapUtils.getString(dbDm02, "docName");
FileUtils.downloadFile(new File(returnUrl), fileName, false, response);
}
String url = Iplat4jUtils.buildDocUrl(docId);
AssertUtils.isEmpty(url, "文件地址为空");
response.sendRedirect(url);
} catch (Exception e) {
String msg = String.format("下载文件【%s】失败!原因:%s", docId, LogUtils.getMsg(e));
response.getWriter().write(msg);
}
}
}
......@@ -96,8 +96,10 @@ public class ServiceHGWD001C extends ServiceBase {
*/
public EiInfo add(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo, EiConstant.resultBlock);
String fileId = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_ID);
// 写入下载记录
this.saveData(inInfo);
this.saveData(inInfo, fileId);
inInfo.setMsg("操作成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "操作失败");
......@@ -114,12 +116,13 @@ public class ServiceHGWD001C extends ServiceBase {
public EiInfo batchDownload(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileId = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_ID);
String fileName = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_NAME);
String zipName = fileName + "_" + DateUtils.shortDateTime();
List<String> docIds = ObjectUtils.listKey(inInfo, HGWD099.FIELD_DOC_ID);
inInfo.set("downloadUrl", Iplat4jUtils.compressFile(docIds, zipName));
// 写入下载记录
this.saveData(inInfo);
this.saveData(inInfo, fileId);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "批量下载失败");
}
......@@ -131,9 +134,7 @@ public class ServiceHGWD001C extends ServiceBase {
*
* @param inInfo
*/
private void saveData(EiInfo inInfo) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileId = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_ID);
private void saveData(EiInfo inInfo, String fileId) {
AssertUtils.isEmpty(fileId, "文件ID不能为空");
List<HGWD001C> fWd001Cs = MapUtils.toDaoEPBases(inInfo, HGWD001C.class);
for (HGWD001C fWd001c : fWd001Cs) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment