Commit 7c6148a4 authored by tmahadi's avatar tmahadi

Changes in Ecollection Module.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104176 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 972939a9
[Dolphin] [Dolphin]
HeaderColumnWidths=335,74,146
SortOrder=1 SortOrder=1
SortRole=date SortRole=date
Timestamp=2016,6,10,11,5,29 Timestamp=2016,12,12,18,55,2
Version=3 Version=3
ViewMode=1 ViewMode=1
...@@ -17,115 +17,87 @@ import java.sql.Connection; ...@@ -17,115 +17,87 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import java.text.DecimalFormat; import java.text.DecimalFormat;
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;
import javax.ejb.Stateless; import javax.ejb.Stateless;
@Stateless
public class EcollectionIC extends ValidatorEJB implements EcollectionICLocal, EcollectionICRemote @Stateless
{ public class EcollectionIC extends ValidatorEJB implements EcollectionICLocal, EcollectionICRemote {
E12GenericUtility genericUtility= new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
{
String errString = ""; String errString = "";
Document dom = null; Document dom = null, dom1 = null, dom2 = null;
Document dom1 = null; try {
Document dom2 = null; System.out.println("Called wfValData [S] from [EJB:" + this.getClass().getSimpleName() + "]");
try if (xmlString != null && xmlString.trim().length() > 0) {
{
if (xmlString != null && xmlString.trim().length() > 0 )
{
dom = parseString(xmlString); dom = parseString(xmlString);
System.out.println("xmlString["+xmlString+"]"); System.out.println("xmlString[" + xmlString + "]");
} }
if (xmlString1 != null && xmlString1.trim().length() > 0 ) if (xmlString1 != null && xmlString1.trim().length() > 0) {
{
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
System.out.println("xmlString1["+xmlString1+"]"); System.out.println("xmlString1[" + xmlString1 + "]");
} }
if (xmlString2 != null && xmlString2.trim().length() > 0 ) if (xmlString2 != null && xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
System.out.println("xmlString2["+xmlString2+"]"); System.out.println("xmlString2[" + xmlString2 + "]");
} }
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} } catch (Exception e) {
catch(Exception e) System.out.println("Exception wfValData [S] in EJB [" + this.getClass().getSimpleName() + "] " + e.getLocalizedMessage());
{
System.out.println("Exception : [EcollectionIC][wfValData( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return(errString); return errString;
} }
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{ public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
String childNodeName = null; String childNodeName = "", errString = "", errCode = "", userId = "", sql = "", errorType = "", custCode = "", bankCode = "", lineNo = "", chqAmtStr = "", siteCode = "", rcpAmtStr = "", refSer = "", refNo = "", prdCode = "";
String errString = ""; int cnt = 0, ctr = 0, childNodeListLength = 0, currentFormNo = 0;
String errCode = ""; NodeList parentNodeList = null, childNodeList = null;
String userId = ""; Node parentNode = null, childNode = null;
String sql = ""; ArrayList<String> errList = new ArrayList<String>(), errFields = new ArrayList<String>();
String errorType = "";
String custCode="",bankCode="",lineNo="",chqAmtStr="";
int cnt = 0;
int ctr=0;
int childNodeListLength;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
int currentFormNo =0;
String siteCode="",rcpAmtStr="",refSer="",refNo="",prdCode="";
java.util.Date tranDate = null; java.util.Date tranDate = null;
double rcpAmt=0,rcpAmtNew=0,rcpAmtStatus=0.0; double rcpAmt = 0, rcpAmtNew = 0, rcpAmtStatus = 0.0, isInvAmt = 0.0, chqAmt = 0.0;
double isInvAmt=0.0,chqAmt=0.0; SimpleDateFormat sdf = null;
SimpleDateFormat dateFormat2 = null; try {
try sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
{ dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); System.out.println("Called wfValData [D] from [EJB:" + this.getClass().getSimpleName() + "]");
System.out.println("@@@@@@@@ wfvaldata called"); // Changes and Commented By Bhushan on 06-06-2016 :START
//Changes and Commented By Bhushan on 06-06-2016 :START // conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM"); conn = getConnection();
conn = getConnection(); // Changes and Commented By Bhushan on 06-06-2016 :END
//Changes and Commented By Bhushan on 06-06-2016 :END
connDriver = null; connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0) {
{
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) switch (currentFormNo) {
{ case 1:
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("site_code")) if (childNodeName.equalsIgnoreCase("site_code")) {
{
siteCode = this.genericUtility.getColumnValue("site_code", dom); siteCode = this.genericUtility.getColumnValue("site_code", dom);
if(siteCode != null && siteCode.trim().length() > 0 ) if (siteCode != null && siteCode.trim().length() > 0) {
{
sql = "select count(*) from site where site_code = ?"; sql = "select count(*) from site where site_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode.trim()); pstmt.setString(1, siteCode.trim());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
...@@ -133,28 +105,22 @@ conn = getConnection(); ...@@ -133,28 +105,22 @@ conn = getConnection();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt == 0) if (cnt == 0) {
{
errCode = "VMSITE1"; errCode = "VMSITE1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if(genericUtility.getColumnValue("eff_date", dom) == null)
{
tranDate = null;
}
else
{
tranDate = dateFormat2.parse(genericUtility.getColumnValue("eff_date",dom));
if (genericUtility.getColumnValue("eff_date", dom) == null) {
tranDate = null;
} else {
tranDate = sdf.parse(genericUtility.getColumnValue("eff_date", dom));
sql = "select code from period where ? between fr_date and to_date"; sql = "select code from period where ? between fr_date and to_date";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setDate(1,new java.sql.Date(tranDate.getTime())); pstmt.setDate(1, new java.sql.Date(tranDate.getTime()));
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
prdCode = rs.getString(1); prdCode = rs.getString(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
...@@ -163,147 +129,122 @@ conn = getConnection(); ...@@ -163,147 +129,122 @@ conn = getConnection();
sql = "select count(*) from period_stat where site_code = ? and prd_code = ? "; sql = "select count(*) from period_stat where site_code = ? and prd_code = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2,prdCode); pstmt.setString(2, prdCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt == 0)
{ if (cnt == 0) {
errCode = "VTSITEPD"; errCode = "VTSITEPD";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
errCode = nfCheckPeriod("FIN",tranDate,siteCode); errCode = nfCheckPeriod("FIN", tranDate, siteCode);
if(errCode != null && errCode.trim().length() > 0) if (errCode != null && errCode.trim().length() > 0) {
{
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} } else {
else
{
errCode = "VMSITENUL"; errCode = "VMSITENUL";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} } else if (childNodeName.equalsIgnoreCase("cust_code")) {
else if (childNodeName.equalsIgnoreCase("cust_code"))
{
custCode = this.genericUtility.getColumnValue("cust_code", dom); custCode = this.genericUtility.getColumnValue("cust_code", dom);
if(custCode != null && custCode.trim().length() > 0 ) siteCode = this.genericUtility.getColumnValue("site_code", dom);
{ if (custCode != null && custCode.trim().length() > 0) {
sql = "SELECT COUNT(*) AS COUNT FROM CUSTOMER WHERE CUST_CODE = ? " ; sql = "select count(*) as COUNT from customer c join site_customer s on c.cust_code = s.cust_code and s.site_code = ? and c.cust_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,custCode); pstmt.setString(1, siteCode);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next()) if (rs.next()) {
{
cnt = rs.getInt("COUNT"); cnt = rs.getInt("COUNT");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( cnt == 0 )
{ if (cnt == 0) {
errCode = "VTCUSTCD1"; errCode = "VTCUSTCD8";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} else {
}
else
{
errCode = "VMCUSTCD1"; errCode = "VMCUSTCD1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} } else if (childNodeName.equalsIgnoreCase("bank_code")) {
else if (childNodeName.equalsIgnoreCase("bank_code"))
{
bankCode = this.genericUtility.getColumnValue("bank_code", dom); bankCode = this.genericUtility.getColumnValue("bank_code", dom);
if(bankCode != null && bankCode.trim().length() > 0) if (bankCode != null && bankCode.trim().length() > 0) {
{ sql = "SELECT COUNT(*) AS COUNT FROM BANK WHERE BANK_CODE = ? ";
sql = "SELECT COUNT(*) AS COUNT FROM BANK WHERE BANK_CODE = ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bankCode); pstmt.setString(1, bankCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next()) if (rs.next()) {
{
cnt = rs.getInt("COUNT"); cnt = rs.getInt("COUNT");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( cnt == 0 )
{ if (cnt == 0) {
errCode = "VMBANKMIS1"; errCode = "VMBANKMIS1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} else {
}
else
{
errCode = "VMBANKCD1"; errCode = "VMBANKCD1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else if (childNodeName.equalsIgnoreCase("chq_amt")) } else if (childNodeName.equalsIgnoreCase("chq_amt")) {
{
chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom); chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom);
if(chqAmtStr != null && chqAmtStr.trim().length() > 0) if (chqAmtStr != null && chqAmtStr.trim().length() > 0) {
{ chqAmt = Double.parseDouble(chqAmtStr);
chqAmt= Double.parseDouble(chqAmtStr); if (chqAmt <= 0) {
if(chqAmt <= 0)
{
errCode = "VTRCPAMT"; errCode = "VTRCPAMT";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else } else {
{
errCode = "VTRCPAMTNL"; errCode = "VTRCPAMTNL";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
}// end for }
break; // case 1 end break;
case 2: case 2:
parentNodeList = dom.getElementsByTagName("Detail2"); parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
System.out.println("@@@@@@@@@@@@childNodeListLength["+childNodeListLength+"]");
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("ref_ser")) if (childNodeName.equalsIgnoreCase("ref_ser")) {
{
refSer = this.genericUtility.getColumnValue("ref_ser", dom); refSer = this.genericUtility.getColumnValue("ref_ser", dom);
if(refSer != null && refSer.trim().length() > 0) custCode = this.genericUtility.getColumnValue("cust_code", dom2, "1");
{ System.out.println("refSer : " + refSer + " :::custCode::: " + custCode);
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE TRAN_SER = ? " ; if (refSer != null && refSer.trim().length() > 0) {
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE TRAN_SER = ? and cust_code = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refSer); pstmt.setString(1, refSer);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next()) if (rs.next()) {
{
cnt = rs.getInt("COUNT"); cnt = rs.getInt("COUNT");
} }
rs.close(); rs.close();
...@@ -311,138 +252,120 @@ conn = getConnection(); ...@@ -311,138 +252,120 @@ conn = getConnection();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( cnt == 0 ) if (cnt == 0) {
{
errCode = "VTINVRESER"; errCode = "VTINVRESER";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} } else {
else
{
errCode = "VTNULRESER"; errCode = "VTNULRESER";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else if (childNodeName.equalsIgnoreCase("ref_no")) } else if (childNodeName.equalsIgnoreCase("ref_no")) {
{
refNo = this.genericUtility.getColumnValue("ref_no", dom); refNo = this.genericUtility.getColumnValue("ref_no", dom);
lineNo = genericUtility.getColumnValue("line_no",dom); lineNo = genericUtility.getColumnValue("line_no", dom);
refSer = genericUtility.getColumnValue("ref_ser",dom); refSer = genericUtility.getColumnValue("ref_ser", dom);
if(refNo != null && refNo.trim().length() > 0) custCode = this.genericUtility.getColumnValue("cust_code", dom2, "1");
{ System.out.println("IN ref_no validation : refNo:::"+ refNo +":::refSer:::" + refSer + ":::custCode:::" + custCode);
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE REF_NO = ? " ; if (refNo != null && refNo.trim().length() > 0) {
sql = "SELECT COUNT(*) AS COUNT FROM RECEIVABLES WHERE REF_NO = ? and tran_ser = ? and cust_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refNo); pstmt.setString(1, refNo);
pstmt.setString(2, refSer);
pstmt.setString(3, custCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next()) if (rs.next()) {
{
cnt = rs.getInt("COUNT"); cnt = rs.getInt("COUNT");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( cnt == 0 )
{ if (cnt == 0) {
errCode = "VTINVREFNO"; errCode = "VTINVREFNO";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} } else {
else if (isDulplicateFrmDom(dom2, refNo, lineNo, refSer)) {
{
if (isDulplicateFrmDom(dom2,refNo,lineNo,refSer))
{
errCode = "VTDUPREFNO"; errCode = "VTDUPREFNO";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} else {
}
else
{
errCode = "VTNULREFNO"; errCode = "VTNULREFNO";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}else if (childNodeName.equalsIgnoreCase("rcp_amt")) } else if (childNodeName.equalsIgnoreCase("rcp_amt")) {
{ rcpAmtStr = genericUtility.getColumnValue("rcp_amt", dom);
rcpAmtStr = genericUtility.getColumnValue("rcp_amt",dom); refSer = genericUtility.getColumnValue("ref_ser", dom);
refSer = genericUtility.getColumnValue("ref_ser",dom); refNo = genericUtility.getColumnValue("ref_no", dom);
refNo = genericUtility.getColumnValue("ref_no",dom); lineNo = genericUtility.getColumnValue("line_no", dom);
lineNo = genericUtility.getColumnValue("line_no",dom);
custCode = this.genericUtility.getColumnValue("cust_code", dom1); custCode = this.genericUtility.getColumnValue("cust_code", dom1);
siteCode = this.genericUtility.getColumnValue("site_code", dom1); siteCode = this.genericUtility.getColumnValue("site_code", dom1);
chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom1); chqAmtStr = this.genericUtility.getColumnValue("chq_amt", dom1);
if (chqAmtStr != null && chqAmtStr.trim().length() > 0) if (chqAmtStr != null && chqAmtStr.trim().length() > 0) {
{ try {
try chqAmt = Double.parseDouble(chqAmtStr);
{ } catch (NumberFormatException n) {
chqAmt= Double.parseDouble(chqAmtStr);
} catch (NumberFormatException n)
{
chqAmt = 0; chqAmt = 0;
} }
} }
System.out.println("chqAmt>>>>>>["+chqAmt+"]"); System.out.println("chqAmt>>>>>>[" + chqAmt + "]");
/*if(rcpAmtNew <= 0) /*
{ * if(rcpAmtNew <= 0) { errCode = "VTRCPAMT";
errCode = "VTRCPAMT"; * errList.add(errCode);
errList.add(errCode); * errFields.add(childNodeName.toLowerCase()); }
errFields.add(childNodeName.toLowerCase()); */
}*/ //TODO Took care of validation in PostSave Activity.
/*sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? ";
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? " ;
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,checkNull(genericUtility.getColumnValue("ref_ser",dom))); pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2,checkNull(genericUtility.getColumnValue("ref_no",dom))); pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3,custCode); pstmt.setString(3, custCode);
pstmt.setString(4,siteCode); pstmt.setString(4, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next()) if (rs.next()) {
{ rcpAmt = rs.getDouble(1);
rcpAmt=rs.getDouble(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("rcpAmtNew>>>["+rcpAmtNew+"]rcpAmt["+rcpAmt+"]"); System.out.println("rcpAmtNew>>>[" + rcpAmtNew + "]rcpAmt[" + rcpAmt + "]");
//Start added by chandr shekar on 21-mar-2016 // Start added by chandr shekar on 21-mar-2016
sql = "select sum(rcpdet.rcp_amt) as amt from rcpdet_form rcpdet,receipt_form rcpform " + sql = "select nvl(sum(rcpdet.rcp_amt), 0) as amt from rcpdet_form rcpdet, receipt_form rcpform "
"where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? " + + "where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? "
"and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? " + + "and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? "
"AND rcpform.cust_code = ? and rcpform.site_code= ? " ; + "AND rcpform.cust_code = ? and rcpform.site_code= ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,checkNull(genericUtility.getColumnValue("ref_ser",dom))); pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2,checkNull(genericUtility.getColumnValue("ref_no",dom))); pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3,custCode); pstmt.setString(3, custCode);
pstmt.setString(4,siteCode); pstmt.setString(4, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next()) if (rs.next()) {
{ rcpAmtStatus = rs.getDouble(1);
rcpAmtStatus=rs.getDouble(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("rcpAmtStatus>>>"+rcpAmtStatus); System.out.println("rcpAmtStatus>>>" + rcpAmtStatus);
//End added by chandrashekar on 21-mar-2016 // End added by chandrashekar on 21-mar-2016
if(rcpAmt-rcpAmtStatus < rcpAmtNew) if (rcpAmt - rcpAmtStatus < rcpAmtNew) {
{
errCode = "VTINVTLAMT"; errCode = "VTINVTLAMT";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }*/
if (ischqAmtGreater(dom2,chqAmt,lineNo)) /*
{ * if (ischqAmtGreater(dom2,chqAmt,lineNo)) { errCode =
errCode = "VTINVCQAMT"; * "VTINVCQAMT"; errList.add(errCode);
errList.add(errCode); * errFields.add(childNodeName.toLowerCase()); }
errFields.add(childNodeName.toLowerCase()); */
}
} }
} // end for } // end for
break; // case 2 end break; // case 2 end
...@@ -451,24 +374,25 @@ conn = getConnection(); ...@@ -451,24 +374,25 @@ conn = getConnection();
int errListSize = errList.size(); int errListSize = errList.size();
cnt = 0; cnt = 0;
String errFldName = null; String errFldName = null;
if(errList != null && errListSize > 0) if (errList != null && errListSize > 0) {
{ for (cnt = 0; cnt < errListSize; cnt++) {
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt); errCode = errList.get(cnt);
errFldName = errFields.get(cnt); errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode); System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode); errorType = errorType(conn, errCode);
if(errString.length() > 0) if (errString.length() > 0) {
{ String bifurErrString = errString.substring(
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); errString.indexOf("<Errors>") + 8,
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); errString.indexOf("<trace>"));
bifurErrString = bifurErrString
+ errString.substring(
errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
errString = ""; errString = "";
} }
if(errorType.equalsIgnoreCase("E")) if (errorType.equalsIgnoreCase("E")) {
{
break; break;
} }
} }
...@@ -477,41 +401,29 @@ conn = getConnection(); ...@@ -477,41 +401,29 @@ conn = getConnection();
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors> </Root> \r\n"); errStringXml.append("</Errors> </Root> \r\n");
} } else {
else
{
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
} } finally {
finally try {
{ if (conn != null) {
try if (rs != null) {
{
if(conn != null)
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
} }
conn = null; conn = null;
} } catch (Exception d) {
catch(Exception d)
{
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
} }
...@@ -521,77 +433,60 @@ conn = getConnection(); ...@@ -521,77 +433,60 @@ conn = getConnection();
} }
// method for item change // method for item change
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
{ Document dom = null, dom1 = null, dom2 = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = ""; String valueXmlString = "";
System.out.println("xmlString............."+xmlString); System.out.println("xmlString............." + xmlString
System.out.println("xmlString1............"+xmlString1); + "\nxmlString1............" + xmlString1
System.out.println("xmlString2............"+xmlString2); + "\nxmlString2............" + xmlString2);
try try {
{ if (xmlString != null && xmlString.trim().length() > 0) {
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString); dom = parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length() > 0) if (xmlString1 != null && xmlString1.trim().length() > 0) {
{
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length() > 0) if (xmlString2 != null && xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams); valueXmlString = itemChanged(dom, dom1, dom2, objContext,
} currentColumn, editFlag, xtraParams);
catch(Exception e) } catch (Exception e) {
{ System.out
System.out.println("Exception : [EcollectionIC][itemChanged( String, String )] :==>\n" + e.getMessage()); .println("Exception : [EcollectionIC][itemChanged( String, String )] :==>\n"
+ e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return valueXmlString; return valueXmlString;
} }
// method for item change // method for item change
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
{
String sql = "";
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
int ctr = 0; NodeList parentNodeList = null, childNodeList = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
E12GenericUtility genericUtility= new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
int currentFormNo = 0, childNodeListLength = 0, ctr = 0;
String columnValue = "", loginSite = "", loginSiteDesc = "", siteCodeDesc = "", hdrCustCode = "", hdrSiteCode = "", bankCode = "", siteCode = "", custCode = "", bankName = "", custName = "", refNo = "", refSer = "", currencyCode = "", sql = "";
double rcpAmt1 = 0, exchangeRate = 0.0;
int currentFormNo =0, childNodeListLength=0; try {
String columnValue="";
String loginSite="",loginSiteDesc="",siteCodeDesc="",hdrCustCode="",hdrSiteCode="";
String bankCode="",siteCode="",custCode="",bankName="",custName="",refNo="",refSer="",currencyCode="";
double rcpAmt1=0, exchangeRate= 0.0;
try
{
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime()); String sysDate = sdf.format(currentDate.getTime());
//Changes and Commented By Bhushan on 06-06-2016 :START // Changes and Commented By Bhushan on 06-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM"); // conn = connDriver.getConnectDB("DriverITM");
conn = getConnection(); conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END // Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
FinCommon finCommon= new FinCommon(); FinCommon finCommon = new FinCommon();
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0) {
{
currentFormNo = Integer.parseInt(objContext.trim()); currentFormNo = Integer.parseInt(objContext.trim());
} }
...@@ -600,10 +495,13 @@ conn = getConnection(); ...@@ -600,10 +495,13 @@ conn = getConnection();
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>"); valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>"); valueXmlString.append(editFlag).append("</editFlag> </header>");
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************"); UserInfoBean userInfo = getUserInfo();
switch(currentFormNo) String userLevel = userInfo.getUserLevel();
{
case 1 : System.out.println("**********ITEMCHANGE FOR CASE" + currentFormNo + "**************" + userLevel);
switch (currentFormNo) {
case 1:
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
...@@ -611,16 +509,14 @@ conn = getConnection(); ...@@ -611,16 +509,14 @@ conn = getConnection();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "]columnValue ==> '" + columnValue + "'"); System.out.println("currentColumn[" + currentColumn + "]columnValue ==> '" + columnValue + "'");
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
if ( currentColumn.trim().equalsIgnoreCase( "itm_default" )) if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
{
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSite"); loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSite");
sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ?"; sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite); pstmt.setString(1, loginSite);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
loginSiteDesc = rs.getString("DESCR"); loginSiteDesc = rs.getString("DESCR");
bankCode = rs.getString("BANK_CODE"); bankCode = rs.getString("BANK_CODE");
} }
...@@ -628,94 +524,114 @@ conn = getConnection(); ...@@ -628,94 +524,114 @@ conn = getConnection();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?"; sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
bankName = checkNull(rs.getString("BANK_NAME")); bankName = checkNull(rs.getString("BANK_NAME"));
//currencyCode = checkNull(rs.getString("CURR_CODE")); // currencyCode = checkNull(rs.getString("CURR_CODE"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
valueXmlString.append("<tran_date><![CDATA[").append(checkNull(sysDate)).append("]]></tran_date>\r\n"); valueXmlString.append("<tran_date><![CDATA[").append(checkNull(sysDate)).append("]]></tran_date>\r\n");
valueXmlString.append("<eff_date><![CDATA[").append(checkNull(sysDate)).append("]]></eff_date>\r\n"); valueXmlString.append("<eff_date><![CDATA[").append(checkNull(sysDate)).append("]]></eff_date>\r\n");
if("2".equalsIgnoreCase(userLevel)) {
valueXmlString.append("<site_code protect = '1'><![CDATA[").append(loginSite).append("]]></site_code>\r\n");
} else {
valueXmlString.append("<site_code><![CDATA[").append(loginSite).append("]]></site_code>\r\n"); valueXmlString.append("<site_code><![CDATA[").append(loginSite).append("]]></site_code>\r\n");
}
valueXmlString.append("<descr><![CDATA[").append(loginSiteDesc).append("]]></descr>\r\n"); valueXmlString.append("<descr><![CDATA[").append(loginSiteDesc).append("]]></descr>\r\n");
valueXmlString.append("<bank_code><![CDATA[").append(bankCode).append("]]></bank_code>\r\n"); valueXmlString.append("<bank_code><![CDATA[").append(bankCode).append("]]></bank_code>\r\n");
valueXmlString.append("<status><![CDATA[").append("E").append("]]></status>\r\n"); valueXmlString.append("<status><![CDATA[").append("E").append("]]></status>\r\n");
valueXmlString.append("<tran_type><![CDATA[").append("E").append("]]></tran_type>\r\n"); valueXmlString.append("<tran_type><![CDATA[").append("E").append("]]></tran_type>\r\n");
valueXmlString.append("<bank_name>").append("<![CDATA["+bankName+"]]>").append("</bank_name>\r\n"); valueXmlString.append("<bank_name>").append("<![CDATA[" + bankName + "]]>").append("</bank_name>\r\n");
valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n"); valueXmlString.append("<curr_code>").append("<![CDATA[" + currencyCode + "]]>").append("</curr_code>\r\n");
//exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",loginSite, checkNull(sysDate), "S", conn); // exchangeRate =
//System.out.println("exchangeRate>>>>["+exchangeRate+"]"); // finCommon.getDailyExchRateSellBuy(currencyCode,"",loginSite,
valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n"); // checkNull(sysDate), "S", conn);
// System.out.println("exchangeRate>>>>["+exchangeRate+"]");
} valueXmlString.append("<exch_rate>").append("<![CDATA[" + exchangeRate + "]]>").append("</exch_rate>\r\n");
else if( currentColumn.trim().equalsIgnoreCase( "bank_code" ) )
{ } else if (currentColumn.trim().equalsIgnoreCase("bank_code")) {
bankCode = checkNull(genericUtility.getColumnValue("bank_code",dom)); bankCode = checkNull(genericUtility.getColumnValue(
currencyCode = checkNull(genericUtility.getColumnValue("curr_code",dom)); "bank_code", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code",dom)); currencyCode = checkNull(genericUtility.getColumnValue(
"curr_code", dom));
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?"; sql = "SELECT BANK_NAME,CURR_CODE FROM BANK WHERE BANK_CODE =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ bankName = checkNull(rs.getString("BANK_NAME"));
bankName = checkNull(rs.getString( "BANK_NAME" )); // currencyCode = checkNull(rs.getString("CURR_CODE"));
//currencyCode = checkNull(rs.getString("CURR_CODE"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("date>>>>>>"+genericUtility.getColumnValue("tran_date", dom)); System.out.println("date>>>>>>"
//exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode, genericUtility.getColumnValue("tran_date", dom), "S", conn); + genericUtility.getColumnValue("tran_date", dom));
//System.out.println("exchangeRate>>>>@@@@@@@@@["+exchangeRate+"]"); // exchangeRate =
valueXmlString.append("<bank_name>").append("<![CDATA["+bankName+"]]>").append("</bank_name>\r\n"); // finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode,
//valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n"); // genericUtility.getColumnValue("tran_date", dom), "S",
//valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n"); // conn);
// System.out.println("exchangeRate>>>>@@@@@@@@@["+exchangeRate+"]");
}else if( currentColumn.trim().equalsIgnoreCase( "cust_code" ) ) valueXmlString.append("<bank_name>")
{ .append("<![CDATA[" + bankName + "]]>")
custCode = checkNull(genericUtility.getColumnValue("cust_code",dom)); .append("</bank_name>\r\n");
sql = "SELECT CUST_NAME,CURR_CODE FROM CUSTOMER WHERE CUST_CODE = ?"; // valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n");
// valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");
} else if (currentColumn.trim().equalsIgnoreCase("cust_code")) {
custCode = checkNull(genericUtility.getColumnValue("cust_code", dom));
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
//sql = "SELECT CUST_NAME, CURR_CODE FROM CUSTOMER WHERE CUST_CODE = ?";
//TODO
sql = "select c.cust_name as CUST_NAME, c.curr_code as CURR_CODE from customer c join site_customer s on c.cust_code = s.cust_code and s.site_code = ? and c.cust_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode); pstmt.setString(1, siteCode);
pstmt.setString(2, custCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ custName = checkNull(rs.getString("CUST_NAME"));
custName = checkNull(rs.getString( "CUST_NAME" ));
currencyCode = rs.getString("CURR_CODE"); currencyCode = rs.getString("CURR_CODE");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",loginSite, checkNull(sysDate), "S", conn); exchangeRate = finCommon.getDailyExchRateSellBuy(
System.out.println("exchangeRate in (cust_code) :"+exchangeRate); currencyCode, "", loginSite, checkNull(sysDate),
valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n"); "S", conn);
valueXmlString.append("<curr_code><![CDATA[").append(currencyCode).append("]]></curr_code>\r\n"); System.out.println("exchangeRate in (cust_code) :"
valueXmlString.append("<cust_name><![CDATA[").append(custName).append("]]></cust_name>\r\n"); + exchangeRate);
valueXmlString.append("<exch_rate>")
.append("<![CDATA[" + exchangeRate + "]]>")
.append("</exch_rate>\r\n");
}else if( currentColumn.trim().equalsIgnoreCase( "site_code" ) ) valueXmlString.append("<curr_code><![CDATA[")
{ .append(currencyCode).append("]]></curr_code>\r\n");
siteCode = checkNull(genericUtility.getColumnValue("site_code",dom)); valueXmlString.append("<cust_name><![CDATA[")
.append(custName).append("]]></cust_name>\r\n");
} else if (currentColumn.trim().equalsIgnoreCase("site_code")) {
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ? "; sql = "SELECT DESCR,BANK_CODE FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ siteCodeDesc = checkNull(rs.getString("DESCR"));
siteCodeDesc = checkNull(rs.getString( "DESCR" ));
bankCode = rs.getString("BANK_CODE"); bankCode = rs.getString("BANK_CODE");
} }
rs.close(); rs.close();
...@@ -726,27 +642,38 @@ conn = getConnection(); ...@@ -726,27 +642,38 @@ conn = getConnection();
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
bankName = checkNull(rs.getString("BANK_NAME")); bankName = checkNull(rs.getString("BANK_NAME"));
//currencyCode = checkNull(rs.getString("CURR_CODE")); // currencyCode = checkNull(rs.getString("CURR_CODE"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("date>>>>>>"+genericUtility.getColumnValue("tran_date", dom)); System.out.println("date>>>>>>"
//exchangeRate = finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode, genericUtility.getColumnValue("tran_date", dom), "S", conn); + genericUtility.getColumnValue("tran_date", dom));
//System.out.println("exchangeRate>>>>@@@@@@@@@>>>>>>>>>["+exchangeRate+"]"); // exchangeRate =
valueXmlString.append("<descr><![CDATA[").append(siteCodeDesc).append("]]></descr>\r\n"); // finCommon.getDailyExchRateSellBuy(currencyCode,"",siteCode,
valueXmlString.append("<bank_code><![CDATA[").append(bankCode).append("]]></bank_code>\r\n"); // genericUtility.getColumnValue("tran_date", dom), "S",
valueXmlString.append("<bank_name><![CDATA[").append(bankName).append("]]></bank_name>\r\n"); // conn);
/*valueXmlString.append("<curr_code>").append("<![CDATA["+currencyCode+"]]>").append("</curr_code>\r\n"); // System.out.println("exchangeRate>>>>@@@@@@@@@>>>>>>>>>["+exchangeRate+"]");
valueXmlString.append("<exch_rate>").append("<![CDATA["+exchangeRate+"]]>").append("</exch_rate>\r\n");*/ valueXmlString.append("<descr><![CDATA[")
.append(siteCodeDesc).append("]]></descr>\r\n");
valueXmlString.append("<bank_code><![CDATA[")
.append(bankCode).append("]]></bank_code>\r\n");
valueXmlString.append("<bank_name><![CDATA[")
.append(bankName).append("]]></bank_name>\r\n");
/*
* valueXmlString.append("<curr_code>").append("<![CDATA["+
* currencyCode+"]]>").append("</curr_code>\r\n");
* valueXmlString
* .append("<exch_rate>").append("<![CDATA["+exchangeRate
* +"]]>").append("</exch_rate>\r\n");
*/
} }
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
break; break;
case 2 : case 2:
parentNodeList = dom.getElementsByTagName("Detail2"); parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
...@@ -754,20 +681,22 @@ conn = getConnection(); ...@@ -754,20 +681,22 @@ conn = getConnection();
valueXmlString.append("<Detail2>"); valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
System.out.println("currentColumn[" + currentColumn + "] ==> '" + columnValue + "'"); System.out.println("currentColumn[" + currentColumn + "] ==> '" + columnValue + "'");
if ( currentColumn.trim().equalsIgnoreCase("itm_default") ) if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
{
hdrCustCode = this.genericUtility.getColumnValue("cust_code", dom1); hdrCustCode = this.genericUtility.getColumnValue("cust_code", dom1);
hdrSiteCode = this.genericUtility.getColumnValue("site_code", dom1); hdrSiteCode = this.genericUtility.getColumnValue("site_code", dom1);
valueXmlString.append("<line_no__ref><![CDATA[" ).append("1").append( "]]></line_no__ref>\r\n"); valueXmlString.append("<line_no__ref><![CDATA[").append("1").append("]]></line_no__ref>\r\n");
valueXmlString.append("<udf_str1><![CDATA[").append(hdrSiteCode).append("]]></udf_str1>\r\n"); valueXmlString.append("<udf_str1><![CDATA[").append(hdrSiteCode).append("]]></udf_str1>\r\n");
valueXmlString.append("<udf_str2><![CDATA[").append(hdrCustCode).append("]]></udf_str2>\r\n"); valueXmlString.append("<udf_str2><![CDATA[").append(hdrCustCode).append("]]></udf_str2>\r\n");
} else if (currentColumn.trim().equalsIgnoreCase("ref_no")
}else if( currentColumn.trim().equalsIgnoreCase( "ref_no" ) ||currentColumn.trim().equalsIgnoreCase( "ref_ser" ) ) || currentColumn.trim().equalsIgnoreCase("ref_ser")) {
{ refNo = checkNull(genericUtility.getColumnValue("ref_no",
refNo = checkNull(genericUtility.getColumnValue("ref_no",dom)); dom));
refSer = checkNull(genericUtility.getColumnValue("ref_ser",dom)); refSer = checkNull(genericUtility.getColumnValue("ref_ser",
custCode = this.genericUtility.getColumnValue("cust_code", dom1); dom));
siteCode = this.genericUtility.getColumnValue("site_code", dom1); custCode = this.genericUtility.getColumnValue("cust_code",
dom1);
siteCode = this.genericUtility.getColumnValue("site_code",
dom1);
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? and cust_code= ? and site_code = ? "; sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? and cust_code= ? and site_code = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, refSer); pstmt.setString(1, refSer);
...@@ -776,42 +705,36 @@ conn = getConnection(); ...@@ -776,42 +705,36 @@ conn = getConnection();
pstmt.setString(4, siteCode); pstmt.setString(4, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if( rs.next() ) if (rs.next()) {
{ rcpAmt1 = rs.getDouble(1);
rcpAmt1=rs.getDouble(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("receipt amount["+getRequiredDecimal(rcpAmt1,2)+"]"); System.out.println("receipt amount["
valueXmlString.append("<rcp_amt><![CDATA[").append( getRequiredDecimal(rcpAmt1,2) ).append("]]></rcp_amt>\r\n"); + getRequiredDecimal(rcpAmt1, 2) + "]");
valueXmlString.append("<rcp_amt><![CDATA[")
.append(getRequiredDecimal(rcpAmt1, 2))
.append("]]></rcp_amt>\r\n");
} }
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
break; break;
} }
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage()); System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} } finally {
finally try {
{ if (conn != null) {
try if (rs != null) {
{
if(conn != null)
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
...@@ -819,87 +742,74 @@ conn = getConnection(); ...@@ -819,87 +742,74 @@ conn = getConnection();
conn.close(); conn.close();
} }
conn = null; conn = null;
} } catch (Exception d) {
catch(Exception d)
{
d.printStackTrace(); d.printStackTrace();
} }
} }
return valueXmlString.toString(); return valueXmlString.toString();
} }
private String checkNull(String input) private String checkNull(String input) {
{ if (input == null) {
if(input == null)
{
input = ""; input = "";
} }
return input; return input;
} }
public String getRequiredDecimal(double actVal, int prec)//Added by chandrashekar on 11-08-14
public String getRequiredDecimal(double actVal, int prec)// Added by
// chandrashekar
// on 11-08-14
{ {
String fmtStr = "############0"; String fmtStr = "############0";
if (prec > 0) if (prec > 0) {
{
fmtStr = fmtStr + "." + "000000000".substring(0, prec); fmtStr = fmtStr + "." + "000000000".substring(0, prec);
} }
DecimalFormat decFormat = new DecimalFormat(fmtStr); DecimalFormat decFormat = new DecimalFormat(fmtStr);
return decFormat.format(actVal); return decFormat.format(actVal);
} }
public static java.util.Date relativeDate(java.util.Date date, int days)
{ public static java.util.Date relativeDate(java.util.Date date, int days) {
java.util.Date calculatedDate = null; java.util.Date calculatedDate = null;
if (date != null) if (date != null) {
{
final GregorianCalendar calendar = new GregorianCalendar(); final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date); calendar.setTime(date);
calendar.add(Calendar.DATE,days); calendar.add(Calendar.DATE, days);
calculatedDate = new java.util.Date(calendar.getTime().getTime()); calculatedDate = new java.util.Date(calendar.getTime().getTime());
} }
return calculatedDate; return calculatedDate;
} }
private String errorType(Connection conn , String errorCode) throws ITMException
{ private String errorType(Connection conn, String errorCode)
throws ITMException {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try {
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} } catch (Exception ex) {
catch(Exception ex)
{
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} } finally {
finally try {
{ if (rs != null) {
try
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
...@@ -907,172 +817,135 @@ conn = getConnection(); ...@@ -907,172 +817,135 @@ conn = getConnection();
return msgType; return msgType;
} }
private boolean isDulplicateFrmDom(Document dom,String refNo, String lineNo,String refSer) throws ITMException private boolean isDulplicateFrmDom(Document dom, String refNo,
{ String lineNo, String refSer) throws ITMException {
NodeList parentList = null; NodeList parentList = null, childList = null;
NodeList childList = null; Node parentNode = null, childNode = null;
Node parentNode = null; String lineNoDom = "", refNoDom = "", refSerDom = "";
Node childNode = null;
String lineNoDom = "";
boolean isDulplicate = false; boolean isDulplicate = false;
String refNoDom= "",refSerDom=""; System.out.println("---inside method[isDulplicateFrmDom] -- EJB ["
System.out.println("---inside isDulplicateFrmDom--"); + this.getClass().getSimpleName() + "]");
try try {
{
parentList = dom.getElementsByTagName("Detail2"); parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength(); int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- ) for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
{ parentNode = parentList.item(prntCtr - 1);
parentNode = parentList.item(prntCtr-1);
childList = parentNode.getChildNodes(); childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++) for (int ctr = 0; ctr < childList.getLength(); ctr++) {
{
childNode = childList.item(ctr); childNode = childList.item(ctr);
if (childNode != null
if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) && childNode.getNodeName().equalsIgnoreCase(
{ "attribute")) {
String updateFlag = ""; String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue(); updateFlag = childNode.getAttributes()
if (updateFlag.equalsIgnoreCase("D")) .getNamedItem("updateFlag").getNodeValue();
{ if (updateFlag.equalsIgnoreCase("D")) {
System.out.println("Break from here as the record is deleted"); System.out
.println("Break from here as the record is deleted");
break; break;
} }
} }
if ( childNode != null && childNode.getFirstChild() != null && if (childNode != null
childNode.getNodeName().equalsIgnoreCase("line_no") ) && childNode.getFirstChild() != null
{ && childNode.getNodeName().equalsIgnoreCase(
lineNoDom = childNode.getFirstChild().getNodeValue().trim(); "line_no")) {
System.out.println("lineNo["+lineNo+"]lineNoDom["+lineNoDom+"]"); lineNoDom = childNode.getFirstChild().getNodeValue()
if (lineNo.equalsIgnoreCase(lineNoDom)) .trim();
{ System.out.println("lineNo[" + lineNo + "]lineNoDom["
System.out.println("Break from here as line No match"); + lineNoDom + "]");
if (lineNo.equalsIgnoreCase(lineNoDom)) {
System.out
.println("Break from here as line No match");
break; break;
} }
} }
if (childNode != null
if ( childNode != null && childNode.getFirstChild() != null && && childNode.getFirstChild() != null
childNode.getNodeName().equalsIgnoreCase("REF_NO") ) && childNode.getNodeName().equalsIgnoreCase(
{ "ref_no")) {
refNoDom = childNode.getFirstChild().getNodeValue().trim(); refNoDom = childNode.getFirstChild().getNodeValue()
.trim();
} }
if ( childNode != null && childNode.getFirstChild() != null && if (childNode != null
childNode.getNodeName().equalsIgnoreCase("ref_ser") ) && childNode.getFirstChild() != null
{ && childNode.getNodeName().equalsIgnoreCase(
refSerDom = childNode.getFirstChild().getNodeValue().trim(); "ref_ser")) {
refSerDom = childNode.getFirstChild().getNodeValue()
.trim();
} }
} }
if (refSer.trim().equalsIgnoreCase(refSerDom.trim()) && refNo.trim().equalsIgnoreCase(refNoDom.trim()) ) if (refSer.trim().equalsIgnoreCase(refSerDom.trim())
{ && refNo.trim().equalsIgnoreCase(refNoDom.trim())) {
isDulplicate = true; isDulplicate = true;
break; break;
} }
}//for loop
}catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
} }
catch(Exception e) } catch (Exception e) {
{ e.printStackTrace();
} finally {
try {
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
System.out.println("isDulplicate>>>>>> ["+isDulplicate+"]"); System.out.println("returning from method[isDulplicateFrmDom] -- EJB ["
+ this.getClass().getSimpleName() + "] return Value : ["
+ isDulplicate + "]");
return isDulplicate; return isDulplicate;
} }
private boolean ischqAmtGreater(Document dom, double chqAmt, String lineNo)
{
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String lineNoDom = "",rcpAmtSt=""; @SuppressWarnings("unused")
private boolean ischqAmtGreater(Document dom, double chqAmt, String lineNo) {
NodeList parentList = null, childList = null;
Node parentNode = null, childNode = null;
String rcpAmtSt = "";
boolean ischqAmtGreater = false; boolean ischqAmtGreater = false;
double chqAmtMeth=0.0,chqAmtSum=0.0; double chqAmtMeth = 0.0, chqAmtSum = 0.0;
String refNoDom= "",refSerDom="";
System.out.println("---inside ischqAmtGreater--"); System.out.println("---inside ischqAmtGreater--");
try try {
{
parentList = dom.getElementsByTagName("Detail2"); parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength(); int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- ) for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
{ parentNode = parentList.item(prntCtr - 1);
parentNode = parentList.item(prntCtr-1);
childList = parentNode.getChildNodes(); childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++) for (int ctr = 0; ctr < childList.getLength(); ctr++) {
{
childNode = childList.item(ctr); childNode = childList.item(ctr);
System.out.println("childNode>>>"+childNode); System.out.println("childNode>>>" + childNode);
if(childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) if (childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) {
{
String updateFlag = ""; String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue(); updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("updateFlag>>>"+updateFlag); System.out.println("updateFlag>>>" + updateFlag);
if (updateFlag.equalsIgnoreCase("D")) if (updateFlag.equalsIgnoreCase("D")) {
{
System.out.println("Break from here as the record is deleted"); System.out.println("Break from here as the record is deleted");
break; break;
} }
} }
if ( childNode != null && childNode.getFirstChild() != null && if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("rcp_amt")) {
childNode.getNodeName().equalsIgnoreCase("rcp_amt") )
{
rcpAmtSt = childNode.getFirstChild().getNodeValue().trim(); rcpAmtSt = childNode.getFirstChild().getNodeValue().trim();
if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0) if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0) {
{ try {
try chqAmtMeth = Double.parseDouble(rcpAmtSt);
{ } catch (NumberFormatException n) {
chqAmtMeth= Double.parseDouble(rcpAmtSt);
} catch (NumberFormatException n)
{
chqAmtMeth = 0; chqAmtMeth = 0;
} }
} }
} }
} }
chqAmtSum=chqAmtSum+chqAmtMeth; chqAmtSum = chqAmtSum + chqAmtMeth;
}
}//for loop System.out.println("chqAmtSum>>>[" + chqAmtSum + "]chqAmt>>>>[" + chqAmt + "]");
System.out.println("chqAmtSum>>>["+chqAmtSum+"]chqAmt>>>>["+chqAmt+"]"); if (chqAmt < chqAmtSum) {
if (chqAmt < chqAmtSum)
{
ischqAmtGreater = true; ischqAmtGreater = true;
} }
} catch (Exception e) {
}catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
} } finally {
finally try {
{ } catch (Exception e) {
try
{
}
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
System.out.println("ischqAmtGreater>>>>>> ["+ischqAmtGreater+"]"); System.out.println("ischqAmtGreater>>>>>> [" + ischqAmtGreater + "]");
return ischqAmtGreater; return ischqAmtGreater;
} }
//end of validation
} }
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import org.w3c.dom.Document;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
//import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
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.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless @Stateless
public class EcollectionPostSave extends ValidatorEJB implements EcollectionPostSaveLocal,EcollectionPostSaveRemote { public class EcollectionPostSave extends ValidatorEJB implements EcollectionPostSaveLocal, EcollectionPostSaveRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{ public String postSave(String xmlString, String tranId, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException {
System.out.println("------------ postSave method called-----------------EcollectionPostSave : "); System.out.println("------------ postSave method called-----------------EcollectionPostSave : ");
System.out.println("tranId111--->>["+tranId+"]"); System.out.println("tranId111--->>[" + tranId + "]");
System.out.println("xml String--->>["+xmlString+"]"); System.out.println("xml String--->>[" + xmlString + "]");
Document dom = null; Document dom = null;
String errString=""; String errString = "";
try {
try if (xmlString != null && xmlString.trim().length() > 0) {
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString); dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn); errString = postSave(dom, tranId, xtraParams, conn);
}
} }
catch(Exception e) } catch (Exception e) {
{ System.out.println("Exception : EcollectionPostSave.java : postSave : ==>\n" + e.getMessage());
System.out.println("Exception : EcollectionPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return errString; return errString;
} }
public String postSave(Document dom,String tranId,String xtraParams,Connection conn)
{ public String postSave(Document dom, String tranId, String xtraParams, Connection conn) {
System.out.println("in EcollectionPostSave tran_id---->>["+tranId+"]"); System.out.println("in EcollectionPostSave tran_id---->>[" + tranId + "]");
ResultSet rs=null; ResultSet rs = null;
PreparedStatement pstmt=null; PreparedStatement pstmt = null;
String sql="",errorString=""; String sql = "", errorString = "", custCode = "", siteCode = "", errCode = "";
double rcpamt=0; double rcpAmt = 0, chqAmt = 0, rcpamtSum = 0, rcpAmtT = 0, rcpAmtNew = 0, rcpAmtStatus = 0;
double rcpamtSum=0; int count = 0;
int count=0;
try try {
{ // GenericUtility genericUtility = GenericUtility.getInstance();
// GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
tranId = genericUtility.getColumnValue("tran_id",dom); String userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tranId--->>["+tranId+"]"); tranId = genericUtility.getColumnValue("tran_id", dom);
chqAmt = Double.parseDouble(genericUtility.getColumnValue("chq_amt", dom, "1"));
custCode = genericUtility.getColumnValue("cust_code", dom, "1");
siteCode = genericUtility.getColumnValue("site_code", dom, "1");
sql = "SELECT (TOT_AMT - ADJ_AMT) AS AMT FROM RECEIVABLES WHERE TRAN_SER = ? AND REF_NO = ? AND cust_code = ? and site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmt = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtNew>>>[" + rcpAmtNew + "]rcpAmt[" + rcpAmt + "]");
// Start added by chandr shekar on 21-mar-2016
sql = "select nvl(sum(rcpdet.rcp_amt), 0) as amt from rcpdet_form rcpdet, receipt_form rcpform "
+ "where rcpform.tran_id=rcpdet.tran_id and rcpdet.ref_ser=? "
+ "and rcpdet.rcp_amt>0 and rcpform.status !='X' and rcpdet.ref_no=? "
+ "AND rcpform.cust_code = ? and rcpform.site_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(genericUtility.getColumnValue("ref_ser", dom)));
pstmt.setString(2, checkNull(genericUtility.getColumnValue("ref_no", dom)));
pstmt.setString(3, custCode);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
rcpAmtStatus = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("rcpAmtStatus>>>" + rcpAmtStatus);
// End added by chandrashekar on 21-mar-2016
if (rcpAmt - rcpAmtStatus < rcpAmtNew) {
errCode = "VTINVTLAMT";
errorString = getErrorString("", errCode, userId);
return errorString;
}
sql = "SELECT rcp_amt FROM RCPDET_FORM WHERE tran_id = ? "; if(isChqAmtGreater(dom, chqAmt)){
errCode = "VTINVCQAMT";
errorString = getErrorString("rcp_amt", errCode, userId);
return errorString;
}
System.out.println("tranId--->>[" + tranId + "]");
sql = "SELECT NVL(SUM(RCP_AMT), 0) FROM RCPDET_FORM WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while( rs.next() ) while (rs.next()) {
{
count++; count++;
rcpamt=rs.getDouble(1); rcpAmtT = rs.getDouble(1);
rcpamtSum=rcpamtSum+rcpamt; rcpamtSum = rcpamtSum + rcpAmtT;
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("rcpamtSum>>>>>>>>" + rcpamtSum);
System.out.println("rcpamtSum>>>>>>>>"+rcpamtSum); if(chqAmt > rcpamtSum) {
System.out.println("count>>>>>>>>"+count); System.out.println("Receipt Amount is Less... :)");
errCode = "VTINVCQAMT";
errorString = getErrorString("rcp_amt", errCode, userId);
return errorString;
}
System.out.println("count>>>>>>>>" + count);
if(count >0) /*if (count > 0) {
{ sql = "update receipt_form set chq_amt = ? where tran_id = ?";
sql="update receipt_form set chq_amt = ? where tran_id = ?"; pstmt = conn.prepareStatement(sql);
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, rcpamtSum); pstmt.setDouble(1, rcpamtSum);
pstmt.setString(2, tranId); pstmt.setString(2, tranId);
count=pstmt.executeUpdate(); count = pstmt.executeUpdate();
System.out.println("post count---->>["+count+"]"); System.out.println("post count---->>[" + count + "]");
if(count >0 ) if (count > 0) {
{
conn.commit(); conn.commit();
} }
}else } else {
{
conn.rollback(); conn.rollback();
} }*/
} } catch (Exception e) {
catch(Exception e) System.out.println("Exception : EcollectionPostSave -->["
{ + e.getMessage() + "]");
System.out.println("Exception : EcollectionPostSave -->["+e.getMessage()+"]");
e.printStackTrace(); e.printStackTrace();
try try {
{
conn.rollback(); conn.rollback();
} } catch (Exception e1) {
catch(Exception e1) System.out
{ .println("Exception while rollbacking transaction....");
System.out.println("Exception while rollbacking transaction....");
e1.printStackTrace(); e1.printStackTrace();
} }
} }
return errorString; return errorString;
} }
private String checkNull(String columnValue) {
return columnValue == null ? "" : columnValue;
}
private boolean isChqAmtGreater(Document dom, double chqAmt) {
NodeList parentList = null, childList = null;
Node parentNode = null, childNode = null;
String lineNoDom = "", rcpAmtSt = "";
boolean ischqAmtGreater = false;
double chqAmtMeth = 0.0, chqAmtSum = 0.0;
String refNoDom = "", refSerDom = "";
System.out.println("---inside ischqAmtGreater--");
try {
parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr--) {
parentNode = parentList.item(prntCtr - 1);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++) {
childNode = childList.item(ctr);
System.out.println("childNode>>>" + childNode);
if (childNode != null && childNode.getNodeName().equalsIgnoreCase("attribute")) {
String updateFlag = "";
updateFlag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("updateFlag>>>" + updateFlag);
if (updateFlag.equalsIgnoreCase("D")) {
System.out.println("Break from here as the record is deleted");
break;
}
}
if (childNode != null && childNode.getFirstChild() != null && childNode.getNodeName().equalsIgnoreCase("rcp_amt")) {
rcpAmtSt = childNode.getFirstChild().getNodeValue().trim();
if (rcpAmtSt != null && rcpAmtSt.trim().length() > 0) {
try {
chqAmtMeth = Double.parseDouble(rcpAmtSt);
} catch (NumberFormatException n) {
chqAmtMeth = 0;
}
}
}
}
chqAmtSum = chqAmtSum + chqAmtMeth;
}// for loop
System.out.println("chqAmtSum>>>[" + chqAmtSum + "] : chqAmt>>>>[" + chqAmt + "]");
if (chqAmt < chqAmtSum) {
ischqAmtGreater = true;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("ischqAmtGreater>>>>>> [" + ischqAmtGreater + "]");
return ischqAmtGreater;
}
} }
...@@ -5,150 +5,153 @@ ...@@ -5,150 +5,153 @@
********************************************************/ ********************************************************/
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import ibase.scheduler.utility.interfaces.Schedule; import ibase.scheduler.utility.interfaces.Schedule;
import java.util.*; import ibase.system.config.AppConnectParm;
import java.util.Date; import ibase.system.config.ConnDriver;
import java.sql.*; import ibase.utility.CommonConstants;
import org.w3c.dom.*; import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.ejb.fin.adv.ReceiptAdvConf;
import ibase.webitm.utility.ITMException;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*; import org.w3c.dom.Document;
import ibase.webitm.ejb.fin.adv.ReceiptAdvConf; import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//import ibase.webitm.utility.GenericUtility; //import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import ibase.utility.CommonConstants;
import java.text.SimpleDateFormat;
import ibase.utility.E12GenericUtility;
public class EcollectionSchedule implements Schedule @SuppressWarnings({ "rawtypes", "unused" })
{ public class EcollectionSchedule implements Schedule {
String chgUser = null; String chgUser = null;
String chgTerm = null; String chgTerm = null;
static long count_records=0; static long count_records = 0;
boolean isError = false; boolean isError = false;
String loginSiteCode = ""; String loginSiteCode = "";
String retString=""; String retString = "";
E12GenericUtility e12GenericUtility = new E12GenericUtility(); E12GenericUtility e12GenericUtility = new E12GenericUtility();
FileOutputStream fos1 = null; FileOutputStream fos1 = null;
java.util.Date startDate = new java.util.Date(System.currentTimeMillis()); java.util.Date startDate = new java.util.Date(System.currentTimeMillis());
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
String startDateStr = null; String startDateStr = null;
public static void main(String args[])
{ public static void main(String args[]) {
EcollectionSchedule ecs=new EcollectionSchedule(); EcollectionSchedule ecs = new EcollectionSchedule();
System.out.println("Main Method Calling******************************************************88"); System.out
.println("Main Method Calling******************************************************88");
} }
public String schedulePriority( String wrkflwPriority )throws Exception public String schedulePriority(String wrkflwPriority) throws Exception {
{
return ""; return "";
} }
public String schedule(HashMap map)throws Exception
{
public String schedule(HashMap map) throws Exception {
return ""; return "";
} }
public String schedule(String scheduleParamXML)throws Exception
{ public String schedule(String scheduleParamXML) throws Exception {
String siteCode = "",actualLoginSiteCode="",errString=""; String siteCode = "", actualLoginSiteCode = "", errString = "";
String xtraParams = ""; String xtraParams = "";
ibase.utility.UserInfoBean userInfo = null; UserInfoBean userInfo = null;
try try {
{ System.out.println("************ [" + scheduleParamXML + "]");
System.out.println("************ ["+scheduleParamXML+"]"); userInfo = new UserInfoBean(scheduleParamXML);
userInfo = new ibase.utility.UserInfoBean( scheduleParamXML );
siteCode = userInfo.getSiteCode(); siteCode = userInfo.getSiteCode();
xtraParams = "loginEmpCode="+userInfo.getEmpCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+loginSiteCode; xtraParams = "loginEmpCode=" + userInfo.getEmpCode() + "~~termId="
+ userInfo.getRemoteHost() + "~~loginSiteCode="
+ loginSiteCode;
//GenericUtility genericUtility=GenericUtility.getInstance(); // GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility= new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
Document dom=genericUtility.parseString(scheduleParamXML); Document dom = genericUtility.parseString(scheduleParamXML);
NodeList paramList = dom.getElementsByTagName( "SCHEDULE" ); NodeList paramList = dom.getElementsByTagName("SCHEDULE"), parentNodeList = null, childNodeList = null;
NodeList parentNodeList = null,childNodeList = null; Node parentNode = null, childNode = null;
Node parentNode = null,childNode = null;
int childNodeListLength = 0; int childNodeListLength = 0;
String childNodeName = null; String childNodeName = null;
parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS"); parentNodeList = dom.getElementsByTagName("ACTUALPARAMETERS");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++) for (int ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName != null && !"#text".equalsIgnoreCase(childNodeName)) {
if(childNodeName!=null && !"#text".equalsIgnoreCase(childNodeName)) if (ctr == 0) {
{ actualLoginSiteCode = childNode.getFirstChild().getNodeValue();
if(ctr==0)
{
actualLoginSiteCode=childNode.getFirstChild().getNodeValue();
} }
} }
} }
System.out.println("ActualLoginSiteCode----["+actualLoginSiteCode+"]"); System.out.println("ActualLoginSiteCode----[" + actualLoginSiteCode + "]");
System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........."+ intializingLog("ecollection_log")); System.out.println("intializingLog$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$........." + intializingLog("ecollection_log"));
if(("null".equals(actualLoginSiteCode) || actualLoginSiteCode.trim().length() == 0 )) if (("null".equals(actualLoginSiteCode) || actualLoginSiteCode
{ .trim().length() == 0)) {
siteCode = userInfo.getSiteCode(); siteCode = userInfo.getSiteCode();
System.out.println("Site code >>>>>>>>>> "+siteCode); System.out.println("Site code >>>>>>>>>> " + siteCode);
errString= insertReceipt(siteCode,scheduleParamXML,xtraParams); errString = insertReceipt(siteCode, scheduleParamXML,
} xtraParams);
else } else {
{ String[] arrStr = actualLoginSiteCode.split(",");
String[] arrStr =actualLoginSiteCode.split(","); int len = arrStr.length;
int len =arrStr.length; for (int i = 0; i < len; i++) {
for(int i =0;i<len;i++) loginSiteCode = arrStr[i];
{ System.out.println("loginSiteCode>>>>>>>>" + loginSiteCode);
loginSiteCode =arrStr[i]; errString = insertReceipt(loginSiteCode, scheduleParamXML,
System.out.println("loginSiteCode>>>>>>>>"+loginSiteCode); xtraParams);
errString= insertReceipt(loginSiteCode,scheduleParamXML,xtraParams);
} }
} }
} } catch (Exception e) {
catch(Exception e)
{
throw new Exception(e); throw new Exception(e);
} }
System.out.println("errString>>>["+errString+"]"); System.out.println("errString>>>[" + errString + "]");
return errString; return errString;
} }
public String insertReceipt(String siteCode , String scheduleParamXML,String xtraParams) throws Exception
{
public String insertReceipt(String siteCode, String scheduleParamXML, String xtraParams) throws Exception {
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
PreparedStatement pstmt1 = null; PreparedStatement pstmt1 = null;
ResultSet rs1 = null; ResultSet rs1 = null;
String sql=""; String sql = "";
String tranId=""; String tranId = "";
String tranDate =null; String tranDate = null;
String bankCode = "",refNo="",custCode="",tranType="",rcpMode="",finEntity="",remarks=""; String bankCode = "", refNoHdr = "", custCode = "", tranType = "", rcpMode = "", finEntity = "", remarks = "";
String sql1="",refSer="",lineNoRef=""; String sql1 = "", refSer = "", lineNoRef = "";
String errString ="",xmlString=""; String errString = "", xmlString = "";
String strToWrite = ""; String strToWrite = "";
String endDateStr = null; String endDateStr = null;
String currencyCode="",stmtId=""; String currencyCode = "", stmtId = "";
double exchRate = 0.0; double exchRate = 0.0;
double rcpAmt=0,bankAmount=0,rcpAmtDet=0; double rcpAmt = 0, bankAmount = 0, rcpAmtDet = 0;
int cnt=0,lineNo=0,bankCnt=0; int cnt = 0, lineNo = 0, bankCnt = 0;
Date refDate=null,effDate=null; Date refDate = null, effDate = null;
//E12GenericUtility e12GenericUtility = new E12GenericUtility(); // E12GenericUtility e12GenericUtility = new E12GenericUtility();
SimpleDateFormat sdf = new SimpleDateFormat(e12GenericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(e12GenericUtility.getApplDateFormat());
ReceiptAdvConf ReceiptAdv = new ReceiptAdvConf(); ReceiptAdvConf ReceiptAdv = new ReceiptAdvConf();
java.util.Date startDate = new java.util.Date(System.currentTimeMillis()); java.util.Date startDate = new java.util.Date(
System.currentTimeMillis());
java.util.Date endDate = new java.util.Date(System.currentTimeMillis()); java.util.Date endDate = new java.util.Date(System.currentTimeMillis());
try try {
{
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
...@@ -158,16 +161,17 @@ public class EcollectionSchedule implements Schedule ...@@ -158,16 +161,17 @@ public class EcollectionSchedule implements Schedule
java.util.Calendar cal = java.util.Calendar.getInstance(); java.util.Calendar cal = java.util.Calendar.getInstance();
tranDate = simpleDateFormat.format(cal.getTime()); tranDate = simpleDateFormat.format(cal.getTime());
sql = "select bank_code,ref_no,chq_amt,cust_code,tran_type,rcp_mode,ref_date,eff_date," + /*sql = "select bank_code,ref_no,chq_amt,cust_code,tran_type,rcp_mode,ref_date,eff_date,"
"remarks,tran_id,curr_code,exch_rate,stmt_id from " + " receipt_form where confirmed='Y' and status='C' and site_code= ? "; + "remarks,tran_id,curr_code,exch_rate,stmt_id from "
+ " receipt_form where confirmed='Y' and status='C' and site_code= ? ";*/
sql = "select d.ref_ser, h.bank_code,h.ref_no,h.chq_amt,h.cust_code,h.tran_type,h.rcp_mode,h.ref_date,h.eff_date,h.remarks,h.tran_id,h.curr_code,h.exch_rate,h.stmt_id from receipt_form h join rcpdet_form d on h.tran_id = d.tran_id and confirmed='Y' and status='C' and site_code= ? and d.line_no = 1";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next()) {
{ lineNo = 0;
bankCode = rs.getString("bank_code"); bankCode = rs.getString("bank_code");
refNo = rs.getString("ref_no"); refNoHdr = rs.getString("ref_no");
custCode = rs.getString("cust_code"); custCode = rs.getString("cust_code");
rcpAmt = rs.getDouble("chq_amt"); rcpAmt = rs.getDouble("chq_amt");
tranType = rs.getString("tran_type"); tranType = rs.getString("tran_type");
...@@ -178,23 +182,41 @@ public class EcollectionSchedule implements Schedule ...@@ -178,23 +182,41 @@ public class EcollectionSchedule implements Schedule
tranId = rs.getString("tran_id"); tranId = rs.getString("tran_id");
currencyCode = rs.getString("curr_code"); currencyCode = rs.getString("curr_code");
exchRate = rs.getDouble("exch_rate"); exchRate = rs.getDouble("exch_rate");
refSer = rs.getString("ref_ser");
refSer = refSer == null ? "" : refSer.trim();
stmtId = rs.getString("stmt_id"); stmtId = rs.getString("stmt_id");
stmtId = stmtId == null ? "" : stmtId.trim();
System.out.println("receipt form tranId:::::::::" + tranId); System.out.println("receipt form tranId:::::::::" + tranId);
strToWrite = tranId+","; strToWrite = tranId + ",";
startDate = new java.util.Date(System.currentTimeMillis()); startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis())); calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND); startDateStr = sdf1.format(startDate) + " " + calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
strToWrite=strToWrite+startDateStr+","; strToWrite = strToWrite + startDateStr + ",";
System.out.println("STARTING DATE: [" + startDateStr + "]: STRING TO WRITE:[" + strToWrite + "].");
System.out.println("STARTING DATE"+startDateStr +"STRING TO WRITE"+strToWrite); /*sql1 = "select * from receivables where cust_code = ? and tran_ser = ? and ref_no = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, custCode);
pstmt1.setString(2, refSer);
pstmt1.setString(3, refNo);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
} else {
System.out.println("Invalid Ref_No: [" + refNo + "]: for Transaction of E-Collection:[" + tranId + "].");
continue;
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;*/
sql1 = " select fin_entity from site where site_code=? "; sql1 = " select fin_entity from site where site_code=? ";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode); pstmt1.setString(1, siteCode);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
if (rs1.next()) if (rs1.next()) {
{
finEntity = rs1.getString("fin_entity"); finEntity = rs1.getString("fin_entity");
} }
rs1.close(); rs1.close();
...@@ -203,25 +225,66 @@ public class EcollectionSchedule implements Schedule ...@@ -203,25 +225,66 @@ public class EcollectionSchedule implements Schedule
pstmt1 = null; pstmt1 = null;
finEntity = finEntity == null ? "" : finEntity.trim(); finEntity = finEntity == null ? "" : finEntity.trim();
/*bankAmount=0; /*
sql1 = " select amount from bank_statement where site_code=? and bank_code= ? and ref_no= ?"; * bankAmount=0; sql1 =
* " select amount from bank_statement where site_code=? and bank_code= ? and ref_no= ?"
* ; pstmt1 = conn.prepareStatement(sql1); pstmt1.setString(1,
* siteCode); pstmt1.setString(2, bankCode); pstmt1.setString(3,
* refNo); rs1 = pstmt1.executeQuery(); if (rs1.next()) {
* bankAmount = rs1.getDouble("amount"); } rs1.close(); rs1 =
* null; pstmt1.close(); pstmt1 = null;
*/
// System.out.println("bankAmount>>>>>>[" + bankAmount +
// "]rcpAmt>>>>>[" + rcpAmt + ']');
// if (rcpAmt == bankAmount)
// {
if(stmtId.trim().length() == 0 ) {
String bankGroup = "";
sql1 = "select group_code from bank where bank_code= ?";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, siteCode); pstmt1.setString(1, bankCode);
pstmt1.setString(2, bankCode);
pstmt1.setString(3, refNo);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
if (rs1.next()) if (rs1.next()) {
{ bankGroup = rs1.getString("group_code").trim();
bankAmount = rs1.getDouble("amount");
} }
rs1.close(); rs1.close();
rs1 = null; rs1 = null;
pstmt1.close(); pstmt1.close();
pstmt1 = null;*/ pstmt1 = null;
java.sql.Date dtTemp = new java.sql.Date(refDate.getTime());
sql1 = "select b.tran_id as stmt_id from bank_statement b,site s, bank bank where s.fin_entity= ? " +
" and s.site_code = b.site_code and bank.bank_code=b.bank_code and bank.group_code= ? " +
" and b.amount=? and b.collection_form_ref is null and b.ref_no = ? and b.ref_date = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, finEntity);
pstmt1.setString(2, bankGroup);
pstmt1.setDouble(3, rcpAmt);
pstmt1.setString(4, refNoHdr);
pstmt1.setDate(5, dtTemp);
rs1 = pstmt1.executeQuery();
if(rs1.next()) {
stmtId = rs1.getString("stmt_id");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
if(stmtId.trim().length() == 0) {
continue;
}
//System.out.println("bankAmount>>>>>>[" + bankAmount + "]rcpAmt>>>>>[" + rcpAmt + ']');
//if (rcpAmt == bankAmount)
//{
StringBuffer xmlBuff = new StringBuffer(); StringBuffer xmlBuff = new StringBuffer();
StringBuffer advBuff = new StringBuffer(); StringBuffer advBuff = new StringBuffer();
errString = ""; errString = "";
...@@ -247,21 +310,18 @@ public class EcollectionSchedule implements Schedule ...@@ -247,21 +310,18 @@ public class EcollectionSchedule implements Schedule
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>"); xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>"); xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext =\"1\"").append(" objName=\"receipt_adv\" domID=\"1\" dbID=\"\">"); xmlBuff.append("<Detail1 objContext =\"1\" objName=\"receipt_adv\" domID=\"1\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>"); xmlBuff.append("<tran_id/>");
xmlBuff.append("<tran_date><![CDATA[" + tranDate + "]]></tran_date>"); xmlBuff.append("<tran_date><![CDATA[" + tranDate + "]]></tran_date>");
xmlBuff.append("<cust_code><![CDATA[" + custCode + "]]></cust_code>"); xmlBuff.append("<cust_code><![CDATA[" + custCode + "]]></cust_code>");
xmlBuff.append("<tran_type><![CDATA[" + tranType + "]]></tran_type>"); xmlBuff.append("<tran_type><![CDATA[" + tranType + "]]></tran_type>");
xmlBuff.append("<rcp_mode><![CDATA[" + rcpMode + "]]></rcp_mode>"); xmlBuff.append("<rcp_mode><![CDATA[" + rcpMode + "]]></rcp_mode>");
xmlBuff.append("<bank_code><![CDATA[" + bankCode + "]]></bank_code>"); xmlBuff.append("<bank_code><![CDATA[" + bankCode + "]]></bank_code>");
xmlBuff.append("<ref_no><![CDATA[" + refNo + "]]></ref_no>"); xmlBuff.append("<ref_no><![CDATA[" + refNoHdr + "]]></ref_no>");
if (refDate != null) if (refDate != null) {
{
xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>"); xmlBuff.append("<ref_date><![CDATA[" + sdf.format(refDate) + "]]></ref_date>");
} else } else {
{
xmlBuff.append("<ref_date><![CDATA[]]></ref_date>"); xmlBuff.append("<ref_date><![CDATA[]]></ref_date>");
} }
xmlBuff.append("<site_code><![CDATA[" + siteCode + "]]></site_code>"); xmlBuff.append("<site_code><![CDATA[" + siteCode + "]]></site_code>");
...@@ -270,11 +330,9 @@ public class EcollectionSchedule implements Schedule ...@@ -270,11 +330,9 @@ public class EcollectionSchedule implements Schedule
xmlBuff.append("<auto_recd><![CDATA[]]></auto_recd>"); xmlBuff.append("<auto_recd><![CDATA[]]></auto_recd>");
xmlBuff.append("<adv_amt><![CDATA[").append("0").append("]]></adv_amt>"); xmlBuff.append("<adv_amt><![CDATA[").append("0").append("]]></adv_amt>");
xmlBuff.append("<bill_amt><![CDATA[").append("0").append("]]></bill_amt>"); xmlBuff.append("<bill_amt><![CDATA[").append("0").append("]]></bill_amt>");
if (effDate != null) if (effDate != null) {
{
xmlBuff.append("<eff_date><![CDATA[" + sdf.format(effDate) + "]]></eff_date>"); xmlBuff.append("<eff_date><![CDATA[" + sdf.format(effDate) + "]]></eff_date>");
} else } else {
{
xmlBuff.append("<eff_date><![CDATA[]]></eff_date>"); xmlBuff.append("<eff_date><![CDATA[]]></eff_date>");
} }
xmlBuff.append("<diff_amt__exch><![CDATA[]]></diff_amt__exch>"); xmlBuff.append("<diff_amt__exch><![CDATA[]]></diff_amt__exch>");
...@@ -287,25 +345,21 @@ public class EcollectionSchedule implements Schedule ...@@ -287,25 +345,21 @@ public class EcollectionSchedule implements Schedule
xmlBuff.append("<fin_scheme><![CDATA[]]></fin_scheme>"); xmlBuff.append("<fin_scheme><![CDATA[]]></fin_scheme>");
xmlBuff.append("<item_ser><![CDATA[]]></item_ser>"); xmlBuff.append("<item_ser><![CDATA[]]></item_ser>");
xmlBuff.append("<rcp_type><![CDATA[]]></rcp_type>"); xmlBuff.append("<rcp_type><![CDATA[]]></rcp_type>");
//xmlBuff.append("<remarks><![CDATA[" + remarks + "]]></remarks>");
xmlBuff.append("<remarks><![CDATA[Transaction created from Ecollection scheduler]]></remarks>"); xmlBuff.append("<remarks><![CDATA[Transaction created from Ecollection scheduler]]></remarks>");
xmlBuff.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>"); xmlBuff.append("<fin_entity><![CDATA[" + finEntity + "]]></fin_entity>");
xmlBuff.append("<curr_code><![CDATA["+currencyCode+"]]></curr_code>"); xmlBuff.append("<curr_code><![CDATA[" + currencyCode + "]]></curr_code>");
xmlBuff.append("<exch_rate><![CDATA["+exchRate+"]]></exch_rate>"); xmlBuff.append("<exch_rate><![CDATA[" + exchRate + "]]></exch_rate>");
xmlBuff.append("</Detail1>"); xmlBuff.append("</Detail1>");
sql1 = " select ref_ser,ref_no,line_no__ref,rcp_amt from rcpdet_form where tran_id=? "; sql1 = "select ref_ser,ref_no,line_no__ref,rcp_amt from rcpdet_form where tran_id=? ";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranId); pstmt1.setString(1, tranId);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
while (rs1.next()) while (rs1.next()) {
{
lineNo++; lineNo++;
System.out.println("lineNo is " + lineNo); System.out.println("lineNo is " + lineNo);
refSer = rs1.getString("ref_ser"); refSer = rs1.getString("ref_ser");
refNo = rs1.getString("ref_no"); String refNo = rs1.getString("ref_no");
lineNoRef = rs1.getString("line_no__ref"); lineNoRef = rs1.getString("line_no__ref");
rcpAmtDet = rs1.getDouble("rcp_amt"); rcpAmtDet = rs1.getDouble("rcp_amt");
...@@ -313,10 +367,9 @@ public class EcollectionSchedule implements Schedule ...@@ -313,10 +367,9 @@ public class EcollectionSchedule implements Schedule
refNo = refNo == null ? "" : refNo.trim(); refNo = refNo == null ? "" : refNo.trim();
lineNoRef = lineNoRef == null ? "" : lineNoRef.trim(); lineNoRef = lineNoRef == null ? "" : lineNoRef.trim();
//xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID=\"1\" dbID=''>"); // xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID=\"1\" dbID=''>");
xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID='"+lineNo+"' dbID=''>"); xmlBuff.append("<Detail2 objContext=\"2\" objName=\"receipt_adv\" domID='" + lineNo + "' dbID=''>");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id/>"); xmlBuff.append("<tran_id/>");
xmlBuff.append("<line_no><![CDATA[" + lineNo + "]]></line_no>"); xmlBuff.append("<line_no><![CDATA[" + lineNo + "]]></line_no>");
xmlBuff.append("<line_no__ref><![CDATA[" + lineNoRef + "]]></line_no__ref>"); xmlBuff.append("<line_no__ref><![CDATA[" + lineNoRef + "]]></line_no__ref>");
...@@ -336,35 +389,37 @@ public class EcollectionSchedule implements Schedule ...@@ -336,35 +389,37 @@ public class EcollectionSchedule implements Schedule
xmlBuff.append("</DocumentRoot>"); xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString(); xmlString = xmlBuff.toString();
System.out.println("xmlString " + xmlString); System.out.println("xmlString " + xmlString);
errString = saveData(siteCode, xmlString, conn); errString = saveData(siteCode, xmlString, scheduleParamXML, conn);
System.out.println("Passed xml in master State full errString " + errString); System.out
if (errString.indexOf("Success") > -1) .println("Passed xml in master State full errString "
{ + errString);
if (errString.indexOf("Success") > -1) {
String[] arrayForTranId = errString.split("<TranID>"); String[] arrayForTranId = errString.split("<TranID>");
int endIndex = arrayForTranId[1].indexOf("</TranID>"); int endIndex = arrayForTranId[1].indexOf("</TranID>");
System.out.println("***********going for confirmation************"); System.out
String tranIdForIssue = arrayForTranId[1].substring(0, endIndex); .println("***********going for confirmation************");
String tranIdForIssue = arrayForTranId[1].substring(0,
endIndex);
System.out.println("tranIdForIssue" + tranIdForIssue); System.out.println("tranIdForIssue" + tranIdForIssue);
errString = ReceiptAdv.confirm(tranIdForIssue, xtraParams, "", conn); errString = ReceiptAdv.confirm(tranIdForIssue, xtraParams,
"", conn);
System.out.println("=====Its Confirmed====="); System.out.println("=====Its Confirmed=====");
System.out.println("retString from conf ::" + errString); System.out.println("retString from conf ::" + errString);
if (errString.indexOf("VTCICONF3") > -1) if (errString.indexOf("VTCICONF3") > -1) {
{ cnt = 0;
cnt=0; bankCnt = 0;
bankCnt=0;
sql1 = " update receipt_form set status= 'P',TRAN_ID__RCP=? where tran_id = ? "; sql1 = " update receipt_form set status= 'P',TRAN_ID__RCP=? where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, tranIdForIssue); pstmt1.setString(1, tranIdForIssue);
pstmt1.setString(2, tranId); pstmt1.setString(2, tranId);
cnt = pstmt1.executeUpdate(); cnt = pstmt1.executeUpdate();
/*if (cnt > 0) /*
{ * if (cnt > 0) {
System.out.println("UPDATE QUERY FOR STATUS"); * System.out.println("UPDATE QUERY FOR STATUS");
conn.commit(); * conn.commit(); }
}*/ */
pstmt1.close(); pstmt1.close();
pstmt1 = null; pstmt1 = null;
...@@ -373,51 +428,51 @@ public class EcollectionSchedule implements Schedule ...@@ -373,51 +428,51 @@ public class EcollectionSchedule implements Schedule
pstmt1.setString(1, tranId); pstmt1.setString(1, tranId);
pstmt1.setString(2, stmtId); pstmt1.setString(2, stmtId);
bankCnt = pstmt1.executeUpdate(); bankCnt = pstmt1.executeUpdate();
/*if (bankCnt > 0) /*
{ * if (bankCnt > 0) {
System.out.println("UPDATE QUERY FOR STATUS"); * System.out.println("UPDATE QUERY FOR STATUS");
conn.commit(); * conn.commit(); }
}*/ */
pstmt1.close(); pstmt1.close();
pstmt1 = null; pstmt1 = null;
if(cnt >0 && bankCnt>0) if (cnt > 0 && bankCnt > 0) {
{
conn.commit(); conn.commit();
System.out.println("UPDATE QUERY FOR STATUS"); System.out.println("UPDATE QUERY FOR STATUS");
} }
} else } else {
{ System.out
System.out.println("connection roll back for confirmation"); .println("connection roll back for confirmation");
conn.rollback(); conn.rollback();
} }
} else } else {
{
System.out.println("connection roll back for save data"); System.out.println("connection roll back for save data");
conn.rollback(); conn.rollback();
} }
System.out.println("Passed xml in master State full final errString " + errString); System.out
.println("Passed xml in master State full final errString "
+ errString);
endDate = new java.util.Date(System.currentTimeMillis()); endDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis())); calendar.setTime(new java.sql.Timestamp(System
endDateStr = sdf1.format(endDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND); .currentTimeMillis()));
System.out.println("**** ecollection completed for.....[" + tranId + "] at [" + endDateStr + "]" ); endDateStr = sdf1.format(endDate) + " "
strToWrite=strToWrite+endDateStr+","; + calendar.get(Calendar.HOUR) + ":"
strToWrite = strToWrite + errString+"\r\n\r\n"; + calendar.get(Calendar.MINUTE) + ":"
+ calendar.get(Calendar.SECOND);
System.out.println("**** ecollection completed for.....["
+ tranId + "] at [" + endDateStr + "]");
strToWrite = strToWrite + endDateStr + ",";
strToWrite = strToWrite + errString + "\r\n\r\n";
fos1.write(strToWrite.getBytes()); fos1.write(strToWrite.getBytes());
System.out.println("End Time for transaction"+endDateStr+"string to write"+strToWrite); System.out.println("End Time for transaction" + endDateStr
+ "string to write" + strToWrite);
/*} else /*
{ * } else { sql1 =
sql1 = " update receipt_form set remarks = 'Mismatch amount in bank statement and total receipt amount',status= 'R' where tran_id = ? "; * " update receipt_form set remarks = 'Mismatch amount in bank statement and total receipt amount',status= 'R' where tran_id = ? "
pstmt1 = conn.prepareStatement(sql1); * ; pstmt1 = conn.prepareStatement(sql1); pstmt1.setString(1,
pstmt1.setString(1, tranId); * tranId); cnt = pstmt1.executeUpdate(); if (cnt > 0) {
cnt = pstmt1.executeUpdate(); * conn.commit(); } pstmt1.close(); pstmt1 = null; }
if (cnt > 0) */
{
conn.commit();
}
pstmt1.close();
pstmt1 = null;
}*/
} }
rs.close(); rs.close();
...@@ -425,111 +480,100 @@ public class EcollectionSchedule implements Schedule ...@@ -425,111 +480,100 @@ public class EcollectionSchedule implements Schedule
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} } catch (SQLException se) {
catch(SQLException se)
{
isError = true; isError = true;
System.out.println("Exception : insReceipt : EcollectionSchedule" +se.getMessage()); System.out.println("Exception : insReceipt : EcollectionSchedule"
try + se.getMessage());
{ try {
conn.rollback(); conn.rollback();
} catch (Exception se1) {
} }
catch(Exception se1){}
throw new ITMException(se); throw new ITMException(se);
}finally } finally {
{ if (conn != null) {
if(conn != null) if (pstmt != null) {
{
if(pstmt!=null)
{
pstmt.close(); pstmt.close();
pstmt=null; pstmt = null;
} }
if(rs!=null) if (rs != null) {
{
rs.close(); rs.close();
rs=null; rs = null;
} }
conn.close(); conn.close();
conn= null; conn = null;
} }
} }
System.out.println("errString........:: " + errString); System.out.println("errString........:: " + errString);
return errString; return errString;
} }
private String saveData(String siteCode,String xmlString, Connection conn) throws ITMException private String saveData(String siteCode, String xmlString, String scheduleParamXML, Connection conn) throws ITMException {
{ UserInfoBean userInfo = null;
System.out.println("saving data..........."); System.out.println("saving data...........");
InitialContext ctx = null; InitialContext ctx = null;
String retString = null; String retString = null;
MasterStatefulLocal masterStateful = null; // for ejb3 MasterStatefulLocal masterStateful = null; // for ejb3
try try {
{
AppConnectParm appConnect = new AppConnectParm(); AppConnectParm appConnect = new AppConnectParm();
userInfo = new UserInfoBean(scheduleParamXML);
ctx = new InitialContext(appConnect.getProperty()); ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local"); masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful); System.out.println("-----------masterStateful------- " + masterStateful);
String [] authencate = new String[2]; masterStateful.setUserInfo(userInfo);
String[] authencate = new String[2];
authencate[0] = ""; authencate[0] = "";
authencate[1] = ""; authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]"); System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn); //retString = masterStateful.processRequest(userInfo, xmlString, true, conn);
} retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
catch(ITMException itme) } catch (ITMException itme) {
{
System.out.println("ITMException :CreateDistOrder :saveData :==>"); System.out.println("ITMException :CreateDistOrder :saveData :==>");
throw itme; throw itme;
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception :CreateDistOrder :saveData :==>"); System.out.println("Exception :CreateDistOrder :saveData :==>");
throw new ITMException(e); throw new ITMException(e);
} }
return retString; return retString;
} }
private String intializingLog(String fileName)
{ private String intializingLog(String fileName) {
String log="intializingLog_Failed"; String log = "intializingLog_Failed";
String strToWrite = ""; String strToWrite = "";
String currTime = null; String currTime = null;
try{ try {
SimpleDateFormat sdf1 = new SimpleDateFormat(e12GenericUtility.getDBDateFormat()); SimpleDateFormat sdf1 = new SimpleDateFormat(
try e12GenericUtility.getDBDateFormat());
{ try {
currTime = sdf1.format(new Timestamp(System.currentTimeMillis())).toString(); currTime = sdf1.format(
currTime = currTime.replaceAll("-",""); new Timestamp(System.currentTimeMillis())).toString();
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis())); currTime = currTime.replaceAll("-", "");
fileName = fileName+currTime+calendar.get(Calendar.HOUR)+""+calendar.get(Calendar.MINUTE)+".txt"; calendar.setTime(new java.sql.Timestamp(System
fos1 = new FileOutputStream(CommonConstants.JBOSSHOME + File.separator +"EDI"+File.separator+fileName); .currentTimeMillis()));
} fileName = fileName + currTime + calendar.get(Calendar.HOUR)
catch(Exception e) + "" + calendar.get(Calendar.MINUTE) + ".txt";
{ fos1 = new FileOutputStream(CommonConstants.JBOSSHOME
System.out.println("Exception []::"+e.getMessage()); + File.separator + "EDI" + File.separator + fileName);
} catch (Exception e) {
System.out.println("Exception []::" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
startDate = new java.util.Date(System.currentTimeMillis()); startDate = new java.util.Date(System.currentTimeMillis());
calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis())); calendar.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
startDateStr = sdf1.format(startDate)+" "+calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND); startDateStr = sdf1.format(startDate) + " "
fos1.write(("Fetching Records Started At " + startDateStr +"\r\n").getBytes()); + calendar.get(Calendar.HOUR) + ":"
+ calendar.get(Calendar.MINUTE) + ":"
} + calendar.get(Calendar.SECOND);
catch(Exception e) fos1.write(("Fetching Records Started At " + startDateStr + "\r\n")
{ .getBytes());
System.out.println("Exception []::"+e.getMessage()); } catch (Exception e) {
System.out.println("Exception []::" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
log = "intializingLog_Successesfull";
log ="intializingLog_Successesfull";
return log; return log;
} }
} }
\ No newline at end of file
...@@ -7,173 +7,153 @@ ...@@ -7,173 +7,153 @@
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.text.SimpleDateFormat;
import java.util.*;
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.sql.Timestamp; import java.sql.Timestamp;
import ibase.utility.E12GenericUtility;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.ejb.Stateless; @SuppressWarnings("unused")
@Stateless @Stateless
public class EcollectionSubIC extends ValidatorEJB implements
EcollectionSubICLocal, EcollectionSubICRemote {
public class EcollectionSubIC extends ValidatorEJB implements EcollectionSubICLocal, EcollectionSubICRemote static E12GenericUtility genericUtility = new E12GenericUtility();
{
E12GenericUtility genericUtility= new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
{
String errString = ""; String errString = "";
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
try try {
{ if (xmlString != null && xmlString.trim().length() > 0) {
if (xmlString != null && xmlString.trim().length() > 0 )
{
dom = parseString(xmlString); dom = parseString(xmlString);
System.out.println("xmlString["+xmlString+"]"); printMessage("xmlString", xmlString);
} }
if (xmlString1 != null && xmlString1.trim().length() > 0 ) if (xmlString1 != null && xmlString1.trim().length() > 0) {
{
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
System.out.println("xmlString1["+xmlString1+"]"); printMessage("xmlString1", xmlString1);
} }
if (xmlString2 != null && xmlString2.trim().length() > 0 ) if (xmlString2 != null && xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
System.out.println("xmlString2["+xmlString2+"]"); printMessage("xmlString2", xmlString2);
}
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
} }
catch(Exception e) errString = wfValData(dom, dom1, dom2, objContext, editFlag,
{ xtraParams);
System.out.println("Exception : [EcollectionSubIC][wfValData( String, String )] :==>\n" + e.getMessage()); } catch (Exception e) {
printMessage("Exception wfValData[S]", e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
return(errString); return errString;
} }
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String childNodeName = null; public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException {
String errString = ""; String childNodeName = "", errString = "", errCode = "", userId = "", sql = "", errorType = "", custCode = "", bankCode = "", lineNo = "", rfDate = "", tranIdRcp = "", tranId = "", stmt_id = "", siteCode = "", rcpAmtStr = "", refSer = "", refNo = "", prdCode = "";
String errCode = ""; int cnt = 0, ctr = 0, rcpFormCnt = 0, bankTranCnt = 0, childNodeListLength = 0, currentFormNo = 0;
String userId = ""; NodeList parentNodeList = null, childNodeList = null;
String sql = ""; Node parentNode = null, childNode = null;
String errorType = ""; ArrayList<String> errList = new ArrayList<String>(), errFields = new ArrayList<String>();
String custCode="",bankCode="",lineNo="",rfDate="",tranIdRcp="",tranId="";
int cnt = 0;
int ctr=0,rcpformCnt=0,banktranCnt=0;
int childNodeListLength;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer(
int currentFormNo =0; "<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
String siteCode="",rcpAmtStr="",refSer="",refNo="",prdCode="";
java.util.Date tranDate = null; java.util.Date tranDate = null;
double rcpAmt=0,rcpAmtNew=0; double rcpAmt = 0, rcpAmtNew = 0, isInvAmt = 0;
double isInvAmt=0;
SimpleDateFormat dateFormat2 = null; SimpleDateFormat dateFormat2 = null;
Timestamp rfDatetmstmp=null; Timestamp rfDatetmstmp = null;
Date currentDate = new Date(); Date currentDate = new Date();
try try {
{ dateFormat2 = new SimpleDateFormat(genericUtility.getApplDateFormat()); dateFormat2 = new SimpleDateFormat(
System.out.println("@@@@@@@@ wfvaldata called"); genericUtility.getApplDateFormat());
//Changes and Commented By Bhushan on 06-06-2016 :START printMessage("call to wfValdata[D]", "Started");
//conn = connDriver.getConnectDB("DriverITM"); // Changes and Commented By Bhushan on 06-06-2016 :START
conn = getConnection(); // conn = connDriver.getConnectDB("DriverITM");
//Changes and Commented By Bhushan on 06-06-2016 :END conn = getConnection();
// Changes and Commented By Bhushan on 06-06-2016 :END
connDriver = null; connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0) {
{
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) switch (currentFormNo) {
{ case 1: {
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("ref_no")) if (childNodeName.equalsIgnoreCase("ref_no")) {
{ refNo = checkNull(genericUtility.getColumnValue(
refNo = this.genericUtility.getColumnValue("ref_no", dom); "ref_no", dom));
rfDate = this.genericUtility.getColumnValue("ref_date", dom); rfDate = checkNull(genericUtility.getColumnValue(
bankCode = this.genericUtility.getColumnValue("bank_code", dom); "ref_date", dom));
siteCode = this.genericUtility.getColumnValue("site_code", dom); bankCode = checkNull(genericUtility.getColumnValue(
tranId = this.genericUtility.getColumnValue("tran_id", dom); "bank_code", dom));
custCode = this.genericUtility.getColumnValue("cust_code", dom); siteCode = checkNull(genericUtility.getColumnValue(
System.out.println("refNo>>>>>>" + refNo); "site_code", dom));
tranId = checkNull(genericUtility.getColumnValue(
"tran_id", dom));
custCode = checkNull(genericUtility.getColumnValue(
"cust_code", dom));
System.out.println("refNo -- -- " + refNo);
if (refNo != null && refNo.trim().length() > 0) if (refNo != null && refNo.trim().length() > 0) {
{
sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' "; sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode); pstmt.setString(2, bankCode);
pstmt.setString(3, refNo); pstmt.setString(3, refNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{ rcpFormCnt = rs.getInt("cnt");
rcpformCnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
if (rcpformCnt > 1) if (rcpFormCnt > 1) {
{
errCode = "VTINVREF"; errCode = "VTINVREF";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
sql = " select count(*) as cnt from bank_statement where site_code = ? and bank_code=? and ref_no=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode);
pstmt.setString(3, refNo);
rs = pstmt.executeQuery();
if (rs.next())
{
banktranCnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
if (banktranCnt == 0)
{
errCode = "VTINREFNO1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if (rfDate != null) /*
{ * sql =
* " select count(*) as cnt from bank_statement where site_code = ? and bank_code=? and ref_no=? "
* ; pstmt = conn.prepareStatement(sql);
* pstmt.setString(1, siteCode);
* pstmt.setString(2, bankCode);
* pstmt.setString(3, refNo); rs =
* pstmt.executeQuery(); if (rs.next()) {
* bankTranCnt = rs.getInt("cnt"); } rs.close();
* rs = null; pstmt.close(); pstmt = null;
*
* if (bankTranCnt == 0) { errCode =
* "VTINREFNO1"; errList.add(errCode);
* errFields.add(childNodeName.toLowerCase()); }
*/
if (rfDate != null && rfDate.trim().length() > 0) {
rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = "select tran_id from receipt where cust_code=? and ref_no=? and ref_date=? and tran_id <> ?"; sql = "select tran_id from receipt where cust_code=? and ref_no=? and ref_date=? and tran_id <> ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -182,28 +162,26 @@ conn = getConnection(); ...@@ -182,28 +162,26 @@ conn = getConnection();
pstmt.setTimestamp(3, rfDatetmstmp); pstmt.setTimestamp(3, rfDatetmstmp);
pstmt.setString(4, tranId); pstmt.setString(4, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
tranIdRcp = checkNull(rs.getString("tran_id")); tranIdRcp = checkNull(rs.getString("tran_id"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (tranIdRcp != null && tranIdRcp.trim().length() > 0)
{ if (tranIdRcp != null && tranIdRcp.trim().length() > 0) {
/** /**
* Existing receipt found for above * Existing receipt found for above
* combination check the record from table * combination check the record from
* rcpdishnr where receipt_no=tranIdRcp * table rcpdishnr where
* receipt_no=tranIdRcp
* */ * */
sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' "; sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp); pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
...@@ -212,71 +190,124 @@ conn = getConnection(); ...@@ -212,71 +190,124 @@ conn = getConnection();
pstmt = null; pstmt = null;
System.out.println("@V@ Dishponer cnt :- [" + cnt + "]"); System.out.println("@V@ Dishponer cnt :- [" + cnt + "]");
if (cnt == 0) if (cnt == 0) {
{ // Unconfirmed record found ERROR (Duplicate utr_no found)
/**
* Unconfirmed record found ERROR
* (Duplicate utr_no found)
* */
errCode = "VTUTRDUPL"; errCode = "VTUTRDUPL";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName
.toLowerCase());
} }
} }
} }
}else } else {
{
errCode = "VTNULREFNO"; errCode = "VTNULREFNO";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} else if (childNodeName.equalsIgnoreCase("ref_date")) {
}else if (childNodeName.equalsIgnoreCase("ref_date") ) rfDate = checkNull(genericUtility.getColumnValue("ref_date", dom));
{ if (rfDate == null || rfDate.trim().length() == 0) {
rfDate = this.genericUtility.getColumnValue("ref_date", dom);
if(rfDate == null || rfDate.trim().length()==0)
{
errCode = "VTNULREFDT"; errCode = "VTNULREFDT";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
}else } else {
{ rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate,genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
rfDatetmstmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(rfDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); if (currentDate.before(rfDatetmstmp)) {
if(currentDate.before(rfDatetmstmp)) System.out.println("rfDatetmstmp < currentDate : " + rfDatetmstmp + " < " + currentDate);
{
System.out.println("rfDatetmstmp < currentDate : "+rfDatetmstmp+" < "+currentDate);
errCode = "VTREFDTLE"; errCode = "VTREFDTLE";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} else if (childNodeName.equalsIgnoreCase("stmt_id")) {
stmt_id = checkNull(genericUtility.getColumnValue("stmt_id", dom));
if (stmt_id.trim().length() > 0) {
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom));
String finEntity = "", bankGroup = "";
sql = " select fin_entity from site where site_code=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
rs = pstmt.executeQuery();
if (rs.next()) {
finEntity = checkNull(rs.getString("fin_entity"));
}
printMessage("finEntity", finEntity);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select group_code from bank where bank_code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode);
rs = pstmt.executeQuery();
if (rs.next()) {
bankGroup = checkNull(rs.getString("group_code"));
}
printMessage("bankGroup", bankGroup);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
String colFormRef = "";
//sql = "select collection_form_ref from bank_statement where tran_id = ?";
sql = "select b.collection_form_ref from bank_statement b,site s,bank bank where s.fin_entity=? "
+ " and s.site_code=b.site_code "
+ " and bank.bank_code=b.bank_code and bank.group_code= ? "
+ " and b.tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finEntity);
pstmt.setString(2, bankGroup);
pstmt.setString(3, stmt_id);
rs = pstmt.executeQuery();
if(rs.next()) {
colFormRef = checkNull(rs.getString(1));
} else {
errCode = "VTINVSTMID";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(colFormRef.trim().length() > 0){
errCode = "VTECSREFID";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} }
}// end for }// end for
}
break; // case 1 end break; // case 1 end
} }
int errListSize = errList.size(); int errListSize = errList.size();
cnt = 0; cnt = 0;
String errFldName = null; String errFldName = null;
if(errList != null && errListSize > 0) if (errList != null && errListSize > 0) {
{ for (cnt = 0; cnt < errListSize; cnt++) {
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt); errCode = errList.get(cnt);
errFldName = errFields.get(cnt); errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode); System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode); errorType = errorType(conn, errCode);
if(errString.length() > 0) if (errString.length() > 0) {
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
errString = ""; errString = "";
} }
if(errorType.equalsIgnoreCase("E")) if (errorType.equalsIgnoreCase("E")) {
{
break; break;
} }
} }
...@@ -285,41 +316,28 @@ conn = getConnection(); ...@@ -285,41 +316,28 @@ conn = getConnection();
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors> </Root> \r\n"); errStringXml.append("</Errors> </Root> \r\n");
} } else {
else
{
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }
} catch (Exception e) {
}
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
} } finally {
finally try {
{ if (conn != null) {
try if (rs != null) {
{
if(conn != null)
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
} }
conn = null; conn = null;
} } catch (Exception d) {
catch(Exception d)
{
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
} }
...@@ -328,86 +346,71 @@ conn = getConnection(); ...@@ -328,86 +346,71 @@ conn = getConnection();
return errString; return errString;
} }
//end of validation // end of validation
private String checkNull(String input) private void printMessage(String fieldname, String value) {
{ System.out.println(this.getClass().getSimpleName().toUpperCase() + " : [" + fieldname + "][" + value + "]");
if(input == null)
{
input = "";
} }
return input;
private String checkNull(String input) {
return input == null ? "" : input;
} }
public String getRequiredDecimal(double actVal, int prec)
{ public String getRequiredDecimal(double actVal, int prec) {
String fmtStr = "############0"; String fmtStr = "############0";
if (prec > 0) if (prec > 0) {
{
fmtStr = fmtStr + "." + "000000000".substring(0, prec); fmtStr = fmtStr + "." + "000000000".substring(0, prec);
} }
DecimalFormat decFormat = new DecimalFormat(fmtStr); DecimalFormat decFormat = new DecimalFormat(fmtStr);
return decFormat.format(actVal); return decFormat.format(actVal);
} }
public static java.util.Date relativeDate(java.util.Date date, int days)
{ public static java.util.Date relativeDate(java.util.Date date, int days) {
java.util.Date calculatedDate = null; java.util.Date calculatedDate = null;
if (date != null) if (date != null) {
{
final GregorianCalendar calendar = new GregorianCalendar(); final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date); calendar.setTime(date);
calendar.add(Calendar.DATE,days); calendar.add(Calendar.DATE, days);
calculatedDate = new java.util.Date(calendar.getTime().getTime()); calculatedDate = new java.util.Date(calendar.getTime().getTime());
} }
return calculatedDate; return calculatedDate;
} }
private String errorType(Connection conn , String errorCode) throws ITMException
{ private String errorType(Connection conn, String errorCode)
throws ITMException {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try {
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
msgType = rs.getString("MSG_TYPE"); msgType = rs.getString("MSG_TYPE");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} } catch (Exception ex) {
catch(Exception ex)
{
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} } finally {
finally try {
{ if (rs != null) {
try
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return msgType; return msgType;
} }
} }
[Dolphin] [Dolphin]
HeaderColumnWidths=328,70,146
SortOrder=1 SortOrder=1
SortRole=date SortRole=date
Sorting=2 Sorting=2
Timestamp=2016,6,10,11,6,27 Timestamp=2016,12,12,18,55,58
Version=3 Version=3
ViewMode=1 ViewMode=1
...@@ -2,67 +2,65 @@ ...@@ -2,67 +2,65 @@
Title : EcollectionConf[F14ISUN014] Title : EcollectionConf[F14ISUN014]
Date : 17/02/15 Date : 17/02/15
Developer: Chandrashekar Developer: Chandrashekar
********************************************************/ ********************************************************/
package ibase.webitm.ejb.fin.adv; package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import javax.ejb.Stateless;
@Stateless @Stateless
public class EcollectionConf extends ActionHandlerEJB implements EcollectionConfLocal, EcollectionConfRemote public class EcollectionConf extends ActionHandlerEJB implements
{ EcollectionConfLocal, EcollectionConfRemote {
public String confirm(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{ public String confirm(String tranId, String xtraParams, String forcedFlag)
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf confirm called>>>>>>>>>>>>>>>>>>>"); throws RemoteException, ITMException {
String confirmed = "",siteCode="",bankCode=""; System.out.println("Calling from " + this.getClass().getSimpleName() + " : confirm");
String confirmed = "", siteCode = "", bankCode = "";
String sql = ""; String sql = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String errString = null; String errString = null;
ResultSet rs = null; ResultSet rs = null;
String loginEmpCode="",status="",refNo="",tranIdRcp="",custCode=""; String loginEmpCode = "", status = "", refNo = "", tranIdRcp = "", custCode = "", stmtId = "";
String finEntity="",bankstmtTranId="",bankGroup=""; String finEntity = "", bankstmtTranId = "", bankGroup = "";
int cnt = 0; int cnt = 0;
int rcpformCnt=0,rcpCnt=0; int rcpformCnt = 0, rcpCnt = 0;
double chqAmt=0.0; double chqAmt = 0.0;
Timestamp rfDate=null; Timestamp rfDate = null;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
Timestamp sysDate = null; Timestamp sysDate = null;
E12GenericUtility genericUtility= new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
try try {
{
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 06-06-2016 :START conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0) {
{ System.out.println("@@@@@tranId" + tranId + "]");
System.out.println("@@@@@tranId"+tranId+"]"); //Commented by Tajuddin Mahadi to include Statement Id while confirming.
//sql = " select confirmed,status,ref_no,site_code,bank_code,cust_code,ref_date,chq_amt from receipt_form where tran_id = ? ";
sql = " select confirmed,status,ref_no,site_code,bank_code,cust_code,ref_date,chq_amt from receipt_form where tran_id = ? "; sql = "SELECT confirmed, status, ref_no, site_code, bank_code, cust_code, ref_date, chq_amt, stmt_id from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
confirmed = rs.getString("confirmed"); confirmed = rs.getString("confirmed");
status = rs.getString("status"); status = rs.getString("status");
refNo = rs.getString("ref_no"); refNo = rs.getString("ref_no");
...@@ -71,45 +69,40 @@ conn = getConnection(); ...@@ -71,45 +69,40 @@ conn = getConnection();
custCode = rs.getString("cust_code"); custCode = rs.getString("cust_code");
rfDate = rs.getTimestamp("ref_date"); rfDate = rs.getTimestamp("ref_date");
chqAmt = rs.getDouble("chq_amt"); chqAmt = rs.getDouble("chq_amt");
stmtId = rs.getString("stmt_id");
} }
System.out.println("refNo>>>>>>>>"+refNo); System.out.println("refNo>>>>>>>>" + refNo);
System.out.println("rfDate>>>>>>>>"+rfDate); System.out.println("rfDate>>>>>>>>" + rfDate);
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ("S".equalsIgnoreCase(status)) if ("S".equalsIgnoreCase(status)) {
{ if (refNo == null || refNo.trim().length() == 0) {
if (refNo == null || refNo.trim().length() == 0)
{
errString = itmDBAccessLocal.getErrorString("", "VTNULREFNO", ""); errString = itmDBAccessLocal.getErrorString("", "VTNULREFNO", "");
return errString; return errString;
}else if (rfDate == null) } else if (rfDate == null) {
{
errString = itmDBAccessLocal.getErrorString("", "VTNULREFDT", ""); errString = itmDBAccessLocal.getErrorString("", "VTNULREFDT", "");
return errString; return errString;
} else } else {
{
sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' "; sql = " select count(*) as cnt from receipt_form where site_code = ? and bank_code=? and ref_no=? and status !='X' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2, bankCode); pstmt.setString(2, bankCode);
pstmt.setString(3, refNo); pstmt.setString(3, refNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
rcpformCnt = rs.getInt("cnt"); rcpformCnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
if( rcpformCnt > 1 ) if (rcpformCnt > 1) {
{
errString = itmDBAccessLocal.getErrorString("", "VTINVREF", ""); errString = itmDBAccessLocal.getErrorString("", "VTINVREF", "");
return errString; return errString;
} }
sql = "select tran_id from receipt where cust_code=? and ref_no=? and ref_date=? and tran_id <> ?"; sql = "select tran_id from receipt where cust_code=? and ref_no=? and ref_date=? and tran_id <> ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode); pstmt.setString(1, custCode);
...@@ -117,75 +110,67 @@ conn = getConnection(); ...@@ -117,75 +110,67 @@ conn = getConnection();
pstmt.setTimestamp(3, rfDate); pstmt.setTimestamp(3, rfDate);
pstmt.setString(4, tranId); pstmt.setString(4, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ tranIdRcp = checkNull(rs.getString("tran_id"));
tranIdRcp=checkNull(rs.getString("tran_id"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (tranIdRcp != null && tranIdRcp.trim().length()>0) if (tranIdRcp != null && tranIdRcp.trim().length() > 0) {
{
/** /**
* Existing receipt found * Existing receipt found for above combination
* for above combination * check the record from table rcpdishnr where
* check the record from table rcpdishnr * receipt_no=tranIdRcp
* where receipt_no=tranIdRcp
* */ * */
sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' "; sql = "select count(*) as cnt from rcpdishnr where receipt_no=? and confirmed='N' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdRcp); pstmt.setString(1, tranIdRcp);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ cnt = rs.getInt("cnt");
cnt=rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@V@ Dishponer cnt :- ["+cnt+"]"); System.out.println("@V@ Dishponer cnt :- [" + cnt
if(cnt==0) + "]");
{ if (cnt == 0) {
/** /**
* Unconfirmed record found * Unconfirmed record found ERROR (Duplicate
* ERROR (Duplicate utr_no found) * utr_no found)
* */ * */
errString = itmDBAccessLocal.getErrorString("", "VTUTRDUPL", ""); errString = itmDBAccessLocal.getErrorString("",
"VTUTRDUPL", "");
return errString; return errString;
} }
} }
System.out.println("@V@ Tran id receipt :- ["+tranIdRcp+"]"); System.out.println("@V@ Tran id receipt :- ["
+ tranIdRcp + "]");
if ("Y".equalsIgnoreCase(confirmed)) if ("Y".equalsIgnoreCase(confirmed)) {
{
errString = itmDBAccessLocal.getErrorString("", "VTINVCONF2", ""); errString = itmDBAccessLocal.getErrorString("", "VTINVCONF2", "");
return errString; return errString;
} else {
} else
{
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"); loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
Calendar currentDate = Calendar.getInstance(); /*Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime()); String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr); System.out.println("Now the date is :=> " + sysDateStr);
sysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); sysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
//Start added by chandr shekar on 18-mar-2016 // Start added by chandr shekar on 18-mar-2016
sql = " select fin_entity from site where site_code=? "; sql = " select fin_entity from site where site_code=? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{ finEntity = checkNull(rs.getString("fin_entity"));
finEntity =checkNull(rs.getString("fin_entity"));
} }
System.out.println("finEntity>>>>>>>>"+finEntity); System.out.println("finEntity>>>>>>>>" + finEntity);
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
...@@ -195,21 +180,19 @@ conn = getConnection(); ...@@ -195,21 +180,19 @@ conn = getConnection();
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bankCode); pstmt.setString(1, bankCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{ bankGroup = checkNull(rs.getString("group_code"));
bankGroup =checkNull(rs.getString("group_code"));
} }
System.out.println("bankGroup>>>>>>>>"+bankGroup); System.out.println("bankGroup>>>>>>>>" + bankGroup);
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = "select b.tran_id from bank_statement b,site s,bank bank where s.fin_entity=? " + sql = "select b.tran_id from bank_statement b,site s,bank bank where s.fin_entity=? "
" and s.site_code=b.site_code " + + " and s.site_code=b.site_code "
" and bank.bank_code=b.bank_code and bank.group_code= ? "+ + " and bank.bank_code=b.bank_code and bank.group_code= ? "
" and b.ref_no=? and b.ref_date=? and b.amount=? and b.collection_form_ref is null"; + " and b.ref_no=? and b.ref_date=? and b.amount=? and b.collection_form_ref is null";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, finEntity); pstmt.setString(1, finEntity);
pstmt.setString(2, bankGroup); pstmt.setString(2, bankGroup);
...@@ -217,69 +200,80 @@ conn = getConnection(); ...@@ -217,69 +200,80 @@ conn = getConnection();
pstmt.setTimestamp(4, rfDate); pstmt.setTimestamp(4, rfDate);
pstmt.setDouble(5, chqAmt); pstmt.setDouble(5, chqAmt);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{ bankstmtTranId = checkNull(rs.getString("tran_id"));
bankstmtTranId =checkNull(rs.getString("tran_id"));
} }
System.out.println("bankstmtTranId>>>>>>>>"+bankstmtTranId); System.out.println("bankstmtTranId>>>>>>>>" + bankstmtTranId);
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null;*/
/*if (bankstmtTranId.trim().length() == 0) {
sql = "select stmt_id from receipt_form where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next()) {
sql = "update receipt_form set confirmed = 'Y',conf_date = ?, emp_code__aprv = ?," +
" status= 'C' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate);
pstmt.setString(2, loginEmpCode);
pstmt.setString(3, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0) {
errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", "");
conn.commit();
} else {
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
}
if(bankstmtTranId.trim().length() == 0) } else {
{ sql = " update receipt_form set remarks = remarks where tran_id = ? ";
sql = " update receipt_form set remarks = 'Bank statement Tran Id is not found.',status= 'R' where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
if (cnt > 0) if (cnt > 0) {
{
conn.commit(); conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTCONFREJ", ""); errString = itmDBAccessLocal.getErrorString("", "VTCONFREJ", "");
} }
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
}
}else }*/
{ // else {
// End added by chandrshekar on 18-mar-2016 // End added by chandrshekar on 18-mar-2016
sql = " update receipt_form set confirmed = 'Y',conf_date = ?, emp_code__aprv = ? " + sql = " update receipt_form set confirmed = 'Y', conf_date = sysdate, emp_code__aprv = ?, status= 'C' where tran_id = ? ";
" ,status= 'C',stmt_id= ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, sysDate); pstmt.setString(1, loginEmpCode);
pstmt.setString(2, loginEmpCode); pstmt.setString(2, tranId);
pstmt.setString(3, bankstmtTranId);
pstmt.setString(4, tranId);
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0) if (cnt > 0) {
{
errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", ""); errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", "");
conn.commit(); conn.commit();
} else } else {
{
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", ""); errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
} }
} //}
} }
} }
} else
{ } else {
errString = itmDBAccessLocal.getErrorString("", "VTNSUBCON", ""); errString = itmDBAccessLocal.getErrorString("",
"VTNSUBCON", "");
} }
} }
// end if errstrng // end if errstrng
} catch (Exception e) } catch (Exception e) {
{ if (conn != null) {
if(conn!=null)
{
try { try {
conn.rollback(); conn.rollback();
} catch (SQLException ex) { } catch (SQLException ex) {
...@@ -290,71 +284,58 @@ conn = getConnection(); ...@@ -290,71 +284,58 @@ conn = getConnection();
} }
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} } finally {
finally try {
{ if (conn != null && !conn.isClosed()) {
try
{
if(conn != null && !conn.isClosed())
{
conn.close(); conn.close();
conn = null; conn = null;
} }
if(rs != null) if (rs != null) {
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception e) {
catch(Exception e) System.out.println("Exception : " + e);
{ e.printStackTrace();
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return errString; return errString;
} }
public String submit(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{ public String submit(String tranId, String xtraParams, String forcedFlag)
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf submit called>>>>>>>>>>>>>>>>>>>"); throws RemoteException, ITMException {
String sql = "",status="",confirmed=""; System.out
.println(">>>>>>>>>>>>>>>>>>EcollectionConf submit called>>>>>>>>>>>>>>>>>>>");
String sql = "", status = "", confirmed = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String errString = null; String errString = null;
ResultSet rs = null; ResultSet rs = null;
int cnt = 0; int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try try {
{
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 06-06-2016 :START conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0) {
{ System.out.println("tranId>>>[" + tranId + "]");
System.out.println("tranId>>>["+tranId+"]");
sql = " select status,confirmed from receipt_form where tran_id = ? "; sql = " select status,confirmed from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
status = rs.getString("status"); status = rs.getString("status");
confirmed = rs.getString("confirmed"); confirmed = rs.getString("confirmed");
} }
...@@ -362,161 +343,135 @@ conn = getConnection(); ...@@ -362,161 +343,135 @@ conn = getConnection();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ("S".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB2","");
return errString;
}else if ("X".equalsIgnoreCase(status)) if ("S".equalsIgnoreCase(status)) {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("","VTINVSUB4",""); "VTINVSUB2", "");
return errString; return errString;
} else if ("X".equalsIgnoreCase(status)) {
} else if ("C".equalsIgnoreCase(status) || "Y".equalsIgnoreCase(confirmed)) errString = itmDBAccessLocal.getErrorString("",
{ "VTINVSUB4", "");
errString = itmDBAccessLocal.getErrorString("","VTINVSUB3","");
return errString; return errString;
} else if ("C".equalsIgnoreCase(status)
}else if ("R".equalsIgnoreCase(status)) || "Y".equalsIgnoreCase(confirmed)) {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("","VTINVSUB5",""); "VTINVSUB3", "");
return errString; return errString;
} else if ("R".equalsIgnoreCase(status)) {
} else if ("P".equalsIgnoreCase(status)) errString = itmDBAccessLocal.getErrorString("",
{ "VTINVSUB5", "");
errString = itmDBAccessLocal.getErrorString("","VTECLNPRC1","");
return errString; return errString;
} else if ("P".equalsIgnoreCase(status)) {
}else errString = itmDBAccessLocal.getErrorString("",
{ "VTECLNPRC1", "");
return errString;
} else {
sql = " update receipt_form set status = 'S' where tran_id = ? "; sql = " update receipt_form set status = 'S' where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0)
{
errString = itmDBAccessLocal.getErrorString("", "VTSTATSUBM", "");
conn.commit();
} else if (cnt > 0) {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", ""); "VTSTATSUBM", "");
conn.commit();
} else {
errString = itmDBAccessLocal.getErrorString("",
"VTNCONFT", "");
} }
} }
} }
} catch (Exception e) {
// end if errstrng if (conn != null) {
} catch (Exception e)
{
if(conn!=null)
{
try { try {
conn.rollback(); conn.rollback();
} catch (SQLException ex) { } catch (SQLException ex) {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} finally } finally {
{ try {
try if (conn != null && !conn.isClosed()) {
{
if(conn != null && !conn.isClosed())
{
conn.close(); conn.close();
conn = null; conn = null;
} }
if(rs != null) if (rs != null) {
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} catch (Exception e) } catch (Exception e) {
{
System.out.println("Exception : " + e); System.out.println("Exception : " + e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return errString; return errString;
} }
public String open(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{ public String open(String tranId, String xtraParams, String forcedFlag)
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf open called>>>>>>>>>>>>>>>>>>>"); throws RemoteException, ITMException {
String sql = "",status=""; System.out
.println(">>>>>>>>>>>>>>>>>>EcollectionConf open called>>>>>>>>>>>>>>>>>>>");
String sql = "", status = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String errString = null; String errString = null;
ResultSet rs = null; ResultSet rs = null;
int cnt = 0; int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try try {
{
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 06-06-2016 :START conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0) {
{ System.out.println("tranId>>>[" + tranId + "]");
System.out.println("tranId>>>["+tranId+"]");
sql = " select status from receipt_form where tran_id = ? "; sql = " select status from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
status = rs.getString("status"); status = rs.getString("status");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ("R".equalsIgnoreCase(status) || "X".equalsIgnoreCase(status)) if ("R".equalsIgnoreCase(status) || "X".equalsIgnoreCase(status)) {
{
sql = " update receipt_form set status = 'E',confirmed = 'N' where tran_id = ? "; sql = " update receipt_form set status = 'E',confirmed = 'N' where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0) if (cnt > 0) {
{
conn.commit(); conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTECOLOPEN", ""); errString = itmDBAccessLocal.getErrorString("",
"VTECOLOPEN", "");
} }
}else } else {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("","VTECNOTREJ",""); "VTECNOTREJ", "");
} }
} }
// end if errstrng // end if errstrng
} catch (Exception e) } catch (Exception e) {
{ if (conn != null) {
if(conn!=null)
{
try { try {
conn.rollback(); conn.rollback();
} catch (SQLException ex) { } catch (SQLException ex) {
...@@ -527,28 +482,22 @@ conn = getConnection(); ...@@ -527,28 +482,22 @@ conn = getConnection();
} }
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} finally } finally {
{ try {
try if (conn != null && !conn.isClosed()) {
{
if(conn != null && !conn.isClosed())
{
conn.close(); conn.close();
conn = null; conn = null;
} }
if(rs != null) if (rs != null) {
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} catch (Exception e) } catch (Exception e) {
{
System.out.println("Exception : " + e); System.out.println("Exception : " + e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
...@@ -558,37 +507,33 @@ conn = getConnection(); ...@@ -558,37 +507,33 @@ conn = getConnection();
return errString; return errString;
} }
public String cancel(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{ public String cancel(String tranId, String xtraParams, String forcedFlag)
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf cancel called>>>>>>>>>>>>>>>>>>>"); throws RemoteException, ITMException {
String sql = "",status="",confirmed=""; System.out
.println(">>>>>>>>>>>>>>>>>>EcollectionConf cancel called>>>>>>>>>>>>>>>>>>>");
String sql = "", status = "", confirmed = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String errString = null; String errString = null;
ResultSet rs = null; ResultSet rs = null;
int cnt = 0; int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try try {
{
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 06-06-2016 :START conn = connDriver.getConnectDB("DriverITM");
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 06-06-2016 :END
conn.setAutoCommit(false); conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0) {
{ System.out.println("tranId>>>[" + tranId + "]");
System.out.println("tranId>>>["+tranId+"]");
sql = " select status,confirmed from receipt_form where tran_id = ? "; sql = " select status,confirmed from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
status = rs.getString("status"); status = rs.getString("status");
confirmed = rs.getString("confirmed"); confirmed = rs.getString("confirmed");
} }
...@@ -596,38 +541,37 @@ conn = getConnection(); ...@@ -596,38 +541,37 @@ conn = getConnection();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (!"X".equalsIgnoreCase(status) && !"C".equalsIgnoreCase(status) && !"P".equalsIgnoreCase(status)) if (!"X".equalsIgnoreCase(status)
{ && !"C".equalsIgnoreCase(status)
&& !"P".equalsIgnoreCase(status)) {
sql = " update receipt_form set status = 'X' where tran_id = ? "; sql = " update receipt_form set status = 'X' where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId); pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate(); cnt = pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0) if (cnt > 0) {
{
conn.commit(); conn.commit();
errString = itmDBAccessLocal.getErrorString("", "VTECLNCAN", ""); errString = itmDBAccessLocal.getErrorString("",
"VTECLNCAN", "");
} }
}else if("X".equalsIgnoreCase(status)) } else if ("X".equalsIgnoreCase(status)) {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("","VTECLNCANX",""); "VTECLNCANX", "");
}else if("C".equalsIgnoreCase(status)) } else if ("C".equalsIgnoreCase(status)) {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("","VTECLNCANC",""); "VTECLNCANC", "");
}else if("P".equalsIgnoreCase(status)) } else if ("P".equalsIgnoreCase(status)) {
{ errString = itmDBAccessLocal.getErrorString("",
errString = itmDBAccessLocal.getErrorString("","VTECLNPRC",""); "VTECLNPRC", "");
} }
} }
// end if errstrng // end if errstrng
} catch (Exception e) } catch (Exception e) {
{ if (conn != null) {
if(conn!=null)
{
try { try {
conn.rollback(); conn.rollback();
} catch (SQLException ex) { } catch (SQLException ex) {
...@@ -638,28 +582,22 @@ conn = getConnection(); ...@@ -638,28 +582,22 @@ conn = getConnection();
} }
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} finally } finally {
{ try {
try if (conn != null && !conn.isClosed()) {
{
if(conn != null && !conn.isClosed())
{
conn.close(); conn.close();
conn = null; conn = null;
} }
if(rs != null) if (rs != null) {
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} catch (Exception e) } catch (Exception e) {
{
System.out.println("Exception : " + e); System.out.println("Exception : " + e);
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
...@@ -669,15 +607,12 @@ conn = getConnection(); ...@@ -669,15 +607,12 @@ conn = getConnection();
return errString; return errString;
} }
private String checkNull(String str)
{ private String checkNull(String str) {
if(str == null) if (str == null) {
{
return ""; return "";
} } else {
else return str;
{
return str ;
} }
} }
......
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