Skip to content

Commit ed48d7b

Browse files
authored
Merge pull request #7 from motech-implementations/new_kilkari_report_and_ma_cumulative_changes
New report for kilkari calls with total beneficiaries and changes req…
2 parents ad758bb + 7f64a71 commit ed48d7b

File tree

10 files changed

+570
-92
lines changed

10 files changed

+570
-92
lines changed

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/business/AggregateKilkariReportsService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ public interface AggregateKilkariReportsService {
3232
AggregateKilkariRepeatListenerMonthWiseDto getKilkariRepeatListenerMonthWiseReport(ReportRequest reportRequest);
3333

3434
List<KilkariCallReportDto> getKilkariCallReport(ReportRequest reportRequest, User currentUser);
35+
36+
List<KilkariCallReportWithBeneficiariesDto> getKilkariCallReportWithBeneficiaries(ReportRequest reportRequest, User currentUser);
3537
}
3638

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/business/impl/AggregateKilkariReportsServiceImpl.java

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,122 @@ public List<KilkariCallReportDto> getKilkariCallReport(ReportRequest reportReque
24992499
}
25002500
return callReportDtos;
25012501
}
2502+
@Override
2503+
public List<KilkariCallReportWithBeneficiariesDto> getKilkariCallReportWithBeneficiaries(ReportRequest reportRequest, User currentUser) {
2504+
2505+
DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
2506+
Calendar calendar = Calendar.getInstance();
2507+
Date toDate = new Date();
2508+
Date startDate = new Date(0);
2509+
Calendar aCalendar = Calendar.getInstance();
2510+
aCalendar.setTime(reportRequest.getFromDate());
2511+
aCalendar.set(Calendar.MILLISECOND, 0);
2512+
aCalendar.set(Calendar.SECOND, 0);
2513+
aCalendar.set(Calendar.MINUTE, 0);
2514+
aCalendar.set(Calendar.HOUR_OF_DAY, 0);
2515+
2516+
2517+
//aCalendar.add(Calendar.DATE, -1);
2518+
Date fromDate = aCalendar.getTime();
2519+
aCalendar.setTime(reportRequest.getToDate());
2520+
aCalendar.set(Calendar.MILLISECOND, 0);
2521+
aCalendar.set(Calendar.SECOND, 0);
2522+
aCalendar.set(Calendar.MINUTE, 0);
2523+
aCalendar.set(Calendar.HOUR_OF_DAY, 0);
2524+
aCalendar.add(Calendar.DATE, 1);
2525+
toDate = aCalendar.getTime();
2526+
2527+
List<KilkariCallReportWithBeneficiariesDto> callReportWithBeneficiariesDtos = new ArrayList<>();
2528+
List<KilkariCalls> kilkariCallStart = new ArrayList<>();
2529+
List<KilkariCalls> kilkariCallEnd = new ArrayList<>();
2530+
List<KilkariMessageListenership> kilkariMessageListenerships = new ArrayList<>();
2531+
2532+
if (reportRequest.getStateId() == 0) {
2533+
kilkariCallStart.addAll(this.getKilkariCallReport(0, "State", fromDate));
2534+
kilkariCallEnd.addAll(this.getKilkariCallReport(0, "State", toDate));
2535+
kilkariMessageListenerships.addAll(this.getKilkariMessageListenershipData(0, "State", fromDate, toDate, reportRequest.getPeriodType()));
2536+
} else if (reportRequest.getDistrictId() == 0) {
2537+
kilkariCallStart.addAll(this.getKilkariCallReport(reportRequest.getStateId(), "District", fromDate));
2538+
kilkariCallEnd.addAll(this.getKilkariCallReport(reportRequest.getStateId(), "District", toDate));
2539+
kilkariMessageListenerships.addAll(this.getKilkariMessageListenershipData(reportRequest.getStateId(), "District", fromDate, toDate, reportRequest.getPeriodType()));
2540+
} else if (reportRequest.getBlockId() == 0) {
2541+
kilkariCallStart.addAll(this.getKilkariCallReport(reportRequest.getDistrictId(), "Block", fromDate));
2542+
kilkariCallEnd.addAll(this.getKilkariCallReport(reportRequest.getDistrictId(), "Block", toDate));
2543+
kilkariMessageListenerships.addAll(this.getKilkariMessageListenershipData(reportRequest.getDistrictId(), "Block", fromDate, toDate, reportRequest.getPeriodType()));
2544+
} else {
2545+
kilkariCallStart.addAll(this.getKilkariCallReport(reportRequest.getBlockId(), "Subcentre", fromDate));
2546+
kilkariCallEnd.addAll(this.getKilkariCallReport(reportRequest.getBlockId(), "Subcentre", toDate));
2547+
kilkariMessageListenerships.addAll(this.getKilkariMessageListenershipData(reportRequest.getBlockId(), "Subcentre", fromDate, toDate, reportRequest.getPeriodType()));
2548+
}
2549+
2550+
if (!(kilkariCallEnd.isEmpty()) && !(kilkariCallStart.isEmpty()) && !(kilkariMessageListenerships.isEmpty())) {
2551+
for(int k = 0; k < kilkariMessageListenerships.size(); k++) {
2552+
for (int i = 0; i < kilkariCallEnd.size(); i++) {
2553+
for (int j = 0; j < kilkariCallStart.size(); j++) {
2554+
if (kilkariCallEnd.get(i).getLocationId().equals(kilkariCallStart.get(j).getLocationId()) &&
2555+
kilkariCallStart.get(j).getLocationId().equals(kilkariMessageListenerships.get(k).getLocationId())) {
2556+
KilkariCalls end = kilkariCallEnd.get(i);
2557+
KilkariCalls start = kilkariCallStart.get(j);
2558+
KilkariMessageListenership kml = kilkariMessageListenerships.get(k);
2559+
KilkariCallReportWithBeneficiariesDto kilkariCallReportWithBeneficiariesDto = new KilkariCallReportWithBeneficiariesDto();
2560+
kilkariCallReportWithBeneficiariesDto.setLocationId(end.getLocationId());
2561+
kilkariCallReportWithBeneficiariesDto.setContent_1_25(end.getContent_1_25() - start.getContent_1_25());
2562+
kilkariCallReportWithBeneficiariesDto.setContent_75_100(end.getContent_75_100() - start.getContent_75_100());
2563+
kilkariCallReportWithBeneficiariesDto.setBillableMinutes(end.getBillableMinutes() - start.getBillableMinutes());
2564+
kilkariCallReportWithBeneficiariesDto.setCallsAttempted(end.getCallsAttempted() - start.getCallsAttempted());
2565+
kilkariCallReportWithBeneficiariesDto.setCallsToInbox(end.getCallsToInbox() - start.getCallsToInbox());
2566+
kilkariCallReportWithBeneficiariesDto.setSuccessfulCalls(end.getSuccessfulCalls() - start.getSuccessfulCalls());
2567+
kilkariCallReportWithBeneficiariesDto.setAvgDuration((float)((kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls()==0)?0.00 : (float) Math.round( kilkariCallReportWithBeneficiariesDto.getBillableMinutes() / (float) kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls() * 100) / 100));
2568+
kilkariCallReportWithBeneficiariesDto.setLocationType(end.getLocationType());
2569+
kilkariCallReportWithBeneficiariesDto.setBeneficiariesCalled(kml.getTotalBeneficiariesCalled());
2570+
kilkariCallReportWithBeneficiariesDto.setPercentageCalls_1_25((float) (kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls() == 0 ? 0 : (Math.round((kilkariCallReportWithBeneficiariesDto.getContent_1_25() * 10000.0f/ kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls())))) / 100f);
2571+
kilkariCallReportWithBeneficiariesDto.setPercentageCalls_75_100((float) (kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls() == 0 ? 0 : (Math.round((kilkariCallReportWithBeneficiariesDto.getContent_75_100() * 10000.0f/ kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls())))) / 100f);
2572+
kilkariCallReportWithBeneficiariesDto.setPercentageCallsResponded((float) (kilkariCallReportWithBeneficiariesDto.getCallsAttempted() == 0 ? 0 : (Math.round((kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls() * 10000.0f/ kilkariCallReportWithBeneficiariesDto.getCallsAttempted())))) / 100f);
2573+
String locationType = end.getLocationType();
2574+
if (locationType.equalsIgnoreCase("State")) {
2575+
kilkariCallReportWithBeneficiariesDto.setLocationName(stateDao.findByStateId(end.getLocationId().intValue()).getStateName());
2576+
}
2577+
if (locationType.equalsIgnoreCase("District")) {
2578+
kilkariCallReportWithBeneficiariesDto.setLocationName(districtDao.findByDistrictId(end.getLocationId().intValue()).getDistrictName());
2579+
}
2580+
if (locationType.equalsIgnoreCase("Block")) {
2581+
kilkariCallReportWithBeneficiariesDto.setLocationName(blockDao.findByblockId(end.getLocationId().intValue()).getBlockName());
2582+
}
2583+
if (locationType.equalsIgnoreCase("Subcentre")) {
2584+
kilkariCallReportWithBeneficiariesDto.setLocationName(healthSubFacilityDao.findByHealthSubFacilityId(end.getLocationId().intValue()).getHealthSubFacilityName());
2585+
kilkariCallReportWithBeneficiariesDto.setLink(true);
2586+
}
2587+
if (locationType.equalsIgnoreCase("DifferenceState")) {
2588+
kilkariCallReportWithBeneficiariesDto.setLocationName("No District Count");
2589+
kilkariCallReportWithBeneficiariesDto.setLink(true);
2590+
kilkariCallReportWithBeneficiariesDto.setLocationId((long) -1);
2591+
}
2592+
if (locationType.equalsIgnoreCase("DifferenceDistrict")) {
2593+
kilkariCallReportWithBeneficiariesDto.setLocationName("No Block Count");
2594+
kilkariCallReportWithBeneficiariesDto.setLink(true);
2595+
kilkariCallReportWithBeneficiariesDto.setLocationId((long) -1);
2596+
2597+
}
2598+
if (locationType.equalsIgnoreCase("DifferenceBlock")) {
2599+
kilkariCallReportWithBeneficiariesDto.setLocationName("No Subcentre Count");
2600+
kilkariCallReportWithBeneficiariesDto.setLink(true);
2601+
kilkariCallReportWithBeneficiariesDto.setLocationId((long) -1);
2602+
2603+
}
2604+
2605+
if ((kilkariCallReportWithBeneficiariesDto.getSuccessfulCalls() + Math.round(kilkariCallReportWithBeneficiariesDto.getBillableMinutes()*100) + kilkariCallReportWithBeneficiariesDto.getCallsAttempted()
2606+
+ kilkariCallReportWithBeneficiariesDto.getCallsToInbox() + kilkariCallReportWithBeneficiariesDto.getContent_1_25()
2607+
+ kilkariCallReportWithBeneficiariesDto.getContent_75_100()) != 0 && !locationType.equalsIgnoreCase("DifferenceState")) {
2608+
callReportWithBeneficiariesDtos.add(kilkariCallReportWithBeneficiariesDto);
2609+
}
2610+
}
2611+
}
2612+
}
2613+
}
2614+
2615+
}
2616+
return callReportWithBeneficiariesDtos;
2617+
}
25022618

25032619

25042620

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/business/impl/AggregateReportsServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ public void createSpecificAggreagateExcel(XSSFWorkbook workbook, AggregateExcelD
657657
// gridData.getReportName().equalsIgnoreCase("Kilkari Message Matrix")||
658658
// gridData.getReportName().equalsIgnoreCase("Kilkari Repeat Listener Month Wise")||
659659
// gridData.getReportName().equalsIgnoreCase("Kilkari Cumulative Summary")||
660-
// gridData.getReportName().equalsIgnoreCase("MA Cumulative Summary")){
660+
// gridData.getReportName().equalsIgnoreCase("District-wise Performance of the State for Mobile Academy")){
661661
spreadsheet.autoSizeColumn(1);
662662
// }
663663

@@ -886,7 +886,7 @@ public void createSpecificAggreagatePdf(PDDocument document, AggregateExcelDto g
886886
float tableFont = 7;
887887
//contents.close();
888888

889-
if (gridData.getReportName().equalsIgnoreCase("MA Cumulative Summary") || gridData.getReportName().equalsIgnoreCase("Kilkari Repeat Listener Month Wise")) {
889+
if (gridData.getReportName().equalsIgnoreCase("District-wise Performance of the State for Mobile Academy") || gridData.getReportName().equalsIgnoreCase("Kilkari Repeat Listener Month Wise")) {
890890
cellWidth = 10f;
891891
tableMargin = 60;
892892
tableFont = 7;

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/controller/UserController.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,13 @@ public Object getReport(@RequestBody ReportRequest reportRequest/*,HttpServletRe
650650
return aggregateResponseDto;
651651
}
652652

653+
if (reportRequest.getReportType().equals(ReportType.kilkariCallsWithBeneficiaries.getReportType())) {
654+
aggregateResponseDto.setBreadCrumbData(breadCrumbs);
655+
List<KilkariCallReportWithBeneficiariesDto> kilkariCallReportWithBeneficiariesDtos = aggregateKilkariReportsService.getKilkariCallReportWithBeneficiaries(reportRequest, currentUser);
656+
aggregateResponseDto.setTableData(kilkariCallReportWithBeneficiariesDtos);
657+
return aggregateResponseDto;
658+
}
659+
653660
if (reportRequest.getReportType().equals(ReportType.maPerformance.getReportType())) {
654661

655662
Date fromDate = dateAdder(reportRequest.getFromDate(),0);
@@ -889,9 +896,10 @@ public Object getReport(@RequestBody ReportRequest reportRequest/*,HttpServletRe
889896
summaryDto1.setAshasNotStarted(a.getAshasNotStarted());
890897
summaryDto1.setAshasStarted(a.getAshasStarted());
891898
summaryDto1.setLocationType(a.getLocationType());
892-
summaryDto1.setCompletedPercentage((float) (a.getAshasStarted() == 0 ? 0 : (Math.round((a.getAshasCompleted() * 10000.0f/ a.getAshasStarted())))) / 100f);
893-
summaryDto1.setFailedpercentage((float) (a.getAshasStarted() == 0 ? 0 : (Math.round((a.getAshasFailed() * 10000.0f / a.getAshasStarted())))) / 100f);
899+
summaryDto1.setCompletedPercentage((float) (a.getAshasRegistered() == 0 ? 0 : (Math.round((a.getAshasCompleted() * 10000.0f/ a.getAshasRegistered())))) / 100f);
900+
summaryDto1.setFailedpercentage((float) (a.getAshasRegistered() == 0 ? 0 : (Math.round((a.getAshasFailed() * 10000.0f / a.getAshasRegistered())))) / 100f);
894901
summaryDto1.setNotStartedpercentage((float) (a.getAshasRegistered() == 0 ? 0 : (Math.round((a.getAshasNotStarted() * 10000.0f / a.getAshasRegistered())))) / 100f);
902+
summaryDto1.setStartedPercentage((float) (a.getAshasRegistered() == 0 ? 0 : (Math.round((a.getAshasStarted() * 10000.0f / a.getAshasRegistered())))) / 100f);
895903
String locationType = a.getLocationType();
896904
if (locationType.equalsIgnoreCase("State")) {
897905
summaryDto1.setLocationName(stateDao.findByStateId(a.getLocationId().intValue()).getStateName());
@@ -1304,7 +1312,13 @@ public String downloadpdf1(HttpServletResponse response, @DefaultValue("") @Quer
13041312
"images/drop-down-2.png",
13051313
ReportType.kilkariCalls.getServiceType(),showAggregateReports)
13061314
);
1307-
1315+
kList.add(new Report(
1316+
ReportType.kilkariCallsWithBeneficiaries.getReportName(),
1317+
ReportType.kilkariCallsWithBeneficiaries.getReportType(),
1318+
ReportType.kilkariCallsWithBeneficiaries.getSimpleName(),
1319+
"images/drop-down-2.png",
1320+
ReportType.kilkariCallsWithBeneficiaries.getServiceType(),showAggregateReports)
1321+
);
13081322
kList.add(new Report(
13091323
ReportType.messageMatrix.getReportName(),
13101324
ReportType.messageMatrix.getReportType(),

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/entity/AggregateCumulativeMADto.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class AggregateCumulativeMADto {
2020
float notStartedpercentage;
2121
float completedPercentage;
2222
float failedpercentage;
23+
float startedPercentage;
2324
private boolean link = false;
2425

2526
public Integer getRecordsReceived() {
@@ -138,6 +139,14 @@ public boolean isLink() {
138139
return link;
139140
}
140141

142+
public float getStartedPercentage() {
143+
return startedPercentage;
144+
}
145+
146+
public void setStartedPercentage(float startedPercentage) {
147+
this.startedPercentage = startedPercentage;
148+
}
149+
141150
public void setLink(boolean link) {
142151
this.link = link;
143152
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package com.beehyv.nmsreporting.entity;
2+
3+
public class KilkariCallReportWithBeneficiariesDto {
4+
private String locationType;
5+
private String locationName;
6+
private Long locationId;
7+
private Long callsAttempted;
8+
private Long content_75_100;
9+
private Long content_1_25;
10+
private Long successfulCalls;
11+
private Double billableMinutes;
12+
private Long callsToInbox;
13+
private Float avgDuration;
14+
private Long beneficiariesCalled;
15+
private float percentageCalls_75_100;
16+
private float percentageCalls_1_25;
17+
private float percentageCallsResponded;
18+
private boolean link =false;
19+
20+
public String getLocationType() {
21+
return locationType;
22+
}
23+
24+
public void setLocationType(String locationType) {
25+
this.locationType = locationType;
26+
}
27+
28+
public String getLocationName() {
29+
return locationName;
30+
}
31+
32+
public void setLocationName(String locationName) {
33+
this.locationName = locationName;
34+
}
35+
36+
public Long getLocationId() {
37+
return locationId;
38+
}
39+
40+
public void setLocationId(Long locationId) {
41+
this.locationId = locationId;
42+
}
43+
44+
public Long getCallsAttempted() {
45+
return callsAttempted;
46+
}
47+
48+
public void setCallsAttempted(Long callsAttempted) {
49+
this.callsAttempted = callsAttempted;
50+
}
51+
52+
public Long getContent_75_100() {
53+
return content_75_100;
54+
}
55+
56+
public void setContent_75_100(Long content_75_100) {
57+
this.content_75_100 = content_75_100;
58+
}
59+
60+
public Long getContent_1_25() {
61+
return content_1_25;
62+
}
63+
64+
public void setContent_1_25(Long content_1_25) {
65+
this.content_1_25 = content_1_25;
66+
}
67+
68+
public Long getSuccessfulCalls() {
69+
return successfulCalls;
70+
}
71+
72+
public void setSuccessfulCalls(Long successfulCalls) {
73+
this.successfulCalls = successfulCalls;
74+
}
75+
76+
public Double getBillableMinutes() {
77+
return billableMinutes;
78+
}
79+
80+
public void setBillableMinutes(Double billableMinutes) {
81+
this.billableMinutes = billableMinutes;
82+
}
83+
84+
public Long getCallsToInbox() {
85+
return callsToInbox;
86+
}
87+
88+
public void setCallsToInbox(Long callsToInbox) {
89+
this.callsToInbox = callsToInbox;
90+
}
91+
92+
public Float getAvgDuration() {
93+
return avgDuration;
94+
}
95+
96+
public void setAvgDuration(Float avgDuration) {
97+
this.avgDuration = avgDuration;
98+
}
99+
100+
public Long getBeneficiariesCalled() {
101+
return beneficiariesCalled;
102+
}
103+
104+
public void setBeneficiariesCalled(Long beneficiariesCalled) {
105+
this.beneficiariesCalled = beneficiariesCalled;
106+
}
107+
108+
public float getPercentageCalls_75_100() {
109+
return percentageCalls_75_100;
110+
}
111+
112+
public void setPercentageCalls_75_100(float percentageCalls_75_100) {
113+
this.percentageCalls_75_100 = percentageCalls_75_100;
114+
}
115+
116+
public float getPercentageCalls_1_25() {
117+
return percentageCalls_1_25;
118+
}
119+
120+
public void setPercentageCalls_1_25(float percentageCalls_1_25) {
121+
this.percentageCalls_1_25 = percentageCalls_1_25;
122+
}
123+
124+
public float getPercentageCallsResponded() {
125+
return percentageCallsResponded;
126+
}
127+
128+
public void setPercentageCallsResponded(float percentageCallsResponded) {
129+
this.percentageCallsResponded = percentageCallsResponded;
130+
}
131+
132+
public boolean isLink() {
133+
return link;
134+
}
135+
136+
public void setLink(boolean link) {
137+
this.link = link;
138+
}
139+
}

0 commit comments

Comments
 (0)