Commit 0f13ee8f authored by vdhoble's avatar vdhoble

By Sagar Mane - Auto Fund Transfer


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98977 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0915d5ec
/********************************************************
Title : AutoFundTrfSch[F15GSUN011]
Date : 21/OCT/15
Developer: Sagar M.
********************************************************/
package ibase.webitm.ejb.fin;
import ibase.scheduler.utility.interfaces.Schedule;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import java.io.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.w3c.dom.*;
import javax.xml.rpc.ParameterMode;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.utility.E12GenericUtility;
import ibase.utility.CommonConstants;
import ibase.utility.UserInfoBean;
import ibase.system.config.*;
import java.text.SimpleDateFormat;
public class AutoFundTrfSch implements Schedule
{
File filePtr ;
File logDir ;
FileOutputStream fos1 = null;
String logDirName = "";
String startDateStr = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
E12GenericUtility e12GenericUtility = new E12GenericUtility();
@Override
public String schedule(String scheduleParamXML)throws Exception
{
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql="";
String siteCodes[] = null;
String tranId="";
String currAppdate ="";
String valuexmlString="",xmlTabString="";
String retString="";
String siteCodeFrom="",siteCodeTo="",bankCode="",bankGroupCode="";
String bankCodeFrom="00", bankCodeTo="ZZ",receiptMode="",processType="",autoConfirm="",rcpDishnr="";
String siteFromDescr="", siteToDescr="", bankFromDescr="", bankToDescr="", strToWriteHead="";
String receiptModeVal="",processTypeVal="",autoConfirmVal="",rcpDishnrVal="";
String loginSiteCode="";
String strToWrite="",logFileInit="";
String currTime = null;
String finSiteCodeFrom="";
String xtraParams = "",source="";
String childNodeName = null;
String autoConfirmValLog="",rcpDishnrValLog="";
String errString ="";
int noOfParam=0,finSiteCount=0,receiptModecount=0;
int childNodeListLength = 0;
ArrayList<String> receiptModeList= null;
java.sql.Timestamp currDate = null;
Document dom = null;
NodeList paramList=null;
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null,childNode = null;
ITMDBAccessEJB itmDBAccessEJB = null;
UserInfoBean userInfo = null;
SimpleDateFormat sdfApp=null,sdfDB=null;
try
{
System.out.println(">>>AutoFundTrfSch schedule:"+scheduleParamXML);
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
sdfDB = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
sdfApp= new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
currTime = sdfDB.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
//StringBuffer recTabStrBuff = new StringBuffer();
dom= e12GenericUtility.parseString(scheduleParamXML);
paramList = dom.getElementsByTagName( "SCHEDULE" );
noOfParam = paramList.getLength();
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println(">>>childNodeListLength:"+ childNodeListLength);
System.out.println(">>>Number of Param:"+ noOfParam);
//Logic for getting Scheduler Parameter
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName))
{
if(ctr==0)
{
autoConfirm = childNode.getFirstChild().getNodeValue();
}
if(ctr==1)
{
rcpDishnr = childNode.getFirstChild().getNodeValue();
}
}
}
System.out.println(">>>Scheduler Param autoConfirm:"+autoConfirm);
System.out.println(">>>Scheduler Param rcpDishnr:"+rcpDishnr);
//Set Auto Confirm Drop down value as per process window of Auto Fund transfer
if(autoConfirm== null || autoConfirm.trim().length()==0)
{
autoConfirmVal= "0";
autoConfirmValLog="N";
}
else if(autoConfirm!= null && autoConfirm.trim().length() > 0)
{
if("Yes".equalsIgnoreCase(autoConfirm))
{
autoConfirmVal="1";
autoConfirmValLog="Y";
}else
{
autoConfirmVal="0";
autoConfirmValLog="N";
}
}
//Set Consider RcpDishnr Drop down value as per process window of Auto Fund transfer
if(rcpDishnr== null || rcpDishnr.trim().length()==0)
{
rcpDishnrVal= "0";
rcpDishnrValLog="N";
}
else if(rcpDishnr!= null && rcpDishnr.trim().length() > 0)
{
if("Yes".equalsIgnoreCase(rcpDishnr))
{
rcpDishnrVal="1";
rcpDishnrValLog="Y";
}
else
{
rcpDishnrVal="0";
rcpDishnrValLog="N";
}
}
//Call intializingLog() for Generate log file for Auto fund Transfer
logFileInit= intializingLog("auto_fund_trf_log");
System.out.println(">>>intializingLog logFileInit:"+logFileInit);
FinCommon finCommon=new FinCommon();
itmDBAccessEJB = new ITMDBAccessEJB();
userInfo = new UserInfoBean( scheduleParamXML );
loginSiteCode = userInfo.getSiteCode();
System.out.println(">>>userInfo:"+userInfo);
System.out.println(">>>userInfo loginSiteCode:"+loginSiteCode);
//xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode;
xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode+"~~loginEmpCode="+userInfo.getEmpCode();
System.out.println(">>xtraParams:"+xtraParams);
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = sdfApp.format(currDate);
//Get Comma separated Site Code from Finparm
finSiteCodeFrom = finCommon.getFinparams("999999", "AUTO_FUND_TRF_SITES", conn);
//Add Receipt Mode to ArrayList which is available in Auto Fundtransfer Process Screen..
receiptModeList= new ArrayList<String>();
receiptModeList.add("Electronic");
receiptModeList.add("Other");
System.out.println(">>receiptModeList:"+receiptModeList);
System.out.println(">>>>finSiteCodeFrom:"+finSiteCodeFrom);
if(!"NULLFOUND".equals(finSiteCodeFrom) && finSiteCodeFrom.trim().length() > 0)
{
siteCodes= finSiteCodeFrom.split(",");
for ( finSiteCount = 0; finSiteCount < siteCodes.length; finSiteCount++)
{
System.out.println(">>In for finSiteCount:"+ finSiteCount);
siteCodeFrom="";
bankCode="";
bankGroupCode="";
siteCodeTo="";
siteCodeFrom= siteCodes[finSiteCount];
System.out.println(">>>siteCodeFrom:"+siteCodeFrom);
//logic for getting Site Code To
sql = "select bank_code from site where site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCodeFrom);
rs=pstmt.executeQuery();
if(rs.next())
{
bankCode= rs.getString("bank_code");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println(">>bankCode:"+bankCode);
if(bankCode!=null && bankCode.trim().length() > 0)
{
sql = "select group_code from bank where bank_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs=pstmt.executeQuery();
if(rs.next())
{
bankGroupCode= rs.getString("group_code");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println(">>bankGroupCode:"+bankGroupCode);
if(bankGroupCode!=null && bankGroupCode.trim().length() > 0)
{
sql = "select site_code from bank where bank_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankGroupCode);
rs=pstmt.executeQuery();
if(rs.next())
{
siteCodeTo= rs.getString("site_code");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println(">>siteCodeTo:"+siteCodeTo);
if(siteCodeTo!= null && siteCodeTo.trim().length() > 0)
{
siteFromDescr= findValue(conn,"descr", "site", "site_code", siteCodeFrom);
siteToDescr= findValue(conn,"descr", "site", "site_code", siteCodeTo);
if(receiptModeList.size() > 0)
{
for(receiptModecount= 0; receiptModecount < receiptModeList.size(); receiptModecount++)
{
System.out.println(">>>receiptModeList receiptModecount:"+receiptModecount);
startDateStr = sdfDB.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
receiptMode= receiptModeList.get(receiptModecount);
System.out.println(">>>receiptMode:"+receiptMode);
if("Electronic".equals(receiptMode))
{
receiptModeVal="E";
processTypeVal="R"; //Receipt Wise
}
else if("Other".equals(receiptMode))
{
receiptModeVal="O";
processTypeVal="P"; //PaySlip Wise
}
strToWrite="";
strToWriteHead="Site Code From:"+siteCodeFrom+" Site Code To:"+siteCodeTo+" Bank Code From:"+bankCodeFrom+" Bank Code To:"+bankCodeTo+" Uptill Date:"+currAppdate+" Receipt Mode:"+receiptModeVal+" Process Type:"+processTypeVal+" Auto Confirm:"+autoConfirmValLog+" Consider RcpDishnr:"+ rcpDishnrValLog +"\n";
strToWrite=strToWrite + strToWriteHead;
//strToWrite=strToWrite+startDateStr+",";
//Prepare tab order xmlData for call the existing process logic for Auto Fund Transfer using scheduler.
xmlTabString="";
StringBuffer recTabStrBuff = new StringBuffer();
recTabStrBuff.append(siteCodeFrom).append("\t");
recTabStrBuff.append(siteCodeTo).append("\t");
recTabStrBuff.append(bankCodeFrom).append("\t");
recTabStrBuff.append(bankCodeTo).append("\t");
recTabStrBuff.append(currAppdate).append("\t");
recTabStrBuff.append(processTypeVal).append("\t");
recTabStrBuff.append(autoConfirmVal).append("\t");
recTabStrBuff.append(rcpDishnrVal).append("\t");
recTabStrBuff.append(siteFromDescr).append("\t");
recTabStrBuff.append(siteToDescr).append("\t");
recTabStrBuff.append(bankFromDescr).append("\t");
recTabStrBuff.append(bankToDescr).append("\t");
recTabStrBuff.append(receiptModeVal).append("\t");
xmlTabString = recTabStrBuff.toString();
System.out.println(">>>xmlTabString:"+xmlTabString);
if(xmlTabString != null && xmlTabString.trim().length() > 0)
{
retString = autoFundTrfProcess("receipt_fundtransfer",loginSiteCode, xmlTabString, xtraParams,conn);
System.out.println(">>>>autoFundTrfProcess() retString:"+retString); //VPSUCC1
if((retString != null ) && (retString.indexOf("VPSUCC1") > -1))
{
conn.commit();
System.out.println(">>>>After Commit Auto Fundtransfer transaction Successfully<<<");
}
else
{
conn.rollback();
System.out.println(">>>>After rollbak Auto Fundtransfer transaction Failed<<<<");
}
strToWrite = strToWrite + retString+"\r\n\r\n";
System.out.println(">>>Before Write to fos1 strToWrite:"+strToWrite);
fos1.write(strToWrite.getBytes());
}
}//end for loop receiptModeList
}
}
}
}
} //end for loop siteCodes array
}
else
{
errString = itmDBAccessLocal.getErrorString("","VTATFNDFIN","");
strToWrite = errString +"\r\n\r\n";
System.out.println(">>>Finparm Not Defined"+strToWrite);
fos1.write(strToWrite.getBytes());
}
}
catch(Exception e)
{
System.out.println(">>>>>>>In catch:");
try
{
if(conn!=null)
{
conn.rollback();
}
e.printStackTrace();
}
catch(Exception e1)
{
System.out.println( "Exception"+e1.getMessage());
}
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println(">>Exception"+e.getMessage());
}
}
return "";
}
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
// autoFundTrfProcess() method for call the existing PB Component of Auto Fund Transfer process
private String autoFundTrfProcess(String objName, String siteCode,String xmlString, String xtraParams, Connection conn) throws ITMException, SQLException
{
System.out.println(">>>>>>>In autoFundTrfProcess <<<<<<<");
String methodName = "",compName = "",compType="",retString = "",serviceCode = "",serviceURI = "",actionURI = "";
String dummy="";
String sql;
PreparedStatement pstmt=null;
ResultSet rs = null;
try
{
methodName = "gbf_process";
actionURI = "http://NvoServiceurl.org/" + methodName;
System.out.println("Action URI>>>>>"+actionURI);
sql = "SELECT SERVICE_CODE,COMP_NAME,COMP_TYPE FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'process'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,objName);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceCode = rs.getString("SERVICE_CODE");
compName = rs.getString("COMP_NAME");
compType = rs.getString("COMP_TYPE");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("serviceCode = "+serviceCode+" compName "+compName+" compType "+compType);
sql = "SELECT SERVICE_URI FROM SYSTEM_EVENT_SERVICES WHERE SERVICE_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,serviceCode);
rs = pstmt.executeQuery();
if ( rs.next() )
{
serviceURI = rs.getString("SERVICE_URI");
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("serviceURI = "+serviceURI+" compName = "+compName);
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(serviceURI));
call.setOperationName( new javax.xml.namespace.QName("http://NvoServiceurl.org", methodName ) );
call.setUseSOAPAction(true);
call.setSOAPActionURI(actionURI);
Object[] aobj = new Object[5];
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_type"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "component_name"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "tab_xml_data_1"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "dummy"), XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter( new javax.xml.namespace.QName("http://NvoServiceurl.org", "xtra_params"), XMLType.XSD_STRING, ParameterMode.IN);
aobj[0] = new String(compType);
aobj[1] = new String(compName);
aobj[2] = new String(xmlString);
aobj[3] = new String(dummy);
aobj[4] = new String(xtraParams);
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println(">>>>PB Component return retString:"+retString);
}
catch(Exception e)
{
System.out.println(">>>>>>>>In catch:");
e.printStackTrace();
System.out.println(e);
}
return retString;
}//end autoFundTrfProcess() method
//intializingLog() method added for to Generate log file
private String intializingLog(String fileName)
{
String log="";
String strToWrite = "";
String currTime = null;
try
{
System.out.println(">>>In intializingLog() fileName:"+fileName);
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat());
try
{
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString();
currTime = currTime.replaceAll("-","");
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".csv";
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName);
//strToWrite="\"TRANID\",\"START TIME\",\"END TIME\",\"STATUS\"\r\n";
//fos1.write(strToWrite.getBytes());
log ="IntializingLog_Successesfull";
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
e.printStackTrace();
}
startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
fos1.write(("Auto Fund Transfer Process Started At: " + startDateStr +"\r\n").getBytes());
}
catch(Exception e)
{
System.out.println("Exception []::"+e.getMessage());
log="IntializingLog_Failed";
e.printStackTrace();
}
return log;
}//end intializingLog() method
//findValue() method added for get value dynamic
private String findValue(Connection conn, String columnName ,String tableName, String columnName2, String value) throws ITMException, RemoteException
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in findValue ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from findValue " + findValue);
return findValue;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment