Commit 9062a860 authored by prahate's avatar prahate

EJB updated for Dist.Receipt Req_Id [D14JSUN004].


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97988 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 237c5747
/********************************************************
Title : DistRcpExShClose
Date : 13/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.*;
import ibase.utility.EMail;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import javax.ejb.Stateless;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class DistRcpExShClose extends ActionHandlerEJB implements DistRcpExShCloseLocal, DistRcpExShCloseRemote // SessionBean
{
public String close(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println("Inside Close Method");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "", sql1 = "";
ConnDriver connDriver = null;
String loginEmpCode = "";
String status = "", empCode = "",siteCode="";
int updateCount=0;
double shortageAmtHdr=0.0;
ITMDBAccessEJB itmDBAccess = null;
ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility();
itmDBAccess = new ITMDBAccessEJB();
// ConnDriver connDriver = new ConnDriver();
connDriver = null;
// connStatus = true;
String objName = "", winName = "", eventCode = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
sql = "select status,site_code,shortage_amt from distrcp_exsh_hdr where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
status = rs.getString("status");
siteCode = rs.getString("site_code");
shortageAmtHdr=rs.getDouble("shortage_amt");
}
System.out.println("Status@@@@@@@@" + status);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (status != null && status.equalsIgnoreCase("C"))
{
System.out.println("The Selected transaction is already Closed");
errString = itmDBAccessEJB.getErrorString("", "VTMCLOSE1", "","", conn);
return errString;
}
else /* (status != null && status.equalsIgnoreCase("O") */
{
sql = "select status from distrcp_exsh_det where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next())
{
status = rs.getString("status");
System.out.println("Status : " + status);
if ("O".equalsIgnoreCase(status))
{
errString = itmDBAccessEJB.getErrorString("","VTMCLOSE2", "", "", conn);
return errString;
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
sql = "update distrcp_exsh_hdr set status = 'C', status_date = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDate(1, new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(2, tranId);
updateCount = pstmt.executeUpdate();
System.out.println("no of row update = " + updateCount);
System.out.println("Status Date"+ new java.sql.Date(new java.util.Date().getTime()));
System.out.println("tranId@@@@@@@@@" + tranId);
pstmt.close();
pstmt = null;
/*if (updateCoount > 0)//code comment by sagar on 19/05/15
{
errString = itmDBAccessEJB.getErrorString("", "VTEXCL001","", "", conn);//comment added by sagar on 19/05/15
}*/
//code added by sagar on 13/05/15, Start..
if(updateCount > 0)
{
System.out.println(">>In Close If update successfully then send intimation mail with report>>>");
DistRcpExShConf distRcpConf= new DistRcpExShConf();
errString=distRcpConf.sendMailReport(tranId, siteCode, shortageAmtHdr, xtraParams, conn);
//errString= sendMailReport(tranId,siteCode,shortageAmtHdr,xtraParams,conn);
System.out.println(">>>>In DistRcpExShClose after sendMailReport() errString:"+errString);
}
System.out.println(">>>>>>>Check errString:"+errString);
if((errString != null) && errString.indexOf("REPORTSUCC") > -1)
{
errString = itmDBAccessEJB.getErrorString("","VTEXCL001","","",conn);
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTFAILCLOS","","",conn);
}
//code added by sagar on 13/05/15, End.
}
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (errString != null && errString.trim().length() > 0)
{
if (errString.indexOf("VTEXCL001") > -1)
{
conn.commit();
}
else
{
conn.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;
}// end of close method
}// end of class
/********************************************************
Title : DistRcpExShConfLocal
Date : 13/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.*;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Local; // added for ejb3
@Local
public interface DistRcpExShCloseLocal extends ActionHandlerLocal//,EJBObject
{
public String close(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : DistRcpExShConfRemote
Date : 13/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.*;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface DistRcpExShCloseRemote extends ActionHandlerRemote//, EJBObject
{
public String close(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
/******************************************************** /********************************************************
Title : DistRcpExShConfLocal Title : DistRcpExShConfLocal
Date : 11/MAR/15 Date : 13/MAR/15
Developer: Pankaj R. Developer: Pankaj R.
********************************************************/ ********************************************************/
......
/******************************************************** /********************************************************
Title : DistRcpExShConfRemote Title : DistRcpExShConfRemote
Date : 11/MAR/15 Date : 13/MAR/15
Developer: Pankaj R. Developer: Pankaj R.
********************************************************/ ********************************************************/
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
......
/******************************************************** /********************************************************
Title : DistRcpExShICLocal Title : DistRcpExShICLocal
Date : 13/MAR/15 Date : 11/MAR/15
Developer: Pankaj R. Developer: Pankaj R.
********************************************************/ ********************************************************/
......
/******************************************************** /********************************************************
Title : DistRcpExShICRemote Title : DistRcpExShICRemote
Date : 13/MAR/15 Date : 11/MAR/15
Developer: Pankaj R. Developer: Pankaj R.
********************************************************/ ********************************************************/
......
/********************************************************
Title : DistRcpExShPostSave
Date : 17/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.E12GenericUtility;
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.Date;
import org.w3c.dom.Node;
import javax.ejb.Stateless;
@Stateless
public class DistRcpExShPostSave extends ValidatorEJB implements DistRcpExShPostSaveLocal,DistRcpExShPostSaveRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
System.out.println("------------ postSave method called-----------------DistRcpExShPostSave : ");
System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]");
Document dom = null;
String errString="",lineNoRcp="";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception : DistRcpExShPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String postSave(Document dom,String tranId,String xtraParams,Connection conn)
{
System.out.println("in DistRcpExShPostSave postSave tran_id---->>["+tranId+"]");
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="",errorString="";
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String lineNoDom="",lineNo="";
int count=0;
double quantityRcp=0,quantityActual=0,rate=0;
double shortageAmt=0,shortageAmtH=0;
try
{
E12GenericUtility genericUtility= new E12GenericUtility();
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);
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("line_no") )
{
lineNoDom = childNode.getFirstChild().getNodeValue().trim();
System.out.println("lineNo["+lineNo+"]lineNoDom["+lineNoDom+"]");
if (lineNo.equalsIgnoreCase(lineNoDom))
{
System.out.println("Break from here as line No match");
break;
}
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("qty_rcp") )
{
quantityRcp = Double.valueOf(childNode.getFirstChild().getNodeValue().trim());
System.out.println("quantityRcp-->["+quantityRcp+"]");
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("qty_actual") )
{
quantityActual = Double.valueOf(childNode.getFirstChild().getNodeValue().trim());
System.out.println("quantityActual-->["+quantityActual+"]");
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("rate") )
{
rate = Double.valueOf(childNode.getFirstChild().getNodeValue().trim());
}
}
System.out.println("rate-->["+rate+"] lineNo-->["+lineNo+"]");
shortageAmt=((quantityRcp)-(quantityActual)) * rate;
System.out.println("ShortageAmt--->>["+shortageAmt+"]");
shortageAmtH=shortageAmtH + shortageAmt;
System.out.println("ShortageAmtHHH--->>["+shortageAmtH+"]");
}//for loop
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
System.out.println("shortageAmtH-->["+shortageAmtH+"]");
{
sql="update distrcp_exsh_hdr set shortage_amt = ? where tran_id = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, shortageAmtH);
// pstmt.setDate(2, new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(2, tranId);
System.out.println("Shortage Amount : "+shortageAmtH);
count=pstmt.executeUpdate();
System.out.println("post count---->>["+count+"]");
if(count >0 )
{
conn.commit();
}
}
}
catch(Exception e)
{
System.out.println("Exception : DistRcpExShPostSave -->["+e.getMessage()+"]");
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception while rollbacking transaction....");
e1.printStackTrace();
}
}
return errorString;
}
}
/********************************************************
Title : DistRcpExShPostSaveLocal
Date : 17/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface DistRcpExShPostSaveLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
/********************************************************
Title : DistRcpExShPostSaveRemote
Date : 17/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote;
@Remote
public interface DistRcpExShPostSaveRemote extends ValidatorRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) 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