Commit 9062a860 authored by prahate's avatar prahate

EJB updated for Dist.Receipt Req_Id [D14JSUN004].


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97988 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 237c5747
/********************************************************
Title : DistRcpExShClose
Date : 13/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.*;
import ibase.utility.EMail;
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 DistRcpExShClose extends ActionHandlerEJB implements DistRcpExShCloseLocal, DistRcpExShCloseRemote // SessionBean
{
public String close(String tranId, String xtraParams, String forcedFlag)throws RemoteException, ITMException
{
System.out.println("Inside Close Method");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "", sql1 = "";
ConnDriver connDriver = null;
String loginEmpCode = "";
String status = "", empCode = "",siteCode="";
int updateCount=0;
double shortageAmtHdr=0.0;
ITMDBAccessEJB itmDBAccess = null;
ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility();
itmDBAccess = new ITMDBAccessEJB();
// ConnDriver connDriver = new ConnDriver();
connDriver = null;
// connStatus = true;
String objName = "", winName = "", eventCode = "";
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);
sql = "select status,site_code,shortage_amt from distrcp_exsh_hdr where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if (rs.next())
{
status = rs.getString("status");
siteCode = rs.getString("site_code");
shortageAmtHdr=rs.getDouble("shortage_amt");
}
System.out.println("Status@@@@@@@@" + status);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (status != null && status.equalsIgnoreCase("C"))
{
System.out.println("The Selected transaction is already Closed");
errString = itmDBAccessEJB.getErrorString("", "VTMCLOSE1", "","", conn);
return errString;
}
else /* (status != null && status.equalsIgnoreCase("O") */
{
sql = "select status from distrcp_exsh_det where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while (rs.next())
{
status = rs.getString("status");
System.out.println("Status : " + status);
if ("O".equalsIgnoreCase(status))
{
errString = itmDBAccessEJB.getErrorString("","VTMCLOSE2", "", "", conn);
return errString;
}
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
sql = "update distrcp_exsh_hdr set status = 'C', status_date = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDate(1, new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(2, tranId);
updateCount = pstmt.executeUpdate();
System.out.println("no of row update = " + updateCount);
System.out.println("Status Date"+ new java.sql.Date(new java.util.Date().getTime()));
System.out.println("tranId@@@@@@@@@" + tranId);
pstmt.close();
pstmt = null;
/*if (updateCoount > 0)//code comment by sagar on 19/05/15
{
errString = itmDBAccessEJB.getErrorString("", "VTEXCL001","", "", conn);//comment added by sagar on 19/05/15
}*/
//code added by sagar on 13/05/15, Start..
if(updateCount > 0)
{
System.out.println(">>In Close If update successfully then send intimation mail with report>>>");
DistRcpExShConf distRcpConf= new DistRcpExShConf();
errString=distRcpConf.sendMailReport(tranId, siteCode, shortageAmtHdr, xtraParams, conn);
//errString= sendMailReport(tranId,siteCode,shortageAmtHdr,xtraParams,conn);
System.out.println(">>>>In DistRcpExShClose after sendMailReport() errString:"+errString);
}
System.out.println(">>>>>>>Check errString:"+errString);
if((errString != null) && errString.indexOf("REPORTSUCC") > -1)
{
errString = itmDBAccessEJB.getErrorString("","VTEXCL001","","",conn);
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTFAILCLOS","","",conn);
}
//code added by sagar on 13/05/15, End.
}
}
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("VTEXCL001") > -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 close method
}// end of class
/********************************************************
Title : DistRcpExShConfLocal
Date : 13/MAY/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 DistRcpExShCloseLocal extends ActionHandlerLocal//,EJBObject
{
public String close(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : DistRcpExShConfRemote
Date : 13/MAY/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 DistRcpExShCloseRemote extends ActionHandlerRemote//, EJBObject
{
public String close(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
......@@ -6,13 +6,21 @@
package ibase.webitm.ejb.dis;
//import java.awt.geom.Arc2D.Double;
import java.rmi.RemoteException;
import java.sql.*;
import ibase.ejb.*;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
......@@ -30,17 +38,20 @@ public class DistRcpExShConf extends ActionHandlerEJB implements DistRcpExShConf
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "",sql1="";
String siteCode="";
ConnDriver connDriver = null;
String loginEmpCode = "";
String confirm = "",empCodeAprv="" ;
String empFName = "",empMName="",empLName="";
String errString = "" ;
String errString = "";
int updateCount=0;
double shortageAmtHdr=0.0,shortAmtVal=0.0;
GenericUtility genericUtility = GenericUtility.getInstance();
ValidatorEJB validatorEJB = null;
DistCommon distCommom = null;
ITMDBAccessEJB itmDBAccessEJB = null;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
connDriver = new ConnDriver();
......@@ -48,18 +59,17 @@ public class DistRcpExShConf extends ActionHandlerEJB implements DistRcpExShConf
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 = ?";
sql = "select confirmed,site_code,shortage_amt 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");
siteCode = rs.getString("site_code");
shortageAmtHdr=rs.getDouble("shortage_amt");
}
System.out.println("Cconfirm@@@@@@@@"+confirm);
rs.close();
......@@ -73,49 +83,43 @@ public class DistRcpExShConf extends ActionHandlerEJB implements DistRcpExShConf
errString = itmDBAccessEJB.getErrorString("","VTMCONF1","","",conn);
return errString;
}
else /*(confirm != null && confirm.equalsIgnoreCase("N") */
{
//comment for test
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);
updateCount = pstmt.executeUpdate();
System.out.println("no of row update: "+updateCount);
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())
/*if(updateCoount > 0)// comment added by sagar on 18/05/15
{
empFName = rs.getString("emp_fname");
empMName = rs.getString("emp_mname");
empLName = rs.getString("emp_lname");
errString = itmDBAccessEJB.getErrorString("","VTSTATSUBM ","","",conn);
}
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)
if(updateCount > 0) //code added by sagar on 13/05/15
{
System.out.println(">>In Submit If update successfully then send intimation mail with report>>>");
errString= sendMailReport(tranId,siteCode,shortageAmtHdr,xtraParams,conn);
System.out.println(">>>>In DistRcpExShConf after sendMailReport() errString:"+errString);
}
System.out.println(">>>>>>>Check errString:"+errString);
if((errString != null) && errString.indexOf("REPORTSUCC") > -1)
{
errString = itmDBAccessEJB.getErrorString("","VTCICONF3 ","","",conn);
errString = itmDBAccessEJB.getErrorString("","VTSTATSUBM","","",conn);
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTFAILSUBM","","",conn);
}
System.out.println("115 err String from confirm method.....");
}
}
......@@ -130,11 +134,12 @@ public class DistRcpExShConf extends ActionHandlerEJB implements DistRcpExShConf
{
try
{
System.out.println(">>>>>In finally errString:"+errString);
if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VTCICONF3") > -1)
if(errString.indexOf("VTSTATSUBM") > -1)
{
conn.commit();
conn.commit();
}
else
{
......@@ -162,4 +167,119 @@ public class DistRcpExShConf extends ActionHandlerEJB implements DistRcpExShConf
return errString;
}//end of confirm method
//method added by sagar on 19/05/15
public String sendMailReport(String tranId, String siteCode,double shortageAmtHdr,String xtraParams,Connection conn) throws ITMException
{
String retString="";
String xmlString="",reportName="",reportArgs="",reportType="",formatCode="",shortAmtValStr="";
double shortAmtVal=0.0;
DistCommon distCommom = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
distCommom = new DistCommon();
System.out.println(">>>>In sendMailReport method>>>");
E12ReportComp reportComp= new E12ReportComp();
reportName="d_distrcp_exc_shrt";
reportArgs="tran_id.String:tran_id,user_id.String:as_user_id,site_code.String:as_site";
reportType="PDF";
formatCode="DOM_REG";
shortAmtValStr = checkNull(distCommom.getDisparams("999999", "SHORT_AMT_VAL", conn));
System.out.println(">>>>>In mail tranId:"+tranId);
System.out.println(">>>>>In mail siteCode:"+siteCode);
System.out.println(">>>>>In mail shortageAmtHdr:"+shortageAmtHdr);
System.out.println(">>>>>In mail shortAmtValStr:"+shortAmtValStr);
if(shortAmtValStr!=null && shortAmtValStr.trim().length() > 0 && !shortAmtValStr.equals("NULLFOUND") )
{
shortAmtVal = Double.parseDouble(shortAmtValStr);
System.out.println(">>>>>>>>Disparm shortAmtVal:"+shortAmtVal);
}
if(shortageAmtHdr > shortAmtVal)
{
formatCode="DRCPSH_1"; // send mail for 'To' and 'Cc'.
System.out.println(">>>shortAmtVal is greater than disparm value then formatCode is:"+formatCode);
}
else
{
formatCode="DRCPSH";// send mail only for 'To'.
System.out.println(">>>shortAmtVal is less than disparm value then formatCode is:"+formatCode);
}
System.out.println(">>>>>>>>formatCode:"+formatCode);
StringBuffer xmlBuff = null;
xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='UTF-8'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("distrcp_exsh").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
xmlBuff.append("<Detail1 objContext=\"1\" objName=\"distrcp_exsh\" domID=\"\" dbID=\"\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
xmlBuff.append("<tran_id><![CDATA["+ tranId +"]]></tran_id>");
xmlBuff.append("<site_code><![CDATA["+ siteCode +"]]></site_code>");
xmlBuff.append("</Detail1>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString = xmlBuff.toString();
System.out.println(">>>>>>>>>>xmlString for sendReport:"+xmlString);
retString= reportComp.sendReport(xmlString, reportName, reportArgs, reportType, formatCode, xtraParams);
System.out.println(">>>retString from sendReport:"+retString);
}
catch(Exception e)
{
retString = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
return retString;
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
return input.trim();
}
private String getObjNameFromDom( Document dom, String attribute ) throws RemoteException,ITMException //for test
{
NodeList detailList = null;
Node currDetail = null;
String objName = "";
int detailListLength = 0;
try
{
detailList = dom.getElementsByTagName("Detail1");
detailListLength = detailList.getLength();
for (int ctr = 0; ctr < detailListLength; ctr++)
{
currDetail = detailList.item(ctr);
objName = currDetail.getAttributes().getNamedItem(attribute).getNodeValue();
}
}
catch ( Exception e )
{
throw new ITMException(e);
}
System.out.println("objName =["+objName+"]");
return objName;
}
}//end of class
/********************************************************
Title : DistRcpExShConfLocal
Date : 11/MAR/15
Date : 13/MAR/15
Developer: Pankaj R.
********************************************************/
......
/********************************************************
Title : DistRcpExShConfRemote
Date : 11/MAR/15
Date : 13/MAR/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import ibase.webitm.utility.ITMException;
......
......@@ -35,7 +35,6 @@ import javax.ejb.Stateless; // added for ejb3
public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, DistRcpExShICRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
//method for validation
......@@ -61,7 +60,6 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
}
return(errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
......@@ -82,14 +80,9 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
String locCode = "";
String quantity = "",lrDateStr="";
String keyFlag="",confirmed="",fldValue="";
String tranIdRcp="",tranId="",qtyactual="",reasCode="",status="";
String tranIdRcpHdr = "",lineNoRcp="",remarks2="";
String tranIdRcp="",tranId="",qtyactual="",reasCode="";
String tranIdRcpHdr = "",lineNoRcp="";
int ctr=0;
int cnt = 0;
int cnt1 = 0;
......@@ -125,24 +118,12 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
{
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());
// }
// }
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");
......@@ -151,37 +132,36 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
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())
tranId= genericUtility.getColumnValue("tran_id", dom);
if(tranId == null || (tranId.length() == 0))
{
cnt = rs.getInt(1);
if(cnt == 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())
{
errCode = "VMTRNIDINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
cnt = rs.getInt(1);
if(cnt == 0)
{
errCode = "VMTRNIDINV";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
}
else if(childNodeName.equalsIgnoreCase("tran_id__rcp"))
......@@ -214,7 +194,7 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
pstmt.close();
pstmt = null;
}
//}
}
else if(childNodeName.equalsIgnoreCase("site_code"))
{
......@@ -383,7 +363,7 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
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);
System.out.println("Reason code :"+reasCode);
if(((qtyRcp-qtyActual) > 0 || (qtyRcp-qtyActual) < 0) && (reasCode == null || reasCode.trim().length() == 0))
{
errCode = "VTREASCOD";
......@@ -417,8 +397,27 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
}
else if(childNodeName.equalsIgnoreCase("remarks2"))
{
remarks2=genericUtility.getColumnValue("remarks2", dom);
status = genericUtility.getColumnValue("status", 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("Status@@@@@@@@@@@@@ :"+status);
if(((qtyRcp-qtyActual) > 0 || (qtyRcp-qtyActual) < 0) && (!(status.equalsIgnoreCase("O"))) && ((remarks2==null || remarks2.trim().length()<=0)))
{
System.out.println("Inside if of REMARKS2@@@@@@@");
errCode = "VMREMARK";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("Completed of REMARKS2@@@@@@@");
}
else
{
System.out.println("Status is : "+status);
}
}
}
}//end switch
......@@ -527,7 +526,7 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
Node childNode = null;
SimpleDateFormat sdf =null;
Timestamp timestamp = null,expDate=null,mfgDate=null;
Timestamp lrDate=null,tranDate=null;
Timestamp lrDate=null,tranDate=null,gpDate=null;
String currDate="";
String childNodeName = null;
......@@ -538,12 +537,12 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
String chgUser = "";
String chgTerm = "";
String sql = "";
String siteDescr = "";
String locCode = "",lrDateStr="",tranDatedStr="";
String siteDescr = "",remarks2="";
String locCode = "",lrDateStr="",tranDatedStr="",gpDateStr="";
String locDescr = "";
String siteCodeMfg="",suppCodeMfg="";
String tranIdRcp="",distOrder="",tranId="",tranCode="",lrNo="",transMode="",grossWeight="";
String tareWeight="",netWeight="",noArt="",tranName="",tranIdIss="",tranDate1="";
String tareWeight="",netWeight="",noArt="",gpNo="",tranName="",tranIdIss="",tranDate1="",rate="";
String lotNo = "",lotSl="";
double quantity=0.0;
......@@ -559,16 +558,14 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
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);
......@@ -580,11 +577,10 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
System.out.println("@@@@@@ 1 siteCode["+siteCode+"]::::::siteDescr["+siteDescr+"]");
chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
currDate = (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 :
......@@ -614,6 +610,7 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
siteCode =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode")); //25/3/15 start
siteDescr = findValue(conn, "descr" ,"site", "site_code", siteCode);
System.out.println("@@@@@@ 1 siteCode["+siteCode+"]::::::siteDescr["+siteDescr+"]");
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + siteDescr + "]]>").append("</descr>"); // 25/3/15end
......@@ -621,7 +618,7 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
System.out.println("Receipt Date@@@@@@@@@@@@@@@@@:"+currDate);
//valueXmlString.append("<tran_date>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date>");
valueXmlString.append("<eff_date>").append("<![CDATA[" + currDate + "]]>").append("</eff_date>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + currDate + "]]>").append("</tran_date>");
valueXmlString.append("<add_date>").append("<![CDATA[" + currDate + "]]>").append("</add_date>");
valueXmlString.append("<add_user>").append("<![CDATA[" + chgUser + "]]>").append("</add_user>");
valueXmlString.append("<add_term>").append("<![CDATA[" + chgTerm + "]]>").append("</add_term>");
......@@ -634,18 +631,12 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
if(currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
valueXmlString.append("<chg_date>").append("<![CDATA[" + currDate + "]]>").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>");
......@@ -665,12 +656,10 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
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 tran_date,lr_no,lr_date,trans_mode,gross_weight,tare_weight,net_weight,no_art,tran_id__iss from distord_rcp where tran_id=?";
sql = "select tran_date,lr_no,lr_date,gp_date,gp_no,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();
......@@ -679,14 +668,14 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
tranDate=rs.getTimestamp("tran_date");
lrNo= checkNull(rs.getString("lr_no"));
lrDate= rs.getTimestamp("lr_date");
gpDate=rs.getTimestamp("gp_date");
gpNo=checkNull(rs.getString("gp_no"));
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;
......@@ -709,26 +698,33 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
}
valueXmlString.append("<lr_date>").append("<![CDATA[" + lrDateStr + "]]>").append("</lr_date>");
// if(tranDated != null)
// {
// tranDatedStr=sdf.format(lrDate).toString();
// }
// else
// {
// tranDatedStr="";
// }
if(gpDate != null)
{
System.out.println("In side iff>>>>>>>");
gpDateStr=sdf.format(gpDate).toString();
System.out.println("gpDateStr@@@@@@@"+gpDateStr);
}
else
{
String s1="";
System.out.println("inside else@@@@?????????");
gpDateStr=s1;
System.out.println("gpDateStr@@@@@@@"+gpDateStr);
}
valueXmlString.append("<gp_date>").append("<![CDATA[" + gpDateStr + "]]>").append("</gp_date>");
if(tranDate == null)
{
valueXmlString.append("<tran_date>").append("<![CDATA[" + currDate + "]]>").append("</tran_date>");
valueXmlString.append("<tran_date1>").append("<![CDATA[" + currDate + "]]>").append("</tran_date1>");
}
else
{
valueXmlString.append("<tran_date>").append("<![CDATA[" + sdf.format(tranDate) + "]]>").append("</tran_date>");
valueXmlString.append("<tran_date1>").append("<![CDATA[" + sdf.format(tranDate) + "]]>").append("</tran_date1>");
}
valueXmlString.append("<lr_no>").append("<![CDATA[" + lrNo + "]]>").append("</lr_no>");
valueXmlString.append("<gp_no>").append("<![CDATA[" + gpNo + "]]>").append("</gp_no>");
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>");
......@@ -737,7 +733,8 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
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"))
......@@ -748,6 +745,20 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
System.out.println("@@@@@ siteCode["+siteCode+"]siteDescr["+siteDescr+"]");
valueXmlString.append("<descr>").append("<![CDATA[" + siteDescr + "]]>").append("</descr>");
}
else if(currentColumn.trim().equalsIgnoreCase("tran_code"))
{
System.out.println("@@@@@@ tran_code itemchange called");
tranCode = genericUtility.getColumnValue("tran_code", dom);
tranName = findValue(conn, "tran_name", "transporter", "tran_code", tranCode);
System.out.println("@@@@@ Tran Code["+tranCode+"]Tran Name["+tranName+"]");
valueXmlString.append("<tran_name>").append("<![CDATA[" + tranName+ "]]>").append("</tran_name>");
System.out.println("Completed");
}
valueXmlString.append("</Detail1>");
break;
......@@ -771,14 +782,16 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
}
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
System.out.println("Entered in CASE@@@@@@@@@@@@@@@@222222222");
System.out.println("Entered in CASE2");
tranId = genericUtility.getColumnValue("tran_id", dom1);
tranIdRcp=genericUtility.getColumnValue("tran_id__rcp", dom1);
System.out.println("tranID@@@@@@@@@@@"+tranId);
System.out.println("TRANIDRCP@@@@@@@@@@@@@"+tranIdRcp);
System.out.println("tranID >>>>>>>> "+tranId);
System.out.println("TRANIDRCP@ >>>>>>>> "+tranIdRcp);
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
String status = genericUtility.getColumnValue("status", dom);
valueXmlString.append("<remarks2 protect = \"1\">").append("<![CDATA[" + remarks2 + "]]>").append("</remarks2>");
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>");
......@@ -794,23 +807,11 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
tranIdRcp = checkNull(genericUtility.getColumnValue("tran_id__rcp", dom));
lineNo = checkNull(genericUtility.getColumnValue("line_no__rcp", dom));
System.out.println("Line NO.>>>>>>>>>"+lineNo);
//lineNo = " " + lineNo.trim();
//lineNo = lineNo.substring( lineNo.length()-3 );
// if (lineNo.trim().length() > 0 )
// {
// valueXmlString.append("<line_no__rcp>").append("<![CDATA[" +lineNo+"]]>").append("</line_no__rcp>");
// }else
// {
// lineNo="0";
// System.out.println("LINE NO>>>>>>>>>>>"+lineNo);
// }
//if (tranIdRcp.trim().length() > 0 && lineNo.trim().length() > 0 )
if (lineNo!=null || lineNo.trim().length() > 0 )
{
System.out.println("In IF>>>>>>>>>>>>>>");
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,item_code,loc_code from distord_rcpdet where tran_id= ? and line_no= ? ";
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,item_code,loc_code,rate from distord_rcpdet where tran_id= ? and line_no= ? ";//pankaj 6/5/15
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdRcp);
pstmt.setString(2,lineNo);
......@@ -833,8 +834,7 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
suppCodeMfg= rs.getString("supp_code__mfg");
itemCode=rs.getString("item_code");
locCode=rs.getString("loc_code");
rate=rs.getString("rate");
itemDescr = findValue(conn, "descr" ,"item", "item_code", itemCode);
locDescr=findValue(conn, "descr", "location", "loc_code", locCode);
......@@ -877,16 +877,30 @@ public class DistRcpExShIC extends ValidatorEJB implements DistRcpExShICLocal, D
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("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
}
}
else if(currentColumn.trim().equalsIgnoreCase("status"))
{
System.out.println("@@@@@@ status itemchange called");
String status = genericUtility.getColumnValue("status", dom);
System.out.println("Status is : "+status);
remarks2="";
if(status != null && status.equalsIgnoreCase("O"))
{
System.out.println("inside open");
valueXmlString.append("<remarks2 protect = \"1\">").append("<![CDATA[" + remarks2 + "]]>").append("</remarks2>");
}
}
valueXmlString.append("</Detail2>");
break;
if(status != null && status.equalsIgnoreCase("C"))
{
System.out.println("inside close");
valueXmlString.append("<remarks2 protect = \"0\">").append("<![CDATA[" + remarks2 + "]]>").append("</remarks2>");
}
}
valueXmlString.append("</Detail2>");
break;
}//end of switch-case
valueXmlString.append("</Root>");
}
......
/********************************************************
Title : DistRcpExShICLocal
Date : 13/MAR/15
Date : 11/MAR/15
Developer: Pankaj R.
********************************************************/
......
/********************************************************
Title : DistRcpExShICRemote
Date : 13/MAR/15
Date : 11/MAR/15
Developer: Pankaj R.
********************************************************/
......
/********************************************************
Title : DistRcpExShPostSave
Date : 17/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.E12GenericUtility;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.w3c.dom.Node;
import javax.ejb.Stateless;
@Stateless
public class DistRcpExShPostSave extends ValidatorEJB implements DistRcpExShPostSaveLocal,DistRcpExShPostSaveRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
System.out.println("------------ postSave method called-----------------DistRcpExShPostSave : ");
System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]");
Document dom = null;
String errString="",lineNoRcp="";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception : DistRcpExShPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String postSave(Document dom,String tranId,String xtraParams,Connection conn)
{
System.out.println("in DistRcpExShPostSave postSave tran_id---->>["+tranId+"]");
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="",errorString="";
NodeList parentList = null;
NodeList childList = null;
Node parentNode = null;
Node childNode = null;
String lineNoDom="",lineNo="";
int count=0;
double quantityRcp=0,quantityActual=0,rate=0;
double shortageAmt=0,shortageAmtH=0;
try
{
E12GenericUtility genericUtility= new E12GenericUtility();
parentList = dom.getElementsByTagName("Detail2");
int parentNodeListLength = parentList.getLength();
for (int prntCtr = parentNodeListLength; prntCtr > 0; prntCtr-- )
{
parentNode = parentList.item(prntCtr-1);
childList = parentNode.getChildNodes();
for (int ctr = 0; ctr < childList.getLength(); ctr++)
{
childNode = childList.item(ctr);
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("line_no") )
{
lineNoDom = childNode.getFirstChild().getNodeValue().trim();
System.out.println("lineNo["+lineNo+"]lineNoDom["+lineNoDom+"]");
if (lineNo.equalsIgnoreCase(lineNoDom))
{
System.out.println("Break from here as line No match");
break;
}
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("qty_rcp") )
{
quantityRcp = Double.valueOf(childNode.getFirstChild().getNodeValue().trim());
System.out.println("quantityRcp-->["+quantityRcp+"]");
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("qty_actual") )
{
quantityActual = Double.valueOf(childNode.getFirstChild().getNodeValue().trim());
System.out.println("quantityActual-->["+quantityActual+"]");
}
if ( childNode != null && childNode.getFirstChild() != null &&
childNode.getNodeName().equalsIgnoreCase("rate") )
{
rate = Double.valueOf(childNode.getFirstChild().getNodeValue().trim());
}
}
System.out.println("rate-->["+rate+"] lineNo-->["+lineNo+"]");
shortageAmt=((quantityRcp)-(quantityActual)) * rate;
System.out.println("ShortageAmt--->>["+shortageAmt+"]");
shortageAmtH=shortageAmtH + shortageAmt;
System.out.println("ShortageAmtHHH--->>["+shortageAmtH+"]");
}//for loop
if (pstmt != null)
{
pstmt.close();
pstmt=null;
}
if (rs !=null)
{
rs.close();
rs=null;
}
System.out.println("shortageAmtH-->["+shortageAmtH+"]");
{
sql="update distrcp_exsh_hdr set shortage_amt = ? where tran_id = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1, shortageAmtH);
// pstmt.setDate(2, new java.sql.Date(new java.util.Date().getTime()));
pstmt.setString(2, tranId);
System.out.println("Shortage Amount : "+shortageAmtH);
count=pstmt.executeUpdate();
System.out.println("post count---->>["+count+"]");
if(count >0 )
{
conn.commit();
}
}
}
catch(Exception e)
{
System.out.println("Exception : DistRcpExShPostSave -->["+e.getMessage()+"]");
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("Exception while rollbacking transaction....");
e1.printStackTrace();
}
}
return errorString;
}
}
/********************************************************
Title : DistRcpExShPostSaveLocal
Date : 17/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface DistRcpExShPostSaveLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
/********************************************************
Title : DistRcpExShPostSaveRemote
Date : 17/MAY/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote;
@Remote
public interface DistRcpExShPostSaveRemote extends ValidatorRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) 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