📄 tradelogger.java
字号:
package com.saas.sys.bpm;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import com.saas.sys.dbm.Dbcommit;
import com.saas.sys.dbm.Dbexecute;
import com.saas.sys.dbm.Dbtable;
import org.apache.commons.beanutils.PropertyUtils;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.log.Logger;
public class TradeLogger implements TradeLoggerIntf {
Logger log = new Logger(this);
Buffers outBuffer = new Buffers();
Dbcommit commit;
Dbexecute exec;
TradeInit tradeInit;
public ArrayList ExecTradeLogger(Buffers inBuffer) {
log.LOG_INFO("进入主控业务方法...");
commit = new Dbcommit();
exec = new Dbexecute();
Buffers outBuffer = new Buffers();
if (inBuffer.getString("TRADE_TYPE_CODE") == "")
throw new RuntimeException("业务类型域字段未赋值!");
outBuffer = inBuffer;
ArrayList outList = new ArrayList();
log.LOG_INFO("********获取业务类型参数开始*********************");
TradeTypeDAO tradeType = new TradeTypeDAO();
tradeType.setParam(":VTRADETYPECODE", "1901");
tradeType = tradeType.selByInfo("SEL_BY_PK");
if (tradeType == null)
throw new RuntimeException("日志类业务类型未定义【1901】!");
log.LOG_INFO("********获取业务类型参数结束*********************");
log.LOG_INFO("********获取业务流程定义开始*********************");
BpmDefinitionDAO bpmdefini = new BpmDefinitionDAO();
ArrayList bpmdefinilist = new ArrayList();
bpmdefini.setParam(":VTRADETYPECODE", "1901");
bpmdefinilist = bpmdefini.selByList("SEL_BY_PK");
int iUnit = 0;
if (bpmdefinilist == null)
throw new RuntimeException("业务流程未定义!");
log.LOG_INFO("********获取业务流程定义结束*********************");
commit.getConnect();
exec.setConnectionHandle(commit.getConnectionHandle());
try {
String fieldName = "";
for (Iterator it = bpmdefinilist.iterator(); it.hasNext();) {
HashMap bpm = (HashMap) it.next();
Class bpmClass = Class.forName(bpm.get("node_class").toString().trim());
Object objBpm = (Object) bpmClass.newInstance();
log.LOG_INFO("********输入参数开始*********************");
inBuffer.list();
log.LOG_INFO("********输入参数结束*********************");
Method bpmMethod = objBpm.getClass().getDeclaredMethod(bpm.get("node_method").toString().trim(), new Class[] { Buffers.class });
log.LOG_INFO("********[开始执行原子业务方法<" + bpmMethod.getName() + ">]*********************");
bpmMethod.invoke(objBpm, new Object[] { inBuffer });
log.LOG_INFO("********原子业务方法执行完毕*********************");
fieldName = bpmClass.getDeclaredField(bpm.get("out_query").toString().trim()).getName();
Dbtable value = (Dbtable) PropertyUtils.getProperty(objBpm, fieldName);
log.LOG_INFO("********获取原子业务方法输出QUERY*********************");
exec.addTable(value);
log.LOG_INFO(exec.getQuery()+"fieldName:"+fieldName);
exec.execBizQuery();
log.LOG_INFO("********获取原子业务方法输出BUFFER*********************");
fieldName = bpmClass.getDeclaredField(bpm.get("out_buffer").toString().trim()).getName();
outBuffer = (Buffers) PropertyUtils.getProperty(objBpm, fieldName);
log.LOG_INFO("********[结束执行原子业务方法<" + bpmMethod.getName() + ">]*********************");
log.LOG_INFO("********输出参数开始*********************");
outBuffer.list();
log.LOG_INFO("********输出参数结束*********************");
if (outBuffer.getInt("RESULT_CODE") == -1) break;
inBuffer = outBuffer;
}
if (outBuffer.getInt("RESULT_CODE") != -1) {
commit.tradeCommit();
outBuffer.setString("SUCCEED_FWD", inBuffer.getString("SUCCEED_FWD"));
}
else {
outBuffer.setString("ERROR_FWD", inBuffer.getString("ERROR_FWD"));
}
log.LOG_INFO("--------[全部业务流程处理完毕!]--------");
log.LOG_INFO("********输出参数开始*********************");
outBuffer.list();
log.LOG_INFO("********输出参数结束*********************");
}
catch (ClassNotFoundException e) {
throw new RuntimeException("调用类未找到:" + e);
}
catch (InstantiationException e) {
throw new RuntimeException(e);
}
catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
catch (InvocationTargetException e) {
throw new RuntimeException(e.getTargetException());
}
catch (NoSuchMethodException e) {
throw new RuntimeException("调用方法未找到:" + e);
}
catch (NoSuchFieldException e) {
throw new RuntimeException("JAVABEAN的域字段未找到:" + e);
}
log.LOG_INFO("退出主控业务方法...");
return outList;
}
public Buffers getOutBuffer() {
return outBuffer;
}
public void setOutBuffer(Buffers outBuffer) {
this.outBuffer = outBuffer;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -