管理办法wps在线编辑,后台代码提交
This commit is contained in:
		
							parent
							
								
									3f298c9f7c
								
							
						
					
					
						commit
						58f90cdbee
					
				| @ -22,6 +22,8 @@ public class YiliWpsConst { | ||||
| 
 | ||||
| 	//bo相关 | ||||
| 	public static final String BO_EU_SYSTEM_DEMO_FILE = "BO_EU_SYSTEM_DEMO_FILE"; | ||||
| 	public static final String BO_EU_PROCESS_MR = "BO_EU_PROCESS_MR";//管理要求统计 | ||||
| 	public static final String BO_EU_PROCESS_MR_TPL = "BO_EU_PROCESS_MR_TPL";//管理要求模版文件 | ||||
| 	public static final String APP_ACT_COE_PAL_UPFILE = "APP_ACT_COE_PAL_UPFILE"; | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -28,6 +28,32 @@ public class YiliWpsController { | ||||
|         return web.getWPSOnlineFilePreviewUrl(palId,fileName); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 打开可编辑的页面(epc) | ||||
|      * @param me | ||||
|      * @param palId | ||||
|      * @return | ||||
|      * @throws Exception | ||||
|      */ | ||||
|     @Mapping("com.awspaas.user.apps.yiliwps.previewUrl_mr") | ||||
|     public String getWPSOnlineFilePreviewUrlMR(UserContext me,String palId) throws Exception{ | ||||
|         WpsWeb web =new WpsWeb(me); | ||||
|         return web.getWPSMROnlineFilePreviewUrl(palId); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 打开只读的页面(epc) | ||||
|      * @param me | ||||
|      * @param palId | ||||
|      * @return | ||||
|      * @throws Exception | ||||
|      */ | ||||
|     @Mapping("com.awspaas.user.apps.yiliwps.previewUrl_mr_read") | ||||
|     public String getWPSOnlineFilePreviewUrlMRRead(UserContext me,String palId) throws Exception{ | ||||
|         WpsWeb web =new WpsWeb(me); | ||||
|         return web.getWPSMROnlineFilePreviewReadUrl(palId); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 打开制度的页面 | ||||
|      * @param me | ||||
| @ -65,4 +91,17 @@ public class YiliWpsController { | ||||
|         WpsWeb web =new WpsWeb(me); | ||||
|         return web.checkFileSize(palId); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 更新管理办法mr状态 | ||||
|      * @param me | ||||
|      * @param palId | ||||
|      * @return | ||||
|      * @throws Exception | ||||
|      */ | ||||
|     @Mapping("com.awspaas.user.apps.yiliwps.updateMrStatus") | ||||
|     public String updateMrStatus(UserContext me,String palId) throws Exception{ | ||||
|         WpsWeb web =new WpsWeb(me); | ||||
|         return web.updateMrStatus(palId); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -30,13 +30,15 @@ public class YiliWpsApi { | ||||
|                            @QueryParam("_w_third_repositoryName") String repositoryName, | ||||
|                            @QueryParam("_w_third_groupValue") String groupValue, | ||||
|                            @QueryParam("_w_third_fileValue") String fileValue, | ||||
|                            @QueryParam("_w_third_filePreview") String filePreview | ||||
|                            @QueryParam("_w_third_filePreview") String filePreview, | ||||
|                            @QueryParam("_w_third_isEPC") String isEPC | ||||
|                            ) { | ||||
|         JSONObject params = new JSONObject(); | ||||
|         UserContext _uc = UserContext.fromSessionId(sid); | ||||
|         System.out.println("isEpc = " + isEPC); | ||||
|         logApi.consoleInfo(">>>>>文件信息请求成功/v1/3rd/file/info"+palId+","+headFileId+queryFileId+sid+fileName+appId+repositoryName+groupValue+fileValue); | ||||
|         WpsWeb web =new WpsWeb(_uc); | ||||
|         return web.getFileInfo(sid,palId,queryFileId,fileName,appId,repositoryName,groupValue,fileValue,filePreview); | ||||
|         return web.getFileInfo(sid,palId,queryFileId,fileName,appId,repositoryName,groupValue,fileValue,filePreview,isEPC); | ||||
|     } | ||||
| 
 | ||||
|     @Path("/v1/3rd/user/info") | ||||
| @ -74,7 +76,9 @@ public class YiliWpsApi { | ||||
|                        @QueryParam("_w_third_queryFileId") String queryFileId, | ||||
|                        @QueryParam("_w_third_palId") String palId, | ||||
|                        @QueryParam("_w_third_sid") String sid, | ||||
|                        @QueryParam("_w_third_fname") String fileName) { | ||||
|                        @QueryParam("_w_third_fname") String fileName, | ||||
|                        @QueryParam("_w_third_isEPC") String isEPC | ||||
|     ) { | ||||
|         JSONObject params = new JSONObject(); | ||||
|         System.out.println("file.getName() = " + file.getName()); | ||||
|         System.out.println("file.size() = " + file.length()); | ||||
| @ -82,9 +86,10 @@ public class YiliWpsApi { | ||||
|         System.out.println("palId = " + palId); | ||||
|         System.out.println("sid = " + sid); | ||||
|         System.out.println("fileName = " + fileName); | ||||
|         System.out.println("isEpc = " + isEPC); | ||||
|         System.out.println(">>>>>>文件保存调用成功:"+System.currentTimeMillis()); | ||||
|         WpsWeb web = new WpsWeb(); | ||||
|         String fileInfo = web.saveFileInfo(save_type,palId,queryFileId,sid,fileName,file); | ||||
|         String fileInfo = web.saveFileInfo(save_type,palId,queryFileId,sid,fileName,file,isEPC); | ||||
|         return fileInfo; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -10,6 +10,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil; | ||||
| import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; | ||||
| import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile; | ||||
| import com.actionsoft.bpms.bo.engine.BO; | ||||
| import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance; | ||||
| import com.actionsoft.bpms.commons.database.RowMap; | ||||
| import com.actionsoft.bpms.commons.formfile.dao.FormFileDao; | ||||
| import com.actionsoft.bpms.commons.formfile.model.delegate.FormFile; | ||||
| @ -83,7 +84,7 @@ public class WpsWeb extends ActionWeb { | ||||
| 		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,String filePreview){ | ||||
| 	public String getFileInfo(String sid,String palId,String fileId,String fileName,String appId,String repositoryName,String groupValue,String fileValue,String filePreview,String isEPC){ | ||||
| 		String sourceFileName = null; | ||||
| 		try { | ||||
| 			sourceFileName = URLDecoder.decode(fileName,"UTF-8"); | ||||
| @ -96,7 +97,10 @@ public class WpsWeb extends ActionWeb { | ||||
| 		JSONObject user = new JSONObject(); | ||||
| 		JSONObject user_acl = new JSONObject(); | ||||
| 		JSONObject watermark = new JSONObject(); | ||||
| 		if(UtilString.isEmpty(filePreview)){ | ||||
| 		if("1".equals(isEPC)){ | ||||
| 			sourceDc = getFileDCContext(fileId,isEPC); | ||||
| 			file.put("id", fileId); | ||||
| 		}else if(UtilString.isEmpty(filePreview)){ | ||||
| 			sourceDc = getFileDCContext(fileId); | ||||
| 			file.put("id", fileId.equals("")?"1":fileId); | ||||
| 		}else{ | ||||
| @ -151,7 +155,7 @@ public class WpsWeb extends ActionWeb { | ||||
| 		return jsonObject.toString(); | ||||
| 	} | ||||
| 
 | ||||
| 	public String saveFileInfo(String save_type,String palId, String fileId,String sid,String fileName, File file){ | ||||
| 	public String saveFileInfo(String save_type,String palId, String fileId,String sid,String fileName, File file,String isEPC){ | ||||
| 		UserContext me = UserContext.fromSessionId(sid); | ||||
| 		JSONObject jsonObject = new JSONObject(); | ||||
| 		JSONObject fileJson = new JSONObject(); | ||||
| @ -162,12 +166,22 @@ public class WpsWeb extends ActionWeb { | ||||
| 			//CallASLPUtil aslpUtil =new CallASLPUtil(); | ||||
| 			//aslpUtil.callTranslateDocASLP(me,palId,fileName,fileInputStream); | ||||
| 			//只写入新文件 | ||||
| 			DCContext sourceDc = getFileDCContext(fileId); | ||||
| 			sourceDc.setSession(me); | ||||
| 			SDK.getDCAPI().write(fileInputStream,sourceDc); | ||||
| 			//在重新获取下fileId | ||||
| 			String querySql = " SELECT ID FROM " + YiliWpsConst.APP_ACT_COE_PAL_UPFILE+" WHERE PALREPOSITORYID = ? ORDER BY CREATETIME DESC"; | ||||
| 			fileId = DBSql.getString(querySql, new Object[]{palId}); | ||||
| 			DCContext sourceDc; | ||||
| 			if("1".equals(isEPC)){//EPC图 | ||||
| 				sourceDc = getFileDCContext(fileId,isEPC); | ||||
| 				sourceDc.setSession(me); | ||||
| 				BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_PROCESS_MR, "FILEUUID", fileId); | ||||
| 				List<FormFile> systemfile = SDK.getBOAPI().getFiles(mrBO.getId(), "SYSTEMFILE"); | ||||
| 				FormFile formFile = systemfile.get(0); | ||||
| 				SDK.getBOAPI().upFile(formFile,fileInputStream); | ||||
| 			}else{//制度图 | ||||
| 				sourceDc = getFileDCContext(fileId); | ||||
| 				//在重新获取下fileId | ||||
| 				String querySql = " SELECT ID FROM " + YiliWpsConst.APP_ACT_COE_PAL_UPFILE+" WHERE PALREPOSITORYID = ? ORDER BY CREATETIME DESC"; | ||||
| 				fileId = DBSql.getString(querySql, new Object[]{palId}); | ||||
| 				sourceDc.setSession(me); | ||||
| 				SDK.getDCAPI().write(fileInputStream,sourceDc); | ||||
| 			} | ||||
| 			//整理返回的数据 | ||||
| 			fileJson.put("id", fileId); | ||||
| 			fileJson.put("size", file.length()); | ||||
| @ -289,6 +303,21 @@ public class WpsWeb extends ActionWeb { | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 获取附件的附件ID(流程图相关的逻辑) | ||||
| 	 * @param fileId | ||||
| 	 * @return | ||||
| 	 */ | ||||
| 	public DCContext getFileDCContext(String fileId,String isEpc){ | ||||
| 		//查询模版记录文件 | ||||
| 		BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_PROCESS_MR, "FILEUUID", fileId); | ||||
| 		List<FormFile> systemfile = SDK.getBOAPI().getFiles(mrBO.getId(), "SYSTEMFILE"); | ||||
| 		FormFile formFile = systemfile.get(0); | ||||
| 		DCContext fileDCContext = SDK.getBOAPI().getFileDCContext(formFile); | ||||
| 		fileDCContext.setSession(this.getContext()); | ||||
| 		return fileDCContext; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 获取附件的附件ID | ||||
| 	 * @return | ||||
| @ -391,4 +420,84 @@ public class WpsWeb extends ActionWeb { | ||||
| 			return ""; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * (编辑)打开流程图管理要求wps在线 | ||||
| 	 * @param palId | ||||
| 	 * @return | ||||
| 	 * @throws Exception | ||||
| 	 */ | ||||
| 	public String getWPSMROnlineFilePreviewUrl(String palId) throws Exception{ | ||||
| 		//先判断流程是否已经编辑过 | ||||
| 		BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_PROCESS_MR, "FILEUUID", palId); | ||||
| 		if(null == mrBO){//如果为空 | ||||
| 			mrBO = new BO(); | ||||
| 			mrBO.set("FILEUUID",palId); | ||||
| 			mrBO.set("STATUS","0");//默认无效 | ||||
| 			ProcessInstance processInstance = SDK.getProcessAPI().createProcessInstance("obj_b733a36123364738895919023e305aca", this.getContext().getUID(), "新建管理要求文件"); | ||||
| 			SDK.getBOAPI().create("BO_EU_PROCESS_MR", mrBO, processInstance, this.getContext()); | ||||
| 			//创建完BO后,把模版附件copy进去 | ||||
| 			//先获取模版文件 | ||||
| 			BO tplBO = SDK.getBOAPI().query(YiliWpsConst.BO_EU_PROCESS_MR_TPL).addQuery("FILESTATE=", true).detail(); | ||||
| 			SDK.getBOAPI().copyFileTo(tplBO.getId(),"SYSTEMFILE",mrBO.getId(),YiliWpsConst.BO_EU_PROCESS_MR,"SYSTEMFILE",processInstance.getId(),null); | ||||
| 		} | ||||
| 		String mrStatus = mrBO.getString("STATUS");//获取管理办法状态 | ||||
| 		DCContext sourceDc = getFileDCContext(palId,"1"); | ||||
| 		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&_w_third_isEPC=%s",palId,"w",this.getContext().getSessionId(),palId,palId,URLEncoder.encode(sourceDc.getFileName()),"1"); | ||||
| 		Map<String,String> headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE); | ||||
| 		logAPI.consoleInfo(">>>>>headers"+headers); | ||||
| 		String content = HttpPostUtil.sendGetRequest(YiliWpsConst.HOST + "/open" + url, headers); | ||||
| 		ResponseObject ro = ResponseObject.newOkResponse(); | ||||
| 		ro.put("mrStatus",mrStatus); | ||||
| 		ro.put("content",content); | ||||
| 		return ro.toString(); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * (只读)打开流程图管理要求wps在线 | ||||
| 	 * @param palId | ||||
| 	 * @return | ||||
| 	 */ | ||||
| 	public String getWPSMROnlineFilePreviewReadUrl(String palId) throws Exception { | ||||
| 		//先判断流程是否已经编辑过 | ||||
| 		BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_PROCESS_MR, "FILEUUID", palId); | ||||
| 		if(null == mrBO) {//如果为空 | ||||
| 			return ResponseObject.newErrResponse("未创建管理要求文件").toString(); | ||||
| 		} | ||||
| 		String mrStatus = mrBO.getString("STATUS");//获取管理办法状态 | ||||
| 		if("0".equals(mrStatus)){ | ||||
| 			return ResponseObject.newErrResponse("管理要求文件未生效").toString(); | ||||
| 		} | ||||
| 		DCContext sourceDc = getFileDCContext(palId,"1"); | ||||
| 		WPS4Util.initAppInfo(YiliWpsConst.AK, YiliWpsConst.SK); | ||||
| 		String url = String.format("/api/preview/v1/files/%s/link?type=%s&_w_third_sid=%s&_w_third_palId=%s&_w_third_queryFileId=%s&_w_third_fname=%s&_w_third_isEPC=%s",palId,"w",this.getContext().getSessionId(),palId,palId,URLEncoder.encode(sourceDc.getFileName()),"1"); | ||||
| 		Map<String,String> headers = WPS4Util.getSignatureHeaders(url, HttpMethod.GET,null, YiliWpsConst.CONTENT_TYPE); | ||||
| 		logAPI.consoleInfo(">>>>>headers"+headers); | ||||
| 		String content = HttpPostUtil.sendGetRequest(YiliWpsConst.HOST + "/open" + url, headers); | ||||
| 		ResponseObject ro = ResponseObject.newOkResponse(); | ||||
| 		ro.put("mrStatus",mrStatus); | ||||
| 		ro.put("content",content); | ||||
| 		return ro.toString(); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 更新MR管理办法状态 | ||||
| 	 * @param palId | ||||
| 	 * @return | ||||
| 	 * @throws Exception | ||||
| 	 */ | ||||
| 	public String updateMrStatus(String palId){ | ||||
| 		ResponseObject ro = ResponseObject.newOkResponse(); | ||||
| 		BO mrBO = SDK.getBOAPI().getByKeyField(YiliWpsConst.BO_EU_PROCESS_MR, "FILEUUID", palId); | ||||
| 		mrBO.set("STATUS","1"); | ||||
| 		int update = SDK.getBOAPI().update(YiliWpsConst.BO_EU_PROCESS_MR, mrBO); | ||||
| 		if(update>0){ | ||||
| 			ro.put("mrStatus",1); | ||||
| 		}else{ | ||||
| 			ro.put("mrStatus",0); | ||||
| 		} | ||||
| 		return ResponseObject.newOkResponse().toString(); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 yujh_java
						yujh_java