Commit f3e9a974 by 宋祥

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

parents 8d13ba90 64b09b2e
...@@ -82,25 +82,4 @@ public class FileDownloadController { ...@@ -82,25 +82,4 @@ public class FileDownloadController {
} }
} }
/**
* 下载本地文件
*
* @param docId
* @param response
* @throws IOException
*/
@RequestMapping({"docId/{docId}"})
public void downloadUrls(@PathVariable String docId, HttpServletResponse response)
throws IOException {
try {
Map dbDm02 = Iplat4jUtils.getDoc02ById(docId);
String url = MapUtils.getString(dbDm02, "url");
String fileName = MapUtils.getString(dbDm02, "docName");
FileUtils.downloadFile(new File(url), fileName, false, response);
} catch (Exception e) {
String msg = String.format("下载文件【%s】失败!原因:%s", docId, LogUtils.getMsg(e));
response.getWriter().write(msg);
}
}
} }
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
package com.baosight.hggp.core.constant; package com.baosight.hggp.core.constant;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
/** /**
* 与操作系统 有关的一些常量. * 与操作系统 有关的一些常量.
* *
...@@ -17,6 +19,11 @@ package com.baosight.hggp.core.constant; ...@@ -17,6 +19,11 @@ package com.baosight.hggp.core.constant;
public class OSConstant { public class OSConstant {
/** /**
* docRootDir
*/
public static String DOC_ROOT_DIR = PlatApplicationContext.getProperty("docRootDir");
/**
* 文件夹分隔符,不同OS下分隔符不同 * 文件夹分隔符,不同OS下分隔符不同
*/ */
public final static String SEPARATOR = System.getProperty("file.separator"); public final static String SEPARATOR = System.getProperty("file.separator");
...@@ -34,16 +41,21 @@ public class OSConstant { ...@@ -34,16 +41,21 @@ public class OSConstant {
/** /**
* 程序运行目录 * 程序运行目录
*/ */
public final static String DOWN_DIR = USER_DIR + SEPARATOR + "file" + SEPARATOR + "download"; public final static String DOWN_DIR = DOC_ROOT_DIR + SEPARATOR + "download";
/** /**
* 二维码目录 * 二维码目录
*/ */
public final static String QRCODE_DIR = USER_DIR + SEPARATOR + "file" + SEPARATOR + "qrcode"; public final static String QRCODE_DIR = DOC_ROOT_DIR + SEPARATOR + "qrcode";
/** /**
* 压缩包目录 * 压缩包目录
*/ */
public final static String ZIP_DIR = USER_DIR + SEPARATOR + "file" + SEPARATOR + "zip"; public final static String ZIP_DIR = DOC_ROOT_DIR + SEPARATOR + "zip";
/**
* 文件下载上下文
*/
public final static String FILE_DOWNLOAD = "file-download";
} }
...@@ -30,4 +30,10 @@ public class DcContract { ...@@ -30,4 +30,10 @@ public class DcContract {
* 设计来源 * 设计来源
*/ */
private String designSource; private String designSource;
/**
* 审批状态
*/
private String spStatus;
} }
...@@ -123,6 +123,7 @@ public class DcApiUtils { ...@@ -123,6 +123,7 @@ public class DcApiUtils {
dcContract.setHtid(dataJson.getString("Htid")); dcContract.setHtid(dataJson.getString("Htid"));
dcContract.setTitle(dataJson.getString("Title")); dcContract.setTitle(dataJson.getString("Title"));
dcContract.setDesignSource(dataJson.getString("!B__SysCusmf_0_11001_507_0")); dcContract.setDesignSource(dataJson.getString("!B__SysCusmf_0_11001_507_0"));
dcContract.setSpStatus(dataJson.getString("SpStatus"));
return dcContract; return dcContract;
} }
......
...@@ -3,7 +3,6 @@ package com.baosight.hggp.core.tools; ...@@ -3,7 +3,6 @@ package com.baosight.hggp.core.tools;
import com.baosight.hggp.core.dao.DaoBase; import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import com.baosight.iplat4j.common.ed.domain.TEDFA00; import com.baosight.iplat4j.common.ed.domain.TEDFA00;
import com.baosight.iplat4j.common.eu.domain.Teudm03;
import com.baosight.iplat4j.common.eu.domain.Teudm05; import com.baosight.iplat4j.common.eu.domain.Teudm05;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -80,7 +79,7 @@ public class Iplat4jTools { ...@@ -80,7 +79,7 @@ public class Iplat4jTools {
public static class EuDm02 { public static class EuDm02 {
/** /**
* 查询页面信息 * 查询
* *
* @param docId * @param docId
* @return * @return
...@@ -92,6 +91,19 @@ public class Iplat4jTools { ...@@ -92,6 +91,19 @@ public class Iplat4jTools {
List<Map> results = DaoBase.getInstance().query("EUDM02.queryDocById", paramMap); List<Map> results = DaoBase.getInstance().query("EUDM02.queryDocById", paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0); return CollectionUtils.isEmpty(results) ? null : results.get(0);
} }
/**
* 查询
*
* @param docIds
* @return
*/
public static List<Map> listByDocId(List<String> docIds) {
AssertUtils.isEmpty(docIds, "文件ID不能为空!");
Map<String, Object> paramMap = new HashMap();
paramMap.put("docIds", docIds);
return DaoBase.getInstance().query("EUDM02.queryDocById", paramMap);
}
} }
/** /**
...@@ -115,5 +127,18 @@ public class Iplat4jTools { ...@@ -115,5 +127,18 @@ public class Iplat4jTools {
List<Teudm05> results = DaoBase.getInstance().query("EUDM05.getDocByDocId", paramMap); List<Teudm05> results = DaoBase.getInstance().query("EUDM05.getDocByDocId", paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0); return CollectionUtils.isEmpty(results) ? null : results.get(0);
} }
/**
* 查询页面信息
*
* @param docIds
* @return
*/
public static List<Teudm05> listByDocId(List<String> docIds) {
AssertUtils.isEmpty(docIds, "文件ID不能为空!");
Map<String, Object> paramMap = new HashMap();
paramMap.put("resIds", docIds);
return DaoBase.getInstance().query("EUDM05.getDocByDocId", paramMap);
}
} }
} }
...@@ -12,7 +12,9 @@ import com.baosight.iplat4j.common.eu.domain.Teudm05; ...@@ -12,7 +12,9 @@ import com.baosight.iplat4j.common.eu.domain.Teudm05;
import com.baosight.iplat4j.core.exception.PlatException; import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext; import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.eu.dm.util.PlatFileUploader; import com.baosight.iplat4j.eu.dm.util.PlatFileUploader;
import org.apache.commons.collections.CollectionUtils;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -33,8 +35,7 @@ public class Iplat4jUtils { ...@@ -33,8 +35,7 @@ public class Iplat4jUtils {
*/ */
public static boolean deleteFileByDocId(String docId) { public static boolean deleteFileByDocId(String docId) {
// 判断文件上传的地址 // 判断文件上传的地址
String fileLocation = S3Constant.FILE_LOCATION; if ("s3".equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
if ("s3".equalsIgnoreCase(fileLocation)) {
Teudm05 dbDm05 = Iplat4jTools.EuDm05.getByDocId(docId); Teudm05 dbDm05 = Iplat4jTools.EuDm05.getByDocId(docId);
if (dbDm05 == null) { if (dbDm05 == null) {
throw new PlatException("文件在服务器中不存在"); throw new PlatException("文件在服务器中不存在");
...@@ -78,6 +79,65 @@ public class Iplat4jUtils { ...@@ -78,6 +79,65 @@ public class Iplat4jUtils {
} }
/** /**
* 获取文件HTTP URL
*
* @param docIds
* @return
*/
public static Map<String, String> buildDocUrl(List<String> docIds) throws Exception {
if (CollectionUtils.isEmpty(docIds)) {
return null;
}
Map<String, String> resultMap = new HashMap<>();
if ("s3".equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
List<Teudm05> dbDm05s = Iplat4jTools.EuDm05.listByDocId(docIds);
if (CollectionUtils.isEmpty(dbDm05s)) {
return null;
}
for (Teudm05 dbDm05 : dbDm05s) {
resultMap.put(dbDm05.getResId(), S3Utils.buildUrl(dbDm05));
}
} else {
List<Map> dbDm02Maps = Iplat4jTools.EuDm02.listByDocId(docIds);
if (CollectionUtils.isEmpty(dbDm02Maps)) {
return null;
}
for (Map dbDm02Map : dbDm02Maps) {
String docId = dbDm02Map.get("docId").toString();
String chgName = dbDm02Map.get("chgName").toString();
String realPath = dbDm02Map.get("realPath").toString();
resultMap.put(docId,
S3Constant.RESOURCE + OSConstant.SEPARATOR + realPath + OSConstant.SEPARATOR + chgName);
}
}
return resultMap;
}
/**
* 构建文件HTTP地址
*
* @param docId
* @return
* @throws Exception
*/
public static String buildDocUrl(String docId) throws Exception {
if (StringUtils.isEmpty(docId)) {
return null;
}
if ("s3".equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
return S3Utils.buildUrl(docId).getUrl();
} else {
Map dbDm02Map = Iplat4jTools.EuDm02.getByDocId(docId);
if (MapUtils.isEmpty(dbDm02Map)) {
return null;
}
String chgName = dbDm02Map.get("chgName").toString();
String realPath = dbDm02Map.get("realPath").toString();
return S3Constant.RESOURCE + "/" + OSConstant.FILE_DOWNLOAD + "/" + realPath + chgName;
}
}
/**
* 压缩文件 * 压缩文件
* *
* @param docIds * @param docIds
...@@ -111,7 +171,7 @@ public class Iplat4jUtils { ...@@ -111,7 +171,7 @@ public class Iplat4jUtils {
// 压缩完删除本地文件 // 压缩完删除本地文件
FileUtils.deleteFiles(zipFolderPath); FileUtils.deleteFiles(zipFolderPath);
// 替换成HTTP地址 // 替换成HTTP地址
return S3Constant.RESOURCE + zipFilePath.replace(OSConstant.USER_DIR, "") return S3Constant.RESOURCE + "/" + OSConstant.FILE_DOWNLOAD + zipFilePath.replace(OSConstant.DOC_ROOT_DIR, "")
.replace(OSConstant.SEPARATOR, "/"); .replace(OSConstant.SEPARATOR, "/");
} }
......
...@@ -4,6 +4,7 @@ import com.amazonaws.services.s3.AmazonS3; ...@@ -4,6 +4,7 @@ import com.amazonaws.services.s3.AmazonS3;
import com.baosight.hggp.core.constant.S3Constant; import com.baosight.hggp.core.constant.S3Constant;
import com.baosight.hggp.core.tools.Iplat4jTools; import com.baosight.hggp.core.tools.Iplat4jTools;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.FileUtils;
import com.baosight.hggp.util.StringUtils; import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.common.eu.domain.Teudm05; import com.baosight.iplat4j.common.eu.domain.Teudm05;
import com.baosight.iplat4j.eu.dm.document.bos.s3.api.signed.SignedBosHelp; import com.baosight.iplat4j.eu.dm.document.bos.s3.api.signed.SignedBosHelp;
...@@ -28,17 +29,37 @@ public class S3Utils { ...@@ -28,17 +29,37 @@ public class S3Utils {
*/ */
public static Teudm05 buildUrl(String docId) throws Exception { public static Teudm05 buildUrl(String docId) throws Exception {
Teudm05 dbDm05 = Iplat4jTools.EuDm05.getByDocId(docId); Teudm05 dbDm05 = Iplat4jTools.EuDm05.getByDocId(docId);
AssertUtils.isNull(dbDm05, String.format("文件【%s】不存在", docId));
String s3UrlPrefix = dbDm05.getUrl(); String s3UrlPrefix = dbDm05.getUrl();
String fileName = dbDm05.getResCname(); String fileName = dbDm05.getResCname();
String returnUrlPrefix = BosParamHelp.disposeUrl(s3UrlPrefix); String returnUrlPrefix = BosParamHelp.disposeUrl(s3UrlPrefix);
URL s3Url = SignedBosHelp.getDownloadTempUrl(s3UrlPrefix, fileName, null); URL s3Url = SignedBosHelp.getDownloadTempUrl(s3UrlPrefix, fileName, null);
String s3UrlParam = StringUtils.defaultIfEmpty(s3Url.getQuery(), ""); String s3UrlParam = StringUtils.defaultIfEmpty(s3Url.getQuery(), "");
String returnUrl = returnUrlPrefix + "?" + s3UrlParam; String returnUrl = returnUrlPrefix + "?" + s3UrlParam;
dbDm05.setUrl(com.baosight.iplat4j.eu.dm.util.FileUtils.returnDocUrlByEncodeFileName(returnUrl)); dbDm05.setUrl(FileUtils.returnDocUrlByEncodeFileName(returnUrl));
return dbDm05; return dbDm05;
} }
/** /**
* 根据docId换取临时下载地址
*
* @param dm05
* @return
*/
public static String buildUrl(Teudm05 dm05) throws Exception {
if (dm05 == null) {
return null;
}
String s3UrlPrefix = dm05.getUrl();
String fileName = dm05.getResCname();
String returnUrlPrefix = BosParamHelp.disposeUrl(s3UrlPrefix);
URL s3Url = SignedBosHelp.getDownloadTempUrl(s3UrlPrefix, fileName, null);
String s3UrlParam = StringUtils.defaultIfEmpty(s3Url.getQuery(), "");
String returnUrl = returnUrlPrefix + "?" + s3UrlParam;
return FileUtils.returnDocUrlByEncodeFileName(returnUrl);
}
/**
* 上传文件 * 上传文件
* *
* @param key 默认不指定key的情况下,以文件内容的hash值作为文件名 * @param key 默认不指定key的情况下,以文件内容的hash值作为文件名
......
...@@ -5,8 +5,6 @@ import com.baosight.hggp.core.dao.DaoUtils; ...@@ -5,8 +5,6 @@ import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.extapp.decheng.api.DcOpenApi; import com.baosight.hggp.core.extapp.decheng.api.DcOpenApi;
import com.baosight.hggp.core.extapp.decheng.model.DcContract; import com.baosight.hggp.core.extapp.decheng.model.DcContract;
import com.baosight.hggp.core.extapp.decheng.model.DcContractList; import com.baosight.hggp.core.extapp.decheng.model.DcContractList;
import com.baosight.hggp.core.extapp.decheng.model.DcUser;
import com.baosight.hggp.core.extapp.decheng.model.DcUserList;
import com.baosight.hggp.core.model.Pager; import com.baosight.hggp.core.model.Pager;
import com.baosight.hggp.core.utils.ThreadUtils; import com.baosight.hggp.core.utils.ThreadUtils;
import com.baosight.hggp.hg.pz.domain.HGPZ009; import com.baosight.hggp.hg.pz.domain.HGPZ009;
...@@ -16,17 +14,11 @@ import com.baosight.hggp.hg.sc.domain.HGSC001; ...@@ -16,17 +14,11 @@ import com.baosight.hggp.hg.sc.domain.HGSC001;
import com.baosight.hggp.hg.sc.enums.ProjectSourceEnum; import com.baosight.hggp.hg.sc.enums.ProjectSourceEnum;
import com.baosight.hggp.hg.sc.tools.HGSCTools; import com.baosight.hggp.hg.sc.tools.HGSCTools;
import com.baosight.hggp.hg.wd.constant.HgWdSqlConstant; import com.baosight.hggp.hg.wd.constant.HgWdSqlConstant;
import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.hg.xs.constant.HgXsSqlConstant;
import com.baosight.hggp.hg.xs.domain.User;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.hg.xs.utils.HGXSUtils;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.DateUtils; import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils; import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils; import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils; import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase; import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
...@@ -175,9 +167,9 @@ public class ServiceHGSC101 extends ServiceEPBase { ...@@ -175,9 +167,9 @@ public class ServiceHGSC101 extends ServiceEPBase {
* @param dcContractList * @param dcContractList
*/ */
private void syncDcContractSingle(HGPZ009 dbPz009, DcContractList dcContractList) throws IOException { private void syncDcContractSingle(HGPZ009 dbPz009, DcContractList dcContractList) throws IOException {
// 获取用户详情 // 获取合同详情
DcContract dcContract = DcOpenApi.contractDetail(dcContractList.getOrd()); DcContract dcContract = DcOpenApi.contractDetail(dcContractList.getOrd());
if (dcContract == null) { if (dcContract == null || !"审批通过".equals(dcContract.getSpStatus())) {
return; return;
} }
dcContract.setOrd(dcContractList.getOrd()); dcContract.setOrd(dcContractList.getOrd());
......
...@@ -3,9 +3,10 @@ package com.baosight.hggp.hg.wd.service; ...@@ -3,9 +3,10 @@ package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation; import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.core.dao.DaoUtils; import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.DeleteFlagEnum; import com.baosight.hggp.core.enums.DeleteFlagEnum;
import com.baosight.hggp.hg.cw.tools.HGCWTools; import com.baosight.hggp.core.utils.Iplat4jUtils;
import com.baosight.hggp.hg.wd.domain.HGWD001B; import com.baosight.hggp.hg.wd.domain.HGWD001B;
import com.baosight.hggp.hg.wd.domain.HGWD002; import com.baosight.hggp.hg.wd.domain.HGWD002;
import com.baosight.hggp.hg.wd.domain.HGWD099;
import com.baosight.hggp.hg.wd.tools.HGWDTools; import com.baosight.hggp.hg.wd.tools.HGWDTools;
import com.baosight.hggp.util.AssertUtils; import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.EiInfoUtils; import com.baosight.hggp.util.EiInfoUtils;
...@@ -17,7 +18,6 @@ import com.baosight.iplat4j.core.ei.EiConstant; ...@@ -17,7 +18,6 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo; import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceBase; import com.baosight.iplat4j.core.service.impl.ServiceBase;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -91,15 +91,20 @@ public class ServiceHGWD001B extends ServiceBase { ...@@ -91,15 +91,20 @@ public class ServiceHGWD001B extends ServiceBase {
*/ */
public EiInfo add(EiInfo inInfo) { public EiInfo add(EiInfo inInfo) {
try { try {
List<HGWD001B> fWd001bs = MapUtils.toDaoEPBases(inInfo, HGWD001B.class); HGWD001B fWd001b = MapUtils.toDaoEPBase(inInfo, HGWD001B.class);
for (HGWD001B fWd001b : fWd001bs) {
// AssertUtils.isEmpty(fWd001b.getFileId(), "文件ID不能为空"); // AssertUtils.isEmpty(fWd001b.getFileId(), "文件ID不能为空");
// 预览记录+1 HGWD099 dbWd099 = HGWDTools.HgWd099.getByDocId(fWd001b.getDocId());
AssertUtils.isNull(dbWd099, "文件不存在");
// 预览次数+1
HGWDTools.HgWd099.previewIncr(fWd001b.getDocId()); HGWDTools.HgWd099.previewIncr(fWd001b.getDocId());
// 新增 // 新增记录
fWd001b.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode()); fWd001b.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HGWD001B.INSERT, fWd001b); DaoUtils.insert(HGWD001B.INSERT, fWd001b);
} // 构建文件HTTP地址
String url = Iplat4jUtils.buildDocUrl(fWd001b.getDocId());
AssertUtils.isEmpty(url, "文件地址异常,请联系管理人员!");
inInfo.set("url", url);
inInfo.set("docType", dbWd099.getDocType());
inInfo.setStatus(EiConstant.STATUS_SUCCESS); inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("操作成功"); inInfo.setMsg("操作成功");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -78,7 +78,6 @@ public class ServiceHGWD002 extends ServiceBase { ...@@ -78,7 +78,6 @@ public class ServiceHGWD002 extends ServiceBase {
return inInfo; return inInfo;
} }
public void builder(EiInfo eiInfo) { public void builder(EiInfo eiInfo) {
String[] orderBy = eiInfo.getBlock(EiConstant.resultBlock).getString("orderBy").split(","); String[] orderBy = eiInfo.getBlock(EiConstant.resultBlock).getString("orderBy").split(",");
if (orderBy.length > 0) { if (orderBy.length > 0) {
......
...@@ -378,12 +378,12 @@ public class HGWDTools { ...@@ -378,12 +378,12 @@ public class HGWDTools {
public static class HgWd099 { public static class HgWd099 {
public static List<HGWD099> getByDocId(String bizType, String docId) { public static HGWD099 getByDocId(String docId) {
AssertUtils.isEmpty(docId, "文件ID不能为空"); AssertUtils.isEmpty(docId, "文件ID不能为空");
Map<String, Object> paramMap = new HashMap(); Map<String, Object> paramMap = new HashMap();
paramMap.put(HGWD099.FIELD_BIZ_TYPE, bizType);
paramMap.put(HGWD099.FIELD_DOC_ID, docId); paramMap.put(HGWD099.FIELD_DOC_ID, docId);
return DaoBase.getInstance().query(HGWD099.QUERY, paramMap); List<HGWD099> results = DaoBase.getInstance().query(HGWD099.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
} }
/** /**
......
...@@ -2,8 +2,6 @@ package com.baosight.hggp.util; ...@@ -2,8 +2,6 @@ package com.baosight.hggp.util;
import com.baosight.hggp.core.constant.OSConstant; import com.baosight.hggp.core.constant.OSConstant;
import org.apache.poi.util.IOUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
...@@ -665,4 +663,57 @@ public class FileUtils extends org.apache.commons.io.FileUtils { ...@@ -665,4 +663,57 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
throw e; throw e;
} }
} }
/**
* URL编码
*
* @param url
* @return
*/
public static String returnDocUrlByEncodeFileName(String url) {
if (url != null && !url.trim().isEmpty()) {
String startSymbol = "/";
String endSymbol = "?";
int lastSlashIndex = url.lastIndexOf(startSymbol);
int questionMarkIndex = url.lastIndexOf(endSymbol);
int startIndex = lastSlashIndex + 1;
int endIndex = questionMarkIndex > startIndex ? questionMarkIndex : url.length();
String replaceUrlStr = url.substring(startIndex, endIndex);
if (containsChinese(replaceUrlStr)) {
try {
replaceUrlStr = getEncodeFileName(replaceUrlStr);
} catch (UnsupportedEncodingException var9) {
UnsupportedEncodingException e = var9;
throw new RuntimeException(e);
}
}
return url.substring(0, startIndex) + replaceUrlStr + url.substring(endIndex);
} else {
return url;
}
}
public static boolean containsChinese(String str) {
if (str != null && !str.trim().isEmpty()) {
char[] var1 = str.toCharArray();
int var2 = var1.length;
for (int var3 = 0; var3 < var2; ++var3) {
char c = var1[var3];
if (c >= 19968 && c <= '龥') {
return true;
}
}
return false;
} else {
return false;
}
}
public static String getEncodeFileName(String fileName) throws UnsupportedEncodingException {
String downloadFileName = URLEncoder.encode(fileName, "UTF-8");
return downloadFileName.replaceAll("\\+", "%20");
}
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="EUDM02">
<select id="query" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT
DOC_ID as "docId", <!-- 文件标识 -->
t2.DIR_ID as "dirId", <!-- 目录标识 -->
DOC_NAME as "docName", <!-- 文件名 -->
CHG_NAME as "chgName", <!-- 物理文件名 -->
DOC_SIZE as "docSize", <!-- 文件大小 -->
DOC_TAG as "docTag", <!-- 文件标签 -->
t2.REC_CREATOR as "recCreator", <!-- 记录创建责任者 -->
t2.REC_CREATE_TIME as "recCreateTime", <!-- 记录创建时刻 -->
t2.REC_REVISOR as "recRevisor", <!-- 记录修改责任者 -->
t2.REC_REVISE_TIME as "recReviseTime", <!-- 记录修改时刻 -->
t2.ARCHIVE_FLAG as "archiveFlag", <!-- 归档标记 -->
t2.SHARED_DOC_TYPE as "sharedDocType", <!-- 共享文档类型-->
t1.REAL_PATH as "realPath"
FROM ${platSchema}.TEUDM02 t2 LEFT JOIN ${platSchema}.TEUDM01 t1 ON
t2.DIR_ID = t1.DIR_ID WHERE 1=1
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="sharedDocType">
t2.SHARED_DOC_TYPE = #sharedDocType#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="dirId">
t2.DIR_ID = #dirId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docName">
DOC_NAME like '%$docName$%'
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docTag">
DOC_TAG like '%$docTag$%'
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projectEname">
PROJECT_ENAME = #projectEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="moduleEname">
MODULE_ENAME = #moduleEname#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
DOC_NAME asc
</isEmpty>
</dynamic>
</select>
<select id="queryDocById" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT
DOC_ID as "docId", <!-- 文件标识 -->
t2.DIR_ID as "dirId", <!-- 目录标识 -->
REAL_PATH as "realPath", <!-- 真实路径 -->
DOC_NAME as "docName", <!-- 文件名 -->
CHG_NAME as "chgName", <!-- 物理文件名 -->
DOC_SIZE as "docSize", <!-- 文件大小 -->
DOC_TAG as "docTag", <!-- 文件标签 -->
t2.REC_CREATOR as "recCreator", <!-- 记录创建责任者 -->
t2.REC_CREATE_TIME as "recCreateTime", <!-- 记录创建时刻 -->
t2.REC_REVISOR as "recRevisor", <!-- 记录修改责任者 -->
t2.REC_REVISE_TIME as "recReviseTime", <!-- 记录修改时刻 -->
t2.ARCHIVE_FLAG as "archiveFlag" <!-- 归档标记 -->
FROM ${platSchema}.TEUDM02 t2 LEFT JOIN ${platSchema}.TEUDM01 t1 ON
t2.DIR_ID = t1.DIR_ID WHERE 1=1
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docIds">
DOC_ID IN <iterate close=")" open="(" conjunction="," property="docIds">#docIds[]#</iterate>
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
DOC_NAME asc
</isEmpty>
</dynamic>
</select>
<select id="queryDocByTag" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
SELECT
DOC_ID as "docId", <!-- 文件标识 -->
t2.DIR_ID as "dirId", <!-- 目录标识 -->
REAL_PATH as "realPath", <!-- 真实路径 -->
DOC_NAME as "docName", <!-- 文件名 -->
CHG_NAME as "chgName", <!-- 物理文件名 -->
DOC_SIZE as "docSize", <!-- 文件大小 -->
DOC_TAG as "docTag", <!-- 文件标签 -->
t2.REC_CREATOR as "recCreator", <!-- 记录创建责任者 -->
t2.REC_CREATE_TIME as "recCreateTime", <!-- 记录创建时刻 -->
t2.REC_REVISOR as "recRevisor", <!-- 记录修改责任者 -->
t2.REC_REVISE_TIME as "recReviseTime", <!-- 记录修改时刻 -->
t2.ARCHIVE_FLAG as "archiveFlag" <!-- 归档标记 -->
FROM ${platSchema}.TEUDM02 t2 LEFT JOIN ${platSchema}.TEUDM01 t1 ON
t2.DIR_ID = t1.DIR_ID WHERE
DOC_TAG = #docTag#
<isNotEmpty prepend=" AND " property="projectEname">
PROJECT_ENAME = #projectEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="moduleEname">
MODULE_ENAME = #moduleEname#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
DOC_NAME asc
</isEmpty>
</dynamic>
</select>
<select id="count" resultClass="int">
SELECT COUNT(*)
FROM ${platSchema}.TEUDM02 t2 LEFT JOIN ${platSchema}.TEUDM01 t1 ON
t2.DIR_ID = t1.DIR_ID WHERE 1=1
<isNotEmpty prepend=" AND " property="dirId">
t2.DIR_ID = #dirId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docName">
DOC_NAME like '%$docName$%'
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docTag">
DOC_TAG like '%$docTag$%'
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projectEname">
PROJECT_ENAME = #projectEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="moduleEname">
MODULE_ENAME = #moduleEname#
</isNotEmpty>
</select>
<!--
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="dirId">
DIR_ID = #dirId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docName">
DOC_NAME = #docName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="chgName">
CHG_NAME = #chgName#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docSize">
DOC_SIZE = #docSize#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="docTag">
DOC_TAG = #docTag#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recCreator">
REC_CREATOR = #recCreator#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recCreateTime">
REC_CREATE_TIME = #recCreateTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recRevisor">
REC_REVISOR = #recRevisor#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="recReviseTime">
REC_REVISE_TIME = #recReviseTime#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="archiveFlag">
ARCHIVE_FLAG = #archiveFlag#
</isNotEmpty>
-->
<insert id="insert">
INSERT INTO ${platSchema}.TEUDM02 (DOC_ID, <!-- 文件标识 -->
DIR_ID, <!-- 目录标识 -->
DOC_NAME, <!-- 文件名 -->
CHG_NAME, <!-- 物理文件名 -->
DOC_SIZE, <!-- 文件大小 -->
DOC_TAG, <!-- 文件标签 -->
REC_CREATOR, <!-- 记录创建责任者 -->
REC_CREATE_TIME, <!-- 记录创建时刻 -->
REC_REVISOR, <!-- 记录修改责任者 -->
REC_REVISE_TIME, <!-- 记录修改时刻 -->
ARCHIVE_FLAG, <!-- 归档标记 -->
SHARED_DOC_TYPE
)
VALUES (#docId:VARCHAR#, #dirId:VARCHAR#, #docName:VARCHAR#, #chgName:VARCHAR#, #docSize:NUMERIC#,
#docTag:VARCHAR#, #recCreator:VARCHAR#, #recCreateTime:VARCHAR#, #recRevisor:VARCHAR#, #recReviseTime:VARCHAR#,
#archiveFlag:VARCHAR#,#sharedDocType:VARCHAR#)
</insert>
<delete id="delete">
DELETE FROM ${platSchema}.TEUDM02 WHERE
DOC_ID = #docId#
</delete>
<delete id="deleteByDocId">
DELETE FROM ${platSchema}.TEUDM02 WHERE 1=1
<isNotEmpty prepend=" AND " property="docId">
DOC_ID = #docId#
</isNotEmpty>
</delete>
<!--TODO 根据docTag删除 先根据项目模块查询 循环删除-->
<delete id="deleteByTag">
DELETE FROM ${platSchema}.TEUDM02 WHERE 1=1
<isNotEmpty prepend=" AND " property="docTag">
DOC_TAG = #docTag#
</isNotEmpty>
</delete>
<update id="update">
UPDATE ${platSchema}.TEUDM02
SET
DIR_ID = #dirId#, <!-- 目录标识 -->
DOC_NAME = #docName#, <!-- 文件名 -->
CHG_NAME = #chgName#, <!-- 物理文件名 -->
DOC_SIZE = #docSize:NUMERIC#, <!-- 文件大小 -->
DOC_TAG = #docTag#, <!-- 文件标签 -->
REC_CREATOR = #recCreator#, <!-- 记录创建责任者 -->
REC_CREATE_TIME = #recCreateTime#, <!-- 记录创建时刻 -->
REC_REVISOR = #recRevisor#, <!-- 记录修改责任者 -->
REC_REVISE_TIME = #recReviseTime#, <!-- 记录修改时刻 -->
ARCHIVE_FLAG = #archiveFlag#, <!-- 归档标记 -->
SHARED_DOC_TYPE as "sharedDocType"
WHERE
DOC_ID = #docId#
</update>
<update id="updateShareDocType">
UPDATE ${platSchema}.TEUDM02
SET
REC_REVISOR = #recRevisor#, <!-- 修改者 -->
REC_REVISE_TIME = #recReviseTime#, <!-- 记录修改时间 -->
SHARED_DOC_TYPE = #sharedDocType#
WHERE
DOC_ID = #docId#
</update>
</sqlMap>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="EUDM05">
<select id="getDocByDocId" parameterClass="java.util.HashMap"
resultClass="com.baosight.iplat4j.common.eu.domain.Teudm05">
SELECT
RES_ID as "resId", <!-- 资源ID -->
PROJECT_ENAME as "projectEname", <!-- 项目英文名 -->
APP_ID as "appId", <!-- 应用标识 -->
RES_TYPE as "resType", <!-- 资源类型 -->
RES_ENAME as "resEname", <!-- 资源英文名 -->
RES_CNAME as "resCname", <!-- 资源中文名 -->
IS_AUTH as "isAuth", <!-- 是否授权 -->
GROUP_ID as "groupId", <!-- 文件组名 -->
STORAGE_TYPE as "storageType", <!-- 存储类型 -->
BUCKET_NAME as "bucketName", <!-- 桶名 -->
FILE_EXTENSION as "fileExtension", <!-- 文件后缀名 -->
FILE_SIZE as "fileSize", <!-- 文件大小 -->
FILE_HASH_VALUE as "fileHashValue", <!-- 文件HASH值 -->
URL as "url", <!-- 永久链接 -->
PREVIEW_URL as "previewUrl", <!-- 预览链接 -->
SORT as "sort", <!-- 排序 -->
UPLOAD_TYPE as "uploadType", <!-- 上传类型 -->
ENCRYPTION_LEVEL as "encryptionLevel", <!-- 加密级别 -->
DEVICE_ID as "deviceId", <!-- 设备ID -->
DOC_TYPE_ENAME as "docTypeEname", <!-- 文档类型 -->
FILE_TYPE as "fileType", <!-- 文件业务类型 -->
ORG_CODE as "orgCode", <!-- 组织机构编码 -->
ORG_NAME as "orgName", <!-- 组织机构名称 -->
FILE_STATUS as "fileStatus", <!-- 预留字段1 -->
RESERVED_FIELD2 as "reservedField2", <!-- 预留字段2 -->
RESERVED_FIELD3 as "reservedField3", <!-- 预留字段3 -->
RESERVED_FIELD4 as "reservedField4", <!-- 预留字段4 -->
RESERVED_FIELD5 as "reservedField5", <!-- 预留字段5 -->
REC_CREATOR as "recCreator", <!-- 创建者 -->
REC_CREATE_TIME as "recCreateTime", <!-- 记录创建时间 -->
REC_REVISOR as "recRevisor", <!-- 修改者 -->
REC_REVISE_TIME as "recReviseTime", <!-- 记录修改时间 -->
ARCHIVE_FLAG as "archiveFlag", <!-- 归档标记 -->
TENANT_ID as "tenantId", <!-- 租户标识 -->
FILE_ID as "fileId",
PLATFORM_CODE as "platformCode",
DOC_TYPE as "docType",
CUSTOM_FOLDER as "customFolder",
CLIENT_ID as "clientId", <!-- 客服端标识 -->
CONFIG_PATH_DEFINE as "configPathDefine",
SHARED_DOC_TYPE as "sharedDocType"
FROM ${platSchema}.TEUDM05 WHERE 1=1
<isNotEmpty prepend=" AND " property="resId">
RES_ID = #resId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="resIds">
RES_ID IN <iterate close=")" open="(" conjunction="," property="resIds">#resIds[]#</iterate>
</isNotEmpty>
<isNotEmpty prepend=" AND " property="projectEname">
PROJECT_ENAME = #projectEname#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="groupId">
GROUP_ID = #groupId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="appId">
APP_ID = #appId#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="fileStatus">
FILE_STATUS = #fileStatus#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
$orderBy$
</isNotEmpty>
<isEmpty property="orderBy">
SORT desc
</isEmpty>
</dynamic>
</select>
<update id="updateToDocMap">
UPDATE ${platSchema}.TEUDM05
SET
RES_TYPE = #resType#, <!-- 资源类型 -->
FILE_SIZE = #fileSize:NUMERIC#, <!-- 文件大小 -->
FILE_HASH_VALUE = #fileHashValue#, <!-- 文件HASH值 -->
FILE_STATUS = #fileStatus#, <!-- 状态 -->
REC_REVISOR = #recRevisor#, <!-- 修改者 -->
REC_REVISE_TIME = #recReviseTime# <!-- 记录修改时间 -->
WHERE
RES_ID = #resId#
</update>
<update id="updateShareDocType">
UPDATE ${platSchema}.TEUDM05
SET
REC_REVISOR = #recRevisor#, <!-- 修改者 -->
REC_REVISE_TIME = #recReviseTime#, <!-- 记录修改时间 -->
SHARED_DOC_TYPE = #sharedDocType#
WHERE
RES_ID = #resId#
</update>
</sqlMap>
\ No newline at end of file
...@@ -34,7 +34,9 @@ function addRecord(fileId, docId, docType, docName) { ...@@ -34,7 +34,9 @@ function addRecord(fileId, docId, docType, docName) {
onSuccess: function (res) { onSuccess: function (res) {
if (res.getStatus() >= 0) { if (res.getStatus() >= 0) {
try { try {
previewFile(docId, docType, docName); let url = res.extAttr.url;
let docType = res.extAttr.docType;
previewFile(url, docType);
} catch (e) { } catch (e) {
} }
} else { } else {
...@@ -52,27 +54,26 @@ function addRecord(fileId, docId, docType, docName) { ...@@ -52,27 +54,26 @@ function addRecord(fileId, docId, docType, docName) {
/** /**
* 新增记录后回调 * 新增记录后回调
* *
* @param docId * @param url
* @param docType * @param docType
* @param docName
*/ */
function previewFile(docId, docType, docName) { function previewFile(url, docType) {
// 隐藏文本描述 // 隐藏文本描述
$("#descDiv").css('display', 'none'); $("#descDiv").css('display', 'none');
if (isXml(docType)) { if (isXml(docType)) {
previewXml(docId); previewXml(url);
} else if (isExcel(docType)) { } else if (isExcel(docType)) {
previewExcel(docId); previewExcel(url);
} else if (isWord(docType)) {
previewDocx(url);
} else if (true) { } else if (true) {
previewOnline(docId, docName); previewOnline(url);
} else if (isText(docType)) { } else if (isText(docType)) {
previewText(docId); previewText(url);
} else if (isWord(docType)) {
previewDocx(docId);
} else if (isImage(docType)) { } else if (isImage(docType)) {
previewImage(docId); previewImage(url);
} else if (isFrame(docType)) { } else if (isFrame(docType)) {
previewFrame(docId); previewFrame(url);
} else { } else {
otherDownload(false, docId); otherDownload(false, docId);
} }
...@@ -145,10 +146,10 @@ function isXml(docType) { ...@@ -145,10 +146,10 @@ function isXml(docType) {
/** /**
* xml文件预览 * xml文件预览
* *
* @param docId * @param url
*/ */
function previewXml(docId) { function previewXml(url) {
fetch(downloadHref(docId, true)).then(res => { fetch(url).then(res => {
return res.text(); return res.text();
}).then(data => { }).then(data => {
let container = document.getElementById("textContainer"); let container = document.getElementById("textContainer");
...@@ -174,10 +175,10 @@ function isExcel(docType) { ...@@ -174,10 +175,10 @@ function isExcel(docType) {
/** /**
* 文件预览 * 文件预览
* *
* @param docId * @param url
*/ */
function previewExcel(docId) { function previewExcel(url) {
fetch(downloadHref(docId, true)).then(res => { fetch(url).then(res => {
return res.blob(); return res.blob();
}).then(blob => { }).then(blob => {
let container = document.getElementById("textContainer"); let container = document.getElementById("textContainer");
...@@ -223,10 +224,10 @@ function isWord(docType) { ...@@ -223,10 +224,10 @@ function isWord(docType) {
/** /**
* docx预览 * docx预览
* *
* @param docId * @param url
*/ */
function previewDocx(docId) { function previewDocx(url) {
fetch(downloadHref(docId, true)).then(res => { fetch(url).then(res => {
return res.arrayBuffer(); return res.arrayBuffer();
}).then(arrayBuffer => { }).then(arrayBuffer => {
let container = document.getElementById("docxContainer"); let container = document.getElementById("docxContainer");
...@@ -288,12 +289,11 @@ function previewFrame(docId) { ...@@ -288,12 +289,11 @@ function previewFrame(docId) {
/** /**
* 在线预览 * 在线预览
* *
* @param docId * @param url
* @param fileName
*/ */
function previewOnline(docId, fileName) { function previewOnline(url) {
$("#previewFrame").css('display', ''); $("#previewFrame").css('display', '');
$("#previewFrame").attr("src", CommonUtils.previewFile(docId, fileName)); $("#previewFrame").attr("src", CommonUtils.previewFile(url));
} }
/** /**
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<EF:EFInput cname="操作类型" ename="operType" blockId="inqu_status" row="0" type="hidden"/> <EF:EFInput cname="操作类型" ename="operType" blockId="inqu_status" row="0" type="hidden"/>
<EF:EFInput cname="业务类型" ename="bizType" blockId="inqu_status" row="0" type="hidden"/> <EF:EFInput cname="业务类型" ename="bizType" blockId="inqu_status" row="0" type="hidden"/>
<EF:EFRegion id="result"> <EF:EFRegion id="result">
<EF:EFUpload blockId="result" ename="uploadFile" docTag="wd_file" path="WD"/> <EF:EFUpload blockId="result" ename="uploadFile" docTag="wd_file" path="upload"/>
</EF:EFRegion> </EF:EFRegion>
<EF:EFInput ename="fileDocId" cname="" hidden="true"/> <EF:EFInput ename="fileDocId" cname="" hidden="true"/>
</EF:EFPage> </EF:EFPage>
......
...@@ -668,25 +668,24 @@ function loadChange(grid,e,field) { ...@@ -668,25 +668,24 @@ function loadChange(grid,e,field) {
/** /**
* 预览 * 预览
* *
* @param docId 文件ID * @param url 文件URL
* @param docName 文件名称必须带后缀
*/ */
let previewFile = function (docId, docName) { let previewFile = function (url) {
let hostname = window.location.hostname; // let hostname = window.location.hostname;
let domain = hostname === "localhost" ? "http://129.211.46.84:8085" : window.location.origin; // let domain = hostname === "localhost" ? "http://129.211.46.84:8085" : window.location.origin;
let url = domain + IPLATUI.CONTEXT_PATH + '/file/download/preview/' + docId // let url = domain + IPLATUI.CONTEXT_PATH + '/file/download/preview/' + docId
+ "?fullfilename="; // + "?fullfilename=";
// Base64转码 // Base64转码
let urlEncode; let urlEncode;
try { try {
docName = encodeURIComponent(docName); urlEncode = encodeURIComponent(btoa(url));
urlEncode = encodeURIComponent(btoa(url + docName));
} catch (e) { } catch (e) {
console.error("encodeURIComponent fail:", e) console.error("encodeURIComponent fail:", e)
let newDocName = docId + docName.substring(docName.lastIndexOf(".")) message("预览失败,文件地址存在非法字符!");
urlEncode = encodeURIComponent(btoa(url + newDocName)); return;
} }
if (urlEncode === "") { if (isBlank(urlEncode)) {
message("预览失败,文件地址为空!");
return; return;
} }
if (PROJECT_ENV === "run" || PROJECT_ENV === "RUN") { if (PROJECT_ENV === "run" || PROJECT_ENV === "RUN") {
...@@ -694,6 +693,19 @@ function loadChange(grid,e,field) { ...@@ -694,6 +693,19 @@ function loadChange(grid,e,field) {
} else { } else {
return "http://139.224.202.156:8012/preview/onlinePreview?url=" + urlEncode; return "http://139.224.202.156:8012/preview/onlinePreview?url=" + urlEncode;
} }
// 本地调试使用
// return "http://localhost:8012/preview/onlinePreview?url=" + urlEncode;
}
/**
* 判断是否为null
*
* @param value
* @returns {boolean}
*/
function isBlank(data) {
return data == null || data === undefined || data === 'null' || $.trim(data) === '' ||
data === 'undefined' || data === 'unknown';
} }
// export 到全局作用域 window对象 // export 到全局作用域 window对象
...@@ -702,6 +714,7 @@ function loadChange(grid,e,field) { ...@@ -702,6 +714,7 @@ function loadChange(grid,e,field) {
uploadFile: uploadFile, uploadFile: uploadFile,
downloadFile: downloadFile, downloadFile: downloadFile,
previewFile: previewFile, previewFile: previewFile,
isBlank: isBlank
} }
}); });
})(window.jQuery); })(window.jQuery);
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