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;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.ProcessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.BankReconPrcLocal;
import ibase.webitm.ejb.fin.BankReconPrcRemote;
import ibase.webitm.ejb.fin.FinCommon;
//import ibase.webitm.utility.GenericUtility;
import ibase.webitm.ejb.fin.adv.ReceiptAdvConf;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
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.io.PrintStream;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
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.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.Node;
import org.w3c.dom.NodeList;
@SuppressWarnings({"unused"})
public class BankPifRtgsprc extends ActionHandlerEJB implements Schedule // extends ProcessEJB implements
// 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();
@Stateless
public class BankPifRtgsprc extends ActionHandlerEJB
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0);
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);
{
GenericUtility genericUtility = GenericUtility.getInstance();
} catch (Exception e)
public String actionHandler() throws RemoteException, ITMException
{
e.printStackTrace();
throw new ITMException(e);
}
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 retStr = "";
Document detailDom = null;
Document headerDom = null;
// GenericUtility genericUtility = GenericUtility.getInstance();
// E12GenericUtility genericUtility = new E12GenericUtility(); //commented by Nandkumar Gadkari on 26/07/18
GenericUtility genericUtility = GenericUtility.getInstance();
try {
if (xmlString != null && xmlString.trim().length() != 0) {
headerDom = genericUtility.parseString(xmlString);
System.out.println(".......tranId......." + tranId + "objContext[" + objContext + "]xtraParams[" + xtraParams + "]");
retStr = pifprocess(tranId, xtraParams);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
detailDom = genericUtility.parseString(xmlString2);
}
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() + ":");
catch (Exception e)
{
System.out.println("Exception :RtgsBankPifprc :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}
public String process(Document headerDom, Document detailDom,
String windowName, String xtraParams) throws RemoteException,
ITMException {
System.out.println("@@@@@@@@@@@@@@@@@@@@ inside BankPifRtgsprc@@@@@@@@@@@@@@@");
public String pifprocess(String tranId, String xtraParams) throws RemoteException, ITMException
{
System.out.println("@@@@@@@@@@@@@@@@@@@@ inside RtgsBankPif Process@@@@@@@@@@@@@@@");
Connection conn = null;
// GenericUtility genericUtility = GenericUtility.getInstance();
//E12GenericUtility genericUtility = new E12GenericUtility(); //commented by Nandkumar Gadkari on 26/07/18
PreparedStatement pstmt = null;
ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance();
PreparedStatement pstmt = null; PreparedStatement pstmt1 = null,pstmtlogin=null,pstmtSite=null;
ResultSet rs = null; ResultSet rs1 = null,rslogin=null,rsSite=null;
String sql = "";
ConnDriver connDriver = null;
String tranId = "", userId = "", loginEmpCode = "", chgTerm = "";
String userId = "";
String errString = "";
String errCode = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean isError = false;
double tempAMt = 0;
double totAmt1 = 0;
double InsNo1 = 0;
String orgAmt = "";
boolean updateCnt=false;
DistCommon disCommon = null;
String forcedFlag = "";
ReceiptAdvConf Conf = null;
File csvFile = null;
File destFile = null;
File file=null;
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
connDriver = new ConnDriver();
String confirm = "";
ArrayList al = new ArrayList();
String row;
String fileName;
int sheetNo = 0;
int cnt = 0;
int successcnt = 0;
Conf = new ReceiptAdvConf();
String refdate = "";
String refdate1 = "";
String refno = "";
String custcode = "";
String totAmt = "";
PreparedStatement psmt = null;
String ediRef = "";
String refNumber = "";
Document dom1 = null;
String xmlParseStr = "";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String description = "", shDescr = "", message = "", Error = "";
String description = ""; String shDescr = ""; String message = ""; String Error = ""; String fileName1 = "";
int parentNodeListLength = 0;
int detField1 = 0;
try {
/*conn = connDriver.getConnectDB("DriverITM");
connDriver = null;*///commented and added getConnection by nandkumar gadkari on 18/03/19
int detField1 = 0,cnt1=0;
java.sql.Date refDate = null;
String retString = "",retString1="";
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();
connDriver = null;
conn.setAutoCommit(false);
csvFile = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default"+ File.separator+"deploy"+File.separator+"Rtgsupdatexls");
System.out.println(":::::::file Path" + csvFile);
al = readExcelFile(csvFile, sheetNo);
System.out.println("call read excel File" + al.size());
//File file = new File("/home/base/tmp/Rtgs.txt");
file = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default"+ File.separator+"deploy"+File.separator+"updatexls"+File.separator+"Rtgs.txt");
if(file.createNewFile())
{
System.out.println(file+" File Created");
}else
System.out.println("File "+file+" already exists");
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
String retString = "";
for (int i = 1; i < al.size(); i++)
{
row = al.get(i).toString();
row = row.replace("[", "");
row = row.replace("]", "");
String col[] = row.split(",");
// cust_code,ref_no,ref_date,net_amt
custcode = col[2].trim();
refno = col[6].trim();
refdate = col[7].trim();
totAmt = col[8].trim();
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("Amount" + totAmt);
// cust_code,ref_date,ref_no,chq_amt
loginSite = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginSite");
System.out.println("Login Site Rtgs Process:["+loginSite+ "]");
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=?)) ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, "M");
pstmt1.setString(2, loginSite);
rs1 = pstmt1.executeQuery();
System.out.println("sql@@@@@@" + sql);
while (rs1.next())
{
refno = rs1.getString(1);
amount = rs1.getString(2);
statNo = rs1.getString(3);
refDate = rs1.getDate(4);
refNoOrg=refno;
System.out.println("RefNumber Orginial" + refno);
System.out.println("amount" + amount);
System.out.println("statNo" + statNo);
System.out.println("refDate" + refDate);
System.out.println("ediRef" + ediRef);
if (refno.trim().length() >= 6)
{
refNum = refno.trim();
}
else
{
System.out.println("Req Decimal");
refNum = getReqDecimal(refno.trim());
System.out.println("RefNumber" + refNum);
}
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 =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custcode);
pstmt.setString(2, refno);
pstmt.setString(3, refdate);
pstmt.setString(4, totAmt);
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()) {
if (rs.next())
{
cnt = rs.getInt(1);
}
System.out.println(" sql@@@" + sql + "-->count" + cnt);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 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.setString(1, custcode);
pstmt.setString(2, refno);
pstmt.setString(1, statNo.trim());
pstmt.setString(2, refNum.trim());
rs = pstmt.executeQuery();
if (rs.next()) {
System.out.println("sql@@@@@" + sql);
if (rs.next())
{
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 = null;
pstmt.close();
pstmt = null;
if (confirm != null && confirm.equalsIgnoreCase("N"))
if(confirm == null || confirm.trim().length() ==0)
{
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);
if (errString == null || errString.trim().length() == 0)
sql = "delete 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, 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");
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";
bw.write(content);
bw.newLine();
System.out.println("Write confirmed");
successcnt++;
System.out.println("Sucess Count Y is:"+ successcnt);
} else
retString1 = Conf.confirm(tranId, xtraParams, forcedFlag);
if ((retString1.contains("VTCICONF3")) || (retString1.trim().length() == 0))
{
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);
System.out.println("dom1>>>>>: " + dom1);
parentNodeList = dom1.getElementsByTagName("error");
parentNodeListLength = parentNodeList.getLength();
for (int lineCount = 0; lineCount < parentNodeListLength; lineCount++)
{
parentNode = parentNodeList.item(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"))
if ((childNode != null) && (childNode.getFirstChild() != null) && (childNode.getNodeName().equalsIgnoreCase("message")))
{
message = (childNode.getFirstChild().getNodeValue().trim());
System.out.println(">>>message : "+ 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);
}
}
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());
System.out.println(">>>Description : "+ description);
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 = 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 + "";
System.out.println("After Parsing Return String>>>>"+ retString);
else
{
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";
bw.write(content);
System.out.println("Write Unconfirmed");
bw.newLine();
System.out.println("retString Final RTgs Process["+retString+"]");
}
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
{
System.out.println("Enter in else Already confirm COndition");
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");
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";
bw.write(content);
bw.newLine();
System.out.println("Write Already confirmed");
successcnt++;
System.out.println("Sucess COunt Y is:" + successcnt);
String remark = "Receipt No -" + tranId + ":Already confirm";
System.out.println("Ref Number" + refno.trim());
System.out.println("Added Delete Statement");
sql = "delete from bank_statement where stat_no = ? and ref_no=? and ref_date = ? and amount =? and status=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, statNo.trim());
pstmt.setString(2, refno.trim());
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");
} 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();
fw.close();
System.out.println("List size is" + al.size());
System.out.println("Counter size is" + successcnt);
if (al.size()-1 == successcnt)
else
{
System.out.println("Else no Found Record");
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());
destFile = new File( CommonConstants.JBOSSHOME + File.separator+"server"+File.separator+"default"
+ File.separator+"deploy"+File.separator+"RtgsStatement");
boolean success = csvFile.renameTo(new File(destFile, csvFile.getName()));
if (success)
errString = itmDBAccessEJB.getErrorString("", "NORECFND", userId, "", conn);
System.out.println("errString Rtgs Count" + errString);
}
if ((errString == null) || (errString.trim().length() == 0))
{
System.out.println("File was successfully moved.\n");
} else
errCode = "VTBPRC1";
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());
isError = true;
errCode = "VTTRNNCNF"; // exception so cannot confirm
errString = itmDBAccessEJB.getErrorString("", errCode, userId);
throw new ITMException(e);
System.out.println("Exception: confirm method ..> " + e.getMessage());
e.printStackTrace();
}
finally
{
if (conn != null)
try
{
try {
if (isError)
{
conn.rollback();
System.out.println("confirm: Connection Rollback");
} else
{
System.out.println("RtgsBankPifprc: Connection Rollback");
}
else {
conn.commit();
System.out.println("confirm: Connection Commit");
System.out.println("RtgsBankPifprc: Connection Commit");
}
conn.close();
conn = null;
......@@ -409,93 +499,40 @@ public class BankPifRtgsprc extends ActionHandlerEJB implements Schedule // ext
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");
}
public Document parseString(String xsdString) {
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);
conn.close();
conn = null;
} catch (Exception e) {
System.out.println("Error :" + e);
}
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(",", "");
e.printStackTrace();
}
cellStoreArrayList.add(value);
}
cellArrayLisstHolder.add(cellStoreArrayList);
return errString;
}
} catch (Exception e) {
e.printStackTrace();
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;
}
return cellArrayLisstHolder;
private String checkNull(String input) {
if (input == null) {
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;
return input;
}
@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