Commit 2d8b9fa3 authored by manishatyagi's avatar manishatyagi
Browse files

Api code to get All sublob by lob and fix quizoutcome, percentage wise...

Api code to get All sublob by lob and fix quizoutcome, percentage wise assessment infographic report
parent 5a042734
......@@ -60,6 +60,15 @@ public class LobController {
return subResponseEntity;
}
@RequestMapping(
value="/api/admin/getAllSubLob", method=RequestMethod.GET)
public ResponseEntity<List<SubLob>> getAllSubLob(@RequestParam String lobName) throws Exception{
log.debug("Inside LobController called getActiveSubLob method with parameter, lobName={}",lobName);
ResponseEntity<List<SubLob>> subResponseEntity = lobService.getAllSubLob(lobName.toUpperCase());
log.debug("Response returned from LobController -- getAllSubLob method, subResponseEntity={}",subResponseEntity);
return subResponseEntity;
}
@RequestMapping(
value = "/api/admin/saveLob" ,method = RequestMethod.POST)
......
......@@ -43,5 +43,5 @@ public interface QuestionSetRepositoryCustom {
List<PendingUserCount> getUnattemptedUsers(Date startDate,Date endDate,long assessmentId,long subLobId,List<String> userId, String criteria) throws Exception;
List<DBObject> getUnattemptedQuestionSetCount(long assessmentId) throws Exception;
List<DBObject> getUnattemptedQuestionSetCount(long assessmentId,List<String> userIdList) throws Exception;
}
......@@ -264,16 +264,19 @@ public class QuestionSetRepositoryImpl implements QuestionSetRepositoryCustom{
}
@Override
public List<DBObject> getUnattemptedQuestionSetCount(long assessmentId) throws Exception {
public List<DBObject> getUnattemptedQuestionSetCount(long assessmentId,List<String> userIdList) throws Exception {
// TODO Auto-generated method stub
log.debug("Inside QuestionSetRepositoryImpl called getUnattemptedQuestionSetUsers method");
//AggregationOperation match = Aggregation.match(Criteria.where("isAttempted").is(false).and(Criteria.where("")));
AggregationOperation match = Aggregation.match(new Criteria().andOperator(
(Criteria.where("assessmentId").is(assessmentId))));
Cond questionSet =ConditionalOperators.when(Criteria.where("isAttempted").is(false)).then(1).otherwise(0);
AggregationOperation project = Aggregation.project("assessmentId").and(questionSet).as("pendingCount");
AggregationOperation group = Aggregation.group("assessmentId").sum("pendingCount").as("pendingCount");
Aggregation agg = Aggregation.newAggregation(match,project,group);
Criteria.where("isActive").is(true),
Criteria.where("isAttempted").is(false),
Criteria.where("assessmentId").is(assessmentId),
Criteria.where("userId").nin(userIdList)));
AggregationOperation project = Aggregation.project("userId");
AggregationOperation group = Aggregation.group("userId");
AggregationOperation group1 = Aggregation.group().count().as("pendingCount");
Aggregation agg = Aggregation.newAggregation(match,project,group,group1);
AggregationResults<DBObject> result = template.aggregate(agg,COLLECTION,DBObject.class);
log.debug("Response returned from QuestionSetRepositoryImpl -- getUnattemptedQuestionSetUsers , result={}",result.getMappedResults());
if(result.getMappedResults().size()!=0)
......
......@@ -841,16 +841,13 @@ AggregationOperation match = Aggregation.match(new Criteria().andOperator(Crite
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");
AggregationOperation group=Aggregation.group("userId").last("quizScore").as("quizScore");
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();
}
@Override
......@@ -865,23 +862,21 @@ AggregationOperation match = Aggregation.match(new Criteria().andOperator(Crite
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("quizOutcome").as("quizOutcome");
// AggregationOperation sort = Aggregation.sort(Sort.Direction.ASC,"_id");
// AggregationOperation group=Aggregation.group("_id","quizOutcome").last("userId").as("userId");
Cond passQuiz =ConditionalOperators.when(Criteria.where("quizOutcome").is(CommonUtils.Quiz_Status.Pass.name())).then(1).otherwise(0);
Cond failQuiz =ConditionalOperators.when(Criteria.where("quizOutcome").is(CommonUtils.Quiz_Status.Fail.name())).then(1).otherwise(0);
Cond evalPendingQuiz = ConditionalOperators.when(Criteria.where("quizOutcome").is(CommonUtils.Quiz_Status.Pending.name())).then(1).otherwise(0);
AggregationOperation projectQ = Aggregation.project("_id").and("questionSet.assessmentId").as("assessmentId")
.and(passQuiz).as("pass").and(failQuiz).as("fail").and(evalPendingQuiz).as("evalPending")
;
AggregationOperation groupQ=Aggregation.group("assessmentId").sum("pass").as("pass").sum("fail").as("fail")
.sum("evalPending").as("evalPending");
Aggregation agg = Aggregation.newAggregation(match,projectQ,groupQ);
AggregationOperation project = Aggregation.project("_id").and("questionSet.assessmentId")
.as("assessmentId").and(passQuiz).as("pass").and(failQuiz).as("fail").and(evalPendingQuiz)
.as("evalPending").and("questionSet.userId").as("userId");
AggregationOperation sort= Aggregation.sort(Sort.Direction.ASC,"_id");
AggregationOperation group=Aggregation.group("userId").last("pass").as("pass").last("fail").as("fail")
.last("evalPending").as("evalPending");
AggregationOperation group1=Aggregation.group().sum("pass").as("pass").sum("fail").as("fail")
.sum("evalPending").as("evalPending").push("_id").as("userId");
Aggregation agg = Aggregation.newAggregation(match,project,sort,group,group1);
AggregationResults<DBObject> result = template.aggregate(agg,COLLECTION,DBObject.class);
log.debug("Response returned from QuizResultRepositoryImpl--getQuizResultWiseAssesmentInfographicReport method,result={}",result.getMappedResults().size());
return result.getMappedResults();
}
}
......@@ -24,4 +24,6 @@ public interface LobService {
public ResponseEntity<String> editLobDetails(@Valid Lob lob);
ResponseEntity<List<Lob>> getActiveLob() throws Exception;
ResponseEntity<List<UserMaster>> getUserListByLobSubLob(long lobId, long subLobId);
public ResponseEntity<List<SubLob>> getAllSubLob(String lobName)throws Exception;
}
......@@ -48,6 +48,19 @@ public class LobServiceImpl implements LobService{
return new ResponseEntity<List<SubLob>>(subLobList,HttpStatus.OK);
}
@Override
public ResponseEntity<List<SubLob>> getAllSubLob(String lobName) throws Exception {
// TODO Auto-generated method stub
log.debug("Inside LobServiceImpl called getAllSubLob method with parameter, lobName={}",lobName);
List<SubLob>subLobList=subLobRepo.findSubLobbyLob(lobName);
if(subLobList.isEmpty()) {
log.debug("Response returned from LobServiceImpl -- getAllSubLob method, subLobList={}",subLobList);
return new ResponseEntity<List<SubLob>>(subLobList,HttpStatus.NO_CONTENT);
}
log.debug("Response returned from LobServiceImpl -- getAllSubLob method, subLobList={}",subLobList);
return new ResponseEntity<List<SubLob>>(subLobList,HttpStatus.OK);
}
@Override
public ResponseEntity<List<Lob>> getActiveLob() throws Exception {
// TODO Auto-generated method stub
......@@ -240,7 +253,4 @@ public class LobServiceImpl implements LobService{
return new ResponseEntity<List<UserMaster>>(HttpStatus.BAD_REQUEST);
}
}
......@@ -5,6 +5,7 @@ package com.statestreet.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
......@@ -590,6 +591,15 @@ public class ReportServiceImpl implements ReportService{
}
if(report.size()>0)
{
List<CommonUtils.Gender> allGender=Arrays.asList(CommonUtils.Gender.values());
allGender.forEach((str)->{
if(!report.stream().anyMatch(o -> o.getCriteria().equals(str.name())))
{
UserAssessmentInfographicReport tempObj=new UserAssessmentInfographicReport(str.name(),0, 0, 0, 0, 0);
report.add(tempObj);
}
});
log.debug("Response returned from ReportServiceImpl --getGenderAssessInfographicReport method, No of record={}",report.size());
return new ResponseEntity<List<UserAssessmentInfographicReport>> (report,HttpStatus.OK);
}
......@@ -738,7 +748,16 @@ public class ReportServiceImpl implements ReportService{
int grandTotal=0;
int pending=0;
List<DBObject> quizResult=quizResultRepo.getQuizResultWiseAssesmentInfographicReport(stDate, enDate, assessmentId,subLobId);
List<DBObject> questionSet = quesSetRepo.getUnattemptedQuestionSetCount(assessmentId);
List<String> userIdList=new ArrayList<String>();
if(quizResult.size()>0)
{
String[] userArray=quizResult.stream().map(dbObject -> dbObject.get("userId")).map(Object::toString).toArray(String[]::new);
for(String user:userArray) {
user=user.substring(1,user.length()-1);
userIdList.add(user);
}
}
List<DBObject> questionSet = quesSetRepo.getUnattemptedQuestionSetCount(assessmentId,userIdList);
Map<String, Integer> hashMap = new HashMap<String,Integer>();
......
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