Commit 12a2e605 authored by agaikwad's avatar agaikwad

Request-M16LNEL001

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@163505 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a331d42e
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.utility.ITMException;
@Stateless
public class QcOrderResultIC extends ValidatorEJB
{
E12GenericUtility genericUtility= new E12GenericUtility();
String winName = null;
FinCommon finCommon = null;
ValidatorEJB validator = null;
@Override
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag,String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
System.out.println("Validation Start..........");
System.out.println("Validation Start.....xmlString[" + xmlString+ "]]]]]xmlString1[[[[[" + xmlString1 + "]]]]]][[[[[[["+ xmlString2 + "]]]]]]].....");
try
{
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
retString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("retString:::"+retString);
}
catch(Exception e)
{
System.out.println(":::" + getClass().getSimpleName() + "::"+ e.getMessage());
e.getMessage();
}
return retString;
}
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 childNodeName = null;
StringBuffer valueXmlString = new StringBuffer();
String userId = "";
String tranId = "";
String tranDate = "";
String effDate = "";
String errCode= "";
String errString = "";
String siteCode = "";
String custCode = "";
String acctcode = "";
String taxClass ="";
String taxChap ="";
String taxEnv ="";
String cctrcode = "";
String lineNo="";
int ctr = 0;
String errorType = "";
String sql="";
int currentFormNo = 0;
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null;
E12GenericUtility genericUtility = new E12GenericUtility();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
ConnDriver connDriver =null;
SimpleDateFormat dateFormat2 = null;
java.util.Date trandate = null;
java.util.Date tranTempDate = null;
try
{
conn = getConnection();
/* connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;*/
userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
dateFormat2=new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo["+currentFormNo+"]");
}
switch(currentFormNo)
{
case 1:
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
int childNodeListLength = childNodeList.getLength();
tranId=checkNull(genericUtility.getColumnValue("tran_id", dom));
System.out.println("tran id from boqdet --4-->>>>["+tranId+"]");
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("CURRENT COLUMN IN VALIDATION ["+childNodeName+"]");
if (childNodeName.equalsIgnoreCase("tran_date"))
{
tranDate=genericUtility.getColumnValue("tran_date", dom);
System.out.println("TranDate"+tranDate);
if (tranDate == null)
{
errCode = "VMTRANDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
trandate = dateFormat2.parse(genericUtility.getColumnValue("tran_date", dom));
System.out.println("trandate["+trandate+"]");
tranTempDate = dateFormat2.parse(genericUtility.getColumnValue("tran_date", dom));
System.out.println("tranTempDate["+tranTempDate+"]");
if (trandate.before(tranTempDate))
{
errCode = "VTINVDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if (childNodeName.equalsIgnoreCase("eff_date"))
{
effDate=genericUtility.getColumnValue("eff_date", dom);
System.out.println("TranDate"+tranDate);
if (tranDate == null)
{
errCode = "VMTRANDT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if( childNodeName.equalsIgnoreCase("qorder_no"))
{
String qcOrdNo="",status="";
int cnt=0;
qcOrdNo = genericUtility.getColumnValue("qorder_no",dom);
System.out.println(">>>qcOrdNo Validation:" + qcOrdNo);
if(qcOrdNo != null && qcOrdNo.trim().length() > 0 )
{
sql = "select count(1) from qc_order where qorder_no = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, qcOrdNo);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>>>>qorder_no cnt:"+qcOrdNo);
if (cnt == 0)
{
errCode = "VMQCORM";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
sql="select status from qc_order where qorder_no= ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,qcOrdNo);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>>>>status:"+status);
if ("C".equalsIgnoreCase(status) || "X".equalsIgnoreCase(status))
{
errCode = "VTQCUNCONF";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VTQCNOBLNK";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} // end Qc Order
if( childNodeName.equalsIgnoreCase("emp_code"))
{
String empCode="";
int cnt=0;
empCode = genericUtility.getColumnValue("emp_code",dom);
System.out.println(">>>emp_code Validation:" + empCode);
if(empCode != null && empCode.trim().length() > 0 )
{
sql = "select count(1) FROM surveyor WHERE SURV_CODE =? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>>>>emp_code cnt:"+empCode);
if (cnt == 0)
{
errCode = "VMSURVCOD";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
else
{
errCode = "VMECODNLL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
if( childNodeName.equalsIgnoreCase("emp_passed_qty"))
{
String empPassQty="",qtyPassed="",qtyRejected="",quantity="";
double empPQty=0;
double qtyPass=0,qtyReject=0,qty=0,sumQty=0;
int cnt=0;
empPassQty = genericUtility.getColumnValue("emp_passed_qty",dom);
qtyPassed = genericUtility.getColumnValue("qty_passed",dom);
qtyRejected = genericUtility.getColumnValue("qty_rejected",dom);
quantity = genericUtility.getColumnValue("quantity",dom);
System.out.println(">>>emp_passed_qty Validation:" + empPassQty);
if(empPassQty !=null && empPassQty.trim().length() > 0)
{
empPQty=Double.parseDouble(empPassQty);
}
else
{
empPQty=0;
}
if(empPQty<=0)
{
errCode = "VTNEGAMT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
qtyPass = qtyPassed == null ? 0 : Double.parseDouble(qtyPassed);
qtyReject = qtyRejected == null ? 0 : Double.parseDouble(qtyRejected);
qty = quantity == null ? 0 : Double.parseDouble(quantity);
sumQty=qtyPass+qtyReject+empPQty;
System.out.println("sumQty["+sumQty+"] = qtyPass["+qtyPass+"] + qtyReject["+qtyReject+"] + empPQty["+empPQty);
if(sumQty > qty)
{
errCode = "VTEXDQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
String refSer="";
for (ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("spec_code"))
{
String mseq = "", mVal = "", mscode = "";
int cnt=0;
mscode = genericUtility.getColumnValue("spec_code", dom);
mVal = genericUtility.getColumnValue("qorder_no", dom);
sql = "select count(*) from qc_ord_spec where qorder_no = ? and spec_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mVal);
pstmt.setString(2, mscode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println(">>>>>>>>qc_ord_spec cnt:" + cnt);
if (cnt == 0) {
errCode = "VTQCS1";
errString = getErrorString("spec_code", errCode,userId);
break;
}
}
}
break;
}
int errListSize = errList.size();
System.out.println("errListSize::::::::::"+errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString>>>>>>>>>"+errString);
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("");
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ 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;
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
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();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom1 = null;
Document dom = null;
Document dom2 = null;
String valueXmlString = "";
try
{
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :QcOrderResultIC(String,String,String,String,String,String):" + e.getMessage() + ":");
valueXmlString = genericUtility.createErrorString(e);
e.printStackTrace();
}
System.out.println("returning from QcOrderResultIC itemChanged");
return (valueXmlString);
}
@Override
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
System.out.println("@@@@@@@ QcOrderResultIC itemChanged called");
String childNodeName = null;
String sql = "";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
E12GenericUtility genericUtility = new E12GenericUtility();
ConnDriver connDriver =null;
//Added
System.out.println("Dom"+dom);
System.out.println( "dom1"+dom1);
System.out.println( "objcontext"+objContext);
try
{
conn = getConnection();
/*connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;*/
this.finCommon = new FinCommon();
if ((objContext != null) && (objContext.trim().length() > 0))
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
switch (currentFormNo)
{
case 1 :
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '"+ currentColumn + "'");
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
String currAppdate ="";
java.sql.Timestamp currDate = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate);
System.out.println("currAppdate["+currAppdate+"]");
valueXmlString.append("<tran_date>").append("<![CDATA["+currAppdate+"]]>").append("</tran_date>");
valueXmlString.append("<eff_date>").append("<![CDATA["+currAppdate+"]]>").append("</eff_date>");
}
else if(currentColumn.trim().equalsIgnoreCase("qorder_no"))
{
double Qty=0,QtyPass=0,QtyRej=0;
double SumQtyPass=0,SumQtyRej=0;
String qcOrder="",lotNo="",itemCode="",descr="";
qcOrder = checkNull(genericUtility.getColumnValue("qorder_no", dom));
if( qcOrder != null && qcOrder.trim().length() > 0)
{
sql = "select quantity,lot_no,item_code from qc_order where qorder_no=? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,qcOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
Qty =rs.getDouble(1);
lotNo = rs.getString(2) == null ? "" : rs.getString(2);
itemCode =rs.getString(3) == null ? "" : rs.getString(3);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("Qty["+Qty+"]lotNo["+lotNo+"]itemCode["+itemCode+"]");
sql="select descr from item where item_code= ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
descr =rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<quantity>").append("<![CDATA["+Qty+"]]>").append("</quantity>");
valueXmlString.append("<item_code>").append("<![CDATA["+itemCode.trim()+"]]>").append("</item_code>");
valueXmlString.append("<descr>").append("<![CDATA["+descr.trim()+"]]>").append("</descr>");
valueXmlString.append("<lot_no>").append("<![CDATA["+lotNo+"]]>").append("</lot_no>");
sql="select sum(emp_passed_qty )from qc_ord_res where qorder_no= ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,qcOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
SumQtyRej =rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<qty_passed>").append("<![CDATA["+SumQtyRej+"]]>").append("</qty_passed>");
sql="select sum(emp_rejected_qty )from qc_ord_res where qorder_no= ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,qcOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
SumQtyPass =rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<qty_rejected>").append("<![CDATA["+SumQtyPass+"]]>").append("</qty_rejected>");
}
}
valueXmlString.append("</Detail1>");
break;
case 2 :
valueXmlString.append("<Detail2>");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '"+ currentColumn + "'");
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
String qorderNo="";
qorderNo = checkNull(this.genericUtility.getColumnValue("qorder_no",dom1));
System.out.println("siteCode["+qorderNo+"]");
valueXmlString.append("<qorder_no>").append("<![CDATA["+qorderNo+"]]>").append("</qorder_no>");
}
valueXmlString.append("</Detail2>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+ 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();
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
\ No newline at end of file
/********************************************************
Title : QcOrderResultICLocal[M16LNEL001]
Date : 11/09/17
Developer: Abhijit Gaikwad
********************************************************/
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import org.w3c.dom.Document;
import javax.ejb.Local;
public interface QcOrderResultICLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlCurrFrmString, String xmlHdrFrmString, String xmlAllFrmString, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/********************************************************
Title : QcOrderResultICRemote[M16LNEL001]
Date : 11/09/17
Developer: Abhijit Gaikwad
********************************************************/
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface QcOrderResultICRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(Document currDom, Document hdrDom, Document allDom, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(String xmlCurrFrmString, String xmlHdrFrmString, String xmlAllFrmString, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlCurrFrmString, String xmlHdrFrmString,String xmlAllFrmString, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document currDom, Document hdrDom, Document allDom, 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