mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
考试接口
This commit is contained in:
@@ -24,9 +24,12 @@ import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.service.IAloneExamService;
|
||||
import com.xboe.module.exam.vo.AloneExamQuery;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 对于与第三方对接的扩展接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/xboe/m/exam/alone-extend")
|
||||
public class AloneExamExtendApi extends ApiBaseController {
|
||||
@@ -115,12 +118,11 @@ public class AloneExamExtendApi extends ApiBaseController {
|
||||
if(StringUtil.isBlank(testId)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
//List<AloneExamAnswer> answer = aloneExamService.findAnswer(aloneId);
|
||||
Map<String,Object> map=new HashMap<String,Object>();
|
||||
try {
|
||||
|
||||
return success(map);
|
||||
Map<String,Object> rs=aloneExamService.statByTestId(testId);
|
||||
return success(rs);
|
||||
}catch(Exception e) {
|
||||
log.error("考试统计错误",e);
|
||||
return error("考试统计错误",e.getMessage(),null);
|
||||
}
|
||||
}
|
||||
@@ -132,10 +134,11 @@ public class AloneExamExtendApi extends ApiBaseController {
|
||||
}
|
||||
|
||||
try {
|
||||
//PageList<TestUserDto> rs=aloneExamService.
|
||||
return success(null);
|
||||
PageList<TestUserDto> rs=aloneExamService.findTestUserAnswers(query);
|
||||
return success(rs);
|
||||
}catch(Exception e) {
|
||||
return error("考试统计错误",e.getMessage(),null);
|
||||
log.error("查询考试用户信息错误",e);
|
||||
return error("查询失败",e.getMessage(),null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ import lombok.Data;
|
||||
@Data
|
||||
public class TestUserAnswerDto {
|
||||
|
||||
private Integer totalScore;
|
||||
private String id;
|
||||
|
||||
private Float totalScore;
|
||||
|
||||
private Float realScore;
|
||||
|
||||
|
||||
@@ -178,6 +178,27 @@ public class AloneExamAnswer extends IdBaseEntity {
|
||||
|
||||
}
|
||||
|
||||
public AloneExamAnswer(String id, String aid, String name,
|
||||
Integer passLine, Integer status, LocalDateTime startTime, LocalDateTime endTime,
|
||||
LocalDateTime lastTime, String ucode,Float score,
|
||||
Float totalScore,Float realScore,Integer useSecond,String aloneId,Integer testDuration) {
|
||||
this.setId(id);
|
||||
this.aid = aid;
|
||||
this.name = name;
|
||||
this.passLine = passLine;
|
||||
this.status = status;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.lastTime = lastTime;
|
||||
this.ucode=ucode;
|
||||
this.score=score;
|
||||
this.totalScore=totalScore;
|
||||
this.realScore=realScore;
|
||||
this.useSecond=useSecond;
|
||||
this.aloneId=aloneId;
|
||||
this.testDuration=testDuration;
|
||||
}
|
||||
|
||||
public AloneExamAnswer(String id, String aid, String name, String testId, String testName, Integer arrange,
|
||||
Integer passLine, Integer status, LocalDateTime startTime, LocalDateTime endTime,
|
||||
LocalDateTime lastTime, String clientId,String ucode,Float score,
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xboe.module.exam.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -19,6 +20,7 @@ import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.exam.dao.AloneExamAnswerDao;
|
||||
import com.xboe.module.exam.dao.AloneExamDao;
|
||||
import com.xboe.module.exam.dto.TestUserAnswerDto;
|
||||
import com.xboe.module.exam.dto.TestUserDto;
|
||||
import com.xboe.module.exam.dto.TestUserQuery;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
@@ -344,17 +346,25 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> statByTestId(String testId) throws Exception {
|
||||
// QueryBuilder query=QueryBuilder.from(AloneExamAnswer.class);
|
||||
// query.addField("new AloneExamAnswer(id,aid,name,testId,testName,arrange,passLine,status,startTime,endTime,lastTime,clientIp,ucode,score,totalScore,realScore,useSecond)");
|
||||
// query.addFilter(FieldFilters.eq("aid",aid));
|
||||
// query.addFilter(FieldFilters.eq("testId",testId));
|
||||
// query.addOrder(OrderCondition.desc("id"));
|
||||
// query.setPageSize(1);
|
||||
// List<AloneExamAnswer> list=dao.findList(query.builder());
|
||||
// if(list.isEmpty()) {
|
||||
// return null;
|
||||
// }
|
||||
return null;
|
||||
String sql="select count(a.id) as total,"
|
||||
+ "sum(CASE WHEN a.status = 9 THEN 1 ELSE 0 END) as ftotal,"
|
||||
+ "sum(CASE WHEN a.status = 1 THEN 1 ELSE 0 END) as dtotal,"
|
||||
+ "sum(CASE WHEN a.status = 0 THEN 1 ELSE 0 END) as ntotal,"
|
||||
+ "sum(CASE WHEN a.score >=t.pass_line THEN 1 ELSE 0 END) as ptotal,"
|
||||
+ "sum(CASE WHEN a.score < t.pass_line THEN 1 ELSE 0 END) as nptotal "
|
||||
+ "from boe_exam_alone a inner join boe_exam_test t on a.test_id=t.id "
|
||||
+ "where a.test_id=?1";
|
||||
List<Object[]> objsList= dao.findListFields(sql,testId);
|
||||
Map<String,Object> rs=new HashMap<String,Object>();
|
||||
Object[] objs=objsList.get(0);
|
||||
rs.put("total",objs[0]);
|
||||
rs.put("done",objs[1]);
|
||||
rs.put("doing",objs[2]);
|
||||
rs.put("noStart",objs[3]);
|
||||
rs.put("pass",objs[4]);
|
||||
rs.put("noPass",objs[5]);
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
public PageList<TestUserDto> findTestUserAnswers(TestUserQuery params) throws Exception{
|
||||
@@ -372,6 +382,9 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
}
|
||||
PageList<Object[]> rsUsers=aeDao.findPageFields(query.builder());
|
||||
List<TestUserDto> dtoUsers=new ArrayList<TestUserDto>();
|
||||
List<String> aloneIds=new ArrayList<String>();
|
||||
Map<String,TestUserDto> userMap=new HashMap<String,TestUserDto>();
|
||||
|
||||
for(Object[] objs : rsUsers.getList()) {
|
||||
TestUserDto dto=new TestUserDto();
|
||||
dto.setAloneId((String)objs[0]);
|
||||
@@ -379,9 +392,38 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
dto.setName((String)objs[2]);
|
||||
dto.setTestId(params.getTestId());
|
||||
dto.setTestName((String)objs[3]);
|
||||
dto.setAnswers(new ArrayList<>());
|
||||
dtoUsers.add(dto);
|
||||
userMap.put(dto.getAloneId(), dto);
|
||||
aloneIds.add(dto.getAloneId());
|
||||
}
|
||||
//查询用户的答卷
|
||||
QueryBuilder query2=QueryBuilder.from(AloneExamAnswer.class);
|
||||
query2.addField("new AloneExamAnswer(id,aid,name,passLine,status,startTime,endTime,lastTime,ucode,score,totalScore,realScore,useSecond,testDuration)");
|
||||
query2.addFilter(FieldFilters.in("aloneId",aloneIds));
|
||||
query2.addFilter(FieldFilters.eq("testId",params.getTestId()));
|
||||
query2.addOrder(OrderCondition.asc("startTime"));
|
||||
query2.setPageSize(1);
|
||||
List<AloneExamAnswer> alist=dao.findList(query2.builder());
|
||||
for(AloneExamAnswer aea : alist) {
|
||||
TestUserAnswerDto adto=new TestUserAnswerDto();
|
||||
adto.setId(aea.getId());
|
||||
adto.setEndTime(aea.getEndTime());
|
||||
adto.setLastTime(aea.getLastTime());
|
||||
adto.setRealScore(aea.getRealScore());
|
||||
adto.setScore(aea.getScore());
|
||||
adto.setStartTime(aea.getStartTime());
|
||||
adto.setStatus(aea.getStatus());
|
||||
adto.setTestDuration(aea.getTestDuration());
|
||||
adto.setTotalScore(aea.getTotalScore());
|
||||
TestUserDto userDto= userMap.get(aea.getAloneId());
|
||||
userDto.getAnswers().add(adto);
|
||||
}
|
||||
|
||||
PageList<TestUserDto> rs=new PageList<TestUserDto>();
|
||||
rs.setCount(rsUsers.getCount());
|
||||
rs.setList(dtoUsers);
|
||||
rs.setPageSize(params.getPageSize());
|
||||
return rs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user