Commit bdd83ac5 authored by abibave's avatar abibave

Request Id: W16INOV004

Changes done for 'no data display' message if data not present.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104474 ce508802-f39f-4f6c-b175-0d175dae99d5
parent ad559bf1
...@@ -30,7 +30,7 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi ...@@ -30,7 +30,7 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
Connection conn = null; Connection conn = null;
ConnDriver connDriver = null; ConnDriver connDriver = null;
int count = 0; int count = 0 , noOfRows = 0;
E12GenericUtility e12GenericUtility = null; E12GenericUtility e12GenericUtility = null;
SimpleDateFormat convertToDBDate = null; SimpleDateFormat convertToDBDate = null;
Calendar calendar = null; Calendar calendar = null;
...@@ -38,9 +38,9 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi ...@@ -38,9 +38,9 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi
String year = "", ytdYear = "", coachDayAndTimeHeading = ""; String year = "", ytdYear = "", coachDayAndTimeHeading = "";
StringBuffer zoneValueBuffer = null,finalBuffer = null, monthBuffer = null, headingBuffer = null, monthAvgValBuffer = null; StringBuffer zoneValueBuffer = null,finalBuffer = null, monthBuffer = null, headingBuffer = null, monthAvgValBuffer = null;
LinkedHashMap<String, StringBuffer> zonewiseDataMap = null; LinkedHashMap<String, StringBuffer> zonewiseDataMap = null;
LinkedHashMap<String, double[]> monthDataMap = null,ytdDataMap= null; LinkedHashMap<String, double[]> monthDataMap = null, ytdDataMap= null;
double[] ytdValueArray = null,monthValSumArray = null; double[] ytdValueArray = null,monthValSumArray = null;
double monthSumValue = 0.0D, ytdSumValue = 0.0D, monthPercSumValue = 0.0D, ytdPercSumValue = 0.0D,allIndiaYtdSum = 0.0D, allIndiaYtdPercSum = 0.0; double monthSumValue = 0.0D, ytdSumValue = 0.0D, monthPercSumValue = 0.0D, ytdPercSumValue = 0.0D, allIndiaYtdSum = 0.0D, allIndiaYtdPercSum = 0.0;
try try
{ {
...@@ -78,7 +78,8 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi ...@@ -78,7 +78,8 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi
System.out.println("From date = "+fromDate+" toDate ="+toDate); System.out.println("From date = "+fromDate+" toDate ="+toDate);
} }
sql = "SELECT H.ZONE, sm.Event_month, sm.MONTH, SUM(FN_RCOACHING_SP_NEW(SM.sales_pers,sm.MONTH, '"+year+"','REP')) AS monthly_count, SUM(vw_flm_qtq_teamwise.availdaysinfield) AS availdaysinfield, SUM(vw_flm_qtq_teamwise.daysinfield) AS daysinfield FROM sales_pers INNER JOIN ( SELECT DISTINCT sales_pers, TO_CHAR(SM.event_date,'mm') AS Event_month , TO_CHAR(SM.event_date,'MON') AS MONTH, TO_CHAR(SM.event_date,'YYYY') AS YEAR FROM strg_meet SM WHERE SM.Sales_Pers IN (SELECT Emp_Code FROM Employee START WITH Emp_Code = (SELECT emp_code FROM users WHERE code='"+loginCode+"' ) CONNECT BY Prior Emp_Code = Report_To ) AND SM.EVENT_DATE BETWEEN '"+fromDate+"' AND '"+toDate+"' ) SM ON sales_pers.sales_pers = SM.sales_pers INNER JOIN (SELECT DISTINCT(ABMCODE) AS ABMCODE,ZONE FROM vw_SALES_HIER ) H ON SM.SALES_PERS = H.ABMCODE INNER JOIN users ON users.emp_code = SM.SALES_PERS INNER JOIN vw_flm_qtq_teamwise ON vw_flm_qtq_teamwise.sales_pers = SM.SALES_PERS AND vw_flm_qtq_teamwise.month = sm.Event_month AND vw_flm_qtq_teamwise.year = sm.YEAR WHERE users.profile_id = 'FLM1' GROUP BY H.ZONE, sm.Event_month, sm.MONTH"; //sql = "SELECT H.ZONE, SM.YEAR, SM.EVENT_MONTH, SM.MONTH, SUM(FN_RCOACHING_SP_NEW(SM.SALES_PERS,SM.MONTH,SM.YEAR,'REP')) AS MONTHLY_COUNT, SUM(vw_flm_qtq_teamwise.availdaysinfield) AS AVAILDAYSINFIELD, SUM(vw_flm_qtq_teamwise.daysinfield) AS DAYSINFIELD FROM sales_pers INNER JOIN ( SELECT DISTINCT sales_pers, TO_CHAR(SM.event_date,'mm') AS Event_month , TO_CHAR(SM.event_date,'MON') AS MONTH, TO_CHAR(SM.event_date,'YYYY') AS YEAR FROM strg_meet SM WHERE SM.Sales_Pers IN (SELECT Emp_Code FROM Employee START WITH Emp_Code = (SELECT emp_code FROM users WHERE code='"+loginCode+"' ) CONNECT BY Prior Emp_Code = Report_To ) AND SM.EVENT_DATE BETWEEN '"+fromDate+"' AND '"+toDate+"' ) SM ON sales_pers.sales_pers = SM.sales_pers INNER JOIN (SELECT DISTINCT(ABMCODE) AS ABMCODE,ZONE FROM vw_SALES_HIER ) H ON SM.SALES_PERS = H.ABMCODE INNER JOIN users ON users.emp_code = SM.SALES_PERS INNER JOIN vw_flm_qtq_teamwise ON vw_flm_qtq_teamwise.sales_pers = SM.SALES_PERS AND vw_flm_qtq_teamwise.month = sm.Event_month AND vw_flm_qtq_teamwise.year = sm.YEAR WHERE users.profile_id = 'FLM1' GROUP BY H.ZONE, SM.YEAR, SM.EVENT_MONTH, SM.MONTH ORDER BY H.ZONE, SM.YEAR, SM.EVENT_MONTH, SM.MONTH";
sql = "SELECT H.ZONE, SM.YEAR, SM.EVENT_MONTH, SM.MONTH, SUM(FN_SP_CNT_NEW_MT(SM.SALES_PERS,SM.MONTH,SM.YEAR,'REP')) AS MONTHLY_COUNT, SUM(vw_flm_qtq_teamwise.availdaysinfield) AS AVAILDAYSINFIELD, SUM(vw_flm_qtq_teamwise.daysinfield) AS DAYSINFIELD FROM sales_pers INNER JOIN ( SELECT DISTINCT sales_pers, TO_CHAR(SM.event_date,'mm') AS Event_month , TO_CHAR(SM.event_date,'MON') AS MONTH, TO_CHAR(SM.event_date,'YYYY') AS YEAR FROM strg_meet SM WHERE SM.Sales_Pers IN (SELECT Emp_Code FROM Employee START WITH Emp_Code = (SELECT emp_code FROM users WHERE code='"+loginCode+"' ) CONNECT BY Prior Emp_Code = Report_To ) AND SM.EVENT_DATE BETWEEN '"+fromDate+"' AND '"+toDate+"' ) SM ON sales_pers.sales_pers = SM.sales_pers INNER JOIN (SELECT DISTINCT(ABMCODE) AS ABMCODE,ZONE FROM vw_SALES_HIER ) H ON SM.SALES_PERS = H.ABMCODE INNER JOIN users ON users.emp_code = SM.SALES_PERS INNER JOIN vw_flm_qtq_teamwise ON vw_flm_qtq_teamwise.sales_pers = SM.SALES_PERS AND vw_flm_qtq_teamwise.month = sm.Event_month AND vw_flm_qtq_teamwise.year = sm.YEAR WHERE users.profile_id = 'FLM1' GROUP BY H.ZONE, SM.YEAR, SM.EVENT_MONTH, SM.MONTH ORDER BY H.ZONE, SM.YEAR, SM.EVENT_MONTH, SM.MONTH";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -86,9 +87,9 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi ...@@ -86,9 +87,9 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi
{ {
String zoneName = checkNull(rs.getString("ZONE")); String zoneName = checkNull(rs.getString("ZONE"));
String monthName = checkNull(rs.getString("MONTH")); String monthName = checkNull(rs.getString("MONTH"));
String monthlyCount = checkDouble(rs.getString("monthly_count")); String monthlyCount = checkDouble(rs.getString("MONTHLY_COUNT"));
String avlDayInField = checkDouble(rs.getString("availdaysinfield")); String avlDayInField = checkDouble(rs.getString("AVAILDAYSINFIELD"));
String daysInField = checkDouble(rs.getString("daysinfield")); String daysInField = checkDouble(rs.getString("DAYSINFIELD"));
String coachDaysPerc = getCoachingDaysPerc(avlDayInField,daysInField,df); String coachDaysPerc = getCoachingDaysPerc(avlDayInField,daysInField,df);
if (ytdDataMap.containsKey(zoneName)) if (ytdDataMap.containsKey(zoneName))
...@@ -139,44 +140,55 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi ...@@ -139,44 +140,55 @@ public class ZonewiseCoachingDays extends ValidatorEJB implements ZonewiseCoachi
zoneValueBuffer.append("<td align='right' width='7%' style='padding-right: 5px;'>"+monthlyCount+"</td>"+"<td width='7%' style = 'padding-left: 0px;'>"+getcolorDotFromValue(Double.parseDouble(coachDaysPerc),df)+"</td>"); zoneValueBuffer.append("<td align='right' width='7%' style='padding-right: 5px;'>"+monthlyCount+"</td>"+"<td width='7%' style = 'padding-left: 0px;'>"+getcolorDotFromValue(Double.parseDouble(coachDaysPerc),df)+"</td>");
zonewiseDataMap.put(zoneName, zoneValueBuffer); zonewiseDataMap.put(zoneName, zoneValueBuffer);
} }
noOfRows++;
} }
finalBuffer.append("<tr><td class='cardSalesPersonTitlehtml' rowspan = '2' width='15%'>ZONE</td>"+monthBuffer.toString()+" <td class='cardSalesPersonTitlehtml' align='center' width='14%' colspan = '2'>"+"YTD "+"' "+ytdYear+"</td></tr>"); if(noOfRows > 0){
finalBuffer.append("<tr>"+headingBuffer.toString()+coachDayAndTimeHeading+"</tr>");
for (String key : zonewiseDataMap.keySet())
{
double ytdArr[] = ytdDataMap.get(key);
double ytdSum = ytdArr[0];
double ytdSumPerc = ytdArr[1];
String ytdAvg = df.format((ytdSum)/monthDataMap.size());
//String ytdPercAvg = df.format((ytdSumPerc)/monthDataMap.size());
String ytdPercAvg = getcolorDotFromValue((ytdSumPerc)/monthDataMap.size(),df);
finalBuffer.append("<tr><td class='cardSalesPersonTitlehtml' width='15%'>"+key+"</td>"+zonewiseDataMap.get(key).toString()+"<td align='right' width='7%' style='padding-right: 5px;'>"+ytdAvg+"</td><td width='7%'style = 'padding-left: 0px;'>"+ytdPercAvg+"</td></tr>"); finalBuffer.append("<tr><td class='cardSalesPersonTitlehtml' rowspan = '2' width='15%'>ZONE</td>"+monthBuffer.toString()+" <td class='cardSalesPersonTitlehtml' align='center' width='14%' colspan = '2'>"+"YTD "+"' "+ytdYear+"</td></tr>");
} finalBuffer.append("<tr>"+headingBuffer.toString()+coachDayAndTimeHeading+"</tr>");
monthAvgValBuffer = new StringBuffer(); for (String key : zonewiseDataMap.keySet())
for (String key : monthDataMap.keySet()) {
{ double ytdArr[] = ytdDataMap.get(key);
double monthAvgArr[] = monthDataMap.get(key); double ytdSum = ytdArr[0];
double monthSum = monthAvgArr[0]; double ytdSumPerc = ytdArr[1];
double monthSumPerc = monthAvgArr[1]; String ytdAvg = df.format((ytdSum)/monthDataMap.size());
String monthAvg = df.format((monthSum)/zonewiseDataMap.size()); String ytdPercAvg = getcolorDotFromValue((ytdSumPerc)/monthDataMap.size(),df);
String monthPercAvg = df.format((monthSumPerc)/zonewiseDataMap.size());
allIndiaYtdSum = allIndiaYtdSum + Double.parseDouble(monthAvg); finalBuffer.append("<tr><td class='cardSalesPersonTitlehtml' width='15%'>"+key+"</td>"+zonewiseDataMap.get(key).toString()+"<td align='right' width='7%' style='padding-right: 5px;'>"+ytdAvg+"</td><td width='7%'style = 'padding-left: 0px;'>"+ytdPercAvg+"</td></tr>");
allIndiaYtdPercSum = allIndiaYtdPercSum + Double.parseDouble(monthPercAvg); }
monthAvgValBuffer.append("<td class='cardHtmlTableBodyAlignRgt' width='7%' background-color='antiquewhite' style='padding-right: 5px;'>"+monthAvg+"</td><td width='7%'style = 'padding-left: 0px;'>"+getcolorDotFromValue(Double.parseDouble(monthPercAvg),df)+"</td>");
} monthAvgValBuffer = new StringBuffer();
for (String key : monthDataMap.keySet())
{
double monthAvgArr[] = monthDataMap.get(key);
double monthSum = monthAvgArr[0];
double monthSumPerc = monthAvgArr[1];
String monthAvg = df.format((monthSum)/zonewiseDataMap.size());
String monthPercAvg = df.format((monthSumPerc)/zonewiseDataMap.size());
allIndiaYtdSum = allIndiaYtdSum + Double.parseDouble(monthAvg);
allIndiaYtdPercSum = allIndiaYtdPercSum + Double.parseDouble(monthPercAvg);
monthAvgValBuffer.append("<td class='cardHtmlTableBodyAlignRgt' width='7%' background-color='antiquewhite' style='padding-right: 5px;'>"+monthAvg+"</td><td width='7%'style = 'padding-left: 0px;'>"+getcolorDotFromValue(Double.parseDouble(monthPercAvg),df)+"</td>");
}
finalBuffer.append("<tr><td class='cardSalesPersonTitlehtml' width='15%'>ALL INDIA</td>"+monthAvgValBuffer.toString()+"<td class='cardHtmlTableBodyAlignRgt' width='7%' style='padding-right: 5px;'>"+df.format(allIndiaYtdSum/monthDataMap.size())+"</td><td width='7%' style = 'padding-left: 0px;'>"+getcolorDotFromValue(allIndiaYtdPercSum/monthDataMap.size(),df)+"</td></tr>");
finalBuffer.append("<tr><td class='cardSalesPersonTitlehtml' width='15%'>ALL INDIA</td>"+monthAvgValBuffer.toString()+"<td class='cardHtmlTableBodyAlignRgt' width='7%' style='padding-right: 5px;'>"+df.format(allIndiaYtdSum/monthDataMap.size())+"</td><td width='7%' style = 'padding-left: 0px;'>"+getcolorDotFromValue(allIndiaYtdPercSum/monthDataMap.size(),df)+"</td></tr>"); rowData = new JSONObject();
rowDataZonewiseCoachingJson = new JSONObject();
rowData = new JSONObject(); rowData.put("coachingDays", "<table cellpadding = '5' border= '1' class = 'mt' id='htmlTable' width = '105%'> <tbody> <tr> <td colspan = '27' width = '100%' align = 'center' class='cardSalesPersonTitle'> % COACHING CALL REPORT DETAIL </td> </tr> "+finalBuffer.toString()+" </tbody> </table>");
rowDataZonewiseCoachingJson = new JSONObject(); rowData.put("exportToExcel", CommonConstants.TOMCAT_HOME+"/ibase/dwh/FusionChart/images/excel.png");
rowData.put("coachingDays", finalBuffer.toString()); rowDataZonewiseCoachingJson.put(count, rowData);
rowData.put("exportToExcel", CommonConstants.TOMCAT_HOME+"/ibase/dwh/FusionChart/images/excel.png"); count++;
rowDataZonewiseCoachingJson.put(count, rowData); }
count++; else{
rowData = new JSONObject();
rowDataZonewiseCoachingJson = new JSONObject();
rowData.put("coachingDays", "<table cellpadding = '5' width = '100%'> <tbody> <tr> <td width = '100%' align = 'center'>No Data to Display</td> </tr> </tbody> </table>");
rowData.put("exportToExcel", CommonConstants.TOMCAT_HOME+"/ibase/dwh/FusionChart/images/excel.png");
rowDataZonewiseCoachingJson.put(count, rowData);
count++;
}
}catch (Exception e) }catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
......
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