EsbExtInterface -1

package com.huawei.esb;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;

import com.huawei.bo.EsbRequest;
import com.huawei.bo.MsgBO;
import com.huawei.common.DBAccess;
import com.huawei.common.DBController;
import com.huawei.common.XMLController;

public class EsbExtInterface {
protected static Logger log = Logger.getLogger(EsbExtInterface.class); // 日志
private static DBController DBCDao = new DBController();

public DBController getDBCDao() {
return DBCDao;
}

public void setDBCDao(DBController dBCDao) {
DBCDao = dBCDao;
}

/**
* 获取ESB业务日志的sequence
*
* @return
*/
public static String getEsbSeq() {
return new DBController().getNextSeqId("seq_esblog");
}

/**
* 获取BPEL流程日志的sequence
*
* @return
*/
public static String getProcessSeq() {
return new DBController().getNextSeqId("seq_process");
}

/**
* XML报文解析入库操作,具体格式 EsbRequest oid isLongFlow businessLog businessId
* transactionId moduleId serviceNumber operator areaId startTime endTime
* status exceptionMsg errCode errType errInfo
*
* @param xml
* @return
*/
public static void writeEsb(String xml) {
log.debug("===========Log writeEsb begin================");
log.debug(xml);

if (xml == null || xml.trim().length() == 0) {
return;
}
// 1. 解析XML串赋值给一个BO对象EsbRequest,具体对象如上所示

EsbRequest request = new EsbRequest();

try {
new XMLController().pareseXmlToBO(xml, request);

if (null == request.getOid() || "".equals(request.getOid())
|| "0".equals(request.getOid())) {
request.setOid(getEsbSeq());
}

// request.setOid(System.currentTimeMillis() + "");
// request.setAreaId("999999");
// request.setBusinessId("Order");
// request.setStartTime("2011-04-27 12:11:11");
// request.setEndTime("2011-04-27 12:11:18");
// request.setErrCode("2001");
// request.setErrInfo("jlsjalfjaljfldjalflfjslfjlsjflsjlfjsj");
// request.setErrType("PRO");
// request.setEsb_version("R003");
// request.setIsLongFlow("0");
// request.setModuleId("SiebelCRM");
// request.setOperator("Test");
// request.setServiceNumber("05232133241");
// request.setStatus("1");
// request.setTransactionId(System.currentTimeMillis() + "");

// 2. 在DBController增加一个方法完成增加表记录,
// 表ESB_BUSINESS_LOG、ESB_BUSINESS_EXCEPTION
boolean flag = new DBController().updateESB(request);

// DBCDao.updateMsgLog();

// updateMsgLog();
log.info("Porcess writeEsb status:" + flag);
log.debug("===========Log writeEsb end================");
} catch (Exception e) {
e.printStackTrace();
log.error("Catch writeEsb Error:", e);
return;
}

}

你可能感兴趣的:(EsbExtInterface)