Commit 740b61d9 authored by sdhaul's avatar sdhaul

Added ConsumerGoodsCRM Components (for CG-CRM Dashboard)

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@200649 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ef5c3488
package ibase.dashboard.sfa.ejb;
import ibase.dashboard.Report.Utility.DashboardUtility;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
/**
* Session Bean implementation class SalesPersonSales
*/
@Stateless
public class ConsumerGoodsCRM extends ValidatorEJB implements ConsumerGoodsCRMLocal, ConsumerGoodsCRMRemote
{
public ConsumerGoodsCRM() {
// TODO Auto-generated constructor stub
}
GenericUtility genericUtility = GenericUtility.getInstance();
JSONObject workSummary = new JSONObject();
int totalCallBal;
@SuppressWarnings("unchecked")
@Override
public JSONArray getWorkSummary(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException
{
JSONArray workSummary = new JSONArray();
JSONObject workData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
dashboardUtility = new DashboardUtility();
salePerson = dashboardUtility.getCommaSeparated(salePerson);
fromDate = genericUtility.getValidDateString( fromDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat() );
toDate = genericUtility.getValidDateString( toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat() );
System.out.println("In ConsumerGoodsCRM getWorkSummary After format :: fromDate:["+fromDate+"] toDate:["+toDate+"]");
sql = " Select " +
"SalesPerson_Code , To_Calls," +
" SalesPerson_Name , nvl(SUM(Tot_Calls),0) as Tot_Calls , nvl(SUM(Tot_PC),0) as Tot_PC , " +
" nvl(SUM(To_Calls - Tot_Dist_Calls),0) as Call_Bal , nvl(SUM(TLSD),0) as TLSD , " +
" nvl(SUM(Ord_Val),0) as Ord_Val , nvl(SUM(ord_qty), 0) AS ord_qty, nvl(SUM(Display),0) as Display " +
" From ( Select SM.Sales_Pers as SalesPerson_Code , " +
" SP.SP_Name as SalesPerson_Name ,nvl(count(strg_code),0) as Tot_Calls , nvl(count(Distinct strg_code),0) as Tot_Dist_Calls ," +
" nvl((select count(distinct strg_code) from STRG_MEET_ORDER SMO " +
" where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as Tot_PC ," +
" NVL((Select count(sc_code) From Strg_Series Where Sales_Pers = SM.Sales_Pers " +
" And Sc_Code in (Select sC_cODE From STRG_Customer " +
" Where Locality_Code In (Select locality_Code From sPRS_TRAVEL " +
" Where Sales_Pers = SM.Sales_Pers " +
" AND travel_date BETWEEN TO_DATE('"+fromDate+"','YYYY-MM-dd') and TO_DATE('"+toDate+"','YYYY-MM-dd')" +
" )) ),0) AS To_Calls , " +
" nvl((select count(*) from STRG_MEET_ORDER SMO " +
" where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as TLSD , " +
" nvl((select sum(value) from STRG_MEET_ORDER SMO " +
" where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as Ord_Val , " +
" nvl((select sum(quantity) from STRG_MEET_ORDER SMO " +
" where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as ord_qty , " +
" nvl((select count(distinct strg_code) from STRG_ITEM_DISPLAY SID " +
" where SID.dcr_id=SM.dcr_id),0) as Display " +
" FROM Strg_Meet SM ,Sales_Pers SP Where SM.Sales_Pers = SP.Sales_Pers " +
" AND SM.event_date BETWEEN TO_DATE('"+fromDate+"','YYYY-MM-dd') and TO_DATE('"+toDate+"','YYYY-MM-dd')" +
" And SM.Sales_Pers In ( Select Emp_Code " +
" From Employee Start With Emp_code = (Select Emp_Code From Users Where Code = "+salePerson+") " +
" Connect By Prior Emp_Code =Report_To )" +
" Group By SM.Sales_Pers ," +
" SP.SP_Name ,SM.dcr_id ) " +
" Group By SalesPerson_Name, To_Calls, SalesPerson_Code Order By SalesPerson_Name";
System.out.println("In ConsumerGoodsCRM getWorkSummary sql: ---- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
totalCallBal = 0;
while (rs.next())
{
workData = new JSONObject();
String salesPersCode = checkNull(rs.getString("SALESPERSON_CODE"));
String salesPersName = checkNull(rs.getString("SALESPERSON_NAME"));
String totalCalls = checkNull(rs.getString("TOT_CALLS"));
String prodCalls = checkNull(rs.getString("TOT_PC"));
String ordQty = checkNull(rs.getString("ORD_QTY"));
String display = rs.getString("DISPLAY");
String tlsd = rs.getString("TLSD");
String callBal = rs.getString("CALL_BAL");
totalCallBal = totalCallBal + Integer.parseInt(callBal);
String hostUrl = CommonConstants.TOMCAT_HOME;
String imgUrl = hostUrl + "/ibase/CustomMenuImageServlet?fldValue="+salesPersCode+"&ALT_FLD_VALUE="+salesPersName;
workData.put("salesPersCode",salesPersCode);
workData.put("salesPersName",salesPersName);
workData.put("imgUrl",imgUrl);
JSONArray workDetails = new JSONArray();
JSONObject workDetail = null;
workDetail = new JSONObject();
workDetail.put("count", totalCalls);
workDetail.put("value", "TC");
workDetail.put("color", "#89cbfc");
workDetails.add(workDetail);
workDetail = new JSONObject();
workDetail.put("count", prodCalls);
workDetail.put("value", "PC");
workDetail.put("color", "#86e8c6");
workDetails.add(workDetail);
workDetail = new JSONObject();
workDetail.put("count", ordQty);
workDetail.put("value", "Orders");
workDetail.put("color", "#c0b9f6");
workDetails.add(workDetail);
workDetail = new JSONObject();
workDetail.put("count", checkNull(display));
workDetail.put("value", "Display");
workDetail.put("color", "#f9af92");
workDetails.add(workDetail);
workDetail = new JSONObject();
workDetail.put("count", checkNull(tlsd));
workDetail.put("value", "TLSD");
workDetail.put("color", "#c26be9");
workDetails.add(workDetail);
workDetail = new JSONObject();
workDetail.put("count", checkNull(callBal));
workDetail.put("value", "Call Balance");
workDetail.put("color", "#ffca3b");
workDetails.add(workDetail);
workData.put("workDetails", workDetails);
workSummary.add(workData);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
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;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :CurrentDayWrkSummary : getMTDWorkParent" + d.getMessage());
throw new ITMException(d);
}
}
return workSummary;
}
@SuppressWarnings("unchecked")
@Override
public JSONArray getKPISummary(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException
{
JSONArray kpiSummary = new JSONArray();
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
dashboardUtility = new DashboardUtility();
salePerson = dashboardUtility.getCommaSeparated(salePerson);
fromDate = genericUtility.getValidDateString( fromDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat() );
toDate = genericUtility.getValidDateString( toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat() );
System.out.println("In ConsumerGoodsCRM getKPISummary After format :: fromDate:["+fromDate+"] toDate:["+toDate+"]");
sql = " Select count(SalesPerson_Name) as people, nvl(SUM(Tot_Calls),0) as Tot_Calls , " +
" nvl(SUM(Tot_PC),0) as Tot_PC , " +
" nvl(SUM(ECO),0) as ECO ,round(nvl(Sum(TLSD),0),2) as TLSD, nvl(SUM(Ord_Val),0) as Ord_Val , nvl(SUM(ord_qty), 0) as ord_qty, nvl(SUM(Display),0) as Display " +
" from( " +
" Select " +
" SalesPerson_Name , " +
" SUM(Tot_Calls) Tot_Calls , " +
" SUM(Tot_PC) Tot_PC , " +
" SUM(ECO) ECO , " +
" (Case When Sum(Tot_FW_Days) = 0 Then 0 Else SUM(TLSD)/Sum(Tot_FW_Days) End) as TLSD , " +
" SUM(Ord_Val) Ord_Val ,SUM(Display) Display, SUM(ord_qty) ord_qty " +
" From ( Select SM.Sales_Pers as SalesPerson_Code ,SP.SP_Name as SalesPerson_Name ,nvl(count(SM.strg_code),0) as Tot_Calls , " +
" nvl((select count(distinct strg_code) from STRG_MEET_ORDER SMO where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as Tot_PC , " +
" 0 as ECO ,nvl((select count(*) from STRG_MEET_ORDER SMO where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as TLSD , " +
" nvl((select sum(value) from STRG_MEET_ORDER SMO where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as Ord_Val , " +
" nvl((select sum(quantity) from STRG_MEET_ORDER SMO where SMO.dcr_id=SM.dcr_id and SMO.Quantity > 0),0) as Ord_Qty , " +
" nvl((select count(distinct strg_code) from STRG_ITEM_DISPLAY SID where SID.dcr_id=SM.dcr_id),0) as Display , " +
" nvl(COUNT(DISTINCT (case when FA.Activity_Type = 'FW' Then (SM.DCR_ID) end)),0) as Tot_FW_Days FROM Strg_Meet SM , " +
" Sales_Pers SP , " +
" FieldActivity FA " +
" Where SM.Sales_Pers = SP.Sales_Pers And FA.Activity_Code = SM.Event_Type " +
" AND SM.event_date BETWEEN TO_DATE('"+fromDate+"','YYYY-MM-dd') and TO_DATE('"+toDate+"','YYYY-MM-dd')" +
" And SM.Sales_Pers In ( Select Emp_Code " +
" From Employee Start With Emp_code = (Select Emp_Code From Users Where Code = "+salePerson+") " +
" Connect By Prior Emp_Code =Report_To )" +
" Group By SM.Sales_Pers ,SP.SP_Name ,SM.dcr_id " +
" UNION ALL " +
" select SM.Sales_Pers as SalesPerson_Code , " +
" SP.SP_Name as SalesPerson_Name , " +
" 0 as Tot_Calls , " +
" 0 as Tot_PC , " +
" nvl(count(distinct smo.strg_code),0) as ECO , " +
" 0 as TLSD , " +
" 0 as Ord_Val , " +
" 0 as Ord_Qty , " +
" 0 as Display , " +
" 0 as Tot_FW_Days " +
" FROM Strg_Meet SM ,Sales_Pers SP , " +
" Strg_Meet_Order SMO " +
" Where SM.Sales_Pers = SP.Sales_Pers " +
" And SM.Strg_Code = SMO.Strg_Code And SM.Dcr_Id = SMO.DCR_Id " +
" AND SM.event_date BETWEEN TO_DATE('"+fromDate+"','YYYY-MM-dd') and TO_DATE('"+toDate+"','YYYY-MM-dd')" +
" And SM.Sales_Pers In ( Select Emp_Code " +
" From Employee Start With Emp_code = (Select Emp_Code From Users Where Code = "+salePerson+") " +
" Connect By Prior Emp_Code =Report_To )" +
" And (SMO.Quantity) > 0 Group By SM.Sales_Pers,SP.SP_Name ) " +
" Group By " +
" SalesPerson_Name )";
System.out.println("In ConsumerGoodsCRM getKPISummary sql: ---- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
JSONObject kpiInfo = null;
JSONObject summary = null;
JSONObject detail = null;
JSONObject workDtl = getWorkDtl(dataSourceName, fromDate, toDate, salePerson);
kpiInfo = new JSONObject();
detail = new JSONObject();
detail.put("keyName", "Todays Calls");
detail.put("keyValue", checkNull(rs.getString("TOT_CALLS")));
detail.put("color", "#89cbfc");
kpiInfo.put("detail",detail);
summary = new JSONObject();
summary.put("keyName", "Total Lines Sold Daily");
summary.put("keyValue", checkNull(rs.getString("TLSD")));
summary.put("color", "#c26be9");
kpiInfo.put("summary",summary);
kpiSummary.add(kpiInfo);
kpiInfo = new JSONObject();
detail = new JSONObject();
detail.put("keyName", "Productive Calls");
detail.put("keyValue", checkNull(rs.getString("TOT_PC")));
detail.put("color", "#86e8c6");
kpiInfo.put("detail",detail);
summary = new JSONObject();
summary.put("keyName", "Call Balance");
summary.put("keyValue", String.valueOf(totalCallBal));
summary.put("color", "#ffca3b");
kpiInfo.put("summary",summary);
kpiSummary.add(kpiInfo);
kpiInfo = new JSONObject();
detail = new JSONObject();
detail.put("keyName", "Orders");
detail.put("keyValue", checkNull(rs.getString("ORD_QTY")));
detail.put("color", "#c0b9f6");
kpiInfo.put("detail",detail);
summary = new JSONObject();
summary.put("keyName", "SKU");
summary.put("keyValue", workDtl.get("sku_name"));
summary.put("color", "#f37487");
kpiInfo.put("summary",summary);
kpiSummary.add(kpiInfo);
kpiInfo = new JSONObject();
detail = new JSONObject();
detail.put("keyName", "Display");
detail.put("keyValue", checkNull(rs.getString("DISPLAY")));
detail.put("color", "#f9af92");
kpiInfo.put("detail",detail);
summary = new JSONObject();
summary.put("keyName", "Outlets");
summary.put("keyValue", workDtl.get("outlet_booked"));
summary.put("color", "#3e3f3f");
kpiInfo.put("summary",summary);
kpiSummary.add(kpiInfo);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
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;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in ConsumerGoodsCRM:getKPISummary" + d.getMessage());
throw new ITMException(d);
}
}
return kpiSummary;
}
public JSONObject getWorkDtl(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException
{
JSONObject workDetl = new JSONObject();
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
System.out.println("In ConsumerGoodsCRM getWorkDtl After format :: fromDate:["+fromDate+"] toDate:["+toDate+"]");
sql = " Select count(Sku_Name) as Sku_Name , nvl(sum(outlet_booked),0) as outlet_booked " +
" from( " +
" Select " +
" I.Descr AS Sku_Name " +
" ,Sum(SMO.Quantity) as Qty_Booked " +
" ,Count(SMO.Strg_Code) as outlet_booked " +
" FROM Strg_Meet SM " +
" ,Sales_Pers SP " +
" ,Strg_Meet_Order SMO " +
" ,item I " +
" Where SM.Sales_Pers = SP.Sales_Pers " +
" And SM.Strg_Code = SMO.Strg_Code " +
" And SM.Dcr_Id = SMO.DCR_Id " +
" And I.Item_Code = SMO.Item_Code " +
" AND SM.event_date BETWEEN TO_DATE('"+fromDate+"','YYYY-MM-dd') and TO_DATE('"+toDate+"','YYYY-MM-dd')" +
" And SM.Sales_Pers In ( Select Emp_Code " +
" From Employee Start With Emp_code = (Select Emp_Code From Users Where Code = "+salePerson+") " +
" Connect By Prior Emp_Code =Report_To )" +
" And (SMO.Quantity) > 0 " +
" Group By " +
" I.Descr " +
" Order By Sku_Name)";
System.out.println("In ConsumerGoodsCRM getWorkDtl SQL:["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
workDetl.put("sku_name", checkNull (rs.getString("SKU_NAME")));
workDetl.put("outlet_booked", checkNull(rs.getString("OUTLET_BOOKED")));
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
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;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :ConsumerGoodsCRM : getWorkDtl" + d.getMessage());
throw new ITMException(d);
}
}
return workDetl;
}
@SuppressWarnings("unchecked")
@Override
public JSONArray getWorkDetails(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException
{
JSONArray workDetails = new JSONArray();
JSONArray finalWorkDetails = new JSONArray();
JSONObject salesPersDetails = new JSONObject();
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
dashboardUtility = new DashboardUtility();
salePerson = dashboardUtility.getCommaSeparated(salePerson);
fromDate = genericUtility.getValidDateString( fromDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat() );
toDate = genericUtility.getValidDateString( toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat() );
sql = " Select sm.sales_pers ,SP.SP_Name as SalesPerson_Name, I.Descr AS Sku_Name" +
" ,Sum(SMO.Quantity) as Qty_Booked" +
" ,Count(SMO.Strg_Code) as outlet_booked" +
" FROM Strg_Meet SM" +
" ,Sales_Pers SP" +
" ,Strg_Meet_Order SMO" +
" ,item I " +
" Where SM.Sales_Pers = SP.Sales_Pers" +
" And SM.Strg_Code = SMO.Strg_Code" +
" And SM.Dcr_Id = SMO.DCR_Id" +
" And I.Item_Code = SMO.Item_Code" +
" AND SM.event_date BETWEEN TO_DATE('"+fromDate+"','YYYY-MM-dd') and TO_DATE('"+toDate+"','YYYY-MM-dd')" +
" And SM.Sales_Pers In ( Select Emp_Code" +
" From Employee Start With Emp_code = (Select Emp_Code From Users Where Code = "+salePerson+")" +
" Connect By Prior Emp_Code =Report_To )" +
" And (SMO.Quantity) > 0" +
" Group By sm.sales_pers ,SP.SP_Name ,I.Descr" +
" Order By SalesPerson_Name,Sku_Name";
System.out.println("In ConsumerGoodsCRM getWorkDetail sql: ---- ["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
JSONObject workDetail = new JSONObject();
String salesPers = checkNull(rs.getString("SALES_PERS"));
String salesPersName = checkNull(rs.getString("SALESPERSON_NAME"));
String productName = checkNull(rs.getString("SKU_NAME"));
String productOutlet = checkNull(rs.getString("OUTLET_BOOKED"));
String productQuantity = checkNull(rs.getString("QTY_BOOKED"));
String productInitals = getProductInitals(productName);
String hostUrl = CommonConstants.TOMCAT_HOME;
String customerImg = hostUrl+"/ibase/CustomMenuImageServlet?fldValue="+salesPers+"&ALT_FLD_VALUE="+salesPersName;
workDetail.put("salesPers", salesPers);
workDetail.put("customer", salesPersName);
workDetail.put("customer_img", customerImg);
workDetail.put("product", productName);
workDetail.put("product_intitals", productInitals);
workDetail.put("product_outlet", productOutlet);
workDetail.put("product_quantity", productQuantity);
JSONObject salesPersDet = (JSONObject) salesPersDetails.get(salesPers);
if(salesPersDet == null || salesPersDet.size() == 0)
{
salesPersDet = new JSONObject();
salesPersDet.put("outletCount", Integer.parseInt(productOutlet));
salesPersDet.put("skuCount", 1);
}
else
{
int outletCount = (int) salesPersDet.get("outletCount") + Integer.parseInt(productOutlet);
int skuCount = (int) salesPersDet.get("skuCount") + 1;
salesPersDet.put("outletCount", outletCount);
salesPersDet.put("skuCount", skuCount);
}
salesPersDetails.put(salesPers, salesPersDet);
workDetails.add(workDetail);
}
for(int i = 0 ; i < workDetails.size() ; i++)
{
JSONObject workDetail = (JSONObject) workDetails.get(i);
String salesPers = (String) workDetail.get("salesPers");
JSONObject salesPersDet = (JSONObject) salesPersDetails.get(salesPers);
workDetail.put("customer_outlet", salesPersDet.get("outletCount"));
workDetail.put("customer_sku", salesPersDet.get("skuCount"));
finalWorkDetails.add(workDetail);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
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;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in ConsumerGoodsCRM:getWorkDetail" + d.getMessage());
throw new ITMException(d);
}
}
return finalWorkDetails;
}
private String getProductInitals(String productName)
{
String[] myName = productName.split(" ");
String initials = "";
if(myName[0] != null && myName[0].length() > 0)
{
initials = initials + String.valueOf(myName[0].charAt(0));
}
if(myName[1] != null && myName[1].length() > 0)
{
initials = initials + String.valueOf(myName[1].charAt(0));
}
return initials;
}
private String checkNull(String str)
{
if (str == null)
{
return "";
}
else
{
return str;
}
}
}
\ No newline at end of file
package ibase.dashboard.sfa.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
@Local
public interface ConsumerGoodsCRMLocal extends ValidatorLocal
{
public JSONArray getWorkSummary(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException;
public JSONArray getKPISummary(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException;
public JSONArray getWorkDetails(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException;
}
package ibase.dashboard.sfa.ejb;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
@Remote
public interface ConsumerGoodsCRMRemote extends ValidatorRemote
{
public JSONArray getWorkSummary(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException;
public JSONArray getKPISummary(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException;
public JSONArray getWorkDetails(String dataSourceName, String fromDate, String toDate, String salePerson) throws RemoteException, ITMException;
}
package ibase.dashboard.sfa.servlet;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import ibase.dashboard.sfa.ejb.ConsumerGoodsCRM;
import ibase.webitm.utility.ITMException;
public class ConsumerGoodsCRMServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
ConsumerGoodsCRM consumerGoodsCRM = null;
String dataSourceName = "";
String loginUser ="";
String salePerson = "";
String fromDate = "";
String toDate = "";
JSONObject finalCRMData = new JSONObject();
try
{
response.setContentType("application/xml");
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) request.getSession().getAttribute("USER_INFO");
if(userInfo != null)
{
loginUser = userInfo.getLoginCode();
dataSourceName = userInfo.getTransDB();
}
fromDate = request.getParameter("fromDate");
toDate = request.getParameter("toDate");
salePerson = request.getParameter("aseName");
if(salePerson == null || salePerson.length()== 0)
{
salePerson = loginUser;
}
consumerGoodsCRM = new ConsumerGoodsCRM();
JSONArray workSummary = consumerGoodsCRM.getWorkSummary(dataSourceName, fromDate, toDate, salePerson);
JSONArray kpiSummary = consumerGoodsCRM.getKPISummary(dataSourceName, fromDate, toDate, salePerson);
JSONArray workDetails = consumerGoodsCRM.getWorkDetails(dataSourceName, fromDate, toDate, salePerson);
finalCRMData.put("WORK_SUMMARY", workSummary);
finalCRMData.put("KPI_SUMMARY", kpiSummary);
finalCRMData.put("WORK_DETAIL", workDetails);
OutputStream outputStream = response.getOutputStream();
outputStream.write(finalCRMData.toString().getBytes());
outputStream.flush();
outputStream.close();
}
catch (Exception e)
{
System.out.println("Exception : ConsumerGoodsCRMServlet :doPost(HttpServletRequest request, HttpServletResponse response) :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
finally
{
if(consumerGoodsCRM != null)
{
consumerGoodsCRM = null;
}
}
}
}
\ No newline at end of file
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