Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1) Added API to get count of Beneficiaries to be synced from server to App so that progress bar can be implemented. #7

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,32 @@ public class IdentityController {
return response;
}

// search beneficiary by lastModDate and districtID
@CrossOrigin(origins = { "*commonapi*" })
@ApiOperation(value ="Get count of beneficiary by villageId and last modified date-time")
@PostMapping(path = "/countBenByVillageIdAndLastModifiedDate")
public @ResponseBody String countBeneficiaryByVillageIdAndLastModDate(
@ApiParam(value = "\"String\"") @RequestBody String object) {
logger.info("IdentityController.getBeneficiaryCount- start. search object = " + object);
String response;
try {

JsonElement json = new JsonParser().parse(object);

SearchSyncDTO search = InputMapper.getInstance().gson().fromJson(json, SearchSyncDTO.class);
Long beneficiaryCount = svc.countBeneficiaryByVillageIdAndLastModifyDate(search.getVillageID(), new Timestamp(search.getLastModifiedDate()));

response = getSuccessResponseString(String.valueOf(beneficiaryCount), 200, "success", "getIdentityCountByVillageAndLastSyncTime");

logger.info("IdentityController.getBeneficiaryCount - end");
} catch (Exception e) {
logger.error("error in getting beneficiary count by village Ids and last sync date : " + e.getLocalizedMessage());
response = getErrorResponseString("error in getting beneficiary count by village Ids and last sync date : " + e.getLocalizedMessage(),
5000, "failure", "");
}
return response;
}

@CrossOrigin(origins = { "*commonapi*" })
@ApiOperation(value = "Search beneficiary based on government identity number")
@PostMapping(path = "/searhByGovIdentity", headers = "Authorization")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,9 @@ public List<Object[]> getBenMappingByVanSerialNo(@Param("benMapIds") BigInteger
+ "or m.mBeneficiarydetail.lastModDate > :lastModDate ) order by m.benMapId Desc")
List<MBeneficiarymapping> findByBeneficiaryDetailsByVillageIDAndLastModifyDate(@Param("villageIDs") List<Integer> villageID, @Param("lastModDate") Timestamp lastModifiedDate);

@Query(value = "select COUNT(m) from MBeneficiarymapping m where m.mBeneficiaryaddress.permVillageId IN :villageIDs and "
+ "(m.mBeneficiaryaddress.lastModDate > :lastModDate or m.mBeneficiarycontact.lastModDate > :lastModDate "
+ "or m.mBeneficiarydetail.lastModDate > :lastModDate ) order by m.benMapId Desc")
Long getBeneficiaryCountsByVillageIDAndLastModifyDate(@Param("villageIDs") List<Integer> villageID, @Param("lastModDate") Timestamp lastModifiedDate);

}
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,20 @@ public List<BeneficiariesDTO> searchBeneficiaryByVillageIdAndLastModifyDate(List
return beneficiaryList;
}

public Long countBeneficiaryByVillageIdAndLastModifyDate(List<Integer> villageIDs, Timestamp lastModifiedDate) {

Long beneficiaryCount= 0L;
try {
// find benmap ids
beneficiaryCount = mappingRepo.getBeneficiaryCountsByVillageIDAndLastModifyDate(villageIDs, lastModifiedDate);

} catch (Exception e) {
logger.error(
"error in getting beneficiary count to sync to CHO App with villageIDs: " + villageIDs + " error : " + e.getLocalizedMessage());
}
return beneficiaryCount;
}

public List<BeneficiariesDTO> searhBeneficiaryByGovIdentity(String identity)
throws NoResultException, QueryTimeoutException, Exception {
List<BeneficiariesDTO> beneficiaryList = new ArrayList<BeneficiariesDTO>();
Expand Down
Loading