Commit 53320d08 authored by kmandhre's avatar kmandhre

change for quantity allocate in invalloc_trace


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93848 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2632c2ba
......@@ -3,6 +3,7 @@ package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.lang.String;
import java.sql.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import java.util.HashMap;
......@@ -39,7 +40,7 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
{
return "";
}
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException
{
Document dom = null;
......@@ -52,7 +53,7 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
executepostSaveRec(dom,domId,objContext,editFlag,xtraParams,conn);
}
}
catch(Exception e)
catch(Exception e)
{
System.out.println("Exception :StockTransferPosEJB ::" + e.getMessage() + ":");
e.printStackTrace();
......@@ -67,6 +68,10 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
HashMap hashMap = new HashMap();
String lineNo = "", tranId = "", tranSer = "XFRX", line = "", updateStatus = ""; //change tran Series(XFRX) on 18/OCT/13 Kunal M
String siteCode = "", itemCode = "", quantity = "", locCode = "", lotNo = "", lotSl = "";
String sql = "";
Double allocQty = 0.0 ,totAllocQty = 0.0, qty = 0.0 ,pendingQty = 0.0;
PreparedStatement pstmt = null;
ResultSet rs = null;
DistStkUpdLocal distStkUpd = null;
NodeList hdrDom = null;
Node currDetail = null;
......@@ -76,7 +81,7 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
System.out.println("domID =[" + domID + "]");
distStkUpd = getComponent("DistStkUpd");
hdrDom = dom.getElementsByTagName("Detail1");
siteCode = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
......@@ -103,24 +108,59 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
{
quantity = "0.000";
}
hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis()));
hashMap.put("ref_ser",tranSer);
hashMap.put("ref_id", tranId);
hashMap.put("ref_line", lineNo);
hashMap.put("item_code", itemCode);
hashMap.put("site_code", siteCode);
hashMap.put("loc_code",locCode);
hashMap.put("lot_no",lotNo);
hashMap.put("lot_sl",lotSl);
hashMap.put("alloc_qty", new Double(quantity.trim().length() == 0?"0":quantity));
hashMap.put("chg_win","W_STOCK_TRANSFER_MULTI");
hashMap.put("chg_user", GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
hashMap.put("chg_term", GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "termId"));
//Calling DistStkUpdEJB
System.out.println("Calling DistStkUpdEJB.....");
if (distStkUpd.updAllocTrace(hashMap, conn) > 0)
//added by kunal on 06/NOV/13
sql = "select ref_ser,ref_id ,trim(ref_line) as ref_line, sum(alloc_qty) from invalloc_trace where "
+" site_code = ? and loc_code = ? and item_code = ? and lot_no = ? and lot_sl = ? "
+" group by ref_ser, ref_id ,trim( ref_line) having sum(alloc_qty) > 0 order by sum(alloc_qty) desc ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
while(rs.next())
{
System.out.println("distStkUpd.UpdAllocTrace(HashMap, Connection) : Sucessuful!");
//refSer = checkNull(rs.getString( "ref_ser" )) ;
//refId = checkNull(rs.getString( "ref_id" ));
System.out.println("ref ser="+rs.getString( "ref_ser" )+" ref id="+rs.getString( "ref_id" ));
//refLine = Integer.parseInt( checkNull(rs.getString("ref_line")).trim().length() == 0 ?"0":rs.getString("ref_line").trim()) ;
allocQty = rs.getDouble(4);
System.out.println("allocQty="+allocQty);
totAllocQty = totAllocQty + allocQty;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("totAllocQty="+totAllocQty);
qty = new Double(quantity.trim().length() == 0?"0":quantity);
pendingQty = qty - totAllocQty;
System.out.println("pendingQty="+pendingQty);
if(pendingQty > 0)
{
//added by kunal on 06/NOV/13 END
hashMap.put("tran_date", new java.sql.Date(System.currentTimeMillis()));
hashMap.put("ref_ser",tranSer);
hashMap.put("ref_id", tranId);
hashMap.put("ref_line", lineNo);
hashMap.put("item_code", itemCode);
hashMap.put("site_code", siteCode);
hashMap.put("loc_code",locCode);
hashMap.put("lot_no",lotNo);
hashMap.put("lot_sl",lotSl);
//hashMap.put("alloc_qty", new Double(quantity.trim().length() == 0?"0":quantity));
hashMap.put("alloc_qty", new Double(pendingQty));//changed by kunal on 06/NOV/13
hashMap.put("chg_win","W_STOCK_TRANSFER_MULTI");
hashMap.put("chg_user", GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
hashMap.put("chg_term", GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "termId"));
//Calling DistStkUpdEJB
System.out.println("Calling DistStkUpdEJB.....");
if (distStkUpd.updAllocTrace(hashMap, conn) > 0)
{
System.out.println("distStkUpd.UpdAllocTrace(HashMap, Connection) : Sucessuful!");
}
}
}//end if
}//end if
......@@ -145,9 +185,9 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
conn = connDriver.getConnectDB("DriverITM");
stmt = conn.createStatement();
sql = "SELECT CASE WHEN STK_OPT IS NULL THEN 'N' ELSE STK_OPT END "
+"FROM SITEITEM "
+"WHERE ITEM_CODE = '"+itemCode+"' "
+"AND SITE_CODE = '"+siteCode+"' ";
+"FROM SITEITEM "
+"WHERE ITEM_CODE = '"+itemCode+"' "
+"AND SITE_CODE = '"+siteCode+"' ";
System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
......@@ -157,8 +197,8 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
if (stkOption == null || stkOption.equals("N"))
{
sql = "SELECT CASE WHEN STK_OPT IS NULL THEN '0' ELSE STK_OPT END "
+"FROM ITEM "
+"WHERE ITEM_CODE = '"+itemCode+"'";
+"FROM ITEM "
+"WHERE ITEM_CODE = '"+itemCode+"'";
System.out.println("sql :"+sql);
rs = stmt.executeQuery(sql);
if (rs.next())
......@@ -182,11 +222,21 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if (stmt != null)
{
stmt.close();
stmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
......@@ -260,22 +310,22 @@ public class StockTransferPos extends ValidatorEJB implements StockTransferPosLo
}*/
// for ejb3
private DistStkUpdLocal getComponent(String componentName)throws Exception
{
{
DistStkUpdLocal comp = null;
try
{
try
{
System.out.println("Looking For Component.... :: " + componentName);
AppConnectParm appConnect = new AppConnectParm();
java.util.Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
comp = (DistStkUpdLocal)ctx.lookup("ibase/DistStkUpd/local"); // for ejb3
comp = (DistStkUpdLocal)ctx.lookup("ibase/DistStkUpd/local"); // for ejb3
//comp = distStkUpdHome.create();
System.out.println(componentName+" Found.....");
}
catch(Exception e)
{
}
catch(Exception e)
{
throw e;
}
}
return comp;
}
}
\ 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