Commit fc4173ba authored by ssalve's avatar ssalve

Sarita : Done changes for line_no__rcp validation on 24 OCT 2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@192282 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ab2a2c35
......@@ -10,6 +10,10 @@ import java.util.ArrayList;
import java.util.Calendar;
import javax.ejb.Stateless;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
......@@ -27,7 +31,7 @@ import ibase.webitm.utility.ITMException;
@Stateless
public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
PoReturnICRemote {
PoReturnICRemote {
E12GenericUtility genericUtility = new E12GenericUtility();
FinCommon finCommon = new FinCommon();
......@@ -90,7 +94,7 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
int currentFormNo = 0, recCnt = 0;
FinCommon fincommon = new FinCommon();
DistCommon discommon = new DistCommon();
// Timestamp mdate1 = null, mdate2 = null, ldt_date = null, ordDate = null,trandatePO1=null,Date1=null,Date2=null;
// Timestamp mdate1 = null, mdate2 = null, ldt_date = null, ordDate = null,trandatePO1=null,Date1=null,Date2=null;
String tranDateStr="",siteCode="",modName="",purcOrder="",isNullPo="",tranidPO="",tranDateStrPO="";
String status="",empCodeaprv="",ordDate1="",lsconfirmed="",lsproviid="",lspotype="",tranType="",cwipTranType="",porcpTranType="";
String lsitemcode="",prdCode="",siteCodlogin="",statFin="",errorType="";
......@@ -156,6 +160,7 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
double lc_stk_qty=0.0,lc_qty_std=0.0, lc_order_qty=0.0 , lc_porcpqty=0.0, lc_ct3_qty=0.0, lc_qty_used=0.0;
String lsmsg="",startStr="",endStr="",descrStr="",descrStart="",descrEnd="",value="";
String lineNoRcp = "";//Added by sarita on 16 OCT 2018
int lineCnt = 0;//Added by sarita on 24 OCT 2018
try {
System.out.println("@@@@@@@@ wfvaldata called");
//conn = connDriver.getConnectDB("DriverITM");
......@@ -1051,7 +1056,6 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
}
}
}//end item code case childNodeName.equalsIgnoreCase("line_no__ord")
......@@ -1629,35 +1633,55 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
if (rs.next())
{
lc_rcp_qty = rs.getDouble(1);
}
System.out.println("lc_rcp_qty@@@["+lc_rcp_qty+"]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//Added by sarita on 22 OCT 18 [START]
if (detlList != null)
{
for (int cntr = 0; cntr < detlList.getLength(); cntr++)
int QtyLineNo = 0;
lineNoRcp =genericUtility.getColumnValue("line_no__rcp",dom);
if(lineNoRcp != null)
{
Element tblQty = dom2.createElement("table_qty");
tblQty.appendChild(dom2.createTextNode(String.valueOf(lc_rcp_qty)));
detlList.item(cntr).appendChild(tblQty);
}
QtyLineNo = Integer.parseInt(lineNoRcp);
}
//Added by sarita on 22 OCT 18 [END]
System.out.println("Line Number Receipt is ["+QtyLineNo+"]");
double lineQty = 0.0;
sql="select case when sum(quantity) is null then 0 else sum(quantity) end from porcpdet " +
" where tran_id=? and purc_order = ? and "+
" line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdRef);
pstmt.setString(2,purcOrder);
pstmt.setInt(3,QtyLineNo);
rs = pstmt.executeQuery();
if (rs.next())
{
lineQty = rs.getDouble(1);
}
System.out.println("lc_rcp_qty@@@["+lc_rcp_qty+"]");
System.out.println("lineQty@@@["+lineQty+"]");
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//Added by sarita on 22 OCT 18 [START]
Double det2Qty = getSumOfDetail2Quantity(dom2);
Double tableQty = getSumOfTableQuantity(dom2);
System.out.println("Detail 2 Final Value is === " + det2Qty + "Table Quantity is " +tableQty);
if(det2Qty > tableQty)
Double det2Qty = getSumOfDetail2Quantity(dom2,QtyLineNo);
System.out.println("Detail 2 Final Value is === " + det2Qty );
if( det2Qty > lineQty )
{
errCode = "VTINVPQTY";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
//Added by sarita on 22 OCT 18 [END]
sql="select case when sum(porcpdet.quantity) is null then 0 else sum(porcpdet.quantity) end " +
"from porcp,porcpdet " +
"where porcp.tran_id = porcpdet.tran_id "+
......@@ -1701,7 +1725,7 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
{
sql="select b.quantity from porder a, porddet b " +
" where a.purc_order = b. purc_order " +
" and a.purc_order = ? and b.line_no = ? ";
" and a.purc_order = int lineCnt = 0;? and b.line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,purcOrder);
pstmt.setString(2,lineNoOrd);
......@@ -2187,6 +2211,35 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
//Added by sarita on 24 OCT 2018 to validate line No for wrong lineNo[START]
else
{
ArrayList<Integer> linNoList = new ArrayList<Integer>();
int lineNo = Integer.parseInt(lineNoRcp);
sql = "select line_no from porcpdet where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdRef);
rs = pstmt.executeQuery();
while(rs.next())
{
lineCnt = rs.getInt("line_no"); System.out.println("lineNo["+lineNo+"] \t lineCnt["+lineCnt+"]");
linNoList.add(lineCnt);
}
if(rs != null) {
rs.close();
rs = null; }
if(pstmt != null) {
pstmt.close();
pstmt = null; }
System.out.println("linNoList ["+linNoList.isEmpty()+"] \t Size ["+linNoList.size()+"] \t ["+linNoList+"]");
if((linNoList.isEmpty() == false) && (!(linNoList.contains(lineNo))))
{
errCode = "VTINVRCPNO";//Invalid line no Rcp
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//Added by sarita on 24 OCT 2018 to validate line No for wrong lineNo[END]
}
}
//Added by sarita for line_no__rcp Validation on 16 OCT 2018 [END]
......@@ -3408,7 +3461,7 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
/*valueXmlString.append("<gp_ser>")
.append("<![CDATA[" + ls_retopt + "]]>")
.append("</gp_ser>");// dhiraj
*/
*/
} else if (currentColumn.trim().equalsIgnoreCase("tran_type")) {
// mcode = dw_edit.getitemstring(1,colname)
mcode = checkNull(genericUtility.getColumnValue("ret_opt",
......@@ -6642,8 +6695,12 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
"item_code", dom));
ls_site = checkNull(genericUtility.getColumnValue(
"site_code", dom1));
//Added by sarita on 24 OCT 2018 [START]
/*ldt_trandtStr = checkNull(genericUtility.getColumnValue(
"tran_date", dom));*/
ldt_trandtStr = checkNull(genericUtility.getColumnValue(
"tran_date", dom));
"tran_date", dom1));
//Added by sarita on 24 OCT 2018 [END]
mPordNo = checkNull(genericUtility.getColumnValue(
"purc_order", dom));
mrateStr = checkNull(genericUtility.getColumnValue("rate",
......@@ -7417,22 +7474,36 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
}
//Added by sarita to get Detail2 total quantity on 22 OCT 2018 [START]
private double getSumOfDetail2Quantity(Document dom2) throws ITMException
private double getSumOfDetail2Quantity(Document dom2, int lineNoRcp) throws ITMException
{
double quantity = 0.0 ,qtyDet = 0.0 ,tblQtyVal = 0.0,tblQty = 0.0;
NodeList detlList = null;
int lineNo = 0 , QtyLineNo = 0;
int cntr = 0;
String lineNoStr = "";
try
{
XPathFactory xpathFactory1 = XPathFactory.newInstance();
XPath xpath1 = xpathFactory1.newXPath();
lineNoStr = String.valueOf(lineNoRcp);
System.out.println("ABCD ["+genericUtility.serializeDom(dom2)+"]");
detlList = dom2.getElementsByTagName("Detail2");
System.out.println("LINE NO RECEIPT 1 ["+lineNoRcp+"]");
//detlList = dom2.getElementsByTagName("Detail2");
detlList = getNodebyValue(dom2, xpath1, lineNoStr, "line_no__rcp");
System.out.println("detlList---["+detlList+"]");
if (detlList != null)
{
for (cntr = 0; cntr < detlList.getLength(); cntr++)
{
lineNo = Integer.parseInt(genericUtility.getColumnValueFromNode("line_no__rcp", detlList.item(cntr)));
System.out.println("lineNo ["+lineNo+"]");
if(QtyLineNo == lineNo)
{
qtyDet = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", detlList.item(cntr)));
System.out.println("qtyDet ["+qtyDet+"]");
quantity = quantity + qtyDet;
System.out.println("IF getSumOfDetail2Quantity.....1 .. ["+quantity+"]");
}
}
}
System.out.println("Value of qtyDet ["+quantity+"] + counter is ["+cntr+"]");
......@@ -7444,33 +7515,6 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
}
return quantity;
}
private double getSumOfTableQuantity(Document dom2) throws ITMException
{
double quantity = 0.0 ,qtyDet = 0.0 ,tblQtyVal = 0.0,tblQty = 0.0;
NodeList detlList = null;
int cntr = 0;
try
{
System.out.println("ABCD ["+genericUtility.serializeDom(dom2)+"]");
detlList = dom2.getElementsByTagName("Detail2");
if (detlList != null)
{
for (cntr = 0; cntr < detlList.getLength(); cntr++)
{
tblQtyVal = Double.parseDouble(genericUtility.getColumnValueFromNode("table_qty", detlList.item(cntr)));
tblQty = tblQty + tblQtyVal;
}
}
System.out.println("Value tblQtyVal ["+tblQty+"] + counter is ["+cntr+"]");
}
catch(Exception e)
{
System.out.println("[Inside getSumOfDetail2Quantity]" + e);
throw new ITMException(e);
}
return tblQty;
}
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
{
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
......@@ -7491,5 +7535,27 @@ public class PoReturnIC extends ValidatorEJB implements PoReturnICLocal,
}
tempNode = null;
}
private NodeList getNodebyValue(Document doc, XPath xpath,String value,String columnName)
{
NodeList nodes = null;
XPathExpression expr = null;
try
{
if("line_no__rcp".equalsIgnoreCase(columnName))
{
expr = xpath.compile("//Detail2 [line_no__rcp = '"+ value +"']");
}
System.out.println("expr ==>["+ expr +"]");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
nodes = (NodeList) result;
System.out.println(" NodeLength ==> ["+nodes.getLength()+"]");
}
catch (Exception e)
{
System.out.println("in the Node Exception ==> ["+ e.getMessage() +"]");
}
return nodes;
}
//Added by sarita to get Detail2 total quantity on 22 OCT 2018 [END]
}
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