Commit 37667dc2 authored by mnair's avatar mnair

Added changes to the component

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@180672 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8ae2b3d6
package ibase.webitm.ejb.dis.adv; package ibase.webitm.ejb.dis.adv;
import java.util.*;
import java.sql.*;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import org.w3c.dom.*;
import java.sql.ResultSet;
import java.sql.Statement; import ibase.system.config.*;
import javax.ejb.Stateless; import ibase.webitm.ejb.*;
import org.w3c.dom.Document; import ibase.webitm.ejb.fin.FinCommon;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless; // added for ejb3
@Stateless @Stateless // added for ejb3
public class StockTransferAct extends ActionHandlerEJB implements StockTransferActLocal,StockTransferActRemote public class StockTransferAct extends ActionHandlerEJB implements StockTransferActLocal,StockTransferActRemote
{ {
E12GenericUtility genericUtility= new E12GenericUtility();
String act_type=null;
public String actionHandler() throws RemoteException,ITMException public String actionHandler() throws RemoteException,ITMException
{ {
return ""; return "";
} }
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
{ {
System.out.println(">>>>>>>>>>>>>In actionHandler actionDefault:");
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
String retString = null; String retString = null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
try try
{ {
if(xmlString != null && xmlString.trim().length()!=0) if(xmlString != null && xmlString.trim().length()!=0)
{ {
System.out.println(">>>>>>>>>>>>>XML String>:"+xmlString); System.out.println("XML String :"+xmlString);
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
System.out.println(">>>>>>>>>>>>>Dom:"+dom);
} }
System.out.println(">>>>>>>>>>>>>>>>actionType:"+actionType+":"); if(xmlString1 != null && xmlString1.trim().length()!=0)
{
System.out.println("XML String1 :"+xmlString1);
if (actionType.equalsIgnoreCase("Default")) dom1 = genericUtility.parseString(xmlString1);
}
System.out.println("actionType:"+actionType+":");
if (actionType.equalsIgnoreCase("All Items"))
{ {
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
System.out.println(">>>>>>>>>>>>>>XML String1:"+xmlString1);
dom1 = genericUtility.parseString(xmlString1);
System.out.println(">>>>>>>>>>>>>>dom1:"+dom1);
}
System.out.println("*********************Before Call actionDefault*********************");
retString = actionDefault(dom1,objContext,xtraParams);//function to fetch data
retString = actionAllItems(dom, dom1, xtraParams, actionType);
} }
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :ModelHandler :actionHandler(String xmlString):" + e.getMessage() + ":"); System.out.println("Exception :StockTransferAct :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
System.out.println("returning String from ModelHandler : actionHandler"+retString); System.out.println("returning String from StockTransferAct : actionHandler"+retString);
return retString; return retString;
} }
public String actionHandlerTransform(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams, String selDataStr) throws RemoteException,ITMException
private String actionDefault( Document dom1, String objContext, String xtraParams) throws RemoteException, ITMException
{ {
String refSerFor="",lineNo="",itemCode = "",itemDescr = "",locCodeFrom="",locCodeTo="",consOrder="";
System.out.println("actionHandlerTransform is calling.............");
Document dom = null;
Document dom1 = null;
Document selDataDom = null;
String retString = null; String retString = null;
double quantity=0.0d; try
int lineCntr=0; {
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = new ibase.utility.E12GenericUtility().parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = new ibase.utility.E12GenericUtility().parseString(xmlString1);
}
if(selDataStr != null && selDataStr.length() > 0)
{
selDataDom = new ibase.utility.E12GenericUtility().parseString(selDataStr);
}
System.out.println("actionType:"+actionType+":");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); }
Statement stmt = null; catch(Exception e)
ResultSet rs = null; {
Connection conn = null; System.out.println("Exception :StockTransfer :actionHandlerTransform(String xmlString):" + e.getMessage() + ":");
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); e.printStackTrace();
E12GenericUtility genericUtility= new E12GenericUtility(); throw new ITMException(e);
}
System.out.println("returning String from StockTransfer : actionHandlerTransform"+retString);
return retString;
}
private String actionAllItems(Document dom, Document dom1, String xtraParams, String actionType) throws RemoteException,ITMException //Added - - Gulzar 25/04/07
{
String consumeOrder = "",refSerFor="";
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
ArrayList lineNo = new ArrayList();
String lineNoStr = "";
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
StringBuffer allocateBuffer = new StringBuffer("");
StringBuffer itemChgXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String allocateStr = "";
String detailCnt = "";
String itemChgRetStr = "";
int detCnt = 0;
String refserfr = "";
String consOrder = "";
Document temp = null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
detailCnt = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"detCnt");
if (detailCnt != null)
{
detCnt = Integer.parseInt(detailCnt);
System.out.println("detCnt...........:: " + detCnt);
}
if (dom == null || detCnt > 1)
{
valueXmlString.append("</Root>\r\n");
return valueXmlString.toString();
}
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
try
{
conn = getConnection();
stmt = conn.createStatement();
consumeOrder = genericUtility.getColumnValue("ref_id__for",dom1);
if(consumeOrder != null && consumeOrder.trim().length() > 0)
{
consOrder = consumeOrder;
System.out.println("Consumer Order Reference series::::::::"+consOrder);
}
refSerFor = genericUtility.getColumnValue("ref_ser__for",dom1);
if(refSerFor.trim().equalsIgnoreCase("C-ORD"))
{
refserfr = refSerFor;
System.out.println("Consumer Order Reference id::::::::"+refserfr);
}
System.out.println("The size of ArrayList :"+lineNo.size());
itemChgRetStr = getItemChanged(dom1,consumeOrder,conn);
itemChgXmlString.append(itemChgRetStr);
itemChgXmlString.append("</Root>\r\n");
if(itemChgXmlString.toString() != null && itemChgXmlString.toString().trim().length()!=0)
{
System.out.println("After ItemChange Of Detail [itemChgXmlString] :"+itemChgXmlString.toString());
dom = genericUtility.parseString(itemChgXmlString.toString());
}
valueXmlString.append("</Root>\r\n");
}
catch (SQLException sqx)
{
System.out.println("The sqlException occure in StockTransferAct :"+sqx);
throw new ITMException(sqx);
}
catch (Exception e)
{
System.out.println("The Exception occure in StockTransferAct :"+e);
throw new ITMException(e);
}
finally
{
try try
{ {
conn = getConnection(); conn.close();
consOrder = genericUtility.getColumnValue("ref_id__for",dom1); conn = null;
System.out.println("Consumer Order Reference id::::::::"+consOrder); }
refSerFor = genericUtility.getColumnValue("ref_ser__for",dom1); catch (Exception e){}
System.out.println("Consumer Order Reference series::::::::"+refSerFor); }
System.out.println("valueXmlString return from StockTransferAct[actionAllItems] :"+itemChgXmlString.toString());
String sql1=" SELECT CONSUME_ORD_DET.CONS_ORDER, " return itemChgXmlString.toString();
+" CONSUME_ORD_DET.LINE_NO, "
+" CONSUME_ORD_DET.ITEM_CODE ," } //End of actionAllItems method
+" ITEM.DESCR,"
+" CONSUME_ORD_DET.QUANTITY," private String getItemChanged(Document dom1,String consumeOrder,Connection conn) throws Exception
+" CONSUME_ORD_DET.LOC_CODE" {
+" FROM CONSUME_ORD_DET,"
+" ITEM," Statement stmt = null;
+" CONSUME_ORD " ResultSet rs = null;
+" WHERE ( CONSUME_ORD_DET.ITEM_CODE = ITEM.ITEM_CODE ) " String tranType = "",itemSer="",sql = "";
+" and " String itemAcctDetr = "";
+"(CONSUME_ORD_DET.CONS_ORDER =CONSUME_ORD.CONS_ORDER ) " String itemCode = "";
+ " and " String locCode = "";
+ "(( CONSUME_ORD_DET.CONS_ORDER='"+consOrder+"')) " String itemDescr = "";
+" ORDER BY CONSUME_ORD_DET.LINE_NO ASC "; String consOrd = "";
String lotNoTo = "";
stmt=conn.createStatement(); String lotSlTo = "";
rs=stmt.executeQuery(sql1); String locCodeDescr = "",acctCodeInv="",cctrCodeInv="",noArt="",acctCodeDr="",cctrCodeDr="";
while(rs.next()) double quantity = 0;
{
StringBuffer valueXmlString = new StringBuffer("");
lineCntr++; ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
FinCommon finCommon = new FinCommon();
lineNo=rs.getString("line_no"); Statement stmt1 = null;
System.out.println("lineNO::"+lineNo); ResultSet rs1 = null;
consOrder=rs.getString("cons_order"); String lineNoStr="";
System.out.println("consOrder::"+consOrder); try
itemCode = rs.getString("item_code"); {
System.out.println("itemCode"+itemCode); tranType = genericUtility.getColumnValue("tran_type",dom1);
itemDescr = rs.getString("descr"); consOrd = genericUtility.getColumnValue("cons_order",dom1);
System.out.println("itemDescr::"+itemDescr);
quantity=rs.getDouble("quantity");
System.out.println("quantity::"+quantity);
locCodeFrom = rs.getString("loc_code");
System.out.println("locCodeFrom::"+locCodeFrom);
locCodeTo = rs.getString("loc_code");
System.out.println("locCodeTo::"+locCodeTo);
System.out.println("Item no::::"+lineNo);
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<cons_order>").append("<![CDATA[").append(consOrder).append("]]>").append("</cons_order>\r\n");
valueXmlString.append("<line_no>").append("<![CDATA[").append(lineCntr).append("]]>").append("</line_no>\r\n");
valueXmlString.append("<item_code isSrvCallOnChg='0'>").append("<![CDATA[").append(itemCode.trim()).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescr.trim()).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(quantity).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<loc_code__fr>").append("<![CDATA[").append(locCodeFrom.trim()).append("]]>").append("</loc_code__fr>\r\n");
valueXmlString.append("<loc_code__to>").append("<![CDATA[").append(locCodeTo.trim()).append("]]>").append("</loc_code__to>\r\n");
valueXmlString.append("</Detail>\r\n");
}//end of while loop
sql = "select line_no,item_code,loc_code,quantity from consume_ord_det "+
"where cons_order = '"+consumeOrder+"' ";
System.out.println("SQL ::"+sql);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next())
{
lineNoStr = rs.getString("line_no");
itemCode = rs.getString("item_code");
quantity = rs.getDouble("quantity");
locCode= rs.getString("loc_code");
System.out.println("itemCode ::"+itemCode);
System.out.println("quantity ::"+quantity);
System.out.println("Location code ::"+locCode);
if(lineCntr==0) sql = "select descr from item where item_code = '"+itemCode+"'";
System.out.println("SQL ::"+sql);
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
if(rs1.next())
{ {
retString = itmDBAccessEJB.getErrorString("","INVTR","","",conn); itemDescr = rs1.getString("descr");
} }
rs1.close();
rs1=null;
stmt1.close();
stmt1=null;
sql = "select descr from location where loc_code = '"+locCode+"'";
System.out.println("SQL ::"+sql);
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
System.out.println("*********In Act Default:"+lineCntr); if(rs1.next())
rs.close();
rs = null;
stmt.close();
stmt = null;
valueXmlString.append("</Root>\r\n");
}//end of try block
catch(Exception e)
{
System.out.println("Exception in actionDefault actionHandler :(Document dom)" +e.getMessage());
throw new ITMException(e);
}//end of catch block
finally
{
try
{ {
System.out.println("Closing Connection....."); locCodeDescr = rs1.getString("descr");
conn.close();
conn = null;
} }
catch(Exception e){}
}//end of finally rs1.close();
rs1=null;
stmt1.close();
stmt1=null;
return valueXmlString.toString(); sql = "Select lot_no,lot_sl from stock where item_code = '"+itemCode+"'";
System.out.println("SQL ::"+sql);
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
if(rs1.next())
{
lotNoTo= rs1.getString("lot_no");
lotSlTo= rs1.getString("lot_sl");
}
rs1.close();
rs1=null;
stmt1.close();
stmt1=null;
sql = "Select acct_code__inv, cctr_code__inv,qty_per_art FROM STOCK WHERE ITEM_CODE = '"+itemCode+"'" +
"And loc_code = '"+locCode+"'"+
"And lot_no = '"+lotNoTo+"'" +
"And lot_sl = '"+lotSlTo+"'";
System.out.println("SQL ::"+sql);
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
}//end of actionDefault method if(rs1.next())
{
acctCodeInv = rs1.getString("acct_code__inv");
cctrCodeInv = rs1.getString("cctr_code__inv");
noArt = rs1.getString("qty_per_art");
}
rs1.close();
rs1=null;
stmt1.close();
stmt1=null;
itemAcctDetr = finCommon.getAcctDetrTtype(itemCode, itemSer, "STKINV", tranType, conn);
if (itemAcctDetr != null && itemAcctDetr.trim().length() > 0)
{
String tokens [] = itemAcctDetr.split(",");
System.out.println("Length="+tokens.length);
if ( tokens.length >= 2)
{
acctCodeDr = tokens[0];
cctrCodeDr = tokens[1];
acctCodeDr = checkNullAndTrim(acctCodeDr);
cctrCodeDr = checkNullAndTrim(cctrCodeDr);
System.out.println("acctCodeDr="+acctCodeDr);
System.out.println("cctrCodeDr="+cctrCodeDr);
}
else
{
acctCodeDr = itemAcctDetr.substring(0,itemAcctDetr.indexOf(","));
cctrCodeDr = itemAcctDetr.substring(itemAcctDetr.indexOf(",") + 1);
}
tokens = null;
}
System.out.println("isSrvCallOnChg is set ---");
valueXmlString.append("<Detail>\r\n>");
valueXmlString.append("<cons_order isSrvCallOnChg=\"0\">").append("<![CDATA[").append((consumeOrder == null) ? "":consumeOrder).append("]]>").append("</cons_order>\r\n");
valueXmlString.append("<line_no isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lineNoStr).append("]]>").append("</line_no>\r\n");
valueXmlString.append("<item_code isSrvCallOnChg=\"0\">").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr isSrvCallOnChg=\"0\">").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<quantity isSrvCallOnChg=\"0\">").append("<![CDATA[").append(quantity).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<loc_code__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCode == null) ? "":locCode).append("]]>").append("</loc_code__fr>\r\n");
valueXmlString.append("<location_descr__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCodeDescr == null) ? "":locCodeDescr).append("]]>").append("</location_descr__fr>\r\n");
//valueXmlString.append("<loc_code__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCode == null) ? "":locCode).append("]]>").append("</loc_code__to>\r\n");
//valueXmlString.append("<loc_descr__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCodeDescr == null) ? "":locCodeDescr).append("]]>").append("</loc_descr__to>\r\n");
valueXmlString.append("<lot_no__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotNoTo == null) ? "":lotNoTo).append("]]>").append("</lot_no__fr>\r\n");
valueXmlString.append("<lot_sl__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotSlTo == null) ? "":lotSlTo).append("]]>").append("</lot_sl__fr>\r\n");
//valueXmlString.append("<lot_no__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotNoTo == null) ? "":lotNoTo).append("]]>").append("</lot_no__to>\r\n");
//valueXmlString.append("<lot_sl__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotSlTo == null) ? "":lotSlTo).append("]]>").append("</lot_sl__to>\r\n");
valueXmlString.append("<acct_code__cr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((acctCodeInv == null) ? "":acctCodeInv).append("]]>").append("</acct_code__cr>\r\n");
valueXmlString.append("<cctr_code__cr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((cctrCodeInv == null) ? "":cctrCodeInv).append("]]>").append("</cctr_code__cr>\r\n");
valueXmlString.append("<acct_code__dr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((acctCodeDr == null) ? "":acctCodeDr).append("]]>").append("</acct_code__dr>\r\n");
valueXmlString.append("<cctr_code__dr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((cctrCodeDr == null) ? "":cctrCodeDr).append("]]>").append("</cctr_code__dr>\r\n");
valueXmlString.append("<no_art isSrvCallOnChg=\"0\">").append("<![CDATA[").append((noArt == null) ? "":noArt).append("]]>").append("</no_art>\r\n");
valueXmlString.append("</Detail>");
}
rs.close();
rs=null;
stmt.close();
stmt=null;
}
catch(Exception e)
{
System.out.println("Exception [StockTransferAct][getItemChanged] :"+e);
e.printStackTrace();
throw e;
}
System.out.println("valueXmlString return from StockTransferAct[getItemChanged] :"+valueXmlString.toString());
return valueXmlString.toString();
} //End of getItemChanged method
private String checkNullAndTrim(String input) {
if (input==null)
{
input="";
}
return input.trim();
} }
} //End of actionStock method
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