@@ -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
0 commit comments