Commit 1db05d1e authored by manohar's avatar manohar

dbo. added for sql server


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91641 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 31afad57
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import ibase.webitm.utility.*; import ibase.webitm.utility.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.system.config.*; import ibase.system.config.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.system.config.AppConnectParm; import ibase.system.config.AppConnectParm;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import ibase.utility.CommonConstants;
import java.sql.*;
import java.io.Serializable; import java.util.*;
import javax.ejb.*; import java.sql.*;
import javax.naming.InitialContext; import java.io.Serializable;
//import javax.ejb.SessionBean; import javax.ejb.*;
import javax.ejb.Stateless; // added for ejb3 import javax.naming.InitialContext;
//import javax.ejb.SessionBean;
@Stateless // added for ejb3 import javax.ejb.Stateless; // added for ejb3
public class StockHelp implements StockHelpLocal,StockHelpRemote
{ @Stateless // added for ejb3
/* public void ejbCreate() throws RemoteException,CreateException public class StockHelp implements StockHelpLocal,StockHelpRemote
{ {
CommonConstants commonConstants = new CommonConstants();
} /* public void ejbCreate() throws RemoteException,CreateException
{
public void ejbRemove()
{ }
}
public void ejbRemove()
public void ejbActivate() {
{ }
}
public void ejbActivate()
public void ejbPassivate() {
{ }
} */
public void ejbPassivate()
public void setSessionContext(SessionContext mSessionContext) {
{ } */
}
// 24/08/11 manoharan public void setSessionContext(SessionContext mSessionContext)
public String getItemDescr(String itemCode) throws ITMException {
{ }
String itemDescr = ""; // 24/08/11 manoharan
GenericUtility genericUtility = null; public String getItemDescr(String itemCode) throws ITMException
genericUtility = GenericUtility.getInstance(); {
PreparedStatement pstmt = null; String itemDescr = "";
ResultSet rs = null; GenericUtility genericUtility = null;
Connection conn = null; genericUtility = GenericUtility.getInstance();
try PreparedStatement pstmt = null;
{ ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); Connection conn = null;
conn = connDriver.getConnectDB("DriverITM"); try
conn.setAutoCommit(false); {
connDriver = null; ConnDriver connDriver = new ConnDriver();
pstmt = conn.prepareStatement("select descr from item where item_code = ?"); conn = connDriver.getConnectDB("DriverITM");
pstmt.setString(1,itemCode); conn.setAutoCommit(false);
rs = pstmt.executeQuery(); connDriver = null;
if(rs.next()) pstmt = conn.prepareStatement("select descr from item where item_code = ?");
{ pstmt.setString(1,itemCode);
itemDescr = rs.getString(1); rs = pstmt.executeQuery();
} if(rs.next())
rs.close(); {
rs = null; itemDescr = rs.getString(1);
pstmt.close(); }
pstmt = null; rs.close();
rs = null;
} pstmt.close();
catch (Exception e) pstmt = null;
{
e.printStackTrace(); }
} catch (Exception e)
finally {
{ e.printStackTrace();
try }
{ finally
genericUtility = null; {
if(pstmt != null) try
{ {
pstmt.close(); genericUtility = null;
pstmt = null; if(pstmt != null)
} {
if(rs != null) pstmt.close();
{ pstmt = null;
rs.close(); }
rs = null; if(rs != null)
} {
if(conn != null) rs.close();
{ rs = null;
conn.close(); }
conn=null; if(conn != null)
} {
} conn.close();
catch(Exception e) conn=null;
{ }
System.out.println("Exception :StockHelpEJB:==>\n"+e.getMessage()); }
} catch(Exception e)
} {
return itemDescr; System.out.println("Exception :StockHelpEJB:==>\n"+e.getMessage());
} }
// end 24/08/11 manoharan }
public ArrayList getDetails(String siteCode, String itemCode) throws ITMException return itemDescr;
{ }
GenericUtility genericUtility = null; // end 24/08/11 manoharan
genericUtility = GenericUtility.getInstance(); public ArrayList getDetails(String siteCode, String itemCode) throws ITMException
PreparedStatement pstmt = null; {
ResultSet rs = null; GenericUtility genericUtility = null;
Connection conn = null; genericUtility = GenericUtility.getInstance();
StockDtlParams thisBean = null; PreparedStatement pstmt = null;
ArrayList stkHelpList = new ArrayList(); ResultSet rs = null;
Connection conn = null;
try StockDtlParams thisBean = null;
{ ArrayList stkHelpList = new ArrayList();
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); try
conn.setAutoCommit(false); {
connDriver = null; ConnDriver connDriver = new ConnDriver();
int i = 1; conn = connDriver.getConnectDB("DriverITM");
double lotWiseQuant = 0, lotWiseAllocQuant = 0, lotWiseAvailQuant = 0; conn.setAutoCommit(false);
double lotWiseHoldQuant = 0, avl = 0; connDriver = null;
String quantKey = "", sql = ""; int i = 1;
String allcQuantKey = "", prevLocCode = "", prevLotNo = ""; double lotWiseQuant = 0, lotWiseAllocQuant = 0, lotWiseAvailQuant = 0;
String holdQuanKey = "", prevLotSl = ""; double lotWiseHoldQuant = 0, avl = 0;
System.out.println("itemCode>>>>>>>>>>>>>>>>"+itemCode); String quantKey = "", sql = "";
System.out.println("siteCode>>>>>>>>>>>>>>>>"+siteCode); String allcQuantKey = "", prevLocCode = "", prevLotNo = "";
String holdQuanKey = "", prevLotSl = "";
sql = "SELECT stock.site_code ,site.descr ,stock.item_code ,item.descr ,stock.loc_code , " System.out.println("itemCode>>>>>>>>>>>>>>>>"+itemCode);
+" stock.lot_no ,stock.lot_sl ,location.inv_stat ,stock.retest_date ,stock.exp_date ," System.out.println("siteCode>>>>>>>>>>>>>>>>"+siteCode);
+" sum(stock.quantity) qty,sum(stock.alloc_qty) alloc_qty,invstat.available ,stock.unit , "
+" stock.potency_perc ,stock.batch_no ,stock.dimension ,stock.supp_code__mfg , " sql = "SELECT stock.site_code ,site.descr ,stock.item_code ,item.descr ,stock.loc_code , "
+" fn_ppo_qty('"+siteCode+"','"+itemCode+"') as ppo_qty,fn_pind_qty('"+siteCode+"','"+itemCode+"') as pind_qty,stock.pack_code , " +" stock.lot_no ,stock.lot_sl ,location.inv_stat ,stock.retest_date ,stock.exp_date ,"
+" stock.qty_per_art ,stock.batch_size , " +" sum(stock.quantity) qty,sum(stock.alloc_qty) alloc_qty,invstat.available ,stock.unit , "
+" sum(case when stock.hold_qty is null then 0 else stock.hold_qty end) hold_qty, " +" stock.potency_perc ,stock.batch_no ,stock.dimension ,stock.supp_code__mfg , ";
+" stock.mfg_date, stock.no_art, stock.rate " if((CommonConstants.DB_NAME).equalsIgnoreCase("mssql"))
+" FROM invstat ,item ,location ,site ,stock " {
+" WHERE ( location.inv_stat = invstat.inv_stat ) " sql = sql + " dbo.fn_ppo_qty('"+siteCode+"','"+itemCode+"') as ppo_qty,dbo.fn_pind_qty('"+siteCode+"','"+itemCode+"') as pind_qty,stock.pack_code , ";
+" and ( stock.loc_code = location.loc_code ) " }
+" and ( stock.item_code = item.item_code ) " else
+" and ( site.site_code = stock.site_code ) " {
+" and ( ( stock.item_code = '"+itemCode+"' ) and ( stock.site_code = '"+siteCode+"' ) ) " sql = sql + " fn_ppo_qty('"+siteCode+"','"+itemCode+"') as ppo_qty,fn_pind_qty('"+siteCode+"','"+itemCode+"') as pind_qty,stock.pack_code , ";
+" and ( invstat.stat_type <> 'S' ) " }
+" and ( stock.quantity <> 0 ) "
+" GROUP BY stock.site_code ,site.descr ,stock.item_code ,item.descr ,stock.loc_code , " sql = sql + " stock.qty_per_art ,stock.batch_size , "
+" stock.lot_no ,stock.lot_sl ,location.inv_stat ,invstat.available ,stock.retest_date , " +" sum(case when stock.hold_qty is null then 0 else stock.hold_qty end) hold_qty, "
+" stock.exp_date ,stock.unit ,stock.potency_perc ,stock.batch_no ,stock.dimension , " +" stock.mfg_date, stock.no_art, stock.rate "
+" stock.supp_code__mfg ,stock.pack_code ,stock.qty_per_art , " +" FROM invstat ,item ,location ,site ,stock "
+" stock.batch_size, stock.mfg_date, stock.no_art, stock.rate " +" WHERE ( location.inv_stat = invstat.inv_stat ) "
+" ORDER BY stock.site_code ASC, stock.item_code ASC, " +" and ( stock.loc_code = location.loc_code ) "
+" stock.loc_code ASC, stock.lot_no ASC, stock.lot_sl ASC, location.inv_stat ASC "; +" and ( stock.item_code = item.item_code ) "
+" and ( site.site_code = stock.site_code ) "
pstmt = conn.prepareStatement(sql); +" and ( ( stock.item_code = '"+itemCode+"' ) and ( stock.site_code = '"+siteCode+"' ) ) "
rs = pstmt.executeQuery(); +" and ( invstat.stat_type <> 'S' ) "
while(rs.next()) +" and ( stock.quantity <> 0 ) "
{ +" GROUP BY stock.site_code ,site.descr ,stock.item_code ,item.descr ,stock.loc_code , "
thisBean = new StockDtlParams(); +" stock.lot_no ,stock.lot_sl ,location.inv_stat ,invstat.available ,stock.retest_date , "
+" stock.exp_date ,stock.unit ,stock.potency_perc ,stock.batch_no ,stock.dimension , "
thisBean.itemCode = rs.getString(3); +" stock.supp_code__mfg ,stock.pack_code ,stock.qty_per_art , "
thisBean.currLocCode = rs.getString(5); +" stock.batch_size, stock.mfg_date, stock.no_art, stock.rate "
thisBean.currLotNo = rs.getString(6); +" ORDER BY stock.site_code ASC, stock.item_code ASC, "
thisBean.currLotSl = rs.getString(7); +" stock.loc_code ASC, stock.lot_no ASC, stock.lot_sl ASC, location.inv_stat ASC ";
thisBean.invStat = rs.getString(8);
thisBean.retestDate = rs.getString(9) == null ? "" : genericUtility.getValidDateString(rs.getString(9),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); pstmt = conn.prepareStatement(sql);
thisBean.expDate = rs.getString(10) == null ? "" : genericUtility.getValidDateString(rs.getString(10),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); rs = pstmt.executeQuery();
thisBean.quantity = rs.getDouble(11); while(rs.next())
thisBean.allocQuant = rs.getDouble(12); {
thisBean.available = rs.getString(13); thisBean = new StockDtlParams();
thisBean.unit = rs.getString(14);
thisBean.potencyPerc = rs.getString(15); thisBean.itemCode = rs.getString(3);
thisBean.batchNo = rs.getString(16); thisBean.currLocCode = rs.getString(5);
thisBean.dimention = rs.getString(17); thisBean.currLotNo = rs.getString(6);
thisBean.suppCodeMfg = rs.getString(18); thisBean.currLotSl = rs.getString(7);
thisBean.ppoQty = rs.getString(19); thisBean.invStat = rs.getString(8);
thisBean.pindQty = rs.getString(20); thisBean.retestDate = rs.getString(9) == null ? "" : genericUtility.getValidDateString(rs.getString(9),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
thisBean.packCode = rs.getString(21); thisBean.expDate = rs.getString(10) == null ? "" : genericUtility.getValidDateString(rs.getString(10),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
thisBean.qtyPerArt = rs.getString(22); thisBean.quantity = rs.getDouble(11);
thisBean.batchSize = rs.getString(23); thisBean.allocQuant = rs.getDouble(12);
thisBean.holdQuant = rs.getDouble(24); thisBean.available = rs.getString(13);
thisBean.mfgDate = rs.getString(25) == null ? "" : genericUtility.getValidDateString(rs.getString(25),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat()); thisBean.unit = rs.getString(14);
thisBean.noArt = rs.getString(26); //Changed By Dipak Chattar On 15 Nov 2011 thisBean.potencyPerc = rs.getString(15);
thisBean.rate = rs.getString(27); ////Changed By Dipak Chattar On 15 Nov 2011 thisBean.batchNo = rs.getString(16);
thisBean.currDateTs = getCurrdateTimestmp(); thisBean.dimention = rs.getString(17);
avl = thisBean.quantity - thisBean.allocQuant; thisBean.suppCodeMfg = rs.getString(18);
thisBean.netAvailable = Double.toString(avl);//balance thisBean.ppoQty = rs.getString(19);
if( thisBean.currLocCode != null && thisBean.currLotNo != null ) thisBean.pindQty = rs.getString(20);
{ thisBean.packCode = rs.getString(21);
if( thisBean.currLocCode.equals(prevLocCode) && thisBean.currLotNo.equals(prevLotNo) ) thisBean.qtyPerArt = rs.getString(22);
{ thisBean.batchSize = rs.getString(23);
lotWiseQuant = lotWiseQuant + thisBean.quantity; thisBean.holdQuant = rs.getDouble(24);
lotWiseAllocQuant = lotWiseAllocQuant + thisBean.allocQuant; thisBean.mfgDate = rs.getString(25) == null ? "" : genericUtility.getValidDateString(rs.getString(25),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
//lotWiseAvailQuant = lotWiseAvailQuant + thisBean.availQuant thisBean.noArt = rs.getString(26); //Changed By Dipak Chattar On 15 Nov 2011
lotWiseHoldQuant = lotWiseHoldQuant + thisBean.holdQuant; thisBean.rate = rs.getString(27); ////Changed By Dipak Chattar On 15 Nov 2011
quantKey = "LWQ" + i; thisBean.currDateTs = getCurrdateTimestmp();
allcQuantKey = "LAQ" + i; avl = thisBean.quantity - thisBean.allocQuant;
holdQuanKey = "LHQ" + i; thisBean.netAvailable = Double.toString(avl);//balance
(thisBean.lotQuantMap).put(quantKey, new Double(lotWiseQuant) ); if( thisBean.currLocCode != null && thisBean.currLotNo != null )
thisBean.lotQuantMap.put(allcQuantKey, new Double(lotWiseAllocQuant)); {
thisBean.lotQuantMap.put(holdQuanKey, new Double(lotWiseHoldQuant)); if( thisBean.currLocCode.equals(prevLocCode) && thisBean.currLotNo.equals(prevLotNo) )
} {
else lotWiseQuant = lotWiseQuant + thisBean.quantity;
{ lotWiseAllocQuant = lotWiseAllocQuant + thisBean.allocQuant;
i++; //lotWiseAvailQuant = lotWiseAvailQuant + thisBean.availQuant
lotWiseQuant = 0; lotWiseHoldQuant = lotWiseHoldQuant + thisBean.holdQuant;
lotWiseAllocQuant = 0; quantKey = "LWQ" + i;
lotWiseAvailQuant = 0; allcQuantKey = "LAQ" + i;
lotWiseHoldQuant = 0; holdQuanKey = "LHQ" + i;
lotWiseQuant = lotWiseQuant + thisBean.quantity; (thisBean.lotQuantMap).put(quantKey, new Double(lotWiseQuant) );
lotWiseAllocQuant = lotWiseAllocQuant + thisBean.allocQuant; thisBean.lotQuantMap.put(allcQuantKey, new Double(lotWiseAllocQuant));
//lotWiseAvailQuant = lotWiseAvailQuant + thisBean.availQuant; thisBean.lotQuantMap.put(holdQuanKey, new Double(lotWiseHoldQuant));
lotWiseHoldQuant = lotWiseHoldQuant + thisBean.holdQuant; }
quantKey = "LWQ" + i; else
allcQuantKey = "LAQ" + i; {
holdQuanKey = "LHQ" + i; i++;
thisBean.lotQuantMap.put(quantKey, new Double(lotWiseQuant)); lotWiseQuant = 0;
thisBean.lotQuantMap.put(allcQuantKey, new Double(lotWiseAllocQuant)); lotWiseAllocQuant = 0;
thisBean.lotQuantMap.put(holdQuanKey, new Double(lotWiseHoldQuant)); lotWiseAvailQuant = 0;
} lotWiseHoldQuant = 0;
} lotWiseQuant = lotWiseQuant + thisBean.quantity;
stkHelpList.add(thisBean); lotWiseAllocQuant = lotWiseAllocQuant + thisBean.allocQuant;
prevLocCode = thisBean.currLocCode; //lotWiseAvailQuant = lotWiseAvailQuant + thisBean.availQuant;
prevLotNo = thisBean.currLotNo; lotWiseHoldQuant = lotWiseHoldQuant + thisBean.holdQuant;
prevLotSl = thisBean.currLotSl; quantKey = "LWQ" + i;
} allcQuantKey = "LAQ" + i;
} holdQuanKey = "LHQ" + i;
catch (Exception e) thisBean.lotQuantMap.put(quantKey, new Double(lotWiseQuant));
{ thisBean.lotQuantMap.put(allcQuantKey, new Double(lotWiseAllocQuant));
e.printStackTrace(); thisBean.lotQuantMap.put(holdQuanKey, new Double(lotWiseHoldQuant));
} }
finally }
{ stkHelpList.add(thisBean);
try prevLocCode = thisBean.currLocCode;
{ prevLotNo = thisBean.currLotNo;
genericUtility = null; prevLotSl = thisBean.currLotSl;
if(pstmt != null) }
{ }
pstmt.close(); catch (Exception e)
pstmt = null; {
} e.printStackTrace();
if(rs != null) }
{ finally
rs.close(); {
rs = null; try
} {
if(conn != null) genericUtility = null;
{ if(pstmt != null)
conn.close(); {
conn=null; pstmt.close();
} pstmt = null;
} }
catch(Exception e) if(rs != null)
{ {
System.out.println("Exception :StockHelpEJB:==>\n"+e.getMessage()); rs.close();
} rs = null;
} }
return stkHelpList; if(conn != null)
} {
private Timestamp getCurrdateTimestmp() conn.close();
{ conn=null;
String s = ""; }
Timestamp timestamp = null; }
GenericUtility genericUtility = GenericUtility.getInstance(); catch(Exception e)
try {
{ System.out.println("Exception :StockHelpEJB:==>\n"+e.getMessage());
java.util.Date date = null; }
timestamp = new Timestamp(System.currentTimeMillis()); }
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat()); return stkHelpList;
date = simpledateformat.parse(timestamp.toString()); }
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0"); private Timestamp getCurrdateTimestmp()
} {
catch(Exception exception) String s = "";
{ Timestamp timestamp = null;
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage()); GenericUtility genericUtility = GenericUtility.getInstance();
} try
return timestamp; {
} java.util.Date date = null;
class StockDtlParams implements Serializable timestamp = new Timestamp(System.currentTimeMillis());
{ SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
HashMap lotQuantMap = new HashMap(); date = simpledateformat.parse(timestamp.toString());
String currLocCode = "", currLotNo = "", currLotSl = "", invStat = "", retestDate = ""; timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
String expDate = "",unit = "", potencyPerc = "", batchNo = "", netAvailable = ""; }
String dimention = "", suppCodeMfg = "", ppoQty = "", pindQty = "", packCode = ""; catch(Exception exception)
String qtyPerArt = "", batchSize = "", mfgDate = "", rate = "", noArt = ""; {
String itemCode = "", available = ""; System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
double quantity = 0, availQuant = 0, holdQuant = 0, allocQuant = 0; }
java.sql.Timestamp currDateTs = null; return timestamp;
} }
class StockDtlParams implements Serializable
{
HashMap lotQuantMap = new HashMap();
String currLocCode = "", currLotNo = "", currLotSl = "", invStat = "", retestDate = "";
String expDate = "",unit = "", potencyPerc = "", batchNo = "", netAvailable = "";
String dimention = "", suppCodeMfg = "", ppoQty = "", pindQty = "", packCode = "";
String qtyPerArt = "", batchSize = "", mfgDate = "", rate = "", noArt = "";
String itemCode = "", available = "";
double quantity = 0, availQuant = 0, holdQuant = 0, allocQuant = 0;
java.sql.Timestamp currDateTs = null;
}
} }
\ 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