Commit 1837d432 authored by cshah's avatar cshah

add getdetails method


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91567 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a3c807f4
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
*/ */
package ibase.webitm.ejb.mfg.adv; package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
...@@ -17,6 +15,7 @@ import java.util.*; ...@@ -17,6 +15,7 @@ import java.util.*;
import java.io.*; import java.io.*;
import java.util.Date; import java.util.Date;
import java.sql.*; import java.sql.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import javax.ejb.*; import javax.ejb.*;
...@@ -24,10 +23,12 @@ import javax.naming.InitialContext; ...@@ -24,10 +23,12 @@ import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
//import ibase.webitm.ejb.mfg.adv.BOMStock.BOMStockDtlParams;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.ejb.*; import ibase.ejb.*;
import javax.annotation.*; import javax.annotation.*;
import ibase.system.config.*; import ibase.system.config.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3 import javax.ejb.Stateless; // added for ejb3
...@@ -760,5 +761,213 @@ public String actionHandler(String actionType, String xmlString,String xmlString ...@@ -760,5 +761,213 @@ public String actionHandler(String actionType, String xmlString,String xmlString
} }
return valueXmlString.toString(); return valueXmlString.toString();
} }
// added by chandni shah - 21-Dec-2011
public ArrayList getDetails(String bomCode, String batchQtyD) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
BOMStockDtlParams thisBean = null;
ArrayList stkBOMList = new ArrayList();
String sql = null;
String trackShelfLife = null;
String itemCode = null;
String reqType = null;
Timestamp currDate =null;
double batchQty = 0.0;
double qtyPar = 0.0;
double minQty = 0.0;
double reqQty =0.0;
double stkQty = 0.0;
double nonStkQty = 0.0;
double allockQty = 0.0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
sql = "SELECT FN_SYSDATE() FROM DUAL";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
currDate = rs.getTimestamp(1);
}
System.out.println("Current Date::::::"+currDate);
rs.close();
pstmt.close();
if(bomCode!=null)
{
sql = "SELECT BOM.ITEM_CODE, BOM.BOM_CODE,BOMDET.ITEM_CODE,ITEM_A.DESCR,BOMDET.REQ_TYPE,"
+"ITEM_B.DESCR,SUM(BOMDET.MIN_QTY) AS MIN_QTY,SUM(BOMDET.QTY_PER) AS QTY_PER, MAX(BOM.BATCH_QTY) AS BATCH_QTY,"
+"0.0 AS STK_QTY,0.0 AS NON_STK_QTY,0.0 AS REQ_QTY,0.0 AS ALLOC_QTY FROM BOM,BOMDET,ITEM ITEM_A,"
+"ITEM ITEM_B "
+"WHERE (BOM.BOM_CODE = BOMDET.BOM_CODE ) AND"
+"(BOM.ITEM_CODE = ITEM_A.ITEM_CODE ) AND"
+"(BOMDET.ITEM_CODE= ITEM_B.ITEM_CODE ) AND"
+"(( BOM.BOM_CODE = ?) )"
+"GROUP BY BOM.BOM_CODE,BOM.ITEM_CODE,BOMDET.ITEM_CODE,BOMDET.REQ_TYPE,ITEM_A.DESCR,ITEM_B.DESCR" ;
System.out.println("MainQuery:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomCode);
rs = pstmt.executeQuery();
while(rs.next())
{
itemCode = rs.getString(3);
reqType = rs.getString(5);
minQty = rs.getDouble(7);
qtyPar = rs.getDouble(8);
batchQty = rs.getDouble(9);
reqQty = rs.getDouble(13);
thisBean = new BOMStockDtlParams();
thisBean.itemCode = rs.getString(3);//BOM.ITEM_CODE //change
thisBean.bomCode = rs.getString(2);
thisBean.descr = rs.getString(6);
thisBean.reqType = rs.getString(5);//BOMDET.REQ_TYPE
thisBean.minQty = rs.getDouble(7);//MIN_QTY
thisBean.qtyPar = rs.getDouble(8);//QTY_PER;
thisBean.batchQty = rs.getDouble(9);//BATCH_QTY;
thisBean.stkQty = rs.getDouble(10);
thisBean.nonStkQty = rs.getDouble(11);
thisBean.nonStkQty = rs.getDouble(12);
thisBean.reqQty = rs.getDouble(13);
if(reqType != null && reqType.equalsIgnoreCase("S"))
{
reqQty = (Double.parseDouble(batchQtyD) / batchQty) * qtyPar;
}
else if(reqType != null && reqType.equalsIgnoreCase("P"))
{
reqQty = (qtyPar / batchQty) * Double.parseDouble(batchQtyD);
}
else
{
reqQty = qtyPar;
}
if (reqQty < minQty)
{
reqQty = minQty;
}
thisBean.reqQty = reqQty;
pstmt = null;
pstmt = conn.prepareStatement("select nvl(track_shelf_life,'N') from item where item_code = ?") ;
pstmt.setString(1,itemCode);
ResultSet rs1 = pstmt.executeQuery();
if(rs1.next())
{
trackShelfLife = rs1.getString(1);
}
rs1.close();
StringBuffer sb = new StringBuffer();
sb.append("select nvl(sum(a.quantity - a.alloc_qty),0), nvl(sum(a.alloc_qty),0) from stock a, invstat b "
+" where a.inv_stat = b.inv_stat and a.item_code = ? and b.available = 'Y' and b.stat_type <> 'S' and (a.quantity - nvl(a.alloc_qty,0)) > 0 " );
if(trackShelfLife != null && trackShelfLife.equalsIgnoreCase("Y"))
{
sb.append("and ( a.exp_date is null or a.exp_date >?)");
}
pstmt = conn.prepareStatement(sb.toString());
pstmt.setString(1,itemCode);
if(trackShelfLife != null && trackShelfLife.equalsIgnoreCase("Y"))
{
pstmt.setTimestamp(2,currDate);
}
rs1 = pstmt.executeQuery();
while(rs1.next())
{
thisBean.stkQty = rs1.getDouble(1);
thisBean.allockQty = rs1.getDouble(2);
}
rs1.close();
rs1 = null;
StringBuffer sbn = new StringBuffer();
sbn.append(" select nvl(sum(a.quantity - a.alloc_qty),0), nvl(sum(a.alloc_qty),0) from stock a, invstat b "
+" where a.inv_stat = b.inv_stat and a.item_code = ? and b.available = 'N' and b.stat_type <> 'S' and (a.quantity - nvl(a.alloc_qty,0)) > 0 " );
if(trackShelfLife.equalsIgnoreCase("Y"))
{
sbn.append("and ( a.exp_date is null or a.exp_date >?)");
}
pstmt = conn.prepareStatement(sbn.toString());
pstmt.setString(1,itemCode);
if(trackShelfLife.equalsIgnoreCase("Y"))
{
pstmt.setTimestamp(2,currDate);
}
rs1 = pstmt.executeQuery();
while(rs1.next())
{
thisBean.nonStkQty = rs1.getDouble(1);
thisBean.allockQty = rs1.getDouble(2);
}
rs1.close();
rs1 = null;
stkBOMList.add(thisBean);
}
}
}
catch (SQLException se)
{
System.out.println("Exception : BOMStockEJB : actionStock " +se.getMessage());
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMStockEJB : actionStock :(Document dom)" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (conn != null)
{
conn.close();
conn = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}catch(Exception e){}
}
return stkBOMList;
}
class BOMStockDtlParams implements Serializable
{
HashMap BOMStockMap = new HashMap();
String bomCode=null;
String trackShelfLife = null;
String itemCode = null;
String reqType = null;
String batchQtyD = null;
String descr = null;
double allockQty = 0.0;
double batchQty = 0.0;
double qtyPar = 0.0;
double minQty = 0.0;
double reqQty =0.0;
double stkQty = 0.0;
double nonStkQty = 0.0;
Timestamp currDate =null;
}
// Ended by chandni shah - 21-Dec-2011
} }
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv; package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.ArrayList;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
...@@ -13,4 +14,7 @@ public interface BOMActLocal extends ActionHandlerLocal//,EJBObject ...@@ -13,4 +14,7 @@ public interface BOMActLocal extends ActionHandlerLocal//,EJBObject
{ {
public String actionHandler() throws RemoteException,ITMException; public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException; public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
// added by chandni shah - 21-Dec-2011
public ArrayList getDetails(String bomCode, String batchQtyD) throws RemoteException,ITMException;
} }
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv; package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.ArrayList;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
...@@ -13,4 +14,6 @@ public interface BOMActRemote extends ActionHandlerRemote//, EJBObject ...@@ -13,4 +14,6 @@ public interface BOMActRemote extends ActionHandlerRemote//, EJBObject
{ {
public String actionHandler() throws RemoteException,ITMException; public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException; public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
// added by chandni shah - 21-Dec-2011
public ArrayList getDetails(String bomCode, String batchQtyD) throws RemoteException,ITMException;
} }
\ No newline at end of file
...@@ -4,10 +4,12 @@ import ibase.system.config.ConnDriver; ...@@ -4,10 +4,12 @@ import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB; import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB; import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.mfg.MfgCommon; import ibase.webitm.ejb.mfg.MfgCommon;
// import ibase.webitm.ejb.mfg.adv.WOStock.woStockDtlParams;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.Serializable;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Date; import java.sql.Date;
...@@ -17,6 +19,7 @@ import java.sql.SQLException; ...@@ -17,6 +19,7 @@ import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import javax.ejb.CreateException; import javax.ejb.CreateException;
...@@ -2599,4 +2602,155 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -2599,4 +2602,155 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
System.out.println("retString ::: " + retString); System.out.println("retString ::: " + retString);
return retString.toString(); return retString.toString();
} }
// added by chandni shah - 21-Dec-2011
public ArrayList getDetails(String woCode) throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
woStockDtlParams thisBean = null;
ArrayList stkWoList = new ArrayList();
String sql = null;
String trackShelfLife = null;
String itemCode = null;
Timestamp currDate =null;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
sql = "SELECT FN_SYSDATE() FROM DUAL";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
currDate = rs.getTimestamp(1);
}
System.out.println("Current Date::::::"+currDate);
rs.close();
pstmt.close();
if(woCode!=null)
{
sql =" select a.item_code,b.descr from workorder a ,item b "
+" where a.item_code = b.item_code "
+" and a.work_order = ? ";
System.out.println("MainQuery:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,woCode);
rs = pstmt.executeQuery();
while(rs.next())
{
itemCode = rs.getString(1);
thisBean = new woStockDtlParams();
thisBean.itemCode = rs.getString(1);
thisBean.descr = rs.getString(2);
pstmt = null;
pstmt = conn.prepareStatement("select nvl(track_shelf_life,'N') from item where item_code = ?") ;
pstmt.setString(1,itemCode);
ResultSet rs1 = pstmt.executeQuery();
if(rs1.next())
{
trackShelfLife = rs1.getString(1);
}
rs1.close();
StringBuffer sb = new StringBuffer();
sb.append("select nvl(sum(a.quantity - a.alloc_qty),0), nvl(sum(a.alloc_qty),0) from stock a, invstat b "
+" where a.inv_stat = b.inv_stat and a.item_code = ? and b.available = 'Y' and b.stat_type <> 'S' and (a.quantity - nvl(a.alloc_qty,0)) > 0 " );
if(trackShelfLife != null && trackShelfLife.equalsIgnoreCase("Y"))
{
sb.append("and ( a.exp_date is null or a.exp_date >?)");
}
pstmt = conn.prepareStatement(sb.toString());
pstmt.setString(1,itemCode);
if(trackShelfLife != null && trackShelfLife.equalsIgnoreCase("Y"))
{
pstmt.setTimestamp(2,currDate);
}
rs1 = pstmt.executeQuery();
while(rs1.next())
{
thisBean.stkQty = rs1.getDouble(1);
thisBean.allockQty = rs1.getString(2);
}
rs1.close();
rs1 = null;
StringBuffer sbn = new StringBuffer();
sbn.append(" select nvl(sum(a.quantity - a.alloc_qty),0), nvl(sum(a.alloc_qty),0) from stock a, invstat b "
+" where a.inv_stat = b.inv_stat and a.item_code = ? and b.available = 'N' and b.stat_type <> 'S' and (a.quantity - nvl(a.alloc_qty,0)) > 0 " );
if(trackShelfLife.equalsIgnoreCase("Y"))
{
sbn.append("and ( a.exp_date is null or a.exp_date >?)");
}
pstmt = conn.prepareStatement(sbn.toString());
pstmt.setString(1,itemCode);
if(trackShelfLife.equalsIgnoreCase("Y"))
{
pstmt.setTimestamp(2,currDate);
}
rs1 = pstmt.executeQuery();
while(rs1.next())
{
thisBean.nonStkQty = rs1.getDouble(1);
thisBean.allockQty = rs1.getString(2);
}
rs1.close();
rs1 = null;
stkWoList.add(thisBean);
}
}
}
catch (SQLException se)
{
System.out.println("Exception : BOMStockEJB : actionStock " +se.getMessage());
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMStockEJB : actionStock :(Document dom)" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
if (conn != null)
{
conn.close();
conn = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}catch(Exception e){}
}
return stkWoList;
}
class woStockDtlParams implements Serializable
{
HashMap BOMStockMap = new HashMap();
String woCode=null;
String trackShelfLife = null;
String itemCode = null;
String allockQty = null;
String descr = null;
double stkQty = 0.0;
double nonStkQty = 0.0;
Timestamp currDate =null;
}
// Ended by chandni shah - 21-Dec-2011
} }
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv; package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.ArrayList;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal; import ibase.webitm.ejb.ActionHandlerLocal;
...@@ -12,5 +13,6 @@ public interface WOrderIssueActLocal extends ActionHandlerLocal//,EJBObject ...@@ -12,5 +13,6 @@ public interface WOrderIssueActLocal extends ActionHandlerLocal//,EJBObject
{ {
public String actionHandler() throws RemoteException,ITMException; public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException; public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
// added by chandni shah - 21-Dec-2011
public ArrayList getDetails(String woCode) throws RemoteException,ITMException;
} }
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv; package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.ArrayList;
//import javax.ejb.EJBObject; //import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote; import ibase.webitm.ejb.ActionHandlerRemote;
...@@ -12,5 +13,6 @@ public interface WOrderIssueActRemote extends ActionHandlerRemote//, EJBObject ...@@ -12,5 +13,6 @@ public interface WOrderIssueActRemote extends ActionHandlerRemote//, EJBObject
{ {
public String actionHandler() throws RemoteException,ITMException; public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException; public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
// added by chandni shah - 21-Dec-2011
public ArrayList getDetails(String woCode) throws RemoteException,ITMException;
} }
\ No newline at end of file
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