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;
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.math.BigDecimal;
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.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.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@SuppressWarnings( { "unused" })
public class BankPiFprc extends ActionHandlerEJB implements Schedule // extends ProcessEJB implements
// BankPiFprcLocal,BankPiFprcRemote{
@Stateless
public class BankPiFprc extends ActionHandlerEJB
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("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);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println(" CshildNodeListLength >>>>:-["
+ childNodeListLength + "]");
process(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());
GenericUtility genericUtility = GenericUtility.getInstance();
}
}
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 {
process(xmlString, xmlString2, winName, xtraParams);
} 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 process(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();
GenericUtility genericUtility = GenericUtility.getInstance();
try {
if (xmlString != null && xmlString.trim().length() != 0) {
headerDom = genericUtility.parseString(xmlString);
}
if (xmlString2 != null && xmlString2.trim().length() != 0) {
detailDom = genericUtility.parseString(xmlString2);
System.out.println(".......tranId......." + tranId + "objContext[" + objContext + "]xtraParams[" + xtraParams + "]");
retStr = pifprocess(tranId, xtraParams);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
} catch (Exception e) {
catch (Exception e)
{
System.out
.println("Exception :BankReconPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):"
+ e.getMessage() + ":");
.println("Exception :BankReconPrcEJB :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 BankPifPrc Process@@@@@@@@@@@@@@@");
Connection conn = null;
// GenericUtility genericUtility = GenericUtility.getInstance();
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 = "";
String activity_code = "", activity_descr = "", combocode = "", combodescr = "", floor = "", floor_descr = "", configunit = "", configunit_descr = "";
String activity_code = ""; String activity_descr = ""; String combocode = ""; String combodescr = ""; String floor = ""; String floor_descr = ""; String configunit = ""; String configunit_descr = "";
ConnDriver connDriver = null;
String tranId = "", userId = "", loginEmpCode = "", chgTerm = "";
String userId = ""; String loginEmpCode = ""; String chgTerm = "";
String errString = "";
String errCode = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean isError = false;
double tempAMt = 0;
double totAmt1 = 0;
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;
File filePath = 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;
double Value=0;
int successcnt = 0;
double Value = 0.0D;
Conf = new ReceiptAdvConf();
String InsNo = "";
String totAmt = "";
String batchNo = "";
String totalAmt = "";
PreparedStatement psmt = null;
Document dom1 = null;
String xmlParseStr = "";
......@@ -221,218 +101,399 @@ public class BankPiFprc extends ActionHandlerEJB implements Schedule // extends
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String description="",shDescr="",message="",Error="", fileName1 ="";
int parentNodeListLength=0;
int detField1=0;
String retString="";
String status = ""; String refNo = ""; String ediRef = ""; String amount = "",tranId1="";
String description = ""; String message = "";
int parentNodeListLength = 0;
int detField1 = 0,counter=0,cnt1=0;
String retString = "",retString1="";
String refNum = "",Status1="",refNoOrg="";
String loginSite = "",siteCode="",msgNo="";
Node arrNode = null;
NamedNodeMap nodeMap = null;
boolean isFlag = true;
try {
/*conn = connDriver.getConnectDB("DriverITM");
connDriver = null;*/ //commented and added getConnection by nandkumar gadkari on 18/03/19
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
connDriver = null;
conn.setAutoCommit(false);
loginSite = GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginSite");
System.out.println("Login Site:["+loginSite+ "]");
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);
pstmt1.setString(1, "M");
pstmt1.setString(2, loginSite);
rs1 = pstmt1.executeQuery();
while (rs1.next())
{
refNo = rs1.getString(1);
ediRef = rs1.getString(2);
amount = rs1.getString(3);
// tranId1= rs1.getString(4);
System.out.println("RefNumber" + refNo);
System.out.println("Trim Refnumber[" + refNo.trim() + "]");
System.out.println("amount" + amount);
System.out.println("ediRef" + ediRef);
System.out.println("tranId1" + tranId1);
refNoOrg=refNo;
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 edi_ref = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refNoOrg);
pstmt.setString(2, amount.trim());
pstmt.setString(3, ediRef.trim());
rs = pstmt.executeQuery();
if (rs.next())
{
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;
}
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())
{
fileName1 = file.getName();
if(fileName1.endsWith(".xls") || fileName1.endsWith(".XLS"))//xls
{
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);
pstmt.setString(1, refNum.trim());
pstmt.setString(2, amount.trim());
pstmt.setString(3, ediRef.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 ref_no = ? and chq_amt=? ";
sql = "select tran_id,confirmed,site_code from receipt where ref_no = ? and chq_amt=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, InsNo);
pstmt.setString(2, totalAmt);
pstmt.setString(1, refNum.trim());
pstmt.setString(2, amount.trim());
rs = pstmt.executeQuery();
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));
}
if(confirm == null || confirm.trim().length() ==0)
{
confirm="N";
}
System.out.println("confirm[" + confirm + "] tranID[" + tranId + "] Site COde["+siteCode+"]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (confirm != null && confirm.equalsIgnoreCase("N"))
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())
{
errString = Conf.confirm(tranId, xtraParams, forcedFlag);
if (errString == null || errString.trim().length() == 0)
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())
{
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);
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
{
dom1 = parseString(errString);
System.out.println("dom1>>>>>: "+dom1);
System.out.println("MAtch SIte Code");
/* if(counter > 0)
{
sql = "select count(*) from bank_statement where ref_no = ? and amount= ? and edi_ref = ?";
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())
{
cnt1 = rs.getInt(1);
}
System.out.println("cnt1@@@@@@@@@@@@@@" +cnt1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt1 > 1)
{
sql = "select STATUS from bank_statement where ref_no = ? and amount= ? and edi_ref = ?";
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())
{
Status1 = rs.getString(1);
}
System.out.println( "Status1@@@@@" + Status1);
rs.close();
rs = null;
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") )
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);
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;
}*/
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();
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
{
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);
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");
}
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");
System.out.println("Else no Found Record Condition");
retString="No Data Found";
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("Not Data found @@@@@@@@@@@@@@@@@@@" + i);
pstmt.close();
pstmt = null;
// errString = itmDBAccessEJB.getErrorString("", "VTNODATA", userId, "", conn);
}
updateCnt=true;
counter++;
}
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"
+ File.separator+"deploy"+File.separator+"BankStatement");
boolean success = csvFile.renameTo(new File(destFile, csvFile.getName()));
if (success) {
System.out.println("File was successfully moved.\n");
} else {
System.out.println("File was not successfully moved.\n");
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("CHEK isFlag:::["+isFlag+"]");
if (isFlag == false)
{
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;
}
}
} 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);
} finally {
if (conn != null) {
catch (Exception e)
{
System.out.println("Exception: Process method ..> " + e.getMessage());
}
finally
{
if (conn != null)
try {
if (isError) {
conn.rollback();
System.out.println("confirm: Connection Rollback");
System.out.println("Process: Connection Rollback");
} else {
conn.commit();
System.out.println("confirm: Connection Commit");
System.out.println("Process: Connection Commit");
}
conn.close();
conn = null;
......@@ -440,97 +501,37 @@ public class BankPiFprc extends ActionHandlerEJB implements Schedule // extends
e.printStackTrace();
}
}
}
return errString;
}
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);
}
catch (Exception e)
{
System.out.println("Error :" +e);
}
return dom;
}
public ArrayList readExcelFile(String fileName, int sheetNo) {
System.out.println("----in readExcelFile1 method CNT..................");
String value = null;
int headerRowCnt = -1, detailRowCnt = -1;
ArrayList cellArrayLisstHolder = new ArrayList();
if (conn != null) {
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);
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();
}
return cellArrayLisstHolder;
}
return errString;
}
public String getReqDecimal(String chqAmt)
{
DecimalFormat df = new DecimalFormat("000000");
int num= Integer.parseInt(chqAmt);
int num = Integer.parseInt(chqAmt);
String refAmt = df.format(num);
System.out.println("@@@@@"+refAmt);
System.out.println("@@@@@" + refAmt);
return refAmt;
}
@Override
public String schedule(HashMap arg0) throws Exception {
// TODO Auto-generated method stub
return null;
private String checkNull(String input) {
if (input == null) {
input = "";
}
@Override
public String schedulePriority(String arg0) throws Exception {
// TODO Auto-generated method stub
return null;
return input;
}
}
\ No newline at end of file
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