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;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.util.*;
import java.text.SimpleDateFormat;
import java.rmi.RemoteException;
......@@ -20,9 +21,11 @@ import java.security.AllPermission;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3
......@@ -78,7 +81,7 @@ public class StockAllocIc extends ValidatorEJB implements StockAllocIcLocal, Sto
String locCode = "";
String quantity = "";
String lineNoSord = "";
String expLev = "";
String expLev = "",batchId="";
//Changed By Rohan on 10/07/12 To add validation sale order.start
String saleOrderHdr = "";
String sqlSOrder = "";
......@@ -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());
}
}
}
}
......
......@@ -9,11 +9,14 @@ import java.util.*;
import java.util.Date;
import java.sql.*;
import java.io.*;
//import webitm4.*;
//import SessionManager.*;
import org.omg.CORBA.ORB;
import org.w3c.dom.*;
import java.util.Properties;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
......@@ -23,7 +26,6 @@ import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.adv.StockAllocPrc;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
import ibase.ejb.*;
import ibase.system.config.*;
......@@ -31,9 +33,11 @@ import ibase.system.config.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
......@@ -148,8 +152,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
String resultString = "";
String sql1 ="",custCodeSord = "",waveType = "", activeAllow="";
String resrvLoc = "",casePickLoc = "",activePickLoc = "" ,deepStoreLoc = "" ,partialResrvLoc = "";//added by kunal on 15/NOV/13
String orderByStkStr = "" , disOpt = "";
int waveType1 = 0;
String orderByStkStr = "" , disOpt = "",batchId="";
int waveType1 = 0,cnt=0;
double pendingQty = 0, minSelfLife = 0;
Connection conn = null;
ResultSet rs = null;
......@@ -334,6 +338,36 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
errString = itmDBAccessEJB.getErrorString("","VTMRPPARM","","",conn);
return errString;
}
/**
* VALLABH KADAM
* Validation for
* if BATCH_ID is not null check exist in SORD_ALLOC
* */
batchId=genericUtility.getColumnValue("batch_id",headerDom);
System.out.println("Batch id at validation :- "+batchId);
if(batchId!=null && batchId.trim().length()>0)
{
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())
{
// waveType = rs2.getString("wave_type");
cnt=rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("Batch id cnt at validation :- "+cnt);
if(cnt<=0){
errString = itmDBAccessEJB.getErrorString("","VTBCHIDINV","","",conn);
return errString;
}
}
//added by Kunal on 18/NOV/13
disOpt = checkNull( genericUtility.getColumnValue("dis_opt",headerDom));
System.out.println("Display option="+disOpt);
......@@ -933,6 +967,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
String childNodeName = "";
String errCode = "";
//String siteCode = this.siteCode; // 21/08/12 manoharan get the shipping site
String siteCode="";
String postOrderFg = this.postOrderFg;
String saleOrder = null;
String expLev = null ;
......@@ -943,7 +978,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
String lotSl= null;
String lotNo = null;
String locDescr = null;
String itemShDescr = null;
String itemShDescr = null,batchId=null,keyString="",keyCol="",tranSer1="";
double allocQty = 0 , pendingQty = 0;
double quantity = 0;
double qtyAvailAlloc = 0;
......@@ -1291,6 +1326,67 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
pstmt.close();
pstmt = null;
}
/**
* Generate BATCH_ID if not exist.
* VALLABH KADAM
* */
batchId=genericUtility.getColumnValue("batch_id",headerDom);
System.out.println("Initial Batch Id :- ["+batchId+"]");
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+"]");
}else
{
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){
errString = itmDBAccessEJB.getErrorString("","VTBCHIDINV","","",conn);
return errString;
}
}
errString = ""; //added by kunal for handle multiple error message 31/DEC/13
}// out for loop
//added by ritesh on 07/10/13 for request DI3ESUN009 start
......@@ -1305,7 +1401,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
String key = (String)it.next();
HashMap soLnValues =(HashMap) map.get(key);
System.out.println("swecondry map "+soLnValues);
errString = sorderAllocate(soLnValues,xtraParams);
// errString = sorderAllocate(soLnValues,xtraParams); //VALLABH without BATCH_ID
errString = sorderAllocate(soLnValues,xtraParams,batchId.trim());
// errString = sorderAllocate(saleOrder, lineNo, itemCode, allocQty, expLev ,holdFlag,activeAllow,xtraParams);
// ADDED BY RITESH ON 09/08/14 END
......@@ -1572,6 +1669,27 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
}
return input;
}
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;
}
/**
* @param saleOrder
......@@ -1585,7 +1703,8 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
* @throws ITMException
*/
// private String sorderAllocate(String saleOrder, String lineNo, String itemCode, double allocQty, String expLev ,String holdFlag,String activeAllow,String xtraParams) throws ITMException
private String sorderAllocate(HashMap soLnValues,String xtraParams) throws ITMException
// private String sorderAllocate(HashMap soLnValues,String xtraParams) throws ITMException VALLABH without BATCH_ID
private String sorderAllocate(HashMap soLnValues,String xtraParams, String batchId) throws ITMException
{
System.out.println("sorderAllocate calling .260814...RITESH..........");
String saleOrder = "", lineNo = "", itemCode = "";
......@@ -2155,6 +2274,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
if(isHdr)
{
System.out.println("New Record Inserting*****250814****============***********");
System.out.println("BATCH id while SAVE XML generation :- "+batchId);
isHdr = false;
isdetFlag = false;
xmlBuff = new StringBuffer();
......@@ -2193,6 +2313,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
xmlBuff.append("<add_term><![CDATA["+ chgTerm +"]]></add_term>");
xmlBuff.append("<add_user><![CDATA["+ chgUser +"]]></add_user>");
xmlBuff.append("<active_pick_allow><![CDATA["+ activeAllow +"]]></active_pick_allow>");
xmlBuff.append("<batch_id><![CDATA["+ batchId +"]]></batch_id>"); //VALLABH BATCH_ID to save.
xmlBuff.append("<alloc_source><![CDATA[P]]></alloc_source>");
xmlBuff.append("<alloc_flag><![CDATA[A]]></alloc_flag>");
xmlBuff.append("</Detail1>");
......@@ -2452,7 +2573,6 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
System.out.println("@@@@@2: xmlString:"+xmlBuff.toString());
}
System.out.println("...............just before savdata()");
System.out.println("Getting site code value");
siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("==site code =="+siteCode);
System.out.println("Printing xmlString"+xmlString);
......@@ -2470,7 +2590,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
int endIndex = arrayForTranId[1].indexOf("</TranID>");
System.out.println("***********going for confirmation************");
String tranIdForIssue = arrayForTranId[1].substring(0,endIndex);
System.out.println("tranIdForIssue"+ tranIdForIssue);
System.out.println("@@@@@@@@ Tran id for conformation :- "+ tranIdForIssue);
retString=allocPrc.confirm(tranIdForIssue, xtraParams, "",conn);
System.out.println("@@@@@@3: retString Confirm"+retString);
......
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