Commit c2e4379e authored by ngadkari's avatar ngadkari

branch code merged in head

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@198800 ce508802-f39f-4f6c-b175-0d175dae99d5
parent aeb8ab49
package ibase.webitm.ejb.fin.adv; package ibase.webitm.ejb.fin.adv;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.BankReconPrcLocal; import ibase.webitm.ejb.fin.adv.ReceiptAdvConf;
import ibase.webitm.ejb.fin.BankReconPrcRemote; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.ejb.fin.FinCommon;
//import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Properties;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@SuppressWarnings( { "unused" }) @Stateless
public class BankPiFprc extends ActionHandlerEJB implements Schedule // extends ProcessEJB implements public class BankPiFprc extends ActionHandlerEJB
// BankPiFprcLocal,BankPiFprcRemote{ implements BankPiFprcLocal, BankPiFprcRemote
{ {
E12GenericUtility genericUtility = new E12GenericUtility(); GenericUtility genericUtility = GenericUtility.getInstance();
FileOutputStream fos1 = null;
public String schedule(String scheduleParamXML) throws Exception,
ITMException {
ibase.utility.UserInfoBean userInfo = null;
String loginSiteCode = "", siteCode = "";
try {
Document dom = null;
String xtraParams = "", siteList = "";
int childNodeListLength = 0;
String childNodeName = null;
String voucher_date = "", sysDate = "";
String xmlString = "", xmlString2 = "", winName = "w_bankpif";
NodeList parentNodeList = null, childNodeList = null; public String actionHandler() throws RemoteException, ITMException
Node parentNode = null, childNode = null; {
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility return "";
.getDBDateFormat()); }
Node currDetail = null; public String actionHandler(String tranId, String xtraParams, String objContext)
int noOfParam = 0; throws RemoteException, ITMException
{
String xtraParam = "";
String retStr = "";
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try {
System.out.println(".......tranId......." + tranId + "objContext[" + objContext + "]xtraParams[" + xtraParams + "]");
retStr = pifprocess(tranId, xtraParams);
}
catch (Exception e)
{
System.out
.println("Exception :BankReconPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" +
e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
System.out public String pifprocess(String tranId, String xtraParams) throws RemoteException, ITMException
.println("scheduleParamXML>>>>[" + scheduleParamXML + "]"); {
userInfo = new ibase.utility.UserInfoBean(scheduleParamXML); System.out.println("@@@@@@@@@@@@@@@@@@@@ inside BankPifPrc Process@@@@@@@@@@@@@@@");
loginSiteCode = userInfo.getSiteCode(); Connection conn = null;
System.out.println("Log in Site code>>>>" + loginSiteCode + "]"); GenericUtility genericUtility = GenericUtility.getInstance();
xtraParams = "loginEmpCode=" + userInfo.getEmpCode() PreparedStatement pstmt = null; PreparedStatement pstmt1 = null,pstmtlogin=null,pstmtSite=null;
+ "~~loginCode=" + userInfo.getLoginCode() + "~~termId=" ResultSet rs = null; ResultSet rs1 = null,rslogin=null,rsSite=null;
+ userInfo.getRemoteHost() + "~~loginSiteCode=" String sql = "";
+ loginSiteCode; String activity_code = ""; String activity_descr = ""; String combocode = ""; String combodescr = ""; String floor = ""; String floor_descr = ""; String configunit = ""; String configunit_descr = "";
dom = genericUtility.parseString(scheduleParamXML); ConnDriver connDriver = null;
NodeList paramList = dom.getElementsByTagName("SCHEDULE"); String userId = ""; String loginEmpCode = ""; String chgTerm = "";
noOfParam = paramList.getLength(); String errString = "";
String errCode = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean isError = false;
boolean updateCnt=false;
double tempAMt = 0.0D;
double totAmt1 = 0.0D;
String orgAmt = "";
DistCommon disCommon = null;
String forcedFlag = "";
ReceiptAdvConf Conf = null;
File csvFile = null;
File destFile = null;
File filePath = null;
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
connDriver = new ConnDriver();
String confirm = "";
ArrayList al = new ArrayList();
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS"); int sheetNo = 0;
parentNode = parentNodeList.item(0); int cnt = 0;
childNodeList = parentNode.getChildNodes(); int successcnt = 0;
childNodeListLength = childNodeList.getLength(); double Value = 0.0D;
System.out.println(" CshildNodeListLength >>>>:-["
+ childNodeListLength + "]");
process(xmlString, xmlString2, winName, xtraParams);
} catch (Exception e) { Conf = new ReceiptAdvConf();
System.out PreparedStatement psmt = null;
.println("Exception :BankPiFprc :schedule :Exception :==>\n" Document dom1 = null;
+ e.getMessage()); String xmlParseStr = "";
e.printStackTrace(); NodeList parentNodeList = null;
throw new ITMException(e); NodeList childNodeList = null;
} finally { Node parentNode = null;
try { Node childNode = null;
if (fos1 != null) { String status = ""; String refNo = ""; String ediRef = ""; String amount = "",tranId1="";
fos1.close(); String description = ""; String message = "";
fos1 = null; int parentNodeListLength = 0;
} int detField1 = 0,counter=0,cnt1=0;
} catch (Exception e) { String retString = "",retString1="";
System.out.println("Exception >>>." + e.getMessage()); String refNum = "",Status1="",refNoOrg="";
String loginSite = "",siteCode="",msgNo="";
} Node arrNode = null;
} NamedNodeMap nodeMap = null;
return ""; boolean isFlag = true;
} try {
//actionHandler added by nandkumar gadkari on 18/03/19 //conn = connDriver.getConnectDB("DriverITM");
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException { conn = getConnection();
String xmlString = "", xmlString2 = "", winName = "w_bankpif"; connDriver = null;
try { conn.setAutoCommit(false);
process(xmlString, xmlString2, winName, xtraParams); loginSite = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginSite");
System.out.println("Login Site:["+loginSite+ "]");
} catch (Exception e) sql = "select ref_no ,edi_ref ,amount from bank_statement where STATUS = ? and stat_no is null and site_code in(select site_code from site where fin_entity =(select fin_entity from site where site_code=?)) ";
{ pstmt1 = conn.prepareStatement(sql);
e.printStackTrace(); pstmt1.setString(1, "M");
throw new ITMException(e); pstmt1.setString(2, loginSite);
} rs1 = pstmt1.executeQuery();
return ""; while (rs1.next())
} {
/* refNo = rs1.getString(1);
* public String process() throws RemoteException,ITMException { return ""; ediRef = rs1.getString(2);
* } amount = rs1.getString(3);
*/ // tranId1= rs1.getString(4);
// process() System.out.println("RefNumber" + refNo);
public String process(String xmlString, String xmlString2, System.out.println("Trim Refnumber[" + refNo.trim() + "]");
String windowName, String xtraParams) throws RemoteException, System.out.println("amount" + amount);
ITMException { System.out.println("ediRef" + ediRef);
System.out.println("xmlString:::::::::::" + xmlString); System.out.println("tranId1" + tranId1);
System.out.println("xmlString:::::::::::" + xmlString2); refNoOrg=refNo;
if (refNo.trim().length() >= 6)
String xtraParam = ""; {
String retStr = ""; refNum = refNo.trim();
Document detailDom = null; }
Document headerDom = null; else
// GenericUtility genericUtility = GenericUtility.getInstance(); {
try { System.out.println("Req Decimal");
if (xmlString != null && xmlString.trim().length() != 0) { refNum = getReqDecimal(refNo.trim());
headerDom = genericUtility.parseString(xmlString); System.out.println("RefNumber" + refNum);
} }
if (xmlString2 != null && xmlString2.trim().length() != 0) { System.out.println("@@@@@RefNumber" + refNum);
detailDom = genericUtility.parseString(xmlString2); System.out.println("#############RefNumber of Bank Statement" + refNoOrg);
} sql = "select count(*) from bank_statement where ref_no = ? and amount= ? and edi_ref = ?";
retStr = process(headerDom, detailDom, windowName, xtraParams); pstmt = conn.prepareStatement(sql);
} catch (Exception e) { pstmt.setString(1, refNoOrg);
System.out pstmt.setString(2, amount.trim());
.println("Exception :BankReconPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" pstmt.setString(3, ediRef.trim());
+ e.getMessage() + ":");
e.printStackTrace(); rs = pstmt.executeQuery();
throw new ITMException(e); if (rs.next())
} {
return retStr; cnt1 = rs.getInt(1);
} }
System.out.println("cnt1@@@@@@@@@@@@@@" +cnt1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt1 > 1)
{
sql="select tran_id from bank_statement where status = ? and ref_no= ? and amount=? and edi_ref = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "M");
pstmt.setString(2, refNoOrg);
pstmt.setString(3, amount.trim());
pstmt.setString(4, ediRef.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
tranId1= rs.getString(1);
System.out.println("tranId1" + tranId1);
}
rs.close();
rs = null;
pstmt.close();
sql = "delete from bank_statement where ref_no=? and edi_ref=? and amount=? and tran_id != ? and status = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNoOrg);
pstmt.setString(2, ediRef.trim());
pstmt.setString(3, amount.trim());
pstmt.setString(4, tranId1.trim());
pstmt.setString(5, "M");
int i = pstmt.executeUpdate();
System.out.println("Delete Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
sql = "select count(1) from receipt where ref_no = ? and chq_amt= ? and entry_batch_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNum.trim());
pstmt.setString(2, amount.trim());
pstmt.setString(3, ediRef.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
System.out.println("sql@@" + sql + "count-->" + cnt);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
public String process(Document headerDom, Document detailDom, if (cnt > 0)
String windowName, String xtraParams) throws RemoteException, {
ITMException { System.out.println("@@ Count>0");
sql = "select tran_id,confirmed,site_code from receipt where ref_no = ? and chq_amt=? ";
System.out.println("@@@@@@@@@@@@@@@@@@@@ inside BankPifRtgsprc@@@@@@@@@@@@@@@"); pstmt = conn.prepareStatement(sql);
Connection conn = null; pstmt.setString(1, refNum.trim());
// GenericUtility genericUtility = GenericUtility.getInstance(); pstmt.setString(2, amount.trim());
PreparedStatement pstmt = null; rs = pstmt.executeQuery();
ResultSet rs = null; if (rs.next())
String sql = ""; {
String activity_code = "", activity_descr = "", combocode = "", combodescr = "", floor = "", floor_descr = "", configunit = "", configunit_descr = ""; tranId = rs.getString(1);
ConnDriver connDriver = null; confirm = rs.getString(2);//rs.getString("confirmed") == null ? "N" : rs.getString("confirmed");
String tranId = "", userId = "", loginEmpCode = "", chgTerm = ""; siteCode=checkNull(rs.getString(3));
String errString = ""; }
String errCode = ""; if(confirm == null || confirm.trim().length() ==0)
ValidatorEJB validatorEJB = null; {
ITMDBAccessEJB itmDBAccessEJB = null; confirm="N";
boolean isError = false; }
double tempAMt = 0; System.out.println("confirm[" + confirm + "] tranID[" + tranId + "] Site COde["+siteCode+"]");
double totAmt1 = 0; rs.close();
String orgAmt = ""; rs = null;
DistCommon disCommon = null; pstmt.close();
String forcedFlag = ""; pstmt = null;
ReceiptAdvConf Conf = null;
File csvFile = null; String finLogin="",finSite="";
File destFile = null; sql="select fin_entity from site where site_code=?";
File filePath=null; pstmtlogin = conn.prepareStatement(sql);
itmDBAccessEJB = new ITMDBAccessEJB(); pstmtlogin.setString(1,loginSite);
validatorEJB = new ValidatorEJB(); rslogin = pstmtlogin.executeQuery();
connDriver = new ConnDriver(); if (rslogin.next())
String confirm = ""; {
ArrayList al = new ArrayList(); finLogin=checkNull(rslogin.getString(1));
String row; }
String fileName; rslogin.close();
int sheetNo = 0; rslogin = null;
int cnt = 0; pstmtlogin.close();
int successcnt =0; pstmtlogin = null;
double Value=0; System.out.println("finLogin["+finLogin+"]");
Conf = new ReceiptAdvConf();
String InsNo = ""; sql="select fin_entity from site where site_code=?";
String totAmt = ""; pstmtSite = conn.prepareStatement(sql);
String batchNo = ""; pstmtSite.setString(1,siteCode);
String totalAmt = ""; rsSite = pstmtSite.executeQuery();
PreparedStatement psmt = null; if (rsSite.next())
Document dom1 = null; {
String xmlParseStr = ""; finSite=checkNull(rsSite.getString(1));
NodeList parentNodeList = null; }
NodeList childNodeList = null; System.out.println("finSite["+finSite+"]");
Node parentNode = null; rsSite.close();
Node childNode = null; rsSite = null;
String description="",shDescr="",message="",Error="", fileName1 =""; pstmtSite.close();
int parentNodeListLength=0; pstmtSite = null;
int detField1=0; System.out.println("!(finLogin.trim()["+finLogin.trim()+"] .equals(finSite.trim()["+finSite.trim()+"]");
String retString=""; if(!(finLogin.trim().equals(finSite.trim())))
try {
/*conn = connDriver.getConnectDB("DriverITM");
connDriver = null;*/ //commented and added getConnection by nandkumar gadkari on 18/03/19
conn = getConnection();
conn.setAutoCommit(false);
filePath = new File(CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default" + File.separator+"deploy"+File.separator+"updatexls");//String to file
System.out.println(":::::::file Path" + filePath);
File[] files = filePath.listFiles();
for(File file : files)
{ {
if(file.isFile()) System.out.println("finLogin"+finLogin);
{ System.out.println("finSite"+finSite);
fileName1 = file.getName(); errString = itmDBAccessEJB.getErrorString("", "NORECFND", userId, "", conn);
if(fileName1.endsWith(".xls") || fileName1.endsWith(".XLS"))//xls return errString;
{
System.out.println("FileName:::"+fileName1);
al = readExcelFile(file.getAbsolutePath(), sheetNo);
System.out.println("call read excel File" + al.size());
File Writefile = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default"+ File.separator+"deploy"+File.separator+"updatexls"+File.separator+"Bank.txt");
if(Writefile.createNewFile())
{
System.out.println(Writefile+" File Created");
}else
System.out.println("File "+Writefile+" already exists");
FileWriter fw = new FileWriter(Writefile.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
for (int i = 1; i < al.size(); i++)
{
row = al.get(i).toString();
row = row.replace("[", "");
row = row.replace("]", "");
String col[] = row.split(",");
batchNo = col[2].trim();
InsNo = col[11].trim();
totAmt = col[13].trim();
System.out.println("Batch Number is " + batchNo);
if(batchNo.contains("."))
{
Value= Double.parseDouble(batchNo);
batchNo = BigDecimal.valueOf(Value).toPlainString();
System.out.println("Batch Number is"+batchNo);
}
System.out.println("Total Amount is" + totAmt);
System.out.println("Instrument Number is" + InsNo);
int Amt = Integer.parseInt(totAmt.substring(totAmt.indexOf(".") + 1, totAmt.length()));
System.out.println("Amt" + Amt);
if (!(Amt > 0))
{
totAmt = totAmt.substring(0, totAmt.indexOf("."));
}
System.out.println("Amt" + totAmt);
totAmt = totAmt != null && totAmt.trim().length() > 0 ? totAmt.trim() : "0";
totalAmt = getReqDecimal(totAmt);
System.out.println("Total AMount:"+totalAmt);
if(InsNo.contains("."))
{
int insNO = Integer.parseInt(InsNo.substring(InsNo.indexOf(".") + 1, InsNo.length()));
System.out.println("Instrument" + insNO);
if (!(insNO > 0))
{
InsNo = InsNo.substring(0, InsNo.indexOf("."));
}
}
System.out.println("Instrument Number" + InsNo);
sql = "select count(1) from receipt where ref_no = ? and chq_amt= ? and entry_batch_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, InsNo);
pstmt.setString(2, totalAmt);
pstmt.setString(3, batchNo);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0)
{
System.out.println("@@ Count>0");
sql = "select tran_id,confirmed from receipt where ref_no = ? and chq_amt=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, InsNo);
pstmt.setString(2, totalAmt);
rs = pstmt.executeQuery();
if (rs.next())
{
tranId = rs.getString(1);
confirm = rs.getString("confirmed") == null ? "N" : rs.getString("confirmed");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (confirm != null && confirm.equalsIgnoreCase("N"))
{
errString = Conf.confirm(tranId, xtraParams, forcedFlag);
if (errString == null || errString.trim().length() == 0)
{
System.out.println("Enter confirm COndition");
System.out.println("The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + " is Sucessfully Confirmed");
String content = "The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + " is Sucessfully Confirmed";
bw.write(content);
bw.newLine();
System.out.println("Write confirmed");
successcnt++;
System.out.println("Sucess Count Y is:"+successcnt);
}
else
{
dom1 = parseString(errString);
System.out.println("dom1>>>>>: "+dom1);
parentNodeList = dom1.getElementsByTagName("error");
parentNodeListLength = parentNodeList.getLength();
for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++)
{
parentNode = parentNodeList.item(lineCount);
childNodeList = parentNode.getChildNodes();
for (detField1 = 0; detField1 < childNodeList.getLength(); detField1++)
{
childNode = childNodeList.item(detField1);
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("message") )
{
message = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>message : "+message);
}
else if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("description") )
{
description = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>Description : "+description);
}
}
retString=""+message+":"+description+"";
System.out.println("After Parsing Return String>>>>"+retString);
}
System.out.println("The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + ":"+retString + " is Unconfirmed");
String content = "The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo +" :"+retString + " is Unconfirmed";
bw.write(content);
System.out.println("Write Unconfirmed");
bw.newLine();
}
}
else
{
System.out.println("Enter in else Already confirm COndition");
System.out.println("The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + " is Already Sucessfully Confirmed");
String content = "The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + " is Already Sucessfully Confirmed";
bw.write(content);
bw.newLine();
System.out.println("Write Already confirmed");
successcnt++;
System.out.println("Sucess COunt Y is:"+successcnt);
}
System.out.println("Complete Process");
}
else
{
System.out.println("The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + " is not Present in Statement");
String content = "The Record of Receipt tran_id : "+ tranId + " and Reference Number : " + InsNo + " and Amount : " + totalAmt + " and Slip Number : " + batchNo + " is not Present in Statement";
bw.write(content);
bw.newLine();
System.out.println("Write Already confirmed");
}
} }
else
bw.close();
fw.close();
System.out.println("List size is"+al.size());
System.out.println("Counter size is"+successcnt);
if(al.size() - 1 == successcnt)
{ {
destFile = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default" System.out.println("MAtch SIte Code");
+ File.separator+"deploy"+File.separator+"BankStatement");
boolean success = csvFile.renameTo(new File(destFile, csvFile.getName())); /* if(counter > 0)
{
if (success) { sql = "select count(*) from bank_statement where ref_no = ? and amount= ? and edi_ref = ?";
System.out.println("File was successfully moved.\n"); pstmt = conn.prepareStatement(sql);
} else { pstmt.setString(1, refNum.trim());
System.out.println("File was not successfully moved.\n"); pstmt.setString(2, amount.trim());
} pstmt.setString(3, ediRef.trim());
rs = pstmt.executeQuery();
} if (rs.next())
} {
} cnt1 = rs.getInt(1);
} }
} catch (Exception e) { System.out.println("cnt1@@@@@@@@@@@@@@" +cnt1);
System.out.println("Exception: confirm method ..> " rs.close();
+ e.getMessage()); rs = null;
isError = true; pstmt.close();
errCode = "VTTRNNCNF"; // exception so cannot confirm pstmt = null;
errString = itmDBAccessEJB.getErrorString("", errCode, userId); if (cnt1 > 1)
throw new ITMException(e); {
} finally { sql = "select STATUS from bank_statement where ref_no = ? and amount= ? and edi_ref = ?";
if (conn != null) { pstmt = conn.prepareStatement(sql);
try { pstmt.setString(1, refNum.trim());
if (isError) { pstmt.setString(2, amount.trim());
conn.rollback(); pstmt.setString(3, ediRef.trim());
System.out.println("confirm: Connection Rollback"); rs = pstmt.executeQuery();
} else { if (rs.next())
conn.commit(); {
System.out.println("confirm: Connection Commit"); Status1 = rs.getString(1);
} }
conn.close(); System.out.println( "Status1@@@@@" + Status1);
conn = null; rs.close();
} catch (Exception e) { rs = null;
e.printStackTrace(); pstmt.close();
} pstmt = null;
} if("M".equals(Status1))
{
sql = "delete from bank_statement where ref_no=? and edi_ref=? and amount=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo.trim());
pstmt.setString(2, ediRef.trim());
pstmt.setString(3, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
}
}*/
if ((confirm != null) && (confirm.equalsIgnoreCase("N")))
{
retString1 = Conf.confirm(tranId, xtraParams, forcedFlag);
if ((retString1.contains("VTCICONF3")) || (retString1.trim().length() == 0))
{
System.out.println("retString1.trim().length() == 0["+retString1+"]");
String remark = "Receipt No - " + tranId + ":confirm Successfully";
System.out.println("Ref Number" + refNo.trim());
sql = "update bank_statement set status=?,remarks=? where ref_no=? and edi_ref=? and amount=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "Z");
pstmt.setString(2, remark);
pstmt.setString(3, refNo.trim());
pstmt.setString(4, ediRef.trim());
pstmt.setString(5, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
else
{
System.out.println("Recent retString1 !=null["+retString1+"]");
dom1 = new ValidatorEJB().parseString(retString1);
arrNode = dom1.getElementsByTagName("error").item(0);
nodeMap = arrNode.getAttributes();
msgNo = nodeMap.getNamedItem("id").getNodeValue().trim();
System.out.println("msgno["+msgNo+"]");
System.out.println(" retString1 dom1>>>>>: " + dom1);
parentNodeList = dom1.getElementsByTagName("error");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength["+parentNodeListLength+"]");
for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++)
{
parentNode = parentNodeList.item(lineCount);
childNodeList = parentNode.getChildNodes();
System.out.println("childNodeList["+childNodeList+"]");
for (detField1 = 0; detField1 < childNodeList.getLength(); detField1++)
{
childNode = childNodeList.item(detField1);
if ((childNode != null) && (childNode.getFirstChild() != null) &&
(childNode.getNodeName().equalsIgnoreCase("message")))
{
message = childNode.getFirstChild().getNodeValue().trim();
System.out.println(">>>message : " + message);
} else {
if ((childNode == null) || (childNode.getFirstChild() == null) ||
(!childNode.getNodeName().equalsIgnoreCase("description")))
continue;
description = childNode.getFirstChild().getNodeValue().trim();
System.out.println(">>>Description : " + description);
}
}
retString = "Rcp No-"+ tranId +":"+msgNo+":"+message;
if(retString.length() > 60)
{
int retLength=retString.length();
int extraLenth= retLength-60;
int totalLength=retLength-extraLenth;
System.out.println("retLength["+retLength+"]");
System.out.println("extraLenth["+extraLenth+"]");
System.out.println("totalLength["+totalLength+"]");
retString =retString.substring(0,totalLength);
System.out.println("retString Grater than then Remark is["+retString+"]");
}
/* else
{
retString = "Rcp No-"+ tranId +":"+msgNo+":"+message;
}*/
System.out.println("retString Final Bnak Pif Process["+retString+"]");
}
System.out.println("Ref Number" + refNo.trim());
System.out.println("if Error ---> Update Status M");
sql = "update bank_statement set status=?,remarks=? where ref_no=? and edi_ref=? and amount=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "M");
pstmt.setString(2, retString);
pstmt.setString(3, refNo.trim());
pstmt.setString(4, ediRef.trim());
pstmt.setString(5, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
}
else
{
String remark = "Receipt No -" + tranId + ":Already confirm";
System.out.println("Ref Number" + refNo.trim());
System.out.println("Added Delete Statement");
// sql = "update bank_statement set status=?,remarks=? where ref_no=? and edi_ref=? and amount=?";
sql = "delete from bank_statement where ref_no=? and edi_ref=? and amount=? and status=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNo.trim());
pstmt.setString(2, ediRef.trim());
pstmt.setString(3, amount.trim());
pstmt.setString(4, "M");
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
System.out.println("Already Process");
} }
return errString; }
} else
{
public Document parseString(String xsdString) System.out.println("Else no Found Record Condition");
{ retString="No Data Found";
Document dom = null; sql = "update bank_statement set status=?,remarks=? where ref_no=? and edi_ref=? and amount=?";
try pstmt = conn.prepareStatement(sql);
{ pstmt.setString(1, "M");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); pstmt.setString(2, retString);
dbf.setNamespaceAware(true); pstmt.setString(3, refNo.trim());
dbf.setIgnoringComments(true); pstmt.setString(4, ediRef.trim());
DocumentBuilder db = dbf.newDocumentBuilder(); pstmt.setString(5, amount.trim());
OutputStreamWriter errorWriter = new OutputStreamWriter(System.err, "UTF-8"); int i = pstmt.executeUpdate();
ByteArrayInputStream baos = new ByteArrayInputStream(xsdString.getBytes()); System.out.println("Not Data found @@@@@@@@@@@@@@@@@@@" + i);
dom = db.parse(baos); pstmt.close();
} pstmt = null;
catch (Exception e) // errString = itmDBAccessEJB.getErrorString("", "VTNODATA", userId, "", conn);
{ }
System.out.println("Error :" +e); updateCnt=true;
} counter++;
return dom; }
rs1.close();
} rs1 = null;
public ArrayList readExcelFile(String fileName, int sheetNo) { pstmt1.close();
System.out.println("----in readExcelFile1 method CNT.................."); pstmt1 = null;
String value = null; System.out.println("CHEK isFlag:::["+isFlag+"]");
int headerRowCnt = -1, detailRowCnt = -1; if (isFlag == false)
ArrayList cellArrayLisstHolder = new ArrayList(); {
System.out.println("PROCESS FAILUER");
errString="VTPRCERR";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
}
if(!updateCnt)
{
errString = itmDBAccessEJB.getErrorString("", "NORECFND", userId, "", conn);
System.out.println("errString BankPif Count" + errString);
}
if ((errString == null) || (errString.trim().length() == 0))
{
errCode = "VTBPRC1";
errString = itmDBAccessEJB.getErrorString("", errCode, userId);
}
else
{
String str1 = errString;
return str1;
}
try { }
FileInputStream myInput = new FileInputStream(fileName); catch (Exception e)
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput); {
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem); System.out.println("Exception: Process method ..> " + e.getMessage());
HSSFSheet mySheet = myWorkBook.getSheetAt(sheetNo); }
Sheet sheet = myWorkBook.getSheetAt(sheetNo); finally
for (Row row : sheet) { {
for (Cell cell : row) { if (conn != null)
if (cell.getCellType() != Cell.CELL_TYPE_BLANK) { try {
if (cell.getCellType() != Cell.CELL_TYPE_STRING if (isError) {
|| cell.getStringCellValue().length() > 0) { conn.rollback();
if (sheetNo == 1) System.out.println("Process: Connection Rollback");
headerRowCnt++; } else {
else if (sheetNo == 2) conn.commit();
detailRowCnt++; System.out.println("Process: Connection Commit");
break; }
} conn.close();
} conn = null;
} } catch (Exception e) {
} e.printStackTrace();
}
}
if (conn != null) {
try {
if (isError) {
conn.rollback();
System.out.println("Process: Connection Rollback");
} else {
conn.commit();
System.out.println("Process: Connection Commit");
}
conn.close();
conn = null;
} catch (Exception e) {
e.printStackTrace();
}
}
for (Row row : mySheet) { return errString;
ArrayList cellStoreArrayList = new ArrayList(); }
for (int cn = 0; cn < row.getLastCellNum(); cn++) {
Cell cell = row.getCell(cn, Row.CREATE_NULL_AS_BLANK);
value = cell.toString();
if (value.contains(",")) {
value = value.replace(",", "");
}
cellStoreArrayList.add(value);
}
cellArrayLisstHolder.add(cellStoreArrayList);
} public String getReqDecimal(String chqAmt)
{
} catch (Exception e) { DecimalFormat df = new DecimalFormat("000000");
e.printStackTrace(); int num = Integer.parseInt(chqAmt);
String refAmt = df.format(num);
System.out.println("@@@@@" + refAmt);
return refAmt;
}
private String checkNull(String input) {
if (input == null) {
input = "";
} }
return cellArrayLisstHolder; return input;
}
public String getReqDecimal(String chqAmt)
{
DecimalFormat df = new DecimalFormat("000000");
int num= Integer.parseInt(chqAmt);
String refAmt = df.format(num);
System.out.println("@@@@@"+refAmt);
return refAmt;
}
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
} }
}
@Override \ No newline at end of file
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
}
}
package ibase.webitm.ejb.fin.adv;
import ibase.webitm.ejb.ActionHandlerLocal;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local // added for ejb3
public interface BankPiFprcLocal extends ActionHandlerLocal
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String tranId, String objContext, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin.adv;
import ibase.webitm.ejb.ActionHandlerLocal;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote // added for ejb3
public interface BankPiFprcRemote extends ActionHandlerLocal
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String tranId, String objContext, String xtraParams) throws RemoteException,ITMException ;
}
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