Writing of post-processing interface for secondary development of pan-micro OA

Writing of post-processing interface for secondary development of pan-micro OA

1. Required dependent files

weaver.soa.workflow.request.RequestInfo //implements 实现类 ,实现 String execute(RequestInfo paramRequestInfo);方法
weaver.conn.RecordSet; //数据库操作类,包含日志打印
com.weaver.general.Util; //工具类 ,主要作用用于数据库查询数据后的数据接收转换作用

Two, demo code analysis

package weaver.interfaces.workflow.action;

import java.util.HashMap;
import java.util.Map;

import com.weaver.general.Util;

import weaver.conn.RecordSet;
import weaver.hrm.User;
import weaver.integration.logging.Logger;
import weaver.integration.logging.LoggerFactory;
import weaver.soa.workflow.request.RequestInfo;

public class TestAction implements Action {
    
    
	
	//设置固定参数空(特点:灵活多变,OA泛微前台可设置该参数数据值)
	private String string1="";
	private String string2="";
	private String string3="";
	
	//打印日志操作类
	private Logger log = LoggerFactory.getLogger(TestAction.class);

	@Override
	public String execute(RequestInfo paramRequestInfo) {
    
    
		// 获取Workflowid
		String workflowid = paramRequestInfo.getWorkflowid();
		//获取签字意见(仅提交触发该接口节点的签字意见)
		String remarkString=paramRequestInfo.getRequestManager().getRemark();
		//获取对应流程表单名称(主表)
		String tableNameString=paramRequestInfo.getRequestManager().getBillTableName();
		//自己写的方法获取对应流程表单名称
		String tableNameString2=getTablename(workflowid); 
		// 获取requestid
		String requestid = paramRequestInfo.getRequestid();
		//获取紧急等级
		String requestLevel=paramRequestInfo.getRequestlevel();
		//获取流程的标题
		String requestname = paramRequestInfo.getRequestManager().getRequestname();
		//获取该流程当前节点id
		int nodeId=paramRequestInfo.getRequestManager().getNodeid();
		//获取该流程是否是自定义表单
		int isbill=paramRequestInfo.getRequestManager().getIsbill();
		//获取该流程下一节点id
		int nextNodeId=paramRequestInfo.getRequestManager().getNextNodeid();
		//获取当前流程操作的用户对象信息
		User usr = paramRequestInfo.getRequestManager().getUser();
		//获取流程当前操作类型
        String src = paramRequestInfo.getRequestManager().getSrc();
		
		
		//数据库操作以及日志打印
		RecordSet recordSet = new RecordSet();
		//sql查询主表语句
		String sqlString = "SELECT * FROM " + tableNameString + " WHERE requestid =" + requestid;
		//执行sql语句
		recordSet.execute(sqlString);
		//创建map
		Map<String, String> mainTableDataMap = new HashMap<String, String>();
		
		//recordSet数据库读取操作为游标,需进行循环后获取数据
		while (recordSet.next()) {
    
    
			// 获取长度
			int intValue = recordSet.getColCounts();
			for (int i = 1; i <= intValue; i++) {
    
    
				// 获取列名
				String colNameString = recordSet.getColumnName(i);
				//获取相应列名对应的值
				String colValueString = Util.null2String(recordSet.getString(colNameString));
				//放入map中
				mainTableDataMap.put(colNameString, colValueString);
			}
		}
		//直接从map中获取想要的列数值
		//优点(操作方便,界面整洁);缺点(不需要的列数据会存入map,增加内存)
		String xwlkrqString=mainTableDataMap.get("xwlkrq");
		
		if (xwlkrqString.equals("")) {
    
    
			
			//错误时使用,流程提交失败后返回前端提示信息
			paramRequestInfo.getRequestManager().setMessageid("");
			paramRequestInfo.getRequestManager().setMessagecontent("签字意见:"
					.concat(remarkString)
					.concat(" 表名:".concat(tableNameString)));
			
			//日志打印(ecology日志)     路径:ecology\log
			recordSet.writeLog("==测试测试"+remarkString);
			
			//日志打印(集成日志) 路径:ecology\log\integration
			log.info("==测试测试"+remarkString);
			
			//执行后处理接口失败 (失败为0)
			return Action.FAILURE_AND_CONTINUE;
		}else {
    
    
			//执行后处理接口通过 (成功为1)
			return Action.SUCCESS;
		}
		
	}

	
	/**
	 * 获取对应workflowid的数据库表单名称
	 * @param workflowid
	 * @return 表单名称(主表)
	 */
	public static String getTablename(String workflowid) {
    
    
		    String formid = "";
		    String sql1 = "select formid from workflow_base where id=" + workflowid;
		     RecordSet rs = new RecordSet();
		     rs.execute(sql1);
		    if (rs.next())
		       formid = rs.getString("formid"); 
		    formid = formid.replaceAll("-", "");
		    String tablename = "formtable_main_" + formid;
		   return tablename;
	   }
}

Three, tips

Live parameters can be configured in the foreground, and the trigger Action interface can be brought in
insert image description here
insert image description here

4. Matters needing attention

  1. The database operation class, "RecordSet" can be reused for query, insert, and change operations as much as possible. Try to choose as little as possible to create a new "RecordSet" class for database operations.
  2. When writing the Action post-processing interface, it is necessary to distinguish the successful operation and the failed operation, and try to print the failure information back to the front-end page when it fails, so that it is convenient to locate the execution failure and error report at a glance.
  3. When configuring flexible parameters in the foreground, pay attention to check whether the parameters become full-width characters when the front-end page is saved.

Guess you like

Origin blog.csdn.net/qq_45844443/article/details/130766821