增加KMS搜索后点击下载打开文档阅览界面
This commit is contained in:
parent
85a8e3cdd9
commit
bfd6504439
Binary file not shown.
@ -77,6 +77,15 @@ public class KnwlSearchController {
|
|||||||
return knwlSearchWeb.getUserList(term);
|
return knwlSearchWeb.getUserList(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 点击下载打开文档预览界面
|
||||||
|
@Mapping("com.actionsoft.apps.kms_knwl_filePreview")
|
||||||
|
public String filePreview(UserContext uc,String fileId) {
|
||||||
|
KnwlSearchWeb knwlSearchWeb = new KnwlSearchWeb(uc);
|
||||||
|
return knwlSearchWeb.filePreview(uc,fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全文检索查询
|
* 全文检索查询
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.actionsoft.apps.kms.web;
|
package com.actionsoft.apps.kms.web;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -12,6 +13,13 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||||
|
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||||
import com.actionsoft.apps.kms.KMSConstant;
|
import com.actionsoft.apps.kms.KMSConstant;
|
||||||
import com.actionsoft.apps.kms.KMSUtil;
|
import com.actionsoft.apps.kms.KMSUtil;
|
||||||
import com.actionsoft.apps.kms.ac.XpageMgrACCM;
|
import com.actionsoft.apps.kms.ac.XpageMgrACCM;
|
||||||
@ -32,6 +40,8 @@ import com.actionsoft.apps.kms.service.MetaSchemaService;
|
|||||||
import com.actionsoft.apps.kms.service.OptService;
|
import com.actionsoft.apps.kms.service.OptService;
|
||||||
import com.actionsoft.apps.kms.service.PublishService;
|
import com.actionsoft.apps.kms.service.PublishService;
|
||||||
import com.actionsoft.apps.kms.service.SearchService;
|
import com.actionsoft.apps.kms.service.SearchService;
|
||||||
|
import com.actionsoft.apps.resource.AppContext;
|
||||||
|
import com.actionsoft.bpms.bo.engine.BO;
|
||||||
import com.actionsoft.bpms.commons.database.RowMap;
|
import com.actionsoft.bpms.commons.database.RowMap;
|
||||||
import com.actionsoft.bpms.commons.htmlframework.AlertWindow;
|
import com.actionsoft.bpms.commons.htmlframework.AlertWindow;
|
||||||
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
|
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
|
||||||
@ -43,13 +53,12 @@ import com.actionsoft.bpms.org.cache.UserCache;
|
|||||||
import com.actionsoft.bpms.org.model.DepartmentModel;
|
import com.actionsoft.bpms.org.model.DepartmentModel;
|
||||||
import com.actionsoft.bpms.org.model.UserModel;
|
import com.actionsoft.bpms.org.model.UserModel;
|
||||||
import com.actionsoft.bpms.server.UserContext;
|
import com.actionsoft.bpms.server.UserContext;
|
||||||
import com.actionsoft.bpms.util.DBSql;
|
import com.actionsoft.bpms.server.fs.DCContext;
|
||||||
import com.actionsoft.bpms.util.UUIDGener;
|
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
|
||||||
import com.actionsoft.bpms.util.UtilDate;
|
import com.actionsoft.bpms.util.*;
|
||||||
import com.actionsoft.bpms.util.UtilSerialize;
|
|
||||||
import com.actionsoft.bpms.util.UtilString;
|
|
||||||
import com.actionsoft.exception.AWSException;
|
import com.actionsoft.exception.AWSException;
|
||||||
import com.actionsoft.sdk.local.SDK;
|
import com.actionsoft.sdk.local.SDK;
|
||||||
|
import com.actionsoft.sdk.local.api.AppAPI;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.awspaas.user.apps.yili.reportform.util.RepositoryAttribute;
|
import com.awspaas.user.apps.yili.reportform.util.RepositoryAttribute;
|
||||||
@ -594,6 +603,15 @@ public class KnwlSearchWeb extends ActionWeb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取人员信息
|
||||||
|
* @param curPage
|
||||||
|
* @param rowsPerPage
|
||||||
|
* @param searchText
|
||||||
|
* @param docTypes
|
||||||
|
* @param searchType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getUserList(int curPage, int rowsPerPage, String searchText, String docTypes, String searchType) {
|
public String getUserList(int curPage, int rowsPerPage, String searchText, String docTypes, String searchType) {
|
||||||
ResponseObject ro = ResponseObject.newOkResponse();
|
ResponseObject ro = ResponseObject.newOkResponse();
|
||||||
JSONArray data = new JSONArray();
|
JSONArray data = new JSONArray();
|
||||||
@ -660,6 +678,140 @@ public class KnwlSearchWeb extends ActionWeb {
|
|||||||
return userJsonArray.toString();
|
return userJsonArray.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据模型ID获取文档预览链接地址
|
||||||
|
* @param uc
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String filePreview(UserContext uc,String fileId) {
|
||||||
|
ResponseObject responseObject = ResponseObject.newOkResponse();
|
||||||
|
String sqls = "select taskId from (select * from BO_ACT_COE_PUBLISH_N where PUBLISHFILEID = '" + fileId
|
||||||
|
+ "' order by CREATEDATE desc) where rownum = 1";
|
||||||
|
String taskId = DBSql.getString(sqls);
|
||||||
|
|
||||||
|
String resultUrl=outputReportPreview(uc, taskId, fileId);
|
||||||
|
responseObject.setData(resultUrl);
|
||||||
|
return responseObject.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String outputReportPreview(UserContext _uc, String taskId, String palId) {
|
||||||
|
|
||||||
|
String returnUrl="";
|
||||||
|
|
||||||
|
String sql = "select * from App_Act_Coe_Pal_Repository where id = '" + palId + "' ";
|
||||||
|
RowMap map = DBSql.getMap(sql);
|
||||||
|
if (map != null) {
|
||||||
|
String ispulish = map.getString("ISPUBLISH");
|
||||||
|
String palname = map.getString("PLNAME");
|
||||||
|
String methodid = map.getString("PLMETHODID");
|
||||||
|
String plparid = map.getString("PLPARENTID");
|
||||||
|
if ("1".equals(ispulish)) {
|
||||||
|
// if ("control.policy".equals(methodid)) {
|
||||||
|
if ("control.policy".equals(methodid) || "data.form".equals(methodid) || "process.epc".equals(methodid)
|
||||||
|
|| "process.flowchart".equals(methodid) || "process.scheme".equals(methodid) || "engineering.standard".equals(methodid)) {
|
||||||
|
try {
|
||||||
|
OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
|
||||||
|
ResponseObject result = ResponseObject.newOkResponse();
|
||||||
|
if (model != null) {
|
||||||
|
UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId,
|
||||||
|
model.getProfileId());
|
||||||
|
if (file.exists()) {
|
||||||
|
File[] fileList = file.listFiles();
|
||||||
|
if (fileList.length > 0) {
|
||||||
|
File docFile = null;
|
||||||
|
for (File file2 : fileList) {
|
||||||
|
if (file2.isFile() && "doc".equals(
|
||||||
|
(file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) {
|
||||||
|
docFile = file2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (docFile == null) {
|
||||||
|
result = ResponseObject.newErrResponse("没有手册文件!");
|
||||||
|
}
|
||||||
|
if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) {
|
||||||
|
OutputAppProfile appFile = OutputAppManager.getProfile(model.getProfileId());
|
||||||
|
String sourceAppId = appFile.getAppContext().getId();
|
||||||
|
String filename = docFile.getName();
|
||||||
|
System.err.println("开始转换===>" + filename + "===>" + sourceAppId);
|
||||||
|
DCContext sourceDc = new DCContext(_uc,
|
||||||
|
DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId,
|
||||||
|
model.getWsId(), taskId, filename);
|
||||||
|
|
||||||
|
|
||||||
|
// 调用App
|
||||||
|
// aslp服务地址
|
||||||
|
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/fileConvert";
|
||||||
|
// 参数定义列表
|
||||||
|
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||||
|
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||||||
|
params.put("isPDFCovertPNG", "0");
|
||||||
|
// 原文件DC,必填
|
||||||
|
params.put("sourceDc", sourceDc);
|
||||||
|
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||||||
|
params.put("isCopy", true);
|
||||||
|
// sessionid,必填
|
||||||
|
params.put("sid", _uc.getSessionId());
|
||||||
|
AppAPI appAPI = SDK.getAppAPI();
|
||||||
|
// 调用转换服务.在预览之前提前进行转换,预览时直接打开转换后的文件
|
||||||
|
String sourceId = "com.actionsoft.apps.coe.pal.publisher";
|
||||||
|
AppContext appContext = appAPI.getAppContext(sourceId);
|
||||||
|
ResponseObject responseObject = appAPI.callASLP(appContext, aslp, params);
|
||||||
|
System.err.println("转换结果=======>" + responseObject);
|
||||||
|
if (responseObject != null) {
|
||||||
|
String results = responseObject.toString();
|
||||||
|
if (UtilString.isNotEmpty(results)) {
|
||||||
|
if (results.contains("200")) {
|
||||||
|
Map<String, Object> aslpParams = new HashMap<String, Object>();
|
||||||
|
aslpParams.put("sid", _uc.getSessionId());
|
||||||
|
aslpParams.put("fileNameOriginal", filename);
|
||||||
|
aslpParams.put("sourceDc", sourceDc);
|
||||||
|
aslpParams.put("isShowDefaultToolbar", true);
|
||||||
|
aslpParams.put("isShowBackbtn", false);
|
||||||
|
aslpParams.put("isEncrypt", true);
|
||||||
|
aslpParams.put("isCopy", true);
|
||||||
|
aslpParams.put("isPrint", true);
|
||||||
|
aslpParams.put("isDownload", true);
|
||||||
|
ResponseObject responseObjects = appAPI.callASLP(
|
||||||
|
appAPI.getAppContext(sourceAppId),
|
||||||
|
"aslp://com.actionsoft.apps.addons.onlinedoc/filePreview",
|
||||||
|
aslpParams);
|
||||||
|
|
||||||
|
if (responseObjects != null) {
|
||||||
|
if (responseObjects.isOk()) {
|
||||||
|
String url = responseObjects.get("url").toString();
|
||||||
|
returnUrl= url.substring(url.indexOf("&cmd"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String openEsSearchPage(String q) {
|
public String openEsSearchPage(String q) {
|
||||||
Map<String, Object> macroLibraries = new HashMap<String, Object>();
|
Map<String, Object> macroLibraries = new HashMap<String, Object>();
|
||||||
macroLibraries.put("sid", super.getContext().getSessionId());
|
macroLibraries.put("sid", super.getContext().getSessionId());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user