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 "";
...@@ -24,167 +22,371 @@ public class StockTransferAct extends ActionHandlerEJB implements StockTransferA ...@@ -24,167 +22,371 @@ public class StockTransferAct extends ActionHandlerEJB implements StockTransferA
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 (actionType.equalsIgnoreCase("Default"))
{
if(xmlString1 != null && xmlString1.trim().length()!=0) if(xmlString1 != null && xmlString1.trim().length()!=0)
{ {
System.out.println(">>>>>>>>>>>>>>XML String1:"+xmlString1); System.out.println("XML String1 :"+xmlString1);
dom1 = genericUtility.parseString(xmlString1); dom1 = genericUtility.parseString(xmlString1);
System.out.println(">>>>>>>>>>>>>>dom1:"+dom1); }
System.out.println("actionType:"+actionType+":");
if (actionType.equalsIgnoreCase("All Items"))
{
retString = actionAllItems(dom, dom1, xtraParams, actionType);
} }
System.out.println("*********************Before Call actionDefault*********************");
retString = actionDefault(dom1,objContext,xtraParams);//function to fetch data
} }
catch(Exception e)
{
System.out.println("Exception :StockTransferAct :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from StockTransferAct : actionHandler"+retString);
return retString;
}
public String actionHandlerTransform(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams, String selDataStr) throws RemoteException,ITMException
{
System.out.println("actionHandlerTransform is calling.............");
Document dom = null;
Document dom1 = null;
Document selDataDom = null;
String retString = null;
try
{
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+":");
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception :ModelHandler :actionHandler(String xmlString):" + e.getMessage() + ":"); System.out.println("Exception :StockTransfer :actionHandlerTransform(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 StockTransfer : actionHandlerTransform"+retString);
return retString; return retString;
} }
private String actionDefault( Document dom1, String objContext, String xtraParams) throws RemoteException, ITMException private String actionAllItems(Document dom, Document dom1, String xtraParams, String actionType) throws RemoteException,ITMException //Added - - Gulzar 25/04/07
{ {
String refSerFor="",lineNo="",itemCode = "",itemDescr = "",locCodeFrom="",locCodeTo="",consOrder="";
String retString = null;
double quantity=0.0d;
int lineCntr=0;
String consumeOrder = "",refSerFor="";
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
Statement stmt = null; Statement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null; Connection conn = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ArrayList lineNo = new ArrayList();
E12GenericUtility genericUtility= new E12GenericUtility(); 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 try
{ {
conn = getConnection(); conn = getConnection();
consOrder = genericUtility.getColumnValue("ref_id__for",dom1);
System.out.println("Consumer Order Reference id::::::::"+consOrder); 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); refSerFor = genericUtility.getColumnValue("ref_ser__for",dom1);
System.out.println("Consumer Order Reference series::::::::"+refSerFor); if(refSerFor.trim().equalsIgnoreCase("C-ORD"))
String sql1=" SELECT CONSUME_ORD_DET.CONS_ORDER, "
+" CONSUME_ORD_DET.LINE_NO, "
+" CONSUME_ORD_DET.ITEM_CODE ,"
+" ITEM.DESCR,"
+" CONSUME_ORD_DET.QUANTITY,"
+" CONSUME_ORD_DET.LOC_CODE"
+" FROM CONSUME_ORD_DET,"
+" ITEM,"
+" CONSUME_ORD "
+" WHERE ( CONSUME_ORD_DET.ITEM_CODE = ITEM.ITEM_CODE ) "
+" and "
+"(CONSUME_ORD_DET.CONS_ORDER =CONSUME_ORD.CONS_ORDER ) "
+ " and "
+ "(( CONSUME_ORD_DET.CONS_ORDER='"+consOrder+"')) "
+" ORDER BY CONSUME_ORD_DET.LINE_NO ASC ";
stmt=conn.createStatement();
rs=stmt.executeQuery(sql1);
while(rs.next())
{ {
refserfr = refSerFor;
System.out.println("Consumer Order Reference id::::::::"+refserfr);
}
lineCntr++;
lineNo=rs.getString("line_no");
System.out.println("lineNO::"+lineNo);
consOrder=rs.getString("cons_order");
System.out.println("consOrder::"+consOrder);
itemCode = rs.getString("item_code");
System.out.println("itemCode"+itemCode);
itemDescr = rs.getString("descr");
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); 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
{
conn.close();
conn = null;
}
catch (Exception e){}
}
System.out.println("valueXmlString return from StockTransferAct[actionAllItems] :"+itemChgXmlString.toString());
return itemChgXmlString.toString();
} //End of actionAllItems method
private String getItemChanged(Document dom1,String consumeOrder,Connection conn) throws Exception
{
Statement stmt = null;
ResultSet rs = null;
String tranType = "",itemSer="",sql = "";
String itemAcctDetr = "";
String itemCode = "";
String locCode = "";
String itemDescr = "";
String consOrd = "";
String lotNoTo = "";
String lotSlTo = "";
String locCodeDescr = "",acctCodeInv="",cctrCodeInv="",noArt="",acctCodeDr="",cctrCodeDr="";
double quantity = 0;
StringBuffer valueXmlString = new StringBuffer("");
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
FinCommon finCommon = new FinCommon();
Statement stmt1 = null;
ResultSet rs1 = null;
String lineNoStr="";
try
{
tranType = genericUtility.getColumnValue("tran_type",dom1);
consOrd = genericUtility.getColumnValue("cons_order",dom1);
valueXmlString.append("<Detail>\r\n"); sql = "select line_no,item_code,loc_code,quantity from consume_ord_det "+
valueXmlString.append("<cons_order>").append("<![CDATA[").append(consOrder).append("]]>").append("</cons_order>\r\n"); "where cons_order = '"+consumeOrder+"' ";
valueXmlString.append("<line_no>").append("<![CDATA[").append(lineCntr).append("]]>").append("</line_no>\r\n"); System.out.println("SQL ::"+sql);
valueXmlString.append("<item_code isSrvCallOnChg='0'>").append("<![CDATA[").append(itemCode.trim()).append("]]>").append("</item_code>\r\n"); stmt = conn.createStatement();
valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescr.trim()).append("]]>").append("</item_descr>\r\n"); rs = stmt.executeQuery(sql);
valueXmlString.append("<quantity>").append("<![CDATA[").append(quantity).append("]]>").append("</quantity>\r\n"); while(rs.next())
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"); lineNoStr = rs.getString("line_no");
valueXmlString.append("</Detail>\r\n"); 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);
sql = "select descr from item where item_code = '"+itemCode+"'";
System.out.println("SQL ::"+sql);
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
if(rs1.next())
{
itemDescr = rs1.getString("descr");
}
}//end of while loop 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);
if(lineCntr==0) if(rs1.next())
{ {
retString = itmDBAccessEJB.getErrorString("","INVTR","","",conn); locCodeDescr = rs1.getString("descr");
} }
rs1.close();
rs1=null;
stmt1.close();
stmt1=null;
System.out.println("*********In Act Default:"+lineCntr); sql = "Select lot_no,lot_sl from stock where item_code = '"+itemCode+"'";
rs.close(); System.out.println("SQL ::"+sql);
rs = null;
stmt.close();
stmt = null;
valueXmlString.append("</Root>\r\n"); stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
if(rs1.next())
{
}//end of try block lotNoTo= rs1.getString("lot_no");
catch(Exception e) 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);
if(rs1.next())
{ {
System.out.println("Exception in actionDefault actionHandler :(Document dom)" +e.getMessage());
throw new ITMException(e);
}//end of catch block acctCodeInv = rs1.getString("acct_code__inv");
finally 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)
{ {
try String tokens [] = itemAcctDetr.split(",");
System.out.println("Length="+tokens.length);
if ( tokens.length >= 2)
{ {
System.out.println("Closing Connection....."); acctCodeDr = tokens[0];
conn.close(); cctrCodeDr = tokens[1];
conn = null;
acctCodeDr = checkNullAndTrim(acctCodeDr);
cctrCodeDr = checkNullAndTrim(cctrCodeDr);
System.out.println("acctCodeDr="+acctCodeDr);
System.out.println("cctrCodeDr="+cctrCodeDr);
} }
catch(Exception e){} else
}//end of finally {
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(); return valueXmlString.toString();
}//end of actionDefault method } //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