Commit 1353f6a4 authored by prahate's avatar prahate

EJB for DistRcpExSh.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97641 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 7d673452
/********************************************************
Title : DistRcpExShConf
Date : 13/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import javax.ejb.Stateless;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class DistRcpExShConf extends ActionHandlerEJB implements DistRcpExShConfLocal,DistRcpExShConfRemote //SessionBean
{
public String confirm(String tranId,String xtraParams,String forcedFlag) throws RemoteException,ITMException
{
System.out.println("Inside Confirm Method");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "",sql1="";
ConnDriver connDriver = null;
String loginEmpCode = "";
String confirm = "",empCodeAprv="" ;
String empFName = "",empMName="",empLName="";
String errString = "" ;
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
empCodeAprv = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("empCodeAprv@@@@@@@"+empCodeAprv);
//empCodeAprv = "loginEmpCode="+userInfo.getEmpCode();
sql = "select confirmed,site_code from distrcp_exsh_hdr where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
confirm = rs.getString("confirmed");
}
System.out.println("Cconfirm@@@@@@@@"+confirm);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(confirm != null && confirm.equalsIgnoreCase("Y"))
{
System.out.println("The Selected transaction is already confirmed");
errString = itmDBAccessEJB.getErrorString("","VTMCONF1","","",conn);
return errString;
}
else /*(confirm != null && confirm.equalsIgnoreCase("N") */
{
sql = "update distrcp_exsh_hdr set confirmed = 'Y', conf_date = ?,emp_code__aprv = ? where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setDate(1, new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(2, empCodeAprv);
pstmt.setString(3, tranId);
int updateCoount = pstmt.executeUpdate();
System.out.println("no of row update = "+updateCoount);
System.out.println("Date@@@@@@@@@"+new java.sql.Date(new java.util.Date().getTime()));
System.out.println("empCodeAprv+empCodeAprv"+empCodeAprv);
System.out.println("tranId@@@@@@@@@"+tranId);
pstmt.close();
pstmt = null;
sql1="select emp_fname,emp_mname,emp_lname from employee where emp_code= ?";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1, empCodeAprv);
rs = pstmt.executeQuery();
if(rs.next())
{
empFName = rs.getString("emp_fname");
empMName = rs.getString("emp_mname");
empLName = rs.getString("emp_lname");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("empFName@@@@@@@@@"+empFName);
System.out.println("empMName@@@@@@@@"+empMName);
System.out.println("empLName@@@@@@@@@"+empLName);
if(updateCoount > 0)
{
errString = itmDBAccessEJB.getErrorString("","VTCICONF3 ","","",conn);
}
System.out.println("115 err String from confirm method.....");
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VTCICONF3") > -1)
{
conn.commit();
}
else
{
conn.rollback();
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}//end of confirm method
}//end of class
/********************************************************
Title : DistRcpExShConfLocal
Date : 11/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.*;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Local; // added for ejb3
@Local
public interface DistRcpExShConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : DistRcpExShConfRemote
Date : 11/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.*;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface DistRcpExShConfRemote extends ActionHandlerRemote//, EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
/********************************************************
Title : DistRcpExShIC
Date : 11/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.utility.E12GenericUtility;
//import ibase.webitm.ejb.dis.DistCommon;
//import ibase.webitm.ejb.fin.FinCommon;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.util.*;
import java.text.SimpleDateFormat;
import java.rmi.RemoteException;
//import java.security.AllPermission;
//import java.security.Timestamp;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, DistRcpExShICRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
//method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = "";
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("Val xmlString :: " + xmlString);
System.out.println("Val xmlString1 :: " + xmlString1);
System.out.println("Val xmlString2 :: " + xmlString2);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams);
}
catch(Exception e)
{
throw new ITMException(e);
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String errorType = "";
String childNodeName = null;
String errString = "";
String errCode = "";
String userId = "";
String sql = "",sql1="";
String siteCode = "";
String tranDate = "";
String lotNo = "";
String lotSl="";
String locCode = "";
String quantity = "";
String keyFlag="";
String tranIdRcp="",tranId="",qtyactual="",reasCode="";
String tranIdRcpHdr = "",lineNoRcp="";
int ctr=0;
int cnt = 0;
int cnt1 = 0;
double qtyRcp=0.0,qtyActual=0.0;
int currentFormNo = 0;
int childNodeListLength;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null,pstmt1=null;
ResultSet rs = null,rs1=null;
String siteCodeShip="";
ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr ++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("tran_date"))
{
tranDate = genericUtility.getColumnValue("tran_date", dom);
if(tranDate == null || tranDate.trim().length() == 0)
{
errCode = "VTTRAN1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("tran_id"))
{
sql1="select key_flag from transetup where tran_window='w_distrcp_exsh'";
pstmt1=conn.prepareStatement(sql1);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
keyFlag=rs1.getString("key_flag");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if(keyFlag.equalsIgnoreCase("M"))
{
tranId= genericUtility.getColumnValue("tran_id", dom);
if(tranId == null || (tranId.length() == 0))
{
errList.add("VMTRANID");
errFields.add(childNodeName.toLowerCase());
}
if(tranId!= null && (tranId.trim().length() > 0))
{
sql = " select count(*) from distord_rcp where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VMTRNIDINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
else if(childNodeName.equalsIgnoreCase("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code", dom);
if(siteCode == null || (siteCode.length() == 0))
{
errList.add("NULLSITECD");
errFields.add(childNodeName.toLowerCase());
}
if(siteCode != null && (siteCode.trim().length() > 0))
{
sql = " select count(*) from site where site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VMSITE1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
else if(childNodeName.equalsIgnoreCase("tran_id__rcp"))
{
tranIdRcp = genericUtility.getColumnValue("tran_id__rcp", dom);
if(tranIdRcp == null || tranIdRcp.trim().length() == 0)
{
errCode = "VMTRIDRCP";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " select count(*)from distord_rcp where tran_id= ?"; //and confirmed='Y' and status= (case when status is null then 'P' else status end) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VTPRCPD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
break;
case 2 :
parentNodeList = dom1.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
tranIdRcpHdr = genericUtility.getColumnValue("tran_id__rcp", dom1 );
System.out.println("tranIdRcpHdr==*****==>"+tranIdRcpHdr);
for(ctr = 0; ctr < childNodeListLength; ctr ++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("tran_id__rcp"))
{
tranIdRcp = genericUtility.getColumnValue("tran_id__rcp", dom);
if(tranIdRcp == null || tranIdRcp.trim().length() == 0)
{
errCode = "VMTRIDRCP";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql = " select count(*)from distord_rcp where tran_id= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdRcp);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VTPRCPD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close(); rs = null;
pstmt.close();
pstmt = null;
if(!(tranIdRcp.equalsIgnoreCase(tranIdRcpHdr)))
{
errCode = "VMDISRCP";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if(childNodeName.equalsIgnoreCase("line_no__rcp"))
{
lineNoRcp = genericUtility.getColumnValue("line_no__rcp", dom);
if(lineNoRcp == null || lineNoRcp.trim().length() == 0)
{
errCode = "VTPRCPD1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("qty_actual"))
{
String tempActualQty=null;
tempActualQty = genericUtility.getColumnValue("qty_actual", dom); //==null?"0":genericUtility.getColumnValue("qty_actual", dom));
System.out.println("QUANTITY ACTUAL:"+tempActualQty);
if(tempActualQty== null || tempActualQty.trim().length() == 0)
{
errCode = "INVQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else if(childNodeName.equalsIgnoreCase("reas_code"))
{
reasCode = genericUtility.getColumnValue("reas_code", dom);
qtyRcp=Double.valueOf(genericUtility.getColumnValue("qty_rcp", dom)==null?"0":genericUtility.getColumnValue("qty_rcp", dom));
qtyActual = Double.valueOf(genericUtility.getColumnValue("qty_actual", dom)==null?"0":genericUtility.getColumnValue("qty_actual", dom));
System.out.println("QUANTITY ACTUAL:"+reasCode);
if(((qtyRcp-qtyActual) > 0 || (qtyRcp-qtyActual) < 0) && (reasCode == null || reasCode.trim().length() == 0))
{
errCode = "VTREASCOD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}//end switch
int errListSize = errList.size();
cnt = 0;
String errFldName = null;
if(errList != null && errListSize > 0)
{
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode);
if(errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if(errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}//end try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
return errString;
}//end of validation
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
System.out.println("XML STRING@@@@@@@@@");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
System.out.println("XML STRING@@@@@@@@@@@@@!1"+xmlString1);
dom2 = parseString(xmlString2);
System.out.println("XML STRING@@@@@@@@@@@@@@@2"+xmlString2);
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [JvVal][itemChanged( String, String )] :==>\n" + e.getMessage());
}
System.out.println("valueXmlStringvalueXmlStrin ST"+valueXmlString);
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
SimpleDateFormat sdf =null;
Timestamp timestamp = null,expDate=null,mfgDate=null;
String tranDate="";
String childNodeName = null;
String siteCode = "";
String itemCode = "";
String itemDescr = "";
String lineNoRcp = "";
String chgUser = "";
String chgTerm = "";
String sql = "";
String siteDescr = "";
String locCode = "";
String locDescr = "";
String siteCodeMfg="",suppCodeMfg="";
String tranIdRcp="",distOrder="",tranId="",tranCode="",lrDate="",lrNo="",transMode="",grossWeight="";
String tareWeight="",netWeight="",noArt="",tranName="",tranIdIss="",tranDate1="";
String lotNo = "",lotSl="";
double quantity=0.0;
String lineNo = "";
int ctr = 0;
int currentFormNo = 0;
String siteCodeShip="",siteCodeShipDescr="",unit="",columnValue="";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println("@@@@@@@@@@@ itemchange method called for ---->>>>["+currentColumn+"]");
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
timestamp = new Timestamp(System.currentTimeMillis());
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
siteCode =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
siteDescr = findValue(conn, "descr" ,"site", "site_code", siteCode);
System.out.println("@@@@@@ 1 siteCode["+siteCode+"]::::::siteDescr["+siteDescr+"]");
chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
tranDate = (sdf.format(timestamp).toString()).trim();
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if(childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim(); //added by cpatil
}
}
ctr++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("@@@@@@ itm_default itemchange called");
System.out.println("@@@@@@ 2 siteCode["+siteCode+"]");
System.out.println("Receipt Date@@@@@@@@@@@@@@@@@:"+tranDate);
valueXmlString.append("<tran_date>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date>");
valueXmlString.append("<eff_date>").append("<![CDATA[" + tranDate + "]]>").append("</eff_date>");
valueXmlString.append("<add_date>").append("<![CDATA[" + tranDate + "]]>").append("</add_date>");
valueXmlString.append("<add_user>").append("<![CDATA[" + chgUser + "]]>").append("</add_user>");
valueXmlString.append("<add_term>").append("<![CDATA[" + chgTerm + "]]>").append("</add_term>");
System.out.println("Effective Date@@@@@@@@@@@@@@@@@:"+tranDate);
}//end of if
if(currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
valueXmlString.append("<chg_date>").append("<![CDATA[" + tranDate + "]]>").append("</chg_date>");
// valueXmlString.append("<chg_user>").append("<![CDATA[" + chgUser + "]]>").append("</chg_user>");
// valueXmlString.append("<chg_term>").append("<![CDATA[" + chgTerm + "]]>").append("</chg_term>");
}
else if(currentColumn.trim().equalsIgnoreCase("tran_id__rcp"))
{
System.out.println("@@@@@@ tran_id__rcp itemchange called");
tranId = genericUtility.getColumnValue("tran_id__rcp", dom);
distOrder = findValue(conn, "dist_order" ,"distord_rcp", "tran_id", tranId);
valueXmlString.append("<dist_order>").append("<![CDATA[" + distOrder + "]]>").append("</dist_order>");
siteCode = findValue(conn, "site_code" ,"distord_rcp", "tran_id",tranId);
siteDescr = findValue(conn, "descr" ,"site", "site_code", siteCode);
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + siteDescr + "]]>").append("</descr>");
System.out.println("@@@@@ siteCode["+siteCode+"]siteCodeDescr["+siteDescr+"]");
siteCodeShip = findValue(conn, "site_code__ship" ,"distord_rcp", "tran_id",tranId);
siteCodeShipDescr = findValue(conn, "descr" ,"site", "site_code", siteCodeShip);
valueXmlString.append("<site_code__ship>").append("<![CDATA[" + siteCodeShip + "]]>").append("</site_code__ship>");
valueXmlString.append("<descr_1>").append("<![CDATA[" + siteCodeShipDescr + "]]>").append("</descr_1>");
System.out.println("@@@@@ siteCodeShip["+siteCodeShip+"]siteCodeShipDescr["+siteCodeShipDescr+"]");
tranCode = findValue(conn, "tran_code", "distord_rcp", "tran_id", tranId);
tranName = findValue(conn, "tran_name", "transporter", "tran_code", tranCode);
valueXmlString.append("<tran_code>").append("<![CDATA[" + tranCode + "]]>").append("</tran_code>");
valueXmlString.append("<tran_name>").append("<![CDATA[" + tranName+ "]]>").append("</tran_name>");
System.out.println("@@@@@ tran_code["+tranCode+"]tran_name["+tranName+"]");
sql = "select lr_no,lr_date,trans_mode,gross_weight,tare_weight,net_weight,no_art,tran_id__iss from distord_rcp where tran_id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
lrNo= checkNull(rs.getString("lr_no"));
lrDate= checkNull(rs.getString("lr_date"));
transMode= rs.getString("trans_mode");
grossWeight = rs.getString("gross_weight");
tareWeight = rs.getString("tare_weight");
netWeight = rs.getString("net_weight");
noArt = rs.getString("no_art");
tranIdIss = rs.getString("tran_id__iss");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<lr_no>").append("<![CDATA[" + lrNo + "]]>").append("</lr_no>");
valueXmlString.append("<lr_date>").append("<![CDATA[" + lrDate + "]]>").append("</lr_date>");
valueXmlString.append("<trans_mode>").append("<![CDATA[" + transMode + "]]>").append("</trans_mode>");
valueXmlString.append("<gross_weight>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[" + tareWeight + "]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
valueXmlString.append("<no_art>").append("<![CDATA[" + noArt + "]]>").append("</no_art>");
valueXmlString.append("<site_code__ship>").append("<![CDATA[" + siteCodeShip + "]]>").append("</site_code__ship>");
valueXmlString.append("<descr_1>").append("<![CDATA[" + siteCodeShipDescr + "]]>").append("</descr_1>");
valueXmlString.append("<tran_id__iss>").append("<![CDATA[" + tranIdIss + "]]>").append("</tran_id__iss>");
}
else if(currentColumn.trim().equalsIgnoreCase("site_code"))
{
System.out.println("@@@@@@ site_code itemchange called");
siteCode = genericUtility.getColumnValue("site_code", dom);
siteDescr = findValue(conn, "descr" ,"site", "site_code", siteCode);
System.out.println("@@@@@ siteCode["+siteCode+"]siteDescr["+siteDescr+"]");
valueXmlString.append("<descr>").append("<![CDATA[" + siteDescr + "]]>").append("</descr>");
}
valueXmlString.append("</Detail1>");
break;
case 2 :
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail2>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if(childNode.getFirstChild() != null)
{
}
}
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
System.out.println("Entered in CASE@@@@@@@@@@@@@@@@222222222");
tranId = genericUtility.getColumnValue("tran_id", dom1);
tranIdRcp=genericUtility.getColumnValue("tran_id__rcp", dom1);
System.out.println("tranID@@@@@@@@@@@"+tranId);
System.out.println("TRANIDRCP@@@@@@@@@@@@@"+tranIdRcp);
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
tranIdRcp = genericUtility.getColumnValue("tran_id__rcp", dom1, "1");
//valueXmlString.append("<tran_id__rcp>").append("<![CDATA[" + tranIdRcp + "]]>").append("</tran_id__rcp>");
valueXmlString.append("<tran_id__rcp protect = \"1\">").append("<![CDATA[" + tranIdRcp + "]]>").append("</tran_id__rcp>");
}//end of if
else if(currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
}
else if(currentColumn.trim().equalsIgnoreCase("tran_id__rcp") || currentColumn.trim().equalsIgnoreCase("line_no__rcp"))
{
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
lineNo = checkNull(genericUtility.getColumnValue("line_no__rcp", dom));
if (lineNo.trim().length() > 0 )
{
valueXmlString.append("<line_no__rcp>").append("<![CDATA[" + lineNo + "]]>").append("</line_no__rcp>");
}
if (tranIdRcp.trim().length() > 0 && lineNo.trim().length() > 0 )
{
if(lineNo.trim().length() > 0)
{
itemCode=findValue(conn, "item_code", "distord_rcpdet", "tran_id", tranIdRcp);
itemDescr = findValue(conn, "descr" ,"item", "item_code", itemCode);
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
locCode=findValue(conn, "loc_code", "distord_rcpdet", "tran_id", tranIdRcp);
locDescr=findValue(conn, "descr", "location", "loc_code", locCode);
valueXmlString.append("<loc_code>").append("<![CDATA[" + locCode + "]]>").append("</loc_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + locDescr + "]]>").append("</descr>");
sql = "select unit,quantity,lot_no,lot_sl,no_art,site_code__mfg,mfg_date,exp_date,gross_weight,tare_weight,net_weight,trans_mode,supp_code__mfg from distord_rcpdet where tran_id= ? and line_no= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdRcp);
pstmt.setString(2,lineNo);
rs = pstmt.executeQuery();
if(rs.next())
{
unit = rs.getString("unit");
quantity = rs.getDouble("quantity");
lotNo = checkNull(rs.getString("lot_no"));
lotSl = checkNull(rs.getString("lot_sl"));
noArt = rs.getString("no_art");
siteCodeMfg= rs.getString("site_code__mfg");
mfgDate= rs.getTimestamp("mfg_date");
expDate= rs.getTimestamp("exp_date");
grossWeight= rs.getString("gross_weight");
tareWeight= rs.getString("tare_weight");
netWeight= rs.getString("net_weight");
transMode= rs.getString("trans_mode");
suppCodeMfg= rs.getString("supp_code__mfg");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("mfgDate@@@@"+sdf.format(mfgDate));
System.out.println("expDate@@@@"+sdf.format(expDate));
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
//valueXmlString.append("<quantity>").append("<![CDATA[" + quantity + "]]>").append("</quantity>");
valueXmlString.append("<qty_rcp>").append("<![CDATA[" + quantity + "]]>").append("</qty_rcp>");
valueXmlString.append("<qty_actual>").append("<![CDATA[" + quantity + "]]>").append("</qty_actual>");
valueXmlString.append("<lot_no>").append("<![CDATA[" + lotNo + "]]>").append("</lot_no>");
valueXmlString.append("<lot_sl>").append("<![CDATA[" + lotSl + "]]>").append("</lot_sl>");
valueXmlString.append("<no_art>").append("<![CDATA[" + noArt + "]]>").append("</no_art>");
valueXmlString.append("<site_code__mfg>").append("<![CDATA[" + siteCodeMfg + "]]>").append("</site_code__mfg>");
valueXmlString.append("<mfg_date>").append("<![CDATA[" + sdf.format(mfgDate) + "]]>").append("</mfg_date>");
valueXmlString.append("<exp_date>").append("<![CDATA[" + sdf.format(expDate) + "]]>").append("</exp_date>");
valueXmlString.append("<gross_weight>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[" + tareWeight + "]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
valueXmlString.append("<trans_mode>").append("<![CDATA[" + transMode + "]]>").append("</trans_mode>");
valueXmlString.append("<supp_code__mfg>").append("<![CDATA[" + suppCodeMfg + "]]>").append("</supp_code__mfg>");
}
}
}
valueXmlString.append("</Detail2>");
break;
}//end of switch-case
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(pstmt != null)
pstmt.close();
if(rs != null)
rs.close();
rs = null;
pstmt = null;
conn.close();
conn = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}//end of itemChanged
private String errorType(Connection conn , String errorCode)
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode);
rs = pstmt.executeQuery();
while(rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return msgType;
}//end of errorType
private String findValue(Connection conn, String columnName ,String tableName, String columnName2, String value) throws ITMException, RemoteException
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (findValue == null )
{
findValue = "";
}
}
catch(Exception e)
{
System.out.println("Exception in findValue ");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from findValue " + findValue);
return findValue;
}//end of findValue
private String checkNull( String input )
{
if (input == null )
{
input = "";
}
return input;
}//end of checkNull
}//class ends
/********************************************************
Title : DistRcpExShICLocal
Date : 13/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface DistRcpExShICLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : DistRcpExShICRemote
Date : 13/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface DistRcpExShICRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
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