预览切换成wps在线预览功能,需要结合文件预览服务应用一起上线

This commit is contained in:
yujh_java 2025-05-23 17:24:49 +08:00
parent 5ec054dfad
commit f47f4e3ac5
3 changed files with 13 additions and 7 deletions

View File

@ -34,8 +34,8 @@ public class WPSOnlineReadOnlyASLP implements ASLP {
String fileType = getFileType(fileName); String fileType = getFileType(fileName);
WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK); 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&_w_third_appId=%s&_w_third_repositoryName=%s&_w_third_groupValue=%s&_w_third_fileValue=%s" 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&_w_third_appId=%s&_w_third_repositoryName=%s&_w_third_groupValue=%s&_w_third_fileValue=%s&_w_third_filePreview=%s"
,sourceDc.getFileValue(),fileType,"ordinary",sid,sourceDc.getGroupValue(),sourceDc.getFileValue(), URLEncoder.encode(sourceDc.getFileName()),sourceDc.getAppId(),sourceDc.getRepositoryName(),sourceDc.getGroupValue(),sourceDc.getFileValue()); ,sourceDc.getFileValue(),fileType,"ordinary",sid,sourceDc.getGroupValue(),sourceDc.getFileValue(), URLEncoder.encode(sourceDc.getFileName()),sourceDc.getAppId(),sourceDc.getRepositoryName(),sourceDc.getGroupValue(),sourceDc.getFileValue(),"filePreview");
System.out.println(">>>>>>>>预览的url = " + url); System.out.println(">>>>>>>>预览的url = " + url);
Map<String,String> headers = null; Map<String,String> headers = null;
try { try {

View File

@ -29,13 +29,14 @@ public class YiliWpsApi {
@QueryParam("_w_third_appId") String appId, @QueryParam("_w_third_appId") String appId,
@QueryParam("_w_third_repositoryName") String repositoryName, @QueryParam("_w_third_repositoryName") String repositoryName,
@QueryParam("_w_third_groupValue") String groupValue, @QueryParam("_w_third_groupValue") String groupValue,
@QueryParam("_w_third_fileValue") String fileValue @QueryParam("_w_third_fileValue") String fileValue,
@QueryParam("_w_third_filePreview") String filePreview
) { ) {
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
UserContext _uc = UserContext.fromSessionId(sid); UserContext _uc = UserContext.fromSessionId(sid);
logApi.consoleInfo(">>>>>文件信息请求成功/v1/3rd/file/info"+palId+","+headFileId+queryFileId+sid+fileName+appId+repositoryName+groupValue+fileValue); logApi.consoleInfo(">>>>>文件信息请求成功/v1/3rd/file/info"+palId+","+headFileId+queryFileId+sid+fileName+appId+repositoryName+groupValue+fileValue);
WpsWeb web =new WpsWeb(_uc); WpsWeb web =new WpsWeb(_uc);
return web.getFileInfo(sid,palId,queryFileId,fileName,appId,repositoryName,groupValue,fileValue); return web.getFileInfo(sid,palId,queryFileId,fileName,appId,repositoryName,groupValue,fileValue,filePreview);
} }
@Path("/v1/3rd/user/info") @Path("/v1/3rd/user/info")

View File

@ -23,6 +23,7 @@ import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
import com.actionsoft.bpms.util.DBSql; import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener; import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilNumber; import com.actionsoft.bpms.util.UtilNumber;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.SDK;
import com.actionsoft.sdk.local.api.LogAPI; import com.actionsoft.sdk.local.api.LogAPI;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -82,15 +83,19 @@ public class WpsWeb extends ActionWeb {
return HttpPostUtil.sendGetRequest(YiliWpsConst.HOST+"/open"+url,headers); return HttpPostUtil.sendGetRequest(YiliWpsConst.HOST+"/open"+url,headers);
} }
public String getFileInfo(String sid,String palId,String fileId,String fileName,String appId,String repositoryName,String groupValue,String fileValue){ public String getFileInfo(String sid,String palId,String fileId,String fileName,String appId,String repositoryName,String groupValue,String fileValue,String filePreview){
String sourceFileName = null; String sourceFileName = null;
try { try {
sourceFileName = URLDecoder.decode(fileName,"UTF-8"); sourceFileName = URLDecoder.decode(fileName,"UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }
//DCContext sourceDc = getFileDCContext(fileId); DCContext sourceDc;
DCContext sourceDc = getFileDCContext(palId,appId,repositoryName,groupValue,fileValue,sourceFileName); if(UtilString.isEmpty(filePreview)){
sourceDc = getFileDCContext(fileId);
}else{
sourceDc = getFileDCContext(palId,appId,repositoryName,groupValue,fileValue,sourceFileName);
}
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
JSONObject file = new JSONObject(); JSONObject file = new JSONObject();
JSONObject user = new JSONObject(); JSONObject user = new JSONObject();