Commit d5093d8e by 宋祥

Merge branch 'dev-sx' of http://129.211.46.84:8800/platform/hg-smart into dev

parents f3e9a974 b3650156
...@@ -3,6 +3,7 @@ package com.baosight.hggp.controller; ...@@ -3,6 +3,7 @@ package com.baosight.hggp.controller;
import com.baosight.hggp.core.constant.S3Constant; import com.baosight.hggp.core.constant.S3Constant;
import com.baosight.hggp.core.utils.Iplat4jUtils; import com.baosight.hggp.core.utils.Iplat4jUtils;
import com.baosight.hggp.core.utils.S3Utils; import com.baosight.hggp.core.utils.S3Utils;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.FileUtils; import com.baosight.hggp.util.FileUtils;
import com.baosight.hggp.util.LogUtils; import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils; import com.baosight.hggp.util.MapUtils;
...@@ -64,18 +65,9 @@ public class FileDownloadController { ...@@ -64,18 +65,9 @@ public class FileDownloadController {
@RequestMapping({"/{docId}"}) @RequestMapping({"/{docId}"})
public void download(@PathVariable String docId, HttpServletResponse response) throws IOException { public void download(@PathVariable String docId, HttpServletResponse response) throws IOException {
try { try {
if ("s3".equalsIgnoreCase(S3Constant.FILE_LOCATION)) { String url = Iplat4jUtils.buildDocUrl(docId);
Teudm05 dbDm05 = S3Utils.buildUrl(docId); AssertUtils.isEmpty(url, "文件地址为空");
// S3地址有公网 response.sendRedirect(url);
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);
}
} catch (Exception e) { } catch (Exception e) {
String msg = String.format("下载文件【%s】失败!原因:%s", docId, LogUtils.getMsg(e)); String msg = String.format("下载文件【%s】失败!原因:%s", docId, LogUtils.getMsg(e));
response.getWriter().write(msg); response.getWriter().write(msg);
......
...@@ -96,8 +96,10 @@ public class ServiceHGWD001C extends ServiceBase { ...@@ -96,8 +96,10 @@ public class ServiceHGWD001C extends ServiceBase {
*/ */
public EiInfo add(EiInfo inInfo) { public EiInfo add(EiInfo inInfo) {
try { 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("操作成功"); inInfo.setMsg("操作成功");
} catch (Exception e) { } catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "操作失败"); LogUtils.setDetailMsg(inInfo, e, "操作失败");
...@@ -114,12 +116,13 @@ public class ServiceHGWD001C extends ServiceBase { ...@@ -114,12 +116,13 @@ public class ServiceHGWD001C extends ServiceBase {
public EiInfo batchDownload(EiInfo inInfo) { public EiInfo batchDownload(EiInfo inInfo) {
try { try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo); Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileId = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_ID);
String fileName = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_NAME); String fileName = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_NAME);
String zipName = fileName + "_" + DateUtils.shortDateTime(); String zipName = fileName + "_" + DateUtils.shortDateTime();
List<String> docIds = ObjectUtils.listKey(inInfo, HGWD099.FIELD_DOC_ID); List<String> docIds = ObjectUtils.listKey(inInfo, HGWD099.FIELD_DOC_ID);
inInfo.set("downloadUrl", Iplat4jUtils.compressFile(docIds, zipName)); inInfo.set("downloadUrl", Iplat4jUtils.compressFile(docIds, zipName));
// 写入下载记录 // 写入下载记录
this.saveData(inInfo); this.saveData(inInfo, fileId);
} catch (Exception e) { } catch (Exception e) {
LogUtils.setMsg(inInfo, e, "批量下载失败"); LogUtils.setMsg(inInfo, e, "批量下载失败");
} }
...@@ -131,9 +134,7 @@ public class ServiceHGWD001C extends ServiceBase { ...@@ -131,9 +134,7 @@ public class ServiceHGWD001C extends ServiceBase {
* *
* @param inInfo * @param inInfo
*/ */
private void saveData(EiInfo inInfo) { private void saveData(EiInfo inInfo, String fileId) {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileId = MapUtils.getString(queryMap, HGWD001.FIELD_FILE_ID);
AssertUtils.isEmpty(fileId, "文件ID不能为空"); AssertUtils.isEmpty(fileId, "文件ID不能为空");
List<HGWD001C> fWd001Cs = MapUtils.toDaoEPBases(inInfo, HGWD001C.class); List<HGWD001C> fWd001Cs = MapUtils.toDaoEPBases(inInfo, HGWD001C.class);
for (HGWD001C fWd001c : fWd001Cs) { 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