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
//E12GenericUtility e12GenericUtility = new E12GenericUtility();
ArrayList<String> retArrayList = new ArrayList<String>();
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try
{
startTime = System.currentTimeMillis();
Timestamp currDate = new java.sql.Timestamp(System.currentTimeMillis());
mailList = new ArrayList();
......@@ -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)
{
......
......@@ -112,8 +112,9 @@ public class PostOrdDespatchGen
Connection connCP=null;
InitialContext ctx = null;
int[] insCnt = null;
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try {
startTime = System.currentTimeMillis();
//System.out.println("process starts---------");
itmDBAccessEJB = new ITMDBAccessEJB();
//xtraParams = "loginCode="+userInfo.getLoginCode()+"~~termId="+userInfo.getRemoteHost()+"~~loginSiteCode="+userInfo.getSiteCode()+"~~loginEmpCode="+userInfo.getEmpCode();
......@@ -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
String toCustCode="",stanCodeInit="",descpIdTo="";
String runOpt="*";
boolean lbClubOrders=false,lbClub=false,lbDrCr=false,lbAdv=false,lbCustomer=false,lbNewPrdInv=false,tempflag=false;
String sql="";
String sql="", currCodefrtBase = "",siteCode = "";
PreparedStatement pstmt=null;
ResultSet rs=null;
double exchangeRate=0.0;
......@@ -75,10 +76,10 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* Intializing 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
{
startTime = System.currentTimeMillis();
java.util.Date today = new java.util.Date();
Calendar cal = Calendar.getInstance();
cal.setTime(today);
......@@ -126,7 +127,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* select desp_date,cust_code, curr_code,
* 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.setString(1, descpIdFrm);
rs=pstmt.executeQuery();
......@@ -141,6 +142,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
remarks=checknull(rs.getString("remarks"));
exchangeRate=rs.getDouble("exch_rate");
tranDatetTStmp=rs.getTimestamp("lr_date");
siteCode = checknull(rs.getString("site_code"));
}
pstmt.close();
pstmt=null;
......@@ -170,6 +172,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* for lrDate in between from_date and to_date
* 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"
+ " and curr_code = ? and curr_code__to = 'RS'";
pstmt=conn.prepareStatement(sql);
......@@ -184,6 +187,9 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt=null;
rs.close();
rs=null;
*/
exchangeRate = finCommon.getDailyExchRateSellBuy(currCode, currCodefrtBase, siteCode, tranDatetTStmp, "S", conn);
}
//System.out.println("@@@@@@lrDate["+lrDate+"]fromDate["+fromDate+"]");
ldsInvHdrMp.put("so_type", orderType);
......@@ -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)
{
e.printStackTrace();
......@@ -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,"
+ "(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 "
+ "where desp_id = ? "
+ " and line_no = ? "
+ " and item_code = ?";
+ " and line_no = ? ";
//+ " and item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invTraceDetMap.get("desp_id"));
pstmt.setString(2, invTraceDetMap.get("line_no"));
pstmt.setString(3, invTraceDetMap.get("item_code"));
//pstmt.setString(3, invTraceDetMap.get("item_code"));
rs=pstmt.executeQuery();
if(rs.next())
{
lc_ratestd=rs.getString("lc_ratestd");
lc_cstrate=rs.getString("lc_cstrate");
lc_disc_amt=rs.getDouble("disc_amt");
}
pstmt.close();
pstmt=null;
......@@ -751,6 +768,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
* select dicsount
* from despatchdet
* */
/* //28-nov-16 manoharan commented and included above
sql="select disc_amt "
+ "from despatchdet "
+ " where desp_id = ?"
......@@ -767,7 +785,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt=null;
rs.close();
rs=null;
*/
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")));
......@@ -993,6 +1011,7 @@ public class PostOrdInvoiceGen extends ActionHandlerEJB
pstmt1.close();
pstmt1=null;
/*pstmt=conn.prepareStatement("select sord_no,sord_line_no,tax_class,tax_chap,tax_env,sum(tax_amt),sum(net_amt)"
+ " from invoice_trace"
+ " where invoice_id=? "
......
......@@ -60,8 +60,10 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
HashMap<String, String> invAcctMap = null;
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
{
startTime = System.currentTimeMillis();
if(conn==null)
{
ConnDriver connDriver = new ConnDriver();
......@@ -1105,6 +1107,16 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
{
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)
{
......@@ -1452,6 +1464,10 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
try
{
//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++ )
{
detLineNo++;
......@@ -1464,9 +1480,6 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
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.setInt(2, detLineNo);
pstmt.setString(3, tempMap.get("acct_code"));
......@@ -1476,12 +1489,20 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
pstmt.setString(7, tempMap.get("analysis1"));
pstmt.setString(8, tempMap.get("analysis2"));
pstmt.setString(9, tempMap.get("analysis3"));
int insertCnt=pstmt.executeUpdate();
//int insertCnt=pstmt.executeUpdate();
//System.out.println("@@@@@@@@@ i["+i+"]insertCnt["+insertCnt+"]");
pstmt.close();
pstmt=null;
//pstmt.close();
//pstmt=null;
pstmt.addBatch();
pstmt.clearParameters();
}
}
pstmt.executeBatch();
pstmt.clearBatch();
pstmt.close();
pstmt = null;
} catch (SQLException e)
{
e.printStackTrace();
......@@ -1696,7 +1717,11 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
retString=gbfPostInvoiceDet(InvoiceHrdMap,invoiceAcctList,conn);
}
//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;
}
......@@ -2186,7 +2211,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
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);
receivablesMap.put("discount_date", ldDiscdt);
......@@ -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", Timestamp.valueOf(genericUtility.getValidDateString(InvoiceHrdMap.get("gp_date").toString(), genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.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);
receivablesMap.put("discount_date", ldDiscdt);
......@@ -2281,7 +2306,7 @@ public class PostOrdInvoicePost extends ActionHandlerEJB implements PostOrdInvoi
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="";
PreparedStatement pstmt=null;
......
......@@ -57,9 +57,10 @@ public class PostOrderActivity {
int ediOption=0;
//Connection connCP=null;
//ConnDriver connDriver = new ConnDriver();
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try
{
startTime = System.currentTimeMillis();
purIntegrate=distCommon.getDisparams("999999", "PUR_INTEGRATED", conn);
sql="select edi_option from transetup where tran_window = 'w_despatch'";
pstmt=conn.prepareStatement(sql);
......@@ -158,6 +159,15 @@ public class PostOrderActivity {
}
}
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 for createPORCP [" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
}catch(Exception e)
{
......@@ -271,8 +281,8 @@ public class PostOrderActivity {
remarks3=rs.getString("remarks3");
stanCodeInit=rs.getString("stan_code__init");
remarks=rs.getString("remarks");
sql="select item_ser, cust_code from sorder where sale_order = ? ";
// 28/Nov-16 manoharan cust_pord included and separate select commented
sql="select item_ser, cust_code,cust_pord from sorder where sale_order = ? ";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,sordNo);
rs1=pstmt1.executeQuery();
......@@ -280,6 +290,7 @@ public class PostOrderActivity {
{
itemSer=checkNull(rs1.getString("item_ser")).trim();
custCode=rs1.getString("cust_code");
custPord=checkNull(rs.getString("cust_pord"));
}
rs1.close();
rs1=null;
......@@ -377,6 +388,7 @@ public class PostOrderActivity {
{
return retString;
}
/* // 28-Nov-16 manoharan commented
sql=" select cust_pord from sorder "
+ " where sale_order = ? ";
pstmt=conn.prepareStatement(sql);
......@@ -390,6 +402,7 @@ public class PostOrderActivity {
rs=null;
pstmt.close();
pstmt=null;
*/
if(custPord.trim().length()>0)
{
sql="select status from porder where purc_order = ?";
......@@ -630,7 +643,7 @@ public class PostOrderActivity {
"despdt.GROSS_WEIGHT,despdt.TARE_WEIGHT,despdt.NETT_WEIGHT,"
+ "despdt.retest_date,despdt.dimension,despdt.pallet_wt,despdt.pack_instr " +
" from despatchdet despdt,SORDDET sdet where despdt.sord_no =sdet.sale_order and " +
" despdt.line_no__sord = sdet.line_no (+) and despdt.desp_id=? ";
" despdt.line_no__sord = sdet.line_no and despdt.desp_id=? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,despId);
rs=pstmt.executeQuery();
......@@ -726,7 +739,9 @@ public class PostOrderActivity {
pstmt1.setString(1,custPord);
pstmt1.setString(2,itemCode);
rs1=pstmt1.executeQuery();
while(rs1.next())
// 28-Nov-16 Manoharan
//while(rs1.next())
if(rs1.next())
{
cntPO++;
acctCodeCr=rs1.getString("acct_code__cr");
......@@ -1551,7 +1566,9 @@ public class PostOrderActivity {
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,invoiceId);
rs=pstmt.executeQuery();
while(rs.next())
// 28-Nov-16 manoharan
//while(rs.next())
if(rs.next())
{
//tranDateTS=rs.getTimestamp(1);
refDate=rs.getDate(1);
......@@ -1720,7 +1737,7 @@ public class PostOrderActivity {
pstmt1.setString(3,invoiceId);
pstmt1.setDouble(4,netAmt);
pstmt1.setDouble(5,-1*(drAmt-netAmt));
pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
pstmt1.setString(7," ");
pstmt1.setString(8," ");
pstmt1.setString(9," ");
......@@ -2487,8 +2504,10 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
ibase.webitm.ejb.fin.FinCommon finCommon = new ibase.webitm.ejb.fin.FinCommon();
ibase.webitm.ejb.dis.DistCommon discmn = new ibase.webitm.ejb.dis.DistCommon();
InitialContext ctx = null;
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try
{
startTime = System.currentTimeMillis();
SimpleDateFormat sdf2 = new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate = sdf2.format(currentDateval.getTime());
dbSysDate = Timestamp.valueOf(genericUtility.getValidDateString(sysDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
......@@ -2520,7 +2539,7 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
if (frtAmt <= 0)
{
System.out.println("frtAmt>>>>>"+frtAmt);
return errString;
return "";//errString; // 23-Nov-16 Manoharan no error as freight amount is 0
}
sql = "select f.fin_entity as ls_fin_entity, f.curr_code as ls_currcode_base " +
" from site s, finent f where f.fin_entity = s.fin_entity and s.site_code = ?";
......@@ -2710,6 +2729,15 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
//System.out.println("MiscDrCrRcp Confirm errString>>>>>"+errString);
}
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 freight DR[" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
} catch (Exception e)
{
......@@ -2850,8 +2878,10 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
HashMap acctCctrMap = new HashMap(), tempMap = null,tempMapAmount=null;
ArrayList tempList = null;
InitialContext ctx = null;
long startTime = 0, endTime = 0, totalTime = 0, totalHrs = 0, totlMts = 0, totSecs = 0; // Added
try
{
startTime = System.currentTimeMillis();
Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDateStr = sdf.format(currentDate.getTime());
......@@ -3310,6 +3340,15 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
}
}
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 Excise DR[" + totalHrs + "] Hours [" + totlMts + "] Minutes [" + totSecs + "] seconds");
}
catch (Exception e)
......@@ -3380,7 +3419,7 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, invoiceId);
rs = pstmt.executeQuery();
while (rs.next())
if (rs.next())
{
tranDate = rs.getTimestamp(1);
custCode = rs.getString(2);
......@@ -4133,13 +4172,4 @@ pstmt1.setDouble(6,netAmt-(-1*(drAmt-netAmt)));
return retString;
}
public String createCommCrNote(String invoiceId, Connection conn)
{
String retString="";
return retString;
}
}
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