Commit ca42cec1 authored by pborate's avatar pborate

Updated for Customer Events Dashboard

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@185811 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0b29677c
......@@ -8,6 +8,8 @@ import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.rmi.RemoteException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -1553,6 +1555,211 @@ public JSONObject getTodaysCallsSummary(String dataSourceName,String loginCode,S
return input;
}
//Added by Priyanka B. as per Prajyot R. [Missed Calls Dashboard] Start
public String getMissedCalls(String fromMonth, String toMonth, String salesPers, String transDB) throws ITMException
{
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
System.out.println("In getMissedCalls() fromMonth = "+fromMonth+"toMonth = "+toMonth+"sales person = "+salesPers+ "transDB "+transDB);
String missedCallData = "";
String missedCallsSql = "Select INITCAP(SP.SP_Name) as SALESPERSON," +
" dm.month AS MONTH," +
" dm.month_mon AS MONTH_MON," +
" dm.year AS YEAR," +
" to_char(to_date('1/' || month || '/' || year, 'dd/mm/yyyy'), 'Mon yyyy') as PERIOD," +
" (Case When SS.Cust_Type = 'D' Then 'Doctor' Else 'Retailer' End) as TYPE," +
" INITCAP(SC.first_name || ' ' || SC.middle_name || ' ' || SC.last_name) as DRNAME," +
" INITCAP(spec.descr) as SPECIALITY," +
" SS.SC_CODE," +
" SS.CLASS_CODE," +
" SS.NO_VISIT," +
" INITCAP(SS.Class_Code_Descr) AS CLASS_CODE_DESCR," +
" (" +
" select max(event_date) " +
" from strg_meet" +
" where sales_pers = sp.sales_pers" +
" AND event_date < to_date('1'||'/'|| dm.month||'/'|| dm.year,'dd/mm/yyyy')" +
" AND strg_code = ss.sc_code" +
" ) as LAST_VISIT," +
" (" +
" select ( trunc(sysdate) - trunc(max(event_date) ) ) " +
" from strg_meet" +
" where sales_pers = sp.sales_pers" +
" AND event_date < to_date('1'||'/'|| dm.month||'/'|| dm.year,'dd/mm/yyyy')" +
" AND strg_code = ss.sc_code" +
" ) as VISIT_SINCE," +
" INITCAP(L.DESCR) as LOCALITY" +
" FROM" +
" (" +
" (" +
" Select dISTINCT" +
" strg_series.sales_pers," +
" strg_series.sc_code," +
" dt.month," +
" dt.month_mon," +
" dt.year" +
" from" +
" strg_series" +
" cross join" +
" (" +
" select distinct" +
" to_char(sfa_time.DT, 'mm') as month," +
" to_char(sfa_time.DT, 'MON') AS month_mon," +
" to_char(sfa_time.DT, 'yyyy') as year" +
" from sfa_time" +
" where sfa_time.DT BETWEEN" +
" trunc(to_date( ? ,'MONYYYY'),'MON') " + //-- as_month_fr || as_year
" AND last_day(to_date( ? ,'MONYYYY')) " + //-- as_month_to || as_year
" ) DT" +
" where status = 'Y'" +
" AND Sales_Pers In ( ? ) " + //--as_sales_pers Assume only one sales_pers will be here
" )" +
" MINUS" +
" (" +
" select" +
" strg_meet.sales_pers," +
" strg_meet.strg_code," +
" to_char(strg_meet.event_date,'mm') as month," +
" to_char(strg_meet.event_date,'MON') as month_mon," +
" to_char(strg_meet.event_date,'yyyy') as year" +
" from" +
" strg_meet" +
" where" +
" strg_meet.event_date BETWEEN" +
" trunc(to_date( ? ,'MONYYYY'),'MON') " + //-- as_month_fr || as_year
" AND last_day(to_date( ? ,'MONYYYY')) " + //-- as_month_to || as_year
" AND strg_meet.strg_code is not null" +
" AND strg_meet.Sales_Pers In ( ? ) " + //--as_sales_pers Assume only one sales_pers will be here
" )" +
" ) DM" +
" INNER JOIN SALES_PERS SP ON SP.Sales_Pers = DM.Sales_Pers" +
" INNER JOIN STRG_CUSTOMER SC ON SC.sc_code = DM.SC_code" +
" INNER JOIN Strg_Series SS ON DM.sales_pers = ss.sales_pers" +
" AND DM.sc_code=SS.sc_code" +
" INNER JOIN speciality spec ON spec.spl_code = SS.spl_code" +
" INNER JOIN LOCALITY L ON SC.LOCALITY_CODE = L.LOCALITY_CODE " +
" WHERE" +
" SP.ACTIVE_YN = 'Y'" +
" AND SP.SALES_PERS IN" +
"(" +
" select emp_code" +
" from employee" +
" start with emp_code = (select emp_code from users where code= ? ) " + //--as_user_id
" connect by prior emp_code = report_to" +
")" +
" ORDER BY SalesPerson,year,month,drname" ;
try
{
conn = connDriver.getConnectDB(transDB);
connDriver = null;
E12GenericUtility e12GenUtility = new E12GenericUtility();
JSONArray missCallArray = new JSONArray();
pstmt = conn.prepareStatement(missedCallsSql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
pstmt.setString(1, fromMonth);
pstmt.setString(2, toMonth);
pstmt.setString(3, salesPers);
pstmt.setString(4, fromMonth);
pstmt.setString(5, toMonth);
pstmt.setString(6, salesPers);
pstmt.setString(7, salesPers);
rs = pstmt.executeQuery();
while(rs.next())
{
JSONObject missCallObject = new JSONObject();
/*
SALES_PERS : SALESPERSON
PERIOD : PERIOD
CUST_TYPE : TYPE
CUST_NAME : DRNAME
SPECIALITY : SPECIALITY
CLASS_CODE : CLASS_CODE
CLASS_CODE_DESCR : CLASS_CODE_DESCR
NO_VISIT : NO_VISIT
LAST_VISIT : LAST_VISIT
LOCALITY : LOCALITY
*/
String customerCode = checkNull(rs.getString("SC_CODE"));
String customerName = checkNull(rs.getString("DRNAME"));
missCallObject.put("SALES_PERS", checkNull(rs.getString("SALESPERSON")));
missCallObject.put("PERIOD", checkNull(rs.getString("PERIOD")));
missCallObject.put("CUST_TYPE", checkNull(rs.getString("TYPE")));
missCallObject.put("CUST_NAME", customerName);
missCallObject.put("SPECIALITY", checkNull(rs.getString("SPECIALITY")));
missCallObject.put("CLASS_CODE", checkNull(rs.getString("CLASS_CODE")));
missCallObject.put("CLASS_CODE_DESCR", checkNull(rs.getString("CLASS_CODE_DESCR")));
missCallObject.put("NO_VISIT", checkNull(rs.getString("NO_VISIT")));
String lastVisit = checkNull(rs.getString("LAST_VISIT"));
String visitSince = checkNull(rs.getString("VISIT_SINCE"));
//String visitSince = "Not Visited Yet";
//if( lastVisitStr.indexOf("~SEP~") != -1 && !"~SEP~".equalsIgnoreCase(lastVisitStr))
//{
// String[] lastVisitArr = lastVisitStr.split("~SEP~");
// lastVisit = lastVisitArr[0];
// visitSince = lastVisitArr[1];
//}
//System.out.println("lastVisitStr == > [" +lastVisitStr + "] lastVisit[" + lastVisit + "]visitSince[ "+ visitSince + "]");
missCallObject.put("LAST_VISIT", lastVisit);
missCallObject.put("DAYS_SINCE", visitSince);
missCallObject.put("LOCALITY", checkNull(rs.getString("LOCALITY")));
String scImagePath = e12GenUtility .getCustomImageURL("STRG_CUSTOMER", "StrgCustomer", customerCode, customerName, "Icon");
missCallObject.put("SC_IMAGE", scImagePath);
System.out.println("missCallObject == > " +missCallObject);
missCallArray.add(missCallObject);
}
System.out.println("missCallArray == > " +missCallArray);
missedCallData = missCallArray.toString();
}
catch(Exception e)
{
System.out.println("Exception in PlanVsActual.getMissedCalls() "+e.getMessage());
e.printStackTrace();
}
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();
System.out.println("Exception in PlanVsActual.getMissedCalls() " + d.getMessage());
throw new ITMException(d);
}
}
return missedCallData;
}
//Added by Priyanka B. as per Prajyot R. [Missed Calls Dashboard] End
}
......
......@@ -22,4 +22,7 @@ public interface PlanVsActualLocal extends ValidatorLocal
public String getTodaysCalls(String dataSourceName,String loginId,String salePersons,String dummy)throws RemoteException,ITMException;
public String getTodaysCallsSummary(String dataSourceName,String loginId,String salePersons,String dummy)throws RemoteException,ITMException;
//Added by Anjali R.[End]
public String getMissedCalls(String fromMonth, String toMonth, String salesPers, String transDB) throws ITMException ;
}
\ No newline at end of file
......@@ -21,6 +21,8 @@ public interface PlanVsActualRemote extends ValidatorRemote
public String getTodaysCallsSummary(String dataSourceName,String loginId,String salePersons,String dummy)throws RemoteException,ITMException;
//Added by Anjali R.[End]
public String getMissedCalls(String fromMonth, String toMonth, String salesPers, String transDB) throws 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