Commit 7f8dc113 authored by sbade's avatar sbade

changes as per client side code


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97704 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 22dc18da
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,10 +12,8 @@ import org.json.simple.JSONObject;
@Local
public interface SalesPerformanceLocal extends ValidatorLocal
{
public JSONObject getGridData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getSalesGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getProfitGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getExpenseGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getMnthlySalesGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getYTDSalesGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getMnthSalesDivWiseGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
......@@ -26,6 +24,4 @@ public interface SalesPerformanceLocal extends ValidatorLocal
public JSONObject getBrandWiseZoneDetail(String dataSourceName,String month,String brandName) throws RemoteException, ITMException;
public JSONObject getBrandZoneWiseMetroDetail(String dataSourceName,String month,String brandName,String zoneDescr,String divDescr) throws RemoteException, ITMException;
public JSONObject getTopBrandMTH(String dataSourceName,String month,String divCode) throws RemoteException, ITMException;
public JSONObject getProfitYTDGraphData(String dataSourceName, String month) throws RemoteException, ITMException;
public JSONObject getExpenseYTDGraphData(String dataSourceName, String month) throws RemoteException, ITMException;
}
......@@ -11,10 +11,8 @@ import org.json.simple.JSONObject;
@Remote
public interface SalesPerformanceRemote extends ValidatorRemote
{
public JSONObject getGridData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getSalesGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getProfitGraphData(String dataSourceName ,String month) throws RemoteException, ITMException;
public JSONObject getExpenseGraphData(String dataSourceName ,String month) throws RemoteException, ITMException;
public JSONObject getMnthlySalesGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getYTDSalesGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
public JSONObject getMnthSalesDivWiseGraphData(String dataSourceName,String month) throws RemoteException, ITMException;
......@@ -25,6 +23,4 @@ public interface SalesPerformanceRemote extends ValidatorRemote
public JSONObject getTopBrandMTH(String dataSourceName,String month,String divCode) throws RemoteException, ITMException;
public JSONObject getBrandWiseZoneDetail(String dataSourceName,String month,String brandName) throws RemoteException, ITMException;
public JSONObject getBrandZoneWiseMetroDetail(String dataSourceName,String month,String brandName,String zoneDescr,String divDescr) throws RemoteException, ITMException;
public JSONObject getProfitYTDGraphData(String dataSourceName, String month) throws RemoteException, ITMException;
public JSONObject getExpenseYTDGraphData(String dataSourceName, String month) throws RemoteException, ITMException;
}
......@@ -24,7 +24,15 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
/*** 1 - This method will contains final data for rendering Top Brands graph ***/
/*** 1.
*
* Method Name : getAllIndiaTopBrandData(String dataSourceName, String month, String topNos)
* Servlet Name : AllIndiaTopBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering All India Top Brand graph.
* Graph Caption :
* 1. All India Top Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getAllIndiaTopBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
......@@ -94,15 +102,22 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMthlySalesJson;
}
/***
* 2 - This method will contains final data for rendering division wise
* graph CNS
***/
/** End of method getAllIndiaTopBrandData() **/
/*** 2.
*
* Method Name : getCNSDivisionBrandData(String dataSourceName, String month,String topNos)
* Servlet Name : CNSDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering CNS Top Brand graph.
* Graph Caption :
* 1. CNS Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getCNSDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
......@@ -165,15 +180,20 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
/***
* 3 - This method will contains final data for rendering division wise
* graph CVD
***/
/** End of Method getCNSDivisionBrandData() **/
/*** 3.
*
* Method Name : getCVDDivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : CVDDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering CVD Top Brand graph.
* Graph Caption :
* 1. CVD Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getCVDDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
......@@ -235,15 +255,21 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
/***
*4- This method will contains final data for rendering division wise
* graph GI/PAIN
***/
/** End of method getCVDDivisionBrandData() **/
/*** 4.
*
* Method Name : getGIPAINDivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : GIPAINDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering GI/PAIN Top Brand graph.
* Graph Caption :
* 1. GI/PAIN Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getGIPAINDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
......@@ -305,15 +331,21 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
/***
* 5- This method will contains final data for rendering division wise
* graph GYNAEC
***/
/** End of method getGIPAINDivisionBrandData() **/
/*** 5.
*
* Method Name : getGYNAECDivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : GYNAECDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering GYNAEC Top Brand graph.
* Graph Caption :
* 1. GYNAEC Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getGYNAECDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
......@@ -376,15 +408,20 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
/***
* 6 - This method will contains final data for rendering division wise
* graph OPTHAL
***/
/** End of method getGYNAECDivisionBrandData() **/
/*** 6.
*
* Method Name : getOPTHALDivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : OPTHALDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering OPTHAL Top Brand graph.
* Graph Caption :
* 1. OPTHAL Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getOPTHALDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
......@@ -446,13 +483,20 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
//add new method on dated 5-aug-20014
//method 7
/** End of method getOPTHALDivisionBrandData() **/
/*** 7.
*
* Method Name : getURODivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : URODivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering URO Top Brand graph.
* Graph Caption :
* 1. URO Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getURODivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
......@@ -513,9 +557,18 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
/** End of method getURODivisionBrandData() **/
/*** 8.
*
* Method Name : getONCODivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : ONCODivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering ONCO Top Brand graph.
* Graph Caption :
* 1. ONCO Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
//method 8
public JSONObject getONCODivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
......@@ -580,9 +633,16 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
return rawDataMnthDivWiseSalesJson;
}
@SuppressWarnings("unchecked")
//method 9
/*** 9.
*
* Method Name : getDERMADivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : DERMADivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering DERMA Top Brand graph.
* Graph Caption :
* 1. DERMA Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getDERMADivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
......@@ -646,78 +706,91 @@ public class SalesPerformanceTwo extends ValidatorEJB implements SalesPerformanc
}
return rawDataMnthDivWiseSalesJson;
}
/** End of method getDERMADivisionBrandData() **/
@SuppressWarnings("unchecked")
//method 10
public JSONObject getRESPDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
topNos = "10";
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = "SELECT sr_no, brand_name, div_group,ROUND(sale_YTD_cy/10000000,1) AS sale_YTD_cy,ROUND(sale_YTD_ly/10000000,1) AS sale_YTD_ly, " + " (CASE WHEN NVL(sale_YTD_ly,0) = 0 THEN 900 ELSE ROUND((sale_YTD_cy -sale_YTD_ly)/ sale_YTD_ly* 100,1) END) AS gr_prcnt, " + " ROUND(hotrgt_ytd_cy/10000000,1) AS hotrgt_ytd,ROUND(trgt_ytd_cy/10000000,1) AS Fldtrgt_ytd,(CASE WHEN NVL(hotrgt_ytd_cy,0) = 0 THEN 0 " + " ELSE ROUND(sale_YTD_cy/hotrgt_ytd_cy * 100,1) END ) AS ho_ach_prcnt,(CASE WHEN NVL(trgt_ytd_cy,0) = 0 THEN 0 " + " ELSE ROUND(sale_YTD_cy/trgt_ytd_cy * 100,1) END ) AS fld_ach_prcnt, " + " totterr, terr100, ROUND(terr100/totterr*100,1) AS terr100prcnt " + " FROM (SELECT row_number() OVER( PARTITION BY div_group ORDER BY sale_YTD_cy DESC ) AS sr_no, " + " fin_year, div_group, sub_grp AS brand_name, sale_YTD_cy, sale_YTD_ly, trgt_YTD_cy, hotrgt_ytd_cy, " + " totterr, terr100 FROM (SELECT a.fin_year, divmst.div_group, sub_grp, " + " SUM(sale_YTD_cy) AS sale_YTD_cy, SUM(sale_YTD_ly) AS sale_YTD_ly,SUM(trgt_YTD_cy) AS trgt_YTD_cy, " + " SUM(hotrgt_ytd_cy) AS hotrgt_ytd_cy,SUM(terrcnt) AS totterr, SUM(terr100cnt) AS terr100 " + " FROM(SELECT dwh.fin_year , dwh.item_ser,dwh.grp_nm AS sub_grp,dwh.terr_code, " + " SUM(sale_YTD_cy) AS sale_YTD_cy,SUM(sale_YTD_ly) AS sale_YTD_ly, " + " SUM(trgt_YTD_cy) AS trgt_YTD_cy,ROUND(SUM(trgt_YTD_cy * (100+ NVL(brnd.HO_TRGT_INCR_PRCNT,0)) /100),2) AS hotrgt_ytd_cy, " + " 1 AS terrcnt,(CASE WHEN SUM(trgt_YTD_cy) =0 THEN 1 WHEN ROUND(SUM( sale_YTD_cy) / SUM(trgt_YTD_cy * " + " (100+ NVL(brnd.HO_TRGT_INCR_PRCNT,0))/100) *100,1)>= 100 THEN 1 ELSE 0 END ) AS terr100cnt " + " FROM (SELECT fin_year , SM_SALES_SUMM_WIDE.item_ser,sales_item.item_sub_group AS sub_grp, sales_item.item_sub_group_descr AS grp_nm, " + " SM_SALES_SUMM_WIDE.terr_code AS terr_code," + " (CASE WHEN SUBSTR(" + month + " ,5,2) ='04' THEN SUM(CY_SALE_YTD_APR) " + " WHEN SUBSTR(" + month + " ,5,2) ='05' THEN SUM(CY_SALE_YTD_MAY) " + " WHEN SUBSTR(" + month + " ,5,2) ='06' THEN SUM(CY_SALE_YTD_JUN) " + " WHEN SUBSTR(" + month + " ,5,2) ='07' THEN SUM(CY_SALE_YTD_JUL) " + " WHEN SUBSTR(" + month + " ,5,2) ='08' THEN SUM(CY_SALE_YTD_AUG) " + " WHEN SUBSTR(" + month + " ,5,2) ='09' THEN SUM(CY_SALE_YTD_SEP) " + " WHEN SUBSTR(" + month + " ,5,2) ='10' THEN SUM(CY_SALE_YTD_OCT) " + " WHEN SUBSTR(" + month + " ,5,2) ='11' THEN SUM(CY_SALE_YTD_NOV) " + " WHEN SUBSTR(" + month + " ,5,2) ='12' THEN SUM(CY_SALE_YTD_DEC) " + " WHEN SUBSTR(" + month + " ,5,2) ='01' THEN SUM(CY_SALE_YTD_JAN) " + " WHEN SUBSTR(" + month + " ,5,2) ='02' THEN SUM(CY_SALE_YTD_FEB) " + " WHEN SUBSTR(" + month + " ,5,2) ='03' THEN SUM(CY_SALE_YTD_MAR) END ) AS sale_YTD_cy, " + " (CASE WHEN SUBSTR(" + month + " ,5,2) ='04' THEN SUM(lY_SALE_YTD_APR) " + " WHEN SUBSTR(" + month + " ,5,2) ='05' THEN SUM(lY_SALE_YTD_MAY) " + " WHEN SUBSTR(" + month + " ,5,2) ='06' THEN SUM(lY_SALE_YTD_JUN) " + " WHEN SUBSTR(" + month + " ,5,2) ='07' THEN SUM(lY_SALE_YTD_JUL) " + " WHEN SUBSTR(" + month + " ,5,2) ='08' THEN SUM(lY_SALE_YTD_AUG) " + " WHEN SUBSTR(" + month + " ,5,2) ='09' THEN SUM(lY_SALE_YTD_SEP) " + " WHEN SUBSTR(" + month + " ,5,2) ='10' THEN SUM(lY_SALE_YTD_OCT) " + " WHEN SUBSTR(" + month + " ,5,2) ='11' THEN SUM(lY_SALE_YTD_NOV) " + " WHEN SUBSTR(" + month + " ,5,2) ='12' THEN SUM(lY_SALE_YTD_DEC) " + " WHEN SUBSTR(" + month + " ,5,2) ='01' THEN SUM(lY_SALE_YTD_JAN) " + " WHEN SUBSTR(" + month + " ,5,2) ='02' THEN SUM(lY_SALE_YTD_FEB) " + " WHEN SUBSTR(" + month + " ,5,2) ='03' THEN SUM(lY_SALE_YTD_MAR) END ) AS sale_YTD_ly, " + " (CASE WHEN SUBSTR(" + month + " ,5,2) ='04' THEN SUM(FLD_TRGT_YTD_APR) " + " WHEN SUBSTR(" + month + " ,5,2) ='05' THEN SUM(FLD_TRGT_YTD_MAY) " + " WHEN SUBSTR(" + month + " ,5,2) ='06' THEN SUM(FLD_TRGT_YTD_JUN) " + " WHEN SUBSTR(" + month + " ,5,2) ='07' THEN SUM(FLD_TRGT_YTD_JUL) " + " WHEN SUBSTR(" + month + " ,5,2) ='08' THEN SUM(FLD_TRGT_YTD_AUG) " + " WHEN SUBSTR(" + month + " ,5,2) ='09' THEN SUM(FLD_TRGT_YTD_SEP) " + " WHEN SUBSTR(" + month + " ,5,2) ='10' THEN SUM(FLD_TRGT_YTD_OCT) " + " WHEN SUBSTR(" + month + " ,5,2) ='11' THEN SUM(FLD_TRGT_YTD_NOV) " + " WHEN SUBSTR(" + month + " ,5,2) ='12' THEN SUM(FLD_TRGT_YTD_DEC) " + " WHEN SUBSTR(" + month + " ,5,2) ='01' THEN SUM(FLD_TRGT_YTD_JAN) " + " WHEN SUBSTR(" + month + " ,5,2) ='02' THEN SUM(FLD_TRGT_YTD_FEB) " + " WHEN SUBSTR(" + month + " ,5,2) ='03' THEN SUM(FLD_TRGT_YTD_MAR) END ) AS trgt_YTD_cy " + " FROM SM_SALES_SUMM_WIDE, sales_item " + " WHERE trim(fin_year)= (CASE WHEN SUBSTR(" + month + " ,5,2)<4 " + " THEN SUBSTR(" + month + " -100 ,1,4)||'-'||SUBSTR(" + month + " ,3,2) " + " ELSE SUBSTR(" + month + " ,1,4)||'-' || SUBSTR(" + month + " +100,3,2) END) " + " AND " + month + " = " + month + " AND SM_SALES_SUMM_WIDE.item_code= sales_item.item_code " + " AND sales_item.item_sub_group NOT IN ('CU','BJ') " + " GROUP BY fin_year ,SM_SALES_SUMM_WIDE.item_ser, sales_item.item_sub_group, " + " sales_item.item_sub_group_descr, SM_SALES_SUMM_WIDE.terr_code ) dwh, " + " SM_SALES_BRAND_MST brnd " + " WHERE brnd.brand_code(+) = dwh.sub_grp " + " AND brnd.div_code(+) = dwh.item_ser " + " AND brnd.fin_year(+) = dwh.fin_year " + " AND dwh.sale_ytd_cy+ dwh.trgt_YTD_cy <>0 " + " GROUP BY dwh.fin_year, dwh.item_ser, dwh.grp_nm,dwh.terr_code ) a, " + " SM_SALES_DIV_MST divmst " + " WHERE a.item_ser= divmst.div_code AND a.fin_year = divmst.fin_year " + " GROUP BY a.fin_year, divmst.div_group, a.sub_grp )) dwh " + " where DIV_GROUP='RESP' " + " order by DIV_GROUP, SR_NO ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
if (count < Integer.parseInt(topNos))
{
rowData = new JSONObject();
rowData.put("brand_name", getBrandName(checkNull(rs.getString("brand_name"))));
rowData.put("sales_ytd_cy", checkNull(rs.getString("sale_YTD_cy")));
rowData.put("gr_prcnt", checkNull(rs.getString("gr_prcnt")));
rowData.put("ho_ach_prcnt", checkNull(rs.getString("ho_ach_prcnt")));
rawDataMnthDivWiseSalesJson.put(count, rowData);
count++;
}
}
System.out.println("fetch Data for getRESPDivisionBrandData rawjson====" + rawDataMnthDivWiseSalesJson.toString());
} catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
} finally
/*** 10.
*
* Method Name : getRESPDivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : RESPDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering RESP Top Brand graph.
* Graph Caption :
* 1. RESP Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getRESPDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
JSONObject rawDataMnthDivWiseSalesJson = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
topNos = "10";
try
{
if (conn != null)
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
sql = "SELECT sr_no, brand_name, div_group,ROUND(sale_YTD_cy/10000000,1) AS sale_YTD_cy,ROUND(sale_YTD_ly/10000000,1) AS sale_YTD_ly, " + " (CASE WHEN NVL(sale_YTD_ly,0) = 0 THEN 900 ELSE ROUND((sale_YTD_cy -sale_YTD_ly)/ sale_YTD_ly* 100,1) END) AS gr_prcnt, " + " ROUND(hotrgt_ytd_cy/10000000,1) AS hotrgt_ytd,ROUND(trgt_ytd_cy/10000000,1) AS Fldtrgt_ytd,(CASE WHEN NVL(hotrgt_ytd_cy,0) = 0 THEN 0 " + " ELSE ROUND(sale_YTD_cy/hotrgt_ytd_cy * 100,1) END ) AS ho_ach_prcnt,(CASE WHEN NVL(trgt_ytd_cy,0) = 0 THEN 0 " + " ELSE ROUND(sale_YTD_cy/trgt_ytd_cy * 100,1) END ) AS fld_ach_prcnt, " + " totterr, terr100, ROUND(terr100/totterr*100,1) AS terr100prcnt " + " FROM (SELECT row_number() OVER( PARTITION BY div_group ORDER BY sale_YTD_cy DESC ) AS sr_no, " + " fin_year, div_group, sub_grp AS brand_name, sale_YTD_cy, sale_YTD_ly, trgt_YTD_cy, hotrgt_ytd_cy, " + " totterr, terr100 FROM (SELECT a.fin_year, divmst.div_group, sub_grp, " + " SUM(sale_YTD_cy) AS sale_YTD_cy, SUM(sale_YTD_ly) AS sale_YTD_ly,SUM(trgt_YTD_cy) AS trgt_YTD_cy, " + " SUM(hotrgt_ytd_cy) AS hotrgt_ytd_cy,SUM(terrcnt) AS totterr, SUM(terr100cnt) AS terr100 " + " FROM(SELECT dwh.fin_year , dwh.item_ser,dwh.grp_nm AS sub_grp,dwh.terr_code, " + " SUM(sale_YTD_cy) AS sale_YTD_cy,SUM(sale_YTD_ly) AS sale_YTD_ly, " + " SUM(trgt_YTD_cy) AS trgt_YTD_cy,ROUND(SUM(trgt_YTD_cy * (100+ NVL(brnd.HO_TRGT_INCR_PRCNT,0)) /100),2) AS hotrgt_ytd_cy, " + " 1 AS terrcnt,(CASE WHEN SUM(trgt_YTD_cy) =0 THEN 1 WHEN ROUND(SUM( sale_YTD_cy) / SUM(trgt_YTD_cy * " + " (100+ NVL(brnd.HO_TRGT_INCR_PRCNT,0))/100) *100,1)>= 100 THEN 1 ELSE 0 END ) AS terr100cnt " + " FROM (SELECT fin_year , SM_SALES_SUMM_WIDE.item_ser,sales_item.item_sub_group AS sub_grp, sales_item.item_sub_group_descr AS grp_nm, " + " SM_SALES_SUMM_WIDE.terr_code AS terr_code," + " (CASE WHEN SUBSTR(" + month + " ,5,2) ='04' THEN SUM(CY_SALE_YTD_APR) " + " WHEN SUBSTR(" + month + " ,5,2) ='05' THEN SUM(CY_SALE_YTD_MAY) " + " WHEN SUBSTR(" + month + " ,5,2) ='06' THEN SUM(CY_SALE_YTD_JUN) " + " WHEN SUBSTR(" + month + " ,5,2) ='07' THEN SUM(CY_SALE_YTD_JUL) " + " WHEN SUBSTR(" + month + " ,5,2) ='08' THEN SUM(CY_SALE_YTD_AUG) " + " WHEN SUBSTR(" + month + " ,5,2) ='09' THEN SUM(CY_SALE_YTD_SEP) " + " WHEN SUBSTR(" + month + " ,5,2) ='10' THEN SUM(CY_SALE_YTD_OCT) " + " WHEN SUBSTR(" + month + " ,5,2) ='11' THEN SUM(CY_SALE_YTD_NOV) " + " WHEN SUBSTR(" + month + " ,5,2) ='12' THEN SUM(CY_SALE_YTD_DEC) " + " WHEN SUBSTR(" + month + " ,5,2) ='01' THEN SUM(CY_SALE_YTD_JAN) " + " WHEN SUBSTR(" + month + " ,5,2) ='02' THEN SUM(CY_SALE_YTD_FEB) " + " WHEN SUBSTR(" + month + " ,5,2) ='03' THEN SUM(CY_SALE_YTD_MAR) END ) AS sale_YTD_cy, " + " (CASE WHEN SUBSTR(" + month + " ,5,2) ='04' THEN SUM(lY_SALE_YTD_APR) " + " WHEN SUBSTR(" + month + " ,5,2) ='05' THEN SUM(lY_SALE_YTD_MAY) " + " WHEN SUBSTR(" + month + " ,5,2) ='06' THEN SUM(lY_SALE_YTD_JUN) " + " WHEN SUBSTR(" + month + " ,5,2) ='07' THEN SUM(lY_SALE_YTD_JUL) " + " WHEN SUBSTR(" + month + " ,5,2) ='08' THEN SUM(lY_SALE_YTD_AUG) " + " WHEN SUBSTR(" + month + " ,5,2) ='09' THEN SUM(lY_SALE_YTD_SEP) " + " WHEN SUBSTR(" + month + " ,5,2) ='10' THEN SUM(lY_SALE_YTD_OCT) " + " WHEN SUBSTR(" + month + " ,5,2) ='11' THEN SUM(lY_SALE_YTD_NOV) " + " WHEN SUBSTR(" + month + " ,5,2) ='12' THEN SUM(lY_SALE_YTD_DEC) " + " WHEN SUBSTR(" + month + " ,5,2) ='01' THEN SUM(lY_SALE_YTD_JAN) " + " WHEN SUBSTR(" + month + " ,5,2) ='02' THEN SUM(lY_SALE_YTD_FEB) " + " WHEN SUBSTR(" + month + " ,5,2) ='03' THEN SUM(lY_SALE_YTD_MAR) END ) AS sale_YTD_ly, " + " (CASE WHEN SUBSTR(" + month + " ,5,2) ='04' THEN SUM(FLD_TRGT_YTD_APR) " + " WHEN SUBSTR(" + month + " ,5,2) ='05' THEN SUM(FLD_TRGT_YTD_MAY) " + " WHEN SUBSTR(" + month + " ,5,2) ='06' THEN SUM(FLD_TRGT_YTD_JUN) " + " WHEN SUBSTR(" + month + " ,5,2) ='07' THEN SUM(FLD_TRGT_YTD_JUL) " + " WHEN SUBSTR(" + month + " ,5,2) ='08' THEN SUM(FLD_TRGT_YTD_AUG) " + " WHEN SUBSTR(" + month + " ,5,2) ='09' THEN SUM(FLD_TRGT_YTD_SEP) " + " WHEN SUBSTR(" + month + " ,5,2) ='10' THEN SUM(FLD_TRGT_YTD_OCT) " + " WHEN SUBSTR(" + month + " ,5,2) ='11' THEN SUM(FLD_TRGT_YTD_NOV) " + " WHEN SUBSTR(" + month + " ,5,2) ='12' THEN SUM(FLD_TRGT_YTD_DEC) " + " WHEN SUBSTR(" + month + " ,5,2) ='01' THEN SUM(FLD_TRGT_YTD_JAN) " + " WHEN SUBSTR(" + month + " ,5,2) ='02' THEN SUM(FLD_TRGT_YTD_FEB) " + " WHEN SUBSTR(" + month + " ,5,2) ='03' THEN SUM(FLD_TRGT_YTD_MAR) END ) AS trgt_YTD_cy " + " FROM SM_SALES_SUMM_WIDE, sales_item " + " WHERE trim(fin_year)= (CASE WHEN SUBSTR(" + month + " ,5,2)<4 " + " THEN SUBSTR(" + month + " -100 ,1,4)||'-'||SUBSTR(" + month + " ,3,2) " + " ELSE SUBSTR(" + month + " ,1,4)||'-' || SUBSTR(" + month + " +100,3,2) END) " + " AND " + month + " = " + month + " AND SM_SALES_SUMM_WIDE.item_code= sales_item.item_code " + " AND sales_item.item_sub_group NOT IN ('CU','BJ') " + " GROUP BY fin_year ,SM_SALES_SUMM_WIDE.item_ser, sales_item.item_sub_group, " + " sales_item.item_sub_group_descr, SM_SALES_SUMM_WIDE.terr_code ) dwh, " + " SM_SALES_BRAND_MST brnd " + " WHERE brnd.brand_code(+) = dwh.sub_grp " + " AND brnd.div_code(+) = dwh.item_ser " + " AND brnd.fin_year(+) = dwh.fin_year " + " AND dwh.sale_ytd_cy+ dwh.trgt_YTD_cy <>0 " + " GROUP BY dwh.fin_year, dwh.item_ser, dwh.grp_nm,dwh.terr_code ) a, " + " SM_SALES_DIV_MST divmst " + " WHERE a.item_ser= divmst.div_code AND a.fin_year = divmst.fin_year " + " GROUP BY a.fin_year, divmst.div_group, a.sub_grp )) dwh " + " where DIV_GROUP='RESP' " + " order by DIV_GROUP, SR_NO ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next())
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
if (count < Integer.parseInt(topNos))
{
rowData = new JSONObject();
rowData.put("brand_name", getBrandName(checkNull(rs.getString("brand_name"))));
rowData.put("sales_ytd_cy", checkNull(rs.getString("sale_YTD_cy")));
rowData.put("gr_prcnt", checkNull(rs.getString("gr_prcnt")));
rowData.put("ho_ach_prcnt", checkNull(rs.getString("ho_ach_prcnt")));
rawDataMnthDivWiseSalesJson.put(count, rowData);
count++;
}
}
conn = null;
} catch (Exception d)
System.out.println("fetch Data for getRESPDivisionBrandData rawjson====" + rawDataMnthDivWiseSalesJson.toString());
} catch (Exception e)
{
d.printStackTrace();
System.out.println("Exception in :SalesPerfomanceTwo:getRESPDivisionBrandData:" + d.getMessage());
throw new ITMException(d);
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 :SalesPerfomanceTwo:getRESPDivisionBrandData:" + d.getMessage());
throw new ITMException(d);
}
}
return rawDataMnthDivWiseSalesJson;
}
return rawDataMnthDivWiseSalesJson;
}
/***
* 11 - This method will contains final data for rendering division wise
* graph SPL CARE
***/
/** End of method getRESPDivisionBrandData() **/
/*** 11.
*
* Method Name : getOtherDivisionBrandData(String dataSourceName,String month, String topNos)
* Servlet Name : OTHERDivisionBrandServlet
* Metadataxml Name : topbrandsdasboard.xml
* Description : This method returns raw data for rendering Other Brand graph.
* Graph Caption :
* 1. Other Top 10 Brands
* ***/
@SuppressWarnings("unchecked")
public JSONObject getOtherDivisionBrandData(String dataSourceName, String month, String topNos) throws RemoteException, ITMException
{
......@@ -783,7 +856,8 @@ public JSONObject getRESPDivisionBrandData(String dataSourceName, String month,
}
return rawDataMnthDivWiseSalesJson;
}
/** End of method getOtherDivisionBrandData() **/
private String checkNull(String str)
{
if (str == 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