Commit fbc6a89a authored by agaikwad's avatar agaikwad

Request-M16LNEL001

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@163506 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 12a2e605
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.DatabaseMetaData;
import ibase.system.config.ConnDriver;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.ActionHandlerEJB;
import org.w3c.dom.Document;
import org.w3c.dom.*;
import java.util.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class QcOrdResultAct extends ActionHandlerEJB implements QcOrdResultActLocal,QcOrdResultActRemote//SessionBean
{
public String actionHandler() throws RemoteException,ITMException
{
return "";
}
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
//Document dom1 = null,dom2=null;
String retString = null;
try
{
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
/*if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}*/
if (actionType.equalsIgnoreCase("Default"))
{
retString = actionDefault(xmlString,objContext,xtraParams);
//retString = actionDefault(xmlString,xmlString1,objContext,xtraParams);
}
}
catch(Exception e)
{
System.out.println("Exception :ChargeBackLocAct :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from ChargeBackLocAct : actionHandler"+retString);
return retString;
}
/* public String actionHandler( String actionType, String xmlString, String objContext, String xtraParams ) throws RemoteException,ITMException
{
String retString = "";
Document dom = null;
try
{
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
if( xmlString != null && xmlString.trim().length() != 0 )
{
dom = genericUtility.parseString(xmlString);
}
}
catch( Exception e )
{
throw new ITMException(e);
}
return retString;
}*/
private String actionDefault(String xmlString, String objContext,String xtraParams) throws RemoteException, ITMException
{
System.out.println("xmlString from QcResult :"+xmlString);
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null;
PreparedStatement pstmt = null;
PreparedStatement pstmt1 = null;
ResultSet rs = null;
ResultSet rs1 = null;
StringBuffer valueXmlString = null;
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root>");
int currentFormNo = 0;
String sql = "";
String sql1 = "";
String retString = "";
String update_flag = "", errorId = "";
String termTableNo = "";
NodeList parentNodeList = null;
int parentNodeListLen = 0;
String childNodeName = null;
Node childNode = null;
NodeList childNodeList = null;
Node parentNode = null;
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
String qcOrder="";
String specCode="";
String descr="";
Document dom = null;
try
{
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
else
{
System.out.println("The xmlString found null");
}
if( conn == null )
{
ConnDriver connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 09-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
connDriver = null;
}
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt(objContext);
}
/* parentNodeList = dom1.getElementsByTagName("Detail2");
parentNodeListLen = parentNodeList.getLength();
System.out.println("Parent node length is ==>"+parentNodeListLen);
if( parentNodeListLen == 1 )
{
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
for(int childctr = 0; childctr < childNodeList.getLength(); childctr++)
{
childNode = childNodeList.item( childctr );
childNodeName = childNode.getNodeName();
if ( childNodeName.equalsIgnoreCase( "attribute" ) )
{
update_flag = childNode.getAttributes().getNamedItem("updateFlag").getNodeValue();
}
}
System.out.println("update_flag is ==>"+update_flag);
if( !update_flag.equals("N") )
{*/
qcOrder = genericUtility.getColumnValue("qorder_no",dom);
System.out.println("qcOrder["+qcOrder+"]");
if( qcOrder != null && qcOrder.trim().length() > 0 )
{
sql ="select spec_code from qcitem_spec_det";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while ( rs.next() )
{
specCode = rs.getString("spec_code");
System.out.println("Spec Code["+specCode+"]");
sql1 ="select spec_descr from qlty_specs where spec_code=? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1,specCode);
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
{
descr = rs1.getString("spec_descr");
}
pstmt1.close();
pstmt1 = null;
rs1.close();
rs1 = null;
System.out.println("descr["+descr+"]");
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<spec_code>").append("<![CDATA[").append(specCode).append("]]>").append("</spec_code>\r\n");
valueXmlString.append("<spec_descr>").append("<![CDATA[").append(descr).append("]]>").append("</spec_descr>\r\n");
valueXmlString.append("</Detail>\r\n");
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
}
/*}
else
{
errorId = "DATAPRSNT";
retString = itmDBAccessEJB.getErrorString("",errorId,userId);
return retString;
}
}*/
/* else
{
errorId = "DATAPRSNT";
retString = itmDBAccessEJB.getErrorString("",errorId,userId);
return retString;
}*/
valueXmlString.append("</Root>\r\n");
retString = valueXmlString.toString();
}
catch( SQLException sqx )
{
sqx.printStackTrace();
throw new ITMException( sqx );
}
catch( Exception e )
{
e.printStackTrace();
throw new ITMException( e );
}
finally
{
try
{
conn.close();
conn = null;
}
catch( Exception e )
{
e.printStackTrace();
throw new ITMException( e );
}
}
return retString;
}
}//end of Ejb
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface QcOrdResultActLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
//public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface QcOrdResultActRemote extends ActionHandlerRemote//,EJBHome
{
//public ActionHandler create() throws RemoteException, CreateException;
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
//public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.util.*;
import java.sql.*;
import java.rmi.RemoteException;
import java.text.*;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
//import javax.ejb.SessionBean;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.utility.*;
import ibase.utility.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class QcOrdResultFinish extends ActionHandlerEJB implements QcOrdResultFinishLocal, QcOrdResultFinishRemote //implements SessionBean
{
/* public void ejbCreate() throws RemoteException,CreateException{
}
public void ejbRemove(){
}
public void ejbActivate(){
}
public void ejbPassivate(){
}
public void setSessionContext(SessionContext se){
}*/
public String confirm(String tranId,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
ConnDriver connDriver = null;
String loginEmpCode = null;
ibase.utility.E12GenericUtility genericUtility= null;
Document dom = null;
int count=0;
ITMDBAccessEJB itmDBAccessEJB = null;
String errString = null;
int upd = 0;
double qtyPassed=0,qtyRejected=0;
String qOrder="";
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = new ibase.utility.E12GenericUtility();
connDriver = new ConnDriver();
//Changes and Commented By Bhushan on 09-06-2016 :START
//conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
//Changes and Commented By Bhushan on 09-06-2016 :END
connDriver = null;
conn.setAutoCommit(false);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
//check if there is record in detail
System.out.println("forced flag::::=>"+forcedFlag);
sql = " select qty_passed,qty_rejected,qorder_no from qc_ord_res where tran_id = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, tranId.trim() );
rs = pstmt.executeQuery();
if( rs.next() )
{
qtyPassed=rs.getDouble(1);
qtyRejected=rs.getDouble(2);
qOrder=rs.getString(3);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(qOrder!=null && qOrder.trim().length() > 0)
{
sql = "update qc_order set qty_passed =? , qty_rejected =? where qorder_no = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setDouble(1,qtyPassed);
pstmt.setDouble(2, qtyRejected);
pstmt.setString(3,qOrder);
upd=pstmt.executeUpdate();
pstmt.close();
pstmt = null;
}
if( errString != null && errString.trim().length() > 0 )
{
conn.rollback();
return errString;
}
else
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTCNLSUCC","");
}
System.out.println("errString : "+errString);
}catch(ITMException ie)
{
try{
conn.rollback();
}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
throw new ITMException( ie );
}catch(Exception e){
try{
conn.rollback();
}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
throw new ITMException( e );
}
finally
{
try{
if( pstmt != null )
{
pstmt.close();
}
pstmt = null;
if(conn != null)
{
conn.close();
}
conn = null;
}catch(Exception e){
e.printStackTrace();
}
}
return errString;
}
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface QcOrdResultFinishLocal extends ActionHandlerLocal //,EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface QcOrdResultFinishRemote extends ActionHandlerRemote//,EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg.adv;
//QcOrdResultPostSave
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.w3c.dom.Document;
import javax.ejb.Stateless;
@Stateless
public class QcOrdResultPostSave extends ValidatorEJB implements QcOrdResultPostSaveLocal,QcOrdResultPostSaveRemote {
E12GenericUtility genericUtility= new E12GenericUtility();
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
System.out.println("------------ postSave method called-----------------SaleOrderPostSave : ");
System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]");
Document dom = null;
String errString="";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception : QcOrdResultPostSave.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 QcOrdResultPostSave postSave tran_id---->>["+tranId+"]");
ResultSet rs=null,rs1=null;
PreparedStatement pstmt=null,pstmt1=null;
String sql="",errorString="",qcOrder="";
double sumQty=0;
try
{
tranId = genericUtility.getColumnValue("tran_id", dom);
System.out.println("tranId["+tranId+"]");
qcOrder = genericUtility.getColumnValue("qorder_no", dom);
System.out.println("qcOrder["+qcOrder+"]");
sql = "select qorder_no from qc_ord_res_spec where tran_id = ?";
pstmt1= conn.prepareStatement(sql);
pstmt1.setString(1, tranId );
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
qcOrder =rs1.getString(1);
System.out.println("qcOrder["+qcOrder+"]");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("qcOrder["+qcOrder+"]");
sql = "select sum(qty_rejected) from qc_ord_res_spec where tran_id = ? and qorder_no=?";
pstmt1= conn.prepareStatement(sql);
pstmt1.setString(1, tranId );
pstmt1.setString(2,qcOrder );
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
sumQty =rs1.getDouble(1);
System.out.println("sumQty["+sumQty+"]");
sql = "update qc_ord_res set qty_rejected = ? where tran_id = ? " ;
pstmt= conn.prepareStatement( sql );
pstmt.setDouble(1, sumQty );
pstmt.setString(2, tranId );
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}
catch(Exception e)
{
System.out.println("Exception : SaleOrderPostSave -->["+e.getMessage()+"]");
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception while rollbacking transaction....");
e1.printStackTrace();
}
}
// Changed by Manish for Maximum open cursor on 29/03/16 [start]
finally
{
try
{
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
if (pstmt1 != null)
{
pstmt1.close();
pstmt1=null;
}
if (rs1 !=null)
{
rs1.close();
rs1=null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
// Changed by Manish for Maximum open cursor on 29/03/16 [end]
return errorString;
}
@Override
public String postSave() throws RemoteException, ITMException {
// TODO Auto-generated method stub
return null;
}
}
package ibase.webitm.ejb.mfg.adv;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import com.aspose.words.Document;
@javax.ejb.Local
public interface QcOrdResultPostSaveLocal extends ValidatorLocal
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Remote
public interface QcOrdResultPostSaveRemote extends ValidatorRemote
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment