Commit c2ba4f21 authored by cpatil's avatar cpatil

modify code for slow issue


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98127 ce508802-f39f-4f6c-b175-0d175dae99d5
parent fe9e4f1e
...@@ -17,10 +17,12 @@ import java.text.DateFormat; ...@@ -17,10 +17,12 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -47,6 +49,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -47,6 +49,7 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
{ {
System.out.println("------------ wfvalData method called-----------------"); System.out.println("------------ wfvalData method called-----------------");
System.out.println("xtraParams --->>> [[" + xtraParams + " ]]"); System.out.println("xtraParams --->>> [[" + xtraParams + " ]]");
System.out.println("xmlString --->>> [[" + xmlString + " ]]");
System.out.println("xmlString1 --->>> [[" + xmlString1 + " ]]"); System.out.println("xmlString1 --->>> [[" + xmlString1 + " ]]");
System.out.println("xmlString2 --->>> [[" + xmlString2 + " ]]"); System.out.println("xmlString2 --->>> [[" + xmlString2 + " ]]");
System.out.println("editFlag --->>> [[" + editFlag + " ]]"); System.out.println("editFlag --->>> [[" + editFlag + " ]]");
...@@ -97,8 +100,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -97,8 +100,8 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
DateFormat sourceFormat = new SimpleDateFormat("dd/MM/yyyy"); DateFormat sourceFormat = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date newBillDate=new java.util.Date(); java.util.Date newBillDate=new java.util.Date();
java.util.Date newInvDate=new java.util.Date(); java.util.Date newInvDate=new java.util.Date();
// java.sql.Date newInvDate=null; // java.sql.Date newInvDate=null;
// java.sql.Date wDate=null; // java.sql.Date wDate=null;
try try
{ {
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
...@@ -587,29 +590,29 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -587,29 +590,29 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
{ {
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
invoiceDate = sdf.format(invDateT); invoiceDate = sdf.format(invDateT);
// newInvDate=new java.sql.Date(invDateT.getTime());; // newInvDate=new java.sql.Date(invDateT.getTime());;
// billDate=sdf.format(billDate); // billDate=sdf.format(billDate);
newInvDate=sourceFormat.parse(invoiceDate); newInvDate=sourceFormat.parse(invoiceDate);
newBillDate=sourceFormat.parse(billDate); newBillDate=sourceFormat.parse(billDate);
System.out.print("stkBillDate121------->>>>>>>>>>>[" + billDate + "]"); System.out.print("stkBillDate121------->>>>>>>>>>>[" + billDate + "]");
System.out.print("invoice confDate ------->>>>>>>>>>>[" + invoiceDate + "]"); System.out.print("invoice confDate ------->>>>>>>>>>>[" + invoiceDate + "]");
// sql = "select to_date( ?,'dd-mm-yyyy') - to_date( ?,'dd-mm-yyyy') from dual"; // sql = "select to_date( ?,'dd-mm-yyyy') - to_date( ?,'dd-mm-yyyy') from dual";
// pstmt = conn.prepareStatement(sql); // pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, billDate); // pstmt.setString(1, billDate);
// pstmt.setString(2, invoiceDate); // pstmt.setString(2, invoiceDate);
// rs = pstmt.executeQuery(); // rs = pstmt.executeQuery();
// if (rs.next()) // if (rs.next())
// { // {
// diffDays = rs.getInt(1); // diffDays = rs.getInt(1);
// } // }
// rs.close(); // rs.close();
// rs = null; // rs = null;
// pstmt.close(); // pstmt.close();
// pstmt = null; // pstmt = null;
// diffDays=(int)countDaysBetween(wDate,todayDate); // diffDays=(int)countDaysBetween(wDate,todayDate);
// diffDays=(int)countDaysBetween(newInvDate,newBillDate); //VALLABH KADAM 24/DEC/14 get diffrence between DAYS // diffDays=(int)countDaysBetween(newInvDate,newBillDate); //VALLABH KADAM 24/DEC/14 get diffrence between DAYS
diffDays=(int)countDaysBetween(newInvDate,newBillDate); //VALLABH KADAM 24/DEC/14 get diffrence between DAYS diffDays=(int)countDaysBetween(newInvDate,newBillDate); //VALLABH KADAM 24/DEC/14 get diffrence between DAYS
System.out.println("Difference in days for validation--->>[" + diffDays + "]"); System.out.println("Difference in days for validation--->>[" + diffDays + "]");
...@@ -619,7 +622,16 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -619,7 +622,16 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
System.out.println("currTranId--->>[" + currTranId + "]"); System.out.println("currTranId--->>[" + currTranId + "]");
System.out.println("Edit flag133BD--->>[" + editFlag + "]"); System.out.println("Edit flag133BD--->>[" + editFlag + "]");
if (isBillNoRepeatedInYear(conn, billNo, billDate, custCodeCurr, currTranId)) if (isBillNoRepeatedInDetail2(dom, dom2, billNo, billDate, currTranId,conn))
{
System.out.println("------bill no repeated in detail2---------");
errCode = "VTBLBDNRP";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
if (isBillNoRepeatedInYear(conn, billNo, billDate, custCodeCurr, currTranId,xtraParams))
{ {
System.out.println("------bill and stockist and year matched-----------"); System.out.println("------bill and stockist and year matched-----------");
errCode = "VTBLBDNRP"; errCode = "VTBLBDNRP";
...@@ -722,7 +734,65 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -722,7 +734,65 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
return errStringXml.toString(); return errStringXml.toString();
} }
// public long countDaysBetween(java.sql.Date startdate, java.util.Date enddate) private boolean isBillNoRepeatedInDetail2(Document dom,Document dom2, String billNo,String billDate, String currTranId,Connection conn) throws Exception
{
System.out.println("@@@@@@ isBillNoRepeatedInDetail2 () called.........");
String errString = "",lineNoCurrent="",updateStatus="";
int ctr1=0,k=0,l=1,noOfParent=0;
NodeList detail2List = dom2.getElementsByTagName("Detail2");
NodeList Currentdetail2List = dom.getElementsByTagName("Detail2");
//parentNodeList = dom.getElementsByTagName("Detail1");
Node parentNode = Currentdetail2List.item(0);
NodeList childNodeList = parentNode.getChildNodes();
int childNodeListLength = childNodeList.getLength();
for(int ctr = 0; ctr < childNodeListLength; ctr++)
{
Node childNode = childNodeList.item(ctr);
String childNodeName = childNode.getNodeName();
//System.out.println("@@@@@@@@ for line_no childNodeName["+childNodeName+"]");
if(childNodeName.equalsIgnoreCase("line_no"))
{
lineNoCurrent = genericUtility.getColumnValue("line_no",dom);
}
}
System.out.println("@@@@ billNo:["+billNo+"]::billDate:["+billDate+"]lineNoCurrent["+lineNoCurrent+"]");
if(detail2List != null && detail2List.getLength() > 0)
{
noOfParent = detail2List.getLength();
System.out.println("@@@@@@@@ noOfParent [["+noOfParent +"]]");
for ( ctr1 = 0; ctr1 < noOfParent; ctr1++ ) //Loop for each node of current detail
{
String lineNoDet2 = genericUtility.getColumnValueFromNode( "line_no", detail2List.item(ctr1) );
String billNoDet2 = genericUtility.getColumnValueFromNode( "bill_no", detail2List.item(ctr1) );
String billDateDet2 = genericUtility.getColumnValueFromNode( "bil_date", detail2List.item(ctr1) );
updateStatus = checkNull(getCurrentUpdateFlag(dom2.getElementsByTagName("Detail2").item(ctr1)));
/*if ("Attribute".equalsIgnoreCase(detail2List.item(ctr1).getNodeName()) )
{
updateStatus =detail2List.item(ctr1).getAttributes().getNamedItem("updateFlag").getNodeValue();
}*/
// String editFlag = genericUtility.getColumnValueFromNode( "edit_flag", detail2List.item(ctr1) );
// updateStatus = checkNull(getCurrentUpdateFlag(dom2.getElementsByTagName("Detail2").item(i)));
System.out.println("@@@@ ctr1["+ctr1+"]updateStatus["+updateStatus+"]billNoDet2:["+billNoDet2+"]billDateDet2["+billDateDet2+"]lineNoDet2["+lineNoDet2+"]");
if( ( "A".equalsIgnoreCase(updateStatus) || "E".equalsIgnoreCase(updateStatus) || "N".equalsIgnoreCase(updateStatus) ) && billNo.equalsIgnoreCase(billNoDet2) && (! lineNoCurrent.equalsIgnoreCase(lineNoDet2) ) )
{
System.out.println("@@@@ duplicate data found......");
return true;
}
}
}
System.out.println("@@@@ duplicate data not found......");
return false;
}
// public long countDaysBetween(java.sql.Date startdate, java.util.Date enddate)
public long countDaysBetween(java.util.Date startdate, java.util.Date enddate) public long countDaysBetween(java.util.Date startdate, java.util.Date enddate)
{ {
...@@ -744,17 +814,19 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -744,17 +814,19 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
return (endTime - startTime)/(1000 * 60 * 60 * 24) ; return (endTime - startTime)/(1000 * 60 * 60 * 24) ;
} }
private boolean isBillNoRepeatedInYear(Connection conn, String billNoL, String stockistDateL, String currCustCode, String currTranIdL) private boolean isBillNoRepeatedInYear(Connection conn, String billNoL, String stockistDateL, String currCustCode, String currTranIdL, String xtraParams)
{ {
System.out.println("--------in isBillNoRepeated method-------"); System.out.println("--------in isBillNoRepeatedInYear() method-------");
billNoL = billNoL == null ? "" : billNoL.trim(); billNoL = billNoL == null ? "" : billNoL.trim();
System.out.println("BollNoL-------->>" + billNoL); System.out.println("billNoL-------->>" + billNoL);
ResultSet rs = null, rs1 = null; ResultSet rs = null, rs1 = null;
PreparedStatement pstmt = null, pstmt1 = null; PreparedStatement pstmt = null, pstmt1 = null;
int currStkYear = 0, actStkYear = 0; int currStkYear = 0, actStkYear = 0;
ArrayList<String> tranIDList = new ArrayList<String>(); ArrayList<String> tranIDList = new ArrayList<String>();
String sql = "", sql1 = "", billNo = "", custCode = "", tranId = ""; String sql = "", sql1 = "", billNo = "", custCode = "", tranId = "";
Timestamp stockistDate = null; Timestamp stockistDate = null;
Timestamp frDate = null, toDate = null;
String currDate = "", frDateStr = "", traDateStr = "", toDateStr = "";
try try
{ {
...@@ -767,6 +839,65 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -767,6 +839,65 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
System.out.println("Current stk Year------>>[" + CurrYear + "]"); System.out.println("Current stk Year------>>[" + CurrYear + "]");
currStkYear = Integer.parseInt(CurrYear); currStkYear = Integer.parseInt(CurrYear);
int cnt = 0;
// String prdCode="";
// String siteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
sql1 = "select fr_date,to_date from acctprd where ? between fr_date and to_date";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1, stkTimest);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
frDate = rs1.getTimestamp("fr_date");
toDate = rs1.getTimestamp("to_date");
}
frDateStr = sdf.format(frDate).toString();
toDateStr = sdf.format(toDate).toString();
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
System.out.println("From Date["+frDateStr+"]To Date["+toDate+"]tranID:["+currTranIdL+"]");
if ( currTranIdL == null || currTranIdL.trim().length() == 0)
{
currTranIdL = "@@@@@@@@@@";
}
System.out.println("tranID:["+currTranIdL+"]");
sql = " select count(1) from spl_sales_por_hdr h, spl_sales_por_det d " +
" where h.tran_id = d.tran_id and d.bill_no = ? " +
" and d.bil_date BETWEEN ? AND ? " +
" and d.tran_id <> ? and h.wf_status <> 'R' " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, billNoL);
pstmt.setTimestamp(2, frDate);
pstmt.setTimestamp(3, toDate);
pstmt.setString(4, currTranIdL);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("cnt" + cnt);
if( cnt > 0)
{
System.out.println("@@@@@@@@ bill_no and bill_date already exist...........");
return true;
}
// commented by cpatil on 18/06/15 for execution time issue.
/*
sql = "select tran_id,cust_code from spl_sales_por_hdr"; sql = "select tran_id,cust_code from spl_sales_por_hdr";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -844,7 +975,11 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -844,7 +975,11 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
pstmt = null; pstmt = null;
} }
} }
} catch (Exception e) */
}
catch (Exception e)
{ {
System.out.println("--------Exception : in isBillNoRepeated method----------"); System.out.println("--------Exception : in isBillNoRepeated method----------");
isError = true; isError = true;
...@@ -2007,12 +2142,15 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca ...@@ -2007,12 +2142,15 @@ public class ProofOfDelivery extends ValidatorEJB implements ProofOfDeliveryLoca
for (int i = 0; i < currDetailListLength; i++) for (int i = 0; i < currDetailListLength; i++)
{ {
nodeName = currDetailList.item(i).getNodeName(); nodeName = currDetailList.item(i).getNodeName();
System.out.println("@@@@@@@@@@@@@@ nodeName["+nodeName+"]");
if (nodeName.equalsIgnoreCase("Attribute")) if (nodeName.equalsIgnoreCase("Attribute"))
{ {
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue(); updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
System.out.println("@@@@@@@@@@@@@@ inside if i["+i+"]updateStatus["+updateStatus+"]");
break; break;
} }
} }
System.out.println("@@@@@@@@@@@@@@ updateStatus["+updateStatus+"]");
return updateStatus; return updateStatus;
} }
......
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