Commit 4710647b authored by ppatro's avatar ppatro

changed by sankara on 11/12/13 invoiceamendmentic and stocktransferconf source in dis or disadv


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93991 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b44139e1
/********************************************************
Title : InvoiceAmendmentIC
Date : 01/06/2012
Developer: Mahesh Patidar
********************************************************/
package ibase.webitm.ejb.wms;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@javax.ejb.Stateless
public class InvoiceAmendmentIC extends ValidatorEJB implements InvoiceAmendmentICLocal,InvoiceAmendmentICRemote
{
public String wfValData() 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;
GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("WFVALDATA 111111");
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: InvoiceAmendmentIC: wfValData(String xmlString): " + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
System.out.println ( "Returning from InvoiceAmendmentIC wfValData" );
return ( errString );
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext,String editFlag, String xtraParams ) throws RemoteException, ITMException
{
String errString = "";
String siteCode1 = "";
String siteCode = "";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
GenericUtility genericUtility = GenericUtility.getInstance();
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
String errorType = "", errCode = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
NodeList parentList = null;
NodeList childList = null;
int noOfChilds ;
String childNodeName = "";
Node childNode =null;
String userId = "";
int cnt = 0;
String columnValue = "";
String columnValue1 = "";
String confirmed = "";
String sql = "";
Timestamp date1 = null;
Timestamp date2 = null;
int currentFormNo = 0;
ConnDriver connDriver = null;
try
{
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
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 );
childList = parentList.item( 0 ).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item( ctr );
childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if ( childNodeName.equalsIgnoreCase("invoice_id") )
{
columnValue = genericUtility.getColumnValue("invoice_id", dom);
columnValue1 = genericUtility.getColumnValue("status", dom);
System.out.println("iNSIDE INVOICE ID["+columnValue+"]");
if(columnValue != null && columnValue.trim().length() > 0)
{
sql = "select confirmed from invoice where invoice_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
confirmed = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(! confirmed.trim().equals("Y"))
{
errList.add( "VMINVCD1" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
sql = "select count(*) from invoice_amendment where invoice_id = ? and status = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
pstmt.setString(2, columnValue1);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
confirmed = "";
sql = "select (case when a.confirmed is null then 'N' else a.confirmed end) " +
" from receipt a, rcpdet b where a.tran_id = b.tran_id and b.ref_ser = 'S-INV' and b.ref_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
confirmed = rs.getString(1);
}
if(confirmed.trim().equals("Y"))
{
errList.add( "VTRCPCON" );
errFields.add( childNodeName.toLowerCase() );
}
if(errList == null || errList.size() == 0)
{
if(cnt == 1 && (! editFlag.equals("E")))
{
errList.add( "VTINVCD01" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
if(errList == null || errList.size() == 0)
{
siteCode = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sql = "select site_code from invoice where invoice_id =? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
siteCode1 = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(! siteCode.trim().equals(siteCode1))
{
errList.add( "VTDIFFST" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
else
{
errList.add( "VMINVIDNL" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( childNodeName.equalsIgnoreCase("tran_code") )
{
columnValue = genericUtility.getColumnValue("tran_code", dom);
if(columnValue != null && columnValue.trim().length() >0)
{
columnValue1 = genericUtility.getColumnValue("status", dom);
if(columnValue1.equals("S"))
{
sql = " Select Count(*) from transporter where tran_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errList.add( "VMTRAN1" );
errFields.add( childNodeName.toLowerCase() );
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else
{
errList.add( "VMTRANCD1" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( childNodeName.equalsIgnoreCase("trans_mode") )
{
columnValue = genericUtility.getColumnValue("trans_mode", dom);
if(columnValue == null || columnValue.trim().length() == 0)
{
errList.add( "VTITMOD" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
sql = " select count(*) from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'W_INVOICE_AMENDMENT' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = " select count(*) from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'X' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errList.add( "VTITMOD" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if ( childNodeName.equalsIgnoreCase("eff_date") )
{
if(genericUtility.getColumnValue("eff_date", dom) != null)
{
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
columnValue = genericUtility.getColumnValue("invoice_id", dom);
columnValue1 = genericUtility.getColumnValue("status", dom);
if(columnValue1.equals("B"))
{
sql = "select eff_date from invoice where invoice_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
date2 = rs.getTimestamp(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
if(date1 != null && date2 != null && date2.before(date1))
{
errList.add( "VTEFF01" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( childNodeName.equalsIgnoreCase("rd_permit_no") )
{
if(genericUtility.getColumnValue("eff_date", dom) != null)
{
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("eff_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
columnValue = genericUtility.getColumnValue("rd_permit_no", dom);
if(columnValue != null && columnValue.trim().length() > 0 && date1 != null)
{
sql = "select expiry_date, status from roadpermit where rd_permit_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
date2 = rs.getTimestamp(1);
columnValue1 = checkNull(rs.getString(2));
if(date2.after(date1))
{
errList.add( "VTEFF01" );
errFields.add( childNodeName.toLowerCase() );
}
else
{
if(columnValue1.equals("C"))
{
errList.add( "VTRDPS" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if ( childNodeName.equalsIgnoreCase("curr_code__frt") )
{
columnValue = genericUtility.getColumnValue("curr_code__frt", dom);
if(columnValue != null && columnValue.trim().length() > 0)
{
sql = "Select Count(*) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errList.add( "VTCURRCD1" );
errFields.add( childNodeName.toLowerCase() );
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if ( childNodeName.equalsIgnoreCase("curr_code__ins") )
{
columnValue = genericUtility.getColumnValue("curr_code__ins", dom);
if(columnValue != null && columnValue.trim().length() > 0)
{
sql = "Select Count(*) from currency where curr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errList.add( "VTCURRCD1" );
errFields.add( childNodeName.toLowerCase() );
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if ( childNodeName.equalsIgnoreCase("lr_date") )
{
if(genericUtility.getColumnValue("lr_date", dom) != null)
{
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("lr_date", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
columnValue = genericUtility.getColumnValue("invoice_id", dom);
columnValue1 = genericUtility.getColumnValue("status", dom);
if(! columnValue1.equals("D"))
{
if(date1 != null)
{
sql = "select var_value from disparm where prd_code = '999999'" +
" and var_name = 'MAX_DELAY_IN_SHIP' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
}
else
{
cnt = 7;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(errList == null || errList.size() == 0)
{
sql = "select tran_date from invoice where invoice_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
date2 = rs.getTimestamp(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
int diffDays = Math.abs(date1.compareTo(date2));
if(date1 != null && (date1.before(date2) || diffDays > cnt))
{
errList.add( "VTILRD" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
else
{
errList.add( "VTILRDATE" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
else if ( childNodeName.equalsIgnoreCase("shipment_id") )
{
columnValue = genericUtility.getColumnValue("shipment_id", dom);
if(columnValue != null && columnValue.trim().length() > 0)
{
sql = "select count(1) from shipment where shipment_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errList.add( "VTSHIPIDEX" );
errFields.add( childNodeName.toLowerCase() );
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
errList.add( "VTSHIPID" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( childNodeName.equalsIgnoreCase("stan_code__init") )
{
columnValue = genericUtility.getColumnValue("stan_code__init", dom);
if(columnValue != null && columnValue.trim().length() > 0)
{
sql = "select count(*) from STATION where STAN_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errList.add( "VESTACD2" );
errFields.add( childNodeName.toLowerCase() );
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if ( childNodeName.equalsIgnoreCase("date_dep") )
{
if(genericUtility.getColumnValue("date_dep", dom) != null)
{
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_dep", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
if(genericUtility.getColumnValue("date_arr", dom) != null)
{
date2 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_arr", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
if(date1 != null && date2 != null && date1.before(date2))
{
System.out.println("Date ["+date1+"]["+date2+"]");
errList.add( "VTETDETA" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( childNodeName.equalsIgnoreCase("date_arr") )
{
if(genericUtility.getColumnValue("date_dep", dom) != null)
{
date1 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_dep", dom) , genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
if(genericUtility.getColumnValue("date_arr", dom) != null)
{
date2 = Timestamp.valueOf(genericUtility.getValidDateString( genericUtility.getColumnValue("date_arr", dom), genericUtility.getApplDateFormat(),getDBDateFormat()) + " 00:00:00.0");;
}
if(date1 != null && date2 != null && date1.before(date2))
{
errList.add( "VTETDETA" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
}
break;
case 2 :
{
parentList = dom.getElementsByTagName( "Detail2" );
childList = parentList.item( 0 ).getChildNodes();
noOfChilds = childList.getLength();
for (int ctr = 0; ctr < noOfChilds; ctr++)
{
childNode = childList.item( ctr );
childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
else if ( childNodeName.equalsIgnoreCase("status") )
{
columnValue = genericUtility.getColumnValue("status", dom);
System.out.println("cURRENT COLUNM STATUS["+columnValue+"]");
if(columnValue == null || columnValue.trim().length() == 0)
{
errList.add( "VMSTAT" );
errFields.add( childNodeName.toLowerCase() );
}
}
if ( childNodeName.equalsIgnoreCase("tracking_no") )
{
columnValue = genericUtility.getColumnValue("tracking_no", dom);
System.out.println("cURRENT COLUNM TRACKING NO["+columnValue+"]");
if(columnValue == null || columnValue.trim().length() == 0)
{
errList.add( "VMTRACKCD" );
errFields.add( childNodeName.toLowerCase() );
}
}
else if ( childNodeName.equalsIgnoreCase("status_date") )
{
columnValue = genericUtility.getColumnValue("status_date", dom);
System.out.println("cURRENT COLUNM status datee["+columnValue+"]");
if(columnValue == null || columnValue.trim().length() == 0)
{
errList.add( "VMSTSCD1" );
errFields.add( childNodeName.toLowerCase() );
}
}
}
}
}
int errListSize = errList.size();
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);
//String errMsg = hashMap.get(errCode)!=null ? hashMap.get(errCode).toString():"";
//System.out.println("errMsg .........."+errMsg);
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+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 TRY
catch(Exception e)
{
System.out.println("Exception in invoice amendmentIC == >");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if( conn != null && !conn.isClosed() )
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
conn.close();
}
}
catch(Exception e)
{
System.out.println( "Exception :invoice amendmentIC:wfValData :==>\n"+e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
private String errorType( Connection conn , String errorCode ) throws ITMException
{
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();
throw new ITMException(ex);
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
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 :invoice amendmentIC :itemChanged(String,String):" + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
System.out.println ( "returning from invoice amendmentIC itemChanged" );
return errString;
}
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
int grossWeight = 0;
int frtAmt = 0;
int exchRateFrt = 0;
int exchRateIns = 0;
int currentFormNo = 0;
int InsAmt = 0;
int noArt = 0;
int pos = 0;
int amt1 = 0;
int childNodeListLength = 0;
int ctr = 0;
double amt4 = 0.0;
String sql = "";
String columnValue = "";
String columnValue1 = "";
String itemCode = "";
String childNodeName = "";
String descr = "";
String descr1 = "";
String reStr = "";
String currCodeFrt = "";
String currCodeIns = "";
String lrNo = "";
String octroiRcpNo = "";
String lorryNo = "";
String gpNo = "";
String grNo = "";
String sbNo = "";
String stanCodeInit = "";
String shipmentId = "";
String custCode = "";
String custName = "";
String salesPers = "";
String spName = "";
String saleOrder = "";
String tranCode = "";
String transMode = "";
String despId = "";
String remark = "";
String chequeNo = "";
String custPord = "";
Date effFrom = null;
Date sbDate = null;
Date grDate = null;
Date sailDate = null;
Date gpDate = null;
Date lrDate = null;
Date octroiRcpDate = null;
Date chequeDate = null;
Date pordDate = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
StringBuffer valueXmlString = new StringBuffer();
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
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:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append( "<Detail1>\r\n" );
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if( currentColumn.trim().equalsIgnoreCase( "invoice_id" ) )
{
columnValue = genericUtility.getColumnValue("invoice_id",dom);
sql = "select invoice.frt_amt, invoice.curr_code__frt, invoice.exch_rate__frt, " +
" invoice.curr_code__ins, invoice.exch_rate__ins, invoice.ins_amt, " +
" invoice.cust_code,customer.cust_name,invoice.sales_pers,sales_pers.sp_name, " +
" invoice.sale_order,invoice.tran_code,invoice.trans_mode ,invoice.desp_id, remarks " +
" From invoice LEFT OUTER JOIN customer ON invoice.cust_code = customer.cust_code " +
" LEFT OUTER JOIN sales_pers ON invoice.sales_pers = sales_pers.sales_pers " +
" where invoice.invoice_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
frtAmt = rs.getInt(1);
currCodeFrt = checkNull(rs.getString(2));
exchRateFrt = rs.getInt(3);
currCodeIns = checkNull(rs.getString(4));
exchRateIns = rs.getInt(5);
InsAmt = rs.getInt(6);
custCode = checkNull(rs.getString(7));
custName = checkNull(rs.getString(8));
salesPers = checkNull(rs.getString(9));
spName = checkNull(rs.getString(10));
saleOrder = checkNull(rs.getString(11));
tranCode = checkNull(rs.getString(12));
transMode = checkNull(rs.getString(13));
despId = checkNull(rs.getString(14));
remark = checkNull(rs.getString(15));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select gross_weight from despatch where desp_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, despId);
rs = pstmt.executeQuery();
if( rs.next() )
{
grossWeight = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<gross_weight><![CDATA[" ).append( grossWeight ).append( "]]></gross_weight>\r\n" );
// Query modified by sandesh on 21/May/2013 . cust_pord, pord_date added
sql = "select cheque_no, cheque_date, cust_pord, pord_date from sorder where sale_order = ?";
System.out.println("query => select cheque_no, cheque_date, cust_pord, pord_date from sorder where sale_order = '"+saleOrder+"'");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, saleOrder);
rs = pstmt.executeQuery();
if( rs.next() )
{
chequeNo = checkNull(rs.getString(1));
chequeDate = rs.getDate(2);
custPord = rs.getString("cust_pord");
pordDate = rs.getDate("pord_date");
}
System.out.println("chequeNo : "+chequeNo+" chequeDate : "+chequeDate+" custPord : "+custPord+" pordDate : "+pordDate);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<ref_no><![CDATA[" ).append( chequeNo==null?"":chequeNo).append( "]]></ref_no>\r\n" );
valueXmlString.append( "<ref_date><![CDATA[" ).append( chequeDate==null?"":sdf.format(chequeDate) ).append( "]]></ref_date>\r\n" );
// Added by sandesh on 21/May/2013 . cust_pord, pord_date added
valueXmlString.append( "<cust_pord><![CDATA[" ).append( custPord==null?"":custPord).append( "]]></cust_pord>\r\n" );
valueXmlString.append( "<pord_date><![CDATA[" ).append( pordDate==null?"":sdf.format(pordDate) ).append( "]]></pord_date>\r\n" );
sql = "select descr from gencodes where fld_value = ? and mod_name='W_INVOICE_AMENDMENT'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,transMode );
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<trans_mode><![CDATA[" ).append( transMode ).append( "]]></trans_mode>\r\n" );
valueXmlString.append( "<trans_descr><![CDATA[" ).append( descr ).append( "]]></trans_descr>\r\n" );
descr = "";
sql = "select tran_name from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<invoice_cust_code><![CDATA[" ).append( custCode ).append( "]]></invoice_cust_code>\r\n" );
valueXmlString.append( "<customer_cust_name><![CDATA[" ).append( custName ).append( "]]></customer_cust_name>\r\n" );
valueXmlString.append( "<frt_amt><![CDATA[" ).append( frtAmt ).append( "]]></frt_amt>\r\n" );
valueXmlString.append( "<invoice_sales_pers><![CDATA[" ).append( salesPers ).append( "]]></invoice_sales_pers>\r\n" );
valueXmlString.append( "<sales_pers_sp_name><![CDATA[" ).append( spName ).append( "]]></sales_pers_sp_name>\r\n" );
valueXmlString.append( "<curr_code__frt><![CDATA[" ).append( currCodeFrt ).append( "]]></curr_code__frt>\r\n" );
valueXmlString.append( "<exch_rate__frt><![CDATA[" ).append( exchRateFrt ).append( "]]></exch_rate__frt>\r\n" );
valueXmlString.append( "<ins_amt><![CDATA[" ).append( InsAmt ).append( "]]></ins_amt>\r\n" );
valueXmlString.append( "<curr_code__ins><![CDATA[" ).append( currCodeIns ).append( "]]></curr_code__ins>\r\n" );
valueXmlString.append( "<exch_rate__ins><![CDATA[" ).append( exchRateIns ).append( "]]></exch_rate__ins>\r\n" );
valueXmlString.append( "<remarks><![CDATA[" ).append( remark ).append( "]]></remarks>\r\n" );
reStr = itemChanged(dom, dom1, dom2, objContext, "status", editFlag, xtraParams);
pos = reStr.indexOf("<Detail1>");
reStr = reStr.substring(pos + 9);
pos = reStr.indexOf("</Detail1>");
reStr = reStr.substring(0,pos);
valueXmlString.append(reStr);
descr = "";
descr1 = "";
sql = "select distinct invdet.item_code, rtrim(ltrim(item.descr)), sum(invdet.quantity) " +
" from invdet,item where invdet.item_code = item.item_code and invdet.invoice_id = ? " +
" group by invdet.item_code, rtrim(ltrim(item.descr)) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
while( rs.next() )
{
itemCode = checkNull(rs.getString(1));
descr = checkNull(rs.getString(2));
amt1 = rs.getInt(3);
if(descr.indexOf('/') > 0)
{
descr = descr.replace('/', '\'');
}
descr1 = descr1 + itemCode +" "+ descr + " "+ amt1 +"/";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<item_info><![CDATA[" ).append( descr1 ).append( "]]></item_info>\r\n" );
}
if( currentColumn.trim().equalsIgnoreCase( "status" ) )
{
columnValue = genericUtility.getColumnValue("status",dom).trim();
columnValue1 = genericUtility.getColumnValue("invoice_id",dom);
if(columnValue.equals("S"))
{
sql = "select desp_id, eff_date from invoice where invoice_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue1);
rs = pstmt.executeQuery();
if( rs.next() )
{
despId = checkNull(rs.getString(1));
effFrom = rs.getDate(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select tran_code, lr_no, lr_date, octroi_rcp_no, orctoi_rcp_date," +
" case when no_art is null then 0 else no_art end, lorry_no,gp_no, " +
" gp_date,gr_no,gr_date,sail_date, sb_no,sb_date,stan_code__init, " +
" SHIPMENT_ID from despatch where desp_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, despId);
rs = pstmt.executeQuery();
if( rs.next() )
{
tranCode = checkNull(rs.getString(1));
lrNo = checkNull(rs.getString(2));
lrDate = rs.getDate(3);
octroiRcpNo = checkNull(rs.getString(4));
octroiRcpDate = rs.getDate(5);
noArt = rs.getInt(6);
lorryNo = checkNull(rs.getString(7));
gpNo = checkNull(rs.getString(8));
gpDate = rs.getDate(9);
grNo = checkNull(rs.getString(10));
grDate = rs.getDate(11);
sailDate = rs.getDate(12);
sbNo = checkNull(rs.getString(13));
sbDate = rs.getDate(14);
stanCodeInit = checkNull(rs.getString(15));
shipmentId = checkNull(rs.getString(16));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
descr = "";
sql = "select tran_name from transporter where tran_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<shipment_id><![CDATA[" ).append( shipmentId ).append( "]]></shipment_id>\r\n" );
valueXmlString.append( "<tran_code protect = \"0\"><![CDATA[" ).append( tranCode ).append( "]]></tran_code>\r\n" );
valueXmlString.append( "<tran_name><![CDATA[" ).append( descr ).append( "]]></tran_name>\r\n" );
valueXmlString.append( "<lr_no protect = \"0\"><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" );
valueXmlString.append( "<lr_date protect = \"0\"><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" );
valueXmlString.append( "<no_art><![CDATA[" ).append( noArt ).append( "]]></no_art>\r\n" );
valueXmlString.append( "<octroi_rcp_no protect = \"0\"><![CDATA[" ).append( octroiRcpNo ).append( "]]></octroi_rcp_no>\r\n" );
valueXmlString.append( "<octroi_rcp_date protect = \"0\"><![CDATA[" ).append( octroiRcpDate==null?"":sdf.format(octroiRcpDate) ).append( "]]></octroi_rcp_date>\r\n" );
valueXmlString.append( "<desp_id><![CDATA[" ).append( despId ).append( "]]></desp_id>\r\n" );
valueXmlString.append( "<eff_date protect = \"0\"><![CDATA[" ).append( effFrom==null?"":sdf.format(effFrom) ).append( "]]></eff_date>\r\n" );
valueXmlString.append( "<lorry_no><![CDATA[" ).append( lorryNo ).append( "]]></lorry_no>\r\n" );
valueXmlString.append( "<gp_no><![CDATA[" ).append( gpNo ).append( "]]></gp_no>\r\n" );
valueXmlString.append( "<gp_date><![CDATA[" ).append( gpDate==null?"":sdf.format(gpDate) ).append( "]]></gp_date>\r\n" );
valueXmlString.append( "<gr_no><![CDATA[" ).append( grNo ).append( "]]></gr_no>\r\n" );
valueXmlString.append( "<gr_date><![CDATA[" ).append( grDate==null?"":sdf.format(grDate) ).append( "]]></gr_date>\r\n" );
valueXmlString.append( "<sail_date><![CDATA[" ).append( sailDate==null?"":sdf.format(sailDate) ).append( "]]></sail_date>\r\n" );
valueXmlString.append( "<sb_no><![CDATA[" ).append( sbNo ).append( "]]></sb_no>\r\n" );
valueXmlString.append( "<sb_date><![CDATA[" ).append( sbDate==null?"":sdf.format(sbDate) ).append( "]]></sb_date>\r\n" );
valueXmlString.append( "<stan_code__init><![CDATA[" ).append( stanCodeInit ).append( "]]></stan_code__init>\r\n" );
valueXmlString.append( "<ref_no><![CDATA[" ).append( genericUtility.getColumnValue("ref_no", dom) ).append( "]]></ref_no>\r\n" );
valueXmlString.append( "<ref_date><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("ref_date", dom)) ).append( "]]></ref_date>\r\n" );
setNodeValue( dom,"stan_code__init" ,stanCodeInit );
reStr = itemChanged(dom, dom1, dom2, objContext, "stan_code__init", editFlag, xtraParams);
pos = reStr.indexOf("<Detail1>");
reStr = reStr.substring(pos + 9);
pos = reStr.indexOf("</Detail1>");
reStr = reStr.substring(0,pos);
valueXmlString.append(reStr);
}
else
{
valueXmlString.append( "<tran_code protect = \"1\"><![CDATA[]]></tran_code>\r\n" );
valueXmlString.append( "<lr_no protect = \"1\"><![CDATA[]]></lr_no>\r\n" );
valueXmlString.append( "<lr_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("lr_date", dom)) ).append( "]]></lr_date>\r\n" );
if(columnValue.equals("B"))
{
valueXmlString.append( "<octroi_rcp_no protect = \"1\"><![CDATA[]]></octroi_rcp_no>\r\n" );
valueXmlString.append( "<octroi_rcp_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("octroi_rcp_date", dom)) ).append( "]]></octroi_rcp_date>\r\n" );
}
else
{
valueXmlString.append( "<octroi_rcp_no protect = \"0\"><![CDATA[]]></octroi_rcp_no>\r\n" );
valueXmlString.append( "<octroi_rcp_date protect = \"0\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("octroi_rcp_date", dom)) ).append( "]]></octroi_rcp_date>\r\n" );
}
valueXmlString.append( "<transporter_tran_name><![CDATA[]]></transporter_tran_name>\r\n" );
valueXmlString.append( "<desp_id><![CDATA[]]></desp_id>\r\n" );
valueXmlString.append( "<eff_date protect = \"0\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("eff_date", dom)) ).append( "]]></eff_date>\r\n" );
valueXmlString.append( "<ref_no protect = \"1\"><![CDATA[]]></ref_no>\r\n" );
valueXmlString.append( "<ref_date protect = \"1\"><![CDATA[" ).append( checkDate(genericUtility.getColumnValue("ref_date", dom)) ).append( "]]></ref_date>\r\n" );
}
}
if( currentColumn.trim().equalsIgnoreCase( "tran_code" ) )
{
columnValue = genericUtility.getColumnValue("tran_code",dom);
sql = "select tran_name from transporter where tran_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<transporter_tran_name><![CDATA[" ).append( descr ).append( "]]></transporter_tran_name>\r\n" );
}
if( currentColumn.trim().equalsIgnoreCase( "trans_mode" ) )
{
columnValue = genericUtility.getColumnValue("trans_mode",dom);
sql = "select descr from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'W_INVOICE_AMENDMENT'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = checkNull(rs.getString(1));
}
else
{
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "select descr from gencodes where fld_value = ? and fld_name = 'TRANS_MODE' and mod_name = 'X'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = checkNull(rs.getString(1));
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<trans_descr><![CDATA[" ).append( descr ).append( "]]></trans_descr>\r\n" );
}
if( currentColumn.trim().equalsIgnoreCase( "curr_code__frt" ) )
{
columnValue = genericUtility.getColumnValue("curr_code__frt",dom);
sql = "select std_exrt from currency where curr_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
amt4 = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<exch_rate__frt><![CDATA[" ).append( amt4 ).append( "]]></exch_rate__frt>\r\n" );
}
if( currentColumn.trim().equalsIgnoreCase( "curr_code__ins" ) )
{
columnValue = genericUtility.getColumnValue("curr_code__ins",dom);
sql = "select std_exrt from currency where curr_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
amt4 = rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<exch_rate__ins><![CDATA[" ).append( amt4 ).append( "]]></exch_rate__ins>\r\n" );
}
if( currentColumn.trim().equalsIgnoreCase( "stan_code__init" ) )
{
columnValue = genericUtility.getColumnValue("stan_code__init",dom);
sql = "select descr from station where stan_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
descr = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append( "<station_descr><![CDATA[" ).append( descr ).append( "]]></station_descr>\r\n" );
}
if( currentColumn.trim().equalsIgnoreCase( "shipment_id" ) )
{
columnValue = genericUtility.getColumnValue("shipment_id",dom);
if(columnValue != null && columnValue.trim().length() > 0)
{
sql = "select lr_no,lr_date from shipment where shipment_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
lrNo = checkNull(rs.getString(1));
lrDate = rs.getDate(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(lrNo.trim().length() > 0)
{
valueXmlString.append( "<lr_no><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" );
}
if(lrDate != null)
{
valueXmlString.append( "<lr_date><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" );
}
}
else
{
columnValue1 = genericUtility.getColumnValue("desp_id",dom);
if(columnValue1 != null && columnValue1.trim().length() > 0)
{
sql = "select lr_no, lr_date from despatch where desp_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, columnValue1);
rs = pstmt.executeQuery();
if( rs.next() )
{
lrNo = checkNull(rs.getString(1));
lrDate = rs.getDate(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(lrNo.trim().length() > 0)
{
valueXmlString.append( "<lr_no><![CDATA[" ).append( lrNo ).append( "]]></lr_no>\r\n" );
}
if(lrDate != null)
{
valueXmlString.append( "<lr_date><![CDATA[" ).append( lrDate==null?"":sdf.format(lrDate) ).append( "]]></lr_date>\r\n" );
}
}
}
}
valueXmlString.append( "</Detail1>\r\n" );
break;
case 2:
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
columnValue = genericUtility.getColumnValue("tran_id", dom1);
valueXmlString.append( "<tran_id><![CDATA[" ).append( checkNull(columnValue) ).append( "]]></tran_id>\r\n" );
valueXmlString.append( "<status_date><![CDATA[" ).append( sdf.format(new java.util.Date()) ).append( "]]></status_date>\r\n" );
}
valueXmlString.append( "</Detail2>\r\n" );
System.out.println("------------------------COMPLETE DESCRIPTION-------------------");
break;
}
}
}
catch(Exception e)
{
System.out.println( "Exception :invoice amendment :itemChanged(Document,String):" + e.getMessage() + ":" );
valueXmlString = valueXmlString.append( genericUtility.createErrorString( e ) );
throw new ITMException(e);
}
finally
{
try
{
if( conn != null && ! conn.isClosed() )
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
conn.close();
}
//System.out.println("------------------------INSIDE FINALLY-------------------");
}
catch(Exception e)
{
System.out.println( "Exception :invoice amendment:itemChanged :==>\n"+e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append( "</Root>\r\n" );
System.out.println( "\n****ValueXmlString :" + valueXmlString.toString() + ":********" );
return valueXmlString.toString();
}
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
{
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
if( tempNode != null )
{
if( tempNode.getFirstChild() == null )
{
CDATASection cDataSection = dom.createCDATASection( nodeVal );
tempNode.appendChild( cDataSection );
}
else
{
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
private String checkDate( String input ) throws ITMException
{
try
{
if(input != null && input.trim().length() > 0 && (! input.trim().equals("null")))
{
input = GenericUtility.getInstance().getValidDateString(input, getApplDateFormat());
}
else
input = "";
}
catch (Exception e)
{
input = "";
System.out.println("Error in date format at 1283"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return input;
}
}
\ No newline at end of file
/********************************************************
Title : InvoiceAmendmentICLocal
Date : 08/06/2012
Developer: Mahesh Patidar
********************************************************/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
@javax.ejb.Local
public interface InvoiceAmendmentICLocal 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;
}
/********************************************************
Title : InvoiceAmendmentICRemote
Date : 08/06/2012
Developer: Mahesh Patidar
********************************************************/
package ibase.webitm.ejb.wms;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
@javax.ejb.Remote
public interface InvoiceAmendmentICRemote 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;
}
/**
* PURPOSE : Confirmation of Stock transfer transaction
* AUTHOR : Gulzar on 13/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.ejb.sys.*;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import java.io.*;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import javax.ejb.Stateless;
import org.w3c.dom.*;
@Stateless
public class StockTransferConf extends ActionHandlerEJB implements StockTransferConfRemote, StockTransferConfLocal
{
/**
* The public function is used to confirm a transaction corresponding to the tran id it takes as an argument
* @param : tranId
* @param : xtraParams
*/
//changes by chitranjan for overriding of confirm method 29/11/11
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "";
Connection conn = null;
boolean isConn= false;
try
{
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 e)
{
System.out.println("Exception in [StockTransferConf] confirm " + e.getMessage());
throw new ITMException(e);
}
return retString;
}
//changes by chitranjan in confirm method parameter add connection ,connStatus
public String confirm( String tranId, String xtraParams, String forcedFlag, Connection conn, boolean connStatus ) throws RemoteException,ITMException
{
String replOrder = "";
String confirmed = "";
String retString = "";
String itemCode = "";
String siteCode = "";
String locCodeFr = "";
String locCodeTo = "";
String lotNo = "";
String lotSl = "";
String lotSlTo = "";
String acctCodeCr = "";
String cctrCodeCr = "";
String sql = "";
String updateSql = "";
double quantity = 0.0;
double noArt = 0.0;
java.sql.Timestamp expDate = null;
java.sql.Timestamp mfgDate = null;
java.sql.Timestamp restestDate = null;
String packCode = "";
String siteCodeMfg = "";
String packInstr = "";
String suppCodeMfg = "";
String unitAlt = "";
String batchNo = "";
String unit = "";
String grade = "";
String remarks = "";
String dimension = "";
String acctCodeDr = "";
String ediOption = "";
String dataStr = "";
String userId = "";
String chgTerm = "";
double grossRate = 0d;
double convQtyStduom = 0d;
double batchSize = 0d;
double stkGrossRate = 0d;
double stkRate = 0d;
// 16/10/11 manoharan
double stkQuantity = 0,holdQuantity = 0;
PreparedStatement pstmtUpd = null, pstmtHold = null, pstmtRel = null;
ResultSet rsHold = null, rsRel = null;
String tranIdHold = "", sqlRel = "", sqlHold = "",nearExpLoc = "";
int lineNoHold = 0;
// end 16/10/11 manoharan
String partialGrlLoc = ""; //added by Ashish Sonawane on 05/SEP/12 for partial GRL location Inventory Status.
String invStatLocCodeTo =""; //added by Ashish Sonawane on 05/SEP/12 for partial GRL location Inventory Status.
PreparedStatement pstmtInvStat =null;
ResultSet rsInvStat =null;
int lineNo = 0, updCnt = 0;
boolean isError = false;
HashMap updateRowMap = null;
HashMap strAllocate = null;
StockUpdate stkUpdate = null;
//Connection conn = null;
PreparedStatement pstmt = null;
PreparedStatement pstmtStock = null;
ResultSet rs = null;
ResultSet rsStock = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
DistCommon dComm = new DistCommon();
double balQty = 0;
try
{
if ( conn == null )
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
connStatus = true;
}
String dbDateFormat = genericUtility.getDBDateFormat();
String applDateFormat = genericUtility.getApplDateFormat();
java.sql.Timestamp currDate = new java.sql.Timestamp( System.currentTimeMillis() );
java.util.Date currDate1 = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(applDateFormat);
String currDateStr = sdf.format(currDate1);
String empCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginEmpCode" );
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
chgTerm = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
java.sql.Timestamp tranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString( currDateStr , applDateFormat, dbDateFormat ) + " 00:00:00.0") ;
updateRowMap = new HashMap();
stkUpdate = new StockUpdate();
sql = "SELECT CONFIRMED, SITE_CODE FROM STOCK_TRANSFER WHERE TRAN_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = rs.getString( "CONFIRMED" );
siteCode = rs.getString( "SITE_CODE" );
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if( confirmed.equalsIgnoreCase("Y") )
{
retString = itmDBAccess.getErrorString("","CONFIRMED","");
return retString;
}
else
{
// 24/06/12 manoharan if transfer to near expiry not to transfer the hold quantity
nearExpLoc = dComm.getDisparams("999999","NEAREXP_LOC",conn);
partialGrlLoc = dComm.getDisparams("999999","PGRL_INVSTAT",conn);
sql = "SELECT LINE_NO, ITEM_CODE, QUANTITY, LOC_CODE__FR, LOC_CODE__TO, LOT_NO__FR, LOT_SL__FR, LOT_SL__TO, ACCT_CODE__CR, CCTR_CODE__CR, NO_ART " +
"FROM STOCK_TRANSFER_DET WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
// 16/10/11 manoharan quantity, hold_qty added
sql = "select acct_code__inv, cctr_code__inv, "
+ "exp_date, pack_code, mfg_date, site_code__mfg, "
+ "pack_instr, supp_code__mfg, retest_date, "
+ "gross_rate, rate, conv__qty_stduom, unit__alt, batch_no, batch_size, "
+ "unit, grade, remarks, dimension, quantity ,hold_qty "
+ "from stock "
+ "where item_code = ? "
+ "and site_code = ? "
+ "and loc_code = ? "
+ "and lot_no = ? "
+ "and lot_sl = ? ";
// end 16/10/11 manoharan hold_qty added
pstmtStock = conn.prepareStatement(sql);
while(rs.next())
{
lineNo = rs.getInt( "LINE_NO" );
itemCode = rs.getString( "ITEM_CODE" );
quantity = rs.getDouble( "QUANTITY" );
locCodeFr = rs.getString( "LOC_CODE__FR" );
locCodeTo = rs.getString( "LOC_CODE__TO" );
lotNo = rs.getString( "LOT_NO__FR" );
lotSl = rs.getString( "LOT_SL__FR" );
lotSlTo = rs.getString( "LOT_SL__TO" );
noArt = rs.getDouble( "NO_ART" );
acctCodeCr = rs.getString( "ACCT_CODE__CR" );
cctrCodeCr = rs.getString( "CCTR_CODE__CR" );
// 16/10/11 manoharan initialise quantity, hold_qty
stkQuantity = 0;
holdQuantity = 0;
// end 16/10/11 manoharan hold_qty added
/*Added by Ashish Sonawane on 05-Sep-12 [START]*/
String sqlInvStat = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ?";
pstmtInvStat = conn.prepareStatement( sqlInvStat );
pstmtInvStat.setString( 1, locCodeTo );
rsInvStat = pstmtInvStat.executeQuery();
if( rsInvStat.next() )
{
invStatLocCodeTo = checkNull(rsInvStat.getString("INV_STAT"));
}
rsInvStat.close();rsInvStat = null;
pstmtInvStat.close();pstmtInvStat = null;
/*Added by Ashish Sonawane on 05-Sep-12 [END]*/
pstmtStock.setString(1,itemCode);
pstmtStock.setString(2,siteCode);
pstmtStock.setString(3,locCodeFr);
pstmtStock.setString(4,lotNo);
pstmtStock.setString(5,lotSl);
rsStock = pstmtStock.executeQuery();
if ( rsStock.next() )
{
//acctCodeDr = rsStock.getString("acct_code__inv");
//cctrCodeDr = rsStock.getString("cctr_code__inv");
expDate = rsStock.getTimestamp("exp_date");
packCode = rsStock.getString("pack_code");
mfgDate = rsStock.getTimestamp("mfg_date");
siteCodeMfg = rsStock.getString("site_code__mfg");
packInstr = rsStock.getString("pack_instr");
suppCodeMfg = rsStock.getString("supp_code__mfg");
restestDate = rsStock.getTimestamp("retest_date");
stkGrossRate = rsStock.getDouble("gross_rate");
stkRate = rsStock.getDouble("rate");
convQtyStduom = rsStock.getDouble("conv__qty_stduom");
unitAlt = rsStock.getString("unit__alt");
batchNo = rsStock.getString("batch_no");
batchSize = rsStock.getDouble("batch_size");
unit = rsStock.getString("unit");
grade = rsStock.getString("grade");
remarks = rsStock.getString("remarks");
dimension = rsStock.getString("dimension");
// 16/10/11 manoharan hold_qty added
stkQuantity = rsStock.getDouble("quantity");
holdQuantity = rsStock.getDouble("hold_qty");
// end 16/10/11 manoharan hold_qty added
}
rsStock.close(); rsStock = null;
pstmtStock.clearParameters();
updateRowMap.put("item_code", itemCode);
updateRowMap.put("site_code", siteCode);
updateRowMap.put("loc_code", locCodeFr);
updateRowMap.put("lot_no", lotNo);
updateRowMap.put("lot_sl", lotSl);
updateRowMap.put("quantity", ""+quantity);
/* Added by Ashish Sonawane on 07-sep-12 as per Manoharan Sir in case of partial GRL no_art to be set as 0 for issue [START] */
if(invStatLocCodeTo.trim().equalsIgnoreCase(locCodeTo.trim()))
{
noArt = 0;
updateRowMap.put("no_art", noArt);
}
else
{
updateRowMap.put("no_art", noArt);
}
/* Added by Ashish Sonawane on 07-sep-12 as per Manoharan Sir in case of partial GRL no_art to be set as 0 for issue [END] */
updateRowMap.put("tran_ser", "XFRX");
updateRowMap.put("acct_code__cr",acctCodeCr);
updateRowMap.put("cctr_code__cr",cctrCodeCr);
updateRowMap.put("acct_code_inv",acctCodeCr);
updateRowMap.put("cctr_code_inv",cctrCodeCr);
updateRowMap.put("rate",Double.toString(stkRate));
updateRowMap.put("gross_rate",Double.toString(stkGrossRate));
updateRowMap.put("tran_id", tranId );
updateRowMap.put("tran_date", tranDate );
updateRowMap.put("tran_type","ID");
updateRowMap.put("qty_stduom", ""+quantity);
updateRowMap.put("unit",unit);
updateRowMap.put("grade",grade);
updateRowMap.put("remarks",remarks);
updateRowMap.put("dimension",dimension);
//updateRowMap.put("tran_type", "I");
//changed by gulzar on 12/24/2011
updateRowMap.put("exp_date", expDate);
updateRowMap.put("pack_code", packCode);
updateRowMap.put("mfg_date", mfgDate);
updateRowMap.put("site_code__mfg", siteCodeMfg);
updateRowMap.put("pack_instr", packInstr);
updateRowMap.put("supp_code__mfg", suppCodeMfg);
updateRowMap.put("retest_date", restestDate);
updateRowMap.put("conv__qty_stduom", ""+convQtyStduom);
updateRowMap.put("unit__alt", unitAlt);
updateRowMap.put("batch_no", batchNo);
updateRowMap.put("batch_size", ""+batchSize);
//End changes by gulzar on 12/24/2011
retString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
if ( retString != null && retString.trim().length() > 0 )
{
isError = true;
break;
}
updateRowMap.put("loc_code", locCodeTo);
updateRowMap.put("lot_sl", lotSlTo);
updateRowMap.put("tran_type", "R");
/* Added by Ashish Sonawane on 07-sep-12 as per Manoharan Sir in case of partial GRL no_art to be set as quantity at the time of receipt [START] */
if(invStatLocCodeTo.trim().equalsIgnoreCase(locCodeTo.trim()))
{
updateRowMap.put("no_art", quantity);
}
/* Added by Ashish Sonawane on 07-sep-12 as per Manoharan Sir in case of partial GRL no_art to be set as quantity at the time of receipt [END] */
retString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
if ( retString != null && retString.trim().length() > 0 )
{
isError = true;
break;
}
updateRowMap.clear();
// 16/10/11 manoharan check whether inv hold is there
// if hold_qty > 0 update the same stock hold_qty for loc_code__to
// also reduce the hold_qty for old loc_code
// This utility methods to update old and new location should be in
// a separate probably in stockupdate so that we can call the same from various places
if (holdQuantity > 0)
{
// update old location with - hold_qty
sqlRel = "UPDATE STOCK SET HOLD_QTY = HOLD_QTY - ?"
+ " WHERE ITEM_CODE = ? "
+ " AND SITE_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? ";
pstmtUpd = conn.prepareStatement(sqlRel);
//pstmtUpd.setDouble(1,holdQuantity); //Commented by Ashish Sonawane on 01/SEP/12 as implication on stock due to PGRL location for partial qty putaway
pstmtUpd.setDouble(1,quantity); //Added by Ashish Sonawane on 01/SEP/12 as implication on stock due to PGRL location for partial qty putaway
pstmtUpd.setString(2,itemCode);
pstmtUpd.setString(3,siteCode);
pstmtUpd.setString(4,locCodeFr);
pstmtUpd.setString(5,lotNo);
pstmtUpd.setString(6,lotSl);
pstmtUpd.executeUpdate();
// 24/06/12 manoharan if not neare expiry location hold quantity to be transferred
if (!nearExpLoc.trim().equalsIgnoreCase(locCodeTo.trim()) )
{
// update new location with + hold_qty
sqlRel = "UPDATE STOCK SET HOLD_QTY = CASE WHEN HOLD_QTY IS NULL THEN 0 ELSE HOLD_QTY END + ? "
+ " WHERE ITEM_CODE = ? "
+ " AND SITE_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? ";
pstmtUpd = conn.prepareStatement(sqlRel);
//pstmtUpd.setDouble(1,holdQuantity); //Commented by Ashish Sonawane on 01/SEP/12 as implication on stock due to PGRL location for partial qty putaway
pstmtUpd.setDouble(1,quantity); //Added by Ashish Sonawane on 01/SEP/12 as implication on stock due to PGRL location for partial qty putaway
pstmtUpd.setString(2,itemCode);
pstmtUpd.setString(3,siteCode);
pstmtUpd.setString(4,locCodeTo);
pstmtUpd.setString(5,lotNo);
//pstmtUpd.setString(6,lotSl);//Gulzar on 21/12/11
pstmtUpd.setString(6,lotSlTo);//Gulzar on 21/12/11
pstmtUpd.executeUpdate();
pstmtHold = null;
rsHold = null;
tranIdHold = "";
lineNoHold = 0;
sqlHold = "SELECT D.TRAN_ID AS TRAN_ID, D.LINE_NO AS LINE_NO, "
+ " D.ITEM_CODE AS ITEM_CODE, D.SITE_CODE AS SITE_CODE, "
+ " D.LOC_CODE AS LOC_CODE, D.LOT_NO AS LOT_NO, D.LOT_SL AS LOT_SL "
+ " FROM INV_HOLD_DET D, INV_HOLD H "
+ " WHERE H.TRAN_ID = D.TRAN_ID "
+ " AND ((D.ITEM_CODE = ? ) OR (D.ITEM_CODE IS NULL OR LENGTH(TRIM(D.ITEM_CODE)) = 0 ) ) "
+ " AND ((D.SITE_CODE = ? ) OR (D.SITE_CODE IS NULL OR LENGTH(TRIM(D.SITE_CODE)) = 0 ) ) "
+ " AND ((D.LOC_CODE = ? ) OR (D.LOC_CODE IS NULL OR LENGTH(TRIM(D.LOC_CODE)) = 0 ) ) "
+ " AND ((D.LOT_NO = ? ) OR (D.LOT_NO IS NULL OR LENGTH(TRIM(D.LOT_NO)) = 0 ) ) "
+ " AND ((D.LOT_SL = ? ) OR (D.LOT_SL IS NULL OR LENGTH(TRIM(D.LOT_SL)) = 0 ) ) "
+ " AND D.HOLD_STATUS = 'H'"
+ " AND H.CONFIRMED = 'Y' ";
pstmtHold = conn.prepareStatement(sqlHold);
pstmtHold.setString(1,itemCode);
pstmtHold.setString(2,siteCode);
pstmtHold.setString(3,locCodeFr);
pstmtHold.setString(4,lotNo);
pstmtHold.setString(5,lotSl);
rsHold = pstmtHold.executeQuery();
balQty = holdQuantity;
while ( rsHold.next() )
{
/*//check whether there is a confirmed release hold for the same
sqlRel = "select count(1) from inv_hold_rel h, inv_hold_rel_det "
+ " where h.tran_id = d.tran_id "
+ " and d.tran_id__hold = ? "
+ " and d.line_no__hold = ? "
+ " and h.confirmed = 'Y'";
pstmtRel = conn.prepareStatement(sqlRel);
pstmtRel.SetString(1,rsHold.getString("TRAN_ID"));
pstmtRel.setInt(2,rsHold.getInt("LINE_NO"));
rsRel = pstmtRel.executeQuery();
if (rsRelel.next())
{
}
rsRel.close();
rsRel = null;
pstmtRel.close();
pstmtRel = null;
*/
tranIdHold = rsHold.getString("TRAN_ID");// added by Ashish Sonawane on 05-sep-12
if(invStatLocCodeTo.trim().equalsIgnoreCase(locCodeTo.trim()))
{
insertIntoInvHold(itemCode,siteCode,locCodeTo,lotNo,lotSlTo,tranIdHold,conn);
System.out.println("@@@@ End of insertion...");
}
else
{
// if not update INV_HOLD_DET with new loc_code (loc_code__to)
sqlRel = "UPDATE INV_HOLD_DET SET LOC_CODE = ?, STATUS_DATE = ? "
+ " WHERE TRAN_ID = ? AND LINE_NO = ?";
pstmtUpd = conn.prepareStatement(sqlRel);
pstmtUpd.setString(1,locCodeTo);
pstmtUpd.setTimestamp(2,new java.sql.Timestamp( System.currentTimeMillis() ));
pstmtUpd.setString(3,rsHold.getString("TRAN_ID"));
pstmtUpd.setInt(4,rsHold.getInt("LINE_NO"));
pstmtUpd.executeUpdate();
// 23/06/12 manoharan
//tranIdHold = rsHold.getString("TRAN_ID"); //commented by Ashish Sonawane on 05-Sep-12 and moved to line no 421
sqlRel = "UPDATE INV_HOLD_REL_TRACE SET LOC_CODE = ? "
+ " WHERE REF_NO = ? "
+ " AND ITEM_CODE = ? "
+ " AND SITE_CODE = ? "
+ " AND LOC_CODE = ? "
+ " AND LOT_NO = ? "
+ " AND LOT_SL = ? " ;
pstmtUpd = conn.prepareStatement(sqlRel);
pstmtUpd.setString(1,locCodeTo);
pstmtUpd.setString(2,tranIdHold);
pstmtUpd.setString(3,itemCode);
pstmtUpd.setString(4,siteCode);
pstmtUpd.setString(5,locCodeFr);
pstmtUpd.setString(6,lotNo);
pstmtUpd.setString(7,lotSl);
updCnt = pstmtUpd.executeUpdate();
System.out.println( "[" + updCnt + "] rows updated successfully in INV_HOLD_REL_TRACE" );
// end 23/06/12 manoharan
}
}
rsHold.close();
rsHold = null;
pstmtHold.close();
pstmtHold = null;
} // end 24/06/12 manoharan not near expiry
}
// end 16/10/11 manoharan
}
rs.close();rs = null;
pstmt.close();pstmt = null;
pstmtStock.close();pstmtStock = null;
if ( retString == null || retString.trim().length() == 0 )
{
updateSql = "UPDATE STOCK_TRANSFER SET CONFIRMED = 'Y', CONF_DATE = ?, EMP_CODE__APRV = ? " +
"WHERE TRAN_ID = ? ";
pstmt = conn.prepareStatement(updateSql);
pstmt.setTimestamp(1, currDate);
pstmt.setString(2, empCode);
pstmt.setString(3, tranId);
updCnt = pstmt.executeUpdate();
pstmt.close();pstmt = null;
if( updCnt > 0 )
{
System.out.println( updCnt + " rows updated successfully" );
}
////////////////////// EDI creation
/*
sql = "SELECT EDI_OPTION FROM TRANSETUP WHERE TRAN_WINDOW = 'w_stock_transfer_wiz' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if ( rs.next() )
{
ediOption = checkNull(rs.getString("EDI_OPTION"));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if ( "1".equals(ediOption.trim()) )
{
CreateRCPXML createRCPXML = new CreateRCPXML("w_stockinvStatLocCodeTo_transfer","tran_id");
dataStr = createRCPXML.getTranXML( tranId, conn );
System.out.println( "dataStr =[ "+ dataStr + "]" );
Document ediDataDom = genericUtility.parseString(dataStr);
E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb();
e12CreateBatchLoad.createBatchLoad( ediDataDom, "w_stock_transfer", "0", xtraParams, conn );
createRCPXML = null;
e12CreateBatchLoad = null;
}
*/
/////////////////////
}
////////////
}
}
catch( Exception e )
{
try
{
conn.rollback();
isError = true;
e.printStackTrace();
}
catch (Exception e1)
{
}
throw new ITMException(e);
}
finally
{
try
{
//added by chitranjan connStatus if connstatus is true then commit.
if( !isError && connStatus )
{
conn.commit();
retString = itmDBAccess.getErrorString("","CONFSUCC","");
}
else if(connStatus)
{
conn.rollback();
}
if(rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(pstmtStock != null )
{
pstmtStock.close();
pstmtStock = null;
}
if( conn != null && connStatus )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
private void insertIntoInvHold(String itemCode ,String siteCode, String locCode ,String lotNo, String lotSl, String tranIdHold ,Connection conn) throws ITMException
{
PreparedStatement pstmtInsertInvHold =null;
PreparedStatement pstmtMaxLine =null;
ResultSet rsMaxLine =null;
int maxLineNo=0;
try {
String sqlMaxLine ="SELECT MAX(LINE_NO) FROM INV_HOLD_DET WHERE TRAN_ID =?";
pstmtMaxLine = conn.prepareStatement(sqlMaxLine);
pstmtMaxLine.setString(1,tranIdHold);
rsMaxLine =pstmtMaxLine.executeQuery();
if(rsMaxLine.next())
{
maxLineNo =(rsMaxLine.getInt(1))+1;
System.out.println("line no to be inserted :" +maxLineNo);
}
else
{
maxLineNo =maxLineNo++;
}
GenericUtility genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateTimeFormat());
Date sysDate = new Date();
String sysDateStr = sdf.format(sysDate);
String sqlInsertInvHold = "INSERT INTO INV_HOLD_DET (TRAN_ID, LINE_NO, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, HOLD_STATUS, STATUS_DATE , SCH_REL_DATE ) " +
" VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmtInsertInvHold = conn.prepareStatement(sqlInsertInvHold);
pstmtInsertInvHold.setString(1, tranIdHold);
pstmtInsertInvHold.setInt(2, maxLineNo);
pstmtInsertInvHold.setString(3, itemCode);
pstmtInsertInvHold.setString(4, siteCode);
pstmtInsertInvHold.setString(5, locCode);
pstmtInsertInvHold.setString(6, lotNo);
pstmtInsertInvHold.setString(7, lotSl);
pstmtInsertInvHold.setString(8, "H");
pstmtInsertInvHold.setTimestamp(9, Timestamp.valueOf( sysDateStr));
pstmtInsertInvHold.setTimestamp(10, Timestamp.valueOf( sysDateStr));
int isInserted = pstmtInsertInvHold.executeUpdate();
System.out.println("@@@@ Hey Row inserted !!!!!!!! .....Total :["+isInserted+"]");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ITMException(e);
}
}
}
/*
Purpose: Local Interface created for StockTransferConf Component
Author: Gulzar on 13/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Local
public interface StockTransferConfLocal extends ActionHandlerLocal
{
public String confirm( String tranId, String xtraParams, String forcedFlag )throws RemoteException,ITMException;
//added by chitranjan for call confirm method
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) throws RemoteException,ITMException;
}
/*
Purpose: Remote Interface created for StockTransferConf Component
Author: Gulzar on 13/09/11
*/
package ibase.webitm.ejb.wms;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Remote
public interface StockTransferConfRemote extends ActionHandlerRemote
{
public String confirm( String tranId, String xtraParams, String forcedFlag ) throws RemoteException,ITMException;
//added by chitranjan for call confirm method
public String confirm( String tranId, String xtraParams,String forcedFlag, Connection conn, boolean connStatus) 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