Commit 1f2e1f1f authored by ngadkari's avatar ngadkari

branch code merged in head

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@198802 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c2e4379e
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.PrintStream;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
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.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.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
@SuppressWarnings({"unused"}) @Stateless
public class BankPifRtgsprc extends ActionHandlerEJB implements Schedule // extends ProcessEJB implements public class BankPifRtgsprc extends ActionHandlerEJB
// BankPiFprcLocal,BankPiFprcRemote{
{
E12GenericUtility genericUtility = new E12GenericUtility();
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;
Node parentNode = null, childNode = null;
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility
.getDBDateFormat());
Node currDetail = null;
int noOfParam = 0;
System.out
.println("scheduleParamXML>>>>[" + scheduleParamXML + "]");
userInfo = new ibase.utility.UserInfoBean(scheduleParamXML);
loginSiteCode = userInfo.getSiteCode();
// System.out.println("@V@ IntializingLog "+
// intializingLog("Chnl_Ptr_VouchConf_log"));
System.out.println("Log in Site code>>>>" + loginSiteCode + "]");
xtraParams = "loginEmpCode=" + userInfo.getEmpCode()+ "~~loginCode=" + userInfo.getLoginCode() + "~~termId="
+ userInfo.getRemoteHost() + "~~loginSiteCode="
+ loginSiteCode;
dom = genericUtility.parseString(scheduleParamXML);
NodeList paramList = dom.getElementsByTagName("SCHEDULE");
noOfParam = paramList.getLength();
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS"); {
parentNode = parentNodeList.item(0); GenericUtility genericUtility = GenericUtility.getInstance();
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println(" CshildNodeListLength >>>>:-["
+ childNodeListLength + "]");
processRtgs(xmlString, xmlString2, winName, xtraParams);
} catch (Exception e) {
System.out
.println("Exception :BankPiFprc :schedule :Exception :==>\n"
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
} finally {
try {
if (fos1 != null) {
fos1.close();
fos1 = null;
}
} catch (Exception e) {
System.out.println("Exception >>>." + e.getMessage());
}
}
return "";
}
//actionHandler added by nandkumar gadkari on 18/03/19
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException, ITMException {
String xmlString = "", xmlString2 = "", winName = "w_bankpif";
try {
processRtgs(xmlString, xmlString2, winName, xtraParams);
} catch (Exception e) public String actionHandler() throws RemoteException, ITMException
{ {
e.printStackTrace();
throw new ITMException(e);
}
return ""; return "";
} }
/*
* public String process() throws RemoteException,ITMException { return "";
* }
*/
// process()
public String processRtgs(String xmlString, String xmlString2,
String windowName, String xtraParams) throws RemoteException,
ITMException {
System.out.println("xmlString:::::::::::" + xmlString);
System.out.println("xmlString:::::::::::" + xmlString2);
public String actionHandler(String tranId, String xtraParams, String objContext)
throws RemoteException, ITMException
{
String xtraParam = ""; String xtraParam = "";
String retStr = ""; String retStr = "";
Document detailDom = null; Document detailDom = null;
Document headerDom = null; Document headerDom = null;
// GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
// E12GenericUtility genericUtility = new E12GenericUtility(); //commented by Nandkumar Gadkari on 26/07/18
try { try {
if (xmlString != null && xmlString.trim().length() != 0) { System.out.println(".......tranId......." + tranId + "objContext[" + objContext + "]xtraParams[" + xtraParams + "]");
headerDom = genericUtility.parseString(xmlString); retStr = pifprocess(tranId, xtraParams);
} }
if (xmlString2 != null && xmlString2.trim().length() != 0) { catch (Exception e)
detailDom = genericUtility.parseString(xmlString2); {
} System.out.println("Exception :RtgsBankPifprc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
retStr = process(headerDom, detailDom, windowName, xtraParams);
} catch (Exception e) {
System.out
.println("Exception :BankPifRtgsprc :process(String xmlString, String xmlString2, String windowName, String xtraParams):"
+ e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
return retStr; return retStr;
} }
public String process(Document headerDom, Document detailDom, public String pifprocess(String tranId, String xtraParams) throws RemoteException, ITMException
String windowName, String xtraParams) throws RemoteException, {
ITMException { System.out.println("@@@@@@@@@@@@@@@@@@@@ inside RtgsBankPif Process@@@@@@@@@@@@@@@");
System.out.println("@@@@@@@@@@@@@@@@@@@@ inside BankPifRtgsprc@@@@@@@@@@@@@@@");
Connection conn = null; Connection conn = null;
// GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
//E12GenericUtility genericUtility = new E12GenericUtility(); //commented by Nandkumar Gadkari on 26/07/18 PreparedStatement pstmt = null; PreparedStatement pstmt1 = null,pstmtlogin=null,pstmtSite=null;
PreparedStatement pstmt = null; ResultSet rs = null; ResultSet rs1 = null,rslogin=null,rsSite=null;
ResultSet rs = null;
String sql = ""; String sql = "";
ConnDriver connDriver = null; ConnDriver connDriver = null;
String tranId = "", userId = "", loginEmpCode = "", chgTerm = ""; String userId = "";
String errString = ""; String errString = "";
String errCode = ""; String errCode = "";
ValidatorEJB validatorEJB = null; ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
boolean isError = false; boolean isError = false;
double tempAMt = 0; boolean updateCnt=false;
double totAmt1 = 0;
double InsNo1 = 0;
String orgAmt = "";
DistCommon disCommon = null; DistCommon disCommon = null;
String forcedFlag = ""; String forcedFlag = "";
ReceiptAdvConf Conf = null; ReceiptAdvConf Conf = null;
File csvFile = null;
File destFile = null;
File file=null;
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB(); validatorEJB = new ValidatorEJB();
connDriver = new ConnDriver(); connDriver = new ConnDriver();
String confirm = ""; String confirm = "";
ArrayList al = new ArrayList(); ArrayList al = new ArrayList();
String row;
String fileName;
int sheetNo = 0;
int cnt = 0; int cnt = 0;
int successcnt = 0; int successcnt = 0;
Conf = new ReceiptAdvConf(); Conf = new ReceiptAdvConf();
String refdate = ""; String refdate = "";
String refdate1 = "";
String refno = ""; String refno = "";
String custcode = ""; String custcode = "";
String totAmt = ""; String ediRef = "";
PreparedStatement psmt = null; String refNumber = "";
Document dom1 = null; Document dom1 = null;
String xmlParseStr = ""; String xmlParseStr = "";
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String description = "", shDescr = "", message = "", Error = ""; String description = ""; String shDescr = ""; String message = ""; String Error = ""; String fileName1 = "";
int parentNodeListLength = 0; int parentNodeListLength = 0;
int detField1 = 0; int detField1 = 0,cnt1=0;
try { java.sql.Date refDate = null;
/*conn = connDriver.getConnectDB("DriverITM"); String retString = "",retString1="";
connDriver = null;*///commented and added getConnection by nandkumar gadkari on 18/03/19 String currentTime = "";
java.util.Date FromDate = null;
String amount = "";
String statNo = "";
String refNum = "";
String Status1="",refNoOrg="",tranId1="";
String loginSite = "",siteCode="",msgNo="";
try
{
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
connDriver = null;
conn.setAutoCommit(false); conn.setAutoCommit(false);
csvFile = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default"+ File.separator+"deploy"+File.separator+"Rtgsupdatexls"); loginSite = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginSite");
System.out.println(":::::::file Path" + csvFile); System.out.println("Login Site Rtgs Process:["+loginSite+ "]");
al = readExcelFile(csvFile, sheetNo);
System.out.println("call read excel File" + al.size()); sql = "select ref_no,amount,stat_no ,ref_date from bank_statement where STATUS = ? and stat_no is not null and site_code in(select site_code from site where fin_entity =(select fin_entity from site where site_code=?)) ";
//File file = new File("/home/base/tmp/Rtgs.txt"); pstmt1 = conn.prepareStatement(sql);
file = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default"+ File.separator+"deploy"+File.separator+"updatexls"+File.separator+"Rtgs.txt"); pstmt1.setString(1, "M");
if(file.createNewFile()) pstmt1.setString(2, loginSite);
{ rs1 = pstmt1.executeQuery();
System.out.println(file+" File Created"); System.out.println("sql@@@@@@" + sql);
}else while (rs1.next())
System.out.println("File "+file+" already exists"); {
FileWriter fw = new FileWriter(file.getAbsoluteFile()); refno = rs1.getString(1);
BufferedWriter bw = new BufferedWriter(fw); amount = rs1.getString(2);
String retString = ""; statNo = rs1.getString(3);
for (int i = 1; i < al.size(); i++) refDate = rs1.getDate(4);
{ refNoOrg=refno;
row = al.get(i).toString(); System.out.println("RefNumber Orginial" + refno);
row = row.replace("[", ""); System.out.println("amount" + amount);
row = row.replace("]", ""); System.out.println("statNo" + statNo);
String col[] = row.split(","); System.out.println("refDate" + refDate);
// cust_code,ref_no,ref_date,net_amt System.out.println("ediRef" + ediRef);
custcode = col[2].trim(); if (refno.trim().length() >= 6)
refno = col[6].trim(); {
refdate = col[7].trim(); refNum = refno.trim();
totAmt = col[8].trim(); }
int Amt = Integer.parseInt(totAmt.substring(totAmt.indexOf(".") + 1, totAmt.length())); else
System.out.println("Amt" + Amt); {
if (!(Amt > 0)) { System.out.println("Req Decimal");
totAmt = totAmt.substring(0, totAmt.indexOf(".")); refNum = getReqDecimal(refno.trim());
} System.out.println("RefNumber" + refNum);
System.out.println("Amount" + totAmt); }
// cust_code,ref_date,ref_no,chq_amt System.out.println("@@@@@RefNumber" + refNum);
System.out.println("#############RefNumber of Bank Statement" + refNoOrg);
sql = "select count(*) from bank_statement where ref_no = ? and amount= ? and stat_no=? and ref_date=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNoOrg);
pstmt.setString(2, amount);
pstmt.setString(3, statNo);
pstmt.setDate(4,refDate);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt1 = rs.getInt(1);
}
System.out.println("cnt1 is#############" +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 stat_no=? and ref_date=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "M");
pstmt.setString(2, refNoOrg);
pstmt.setString(3, amount);
pstmt.setString(4, statNo);
pstmt.setDate(5, refDate);
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 amount= ? and stat_no=? and ref_date=? and tran_id != ? and status = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNoOrg);
pstmt.setString(2, amount);
pstmt.setString(3, statNo);
pstmt.setDate(4, refDate);
pstmt.setString(5, tranId1.trim());
pstmt.setString(6, "M");
int i = pstmt.executeUpdate();
System.out.println("Delete Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
sql = "select count(1) from receipt where cust_code = ? and ref_no=? and ref_date = ? and chq_amt =? "; sql = "select count(1) from receipt where cust_code = ? and ref_no=? and ref_date = ? and chq_amt =? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custcode); pstmt.setString(1, statNo.trim());
pstmt.setString(2, refno); pstmt.setString(2, refNum.trim());
pstmt.setString(3, refdate); pstmt.setDate(3, refDate);
pstmt.setString(4, totAmt); pstmt.setString(4, amount.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next())
{
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
System.out.println(" sql@@@" + sql + "-->count" + cnt);
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0) if (cnt > 0)
{ {
System.out.println("@@ Count>0"); System.out.println("@@ Count>0");
sql = "select tran_id,confirmed from receipt where cust_code = ? and ref_no=?"; sql = "select tran_id,confirmed,site_code from receipt where cust_code = ? and ref_no=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custcode); pstmt.setString(1, statNo.trim());
pstmt.setString(2, refno); pstmt.setString(2, refNum.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { System.out.println("sql@@@@@" + sql);
if (rs.next())
{
tranId = rs.getString(1); tranId = rs.getString(1);
confirm = rs.getString("confirmed") == null ? "N" : rs.getString("confirmed"); confirm = rs.getString(2);//rs.getString("confirmed") == null ? "N" : rs.getString("confirmed");
siteCode=checkNull(rs.getString(3));
} }
System.out.println("confirm[" + confirm + "] traniD" + tranId + "] Site Code["+siteCode+"]");
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(confirm == null || confirm.trim().length() ==0)
if (confirm != null && confirm.equalsIgnoreCase("N")) {
confirm="N";
}
System.out.println("confirm[" + confirm + "] tranID[" + tranId + "] Site COde["+siteCode+"]");
String finLogin="",finSite="";
sql="select fin_entity from site where site_code=?";
pstmtlogin = conn.prepareStatement(sql);
pstmtlogin.setString(1,loginSite);
rslogin = pstmtlogin.executeQuery();
if (rslogin.next())
{
finLogin=checkNull(rslogin.getString(1));
}
rslogin.close();
rslogin = null;
pstmtlogin.close();
pstmtlogin = null;
System.out.println("finLogin["+finLogin+"]");
sql="select fin_entity from site where site_code=?";
pstmtSite = conn.prepareStatement(sql);
pstmtSite.setString(1,siteCode);
rsSite = pstmtSite.executeQuery();
if (rsSite.next())
{
finSite=checkNull(rsSite.getString(1));
}
System.out.println("finSite["+finSite+"]");
rsSite.close();
rsSite = null;
pstmtSite.close();
pstmtSite = null;
System.out.println("!(finLogin.trim()["+finLogin.trim()+"] .equals(finSite.trim()["+finSite.trim()+"]");
if(!(finLogin.trim().equals(finSite.trim())))
{
System.out.println("finLogin"+finLogin);
System.out.println("finSite"+finSite);
errString = itmDBAccessEJB.getErrorString("", "NORECFND", userId, "", conn);
return errString;
}
else
{
System.out.println("MAtch SIte Code Rtgs");
/* sql = "select STATUS from bank_statement where stat_no = ? and ref_no=? and ref_date = ? and amount =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statNo.trim());
pstmt.setString(2, refNum.trim());
pstmt.setDate(3, refDate);
pstmt.setString(4, amount.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
Status1 = rs.getString(1);
}
System.out.println( "Status1" + Status1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if("M".equals(Status1))
{ {
errString = Conf.confirm(tranId, xtraParams, forcedFlag); sql = "delete from bank_statement where stat_no = ? and ref_no=? and ref_date = ? and amount =?";
if (errString == null || errString.trim().length() == 0) pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statNo.trim());
pstmt.setString(2, refno.trim());
pstmt.setDate(3, refDate);
pstmt.setString(4, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}*/
if ((confirm != null) && (confirm.equalsIgnoreCase("N")))
{ {
System.out.println("Enter confirm COndition"); retString1 = Conf.confirm(tranId, xtraParams, forcedFlag);
System.out.println("The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + " is Sucessfully Confirmed");
String content = "The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + " is Sucessfully Confirmed"; if ((retString1.contains("VTCICONF3")) || (retString1.trim().length() == 0))
bw.write(content);
bw.newLine();
System.out.println("Write confirmed");
successcnt++;
System.out.println("Sucess Count Y is:"+ successcnt);
} else
{ {
String remark = "Receipt No - " + tranId + ":confirm Successfully";
System.out.println("Ref Number" + refno.trim());
sql = "update bank_statement set status=?,remarks=? where stat_no = ? and ref_no=? and ref_date = ? and amount =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "Z");
pstmt.setString(2, remark);
pstmt.setString(3, statNo.trim());
pstmt.setString(4, refno.trim());
pstmt.setDate(5, refDate);
pstmt.setString(6, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
else {
dom1 = parseString(errString); dom1 = parseString(errString);
System.out.println("dom1>>>>>: " + dom1); System.out.println("dom1>>>>>: " + dom1);
parentNodeList = dom1.getElementsByTagName("error"); parentNodeList = dom1.getElementsByTagName("error");
parentNodeListLength = parentNodeList.getLength(); parentNodeListLength = parentNodeList.getLength();
for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++) for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++)
{ {
parentNode = parentNodeList.item(lineCount); /* parentNode = parentNodeList.item(lineCount);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
for (detField1 = 0; detField1 < childNodeList.getLength(); detField1++) for (detField1 = 0; detField1 < childNodeList.getLength(); detField1++)
{ {
childNode = childNodeList.item(detField1); childNode = childNodeList.item(detField1);
if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("message")) if ((childNode != null) && (childNode.getFirstChild() != null) && (childNode.getNodeName().equalsIgnoreCase("message")))
{ {
message = (childNode.getFirstChild().getNodeValue().trim()); message = childNode.getFirstChild().getNodeValue().trim();
System.out.println(">>>message : "+ message); 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);
}
} }
else if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("description")) retString = message + ":" + description + ":" + tranId + "- Unconfirm Transaction";
System.out.println("After Parsing Return String>>>>" + retString);*/
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")))
{ {
description = (childNode.getFirstChild().getNodeValue().trim()); message = childNode.getFirstChild().getNodeValue().trim();
System.out.println(">>>Description : "+ description); 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 = message + ":" + description + ":Receipt No -" + tranId + " is Unconfirm Transaction";
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+"]");
} }
retString = "" + message + ":" + description + ""; else
System.out.println("After Parsing Return String>>>>"+ retString); {
retString = "Rcp No-"+ tranId +":"+msgNo+":"+message;
} }
System.out.println("The Record of tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + ":" + retString + " is Unconfirmed");
String content = "The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + ":"+ retString +" is Unconfirmed"; System.out.println("retString Final RTgs Process["+retString+"]");
bw.write(content);
System.out.println("Write Unconfirmed");
bw.newLine();
} }
System.out.println("The Record of tran_id : " + tranId + "State No:" + statNo + " and Reference Number : " + refNum + " and Reference Date : " + refDate + " and Cheque Amount : " + amount + ":" + retString + " is Unconfirmed");
System.out.println("Ref Number" + refno.trim());
System.out.println("if Error ---> Update Status M");
sql = "update bank_statement set status=?,remarks=? where stat_no = ? and ref_no=? and ref_date = ? and amount =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "M");
pstmt.setString(2, retString);
pstmt.setString(3, statNo.trim());
pstmt.setString(4, refno.trim());
pstmt.setDate(5, refDate);
pstmt.setString(6, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
}
} }
else else
{ {
System.out.println("Enter in else Already confirm COndition"); String remark = "Receipt No -" + tranId + ":Already confirm";
System.out.println("The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + " is Already Sucessfully Confirmed"); System.out.println("Ref Number" + refno.trim());
String content = "The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + " is Already Sucessfully Confirmed"; System.out.println("Added Delete Statement");
bw.write(content); sql = "delete from bank_statement where stat_no = ? and ref_no=? and ref_date = ? and amount =? and status=? ";
bw.newLine(); pstmt = conn.prepareStatement(sql);
System.out.println("Write Already confirmed"); pstmt.setString(1, statNo.trim());
successcnt++; pstmt.setString(2, refno.trim());
System.out.println("Sucess COunt Y is:" + successcnt); pstmt.setDate(3, refDate);
pstmt.setString(4, amount.trim());
pstmt.setString(5, "M");
int i = pstmt.executeUpdate();
System.out.println("Not Data found @@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
} }
System.out.println("Complete Process"); System.out.println("Complete Process");
} else {
System.out.println("The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + " is not Present in Statement");
String content = "The Record of Receipt tran_id : "+ tranId+"Customer Code :"+ custcode+ " and Reference Number : " + refno + " and Reference Date : : " + refdate + " and Cheque Amount : " + totAmt + " is not Present in Statement";
bw.write(content);
bw.newLine();
System.out.println("Write Already confirmed");
} }
} }
bw.close(); else
fw.close(); {
System.out.println("List size is" + al.size());
System.out.println("Counter size is" + successcnt); System.out.println("Else no Found Record");
if (al.size()-1 == successcnt) retString="No Data Found";
sql = "update bank_statement set status=?,remarks=? where stat_no = ? and ref_no=? and ref_date = ? and amount =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "M");
pstmt.setString(2, retString);
pstmt.setString(3, statNo.trim());
pstmt.setString(4, refno.trim());
pstmt.setDate(5, refDate);
pstmt.setString(6, amount.trim());
int i = pstmt.executeUpdate();
System.out.println("confirm Successfully@@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
// errString = itmDBAccessEJB.getErrorString("", "VTNODATA", userId, "", conn);
// errString = itmDBAccessEJB.getErrorString("", "VTNODATA", userId, "", conn);
}
updateCnt=true;
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(!updateCnt)
{ {
System.out.println("In List size is" + al.size()); errString = itmDBAccessEJB.getErrorString("", "NORECFND", userId, "", conn);
destFile = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default" System.out.println("errString Rtgs Count" + errString);
+ File.separator+"deploy"+File.separator+"RtgsStatement"); }
boolean success = csvFile.renameTo(new File(destFile, csvFile.getName()));
if (success) if ((errString == null) || (errString.trim().length() == 0))
{ {
System.out.println("File was successfully moved.\n"); errCode = "VTBPRC1";
} else errString = itmDBAccessEJB.getErrorString("", errCode, userId);
}
else
{ {
System.out.println("File was not successfully moved.\n"); String str1 = errString;
return str1;
} }
} }
} catch (Exception e) catch (Exception e)
{ {
System.out.println("Exception: confirm method ..> "+ e.getMessage()); System.out.println("Exception: confirm method ..> " + e.getMessage());
isError = true; e.printStackTrace();
errCode = "VTTRNNCNF"; // exception so cannot confirm
errString = itmDBAccessEJB.getErrorString("", errCode, userId);
throw new ITMException(e);
} }
finally finally
{ {
if (conn != null) if (conn != null)
try
{ {
try {
if (isError) if (isError)
{ {
conn.rollback(); conn.rollback();
System.out.println("confirm: Connection Rollback"); System.out.println("RtgsBankPifprc: Connection Rollback");
} else }
{ else {
conn.commit(); conn.commit();
System.out.println("confirm: Connection Commit"); System.out.println("RtgsBankPifprc: Connection Commit");
} }
conn.close(); conn.close();
conn = null; conn = null;
...@@ -409,93 +499,40 @@ public class BankPifRtgsprc extends ActionHandlerEJB implements Schedule // ext ...@@ -409,93 +499,40 @@ public class BankPifRtgsprc extends ActionHandlerEJB implements Schedule // ext
e.printStackTrace(); e.printStackTrace();
} }
} }
if (conn != null) {
try
{
if (isError)
{
conn.rollback();
System.out.println("RtgsBankPifprc: Connection Rollback");
} }
return errString; else {
conn.commit();
System.out.println("RtgsBankPifprc: Connection Commit");
} }
conn.close();
public Document parseString(String xsdString) { conn = null;
Document dom = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
OutputStreamWriter errorWriter = new OutputStreamWriter(System.err,
"UTF-8");
ByteArrayInputStream baos = new ByteArrayInputStream(xsdString
.getBytes());
dom = db.parse(baos);
} catch (Exception e) { } catch (Exception e) {
System.out.println("Error :" + e); e.printStackTrace();
}
return dom;
}
public ArrayList readExcelFile(File fileName, int sheetNo) {
System.out
.println("----in readExcelFile1 method CNT..................");
String value = null;
int headerRowCnt = -1, detailRowCnt = -1;
ArrayList cellArrayLisstHolder = new ArrayList();
try {
FileInputStream myInput = new FileInputStream(fileName);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
HSSFSheet mySheet = myWorkBook.getSheetAt(sheetNo);
Sheet sheet = myWorkBook.getSheetAt(sheetNo);
for (Row row : sheet) {
for (Cell cell : row) {
if (cell.getCellType() != Cell.CELL_TYPE_BLANK) {
if (cell.getCellType() != Cell.CELL_TYPE_STRING
|| cell.getStringCellValue().length() > 0) {
if (sheetNo == 1)
headerRowCnt++;
else if (sheetNo == 2)
detailRowCnt++;
break;
}
}
}
}
for (Row row : mySheet) {
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);
return errString;
} }
} catch (Exception e) { public String getReqDecimal(String chqAmt)
e.printStackTrace(); {
DecimalFormat df = new DecimalFormat("000000");
int num = Integer.parseInt(chqAmt);
String refAmt = df.format(num);
System.out.println("@@@@@" + refAmt);
return refAmt;
} }
return cellArrayLisstHolder; private String checkNull(String input) {
if (input == null) {
input = "";
} }
return input;
/*
* public String getReqDecimal(String chqAmt) { DecimalFormat df = new
* DecimalFormat("000000"); //int num= Integer.parseInt(chqAmt); String
* refAmt = df.format(chqAmt); System.out.println("@@@@@"+refAmt); return
* refAmt; }
*/
@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;
}
} }
\ No newline at end of file
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