wps代码优化
This commit is contained in:
parent
d80f7d2571
commit
222af80abc
@ -53,4 +53,16 @@ public class YiliWpsController {
|
||||
WpsWeb web =new WpsWeb(me);
|
||||
return web.getCoeDefinition(palId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件大小是否超过设定值
|
||||
* @param me
|
||||
* @param palId
|
||||
* @return
|
||||
*/
|
||||
@Mapping("com.awspaas.user.apps.yiliwps.checkFileSize")
|
||||
public String checkFileSize(UserContext me,String palId){
|
||||
WpsWeb web =new WpsWeb(me);
|
||||
return web.checkFileSize(palId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class YiliWpsApi {
|
||||
@QueryParam("_w_third_fname") String fileName){
|
||||
System.out.println(">>>>>>文件历史调用成功:"+System.currentTimeMillis());
|
||||
WpsWeb web = new WpsWeb();
|
||||
return web.getHistoryFileInfo(queryFileId,fileName);
|
||||
return web.getHistoryFileInfo(queryFileId);
|
||||
}
|
||||
|
||||
@Path("/v1/3rd/file/version/{version}")
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.awspaas.user.apps.yiliwps.web;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.constant.CoEConstant;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||
@ -13,6 +14,7 @@ import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.formfile.dao.FormFileDao;
|
||||
import com.actionsoft.bpms.commons.formfile.model.delegate.FormFile;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ActionWeb;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.org.model.UserModel;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.conf.portal.AWSPortalConf;
|
||||
@ -20,6 +22,7 @@ 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.bpms.util.UtilNumber;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.LogAPI;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@ -54,7 +57,7 @@ public class WpsWeb extends ActionWeb {
|
||||
public String getWPSOnlineFilePreviewUrl(String palId,String fileName) throws Exception{
|
||||
//先判断该fileId有无附件
|
||||
String fileId = getFileIdByPalId(palId);
|
||||
DCContext sourceDc = getFileDCContext(fileId,fileName);
|
||||
DCContext sourceDc = getFileDCContext(fileId);
|
||||
WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK);
|
||||
String url = String.format("/api/edit/v1/files/%s/link?type=%s&_w_third_sid=%s&_w_third_palId=%s&_w_third_queryFileId=%s&_w_third_fname=%s",fileId,"w",this.getContext().getSessionId(),palId,fileId,URLEncoder.encode(sourceDc.getFileName()));
|
||||
Map<String,String> headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE);
|
||||
@ -70,7 +73,7 @@ public class WpsWeb extends ActionWeb {
|
||||
public String getWPSOnlineFileReadOnlyUrl(String palId,String fileName) throws Exception{
|
||||
//先判断该fileId有无附件
|
||||
String fileId = getFileIdByPalId(palId);
|
||||
DCContext sourceDc = getFileDCContext(fileId,fileName);
|
||||
DCContext sourceDc = getFileDCContext(fileId);
|
||||
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<String,String> headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE);
|
||||
@ -85,7 +88,7 @@ public class WpsWeb extends ActionWeb {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DCContext sourceDc = getFileDCContext(fileId,sourceFileName);
|
||||
DCContext sourceDc = getFileDCContext(fileId);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject file = new JSONObject();
|
||||
JSONObject user = new JSONObject();
|
||||
@ -149,7 +152,7 @@ public class WpsWeb extends ActionWeb {
|
||||
//CallASLPUtil aslpUtil =new CallASLPUtil();
|
||||
//aslpUtil.callTranslateDocASLP(me,palId,fileName,fileInputStream);
|
||||
//只写入新文件
|
||||
DCContext sourceDc = getFileDCContext(fileId,fileName);
|
||||
DCContext sourceDc = getFileDCContext(fileId);
|
||||
sourceDc.setSession(me);
|
||||
SDK.getDCAPI().write(fileInputStream,sourceDc);
|
||||
//在重新获取下fileId
|
||||
@ -178,11 +181,11 @@ public class WpsWeb extends ActionWeb {
|
||||
* 获取历史版本文件
|
||||
* @return
|
||||
*/
|
||||
public String getHistoryFileInfo(String queryFileId,String fileName){
|
||||
public String getHistoryFileInfo(String queryFileId){
|
||||
JSONObject resultJson =new JSONObject();
|
||||
JSONArray historyArray =new JSONArray();
|
||||
JSONObject fileJson = new JSONObject();
|
||||
DCContext sourceDc = getFileDCContext(queryFileId,fileName);
|
||||
DCContext sourceDc = getFileDCContext(queryFileId);
|
||||
//组装json
|
||||
JSONObject userJson =new JSONObject();
|
||||
userJson.put("id","admin");
|
||||
@ -243,7 +246,7 @@ public class WpsWeb extends ActionWeb {
|
||||
* @param palId
|
||||
* @return
|
||||
*/
|
||||
public DCContext getFileDCContext(String palId,String fileName){
|
||||
public DCContext getFileDCContext(String palId){
|
||||
DCContext sourceDc = null;
|
||||
//先判断该fileId有无附件
|
||||
String querySql = " SELECT PALREPOSITORYID,SHAPEID,FILETYPE,FILENAME FROM " + YiliWpsConst.APP_ACT_COE_PAL_UPFILE+" WHERE ID = ? ORDER BY CREATETIME DESC";
|
||||
@ -299,6 +302,32 @@ public class WpsWeb extends ActionWeb {
|
||||
return model.getDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验正文文件大小
|
||||
* @return
|
||||
*/
|
||||
public String checkFileSize(String palId){
|
||||
ResponseObject ro = ResponseObject.newOkResponse();
|
||||
//判断用户上传的文件的大小有多大
|
||||
String fileId = getFileIdByPalId(palId);
|
||||
DCContext sourceDc = getFileDCContext(fileId);
|
||||
if(null == sourceDc){
|
||||
ro.put("state",false);
|
||||
}
|
||||
String fileLength = String.valueOf(sourceDc.length());
|
||||
String maxFileLength = SDK.getAppAPI().getProperty(CoEConstant.APP_ID, "wps_export_file_size");
|
||||
String maxFileLength_B = UtilNumber.mul(UtilNumber.mul(maxFileLength, "1024.0"),"1024.0");
|
||||
System.out.println(">>fileLength = " + fileLength);
|
||||
System.out.println(">>maxFileLength_B = " + maxFileLength_B);
|
||||
if(Double.parseDouble(UtilNumber.sub(fileLength,maxFileLength_B))>0){//大于设置的值,则走wps逻辑
|
||||
ro.put("maxFileLength",maxFileLength);
|
||||
ro.put("state",true);
|
||||
}else{
|
||||
ro.put("state",false);
|
||||
}
|
||||
return ro.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过文件ID获取主要模型块的附件ID
|
||||
|
||||
Loading…
Reference in New Issue
Block a user