Commit e06024f4 authored by manohar's avatar manohar

This commit was generated by cvs2svn to compensate for changes in r439,

which included commits to RCS files with non-trunk default branches.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91504 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 97b4e65b
/*
* PURPOSE : Inv Hold Generation
* Author: Sandesh
* Date: 30/08/11
*/
package ibase.webitm.ejb.dis;
import ibase.ejb.*;
import ibase.utility.*;
import ibase.system.config.*;
import ibase.utility.BaseLogger;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.utility.ITMException;
import ibase.utility.CommonConstants;
import java.lang.*;
import java.io.*;
import java.rmi.RemoteException;
import java.sql.*;
import javax.ejb.*;
import java.text.*;
import java.util.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
public class InvHoldGen
{
public String generateHoldTrans( String lockCode, String refID, String refSer, String siteCode, ArrayList stockList, String xtraParams, Connection conn )throws RemoteException,ITMException
{
String sql = "";
String confirmed = "";
String itemCode = "";
String locCode = "";
String lotSl = "";
String lotNo = "";
String chgUser = "";
String chgTerm = "";
String retString = "";
String tranId = "";
java.sql.Timestamp chgDate = null,currDate = null;
int lineNo = 0;
boolean isError = false;
PreparedStatement pstmtHold = null;
PreparedStatement pstmtHolddet = null;
PreparedStatement pstmtSel = null;
ResultSet rsSel = null;
java.util.Date date = null;
try
{
if ( lockCode == null || lockCode.trim().length() == 0 )
{
return "";
}
conn.setAutoCommit(false);
String holdInsertSql = "INSERT INTO INV_HOLD(TRAN_ID,TRAN_DATE,SITE_CODE,CONFIRMED,REF_ID,REF_SER,CHG_USER,CHG_DATE,CHG_TERM, LOCK_CODE) VALUES(?,?,?,?,?,?,?,?,?,?)";
pstmtHold = conn.prepareStatement(holdInsertSql);
String holddetInsertSql = "INSERT INTO INV_HOLD_DET(TRAN_ID,LINE_NO,ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL,HOLD_STATUS) VALUES(?,?,?,?,?,?,?,?)";
pstmtHolddet = conn.prepareStatement(holddetInsertSql);
GenericUtility genericUtility = GenericUtility.getInstance();
chgDate = new java.sql.Timestamp( System.currentTimeMillis() );
currDate = new java.sql.Timestamp(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
chgDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
int updCnt = 0;
tranId = generateTranId( "w_inv_hold", conn );
pstmtHold.setString( 1, tranId );
pstmtHold.setTimestamp( 2, currDate );
pstmtHold.setString( 3, siteCode );
pstmtHold.setString( 4, "N" );
pstmtHold.setString( 5, refID );
pstmtHold.setString( 6, refSer );
pstmtHold.setString( 7, userId );
pstmtHold.setTimestamp( 8, currDate );
pstmtHold.setString( 9, chgTerm );
pstmtHold.setString( 10, lockCode );
updCnt = pstmtHold.executeUpdate();
pstmtHold.clearParameters();
if( updCnt > 0 )
{
System.out.println( updCnt + " rows updated successfully" );
}
HashMap dataMap = new HashMap();
for ( int ctr = 0; ctr < stockList.size(); ctr++ )
{
lineNo++;
dataMap = (HashMap)stockList.get(ctr);
itemCode = "";
siteCode = "";
locCode = "";
lotNo = "";
lotSl = "";
if ( dataMap.get("item_code") != null )
{
itemCode = (String)dataMap.get("item_code");
}
if ( dataMap.get("site_code") != null )
{
siteCode = (String)dataMap.get("site_code");
}
if ( dataMap.get("loc_code") != null )
{
locCode = (String)dataMap.get("loc_code");
}
if ( dataMap.get("lot_no") != null )
{
lotNo = (String)dataMap.get("lot_no");
}
if ( dataMap.get("lot_sl") != null )
{
lotSl = (String)dataMap.get("lot_sl");
}
pstmtHolddet.setString( 1, tranId );
pstmtHolddet.setInt( 2, lineNo );
pstmtHolddet.setString( 3, itemCode );
pstmtHolddet.setString( 4, siteCode );
pstmtHolddet.setString( 5, locCode );
pstmtHolddet.setString( 6, lotNo );
pstmtHolddet.setString( 7, lotSl );
pstmtHolddet.setString( 8, "H" );
pstmtHolddet.addBatch();
pstmtHolddet.clearParameters();
dataMap.clear();
}
pstmtHolddet.executeBatch();
pstmtHolddet.clearBatch();
}
catch(BatchUpdateException buex)
{
isError = true;
retString = "ERROR";
int [] updateCounts = buex.getUpdateCounts();
for (int i = 0; i < updateCounts.length; i++)
{
System.err.println(" Statement " + i + ":" + updateCounts[i]);
}
System.err.println(" Message: " + buex.getMessage());
System.err.println(" SQLSTATE: " + buex.getSQLState());
System.err.println(" Error code: " + buex.getErrorCode());
SQLException ex = buex.getNextException();
while (ex != null)
{
System.err.println("SQL exception:");
System.err.println(" Message: " + ex.getMessage());
System.err.println(" SQLSTATE: " + ex.getSQLState());
System.err.println(" Error code: " + ex.getErrorCode());
ex = ex.getNextException();
}
}
catch (Exception e)
{
isError = true;
retString = "ERROR";
System.out.println ( "Exception: InvHoldGen: " + e.getMessage() + ":" );
throw new ITMException(e);
}
finally
{
try
{
if ( !isError )
{
//conn.commit();
}
if ( rsSel !=null )
{
rsSel.close();
rsSel = null;
}
if ( pstmtHold!=null )
{
pstmtHold.close();
pstmtHold = null;
}
if ( pstmtHolddet!=null )
{
pstmtHolddet.close();
pstmtHolddet = null;
}
}
catch(Exception e)
{
System.out.println( "Exception ::==>\n"+e.getMessage());
throw new ITMException(e);
}
}
return retString;
}
private String generateTranId( String windowName, Connection conn )throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
String paySiteCode = "";
String effectiveDate = "";
java.sql.Date effDate = null;
try
{
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
//System.out.println("selSql :"+selSql);
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
}
return tranId;
}//generateTranTd()
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.text.*;
import java.sql.*;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class InvHoldIC extends ValidatorEJB implements InvHoldICLocal , InvHoldICRemote // SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("EpaymentICEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
System.out.println("xmlString:::"+xmlString);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : EpaymentICEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0;
String childNodeName = null;
String errCode = null;
String userId = null;
int cnt = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
String tranDateStr = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
genericUtility = GenericUtility.getInstance();
if(objContext != null && objContext.length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if ( childNodeName.equalsIgnoreCase( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "site_code", dom, "1" );
if( siteCode != null )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM site WHERE site_code ='" + siteCode.trim() + "'";
System.out.println( " SQL FOR custCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM site WHERE site_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Site invalid or not found <==== ");
errCode = "VMINVSITE";
errString = getErrorString( "SITE_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase( "emp_code__aprv" ) )
{
String empCode = null;
empCode = genericUtility.getColumnValue( "emp_code__aprv", dom, "1" );
if( empCode != null && empCode.length() > 0 )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM Employee WHERE emp_code ='" + empCode.trim() + "'";
System.out.println( " SQL FOR empCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM Employee WHERE emp_code = ?";
System.out.println( " SQL FOR empCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,empCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Employee invalid or not found <==== ");
errCode = "VMINVEMP";
errString = getErrorString( "EMP_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase( "role_code" ) )
{
String roleCode = null;
roleCode = genericUtility.getColumnValue( "role_code", dom, "1" );
if( roleCode != null && roleCode.length() > 0 )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select count( 1 ) cnt from wf_role where role_code = '" + roleCode + "'";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from wf_role where role_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,roleCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Role code invalid or not found <==== ");
errCode = "VMINVROLE";
errString = getErrorString( "role_code", errCode, userId );
}
}
}
//Changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate lock_code.Start
if ( childNodeName.equalsIgnoreCase( "lock_code" ) )
{
String lockCode = null;
lockCode = genericUtility.getColumnValue( "lock_code", dom, "1" );
if(lockCode == null)//checking for null
{
errString = getErrorString("lock_code","NULLLOCKCD",userId);
break;
}
else //To check exist in INV_LOCK master
{
sql = "SELECT COUNT(*) COUNT FROM INV_LOCK WHERE LOCK_CODE = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,lockCode);
rs = pstmt.executeQuery();
if( rs.next())
{
cnt = rs.getInt("COUNT");
}
if( cnt == 0 )
{
errString = getErrorString("lock_code","INVLOCKCD",userId);
break;
}
}
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
//Changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate lock_code.end
} //END OF CASE1
break;
case 2 :
System.out.println("VALIDATION FOR DETAIL [ 2 ]..........");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to get the value of the LINE_NO_SL.Start
boolean lineNoSlPrsnt = false;
String lineNoSl = null;
lineNoSl = genericUtility.getColumnValue( "line_no_sl", dom, "2" );
System.out.println("lineNoSl =["+lineNoSl+"]");
if( lineNoSl != null && lineNoSl.trim().length() > 0 )
{
lineNoSlPrsnt = true;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to get the value of the LINE_NO_SL.End
if ( childNodeName.equalsIgnoreCase( "item_code" ) )
{
String itemCode = null;
itemCode = genericUtility.getColumnValue( "item_code", dom, "2" );
errCode = null;
System.out.println(" itemCode =====> [" + itemCode + "]");
if( itemCode != null && itemCode.length() > 0 )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM item WHERE item_code ='" + itemCode.trim() + "'";
System.out.println( " SQL FOR item ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM item WHERE item_code = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Item Code Invalid <==== ");
errCode = "VMINVITEM";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
errCode = "VMITEMBLK";
}
if( errCode != null )
{
errString = getErrorString( "item_code", errCode, userId );
}
}
else if( childNodeName.equalsIgnoreCase( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "site_code", dom, "2" );
if( siteCode != null )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM site WHERE site_code ='" + siteCode.trim() + "'";
System.out.println( " SQL FOR siteCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM site WHERE site_code =?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Site invalid or not found <==== ");
errCode = "VMINVSITE";
errString = getErrorString( "SITE_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate null site code if Line No is present.start
else
{
if(lineNoSlPrsnt)
{
errString = getErrorString( "SITE_CODE", "NULLSITECD" , userId );
}
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate null site code if Line No is present.end
}
else if( childNodeName.equalsIgnoreCase( "loc_code" ) )
{
String locCode = null;
locCode = genericUtility.getColumnValue( "loc_code", dom, "2" );
if( locCode != null )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM Location WHERE loc_code ='" + locCode.trim() + "'";
System.out.println( " SQL FOR locCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM Location WHERE loc_code =?";
pstmt = conn.prepareStatement( sql );
System.out.println( " SQL FOR locCode ====> " + sql );
pstmt.setString(1,locCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Location invalid or not found <==== ");
errCode = "VMINVLOC";
errString = getErrorString( "LOC_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate null location code if Line No is present.start
else
{
if(lineNoSlPrsnt)
{
errString = getErrorString( "LOC_CODE", "NULLLOCCD" , userId );
}
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate null location code if Line No is present.end
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate null lot no & lot sl if Line No is present.start
else if( childNodeName.equalsIgnoreCase( "lot_no" ) )
{
String lotNo = null;
lotNo = genericUtility.getColumnValue( "lot_no", dom, "2" );
if( lineNoSlPrsnt )
{
if( lotNo == null )
{
errString = getErrorString( "LOT_NO", "NULLLOTNO", userId );
}
}
}
else if( childNodeName.equalsIgnoreCase( "lot_sl" ) )
{
String lotSl = null;
lotSl = genericUtility.getColumnValue( "lot_sl", dom, "2" );
if( lineNoSlPrsnt )
{
if( lotSl == null )
{
errString = getErrorString( "LOT_SL", "NULLLOTSL", userId );
}
}
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to validate null lot no & lot sl if Line No is present.end
else if ( childNodeName.equalsIgnoreCase( "sch_rel_date" ) )
{
java.sql.Timestamp schRelDate = null;
java.sql.Timestamp tranDate = null;
String schRelDateStr = null;
schRelDateStr = genericUtility.getColumnValue( "sch_rel_date", dom, "2" );
tranDateStr = genericUtility.getColumnValue( "tran_date", dom1, "1" );
errCode = null;
System.out.println( "tranDateStr :: " + tranDateStr );
if( schRelDateStr == null || schRelDateStr.length() == 0 )
{
errCode = "VMSCHDTBLK";
}
else
{
if( tranDateStr != null && tranDateStr.length() > 0 )
{
tranDate = Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
/*
else
{
tranDate = new java.sql.Timestamp( System.currentTimeMillis() - 24 * 3600 );
//tranDate = Timestamp.valueOf(genericUtility.getValidDateString( tranDate.toString(), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println( "tranDate :: " + tranDate );
}
*/
System.out.println( "tranDate :: " + tranDate );
schRelDate = Timestamp.valueOf(genericUtility.getValidDateString(schRelDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println( "schRelDate :: " + schRelDate );
if( schRelDate.compareTo ( tranDate ) < 0 )
{
errCode = "VMSCHDTBFR";
}
}
if( errCode != null )
{
errString = getErrorString( "sch_rel_date", errCode, userId );
}
}
}//END FOR OF CASE2
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString( "", errCode, userId );
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < ExprProcessIcEJB > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
System.out.println("xmlString1" + xmlString1);
if (xmlString2.length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EpaymentICEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("[EpaymentICEJB] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.equals( "itm_default" ))
{
String loginSiteCode = null;
String loginEmpCode = null;
String deptCode = null;
String deptDescr = null;
String siteDescr = null;
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select e.dept_code, d.descr dept_descr, s.descr site_descr from employee e, department d, site s "
+" where e.emp_code = '" + loginEmpCode + "'"
+" and s.site_code = '" + loginSiteCode + "'"
+" and e.dept_code = d.dept_code(+) ";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
*/
sql = "select e.dept_code, d.descr dept_descr, s.descr site_descr from employee e, department d, site s "
+" where e.emp_code = ? "
+" and s.site_code = ?"
+" and e.dept_code = d.dept_code(+) ";
pStmt = conn.prepareStatement( sql );
pStmt.setString(1,loginEmpCode);
pStmt.setString(2,loginSiteCode);
rs = pStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
deptCode = rs.getString( "dept_code" );
deptDescr = rs.getString( "dept_descr" );
siteDescr = rs.getString( "site_descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<tran_date>").append("<![CDATA[" + getCurrdateAppFormat() + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + ( loginSiteCode != null ? loginSiteCode : "" )+ "]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr : "" )+ "]]>").append("</site_descr>");
valueXmlString.append("<dept_code>").append("<![CDATA[" + ( deptCode != null ? deptCode : "" )+ "]]>").append("</dept_code>");
valueXmlString.append("<department_descr>").append("<![CDATA[" + ( deptDescr != null ? deptDescr : "" )+ "]]>").append("</department_descr>");
}
if (currentColumn.equals( "role_code" ))
{
String descr = null;
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select descr from wf_role where role_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
*/
sql = "select descr from wf_role where role_code = ?";
pStmt = conn.prepareStatement(sql);
if(columnValue != null)
{
pStmt.setString(1,columnValue);
}
else
{
pStmt.setString(1,"");
}
rs = pStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<wf_role_descr>").append("<![CDATA[" + ( descr != null ? descr : "" )+ "]]>").append("</wf_role_descr>");
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to display descreption of the lock code when lock code is entered.start
if (currentColumn.equals( "lock_code" ))
{
String lockDescr = null;
sql = "SELECT DESCR FROM INV_LOCK WHERE LOCK_CODE = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1,columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
lockDescr = rs.getString( "DESCR" );
}
valueXmlString.append( "<lock_descr><![CDATA[" ).append( lockDescr != null ? lockDescr : "").append( "]]></lock_descr>\r\n" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pStmt != null )
{
pStmt.close();
pStmt = null;
}
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to display descreption of the lock code when lock code is entered.end
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
///////////////
case 2:
valueXmlString.append("<Detail2>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.equals( "itm_default" ))
{
valueXmlString.append("<hold_status>").append("<![CDATA[" + "H" + "]]>").append("</hold_status>");
valueXmlString.append("<status_date>").append("<![CDATA[" + getCurrdateAppFormat() + "]]>").append("</status_date>");
}
if (currentColumn.equals( "item_code" ))
{
String descr = null;
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select descr from item where item_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
*/
sql = "select descr from item where item_code = ?";
pStmt = conn.prepareStatement(sql);
if(columnValue != null)
{
pStmt.setString(1,columnValue);
}
else
{
pStmt.setString(1,"");
}
rs = pStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
//end getting site bank
valueXmlString.append("<item_descr>").append("<![CDATA[" + ( descr != null ? descr : "" )+ "]]>").append("</item_descr>");
}
if (currentColumn.equals( "site_code" ))
{
String descr = null;
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select descr from site where site_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
*/
sql = "select descr from site where site_code = ?";
pStmt = conn.prepareStatement(sql);
if(columnValue != null)
{
pStmt.setString(1,columnValue);
}
else
{
pStmt.setString(1,"");
}
rs = pStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
//end getting site bank
valueXmlString.append("<site_descr>").append("<![CDATA[" + ( descr != null ? descr : "" )+ "]]>").append("</site_descr>");
}
if (currentColumn.equals( "loc_code" ))
{
String descr = null;
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select descr from location where loc_code = '" + ( columnValue.trim() != null ? columnValue : "" ) + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
*/
sql = "select descr from location where loc_code = ?";
pStmt = conn.prepareStatement(sql);
if(columnValue != null)
{
pStmt.setString(1,columnValue);
}
else
{
pStmt.setString(1,"");
}
rs = pStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
//end getting site bank
valueXmlString.append("<location_descr>").append("<![CDATA[" + ( descr != null ? descr : "" )+ "]]>").append("</location_descr>");
}
valueXmlString.append("</Detail2>");
valueXmlString.append("</Root>");
////////////////
}//END OF TRY
}
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pStmt != null )
{
pStmt.close();
pStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface InvHoldICLocal extends ValidatorLocal //, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, 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;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, 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;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface InvHoldICRemote extends ValidatorRemote //, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, 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;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, 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;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.text.*;
import java.sql.*;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class InvHoldRelIC extends ValidatorEJB implements InvHoldRelICLocal , InvHoldRelICRemote // SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("EpaymentICEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
System.out.println( "xmlString::: " + xmlString );
System.out.println( "xmlString1:::" + xmlString1 );
System.out.println( "xmlString2:::" + xmlString2 );
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : EpaymentICEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0;
String childNodeName = null;
String errCode = null;
String userId = null;
int cnt = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
String tranIdHold = null;
String lineNo = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
genericUtility = GenericUtility.getInstance();
if(objContext != null && objContext.length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if ( childNodeName.equalsIgnoreCase( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "cust_code", dom, "1" );
if( siteCode != null )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM site WHERE site_code ='" + siteCode.trim() + "'";
System.out.println( " SQL FOR custCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM site WHERE site_code = ?";
System.out.println( " SQL FOR custCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Site invalid or not found <==== ");
errCode = "VMINVSITE";
errString = getErrorString( "SITE_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase( "emp_code__aprv" ) )
{
String empCode = null;
empCode = genericUtility.getColumnValue( "emp_code__aprv", dom, "1" );
if( empCode != null && empCode.length() > 0 )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " SELECT COUNT(*) FROM Employee WHERE emp_code ='" + empCode.trim() + "'";
System.out.println( " SQL FOR empCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = " SELECT COUNT(*) FROM Employee WHERE emp_code = ?";
System.out.println( " SQL FOR custCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,empCode);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Employee invalid or not found <==== ");
errCode = "VMINVEMP";
errString = getErrorString( "EMP_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
} //END OF CASE1
break;
case 2 :
System.out.println("VALIDATION FOR DETAIL [ 2 ]..........");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
errCode = null;
if( childNodeName.equalsIgnoreCase( "tran_id__hold" ) || childNodeName.equalsIgnoreCase( "LINE_NO__HOLD" ) )
{
tranIdHold = genericUtility.getColumnValue( "tran_id__hold", dom, "2" );
lineNo = genericUtility.getColumnValue( "line_no__hold", dom, "2" );
if( tranIdHold != null && tranIdHold.length() > 0 )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select count( 1 ) cnt from inv_hold_det where tran_id = '" + tranIdHold + "' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from inv_hold_det where tran_id = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,tranIdHold);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VTTRANINV";
}
if( errCode == null )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select count( 1 ) cnt from inv_hold where tran_id = '" + tranIdHold + "' and confirmed = 'Y' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from inv_hold where tran_id = ? and confirmed = 'Y' ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,tranIdHold);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VTTRANUNC";
}
}
}
else
{
errCode = "VTTRANBLK";
}
if( errCode != null )
{
errString = getErrorString( "tran_id__hold", errCode, userId );
}else if( lineNo != null && lineNo.length() > 0 )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select count( 1 ) cnt from inv_hold_det where tran_id = '" + tranIdHold + "' and line_no = " + lineNo;
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "SELECT COUNT( 1 ) CNT FROM INV_HOLD_DET WHERE TRAN_ID = ? AND LINE_NO = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,tranIdHold);
pstmt.setString(2,lineNo);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt == 0 )
{
errCode = "VTLINEINV";
}
}
else
{
errCode = "VTLINEBLK";
}
if( errCode != null )
{
errString = getErrorString( "line_no__hold", errCode, userId );
}else if ( ( tranIdHold != null && tranIdHold.length() > 0 ) && ( lineNo != null && lineNo.length() > 0 ) )
{
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select count( 1 ) cnt from inv_hold_det where tran_id = '" + tranIdHold + "' and line_no = " + lineNo + " and HOLD_STATUS = 'R'";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "SELECT COUNT( 1 ) CNT FROM INV_HOLD_DET WHERE TRAN_ID = ? AND LINE_NO = ? AND HOLD_STATUS = 'R'";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,tranIdHold);
pstmt.setString(2,lineNo);
rs = pstmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
cnt = rs.getInt( "cnt" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt > 0 )
{
errCode = "VTTRNCNFED";
}
}
if( errCode != null )
{
errString = getErrorString( "line_no__hold", errCode, userId );
}
else
{
NodeList allLines = null;
NodeList allTranIds = null;
String tranIdH = null;
String lineNoH = null;
int recCnt = 0;
System.out.println( " tranIdHold, lineNoHold :: ( " + tranIdHold + ", " + lineNo + " )" );
allLines = dom2.getElementsByTagName("line_no__hold");
allTranIds = dom2.getElementsByTagName("tran_id__hold");
int noOfLines = allLines.getLength();
for( int idx = 0; idx < noOfLines ; idx++ )
{
if ( allTranIds.item( idx ).getFirstChild() != null )
{
tranIdH = ( allTranIds.item( idx ).getFirstChild() ).getNodeValue();
}
if ( allLines.item( idx ).getFirstChild() != null )
{
lineNoH = ( allLines.item( idx ).getFirstChild() ).getNodeValue();
}
System.out.println( " tranIdH :: ( " + tranIdH + ", " + lineNoH + " )" );
if( tranIdH.equals( tranIdHold ) && lineNoH.equals( lineNo ) )
{
recCnt++;
}
}
if( recCnt > 1 )
{
errCode = "VTDUPENTRY";
errString = getErrorString( "line_no__hold", errCode, userId );
}
}
}
}//END FOR OF CASE2
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < ExprProcessIcEJB > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
System.out.println("xmlString1" + xmlString1);
if (xmlString2.length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EpaymentICEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement vPStmt = null;
ResultSet vRs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String loginSite = null;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("[EpaymentICEJB] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append("<Detail1>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.equals( "itm_default" ))
{
String siteDescription = null;
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "select s.descr site_descr from site s "
+" where s.site_code = '" + loginSite + "'";
vPStmt = conn.prepareStatement( sql );
vRs = vPStmt.executeQuery();
*/
sql = "SELECT S.DESCR SITE_DESCR FROM SITE S WHERE S.SITE_CODE = ?";
vPStmt = conn.prepareStatement( sql );
vPStmt.setString(1,loginSite);
vRs = vPStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( vRs.next() )
{
siteDescription = vRs.getString( "site_descr" );
}
vRs.close();
vRs = null;
vPStmt.close();
vPStmt = null;
valueXmlString.append("<tran_date>").append("<![CDATA[" + getCurrdateAppFormat() + "]]>").append("</tran_date>");
valueXmlString.append("<confirmed>").append("<![CDATA[" + "N" + "]]>").append("</confirmed>");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + ( siteDescription != null ? siteDescription : "" )+ "]]>").append("</site_descr>");
}
if (currentColumn.equals( "site_code" ))
{
//site bank
String vSql = null;
String siteDescr = null;
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
vSql = "select descr from site where site_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
vPStmt = conn.prepareStatement( vSql );
vRs = vPStmt.executeQuery();
*/
vSql = "select descr from site where site_code = ?";
vPStmt = conn.prepareStatement(vSql);
if(columnValue != null)
{
vPStmt.setString(1,columnValue);
}
else
{
vPStmt.setString(1,"");
}
vRs = vPStmt.executeQuery();
//Changed by Dharmesh on 09/08/11 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( vRs.next() )
{
siteDescr = vRs.getString( "descr" );
}
vRs.close();
vRs = null;
vPStmt.close();
vPStmt = null;
//end getting site bank
valueXmlString.append("<site_descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr : "" )+ "]]>").append("</site_descr>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
}//END OF TRY
}
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( vRs != null )
{
vRs.close();
vRs = null;
}
if ( vPStmt != null )
{
vPStmt.close();
vPStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface InvHoldRelICLocal extends ValidatorLocal //, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, 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;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, 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;
}
\ No newline at end of file
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface InvHoldRelICRemote extends ValidatorRemote //, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, 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;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, 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;
}
\ No newline at end of file
package ibase.webitm.ejb.dis.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 InvHoldConf extends ActionHandlerEJB implements InvHoldConfLocal ,InvHoldConfRemote //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
{
String retString = "",errCode = "",confirmed = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
boolean isError = false;
ResultSet rs = null;
PreparedStatement pStmt = null;
String actionSet = "";
boolean isConn= true;
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
retString =this.confirm( tranID,xtraParams, forcedFlag ,conn ,isConn);
if ( retString != null && retString.length() > 0 )
{
throw new Exception("Exception while calling confirm for tran Id:["+tranID+"]");
}
}
catch(Exception exception)
{
System.out.println("Exception in [InvHoldConfEJB] getCurrdateAppFormat " + exception.getMessage());
}
return retString;
}
public String confirm(String tranId,String xtraParams, String forcedFlag ,Connection conn ,boolean conStat) throws RemoteException,ITMException
{
//Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
ConnDriver connDriver = null;
String loginEmpCode = null;
ibase.webitm.utility.GenericUtility genericUtility = null;
Document dom = null;
int count=0;
ITMDBAccessEJB itmDBAccessEJB = null;
String errString = null;
int upd = 0;
boolean conStatus = conStat;
//changed by Dharmesh on 12-08-2011 [WM1ESUN004].start
String itemCode = null;
String siteCode = null;
String locCode = null;
String lotNo = null;
String lotSl = null;
String lineNoSl = null;
String tranIdTrace = null;
String sqlUpdate = null;
String sqlSelStck = null;
String sqlInsert = null;
String sqlHoldDet = null;
String sqlNoSl = null;
String lockCode = null;
double holdQty = 0.0;
double qtyPerArt = 0.0;
double stockQty = 0.0;
PreparedStatement pUpdate = null;
PreparedStatement pSelStck = null;
PreparedStatement pstmtInsert = null;
PreparedStatement pHoldDet = null;
ResultSet rsHoldDet = null;
ResultSet rsSelStck = null;
ResultSet rsNoSl = null;
//changed by Dharmesh on 12-08-2011 [WM1ESUN004].end
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
/*
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
*/
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
//check if there is record in detal
int countDet = 0;
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " select count( 1 ) cnt from inv_hold_det where tran_id = '" + tranId.trim() + "' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from inv_hold_det where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet == 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTNODET","","",conn);
}
if( errString == null || errString.length() == 0 )
{
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " select count( 1 ) cnt from inv_hold where tran_id = '" + tranId.trim() + "' AND CONFIRMED = 'Y' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from inv_hold where tran_id = ? AND CONFIRMED = 'Y' " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet > 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTCONFMD","","",conn);
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to commit unconfirmed transaction.start
else
{
sql = "SELECT LOCK_CODE FROM INV_HOLD WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if ( rs.next() )
{
lockCode = rs.getString("LOCK_CODE");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
sqlUpdate = "UPDATE STOCK SET HOLD_QTY = ? WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? ";
pUpdate = conn.prepareStatement ( sqlUpdate );
sqlSelStck = "SELECT QUANTITY, QTY_PER_ART, HOLD_QTY FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? " ;
pSelStck = conn.prepareStatement( sqlSelStck );
sqlInsert = " INSERT INTO INV_HOLD_REL_TRACE ( TRAN_ID, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, REF_NO, HOLD_QTY, LOCK_CODE ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? ) " ;
pstmtInsert = conn.prepareStatement(sqlInsert);
sqlHoldDet = "SELECT ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, LINE_NO_SL FROM INV_HOLD_DET WHERE TRAN_ID = ?" ;
pHoldDet = conn.prepareStatement(sqlHoldDet);
pHoldDet.setString(1,tranId);
rsHoldDet = pHoldDet.executeQuery();
pHoldDet.clearParameters();
while ( rsHoldDet.next() )
{
itemCode = checkNull(rsHoldDet.getString("ITEM_CODE"));
siteCode = checkNull(rsHoldDet.getString("SITE_CODE"));
locCode = checkNull(rsHoldDet.getString("LOC_CODE"));
lotNo = checkNull(rsHoldDet.getString("LOT_NO"));
lotSl = checkNull(rsHoldDet.getString("LOT_SL"));
lineNoSl = checkNull(rsHoldDet.getString("LINE_NO_SL"));
if( lineNoSl != null && lineNoSl.trim().length() > 0 ) //i.e. Line_sl is present
{
tranIdTrace = generateTranId("w_inv_hold_rel_trace", conn);
pSelStck.setString( 1,itemCode );
pSelStck.setString( 2,siteCode );
pSelStck.setString( 3,locCode );
pSelStck.setString( 4,lotNo );
pSelStck.setString( 5,lotSl );
rsSelStck = pSelStck.executeQuery();
if( rsSelStck.next() )
{
stockQty = rsSelStck.getDouble("QUANTITY");
qtyPerArt = rsSelStck.getDouble("QTY_PER_ART");
holdQty = rsSelStck.getDouble("HOLD_QTY");
}
if( rsSelStck != null )
{
rsSelStck.close();
rsSelStck = null;
}
pSelStck.clearParameters();
if(holdQty != stockQty)
{
holdQty = holdQty + qtyPerArt;
if( holdQty > stockQty )
{
pUpdate.setDouble( 1, stockQty );
}
else//i.e.( holdQty <= stockQty )
{
pUpdate.setDouble( 1, holdQty );
}
pUpdate.setString( 2, itemCode);
pUpdate.setString( 3, siteCode);
pUpdate.setString( 4, locCode);
pUpdate.setString( 5, lotNo);
pUpdate.setString( 6, lotSl);
pUpdate.executeUpdate();
pUpdate.clearParameters();
}
pstmtInsert.setString( 1, tranIdTrace);
pstmtInsert.setString( 2, itemCode );
pstmtInsert.setString( 3, siteCode );
pstmtInsert.setString( 4, locCode );
pstmtInsert.setString( 5, lotNo);
pstmtInsert.setString( 6, lotSl );
pstmtInsert.setString( 7, tranId);
pstmtInsert.setDouble( 8,qtyPerArt );
pstmtInsert.setString( 9, lockCode );
pstmtInsert.executeUpdate();
pstmtInsert.clearParameters();
}
else //i.e. line_sl is not found
{
pHoldDet.setString( 1, tranId );
rsNoSl = pHoldDet.executeQuery();
while ( rsNoSl.next() )
{
HashMap pkKeyValMap = new HashMap();
StringBuffer sb = new StringBuffer("SELECT ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY, HOLD_QTY,QTY_PER_ART FROM STOCK WHERE ");
itemCode = checkNull(rsNoSl.getString("ITEM_CODE"));
siteCode = checkNull(rsNoSl.getString("SITE_CODE"));
locCode = checkNull(rsNoSl.getString("LOC_CODE"));
lotNo = checkNull(rsNoSl.getString("LOT_NO"));
lotSl = checkNull(rsNoSl.getString("LOT_SL"));
ArrayList pkList = new ArrayList();
if ( itemCode != null && itemCode.length() > 0 )
{
pkKeyValMap.put("ITEM_CODE", itemCode);
pkList.add("ITEM_CODE");
}
if ( siteCode != null && siteCode.length() > 0 )
{
pkKeyValMap.put("SITE_CODE", siteCode);
pkList.add("SITE_CODE");
}
if ( locCode != null && locCode.length() > 0 )
{
pkKeyValMap.put("LOC_CODE", locCode);
pkList.add("LOC_CODE");
}
if ( lotNo != null && lotNo.length() > 0 )
{
pkKeyValMap.put("LOT_NO", lotNo);
pkList.add("LOT_NO");
}
if ( lotSl != null && lotSl.length() > 0 )
{
pkKeyValMap.put("LOT_SL", lotSl);
pkList.add("LOT_SL");
}
System.out.println("pkKeyValMap :"+pkKeyValMap);
String key = "";
for ( int i = 0; i < pkList.size(); i++ )
{
key = pkList.get(i).toString();
sb.append(key).append(" = ? and ");
}
String stockQuery = sb.toString();
stockQuery = stockQuery.substring(0,(stockQuery.length() - 4));
System.out.println("stockQuery :"+stockQuery);
sb = null;
PreparedStatement pstmtStock = null;
ResultSet rsStock = null;
pstmtStock = conn.prepareStatement(stockQuery);
for ( int i = 0; i < pkList.size(); i++ )
{
key = pkList.get(i).toString();
if ( pkKeyValMap.containsKey(key) )
{
System.out.println("Key =["+key+ "] and Value =["+pkKeyValMap.get(key)+"]");
pstmtStock.setString(i+1, pkKeyValMap.get(key).toString());
}
}
rsStock = pstmtStock.executeQuery();
while ( rsStock.next() )
{
tranIdTrace = generateTranId("w_inv_hold_rel_trace", conn);
itemCode = checkNull(rsStock.getString("ITEM_CODE"));
siteCode = checkNull(rsStock.getString("SITE_CODE"));
locCode = checkNull(rsStock.getString("LOC_CODE"));
lotNo = checkNull(rsStock.getString("LOT_NO"));
lotSl = checkNull(rsStock.getString("LOT_SL"));
stockQty = rsStock.getDouble("QUANTITY");
System.out.println("Quantity :" + stockQty );
holdQty = rsStock.getDouble("HOLD_QTY");
qtyPerArt = rsStock.getDouble("QTY_PER_ART");
if(holdQty < stockQty )
{
pUpdate.setDouble( 1, stockQty);
pUpdate.setString( 2, itemCode);
pUpdate.setString( 3, siteCode);
pUpdate.setString( 4, locCode);
pUpdate.setString( 5, lotNo);
pUpdate.setString( 6, lotSl);
pUpdate.executeUpdate();
pUpdate.clearParameters();
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
pstmtInsert = conn.prepareStatement(sqlInsert);
pstmtInsert.setString( 1, tranIdTrace);
pstmtInsert.setString( 2, itemCode );
pstmtInsert.setString( 3, siteCode );
pstmtInsert.setString( 4, locCode );
pstmtInsert.setString( 5, lotNo );
pstmtInsert.setString( 6, lotSl );
pstmtInsert.setString( 7, tranId );
pstmtInsert.setDouble( 8, stockQty );
pstmtInsert.setString( 9, lockCode );
pstmtInsert.executeUpdate();
pstmtInsert.clearParameters();
pstmtStock.clearParameters();
if( rs != null )
{
rs.close();
rs = null;
}
}
pkList = null;
if(rsStock != null)
{
rsStock.close();
rsStock = null;
}
}//end of while()
if( rsNoSl != null )
{
rsNoSl.close();
rsNoSl = null;
}
}//end of else
if( rs != null )
{
rs.close();
rs = null;
}
}//end of while()
pHoldDet.clearParameters();
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to commit unconfirmed transaction.end
}
if( errString == null || errString.length() == 0 )
{
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "update inv_hold set confirmed = 'Y', emp_code__aprv = '" + loginEmpCode + "', CONF_DATE = ? where tran_id = '" + tranId + "'";
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.executeUpdate();
*/
sql = "update inv_hold set confirmed = 'Y', emp_code__aprv = ? , CONF_DATE = ? where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginEmpCode);
pstmt.setTimestamp( 2, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(3,tranId);
pstmt.executeUpdate();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
pstmt.close();
pstmt = null;
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "update inv_hold_det set STATUS_DATE = ? where tran_id = '" + tranId.trim() + "'";
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.executeUpdate();
*/
sql = "update inv_hold_det set STATUS_DATE = ? where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(2,tranId);
pstmt.executeUpdate();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
pstmt.close();
pstmt = null;
}
if( errString != null && errString.length() > 0 )
{
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
else
{
if(conStatus)
{
conn.commit();
}
errString = itmDBAccessEJB.getErrorString("","VTCNFSUCC","");
System.out.println("Returnng String From InvHoldConfEJB : .." + errString);
}
System.out.println("errString : "+errString);
}catch(ITMException ie)
{
System.out.println("ITMException : "+ie);
try{
conn.rollback();
}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldConfEJB :"+errString);
return errString;
}catch(Exception e){
System.out.println("Returnng String From InvHoldConfEJB :"+e);
try{
conn.rollback();
}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldConfEJB :"+errString);
return errString;
}
finally
{
try{
if( pstmt != null )
{
pstmt.close();
}
pstmt = null;
if(conn != null && conStatus==true)
{
conn.close();
conn = null;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to close preparedStatements and to make null.start
if( pstmtInsert != null )
{
pstmtInsert.close();
pstmtInsert = null;
}
if(pHoldDet != null)
{
pHoldDet.close();
pHoldDet = null;
}
if(pSelStck != null)
{
pSelStck.close();
pSelStck = null;
}
if(pUpdate != null)
{
pUpdate.close();
pUpdate = null;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to close preparedStatements and to make null.end
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("InvHoldConfEJB :"+errString);
return errString;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to auto genrate Transacion Id for inv_hold_rel_trace.start
public String generateTranId(String windowName,Connection conn)throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
java.sql.Date effDate = null;
try
{
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
//System.out.println("selSql :"+selSql);
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
}
}
return tranId;
}//generateTranTd()
private String checkNull( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
return inputVal;
}
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to auto genrate Transacion Id for inv_hold_rel_trace.end
\ No newline at end of file
package ibase.webitm.ejb.dis.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 InvHoldConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis.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 InvHoldConfRemote extends ActionHandlerRemote//,EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis.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.servlet.RSItemChange;
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 InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLocal , InvHoldRelConfRemote //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.webitm.utility.GenericUtility genericUtility = null;
Document dom = null;
int count=0;
ITMDBAccessEJB itmDBAccessEJB = null;
String errString = null;
int upd = 0;
//changed by Dharmesh on 12-08-2011 [WM1ESUN004].start
String itemCode = null;
String siteCode = null;
String locCode = null;
String lotNo = null;
String lotSl = null;
String lineNoSl = null;
String tranIdTrace = null;
String tranIdHold = null;
//String lineNoHold = null;
double holdQtyStock = 0.0;
double qtyPerArt = 0.0;
double holdQtyTrace = 0.0;
double totalHoldStock = 0.0;
double relQtyTrace = 0.0;
double holdQty = 0.0;
double stockQty = 0.0;
double totalHoldTrace = 0.0;
double totalRelTrace = 0.0;
double balQtyHold = 0.0;
double qtyToHold = 0.0;
double relQty = 0.0;
int lineNoHold = 0;
String sqlUpdate = null;
String sqlHoldDet = null;
String sqlSelStck = null;
String sqlSelTrace = null;
String sqlInsert = null;
String sqlDetail = null;
String lockCode = null;
PreparedStatement pUpdate = null;
PreparedStatement pHoldDet = null;
PreparedStatement pSelStock = null;
PreparedStatement pSelTrace = null;
PreparedStatement pInsert = null;
PreparedStatement pDetail = null;
ResultSet rsHoldDet = null;
ResultSet rsSelStck = null;
ResultSet rsSelTrace = null;
ResultSet rsDetail = null;
//changed by Dharmesh on 12-08-2011 [WM1ESUN004].end
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
//check if there is record in detal
int countDet = 0;
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " select count( 1 ) cnt from inv_hold_rel_det where tran_id = '" + tranId.trim() + "' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from inv_hold_rel_det where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet == 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTNODET","","",conn);
}
if( errString == null || errString.length() == 0 )
{
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " select count( 1 ) cnt from inv_hold_rel where tran_id = '" + tranId.trim() + "' AND CONFIRMED = 'Y' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
sql = "select count( 1 ) cnt from inv_hold_rel where tran_id = ? AND CONFIRMED = 'Y'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet > 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTCONFMD","","",conn);
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to commit unconfirmed transaction.start
else
{
sqlUpdate = "UPDATE STOCK SET HOLD_QTY = ? WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pUpdate = conn.prepareStatement(sqlUpdate);
sqlSelStck = "SELECT ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, QTY_PER_ART, HOLD_QTY FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? " ;
pSelStock = conn.prepareStatement(sqlSelStck);
sqlSelTrace = "SELECT SUM( HOLD_QTY ) AS HOLD_QTY_TRACE, SUM( REL_QTY ) AS REL_QTY_TRACE FROM INV_HOLD_REL_TRACE WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? " ;
pSelTrace = conn.prepareStatement(sqlSelTrace);
sqlInsert = " INSERT INTO INV_HOLD_REL_TRACE ( TRAN_ID, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, REF_NO, REL_QTY, LOCK_CODE ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? ) " ;
pInsert = conn.prepareStatement(sqlInsert);
sqlHoldDet = "SELECT ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, LINE_NO_SL FROM INV_HOLD_DET WHERE TRAN_ID = ? AND LINE_NO = ?" ;
pHoldDet = conn.prepareStatement(sqlHoldDet);
sqlDetail = " SELECT HOLDDET.TRAN_ID__HOLD, HOLDDET.LINE_NO__HOLD, IHOLD.LOCK_CODE "+
" FROM INV_HOLD_REL_DET HOLDDET, INV_HOLD IHOLD "+
" WHERE HOLDDET.TRAN_ID__HOLD = IHOLD.TRAN_ID AND HOLDDET.TRAN_ID = ? ";
pDetail = conn.prepareStatement( sqlDetail );
pDetail.setString( 1,tranId );
rsDetail = pDetail.executeQuery();
pDetail.clearParameters();
while( rsDetail.next() )
{
tranIdHold = rsDetail.getString("TRAN_ID__HOLD");
lineNoHold = rsDetail.getInt("LINE_NO__HOLD");
lockCode = rsDetail.getString("LOCK_CODE");
pHoldDet.setString( 1,tranIdHold );
pHoldDet.setInt( 2,lineNoHold );
rsHoldDet = pHoldDet.executeQuery();
pHoldDet.clearParameters();
while( rsHoldDet.next() )
{
itemCode = checkNull(rsHoldDet.getString("ITEM_CODE"));
siteCode = checkNull(rsHoldDet.getString("SITE_CODE"));
locCode = checkNull(rsHoldDet.getString("LOC_CODE"));
lotNo = checkNull(rsHoldDet.getString("LOT_NO"));
lotSl = checkNull(rsHoldDet.getString("LOT_SL"));
lineNoSl = checkNull(rsHoldDet.getString("LINE_NO_SL"));
if( lineNoSl != null && lineNoSl.trim().length() > 0 ) //i.e. Line_sl is found
{
tranIdTrace = generateTranId("w_inv_hold_rel_trace", conn);
pSelStock.setString( 1, itemCode );
pSelStock.setString( 2, siteCode );
pSelStock.setString( 3, locCode );
pSelStock.setString( 4, lotNo );
pSelStock.setString( 5, lotSl );
rsSelStck = pSelStock.executeQuery();
pSelStock.clearParameters();
if( rsSelStck.next() )
{
qtyPerArt = rsSelStck.getDouble("QTY_PER_ART");
holdQtyStock = rsSelStck.getDouble("HOLD_QTY");
}
if( rsSelStck != null )
{
rsSelStck.close();
rsSelStck = null;
}
pSelTrace.setString( 1, itemCode );
pSelTrace.setString( 2, siteCode );
pSelTrace.setString( 3, locCode );
pSelTrace.setString( 4, lotNo );
pSelTrace.setString( 5, lotSl );
rsSelTrace = pSelTrace.executeQuery();
pSelTrace.clearParameters();
if( rsSelTrace.next() )
{
holdQtyTrace = rsSelTrace.getDouble("HOLD_QTY_TRACE");
relQtyTrace = rsSelTrace.getDouble("REL_QTY_TRACE");
}
if(rsSelTrace != null)
{
rsSelTrace.close();
rsSelTrace = null;
}
balQtyHold = holdQtyTrace - ( relQtyTrace + qtyPerArt );
if( balQtyHold == 0 )
{
pUpdate.setDouble( 1, balQtyHold);
pUpdate.setString( 2, itemCode);
pUpdate.setString( 3, siteCode);
pUpdate.setString( 4, locCode);
pUpdate.setString( 5, lotNo);
pUpdate.setString( 6, lotSl);
pUpdate.executeUpdate();
pUpdate.clearParameters();
}
else if ( balQtyHold < holdQtyStock )
{
balQtyHold = holdQtyStock - balQtyHold ;
pUpdate.setDouble( 1, balQtyHold);
pUpdate.setString( 2, itemCode);
pUpdate.setString( 3, siteCode);
pUpdate.setString( 4, locCode);
pUpdate.setString( 5, lotNo);
pUpdate.setString( 6, lotSl);
pUpdate.executeUpdate();
pUpdate.clearParameters();
}
pInsert.setString( 1, tranIdTrace);
pInsert.setString( 2, itemCode );
pInsert.setString( 3, siteCode );
pInsert.setString( 4, locCode );
pInsert.setString( 5, lotNo );
pInsert.setString( 6, lotSl );
pInsert.setString( 7, tranId );
pInsert.setDouble( 8, (-qtyPerArt) );
pInsert.setString( 9, lockCode );
pInsert.executeUpdate();
pInsert.clearParameters();
}//end of Line_sl present
else //i.e. line_sl is not found
{
HashMap pkKeyValMap = new HashMap();
StringBuffer sb = new StringBuffer("SELECT ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY, HOLD_QTY, QTY_PER_ART FROM STOCK WHERE ");
ArrayList pkList = new ArrayList();
if ( itemCode != null && itemCode.length() > 0 )
{
pkKeyValMap.put("ITEM_CODE", itemCode);
pkList.add("ITEM_CODE");
}
if ( siteCode != null && siteCode.length() > 0 )
{
pkKeyValMap.put("SITE_CODE", siteCode);
pkList.add("SITE_CODE");
}
if ( locCode != null && locCode.length() > 0 )
{
pkKeyValMap.put("LOC_CODE", locCode);
pkList.add("LOC_CODE");
}
if ( lotNo != null && lotNo.length() > 0 )
{
pkKeyValMap.put("LOT_NO", lotNo);
pkList.add("LOT_NO");
}
if ( lotSl != null && lotSl.length() > 0 )
{
pkKeyValMap.put("LOT_SL", lotSl);
pkList.add("LOT_SL");
}
System.out.println("pkKeyValMap :"+pkKeyValMap);
String key = "";
for ( int i = 0; i < pkList.size(); i++ )
{
key = pkList.get(i).toString();
sb.append(key).append(" = ? and ");
}
String stockQuery = sb.toString();
stockQuery = stockQuery.substring(0,(stockQuery.length() - 4));
System.out.println("stockQuery :"+stockQuery);
sb = null;
PreparedStatement pstmtStock = null;
ResultSet rsStock = null;
pstmtStock = conn.prepareStatement(stockQuery);
for ( int i = 0; i < pkList.size(); i++ )
{
key = pkList.get(i).toString();
if ( pkKeyValMap.containsKey(key) )
{
System.out.println("Key =["+key+ "] and Value =["+pkKeyValMap.get(key)+"]");
pstmtStock.setString(i+1, pkKeyValMap.get(key).toString());
}
}
/*
pSelTrace.setString( 1, itemCode );
pSelTrace.setString( 2, siteCode );
pSelTrace.setString( 3, locCode );
pSelTrace.setString( 4, lotNo );
pSelTrace.setString( 5, lotSl );
rsSelTrace = pSelTrace.executeQuery();
pSelTrace.clearParameters();
if(rsSelTrace.next())
{
holdQtyTrace = rsSelTrace.getDouble("HOLD_QTY_TRACE");
relQtyTrace = rsSelTrace.getDouble("REL_QTY_TRACE");
}
if( rsSelTrace != null)
{
rsSelTrace.close();
rsSelTrace = null;
}
*/
rsStock = pstmtStock.executeQuery();
pstmtStock.clearParameters();
while( rsStock.next() )
{
tranIdTrace = generateTranId("w_inv_hold_rel_trace", conn);
itemCode = checkNull(rsStock.getString("ITEM_CODE"));
siteCode = checkNull(rsStock.getString("SITE_CODE"));
locCode = checkNull(rsStock.getString("LOC_CODE"));
lotNo = checkNull(rsStock.getString("LOT_NO"));
lotSl = checkNull(rsStock.getString("LOT_SL"));
holdQtyStock = rsStock.getDouble("HOLD_QTY");
stockQty = rsStock.getDouble("QUANTITY");
System.out.println("Quantity :" + stockQty);
//Selecting sum(hold_qty) and sum(rel_qty) from trace table
pSelTrace.setString( 1, itemCode );
pSelTrace.setString( 2, siteCode );
pSelTrace.setString( 3, locCode );
pSelTrace.setString( 4, lotNo );
pSelTrace.setString( 5, lotSl );
rsSelTrace = pSelTrace.executeQuery();
pSelTrace.clearParameters();
if(rsSelTrace.next())
{
holdQtyTrace = rsSelTrace.getDouble("HOLD_QTY_TRACE");
relQtyTrace = rsSelTrace.getDouble("REL_QTY_TRACE");
}
rsSelTrace.close();
rsSelTrace = null;
//qtyToHold = totalHoldTrace - (totalRelTrace + relQtyTrace) ;
balQtyHold = holdQtyTrace - ( relQtyTrace + holdQtyStock ) ;
if( balQtyHold == 0 )
{
//holdQtyStock = holdQtyStock - relQtyTrace ;
pUpdate.setDouble( 1, balQtyHold );
pUpdate.setString( 2, itemCode);
pUpdate.setString( 3, siteCode);
pUpdate.setString( 4, locCode);
pUpdate.setString( 5, lotNo);
pUpdate.setString( 6, lotSl);
pUpdate.executeUpdate();
pUpdate.clearParameters();
}
else if ( balQtyHold < holdQtyStock )
{
balQtyHold = holdQtyStock - balQtyHold;
pUpdate.setDouble( 1, balQtyHold );
pUpdate.setString( 2, itemCode);
pUpdate.setString( 3, siteCode);
pUpdate.setString( 4, locCode);
pUpdate.setString( 5, lotNo);
pUpdate.setString( 6, lotSl);
pUpdate.executeUpdate();
pUpdate.clearParameters();
}
pInsert.setString( 1, tranIdTrace );
pInsert.setString( 2, itemCode );
pInsert.setString( 3, siteCode );
pInsert.setString( 4, locCode );
pInsert.setString( 5, lotNo );
pInsert.setString( 6, lotSl );
pInsert.setString( 7, tranId );
pInsert.setDouble( 8, (-holdQtyStock) );
pInsert.setString( 9, lockCode );
pInsert.executeUpdate();
pInsert.clearParameters();
}
pkList = null;
if(rsStock != null)
{
rsStock.close();
rsStock = null;
}
}//end of else
pHoldDet.clearParameters();
}//end of outer while()
if(rsHoldDet != null)
{
rsHoldDet.close();
rsHoldDet = null;
}
}//while( rsDetail.next() )
if(rsDetail != null)
{
rsDetail.close();
rsDetail = null;
}
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to commit unconfirmed transaction.end
}
//
if( errString == null || errString.length() == 0 )
{
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = "update inv_hold_rel set confirmed = 'Y', emp_code__aprv = '" + loginEmpCode + "', CONF_DATE = ? where tran_id = '" + tranId + "'";
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.executeUpdate();
*/
sql = "update inv_hold_rel set confirmed = 'Y', emp_code__aprv = ? , CONF_DATE = ? where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginEmpCode);
pstmt.setTimestamp( 2 , new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(3,tranId);
pstmt.executeUpdate();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
pstmt.close();
pstmt = null;
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " update inv_hold_det hd set "
+" hd.hold_status = 'R', "
+" hd.STATUS_DATE = ? "
+" where (hd.tran_id, hd.line_no ) "
+" in ( select rd.tran_id__hold, rd.line_no__hold "
+" from inv_hold_rel_det rd "
+" where tran_id = '" + tranId + "' ) ";
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.executeUpdate();
*/
sql = " update inv_hold_det hd set "
+" hd.hold_status = 'R', "
+" hd.STATUS_DATE = ? "
+" where (hd.tran_id, hd.line_no ) "
+" in ( select rd.tran_id__hold, rd.line_no__hold "
+" from inv_hold_rel_det rd "
+" where tran_id = ? )";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp( 1 , new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(2,tranId);
pstmt.executeUpdate();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
pstmt.close();
pstmt = null;
}
if( errString != null && errString.length() > 0 )
{
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
else
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTCNFSUCC","");
System.out.println("Returnng String From InvHoldRelConfEJB : .." + errString);
}
System.out.println("errString : "+errString);
}catch(ITMException ie)
{
System.out.println("ITMException : "+ie);
try{
conn.rollback();
}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldRelConfEJB :"+errString);
return errString;
}catch(Exception e){
System.out.println("Returnng String From InvHoldRelConfEJB :"+e);
try{
conn.rollback();
}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldRelConfEJB :"+errString);
return errString;
}
finally
{
try{
if( pstmt != null )
{
pstmt.close();
}
pstmt = null;
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to close preparedStatements and to make null.start
if( pInsert != null )
{
pInsert.close();
pInsert = null;
}
if(pHoldDet != null)
{
pHoldDet.close();
pHoldDet = null;
}
if(pSelStock != null)
{
pSelStock.close();
pSelStock = null;
}
if(pUpdate != null)
{
pUpdate.close();
pUpdate = null;
}
if(pDetail != null)
{
pDetail.close();
pDetail = null;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to close preparedStatements and to make null.end
if(conn != null)
{
conn.close();
}
conn = null;
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("InvHoldRelConfEJB :"+errString);
return errString;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to auto genrate Transacion Id for inv_hold_rel_trace.start
public String generateTranId(String windowName,Connection conn)throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
java.sql.Date effDate = null;
try
{
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
}
}
return tranId;
}//generateTranTd()
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to auto genrate Transacion Id for inv_hold_rel_trace.end
private String checkNull( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
return inputVal;
}
}
package ibase.webitm.ejb.dis.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 InvHoldRelConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis.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 InvHoldRelConfRemote extends ActionHandlerRemote//,EJBObject
{
public String confirm(String xmlString, 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