Commit be724be5 by liuyang

1、同步汉光文档库功能

parent 452cea71
......@@ -8,6 +8,8 @@
package com.baosight.hpjx.core.constant;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
/**
* 与操作系统 有关的一些常量.
*
......@@ -15,6 +17,11 @@ package com.baosight.hpjx.core.constant;
* @date:2019/12/12,16:32
*/
public class OSConstant {
/**
* docRootDir
*/
public static String DOC_ROOT_DIR = PlatApplicationContext.getProperty("docRootDir");
/**
* 文件夹分隔符,不同OS下分隔符不同
......@@ -45,5 +52,10 @@ public class OSConstant {
* 压缩包目录
*/
public final static String ZIP_DIR = USER_DIR + SEPARATOR + "file" + SEPARATOR + "zip";
/**
* 文件下载上下文
*/
public final static String FILE_DOWNLOAD = "file-download";
}
......@@ -118,7 +118,43 @@ public class Iplat4jTools {
return results;
}
}
/**
* 上传的文件
*
* @author:songx
* @date:2024/8/8,16:47
*/
public static class EuDm02 {
/**
* 查询
*
* @param docId
* @return
*/
public static Map getByDocId(String docId) {
AssertUtils.isEmpty(docId, "文件ID不能为空!");
Map<String, String> paramMap = new HashMap();
paramMap.put("docId", docId);
List<Map> results = DaoBase.getInstance().query("EUDM02.queryDocById", paramMap);
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);
}
}
/**
* 上传的文件
*
......
......@@ -13,6 +13,7 @@ import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.eu.dm.util.PlatFileUploader;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
......@@ -79,6 +80,31 @@ public class Iplat4jUtils {
}
/**
* 构建文件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
+ URLEncoder.encode(chgName, "UTF-8");
}
}
/**
* 压缩文件
*
* @param docIds
......@@ -86,8 +112,8 @@ public class Iplat4jUtils {
* @return
*/
public static String compressFile(List<String> docIds, String zipName) throws Exception {
String zipFolderPath = OSConstant.ZIP_DIR + OSConstant.SEPARATOR + DateUtils.shortDate()
+ OSConstant.SEPARATOR + zipName;
String mainFolderPath = OSConstant.ZIP_DIR + OSConstant.SEPARATOR + DateUtils.shortDate();
String zipFolderPath = mainFolderPath + OSConstant.SEPARATOR + zipName;
FileUtils.createDirs(zipFolderPath);
String zipFilePath = zipFolderPath + ".zip";
if (CommonConstant.FileLocation.S3.equalsIgnoreCase(S3Constant.FILE_LOCATION)) {
......@@ -112,8 +138,10 @@ public class Iplat4jUtils {
// 压缩完删除本地文件
FileUtils.deleteFiles(zipFolderPath);
// 替换成HTTP地址
return S3Constant.RESOURCE + zipFilePath.replace(OSConstant.USER_DIR, "")
.replace(OSConstant.SEPARATOR, "/");
return S3Constant.RESOURCE + "/" + OSConstant.FILE_DOWNLOAD
+ mainFolderPath.replace(OSConstant.DOC_ROOT_DIR, "")
.replace(OSConstant.SEPARATOR, "/") + "/"
+ URLEncoder.encode(zipName, "UTF-8").replace("\\+", "%20") + ".zip";
}
}
......@@ -3,6 +3,7 @@ package com.baosight.hpjx.hp.wd.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.ChangeTypeEnum;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.DeleteFlagEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
......@@ -14,10 +15,7 @@ import com.baosight.hpjx.hp.sc.domain.HPSC001;
import com.baosight.hpjx.hp.sc.enums.ProjectSourceEnum;
import com.baosight.hpjx.hp.wd.constant.HpWdConstant;
import com.baosight.hpjx.hp.wd.constant.HpWdSqlConstant;
import com.baosight.hpjx.hp.wd.domain.HPWD001;
import com.baosight.hpjx.hp.wd.domain.HPWD001A;
import com.baosight.hpjx.hp.wd.domain.HPWD003;
import com.baosight.hpjx.hp.wd.domain.HPWD099;
import com.baosight.hpjx.hp.wd.domain.*;
import com.baosight.hpjx.hp.wd.tools.HPWDTools;
import com.baosight.hpjx.hp.wd.utils.HpWdUtils;
import com.baosight.hpjx.hp.xs.domain.User;
......@@ -218,9 +216,6 @@ public class ServiceHPWD001 extends ServiceEPBase {
Map<?, ?> map = eiBlock.getRow(i);
HPWD099 hgwd099 = new HPWD099();
hgwd099.fromMap(map);
if (hgwd099.getOperStatus() == 0){
hgwd099.setDocVersion(hgwd099.getDocVersion() + 1);
}
hgwd099.setStatus(HpWdConstant.FileStatus.S_1);
hgwd099.setReleaseDate(DateUtils.shortDateTime());
hgwd099.setOperStatus(HpWdConstant.OperStatus.S_0);
......@@ -552,7 +547,8 @@ public class ServiceHPWD001 extends ServiceEPBase {
public EiInfo queryProjectManager(EiInfo inInfo) {
try {
Map queryRow =EiInfoUtils.getFirstRow(inInfo);
Integer isManager =HPWDTools.HpWd003.isProjectManager(queryRow.get(HPWD001.FIELD_FILE_ID).toString());
String fileId = MapUtils.getString(queryRow,HPWD001.FIELD_FILE_ID);
Integer isManager = HPWDTools.HpWd003.isProjectManager(fileId);
inInfo.set("isManager", isManager);
}catch (Exception e){
LogUtils.setMsg(inInfo, e, "查询失败");
......@@ -560,24 +556,6 @@ public class ServiceHPWD001 extends ServiceEPBase {
return inInfo;
}
/**
* 批量下载
*
* @param inInfo
* @return
*/
public EiInfo batchDownload(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileName = MapUtils.getString(queryMap, HPWD001.FIELD_FILE_NAME);
String zipName = fileName + "_" + DateUtils.shortDateTime();
List<String> docIds = ObjectUtils.listKey(inInfo, HPWD099.FIELD_DOC_ID);
inInfo.set("downloadUrl", Iplat4jUtils.compressFile(docIds, zipName));
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "批量下载失败");
}
return inInfo;
}
/**
* 清理下载的文件
......
......@@ -3,13 +3,12 @@ package com.baosight.hpjx.hp.wd.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DeleteFlagEnum;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.utils.Iplat4jUtils;
import com.baosight.hpjx.hp.wd.domain.HPWD001B;
import com.baosight.hpjx.hp.wd.domain.HPWD002;
import com.baosight.hpjx.hp.wd.domain.HPWD099;
import com.baosight.hpjx.hp.wd.tools.HPWDTools;
import com.baosight.hpjx.util.EiInfoUtils;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.MapUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
......@@ -88,15 +87,19 @@ public class ServiceHPWD001B extends ServiceEPBase {
*/
public EiInfo add(EiInfo inInfo) {
try {
List<HPWD001B> fWd001bs = MapUtils.toDaoEPBases(inInfo, HPWD001B.class);
for (HPWD001B fWd001b : fWd001bs) {
// AssertUtils.isEmpty(fWd001b.getFileId(), "文件ID不能为空");
// 预览记录+1
HPWDTools.HpWd099.previewIncr(fWd001b.getDocId());
// 新增
fWd001b.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HPWD001B.INSERT, fWd001b);
}
HPWD001B fWd001b = MapUtils.toDaoEPBase(inInfo, EiConstant.resultBlock, HPWD001B.class);
HPWD099 dbWd099 = HPWDTools.HpWd099.getByDocId("WD",fWd001b.getDocId());
AssertUtils.isNull(dbWd099, "文件不存在");
HPWDTools.HpWd099.previewIncr(fWd001b.getDocId());
//新增 预览记录+1
fWd001b.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HPWD001B.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.setMsg("操作成功");
} catch (Exception e) {
......
......@@ -3,8 +3,11 @@ package com.baosight.hpjx.hp.wd.service;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DeleteFlagEnum;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.utils.Iplat4jUtils;
import com.baosight.hpjx.hp.wd.domain.HPWD001;
import com.baosight.hpjx.hp.wd.domain.HPWD001C;
import com.baosight.hpjx.hp.wd.domain.HPWD002;
import com.baosight.hpjx.hp.wd.domain.HPWD099;
import com.baosight.hpjx.hp.wd.tools.HPWDTools;
import com.baosight.hpjx.util.*;
import com.baosight.iplat4j.core.ei.EiBlock;
......@@ -85,20 +88,57 @@ public class ServiceHPWD001C extends ServiceEPBase {
*/
public EiInfo add(EiInfo inInfo) {
try {
List<HPWD001C> fWd001cs = MapUtils.toDaoEPBases(inInfo, HPWD001C.class);
for (HPWD001C fWd001c : fWd001cs) {
AssertUtils.isEmpty(fWd001c.getFileId(), "文件ID不能为空");
// 下载记录+1
HPWDTools.HpWd099.downloadIncr(fWd001c.getDocId());
// 新增
fWd001c.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HPWD001C.INSERT, fWd001c);
}
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
HPWD001C fWd001c = MapUtils.toDaoEPBase(inInfo, EiConstant.resultBlock,HPWD001C.class);
this.saveData(inInfo, fWd001c.getFileId());
// 构建文件HTTP地址
//String url = Iplat4jUtils.buildDocUrl(fWd001c.getDocId());
//AssertUtils.isEmpty(url, "文件地址异常,请联系管理人员!");
//inInfo.set("url", url);
inInfo.setMsg("操作成功");
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "操作失败");
}
return inInfo;
}
/**
* 批量下载
*
* @param inInfo
* @return
*/
public EiInfo batchDownload(EiInfo inInfo) {
try {
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String fileId = MapUtils.getString(queryMap, HPWD001.FIELD_FILE_ID);
String fileName = MapUtils.getString(queryMap, HPWD001.FIELD_FILE_NAME);
String zipName = fileName + "_" + DateUtils.shortDateTime();
List<String> docIds = ObjectUtils.listKey(inInfo, HPWD099.FIELD_DOC_ID);
inInfo.set("downloadUrl", Iplat4jUtils.compressFile(docIds, zipName));
//写入下载记录
this.saveData(inInfo, fileId);
} catch (Exception e) {
LogUtils.setMsg(inInfo, e, "批量下载失败");
}
return inInfo;
}
/**
* 保存数据
*
* @param inInfo
*/
private void saveData(EiInfo inInfo, String fileId) {
AssertUtils.isEmpty(fileId, "文件ID不能为空");
List<HPWD001C> fWd001Cs = MapUtils.toDaoEPBases(inInfo, HPWD001C.class);
for (HPWD001C fWd001c : fWd001Cs) {
// 下载记录+1
HPWDTools.HpWd099.downloadIncr(fWd001c.getDocId());
// 新增
fWd001c.setFileId(fileId);
fWd001c.setDeleteFlag(DeleteFlagEnum.UN_REMOVE.getCode());
DaoUtils.insert(HPWD001C.INSERT, fWd001c);
}
}
}
......@@ -4,7 +4,9 @@ import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.ChangeTypeEnum;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.core.tools.Iplat4jTools;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.sc.domain.HPSC001;
......@@ -12,7 +14,9 @@ import com.baosight.hpjx.hp.sc.tools.HPSCTools;
import com.baosight.hpjx.hp.wd.constant.HpWdConstant;
import com.baosight.hpjx.hp.wd.domain.HPWD001;
import com.baosight.hpjx.hp.wd.domain.HPWD001A;
import com.baosight.hpjx.hp.wd.domain.HPWD003;
import com.baosight.hpjx.hp.wd.tools.HPWDTools;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.util.AssertUtils;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
......@@ -21,6 +25,7 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
......@@ -66,6 +71,9 @@ public class ServiceHPWD001E extends ServiceEPBase {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Map<String, Object>> edcm01List = Iplat4jTools.EdCm01.list("hpjx.hpwd.fileType");
List<HPWD001> hgwd001s = new ArrayList<>();
List<User> users = DaoBase.getInstance().query("HPWD003A.query",new HashMap<String, Object>(){{
put("userId", UserSessionUtils.getUserId());
}});
// 写入数据
for (Map resultRow : resultRows) {
HPWD001 hgwd001 = new HPWD001();
......@@ -74,7 +82,7 @@ public class ServiceHPWD001E extends ServiceEPBase {
// 设置项目信息
this.setProjectInfo(hgwd001);
if (hgwd001.getId() == null || hgwd001.getId() == 0) {
this.add(hgwd001);
this.add(hgwd001,users);
} else {
this.modify(hgwd001,edcm01List);
}
......@@ -92,7 +100,7 @@ public class ServiceHPWD001E extends ServiceEPBase {
/**
* 新增操作
*/
public void add(HPWD001 hgwd001) {
public void add(HPWD001 hgwd001,List<User> users) {
hgwd001.setFileId(SequenceGenerator.getNextSequence(HPConstant.SequenceId.WD_FILE_ID));
hgwd001.setDocVersion(hgwd001.getDocVersion() + 1);
DaoUtils.insert(HPWD001.INSERT, hgwd001);
......@@ -106,6 +114,16 @@ public class ServiceHPWD001E extends ServiceEPBase {
hgwd001a.setChangeEnd(hgwd001.getFileName());
hgwd001a.setMatId(hgwd001.getId());
HPWDTools.HpWd001.addHPWD001A(hgwd001a);
if (CollectionUtils.isNotEmpty(users)){
User user = users.get(0);
HPWD003 fWd003 = new HPWD003();
fWd003.setUserId(user.getUserId());
fWd003.setUserName(user.getUserId());
fWd003.setOrgId(user.getDepCode());
fWd003.setOrgCname(user.getDepName());
fWd003.setFileId(hgwd001.getFileId());
DaoUtils.insert(HPWD003.INSERT, fWd003);
}
}
/**
......
......@@ -4,13 +4,17 @@ import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.ChangeTypeEnum;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.core.constant.CommonConstant;
import com.baosight.hpjx.core.dao.DaoBase;
import com.baosight.hpjx.core.dao.DaoUtils;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.core.tools.Iplat4jTools;
import com.baosight.hpjx.hp.constant.HPConstant;
import com.baosight.hpjx.hp.wd.constant.HpWdConstant;
import com.baosight.hpjx.hp.wd.domain.HPWD001;
import com.baosight.hpjx.hp.wd.domain.HPWD001A;
import com.baosight.hpjx.hp.wd.domain.HPWD003;
import com.baosight.hpjx.hp.wd.tools.HPWDTools;
import com.baosight.hpjx.hp.xs.domain.User;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.contants.ACConstants;
......@@ -18,6 +22,7 @@ import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.ed.util.SequenceGenerator;
import org.apache.commons.collections.CollectionUtils;
import java.util.Arrays;
import java.util.HashMap;
......@@ -59,13 +64,16 @@ public class ServiceHPWD001F extends ServiceEPBase {
try {
List<Map> resultRows = inInfo.getBlock(EiConstant.resultBlock).getRows();
List<Map<String, Object>> edcm01List = Iplat4jTools.EdCm01.list("hpjx.hpwd.fileType");
List<User> users = DaoBase.getInstance().query(HPWD003.QUERY,new HashMap<String, Object>(){{
put("userId", UserSessionUtils.getUserId());
}});
// 写入数据
for (Map resultRow : resultRows) {
HPWD001 hpwd001 = new HPWD001();
hpwd001.fromMap(resultRow);
hpwd001.setStatus(HpWdConstant.FileStatus.S_0);
if (hpwd001.getId() == null || hpwd001.getId() == 0) {
this.add(hpwd001);
this.add(hpwd001,users);
} else {
this.modify(hpwd001,edcm01List);
}
......@@ -81,7 +89,7 @@ public class ServiceHPWD001F extends ServiceEPBase {
/**
* 新增操作
*/
public void add(HPWD001 hpwd001) {
public void add(HPWD001 hpwd001,List<User> users) {
hpwd001.setFileId(SequenceGenerator.getNextSequence(HPConstant.SequenceId.WD_FILE_ID));
hpwd001.setDocVersion(hpwd001.getDocVersion() + 1);
DaoUtils.insert(HPWD001.INSERT, hpwd001);
......@@ -95,6 +103,16 @@ public class ServiceHPWD001F extends ServiceEPBase {
hpwd001a.setChangeEnd(hpwd001.getFileName());
hpwd001a.setMatId(hpwd001.getId());
HPWDTools.HpWd001.addHPWD001A(hpwd001a);
if (CollectionUtils.isNotEmpty(users)){
User user = users.get(0);
HPWD003 fWd003 = new HPWD003();
fWd003.setUserId(user.getUserId());
fWd003.setUserName(user.getUserId());
fWd003.setOrgId(user.getDepCode());
fWd003.setOrgCname(user.getDepName());
fWd003.setFileId(hpwd001.getFileId());
DaoUtils.insert(HPWD003.INSERT, fWd003);
}
}
/**
......
......@@ -167,7 +167,7 @@
DOC_NAME = #docName#, <!-- 文件名称 -->
DOC_TYPE = #docType#, <!-- 文件类型 -->
STATUS = #status#,
DOC_VERSION = DOC_VERSION + 1, <!--版本号-->
<!-- DOC_VERSION = DOC_VERSION + 1, 版本号-->
RELEASE_DATE = #releaseDate#, <!--发布时间-->
OPER_STATUS = #operStatus#,
UPDATED_BY = #updatedBy#, <!-- 修改人 -->
......@@ -190,7 +190,7 @@
UPDATE ${hpjxSchema}.T_HPWD099
SET
RELEASE_DATE = #releaseDate#, <!--发布时间-->
DOC_VERSION = #docVersion#, <!--版本号-->
DOC_VERSION = DOC_VERSION + 1, <!--版本号-->
STATUS = #status#, <!-- 状态 -->
OPER_STATUS = #operStatus#,
<include refid="SqlBase.updateRevise"/>
......
......@@ -335,12 +335,13 @@ public class HPWDTools {
public static class HpWd099 {
public static List<HPWD099> getByDocId(String bizType, String docId) {
public static HPWD099 getByDocId(String bizType, String docId) {
AssertUtils.isEmpty(docId, "文件ID不能为空");
Map<String, Object> paramMap = new HashMap();
paramMap.put(HPWD099.FIELD_BIZ_TYPE, bizType);
paramMap.put(HPWD099.FIELD_DOC_ID, docId);
return DaoBase.getInstance().query(HPWD099.QUERY, paramMap);
List<HPWD099> results = DaoBase.getInstance().query(HPWD099.QUERY, paramMap);
return CollectionUtils.isEmpty(results) ? null : results.get(0);
}
/**
......
......@@ -94,7 +94,11 @@ $(function () {
IPLATUI.EFTree = {
"categoryTree": {
ROOT: {label: 'root', text: '目录结构'},
query: function (inInfo, model) {
if (model == null || model.id === "root") {
return inInfo;
}
inInfo.set("inqu_status-0-projCode", $("#inqu_status-0-projCode").val());
return inInfo;
},
......@@ -489,10 +493,15 @@ $(function () {
title: "操作",
readonly: true,
template: function (item) {
let template = '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'href="' + downloadHref(item.docId) + '">下载</a>';
let template = "";
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="showPreview(\'' + item.docId + '\',\'' + item.bizId + '\')" >预览</a>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="changeFile(\'' + item.docId + '\',\'' + item.bizId + '\')" target="_blank">变更</a><br/>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="showQueryRecord(\'' + item.docId + '\',\'' + item.bizId + '\')" >预览记录</a>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="changeFile(\'' + item.docId + '\',\''+item.bizId+'\')" target="_blank">变更</a>';
+ 'onclick="showDownloadRecord(\'' + item.docId + '\',\'' + item.bizId + '\')" >下载记录</a>';
return template;
}
}, {
......@@ -556,7 +565,7 @@ $(function () {
//确认发布
$("#confirmRelease").on("click", updateRelease);
// 批量下载
$("#BATCH_DOWNLOAD").on("click", batchDownload);
$("#BATCH_DOWNLOAD").on("click", download);
});
let query = function () {
......@@ -861,31 +870,79 @@ let showAuthButton = function () {
let parentId = IPLATUI.EFTree.categoryTree.selectTreeNode.fileId;
let leafLevel = IPLATUI.EFTree.categoryTree.selectTreeNode.leafLevel;
let isAuth = IPLATUI.EFTree.categoryTree.selectTreeNode.isAuth;
let changeRecord = $("#CHANGE_RECORD").hide();
if (!isBlank(leafLevel) && leafLevel == 0){
changeRecord.show();
// 隐藏变更记录按钮
if (!isBlank(leafLevel) && leafLevel === 0) {
CommonUtils.showButton("CHANGE_RECORD");
CommonUtils.showButton("COPY_PROT_FILE");
} else {
CommonUtils.hideButton("CHANGE_RECORD");
}
// C:目录
if (isBlank(leafType) || leafType != "C") {
$("#RELEASE").hide();
$("#UPLOAD_FILE").hide();
$("#COPY_FILE").hide();
$("#COPY_PROT_FILE").hide();
$("#PREVIEW").hide();
$("#BATCH_DOWNLOAD").hide();
if (isBlank(leafType) || leafType !== "C") {
CommonUtils.hideButton("RELEASE");
CommonUtils.hideButton("UPLOAD_FILE");
CommonUtils.hideButton("COPY_FILE");
CommonUtils.hideButton("PREVIEW");
CommonUtils.hideButton("BATCH_DOWNLOAD");
return
}
// 0:不授权
if (isAuth == 0) {
$("#RELEASE").show();
$("#UPLOAD_FILE").show();
$("#COPY_FILE").show();
$("#COPY_PROT_FILE").show();
$("#PREVIEW").show();
$("#BATCH_DOWNLOAD").show();
return;
if (isAuth === "0") {
notAuthShowButton();
} else {
isProjectManager(parentId);
}
isProjectManager(parentId);
}
/**
* 不授权显示按钮
*/
function notAuthShowButton() {
CommonUtils.showButton("RELEASE");
CommonUtils.showButton("UPLOAD_FILE");
CommonUtils.showButton("COPY_FILE");
CommonUtils.showButton("COPY_PROT_FILE");
CommonUtils.showButton("PREVIEW");
CommonUtils.showButton("BATCH_DOWNLOAD");
}
/**
* 项目管理人员
*
* @param parentId
*/
let isProjectManager = function (parentId) {
CommonUtils.hideButton("RELEASE");
CommonUtils.hideButton("COPY_PROT_FILE");
CommonUtils.hideButton("COPY_FILE");
CommonUtils.hideButton("UPLOAD_FILE");
CommonUtils.hideButton("PREVIEW");
CommonUtils.hideButton("BATCH_DOWNLOAD");
let inEiInfo = new EiInfo();
inEiInfo.set("inqu_status-0-fileId", parentId);
EiCommunicator.send("HPWD001", "queryProjectManager", inEiInfo, {
onSuccess(ei) {
if (ei.status < 0){
return;
}
let isManager = ei.extAttr.isManager;
let downloadFlag = ei.extAttr.downloadFlag;
// 1-管理员,2-项目经理,3-设计人
if (isManager === 1 || isManager === 2 || isManager === 3) {
if (isManager !== 1 && downloadFlag !== 1) {
$("#BATCH_DOWNLOAD").attr("disabled", true);
}
if (isManager === 1 || isManager === 2) {
CommonUtils.showButton("RELEASE");
}
CommonUtils.showButton("COPY_PROT_FILE");
CommonUtils.showButton("COPY_FILE");
CommonUtils.showButton("UPLOAD_FILE");
CommonUtils.showButton("PREVIEW");
CommonUtils.showButton("BATCH_DOWNLOAD");
}
}
}, {async: false})
}
/**
......@@ -1026,51 +1083,44 @@ let preview = function () {
window.open(url, '_blank');
}
let isProjectManager = function (parentId) {
let inEiInfo = new EiInfo();
inEiInfo.set("inqu_status-0-fileId", parentId);
$("#COPY_PROT_FILE").show();
$("#BATCH_DOWNLOAD").show();
$("#RELEASE").show();
$("#UPLOAD_FILE").show();
$("#COPY_FILE").show();
$("#PREVIEW").show();
EiCommunicator.send("HPWD001", "queryProjectManager", inEiInfo, {
onSuccess(ei) {
if (ei.status != -1){
switch (ei.extAttr.isManager) {
case 1:
case 2:
break
case 3:
$("#RELEASE").hide();
break
default:
$("#RELEASE").hide();
$("#UPLOAD_FILE").hide();
$("#COPY_FILE").hide();
$("#PREVIEW").hide();
$("#COPY_PROT_FILE").hide();
}
}
}
}, {async: false})
/**
* 预览
*
* @param docId
* @param fileId
*/
let showPreview = function (docId, fileId) {
//let fileId = IPLATUI.EFTree.categoryTree.selectTreeNode.fileId;
addRecordWindow(fileId, docId);
}
/**
* 批量下载
* 显示查询记录
*
* @param docId
* @param fileId
*/
let batchDownload = function () {
var rows = resultGrid.getCheckedRows();
if (rows.length == 0) {
message("请先勾选要下载的数据!");
return;
}
JSUtils.submitGridsData("result", "HPWD001", "batchDownload", false,
function (res) {
if (res.status > -1) {
window.open(res.extAttr.downloadUrl, '_blank');
}
}
);
let showQueryRecord = function (docId, fileId) {
//let fileId = IPLATUI.EFTree.categoryTree.selectTreeNode.fileId;
JSColorbox.open({
href: "HPWD001B?inqu_status-0-fileId=" + fileId + "&inqu_status-0-docId=" + docId,
title: "<div style='text-align: center;'>预览记录</div>",
width: "80%",
height: "80%",
});
}
/**
* 显示下载记录
*
* @param docId
*/
let showDownloadRecord = function (docId,fileId) {
//let fileId = IPLATUI.EFTree.categoryTree.selectTreeNode.fileId;
JSColorbox.open({
href: "HPWD001C?inqu_status-0-fileId=" + fileId + "&inqu_status-0-docId=" + docId,
title: "<div style='text-align: center;'>下载记录</div>",
width: "80%",
height: "80%",
});
}
......@@ -88,7 +88,7 @@
serviceName="HPWD099" queryMethod="query" deleteMethod="delete">
<EF:EFColumn ename="id" cname="ID" hidden="true"/>
<EF:EFColumn ename="docId" cname="文件ID" enable="false" width="180" hidden="true"/>
<EF:EFColumn ename="operator" cname="操作" enable="false" width="100" align="center" sort="false"/>
<EF:EFColumn ename="operator" cname="操作" enable="false" width="150" align="center" sort="false"/>
<EF:EFColumn ename="docName" cname="附件名称" enable="false" width="180"/>
<EF:EFColumn ename="docType" cname="附件类型" enable="false" width="110" align="center"/>
<EF:EFColumn ename="docVersion" cname="版本号" enable="false" width="90" align="center" sort="true"/>
......@@ -219,3 +219,5 @@
</div>
</EF:EFWindow>
<jsp:include page="HPWD002A1.jsp" />
/**
* 下载
*/
let download = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length == 0) {
message("请先勾选要下载的数据!");
return;
}
if (rows.length == 1) {
singleDownload(rows[0]);
} else {
batchDownload();
}
}
/**
* 单个下载
*
* @param row
*/
let singleDownload = function (row) {
//let fileId = $("#inqu_status-0-fileId").val();
let inInfo = new EiInfo();
inInfo.set("result-0-fileId", row['fileId']);
inInfo.set("result-0-docId", row['docId']);
EiCommunicator.send("HPWD001C", "add", inInfo, {
onSuccess(res) {
if (res.status > -1) {
//let url = res.extAttr.url + "?filename=" + row['docName'];
let url = downloadHref(row['docId'],false);
window.open( url, '_blank');
} else {
message(res.msg);
}
}
}, {async: false})
}
/**
* 批量下载
*
* @param fileId
* @param docId
*/
let batchDownload = function () {
JSUtils.submitGridsData("result", "HPWD001C", "batchDownload", false,
function (res) {
if (res.status > -1) {
window.open(res.extAttr.downloadUrl, '_blank');
}
}
);
}
\ No newline at end of file
......@@ -107,11 +107,22 @@ let save = function (btnNode) {
let flag = true;
$.each(rows, function(index, item) {
let projCode= item.get("projCode");
let fileName= item.get("fileName");
if(isBlank(projCode)){
message("选中的第"+(index+1)+"行\"所属项目\",不能为空!");
flag = false;
return false;
}
if(isBlank(fileName)){
message("选中的第"+(index+1)+"行\"目录名称\",不能为空!");
flag = false;
return false;
}
if(isChinese(fileName)){
message("选中的第"+(index+1)+"行\"目录名称\",不能包含特殊字符!");
flag = false;
return false;
}
});
if(flag) {
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"保存\"操作? ", {
......
......@@ -91,22 +91,22 @@ $(function () {
IPLATUI.EFTree = {
"docTree": {
ROOT: {label: 'root', text: '目录结构'},
query: function (inInfo, model) {
if (model == null || model.id === "root") {
return inInfo;
}
// 选中树节点
selectTreeId(model.id);
// 设置选中节点
treeSelectClick(model);
inInfo.set("inqu_status-0-projCode", $("#inqu_status-0-projCode").val());
return inInfo;
},
select: function (e) {
var _data = this.dataItem(e.node);
var labelValue = _data.label;
var typeValue = _data.type;
const eNameValue = _data.ename;
setTreeNodeValue(_data);
$("[name = 'inqu_status-0-parentId']").val(labelValue);
$("[name = 'inqu_status-0-fileId']").val(_data.id);
$("[name = 'inqu_status-0-leafLevel']").val(_data.leafLevel==null?0:_data.leafLevel);
$("[name = 'inqu_status-0-projCode']").val(_data.projCode);
$("[name = 'inqu_status-0-companyCode']").val(_data.companyCode);
$("[name = 'inqu_status-0-type']").val(typeValue);
$("[name = 'inqu_status-0-fileName']").val(_data.text);
resultGrid.dataSource.page(1);
// 显示授权按钮
showAuthButton();
let nodeData = this.dataItem(e.node);
// 设置选中节点
treeSelectClick(nodeData);
},
/*ROOT:{label: 'root',text: '组织机构'},*/
template: function (node) {
......@@ -169,12 +169,10 @@ $(function () {
field: "operator",
title: "操作",
template: function (model) {
let param = "'" + model.fileId + "', '" + model.docId + "'";
let param = "'" + model.docId + "'";
let template = '';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="showQueryRecord(' + param + ')" >预览记录</a>';
template += '<a style="cursor: pointer;display: inline-flex;justify-content: center;margin:auto 5px" '
+ 'onclick="showDownloadRecord(' + param + ')" >下载记录</a>';
+ 'onclick="showPreview(' + param + ')" >预览</a>';
return template;
}
}, {
......@@ -260,9 +258,19 @@ let preview = function () {
}
/**
* 预览
*
* @param docId
*/
let showPreview = function (docId) {
let treeId = IPLATUI.EFTree.docTree.selectTreeNode.treeId;
addRecordWindow(treeId, docId);
}
/**
* 下载
*/
let download = function () {
/*let download = function () {
let rows = resultGrid.getCheckedRows();
if (rows.length < 1) {
message("请选择数据");
......@@ -283,33 +291,104 @@ let download = function () {
);
}
});
}
}*/
/**
* 设置树节点的值
*
* @param nodeData
*/
let setTreeNodeValue = function (nodeData) {
/*let setTreeNodeValue = function (nodeData) {
IPLATUI.EFTree.docTree.selectTreeNode.fileId = nodeData.label;
IPLATUI.EFTree.docTree.selectTreeNode.parentId = nodeData.parentId;
IPLATUI.EFTree.docTree.selectTreeNode.fileName = nodeData.text;
IPLATUI.EFTree.docTree.selectTreeNode.companyCode = nodeData.companyCode;
IPLATUI.EFTree.docTree.selectTreeNode.projCode = nodeData.projCode;
IPLATUI.EFTree.docTree.selectTreeNode.leafLevel = nodeData.leafLevel;
}*/
/**
* 设置树节点的值
*
* @param nodeData
*/
let setTreeNodeValue = function (nodeData) {
IPLATUI.EFTree.docTree.selectTreeNode.treeId = nodeData.id;
IPLATUI.EFTree.docTree.selectTreeNode.projCode = nodeData.projCode;
IPLATUI.EFTree.docTree.selectTreeNode.leafType = nodeData.leafType;
IPLATUI.EFTree.docTree.selectTreeNode.downloadFlag = nodeData.downloadFlag == null ? 0
: nodeData.downloadFlag;
$("[name = 'inqu_status-0-fileId']").val(nodeData.id);
$("[name = 'inqu_status-0-projCode']").val(nodeData.projCode);
}
/**
* 显示授权按钮
*/
let showAuthButton = function () {
let leafType = IPLATUI.EFTree.docTree.selectTreeNode.leafLevel;
// C:目录
if (leafType && leafType >0) {
$("#PREVIEW").attr("disabled", false);
let leafType = IPLATUI.EFTree.docTree.selectTreeNode.leafType;
if (leafType === 'C') {
CommonUtils.showButton("PREVIEW");
CommonUtils.showButton("DOWNLOAD");
} else {
CommonUtils.hideButton("PREVIEW");
CommonUtils.hideButton("DOWNLOAD");
}
// 是否可以下载
let downloadFlag = IPLATUI.EFTree.docTree.selectTreeNode.downloadFlag;
/*if (downloadFlag === "1") {
$("#DOWNLOAD").attr("disabled", false);
} else {
$("#PREVIEW").attr("disabled", true);
$("#DOWNLOAD").attr("disabled", true);
}*/
}
/**
* 选中树节点
*
* @param treeId
*/
let selectTreeId = function (treeId) {
// 刷新树节点
const tree = $("#docTree").data("kendoTreeView");
// 选中的节点
selectTreeNode(tree, treeId);
}
/**
* 选中树节点
*
* @param tree
* @param treeId
*/
let selectTreeNode = (tree, treeId) => {
if (!tree || treeId == null) {
return
}
setTimeout(() => {
let barDataItem = tree.dataSource.get(treeId);
if (barDataItem) {
let barElement = tree.findByUid(barDataItem.uid);
// 刷新完成后选中对应的树节点
tree.select(barElement);
} else {
selectTreeNode(tree, treeId)
}
}, 300)
}
/**
* 树点击事件
*
* @param nodeData
*/
let treeSelectClick = function (nodeData) {
// 设置选择的树节点信息
setTreeNodeValue(nodeData);
// 显示授权按钮
showAuthButton();
// 刷新列表
query();
}
......@@ -18,8 +18,7 @@
<EF:EFRegion title="文档目录树" id="tree" fitHeight="true">
<div id="menu" style="margin-top: 12px; margin-bottom: 8px">
<EF:EFTree bindId="docTree" ename="tree_name" textField="text" valueField="label"
hasChildren="leaf" pid="parentId" serviceName="HPWD001D" methodName="queryTree"
expandLevel="1">
hasChildren="leaf" pid="parentId" serviceName="HPWD001D" methodName="queryTree">
</EF:EFTree>
</div>
</EF:EFRegion>
......@@ -71,3 +70,5 @@
</EF:EFPage>
<jsp:include page="HPWD002A1.jsp" />
.left-flex {
/*display: flex;*/
/*align-items: flex-start;*/
height: 100%;
width: 100%;
overflow: auto;
}
.center-flex {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
overflow: scroll;
}
iframe {
min-width: 100%;
min-height: 100%;
border: 0px;
}
img {
max-width: 100%;
max-height: 100%;
cursor: zoom-in;
transition: transform 0.1s;
}
img:hover {
cursor: zoom-out;
}
.textSpan {
font-size: 16px;
}
.textSpan table {
border: 1px solid black;
}
.textSpan table td {
border: 1px solid black;
}
.imageOuterDiv {
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 9999999;
width: 100%;
height: 100%;
display: none;
}
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: 1
Date: 2024/11/26
Time: 16:28
To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<script src="${ctx}/common/docxjs/jszip.min.js"></script>
<script src="${ctx}/common/docxjs/docx-preview.js"></script>
<script src="${ctx}/common/js/xlsx.full.min.js"></script>
<script src="${ctx}/HP/WD/HPWD001C1.js"></script>
<script src="${ctx}/HP/WD/HPWD002A1.js"></script>
<link rel="stylesheet" href="${ctx}/HP/WD/HPWD002A1.css">
<%-- 预览文件 --%>
<EF:EFWindow id="previewFile" title="附件预览" height="100%" width="100%">
<div id="descDiv" class="center-flex">
<span id="descSpan" style="font-weight: bold;font-size: 18px">附件预览区域...</span>
</div>
<%-- 文本预览 --%>
<div id="textContainer" class="left-flex" style="display: none;">
<pre id="textSpan" class="textSpan"></pre>
</div>
<%-- docx文件预览--%>
<div id="docxContainer" style="display: none;"></div>
<%-- IMAGE文件预览--%>
<div id="imageContainer" class="left-flex" style="display: none;">
<img id="image" src="" style="border: 1px solid gray;width: 100%;height: 100%;"/>
</div>
<%-- other --%>
<iframe id="previewFrame" src="" style="display: none;"></iframe>
</EF:EFWindow>
<%-- 图片放大区域 --%>
<div id="imageOuterDiv" class="imageOuterDiv">
<img id="bigImage" src=""/>
</div>
\ No newline at end of file
......@@ -54,6 +54,12 @@ function isPositiveNumber(input) {
return !isBlank(input) && isNumber(input) && (input > 0);
}
/*校验是否中文名称组成 */
function isChinese(str) {
let reg=/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/; /*定义验证表达式*/
return !reg.test(str); /*进行验证*/
}
/**
* 消息提示
*
......@@ -558,9 +564,9 @@ function loadChange(grid,e,field) {
/**
* 上传文件
*
* @param bizType
* @param bizId
* @param
* @param bizType 业务类型
* @param bizId 业务ID
* @param callback 函数是含税就回调
*/
let uploadFile = function (bizType, bizId, callback) {
let params = {
......@@ -593,6 +599,35 @@ function loadChange(grid,e,field) {
}
/**
* 隐藏按钮
*
* @param name
*/
function hideButton(name) {
let button = $("#" + name);
button.hide();
// 隐藏父级标签,防止按钮重叠
button.parent().css("display", "none");
}
/**
* 显示按钮
*
* @param name
*/
function showButton(name) {
let button = $("#" + name);
let parent = button.parent();
if (!CommonUtils.isBlank(button.attr("uuid"))) {
button.show();
parent.css("display", "");
} else {
// 隐藏父级标签,防止按钮重叠
parent.css("display", "none");
}
}
/**
* 导入
*
* @param id 路由ID
......@@ -609,13 +644,61 @@ function loadChange(grid,e,field) {
});
}
/**
* 文件下载路径
*
* @param docId
* @param isPreview 是否预览,true:预览
* @returns {string}
*/
let downloadFile = function (docId, isPreview) {
if (isPreview) {
return IPLATUI.CONTEXT_PATH + '/file/download/preview/' + docId;
} else {
// S3地址必须支持公网
return IPLATUI.CONTEXT_PATH + '/file/download/' + docId;
}
}
/**
* 预览
*
* @param url 文件URL
*/
let previewFile = function (url) {
// Base64转码
let urlEncode;
try {
urlEncode = encodeURIComponent(btoa(url));
} catch (e) {
console.error("encodeURIComponent fail:", e)
message("预览失败,文件地址存在非法字符!");
return;
}
if (isBlank(urlEncode)) {
message("预览失败,文件地址为空!");
return;
}
if (PROJECT_ENV === "run" || PROJECT_ENV === "RUN") {
return "https://www.eis-paas.com/preview/onlinePreview?url=" + urlEncode
} else {
return "http://139.224.202.156:8012/preview/onlinePreview?url=" + urlEncode;
}
// 本地调试使用
// return "http://localhost:8012/preview/onlinePreview?url=" + urlEncode;
}
// export 到全局作用域 window对象
$.extend(window, {
CommonUtils: {
showFile: showFile,
uploadFile: uploadFile,
isBlank: isBlank,
importData: importData
importData: importData,
downloadFile: downloadFile,
previewFile: previewFile,
hideButton: hideButton,
showButton: showButton,
}
});
})(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