From e97a0bab32b18e32ad3b74d648bad11345466c30 Mon Sep 17 00:00:00 2001 From: yujh Date: Mon, 2 Sep 2024 10:12:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../步骤横表-流程手册4.xml | 1 + .../js/coe.pal.process.publish.multiple_L4.js | 5 ++ .../yiliwps/controller/YiliWpsController.java | 23 +++++ .../user/apps/yiliwps/restful/YiliWpsApi.java | 13 ++- .../awspaas/user/apps/yiliwps/web/WpsWeb.java | 87 ++++++++----------- 5 files changed, 72 insertions(+), 57 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册4.xml b/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册4.xml index 9f50d7ba..842a6bfb 100644 --- a/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册4.xml +++ b/com.actionsoft.apps.coe.pal.output.pr/步骤横表-流程手册4.xml @@ -7078,6 +7078,7 @@ y7fdOgAAAABJRU5ErkJggk== ${table4.post} <#else> ${table4.role} + diff --git a/com.actionsoft.apps.coe.pal.publisher/web/com.actionsoft.apps.coe.pal.publisher/js/coe.pal.process.publish.multiple_L4.js b/com.actionsoft.apps.coe.pal.publisher/web/com.actionsoft.apps.coe.pal.publisher/js/coe.pal.process.publish.multiple_L4.js index af21ec9b..ec7c36ab 100644 --- a/com.actionsoft.apps.coe.pal.publisher/web/com.actionsoft.apps.coe.pal.publisher/js/coe.pal.process.publish.multiple_L4.js +++ b/com.actionsoft.apps.coe.pal.publisher/web/com.actionsoft.apps.coe.pal.publisher/js/coe.pal.process.publish.multiple_L4.js @@ -323,6 +323,8 @@ function initHtml() { ' background-color: #f9f9f9; \n' + ' border: 1px solid #ddd; \n' + ' border-radius: 4px; \n' + + ' max-height: 400px; \n' + + ' overflow-y: auto; \n' + ' box-shadow: 0 2px 4px rgba(0,0,0,0.1); \n' + ' color: #333; \n' + ' font-size: 14px; \n' + @@ -2513,6 +2515,9 @@ function searchProcess(type) { //先向后台请求完整tree数据 if (type == 'new') { var data = getAllTreeData(); + data = data.filter(function(obj) { + return obj.category === 'process'; + }); for (var i = 0; i < data.length; i++) { var text = data[i].name; if (text.indexOf(name) > -1) { diff --git a/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/controller/YiliWpsController.java b/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/controller/YiliWpsController.java index 0743d44e..1c8dbe84 100644 --- a/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/controller/YiliWpsController.java +++ b/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/controller/YiliWpsController.java @@ -13,12 +13,35 @@ import java.util.List; @Controller public class YiliWpsController { public final static LogAPI logAPI = SDK.getLogAPI(); + + /** + * 打开可编辑的页面 + * @param me + * @param palId + * @param fileName + * @return + * @throws Exception + */ @Mapping("com.awspaas.user.apps.yiliwps.previewUrl") public String getWPSOnlineFilePreviewUrl(UserContext me,String palId,String fileName) throws Exception{ WpsWeb web =new WpsWeb(me); return web.getWPSOnlineFilePreviewUrl(palId,fileName); } + /** + * 打开制度的页面 + * @param me + * @param palId + * @param fileName + * @return + * @throws Exception + */ + @Mapping("com.awspaas.user.apps.yiliwps.readOnlyUrl") + public String getWPSOnlineFileReadOnlyUrl(UserContext me,String palId,String fileName) throws Exception{ + WpsWeb web =new WpsWeb(me); + return web.getWPSOnlineFileReadOnlyUrl(palId,fileName); + } + /** * 获取新的pal模型文件 * @param me diff --git a/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/restful/YiliWpsApi.java b/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/restful/YiliWpsApi.java index 41960343..b6a21f12 100644 --- a/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/restful/YiliWpsApi.java +++ b/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/restful/YiliWpsApi.java @@ -87,15 +87,13 @@ public class YiliWpsApi { @Path("/v1/3rd/file/history") @POST public String histoty(@QueryParam("_w_boId") String boId, - @QueryParam("_w_boItemName") String boItemName, - @QueryParam("_w_sid") String sid){ + @QueryParam("_w_third_palId") String palId, + @QueryParam("_w_third_queryFileId") String queryFileId, + @QueryParam("_w_third_sid") String sid, + @QueryParam("_w_third_fname") String fileName){ System.out.println(">>>>>>文件历史调用成功:"+System.currentTimeMillis()); - JSONObject params = new JSONObject(); - params.put("boItemName", boItemName); - params.put("boId", boId); - params.put("sid", sid); WpsWeb web = new WpsWeb(); - return web.getHistoryFileInfo(params); + return web.getHistoryFileInfo(queryFileId,fileName); } @Path("/v1/3rd/file/version/{version}") @@ -124,7 +122,6 @@ public class YiliWpsApi { @Path("/test/{name}") @POST public String sayHelloparam(@PathParam("name") String name) { - return "test,hello,world!-param " + name; } } diff --git a/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/web/WpsWeb.java b/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/web/WpsWeb.java index 3936e0d1..395fd557 100644 --- a/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/web/WpsWeb.java +++ b/com.awspaas.user.apps.yiliwps/src/com/awspaas/user/apps/yiliwps/web/WpsWeb.java @@ -19,6 +19,7 @@ import com.actionsoft.bpms.server.conf.portal.AWSPortalConf; import com.actionsoft.bpms.server.fs.DCContext; import com.actionsoft.bpms.server.fs.dc.DCProfileManager; import com.actionsoft.bpms.util.DBSql; +import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.api.LogAPI; import com.alibaba.fastjson.JSONArray; @@ -45,7 +46,7 @@ public class WpsWeb extends ActionWeb { } /** - * + * 打开在线编辑页 * @param * @return */ @@ -61,6 +62,23 @@ public class WpsWeb extends ActionWeb { return HttpPostUtil.sendGetRequest(YiliWpsConst.HOST+"/open"+url,headers); } + /** + * 打开只读页面 + * @param + * @return + */ + public String getWPSOnlineFileReadOnlyUrl(String palId,String fileName) throws Exception{ + //先判断该fileId有无附件 + String querySql = " SELECT ID FROM " + YiliWpsConst.APP_ACT_COE_PAL_UPFILE+" WHERE PALREPOSITORYID = ? ORDER BY CREATETIME DESC"; + String fileId = DBSql.getString(querySql, new Object[]{palId}); + DCContext sourceDc = getFileDCContext(fileId,fileName); + WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK); + String url = String.format("/api/preview/v1/files/%s/link?type=%s&preview_mode=%s&_w_third_sid=%s&_w_third_palId=%s&_w_third_queryFileId=%s&_w_third_fname=%s",fileId,"w","ordinary",this.getContext().getSessionId(),palId,fileId,URLEncoder.encode(sourceDc.getFileName())); + Map headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE); + logAPI.consoleInfo(">>>>>headers"+headers); + return HttpPostUtil.sendGetRequest(YiliWpsConst.HOST+"/open"+url,headers); + } + public String getFileInfo(String sid,String palId,String fileId,String fileName){ String sourceFileName = null; try { @@ -157,57 +175,30 @@ public class WpsWeb extends ActionWeb { /** * 获取历史版本文件 - * @param params * @return */ - public String getHistoryFileInfo(JSONObject params){ + public String getHistoryFileInfo(String queryFileId,String fileName){ JSONObject resultJson =new JSONObject(); JSONArray historyArray =new JSONArray(); - String boId = params.getString("boId"); - String boItemName = params.getString("boItemName").toString(); - String sid = params.getString("sid"); - UserContext uc = UserContext.fromSessionId(sid); - String sql = "SELECT * FROM WFC_FORMFILES WHERE BOID=? AND BOFIELDNAME=? ORDER BY ORDERINDEX DESC"; - List list = DBSql.query(sql, new FormFileDao().rowMapper(), new Object[]{boId,boItemName}); - if(null != list && list.size()>1){ - for (int i = 1; i < list.size(); i++) {//因为第一个是现版本,所以从第二个开始 - JSONObject fileJson = new JSONObject(); - FormFile formFile = list.get(i); - DCContext fileDCContext = SDK.getBOAPI().getFileDCContext(formFile); - fileDCContext.setSession(uc); - String fileName = fileDCContext.getFileName(); - int orderIndex = formFile.getOrderIndex()+1;//wps历史版本从1开始 - String id = formFile.getId(); - long fileSize = formFile.getFileSize(); - String downloadUrl = fileDCContext.getDownloadURL(); - downloadUrl = downloadUrl.replace("sid=ck", "sid="+sid); - downloadUrl = AWSPortalConf.getUrl()+ "/r"+ downloadUrl.substring(1,downloadUrl.length()); - downloadUrl += "%version=" +orderIndex; - long createTime = formFile.getCreateDate().getTime(); - //获取编辑人信息 - JSONObject userJson =new JSONObject(); - String createUser = formFile.getCreateUser(); - UserModel user = SDK.getORGAPI().getUser(createUser); - String userName = user.getUserName(); - String userPhoto = SDK.getPortalAPI().getUserPhoto(uc, createUser); - String avatar_url = AWSPortalConf.getUrl() +"/r" + userPhoto.substring(1,userPhoto.length()); - //组装json - userJson.put("id",createUser); - userJson.put("name",userName); - userJson.put("avatar_url",avatar_url); - fileJson.put("id",id); - fileJson.put("name",fileName); - fileJson.put("version",orderIndex); - fileJson.put("size",fileSize); - fileJson.put("download_url",downloadUrl); - fileJson.put("create_time",createTime); - fileJson.put("modify_time",createTime); - fileJson.put("creator",userJson); - fileJson.put("modifier",userJson); - historyArray.add(fileJson); - } - } + JSONObject fileJson = new JSONObject(); + DCContext sourceDc = getFileDCContext(queryFileId,fileName); + //组装json + JSONObject userJson =new JSONObject(); + userJson.put("id","admin"); + userJson.put("name","对不起,暂不支持显示历史版本"); + userJson.put("avatar_url",""); + fileJson.put("id", UUIDGener.getUUID()); + fileJson.put("name","对不起,暂不支持显示历史版本"); + fileJson.put("version",1); + fileJson.put("size",sourceDc.getFileLength()); + fileJson.put("download_url",sourceDc.getDownloadURL()); + fileJson.put("create_time",System.currentTimeMillis()/1000); + fileJson.put("modify_time",System.currentTimeMillis()/1000); + fileJson.put("creator",userJson); + fileJson.put("modifier",userJson); + historyArray.add(fileJson); resultJson.put("histories",historyArray); + System.out.println("historyArray = " + historyArray.toString()); return resultJson.toString(); } @@ -279,9 +270,7 @@ public class WpsWeb extends ActionWeb { FormFile formFile = files.get(0); sourceDc = SDK.getBOAPI().getFileDCContext(formFile, repositoryName); sourceDc.setSession(this.getContext()); - //往附件表中写入一个附件 - return sourceDc; } }