Commit f8f19c18 authored by manohar's avatar manohar

New components for lot status transaction (edit 864 loading) - ASN related reference removed


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94554 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 80571c4e
/**
* Author : Chaitali Parab
* Date :
*
* */
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
@javax.ejb.Stateless
public class LotStatIC extends ValidatorEJB implements LotStatICLocal, LotStatICRemote
{
/**
* The method defined with no paramter and returns nothing
*/
public String wfValData() throws RemoteException, ITMException
{
return "";
}
/**
* The public method is used for validation of required fields which inturn called overloded method
* Returns validation string in XML format if exist otherwise returns null
* @param xmlString contains the current form data in XML format
* @param xmlString1 contains always header form data in XML format
* @param xmlString2 contains all forms data in XML format
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginCode etc
*/
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;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
if( xmlString != null && xmlString.trim().length()!=0 )
{
dom = genericUtility.parseString(xmlString);
}
if( xmlString1 != null && xmlString1.trim().length()!=0 )
{
dom1 = genericUtility.parseString(xmlString1);
}
if( xmlString2 != null && xmlString2.trim().length()!=0 )
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = wfValData( dom, dom1, dom2, objContext, editFlag, xtraParams );
System.out.println ( "ErrString: " + errString);
}
catch(Exception e)
{
System.out.println ( "Exception: AsnLotStatIC: wfValData(String xmlString): " + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println ( "Returning from AsnLotStatIC wfValData" );
return ( errString );
}
/**
* The public overloded method is used for validation of required fields
* Returns validation string if exist otherwise returns null in XML format
* @param dom contains the current form data
* @param dom1 contains always header form data
* @param dom2 contains all forms data
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contais additional information such as loginEmpCode,loginCode,chgTerm etc
*/
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String columnValue = "";
String errString = "";
int currentFormNo = 0;
int count = 0;
String columnName = "";
String sql = "";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pStmt = null;
GenericUtility genericUtility = GenericUtility.getInstance();
StringBuffer valueXmlString = new StringBuffer();
String itemCode = "", lotNo = "", lockCode = "";
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String errorType = "", errCode = "";
ArrayList errList = new ArrayList();
ArrayList errFields = new ArrayList();
try
{
SimpleDateFormat sdft = new SimpleDateFormat( genericUtility.getApplDateFormat() );
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
int noOfChilds = 0;
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
if ( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
switch( currentFormNo )
{
case 1 :
{
parentList = dom.getElementsByTagName( "Detail" + currentFormNo );
for ( int pctr = 0; pctr < parentList.getLength(); pctr++ )
{
parentNode = parentList.item( pctr);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
for ( int ctr = 0; ctr < childList.getLength(); ctr++ )
{
childNode = childList.item(ctr);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
String childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
columnName = childNode.getNodeName();
if( "site_code".equalsIgnoreCase(columnName) )
{
//checking for blank value
if ( childNode == null || childNode.getFirstChild() == null )
{
errList.add( "VTSITEEMT" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
sql = "select count(*) from site where site_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();rs = null;
pStmt.close();pStmt = null;
if( count == 0 )
{
errList.add( "VTSITE123" );
errFields.add( childNodeName.toLowerCase() );
}
//VTSITE123
}
}
/*
else if( "emp_code__aprv".equalsIgnoreCase(columnName) )
{
if ( childNode == null || childNode.getFirstChild() == null )
{
//errString = getErrorString(columnName ,"VTEMPNULL",userId);
//break;
}
else
{
sql = "select count(*) from employee where emp_code =? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();rs = null;
pStmt.close();pStmt = null;
if( count == 0 )
{
errString = getErrorString(columnName ,"VMEMPCD1",userId);
break;
}
}
}
*/
}
}
}//end of case 1
break;
case 2 :
{
parentList = dom.getElementsByTagName( "Detail" + currentFormNo );
for ( int pctr = 0; pctr < parentList.getLength(); pctr++ )
{
parentNode = parentList.item( pctr);
childList = parentNode.getChildNodes();
noOfChilds = childList.getLength();
for ( int ctr = 0; ctr < childList.getLength(); ctr++ )
{
childNode = childList.item(ctr);
if( childNode.getNodeType() != Node.ELEMENT_NODE )
{
continue;
}
String childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
columnName = childNode.getNodeName();
if("item_code".equalsIgnoreCase(columnName))
{
if ( childNode == null || childNode.getFirstChild() == null )
{
errList.add( "VTITMNUL" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
sql = "select count(*) from item where item_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
if( count == 0 )
{
errList.add( "VTITEMCD1" );
errFields.add( childNodeName.toLowerCase() );
}
rs.close();rs = null;
pStmt.close();pStmt = null;
/*
count = 0;
lotNo = genericUtility.getColumnValue( "lot_no", dom );
sql = "select count(*) from asn_det where item_code= ? and lot_no = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
pStmt.setString(2, lotNo);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
if( count == 0 )
{
errList.add( "VTASNITEM" );
errFields.add( childNodeName.toLowerCase() );
}
rs.close();rs = null;
pStmt.close();pStmt = null;
*/
}
}
if("lock_code".equalsIgnoreCase(columnName)) // 10/04/14 manoharan added validation for loc_code
{
if ( childNode == null || childNode.getFirstChild() == null )
{
errList.add( "NULLLOCKCD" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
sql = "select count(*) from inv_lock where lock_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
if( count == 0 )
{
errList.add( "INVLOCKCD" );
errFields.add( childNodeName.toLowerCase() );
}
rs.close();rs = null;
pStmt.close();pStmt = null;
}
}
else if("lot_no".equalsIgnoreCase(columnName))
{
if ( childNode == null || childNode.getFirstChild() == null )
{
errList.add( "VTNULLLOT" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
itemCode = genericUtility.getColumnValue( "item_code", dom );
lotNo = genericUtility.getColumnValue( "lot_no", dom );
lockCode = genericUtility.getColumnValue( "lock_code", dom );
sql = "select count(*) from inv_hold h, inv_hold_det d "
+ " where h.tran_id = d.tran_id and h.confirmed = 'Y' and h.lock_code = ? and d.item_code = ? and d.lot_no = ? and d.hold_status = 'H'";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, lockCode);
pStmt.setString(2, itemCode);
pStmt.setString(3, lotNo);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
if (count == 0)
{
errList.add( "VTHOLDLOT" );
errFields.add( childNodeName.toLowerCase() );
}
/*
sql = "select count(*) from stock where lot_no = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
if( count == 0 )
{
errString = getErrorString(columnName ,"VTLOTASN",userId);
break;
}
rs.close();rs = null;
pStmt.close();pStmt = null;
count = 0;
itemCode = genericUtility.getColumnValue( "item_code", dom );
sql = "select count(*) from asn_det where item_code = ? and lot_no=? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, itemCode);
pStmt.setString(2, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();rs = null;
pStmt.close();pStmt = null;
if( count == 0 )
{
errList.add( "VTLOTASN1" );
errFields.add( childNodeName.toLowerCase() );
}
*/
}
}
}
}
}//end of case 2
break;
}//end of switch
int errListSize = errList.size();
int cnt =0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = (String)errList.get(cnt);
errFldName = (String)errFields.get(cnt);
System.out.println("errCode .........."+errCode);
errString = getErrorString( errFldName, errCode, userId );
errorType = errorType( conn , errCode );
if ( errString.length() > 0)
{
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString =bifurErrString;//+"<trace>"+errMsg+"</trace>";
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
errString = errStringXml.toString();
}//end of try block
catch( Exception e )
{
throw new ITMException(e);
}//end of catch block
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pStmt != null && !pStmt.isClosed() )
{
pStmt.close();
pStmt = null;
}
if( conn != null && !conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch( Exception e )
{
System.out.println( "Exception :AsnLotStatIC:wfValData :==>\n"+e.getMessage());
throw new ITMException(e);
}
}//end of finally block
return ( errString );
}//
/**
* The method defined with no paramter and returns nothing
*/
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
/**
* The public method is used for itemchange of required fields which inturn called overloded method
* Returns itemchange string in XML format
* @param xmlString contains the current form data in XML format
* @param xmlString1 contains always header form data in XML format
* @param xmlString2 contains all forms data in XML format
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginEmpCode,loginCode,chgTerm etc
*/
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 errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if ( xmlString != null && xmlString.trim().length()!=0 )
{
dom = genericUtility.parseString(xmlString);
}
if ( xmlString1 != null && xmlString1.trim().length()!=0 )
{
dom1 = genericUtility.parseString(xmlString1);
}
if ( xmlString2 != null && xmlString2.trim().length()!=0 )
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
System.out.println ( "ErrString :" + errString);
}
catch ( Exception e )
{
System.out.println ( "Exception :itemChanged(String,String):" + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
}
System.out.println ( "returning from AsnLotStatIC itemChanged" );
return (errString);
}
/**
* The public overloded method is used for itemchange of required fields
* Returns itemchange string in XML format
* @param dom contains the current form data
* @param dom1 contains always header form data
* @param dom2 contains all forms data
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginCode etc
*/
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
String sql = "";
String columnValue = "";
String siteCode = "";
String siteDescr = "";
String empCodeAprv = "";
String firstName = "";
String middleName = "";
String lastName = "";
String itemDescr = "";
String lotNo = "";
String itemCode= "";
String holdStatus = "";
String loginSiteCode = "";
Date currentDate = null;
SimpleDateFormat sdf = null;
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
columnValue = genericUtility.getColumnValue( currentColumn, dom );
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverValidator");
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
switch( currentFormNo )
{
case 1:
{
valueXmlString.append( "<Detail1>\r\n" );
if("itm_default".equalsIgnoreCase(currentColumn))
{
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
sql = "select descr from site where site_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, loginSiteCode);
rs = pStmt.executeQuery();
if( rs.next() )
{
siteDescr = checkNull(rs.getString("descr"));
}
currentDate = new Date();
valueXmlString.append( "<tran_date><![CDATA[" ).append(sdf.format(currentDate).toString()).append( "]]></tran_date>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append(loginSiteCode).append( "]]></site_code >\r\n" );
valueXmlString.append( "<site_descr><![CDATA[" ).append(siteDescr).append( "]]></site_descr>\r\n" );
//added on 23 nov 2011
}
else if( "site_code".equalsIgnoreCase(currentColumn) )
{
sql = "select descr from site where site_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
siteDescr = checkNull(rs.getString("descr"));
}
valueXmlString.append( "<site_descr><![CDATA[" ).append(siteDescr).append( "]]></site_descr>\r\n" );
}
else if( "emp_code__aprv".equalsIgnoreCase(currentColumn))
{
sql = "select emp_fname, emp_mname, emp_lname from employee where emp_code= ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
firstName = checkNull(rs.getString("emp_fname"));
middleName = checkNull(rs.getString("emp_mname"));
lastName = checkNull(rs.getString("emp_lname"));
}
valueXmlString.append( "<emp_name><![CDATA[" ).append(firstName.trim()+" "+middleName.trim()+" "+lastName.trim()).append( "]]></emp_name>\r\n" );
}
valueXmlString.append( "</Detail1>\r\n" );
}//end of case 1
break;
case 2 :
{
valueXmlString.append( "<Detail2>\r\n" );
if("item_code".equalsIgnoreCase(currentColumn) )
{
sql = "select descr from item where item_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
itemDescr = checkNull(rs.getString("descr"));
}
valueXmlString.append( "<item_descr><![CDATA[" ).append(itemDescr).append( "]]></item_descr>\r\n" );
}
valueXmlString.append( "</Detail2>\r\n" );
}//end of case 2
break;
}//end of switch
}//end of try block
catch( Exception e )
{
throw new ITMException(e);
}
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pStmt != null && !pStmt.isClosed() )
{
pStmt.close();
pStmt = null;
}
if( conn != null && !conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch( Exception e )
{
System.out.println( "Exception :AsnLotStatIC:itemChanged :==>\n"+e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append( "</Root>\r\n" );
return valueXmlString.toString();
}//end of itemchange
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
private String errorType( Connection conn , String errorCode )
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
}
}
return msgType;
}
}
/**
* Author : Chaitali Parab
* Date : 25/08/2011
*
* */
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Local
public interface LotStatICLocal extends ValidatorLocal
{
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
/**
* Author : Chaitali Parab
* Date : 25/08/2011
*
* */
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
@javax.ejb.Remote
public interface LotStatICRemote extends ValidatorRemote
{
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;
}
/**
* Author : Chaitali Parab
* Date :
*
* */
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
//Changed by Rohan on 24-07-13 for importing adv packages
import ibase.webitm.ejb.dis.adv.*;
@javax.ejb.Stateless
public class LotStatPos extends ValidatorEJB implements LotStatPosLocal, LotStatPosRemote
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave( String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
String errMsg = "";
String tranIdRel = "";
String lineNoRel = "";
String itemCode = "";
String lotNo = "";
String sql = "";
String invHoldRelSql = "";
String invHoldRelDetSql = "";
String siteCode = "";
String confirmed = "";
String empCode = "";
String remark = "";
String itemCodeDet = "";
String lotNoDet = "";
String lineNo = "";
String tranIdGenerate = "";
boolean flag = false;
//Change by Rohan on 25-07-13 for define variable.start
boolean isHoldHdr = false;
String invholdSql = "";
String invholddetSql = "";
String tranIdHold = "";
String lockCodeRej = "";
String locCode = "";
String lotSl = "";
int lineNoHoldCtr = 0;
PreparedStatement pstmtHdr = null;
PreparedStatement pstmtDet = null;
ResultSet rsHdr = null;
ResultSet rsDet = null;
DistCommon discommon = new DistCommon();
//Change by Rohan on 25-07-13 for define variable.end
int count = 0;
int updCnt = 0;
int ctr = 0;
int lineNoCtr = 0;
java.sql.Timestamp chgDate = null,currDate = null;
Date date = null;
String chgTerm = "";
String userId = "";
String lotStatus = "";
String lockCode = "";
Document dom = null;
PreparedStatement pStmt = null;
PreparedStatement pRelHdr = null;
PreparedStatement pRelDet = null;
ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
HashMap tempMap = null;
//changed by sankara on 16/09/13 for displaying error message.
boolean dataFlag = false;
try
{
dom = genericUtility.parseString(domString);
// 10/04/14 manoharan check whether lock exists
boolean invHoldExists = true;
int length = dom.getElementsByTagName( "Detail2").getLength();
for ( int pctr = 0; pctr < length; pctr++ )
{
count = 0;
itemCodeDet = GenericUtility.getInstance().getColumnValueFromNode("item_code", dom.getElementsByTagName("Detail2").item(pctr));
lotNoDet = GenericUtility.getInstance().getColumnValueFromNode("lot_no", dom.getElementsByTagName("Detail2").item(pctr));
lockCode = GenericUtility.getInstance().getColumnValueFromNode("lock_code", dom.getElementsByTagName("Detail2").item(pctr));
sql = "select count(*) from inv_hold h, inv_hold_det d "
+ " where h.tran_id = d.tran_id and h.confirmed = 'Y' and h.lock_code = ? and d.item_code = ? and d.lot_no = ? and d.hold_status = 'H'";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, lockCode);
pStmt.setString(2, itemCodeDet);
pStmt.setString(3, lotNoDet);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
if (count == 0)
{
invHoldExists = false;
break;
}
}
if (!invHoldExists)
{
errMsg = itmDBAccessLocal.getErrorString("","VTNODATAFD","");
return errMsg;
}
invHoldRelSql = "INSERT INTO INV_HOLD_REL(TRAN_ID, TRAN_DATE, SITE_CODE, REMARKS, CONFIRMED, EMP_CODE__APRV,CHG_USER ,CHG_DATE, CHG_TERM) VALUES(?,?,?,?,?,?,?,?,?)";
pRelHdr = conn.prepareStatement(invHoldRelSql);
invHoldRelDetSql = "INSERT INTO INV_HOLD_REL_DET(TRAN_ID, LINE_NO, TRAN_ID__HOLD, LINE_NO__HOLD, REMARKS) VALUES(?,?,?,?,?)";
pRelDet = conn.prepareStatement(invHoldRelDetSql);
currDate = new java.sql.Timestamp(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
siteCode = GenericUtility.getInstance().getColumnValueFromNode("site_code", dom.getElementsByTagName("Detail1").item(0));
confirmed = "N";
empCode = "";
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
String currDateStr = sdfAppl.format(currDate);
tranIdGenerate = generateTranId( "w_inv_hold_rel", siteCode, currDateStr, conn );
pRelHdr.setString( 1, tranIdGenerate );
pRelHdr.setTimestamp( 2, currDate );
pRelHdr.setString( 3, siteCode );
pRelHdr.setString( 4, " " );
pRelHdr.setString( 5, confirmed );
pRelHdr.setString( 6, empCode );
pRelHdr.setString( 7, userId );
pRelHdr.setTimestamp( 8, currDate );
pRelHdr.setString( 9, chgTerm );
updCnt = pRelHdr.executeUpdate();
pRelHdr.clearParameters();
if( updCnt > 0 )
{
System.out.println( updCnt + " rows updated successfully" );
}
//Chnaged by Rohan on 25-07-13 for if lot staus 'R' then aquried new lock configured in disparam.start
invholdSql = "INSERT INTO INV_HOLD(TRAN_ID,TRAN_DATE,SITE_CODE,CONFIRMED,REF_ID,REF_SER,CHG_USER,CHG_DATE,CHG_TERM, LOCK_CODE,REF_NO) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
pstmtHdr = conn.prepareStatement(invholdSql);
invholddetSql = "INSERT INTO INV_HOLD_DET(TRAN_ID,LINE_NO,ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL,HOLD_STATUS,SCH_REL_DATE) VALUES(?,?,?,?,?,?,?,?,?)";
pstmtDet = conn.prepareStatement(invholddetSql);
lockCodeRej = discommon.getDisparams("999999","REJECTION_LOCKCODE",conn);
//Chnaged by Rohan on 25-07-13 for if lot staus 'R' then aquried new lock configured in disparam.end
length = dom.getElementsByTagName( "Detail2").getLength();
for ( int pctr = 0; pctr < length; pctr++ )
{
lotStatus = GenericUtility.getInstance().getColumnValueFromNode("lot_status", dom.getElementsByTagName("Detail2").item(pctr));
//Changed by Rohan on 24-07-13 for release lot staus 'R'
//if(lotStatus.equalsIgnoreCase("A"))
if((!"".equalsIgnoreCase(lotStatus) && lotStatus != null))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no", dom.getElementsByTagName("Detail2").item(pctr));
itemCodeDet = GenericUtility.getInstance().getColumnValueFromNode("item_code", dom.getElementsByTagName("Detail2").item(pctr));
lotNoDet = GenericUtility.getInstance().getColumnValueFromNode("lot_no", dom.getElementsByTagName("Detail2").item(pctr));
lockCode = GenericUtility.getInstance().getColumnValueFromNode("lock_code", dom.getElementsByTagName("Detail2").item(pctr));
/*
sql = "select count(*) from asn_det where item_code = ? and lot_no = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, itemCodeDet);
pStmt.setString(2, lotNoDet);
rs = pStmt.executeQuery();
if( rs.next() )
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
if(count != 0)
{
*/
ctr++;
//flag = true;
//Chnaged by Rohan on 25-07-13 for if lot staus 'R' then aquried new lock configured in disparam.start
if((!"".equalsIgnoreCase(lotStatus) && lotStatus != null) && !lotStatus.equalsIgnoreCase("A") && !isHoldHdr)
{
tranIdHold = generateTranId( "w_inv_hold", siteCode, currDateStr, conn );
System.out.println("tranIdHold"+tranIdHold);
pstmtHdr.setString( 1, tranIdHold );
pstmtHdr.setTimestamp( 2, currDate);
pstmtHdr.setString( 3, siteCode );
pstmtHdr.setString( 4, "N" );
pstmtHdr.setString( 5, tranIdGenerate );
pstmtHdr.setString( 6, "P-RCP");
pstmtHdr.setString( 7, userId );
pstmtHdr.setTimestamp( 8, currDate );
pstmtHdr.setString( 9, chgTerm );
pstmtHdr.setString( 10, lockCodeRej );
pstmtHdr.setString( 11, tranId );
updCnt = pstmtHdr.executeUpdate();
pstmtHdr.clearParameters();
if( updCnt > 0 )
{
isHoldHdr = true;
System.out.println( updCnt + " rows updated successfully" );
}
}
//Chnaged by Rohan on 25-07-13 for if lot staus 'R' then aquried new lock configured in disparam.end
//CHanged by Rohan on 26-07-13 for getting loc code and lot sl.
//sql = "select ih.tran_id, ih.line_no from inv_hold h, inv_hold_det ih"
sql = "select ih.tran_id, ih.line_no,ih.loc_code,ih.lot_sl from inv_hold h, inv_hold_det ih"
+" where h.tran_id = ih.tran_id "
+" and h.lock_code = ?"
+" and ih.item_code = ?"
+" and ih.lot_no = ?"
+" and ih.hold_status = 'H'";
//+" and h.ref_id in ("
//+" select p.tran_id from porcp p where p.asn_no in ("
//+" select ah.asn_no from asn_hdr ah where ah.tran_id in ("
//+" select tran_id from asn_det ad where ad.item_code = ? and ad.lot_no = ? )"
//+" ) )
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, lockCode);
pStmt.setString(2, itemCodeDet);
pStmt.setString(3, lotNoDet);
//pStmt.setString(4, itemCodeDet);
//pStmt.setString(5, lotNoDet);
rs = pStmt.executeQuery();
if( rs.next() )
{
//changed by sankara on 16/09/13 for displaying error message.
dataFlag = true;
lineNoCtr++;
tranIdRel = rs.getString("tran_id");
lineNoRel = rs.getString("line_no");
pRelDet.setString( 1, tranIdGenerate );
pRelDet.setInt( 2,lineNoCtr);
pRelDet.setString( 3, tranIdRel );
pRelDet.setString( 4, lineNoRel );
pRelDet.setString( 5, remark );
pRelDet.addBatch();
pRelDet.clearParameters();
//Chnaged by Rohan on 25-07-13 for if lot staus 'R' then aquried new lock configured in disparam.start
if((!"".equalsIgnoreCase(lotStatus) && lotStatus != null) && !lotStatus.equalsIgnoreCase("A"))
{
lineNoHoldCtr++;
locCode = checkNull(rs.getString("loc_code"));
lotSl = checkNull(rs.getString("lot_sl"));
pstmtDet.setString( 1, tranIdHold );
pstmtDet.setInt( 2, lineNoHoldCtr );
pstmtDet.setString( 3, itemCodeDet );
pstmtDet.setString( 4, siteCode );
pstmtDet.setString( 5, locCode );
pstmtDet.setString( 6, lotNoDet );
pstmtDet.setString( 7, lotSl );
pstmtDet.setString( 8, "H" );
pstmtDet.setTimestamp( 9, currDate );
pstmtDet.addBatch();
pstmtDet.clearParameters();
}
//Chnaged by Rohan on 25-07-13 for if lot staus 'R' then aquried new lock configured in disparam.end
}
//changed by sankara on 16/09/13 for displaying error message start.
if( dataFlag == false )
{
errMsg = itmDBAccessLocal.getErrorString("","VTNODATAFD","");
return errMsg;
}
//changed by sankara on 16/09/13 for displaying error message end.
rs.close();
rs = null;
pStmt.close();
pStmt = null;
//updCnt = pRelDet.executeUpdate();
if( updCnt > 0 )
{
System.out.println( updCnt + " rows updated successfully" );
}
//} // asn_det checking
}//lotStatus = 'A'
}//for pctr
pRelDet.executeBatch();
pRelDet.clearBatch();
//Changed by Rohan on 26-07-13 for execute batch .strat
pstmtDet.executeBatch();
pstmtDet.clearBatch();
if(pstmtDet != null)
{
pstmtDet.close();
pstmtDet = null;
}
if(pstmtHdr != null)
{
pstmtHdr.close();
pstmtHdr = null;
}
//Changed by Rohan on 26-07-13 for execute batch .end
//if(flag == true)
if(length == ctr)
{
//Chaged by Rohan on 24-07-13 for releasing stock.start
System.out.println("888888888888 GOing for release old lock 888888888888888888888888");
InvHoldRelConf InvHoldRelConf = new InvHoldRelConf();
//confirm(tranIdRel,xtraParams,"F", conn, false);
errMsg = InvHoldRelConf.confirm( tranIdGenerate,xtraParams,"F",conn,false);
if ( errMsg == null && errMsg.trim().length() <= 0 )
{
errMsg = itmDBAccessLocal.getErrorString("","VTPRCERR","");
return errMsg;
}
//Changed by Rohan on 24-07-13 for release lot staus 'R' and then put REJECTION_LOCKCODE.start
if((!"".equalsIgnoreCase(lotStatus) && lotStatus != null) && !lotStatus.equalsIgnoreCase("A"))
{
System.out.println("888888888888 GOing for aqurie new lock 888888888888888888888888");
//update stock hold qty.start
sql = "UPDATE STOCK SET HOLD_QTY = QUANTITY WHERE ITEM_CODE = ? AND SITE_CODE = ? "
+" AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString( 1, itemCodeDet );
pStmt.setString( 2, siteCode );
pStmt.setString( 3, locCode );
pStmt.setString( 4, lotNoDet );
pStmt.setString( 5, lotSl );
int rowcnt = pStmt.executeUpdate();
if(rowcnt == 0)
{
errMsg = itmDBAccessLocal.getErrorString("","VTPRCERR","");
return errMsg;
}
else
{
System.out.println("**************stk hold succefuly ****************");
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
//update stock hold qty.end
InvHoldConf invHoldConf = new InvHoldConf();
errMsg = invHoldConf.confirm(tranIdHold,xtraParams, "F" ,conn,false);
if ( errMsg == null && errMsg.trim().length() <= 0 )
{
errMsg = itmDBAccessLocal.getErrorString("","VTPRCERR","");
return errMsg;
}
}
//Changed by Rohan on 24-07-13 for release lot staus not 'R' and then put REJECTION_LOCKCODE.end
//Chaged by Rohan on 24-07-13 for releasing stock.end
sql = "update lot_stat_hdr set confirmed = 'Y', conf_date = ? where tran_id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setTimestamp(1,currDate);
pStmt.setString(2,tranId);
int rowcnt = pStmt.executeUpdate();
if(rowcnt == 0)
{
errMsg = itmDBAccessLocal.getErrorString("","VTPRCERR","");
return errMsg;
}
}
}
catch(BatchUpdateException buex)
{
try
{
conn.rollback();
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)
{
e.printStackTrace();
}
throw new ITMException(buex);
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(pRelDet != null)
{
pRelDet.close();
pRelDet = null;
}
if(pRelHdr != null)
{
pRelHdr.close();
pRelHdr = null;
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
//Chnaged by Rohan on 24-07-13 for commiting connection.start
if(pstmtDet != null)
{
pstmtDet.close();
pstmtDet = null;
}
if(pstmtHdr != null)
{
pstmtHdr.close();
pstmtHdr = null;
}
if ( errMsg != null && errMsg.trim().length() > 0 && errMsg.indexOf("success") != -1 )
{
conn.commit();
errMsg = "";
}
else
{
conn.rollback();
}
//Chnaged by Rohan on 24-07-13 for commiting connection.start
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
return errMsg;
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
private String generateTranId( String windowName, String siteCode, String tranDateStr, 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 + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + tranDateStr + "</tran_date>";
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()
}
\ No newline at end of file
/**
* Author : Chaitali Parab
* Date : 25/08/2011
*
* */
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
import javax.ejb.EJBObject;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Local
public interface LotStatPosLocal extends ValidatorLocal
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
/**
* Author : Chaitali Parab
* Date : 25/08/2011
*
* */
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
@javax.ejb.Remote
public interface LotStatPosRemote extends ValidatorRemote
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment