Commit 0b29677c authored by pborate's avatar pborate

Updated for Customer Events Dashboard

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@185810 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 76de57d7
...@@ -6,9 +6,12 @@ import java.sql.Connection; ...@@ -6,9 +6,12 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
...@@ -25,8 +28,8 @@ public class ImpEvents extends ValidatorEJB implements ImpEventsRemote, ImpEven ...@@ -25,8 +28,8 @@ public class ImpEvents extends ValidatorEJB implements ImpEventsRemote, ImpEven
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
//Commented by Priyanka B. as per Prajyot R. [For Customer Events Dashboard] Start
/*
@SuppressWarnings({ "unchecked", "null" }) @SuppressWarnings({ "unchecked", "null" })
@Override @Override
public JSONObject getEvents(String empCode,String dataSourceName) throws RemoteException, ITMException { public JSONObject getEvents(String empCode,String dataSourceName) throws RemoteException, ITMException {
...@@ -204,8 +207,178 @@ public class ImpEvents extends ValidatorEJB implements ImpEventsRemote, ImpEven ...@@ -204,8 +207,178 @@ public class ImpEvents extends ValidatorEJB implements ImpEventsRemote, ImpEven
return rawDataTomorrowEventsJson; return rawDataTomorrowEventsJson;
} }
*///Commented by Priyanka B. as per Prajyot R. [For Customer Events Dashboard] End
@SuppressWarnings({ "unchecked", "null" })
@Override
public String getEvents(String empCode, String dataSourceName) throws RemoteException, ITMException
{
System.out.println("@@@@@@@@@@@@ImpEvents@@@@@@@@@@@ImpEvents@@@@@@@@@@");
JSONArray eventsArray = new JSONArray();
try
{
String eventSelectPart = "SELECT TO_CHAR(STRG_EVENTS.EVENT_DATE,'DD-MON-YYYY') AS EVENT_DATE,STRG_CUSTOMER.MOBILE_NO AS DR_MOBILE_NO, "
+ " TRUNC(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' )) AS PRESENT_DATE, "
+ " STRG_CUSTOMER.SC_CODE, "
+ " INITCAP(STRG_CUSTOMER.FIRST_NAME||' '||STRG_CUSTOMER.MIDDLE_NAME||' '||STRG_CUSTOMER.LAST_NAME )AS DR_NAME, "
+ " LISTAGG(STRG_EVENTS.DESCR, ', ') WITHIN GROUP (ORDER BY STRG_EVENTS.DESCR) as EVENT"
+ " FROM SALES_PERS "
+ " INNER JOIN STRG_SERIES on STRG_SERIES.SALES_PERS = SALES_PERS.SALES_PERS"
+ " AND STRG_SERIES.Cust_Type = 'D' "
+ " AND STRG_SERIES.Status = 'Y' "
+ " INNER JOIN STRG_CUSTOMER ON STRG_CUSTOMER.SC_CODE = STRG_SERIES.SC_CODE "
+ " INNER JOIN STRG_EVENTS ON STRG_CUSTOMER.SC_CODE = STRG_EVENTS.SC_CODE";
if (empCode != null)
{
// Start of todays event
//SELECT *
//FROM STRG_EVENTS
//WHERE TRUNC(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' )) = TRUNC(SYSDATE);
String todaySql = eventSelectPart
+ " WHERE SALES_PERS.SALES_PERS = ?"
+ " AND TRUNC(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' )) = TRUNC(SYSDATE) "
+ " GROUP BY STRG_EVENTS.EVENT_DATE ,"
+ " STRG_CUSTOMER.SC_CODE,"
+ " STRG_CUSTOMER.FIRST_NAME,"
+ " STRG_CUSTOMER.MIDDLE_NAME,"
+ " STRG_CUSTOMER.LAST_NAME,"
+ " STRG_CUSTOMER.MOBILE_NO ";
JSONArray todaysData = getData(dataSourceName, empCode, todaySql, "TODAY");
eventsArray.addAll(todaysData);
//EventsDataJson.put("TODAY", todaysData);
// End of todays event
// Start of thisWeekSql events
//SELECT *
//FROM STRG_EVENTS
//WHERE TO_CHAR(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' ), 'IW') = TO_CHAR(SYSDATE, 'IW')
//AND TRUNC(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' )) > TRUNC(SYSDATE);
String thisWeekSql = eventSelectPart
+ " WHERE SALES_PERS.SALES_PERS = ? "
+ " AND TO_CHAR(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' ), 'IW') = TO_CHAR(SYSDATE, 'IW') "
+ " AND TRUNC(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' )) > TRUNC(SYSDATE) "
+ " GROUP BY STRG_EVENTS.EVENT_DATE ,"
+ " STRG_CUSTOMER.SC_CODE, "
+ " STRG_CUSTOMER.FIRST_NAME,"
+ " STRG_CUSTOMER.MIDDLE_NAME,"
+ " STRG_CUSTOMER.LAST_NAME,"
+ " STRG_CUSTOMER.MOBILE_NO ";
JSONArray thisWeekData = getData(dataSourceName, empCode, thisWeekSql, "WEEK_DATA");
eventsArray.addAll(thisWeekData);
//EventsDataJson.put("WEEK_DATA", thisWeekData);
// End of thisWeekSql events
// Start of nextWeekData
//SELECT *
//FROM STRG_EVENTS
//WHERE TO_CHAR(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' ), 'IW') = TO_CHAR(SYSDATE, 'IW') + 1;
String nextWeekSql = eventSelectPart
+ " WHERE SALES_PERS.SALES_PERS = ? "
+ " AND TO_CHAR(TO_DATE( ( TO_CHAR(SYSDATE,'YYYY') || TO_CHAR(EVENT_DATE,'MMDDHH24MISS') ), 'YYYYMMDDHH24MISS' ), 'IW') = TO_CHAR(SYSDATE, 'IW') + 1"
+ " GROUP BY STRG_EVENTS.EVENT_DATE,"
+ " STRG_CUSTOMER.SC_CODE, "
+ " STRG_CUSTOMER.FIRST_NAME,"
+ " STRG_CUSTOMER.MIDDLE_NAME,"
+ " STRG_CUSTOMER.LAST_NAME,"
+ " STRG_CUSTOMER.MOBILE_NO ";
JSONArray nextWeekData = getData(dataSourceName, empCode, nextWeekSql, "NEXT_WEEK_DATA");
eventsArray.addAll(nextWeekData);
//EventsDataJson.put("NEXT_WEEK_DATA", nextWeekData);
// End of nextWeekData
System.out.println("FINAL DATA IN IMPEVENT" + eventsArray);
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return eventsArray.toString();
}
private JSONArray getData(String dataSourceName,String empCode,String sql, String eventInterval) throws ITMException
{
JSONArray finalDataArray = new JSONArray();
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
E12GenericUtility e12GenUtility = new E12GenericUtility();
try
{
conn = connDriver.getConnectDB(dataSourceName);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
while (rs.next())
{
JSONObject finalDataObject = new JSONObject();
String customerCode = checkNull(rs.getString("SC_CODE"));
String customerName = checkNull(rs.getString("DR_NAME"));
finalDataObject.put("SC_NAME", customerName);
finalDataObject.put("SC_CODE", customerCode);
finalDataObject.put("EVENT_DESCR", checkNull(rs.getString("EVENT")));
finalDataObject.put("EVENT_DATE", checkNull(rs.getString("EVENT_DATE")));
finalDataObject.put("PRESENT_DATE", checkNull(rs.getString("PRESENT_DATE")));
finalDataObject.put("DR_MOBILE_NO", checkNull(rs.getString("DR_MOBILE_NO")));
finalDataObject.put("EVENT_INTERVAL", eventInterval);
System.out.println("getData object " + finalDataObject);
String scImagePath = e12GenUtility.getCustomImageURL("STRG_CUSTOMER", "StrgCustomer", customerCode, customerName, "Icon");
finalDataObject.put("SC_IMAGE", scImagePath);
finalDataArray.add(finalDataObject);
}
rs.close();
rs = null;
pstmt.close();
}
catch (Exception e)
{
// TODO Auto-generated catch block
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;
}
conn = null;
connDriver = null;
}
catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :ImpEvents:" + d.getMessage());
throw new ITMException(d);
}
}
System.out.println("getData sql ["+sql+"] \n finalDataArray >> " + finalDataArray);
return finalDataArray;
}
private String checkNull(String input) private String checkNull(String input)
{ {
if (input == null) if (input == null)
......
...@@ -10,7 +10,7 @@ import org.json.simple.JSONObject; ...@@ -10,7 +10,7 @@ import org.json.simple.JSONObject;
@Local @Local
public interface ImpEventsLocal { public interface ImpEventsLocal {
public JSONObject getEvents(String loginCode, String dataSourceName) throws RemoteException, ITMException; public String getEvents(String loginCode, String dataSourceName) throws RemoteException, ITMException;
......
...@@ -8,7 +8,7 @@ public interface ImpEventsRemote ...@@ -8,7 +8,7 @@ public interface ImpEventsRemote
{ {
public JSONObject getEvents(String loginCode, String dataSourceName) throws RemoteException, ITMException; public String getEvents(String loginCode, String dataSourceName) throws RemoteException, 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