测试代码删除
This commit is contained in:
parent
f2a509bfff
commit
ce2a1403be
@ -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<String,String> 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<String,String> headers = WPS4Util.getSignatureHeaders(url, "GET",null,YiliWpsConst.CONTENT_TYPE);
|
||||
headers.put("Route-Key",routeKey);
|
||||
HttpPostUtil.sendGetDownloadRequest(host + "/open" + url, headers,savePath);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user