Commit 3f54ed1b authored by manohar's avatar manohar

code optimization


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104048 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 64e3151f
...@@ -81,8 +81,10 @@ public class PostOrdCreditChk ...@@ -81,8 +81,10 @@ public class PostOrdCreditChk
//E12GenericUtility e12GenericUtility = new E12GenericUtility(); //E12GenericUtility e12GenericUtility = new E12GenericUtility();
ArrayList<String> retArrayList = new ArrayList<String>(); ArrayList<String> retArrayList = new ArrayList<String>();
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try try
{ {
startTime = System.currentTimeMillis();
Timestamp currDate = new java.sql.Timestamp(System.currentTimeMillis()); Timestamp currDate = new java.sql.Timestamp(System.currentTimeMillis());
mailList = new ArrayList(); mailList = new ArrayList();
...@@ -3374,6 +3376,16 @@ public class PostOrdCreditChk ...@@ -3374,6 +3376,16 @@ public class PostOrdCreditChk
// } // }
// } // }
//} //}
endTime = System.currentTimeMillis();
totalTime = endTime - startTime;
totSecs = (int) (((double) 1 / 1000) * (totalTime));
totalHrs = (int) (totSecs / 3600);
totlMts = (int) (((totSecs - (totalHrs * 3600)) / 60));
totSecs = (int) (totSecs - ((totalHrs * 3600) + (totlMts * 60)));
System.out.println("Total Time Spend credit check [" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
} }
catch( Exception e) catch( Exception e)
{ {
......
...@@ -112,8 +112,9 @@ public class PostOrdDespatchGen ...@@ -112,8 +112,9 @@ public class PostOrdDespatchGen
Connection connCP=null; Connection connCP=null;
InitialContext ctx = null; InitialContext ctx = null;
int[] insCnt = null; int[] insCnt = null;
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try { try {
startTime = System.currentTimeMillis();
//System.out.println("process starts---------"); //System.out.println("process starts---------");
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
//xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+userInfo.getSiteCode()+"~~loginEmpCode="+userInfo.getEmpCode(); //xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+userInfo.getSiteCode()+"~~loginEmpCode="+userInfo.getEmpCode();
...@@ -1796,6 +1797,15 @@ public class PostOrdDespatchGen ...@@ -1796,6 +1797,15 @@ public class PostOrdDespatchGen
}*/ }*/
// } // }
endTime = System.currentTimeMillis();
totalTime = endTime - startTime;
totSecs = (int) (((double) 1 / 1000) * (totalTime));
totalHrs = (int) (totSecs / 3600);
totlMts = (int) (((totSecs - (totalHrs * 3600)) / 60));
totSecs = (int) (totSecs - ((totalHrs * 3600) + (totlMts * 60)));
System.out.println("Total Time Spend despatch generation [" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
} }
......
...@@ -59,7 +59,8 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -59,7 +59,8 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
String toCustCode="",stanCodeInit="",descpIdTo=""; String toCustCode="",stanCodeInit="",descpIdTo="";
String runOpt="*"; String runOpt="*";
boolean lbClubOrders=false,lbClub=false,lbDrCr=false,lbAdv=false,lbCustomer=false,lbNewPrdInv=false,tempflag=false; boolean lbClubOrders=false,lbClub=false,lbDrCr=false,lbAdv=false,lbCustomer=false,lbNewPrdInv=false,tempflag=false;
String sql=""; String sql="", currCodefrtBase = "",siteCode = "";
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
ResultSet rs=null; ResultSet rs=null;
double exchangeRate=0.0; double exchangeRate=0.0;
...@@ -75,10 +76,10 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -75,10 +76,10 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* Intializing Log * Intializing Log
* */ * */
//System.out.println("Intializing Log $$$$$..."+ intializingLog("Post_Ord_InvGen_log")); //System.out.println("Intializing Log $$$$$..."+ intializingLog("Post_Ord_InvGen_log"));
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try try
{ {
startTime = System.currentTimeMillis();
java.util.Date today = new java.util.Date(); java.util.Date today = new java.util.Date();
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(today); cal.setTime(today);
...@@ -126,7 +127,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -126,7 +127,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* select desp_date,cust_code, curr_code, * select desp_date,cust_code, curr_code,
* lr_no, lr_date, remarks from table 'despatch' * lr_no, lr_date, remarks from table 'despatch'
* */ * */
sql="select desp_date, cust_code, curr_code, lr_no, lr_date, remarks,exch_rate from despatch where desp_id=?"; sql="select desp_date, cust_code, curr_code, lr_no, lr_date, remarks,exch_rate, site_code from despatch where desp_id=?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, descpIdFrm); pstmt.setString(1, descpIdFrm);
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
...@@ -141,6 +142,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -141,6 +142,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
remarks=checknull(rs.getString("remarks")); remarks=checknull(rs.getString("remarks"));
exchangeRate=rs.getDouble("exch_rate"); exchangeRate=rs.getDouble("exch_rate");
tranDatetTStmp=rs.getTimestamp("lr_date"); tranDatetTStmp=rs.getTimestamp("lr_date");
siteCode = checknull(rs.getString("site_code"));
} }
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
...@@ -170,6 +172,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -170,6 +172,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* for lrDate in between from_date and to_date * for lrDate in between from_date and to_date
* and curr_code,curr_code__to='RS' * and curr_code,curr_code__to='RS'
* */ * */
/* 28-Nov-16 manoharan
sql="select exch_rate__sell from daily_exch_rate_sell_buy where ? between from_date and to_date" sql="select exch_rate__sell from daily_exch_rate_sell_buy where ? between from_date and to_date"
+ " and curr_code = ? and curr_code__to = 'RS'"; + " and curr_code = ? and curr_code__to = 'RS'";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
...@@ -183,7 +186,10 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -183,7 +186,10 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;
*/
exchangeRate = finCommon.getDailyExchRateSellBuy(currCode, currCodefrtBase, siteCode, tranDatetTStmp, "S", conn);
} }
//System.out.println("@@@@@@lrDate["+lrDate+"]fromDate["+fromDate+"]"); //System.out.println("@@@@@@lrDate["+lrDate+"]fromDate["+fromDate+"]");
ldsInvHdrMp.put("so_type", orderType); ldsInvHdrMp.put("so_type", orderType);
...@@ -283,6 +289,16 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -283,6 +289,16 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
} }
} }
endTime = System.currentTimeMillis();
totalTime = endTime - startTime;
totSecs = (int) (((double) 1 / 1000) * (totalTime));
totalHrs = (int) (totSecs / 3600);
totlMts = (int) (((totSecs - (totalHrs * 3600)) / 60));
totSecs = (int) (totSecs - ((totalHrs * 3600) + (totlMts * 60)));
System.out.println("Total Time Spend invoice generation [" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
} catch (SQLException e) } catch (SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -721,20 +737,21 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -721,20 +737,21 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* *
* */ * */
sql="select (case when rate__std is null then 0 else rate__std end ) as lc_ratestd," sql="select (case when rate__std is null then 0 else rate__std end ) as lc_ratestd,"
+ "(case when cost_rate is null then 0 else cost_rate end )as lc_cstrate " + "(case when cost_rate is null then 0 else cost_rate end )as lc_cstrate, disc_amt "
+ " from despatchdet " + " from despatchdet "
+ "where desp_id = ? " + "where desp_id = ? "
+ " and line_no = ? " + " and line_no = ? ";
+ " and item_code = ?"; //+ " and item_code = ?";
pstmt=conn.prepareStatement(sql); pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invTraceDetMap.get("desp_id")); pstmt.setString(1, invTraceDetMap.get("desp_id"));
pstmt.setString(2, invTraceDetMap.get("line_no")); pstmt.setString(2, invTraceDetMap.get("line_no"));
pstmt.setString(3, invTraceDetMap.get("item_code")); //pstmt.setString(3, invTraceDetMap.get("item_code"));
rs=pstmt.executeQuery(); rs=pstmt.executeQuery();
if(rs.next()) if(rs.next())
{ {
lc_ratestd=rs.getString("lc_ratestd"); lc_ratestd=rs.getString("lc_ratestd");
lc_cstrate=rs.getString("lc_cstrate"); lc_cstrate=rs.getString("lc_cstrate");
lc_disc_amt=rs.getDouble("disc_amt");
} }
pstmt.close(); pstmt.close();
pstmt=null; pstmt=null;
...@@ -751,6 +768,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -751,6 +768,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* select dicsount * select dicsount
* from despatchdet * from despatchdet
* */ * */
/* //28-nov-16 manoharan commented and included above
sql="select disc_amt " sql="select disc_amt "
+ "from despatchdet " + "from despatchdet "
+ " where desp_id = ?" + " where desp_id = ?"
...@@ -767,7 +785,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -767,7 +785,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt=null; pstmt=null;
rs.close(); rs.close();
rs=null; rs=null;
*/
if(lc_disc_amt > 0) if(lc_disc_amt > 0)
{ {
ld_discount=(lc_disc_amt * 100)/(Double.parseDouble(invTraceDetMap.get("desp_quantity__stduom")==null?"0.00":invTraceDetMap.get("desp_quantity__stduom")) * Double.parseDouble(invTraceDetMap.get("desp_rate__stduom")==null?"0.00":invTraceDetMap.get("desp_rate__stduom"))); ld_discount=(lc_disc_amt * 100)/(Double.parseDouble(invTraceDetMap.get("desp_quantity__stduom")==null?"0.00":invTraceDetMap.get("desp_quantity__stduom")) * Double.parseDouble(invTraceDetMap.get("desp_rate__stduom")==null?"0.00":invTraceDetMap.get("desp_rate__stduom")));
...@@ -993,6 +1011,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB ...@@ -993,6 +1011,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt1.close(); pstmt1.close();
pstmt1=null; pstmt1=null;
/*pstmt=conn.prepareStatement("select sord_no,sord_line_no,tax_class,tax_chap,tax_env,sum(tax_amt),sum(net_amt)" /*pstmt=conn.prepareStatement("select sord_no,sord_line_no,tax_class,tax_chap,tax_env,sum(tax_amt),sum(net_amt)"
+ " from invoice_trace" + " from invoice_trace"
+ " where invoice_id=? " + " where invoice_id=? "
......
...@@ -60,8 +60,10 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -60,8 +60,10 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
HashMap<String, String> invAcctMap = null; HashMap<String, String> invAcctMap = null;
ArrayList<HashMap<String, String>> invAcctList = new ArrayList<HashMap<String,String>>(); ArrayList<HashMap<String, String>> invAcctList = new ArrayList<HashMap<String,String>>();
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try try
{ {
startTime = System.currentTimeMillis();
if(conn==null) if(conn==null)
{ {
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
...@@ -1105,6 +1107,16 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -1105,6 +1107,16 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
{ {
conn.commit(); conn.commit();
} }
endTime = System.currentTimeMillis();
totalTime = endTime - startTime;
totSecs = (int) (((double) 1 / 1000) * (totalTime));
totalHrs = (int) (totSecs / 3600);
totlMts = (int) (((totSecs - (totalHrs * 3600)) / 60));
totSecs = (int) (totSecs - ((totalHrs * 3600) + (totlMts * 60)));
System.out.println("Total Time Spend invoice posting[" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
} catch (ITMException e) } catch (ITMException e)
{ {
...@@ -1452,6 +1464,10 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -1452,6 +1464,10 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
try try
{ {
//System.out.println("@@@@@@@1087 invAcctList.size["+invAcctList.size()+"]"); //System.out.println("@@@@@@@1087 invAcctList.size["+invAcctList.size()+"]");
// 28-nov-16 manoharan moved from below (inside loop
sql="insert into invacct (invoice_id,line_no,acct_code,cctr_code,anal_code,amount,analysis1,analysis2,analysis3)"
+ " values (?,?,?,?,?,?,?,?,?)";
pstmt=conn.prepareStatement(sql);
for( int i=0; i < invAcctList.size() ; i++ ) for( int i=0; i < invAcctList.size() ; i++ )
{ {
detLineNo++; detLineNo++;
...@@ -1464,9 +1480,6 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -1464,9 +1480,6 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
if( tempMap != null) if( tempMap != null)
{ {
sql="insert into invacct (invoice_id,line_no,acct_code,cctr_code,anal_code,amount,analysis1,analysis2,analysis3)"
+ " values (?,?,?,?,?,?,?,?,?)";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tempMap.get("invoice_id")); pstmt.setString(1, tempMap.get("invoice_id"));
pstmt.setInt(2, detLineNo); pstmt.setInt(2, detLineNo);
pstmt.setString(3, tempMap.get("acct_code")); pstmt.setString(3, tempMap.get("acct_code"));
...@@ -1476,12 +1489,20 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -1476,12 +1489,20 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
pstmt.setString(7, tempMap.get("analysis1")); pstmt.setString(7, tempMap.get("analysis1"));
pstmt.setString(8, tempMap.get("analysis2")); pstmt.setString(8, tempMap.get("analysis2"));
pstmt.setString(9, tempMap.get("analysis3")); pstmt.setString(9, tempMap.get("analysis3"));
int insertCnt=pstmt.executeUpdate(); //int insertCnt=pstmt.executeUpdate();
//System.out.println("@@@@@@@@@ i["+i+"]insertCnt["+insertCnt+"]"); //System.out.println("@@@@@@@@@ i["+i+"]insertCnt["+insertCnt+"]");
pstmt.close(); //pstmt.close();
pstmt=null; //pstmt=null;
pstmt.addBatch();
pstmt.clearParameters();
} }
} }
pstmt.executeBatch();
pstmt.clearBatch();
pstmt.close();
pstmt = null;
} catch (SQLException e) } catch (SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
...@@ -1696,7 +1717,11 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -1696,7 +1717,11 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
retString=gbfPostInvoiceDet(InvoiceHrdMap,invoiceAcctList,conn); retString=gbfPostInvoiceDet(InvoiceHrdMap,invoiceAcctList,conn);
} }
//System.out.println("@@@@@@@@1002 retString gbfPostInvoiceDet["+retString+"]"); //System.out.println("@@@@@@@@1002 retString gbfPostInvoiceDet["+retString+"]");
// 28-nov-16 manoharan
if( retString == null || retString.trim().length() == 0)
{
retString = finCommon.checkGlTranDrCr("S-INV",InvoiceHrdMap.get("invoice_id"),conn);
}
return retString; return retString;
} }
...@@ -2186,7 +2211,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -2186,7 +2211,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
receivablesMap.put("mrp_value","0"); receivablesMap.put("mrp_value","0");
ldDiscdt=gbf_calc_discountdate(InvoiceHrdMap.get("cr_term"), InvoiceHrdMap.get("tran_date"), InvoiceHrdMap.get("eff_date"), ldDiscdt=calcDiscountDate(InvoiceHrdMap.get("cr_term"), InvoiceHrdMap.get("tran_date"), InvoiceHrdMap.get("eff_date"),
InvoiceHrdMap.get("tran_date"),conn); InvoiceHrdMap.get("tran_date"),conn);
receivablesMap.put("discount_date", ldDiscdt); receivablesMap.put("discount_date", ldDiscdt);
...@@ -2245,7 +2270,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -2245,7 +2270,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
//receivablesMap.put("gp_date", InvoiceHrdMap.get("gp_date"));// Change By Nasruddin on 14-oct-16 //receivablesMap.put("gp_date", InvoiceHrdMap.get("gp_date"));// Change By Nasruddin on 14-oct-16
receivablesMap.put("gp_date", Timestamp.valueOf(genericUtility.getValidDateString(InvoiceHrdMap.get("gp_date").toString(), genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0")); receivablesMap.put("gp_date", Timestamp.valueOf(genericUtility.getValidDateString(InvoiceHrdMap.get("gp_date").toString(), genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"));
receivablesMap.put("mrp_value","0"); receivablesMap.put("mrp_value","0");
ldDiscdt=gbf_calc_discountdate(InvoiceHrdMap.get("cr_term"), InvoiceHrdMap.get("tran_date"), InvoiceHrdMap.get("eff_date"), ldDiscdt=calcDiscountDate(InvoiceHrdMap.get("cr_term"), InvoiceHrdMap.get("tran_date"), InvoiceHrdMap.get("eff_date"),
InvoiceHrdMap.get("tran_date"),conn); InvoiceHrdMap.get("tran_date"),conn);
receivablesMap.put("discount_date", ldDiscdt); receivablesMap.put("discount_date", ldDiscdt);
...@@ -2281,7 +2306,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi ...@@ -2281,7 +2306,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
return retSting; return retSting;
} }
private Timestamp gbf_calc_discountdate(String crTerm, String vouchDate, String effDate, String billDate,Connection conn) throws ITMException private Timestamp calcDiscountDate(String crTerm, String vouchDate, String effDate, String billDate,Connection conn) throws ITMException
{ {
String discountDate="",sql="",lsStart="",lsMonth="",lsOverridediscdt=""; String discountDate="",sql="",lsStart="",lsMonth="",lsOverridediscdt="";
PreparedStatement pstmt=null; PreparedStatement pstmt=null;
......
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