Commit 26b6cbef authored by caluka's avatar caluka

Ejb code updated for E-Collection confirm and submit


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97431 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 946a97a5
/********************************************************
Title : EcollectionConf[F14ISUN014]
Date : 17/02/15
Developer: Chandrashekar
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless;
import java.util.Calendar;
@Stateless
public class EcollectionConf extends ActionHandlerEJB implements EcollectionConfLocal, EcollectionConfRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf confirm called>>>>>>>>>>>>>>>>>>>");
String confirmed = "";
String sql = "";
Connection conn = null;
PreparedStatement pstmt = null;
String errString = null;
ResultSet rs = null;
String loginEmpCode="",status="",refNo="";
int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
Timestamp sysDate = null;
E12GenericUtility genericUtility= new E12GenericUtility();
try
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0)
{
System.out.println("@@@@@tranId"+tranId+"]");
sql = " select confirmed,status,ref_no from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
confirmed = rs.getString("confirmed");
status = rs.getString("status");
refNo = rs.getString("ref_no");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(refNo == null || refNo.trim().length() == 0)
{
errString = itmDBAccessLocal.getErrorString("","VTNULREFNO","");
}
else
{
if ("Y".equalsIgnoreCase(confirmed))
{
errString = itmDBAccessLocal.getErrorString("","VTINVCONF2","");
} else
{
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDateStr);
sysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println(">>>>>>>>sysDate:" + sysDate);
System.out.println(">>>>>>>>loginEmpCode:" + loginEmpCode);
if ("S".equalsIgnoreCase(status))
{
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;
if (cnt > 0)
{
errString = itmDBAccessLocal.getErrorString("", "VCNFSUC1", "");
} else
{
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
}
} else
{
errString = itmDBAccessLocal.getErrorString("", "VTNSUBCON", "");
}
}
}
}
// end if errstrng
} catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(errString != null && errString.trim().length() > 0)
{
System.out.println("--going to commit tranaction--");
if(errString.indexOf("VCNFSUC1") > -1)
{
conn.commit();
System.out.println("--transaction commited--");
}
else
{
conn.rollback();
System.out.println("--transaction rollback--");
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
public String submit(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println(">>>>>>>>>>>>>>>>>>EcollectionConf submit called>>>>>>>>>>>>>>>>>>>");
String sql = "",status="",confirmed="";
Connection conn = null;
PreparedStatement pstmt = null;
String errString = null;
ResultSet rs = null;
int cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
//E12GenericUtility genericUtility= new E12GenericUtility();
try
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
if (tranId != null && tranId.trim().length() > 0)
{
System.out.println("tranId>>>["+tranId+"]");
sql = " select status,confirmed from receipt_form where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
status = rs.getString("status");
confirmed = rs.getString("confirmed");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("S".equalsIgnoreCase(status))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB2","");
} else if ("C".equalsIgnoreCase(status) || "Y".equalsIgnoreCase(confirmed))
{
errString = itmDBAccessLocal.getErrorString("","VTINVSUB3","");
} else
{
sql = " update receipt_form set status = 'S' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
if (cnt > 0)
{
errString = itmDBAccessLocal.getErrorString("", "VTSTATSUBM", "");
} else
{
errString = itmDBAccessLocal.getErrorString("", "VTNCONFT", "");
}
}
}
// end if errstrng
} catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
} finally
{
try
{
if (errString != null && errString.trim().length() > 0)
{
System.out.println("--going to commit tranaction--");
if (errString.indexOf("VTSTATSUBM") > -1)
{
conn.commit();
System.out.println("--transaction commited--");
} else
{
conn.rollback();
System.out.println("--transaction rollback--");
}
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
} catch (Exception e)
{
System.out.println("Exception : " + e);
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
}
\ No newline at end of file
/********************************************************
Title : EcollectionConfLocal[F14ISUN014]
Date : 17/02/15
Developer: Chandrashekar
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface EcollectionConfLocal extends ActionHandlerLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String submit(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
/********************************************************
Title : EcollectionConfRemote[F14ISUN014]
Date : 17/02/15
Developer: Chandrashekar
********************************************************/
package ibase.webitm.ejb.fin.adv;
import java.rmi.RemoteException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface EcollectionConfRemote extends ActionHandlerRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String submit(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment