wps代码优化
This commit is contained in:
parent
7aa183907b
commit
52de8519f4
@ -35,6 +35,7 @@ import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class WpsWeb extends ActionWeb {
|
||||
public final static LogAPI logAPI = SDK.getLogAPI();
|
||||
@ -52,8 +53,7 @@ public class WpsWeb extends ActionWeb {
|
||||
*/
|
||||
public String getWPSOnlineFilePreviewUrl(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});
|
||||
String fileId = getFileIdByPalId(palId);
|
||||
DCContext sourceDc = getFileDCContext(fileId,fileName);
|
||||
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()));
|
||||
@ -69,8 +69,7 @@ public class WpsWeb extends ActionWeb {
|
||||
*/
|
||||
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});
|
||||
String fileId = getFileIdByPalId(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()));
|
||||
@ -297,4 +296,26 @@ public class WpsWeb extends ActionWeb {
|
||||
model.setFileName(fileName);
|
||||
return model.getDefinition();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过文件ID获取主要模型块的附件ID
|
||||
* @param palId
|
||||
* @return
|
||||
*/
|
||||
public String getFileIdByPalId(String palId){
|
||||
List<Map<String, Object>> repositoryFileElements = CoeDesignerUtil.getShapeMessageJson(palId);
|
||||
List<Object> ids = repositoryFileElements.stream()
|
||||
.filter(map -> "制度".equals(map.get("title")) || "操作指导".equals(map.get("title")) || "工程技术标准".equals(map.get("title")) || "方案".equals(map.get("title")))
|
||||
.map(map -> map.get("id"))
|
||||
.collect(Collectors.toList());
|
||||
if(ids.size()>0){
|
||||
String querySql = " SELECT ID FROM " + YiliWpsConst.APP_ACT_COE_PAL_UPFILE+" WHERE PALREPOSITORYID = ? AND SHAPEID =? AND FILETYPE=? ORDER BY CREATETIME DESC";
|
||||
String fileId = DBSql.getString(querySql, new Object[]{palId, ids.get(0).toString(), "s"});
|
||||
System.out.println(">>>>>>>>>>fileId = " + fileId);
|
||||
return fileId;
|
||||
}else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user