Skip to content

Commit 9b14482

Browse files
committed
cumulative beneficiary fix.
1 parent 3c33e04 commit 9b14482

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public class UserController {
128128
@Autowired
129129
private DownloadReportActivityService downloadReportActivityService;
130130

131+
@Autowired
132+
private KilkariCallReportDao kilkariCallReportDao;
133+
131134
private final CacheManager cacheManager = CacheManager.create();
132135
private final Cache etlNotificationCache = cacheManager.getCache("etlNotificationCache");
133136

@@ -1440,7 +1443,7 @@ public ResponseEntity<Long> getCumulativeBeneficiaries(){
14401443
}
14411444

14421445

1443-
Long cumulativeJoinedSubscription = aggregateCumulativeBeneficiaryDao.getCumulativeJoinedSubscription(locationId, locationType, toDate);
1446+
Long cumulativeJoinedSubscription = kilkariCallReportDao.getCumulativeJoinedSubscription(locationId, locationType, toDate);
14441447
return ResponseEntity.ok(cumulativeJoinedSubscription);
14451448
// Long ashaStarted = 0L;
14461449
// Long ashaCompleted = 0L;

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/dao/AggregateCumulativeBeneficiaryDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,4 @@ public interface AggregateCumulativeBeneficiaryDao {
2424
Map<Integer,Long> getTotalDeactivationSum(List<Integer> locationId, String locationType, Date fromDate, Date toDate, String periodType);
2525

2626
Long getJoinedSubscriptionSumTillDate(Integer locationId, String locationType, Date toDate);
27-
28-
Long getCumulativeJoinedSubscription(Long locationId, String locationType, Date toDate);
2927
}

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/dao/KilkariCallReportDao.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
*/
1010
public interface KilkariCallReportDao {
1111
KilkariCalls getKilkariCallreport(Integer locationId, String locationType, Date toDate);
12+
13+
Long getCumulativeJoinedSubscription(Long locationId, String locationType, Date toDate);
14+
1215
}

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/dao/impl/AggregateCumulativeBeneficiaryDaoImpl.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,6 @@ public AggregateCumulativeBeneficiary getCumulativeBeneficiary(Long locationId,
5353
return aggregateCumulativeBeneficiary;
5454
}
5555

56-
public Long getCumulativeJoinedSubscription(Long locationId, String locationType, Date toDate) {
57-
String hql;
58-
Query query;
59-
60-
if (locationId == 0 && "State".equalsIgnoreCase(locationType)) {
61-
hql = "SELECT COALESCE(SUM(CAST(total_beneficiaries AS SIGNED)), 0) FROM agg_kilkari_call_report WHERE location_type = :locationType AND date = :toDate";
62-
query = getSession().createQuery(hql);
63-
query.setParameter("locationType", "State");
64-
} else {
65-
hql = "SELECT COALESCE(SUM(CAST(total_beneficiaries AS SIGNED)), 0) FROM agg_kilkari_call_report WHERE locationId = :locationId AND location_type = :locationType AND date = :toDate";
66-
query = getSession().createQuery(hql);
67-
query.setParameter("locationId", locationId);
68-
query.setParameter("locationType", locationType);
69-
}
70-
71-
query.setParameter("toDate", toDate);
72-
73-
Long result = (Long) query.uniqueResult();
74-
return result != null ? result : 0L;
75-
}
76-
77-
7856

7957

8058
@Override

NMSReportingSuite/src/main/java/com/beehyv/nmsreporting/dao/impl/KilkariCallReportDaoImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.beehyv.nmsreporting.model.KilkariCalls;
66
import org.hibernate.Criteria;
77
import org.hibernate.criterion.Order;
8+
import org.hibernate.criterion.Projections;
89
import org.hibernate.criterion.Restrictions;
910
import org.springframework.stereotype.Repository;
1011

@@ -47,5 +48,23 @@ public KilkariCalls getKilkariCallreport(Integer locationId, String locationTyp
4748
kilkariCalls.setUniqueBeneficiaries(kilkariCalls.getUniqueBeneficiaries()== null? 0 : kilkariCalls.getUniqueBeneficiaries());
4849
return kilkariCalls;
4950
}
51+
52+
@Override
53+
public Long getCumulativeJoinedSubscription(Long locationId, String locationType, Date toDate) {
54+
Criteria criteria = createEntityCriteria();
55+
56+
if (locationId == 0 && "State".equalsIgnoreCase(locationType)) {
57+
criteria.add(Restrictions.eq("locationType", locationType));
58+
} else {
59+
criteria.add(Restrictions.eq("locationId", locationId));
60+
criteria.add(Restrictions.eq("locationType", locationType));
61+
}
62+
criteria.add(Restrictions.eq("date", toDate));
63+
64+
criteria.setProjection(Projections.sum("uniqueBeneficiaries"));
65+
66+
Long result = (Long) criteria.uniqueResult();
67+
return result != null ? result : 0L;
68+
}
5069
}
5170

0 commit comments

Comments
 (0)