From ce2a1403be067854d688415ff6ee5db869adcec8 Mon Sep 17 00:00:00 2001 From: yujh Date: Wed, 2 Oct 2024 10:05:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/output/template/TestController.java | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100644 com.awspaas.user.apps.output.template/src/com/awspaas/user/apps/output/template/TestController.java diff --git a/com.awspaas.user.apps.output.template/src/com/awspaas/user/apps/output/template/TestController.java b/com.awspaas.user.apps.output.template/src/com/awspaas/user/apps/output/template/TestController.java deleted file mode 100644 index b18d58a3..00000000 --- a/com.awspaas.user.apps.output.template/src/com/awspaas/user/apps/output/template/TestController.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.awspaas.user.apps.output.template; - -import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; -import com.actionsoft.bpms.bo.engine.BO; -import com.actionsoft.bpms.commons.formfile.model.delegate.FormFile; -import com.actionsoft.bpms.server.UserContext; -import com.actionsoft.bpms.server.bind.annotation.Controller; -import com.actionsoft.bpms.server.bind.annotation.Mapping; -import com.actionsoft.bpms.server.conf.portal.AWSPortalConf; -import com.actionsoft.bpms.server.fs.DCContext; -import com.actionsoft.bpms.server.fs.dc.DCUtil; -import com.actionsoft.sdk.local.SDK; -import com.actionsoft.sdk.local.api.BOAPI; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.awspaas.user.apps.output.template.util.HttpPostUtil; -import com.awspaas.user.apps.output.template.util.WPS4Util; -import com.awspaas.user.apps.output.template.util.YiliWpsConst; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Map; -import java.util.UUID; -@Controller -public class TestController { - /** - * 打开可编辑的页面 - * @param me - * @return - * @throws Exception - */ - @Mapping("com.awspaas.user.apps.output.template.mergeFile") - public String mergeFile(UserContext me,String bindId) throws Exception{ - try { - BO bo = SDK.getBOAPI().query("BO_EU_TEST_FILEMERGE").bindId(bindId).detail(); - BOAPI boapi = SDK.getBOAPI(); - FormFile file1 = boapi.getFiles(bo.getId(), "FILE1").get(0); - DCContext fileDCContext1 = boapi.getFileDCContext(file1); - fileDCContext1.setSession(me); - FormFile file2 = boapi.getFiles(bo.getId(), "FILE2").get(0); - DCContext fileDCContext2 = boapi.getFileDCContext(file2); - fileDCContext2.setSession(me); - WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK); - String url = String.format("/api/cps/sync/v1/merge"); - JSONObject result = new JSONObject(); - JSONArray array = new JSONArray(); - JSONObject merged_file_obj1 = new JSONObject(); - JSONObject merged_file_obj2 = new JSONObject(); - result.put("task_id", UUID.randomUUID()); - merged_file_obj1.put("doc_url",SDK.getAppAPI().getProperty(YiliWpsConst.APPID,"targetPortal")+"/r"+fileDCContext1.getDownloadURL().substring(1)); - merged_file_obj1.put("doc_filename",fileDCContext1.getFileName()); - array.add(merged_file_obj1); - merged_file_obj2.put("doc_url",SDK.getAppAPI().getProperty(YiliWpsConst.APPID,"targetPortal")+"/r"+fileDCContext2.getDownloadURL().substring(1)); - merged_file_obj2.put("doc_filename",fileDCContext2.getFileName()); - array.add(merged_file_obj2); - result.put("merged_file_list",array); - Map headers = WPS4Util.getSignatureHeaders(url, "POST",result.toString(), YiliWpsConst.CONTENT_TYPE); - JSONObject json = HttpPostUtil.sendPostRequest(YiliWpsConst.HOST + "/open" + url, result.toString(), headers, JSONObject.class); - System.out.println("jsonObject = " + json.toString()); - if(json.getString("code").equals("200")){ - System.out.println(">>>>>>>已合并成功"); - String download_id = json.getJSONObject("data").getString("download_id"); - String route_key = json.getJSONObject("data").getString("route_key"); - //String savePath = AWSPortalConf.getUrl() +"/test/123.doc"; - String savePath = fileDCContext1.getPath()+"/"+fileDCContext1.getFileName(); - System.out.println("savePath = " + savePath); - operateDocumentResultDownload(YiliWpsConst.HOST,download_id,route_key,savePath); - return savePath; - } - return json.toString(); - }catch (Exception e){ - e.printStackTrace(); - } - return ""; - } - - public static void operateDocumentResultDownload(String host,String downloadId,String routeKey,String savePath) throws Exception { - String url = "/api/cps/v1/download/{download_id}"; - url = url.replace("{download_id}",downloadId); - Map headers = WPS4Util.getSignatureHeaders(url, "GET",null,YiliWpsConst.CONTENT_TYPE); - headers.put("Route-Key",routeKey); - HttpPostUtil.sendGetDownloadRequest(host + "/open" + url, headers,savePath); - } -}