Commit fff4603c authored by vkadam's avatar vkadam

BATCH_ID auto generation, validation, and post save for process window and manual stock allocation.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97150 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f059ed02
/***************
* VALLABH KADAM
* StkAllocPostSave
* request id [D14JSUN005]
* 19/JAN/15
* ********************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.util.*;
import java.util.Date;
import java.text.DateFormat;
import java.sql.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.text.SimpleDateFormat;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.TransIDGenerator;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class StkAllocPostSave extends ValidatorEJB implements StkAllocPostSaveLocal,StkAllocPostSaveRemote{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave( String domString, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
String retString = "";
boolean isLocalConn = false;
PreparedStatement pstmt = null;
Document dom = null;
ResultSet rs =null;
boolean isError = false;
int cnt=0;
String tranId = "";
String sql = null;
String batchId="",siteCode="",keyString="",keyCol="",tranSer1="";
CommonConstants commonConstants = new CommonConstants();
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
dom = genericUtility.parseString(domString);
tranId = GenericUtility.getInstance().getColumnValue("tran_id",dom);
System.out.println("Tran id :- ["+tranId+"]");
/**
* IF BATCH_ID from SORD_ALLOC
* is null for selected tranId
* Generate new tranId
* */
sql="select batch_id from sord_alloc where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, tranId);
rs = pstmt.executeQuery();
while( rs.next())
{
batchId=rs.getString("batch_id");
}
rs.close();
rs=null;
pstmt.close();
pstmt =null;
if(batchId==null || batchId.trim().length()<=0)
{
System.out.println("********************Batch id found null Generating Batch id now ************************");
//Generate new BATCH_ID here
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE lower(TRAN_WINDOW) = 'w_sordalloc'";
System.out.println("keyStringQuery--------->>"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
rs.close();
rs=null;
pstmt.close();
pstmt =null;
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
String xmlValues = "";
String tranDateStr = getCurrdateAppFormat();
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);
batchId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("@@@@ generated BATCH ID ******** :["+batchId+"]");
// UPDATE auto generated BATCH_ID for tranId.
sql="update sord_alloc set batch_id=? where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,batchId.trim());
pstmt.setString(2,tranId );
cnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Update count of BATCH_ID :- "+cnt);
// UPDATE END
}
}
catch(Exception e)
{
System.out.println("Exception :==>\n"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
{
if( isError )
{
conn.rollback();
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if ( isLocalConn )
{
if ( ! isError )
{
conn.commit();
}
conn.close();
conn = null;
}
}
}
catch(Exception e)
{
System.out.println("Exception :==>\n"+e.getMessage());
throw new ITMException(e);
}
}
System.out.println("Return string :"+retString);
return retString;
}
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
}
/***************
* VALLABH KADAM
* StkAllocPostSaveLocal
* request id [D14JSUN005]
* 19/JAN/15
* ********************/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.util.ArrayList;
import java.sql.Connection;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; //added for ejb3
@Local // added for ejb3
public interface StkAllocPostSaveLocal extends ValidatorLocal//, EJBObject
{
public String postSave( String domString, String editFlag, String xtraParams,
Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
/***************
* VALLABH KADAM
* StkAllocPostSaveRemote
* request id [D14JSUN005]
* 19/JAN/15
* ********************/
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.util.ArrayList;
import java.sql.Connection;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface StkAllocPostSaveRemote extends ValidatorRemote//, EJBObject
{
public String postSave( String domString, String editFlag, String xtraParams,
Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ import ibase.system.config.ConnDriver; ...@@ -13,6 +13,7 @@ import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.util.*; import java.util.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.rmi.RemoteException; import java.rmi.RemoteException;
...@@ -20,9 +21,11 @@ import java.security.AllPermission; ...@@ -20,9 +21,11 @@ import java.security.AllPermission;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
...@@ -78,7 +81,7 @@ public class StockAllocIc extends ValidatorEJB implements StockAllocIcLocal, Sto ...@@ -78,7 +81,7 @@ public class StockAllocIc extends ValidatorEJB implements StockAllocIcLocal, Sto
String locCode = ""; String locCode = "";
String quantity = ""; String quantity = "";
String lineNoSord = ""; String lineNoSord = "";
String expLev = ""; String expLev = "",batchId="";
//Changed By Rohan on 10/07/12 To add validation sale order.start //Changed By Rohan on 10/07/12 To add validation sale order.start
String saleOrderHdr = ""; String saleOrderHdr = "";
String sqlSOrder = ""; String sqlSOrder = "";
...@@ -235,6 +238,35 @@ public class StockAllocIc extends ValidatorEJB implements StockAllocIcLocal, Sto ...@@ -235,6 +238,35 @@ public class StockAllocIc extends ValidatorEJB implements StockAllocIcLocal, Sto
} }
} }
else if(childNodeName.equalsIgnoreCase("batch_id"))
{
batchId = genericUtility.getColumnValue("batch_id", dom);
System.out.println("Batch ID :- ----"+batchId);
if(batchId!=null && batchId.trim().length()>0){
// if(batchId!=null){
System.out.println("*****IN if VALIDATION *****");
sql="select count(*) as cnt from sord_alloc where batch_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,batchId);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Batch id cnt at validation :- "+cnt);
if(cnt<=0)
{
errCode = "VTBCHIDINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
} }
......
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