Commit 5d79f707 authored by sakshi gupta's avatar sakshi gupta
Browse files

percentage wise report

parent 2e26ff59
......@@ -179,5 +179,16 @@ public class ReportController {
log.debug("Inside ReportController called method getUserAssessmentReport with parameter,userId={},"
+ "startDate={},endDate={}",userId,startDate,endDate);
return reportService.getUserAssessmentReport(userId,startDate,endDate);
}
}
@RequestMapping(method=RequestMethod.GET,value="/api/admin/getPercentageWiseInfographicReport")
public ResponseEntity<Map<String, Integer>> getPercentageWiseInfographicReport (
@RequestParam(value = "startDate", required = true) String startDate,
@RequestParam(value = "endDate", required = true) String endDate,
@RequestParam(value = "assessmentId", required = true) long assessmentId,
@RequestParam(value = "subLobId") long subLobId) throws Exception{
log.debug("Inside ReportController called method getPercentageWiseInfographicReport with parameter,startDate={},endDate={},assessmentId={},subLobId={}",startDate,endDate,assessmentId,subLobId);
return reportService.getPercentageWiseInfographicReport(startDate, endDate, assessmentId,subLobId);
}
}
......@@ -74,4 +74,6 @@ public interface QuizResultRepositoryCustom {
List<DBObject> getUserAssessmentReport(Date stDate, Date enDate, String userId)throws Exception;
List<DBObject> getPercentageWiseAssessmentReport(Date stDate, Date enDate, long assessmentId, long subLobId) throws Exception;
}
......@@ -18,6 +18,7 @@ import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.aggregation.ConditionalOperators;
import org.springframework.data.mongodb.core.aggregation.ConditionalOperators.Cond;
import org.springframework.data.mongodb.core.aggregation.GroupOperation.GroupOperationBuilder;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
......@@ -827,4 +828,30 @@ AggregationOperation match = Aggregation.match(new Criteria().andOperator(Crite
return result.getMappedResults();
}
@Override
public List<DBObject> getPercentageWiseAssessmentReport(Date stDate, Date enDate, long assessmentId, long subLobId)
throws Exception {
log.debug("Inside QuizResultRepositoryImpl called getPercentageWiseAssessmentReport method, with parameter "
+ "stDate={},enDate={},assessmentId={},subLobId={}",stDate,enDate,assessmentId,subLobId);
AggregationOperation match = null;
if(subLobId>0)
{
match = Aggregation.match(new Criteria().andOperator(Criteria.where("quizDate").gte(stDate).lte(enDate),Criteria.where("questionSet.subLob._id").is(subLobId)
, Criteria.where("questionSet.assessmentId").is(assessmentId)));
}
AggregationOperation project = Aggregation.project("_id").and("quizScore").as("quizScore").and("questionSet.userId").as("userId");
AggregationOperation sort = Aggregation.sort(Sort.Direction.ASC,"_id");
AggregationOperation group=Aggregation.group("_id","quizScore").last("userId").as("userId");
Aggregation agg = Aggregation.newAggregation(match,project,sort,group);
AggregationResults<DBObject> result = template.aggregate(agg,COLLECTION,DBObject.class);
log.debug("Response returned from QuizResultRepositoryImpl--getPercentageWiseAssessmentReport method,result={}",result.getMappedResults().size());
return result.getMappedResults();
}
}
......@@ -55,4 +55,7 @@ public interface ReportService {
public ResponseEntity<Map<String,List<DBObject>>> getInfoGraphicReport (String startDate,String endDate) throws Exception;
public ResponseEntity<List<DBObject>> getUserAssessmentReport(String userId,String startDate,String endDate)throws Exception;
public ResponseEntity<Map<String, Integer>> getPercentageWiseInfographicReport(String startDate, String endDate,
long assessmentId, long subLobId)throws Exception;
}
......@@ -3,6 +3,7 @@
*/
package com.statestreet.service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
......@@ -516,4 +517,75 @@ public class ReportServiceImpl implements ReportService{
}
}
@Override
public ResponseEntity<Map<String, Integer>> getPercentageWiseInfographicReport(String startDate, String endDate,
long assessmentId, long subLobId) throws Exception {
// TODO Auto-generated method stub
log.debug("Inside ReportServiceImpl called method getPercentageWiseInfographicReport with parameter, startDate={},endDate={},assessmentId={},subLobId={}",
startDate,endDate,assessmentId,subLobId);
DATE_FORMAT.setTimeZone(CommonUtils.TIME_ZONE);
Date stDate=DATE_FORMAT.parse(startDate);
Date enDate=DATE_FORMAT.parse(endDate);
Calendar cal = Calendar.getInstance();
cal.setTime(enDate);
cal.add(Calendar.DATE,1);
enDate=DATE_FORMAT.parse(DATE_FORMAT.format(cal.getTime()));
List<DBObject> percentageWiseAssessmentReport=quizResultRepo.getPercentageWiseAssessmentReport(stDate, enDate, assessmentId,subLobId);
Integer grandTotal=0;
Map<String, Integer> hashMap = new HashMap<String,Integer>();
for(DBObject result:percentageWiseAssessmentReport) {
int score=(Integer)result.get("quizScore");
if(score>0&score<35) {
grandTotal++;
if(hashMap.containsKey("0-35")) {
hashMap.put("0-35", hashMap.get("0-35")+1) ;
}
else
hashMap.put("0-35", 1) ;
}else if(score>=36&score<=50){
grandTotal++;
if(hashMap.containsKey("36-50")) {
hashMap.put("36-50", hashMap.get("36-50")+1) ;
}
else
hashMap.put("36-50", 1) ;
}else if(score>=51&score<=70){
grandTotal++;
if(hashMap.containsKey("51-70")) {
hashMap.put("51-70", hashMap.get("51-70")+1) ;
}
else
hashMap.put("51-70", 1) ;
}else if(score>=71&score<=80){
grandTotal++;
if(hashMap.containsKey("71-80")) {
hashMap.put("71-80", hashMap.get("71-80")+1) ;
}
else
hashMap.put("71-80", 1) ;
}else if(score>=81&score<=100){
grandTotal++;
if(hashMap.containsKey("81-100")) {
hashMap.put("81-100", hashMap.get("81-100")+1) ;
}
else
hashMap.put("81-100", 1) ;
}
hashMap.put("Grand Total", grandTotal);
}
if(hashMap.size()>0)
{
log.debug("Response returned from Rep ortServiceImpl --getUserAssessmentReport method, No of record={}",percentageWiseAssessmentReport.size());
return new ResponseEntity<Map<String, Integer>> (hashMap,HttpStatus.OK);
}
else
{
log.debug("Response returned from ReportServiceImpl --getUserAssessmentReport method -- No record found");
return new ResponseEntity<Map<String, Integer>> (HttpStatus.NO_CONTENT);
}
}
}
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