mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 11:26:50 +08:00
Merge branch 'master' of codeup.aliyun.com:6265f483e4166464dc2f9c14/boeu/baseservers
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.xboe.module.exam.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -24,9 +23,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 +117,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);
|
||||
}
|
||||
}
|
||||
@@ -130,12 +131,18 @@ public class AloneExamExtendApi extends ApiBaseController {
|
||||
if(StringUtil.isBlank(query.getTestId())){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
|
||||
if(query.getPageSize()==null) {
|
||||
query.setPageSize(100);
|
||||
}
|
||||
if(query.getPageIndex()==null) {
|
||||
query.setPageIndex(1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,10 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestUserAnswerDto {
|
||||
|
||||
private String id;
|
||||
|
||||
private Integer totalScore;
|
||||
private Float totalScore;
|
||||
|
||||
private Float realScore;
|
||||
|
||||
|
||||
@@ -177,6 +177,27 @@ public class AloneExamAnswer extends IdBaseEntity {
|
||||
public AloneExamAnswer() {
|
||||
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@@ -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.sqlFindList(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,39 @@ 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,aloneId,testDuration)");
|
||||
//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
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +241,13 @@ public class TeacherApi extends ApiBaseController {
|
||||
if(StringUtils.isBlank(id)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
Account a = accountService.get(id);
|
||||
if(a==null) {
|
||||
return badRequest("用户不对,数据错误,请联系管理员");
|
||||
}
|
||||
Teacher teacher = service.get(id);
|
||||
Map<String,Object> rs=new HashMap<String,Object>();
|
||||
rs.put("sysId",a.getSysId());
|
||||
if(teacher!=null){
|
||||
rs.put("id",id);
|
||||
rs.put("photo",teacher.getPhoto());
|
||||
|
||||
@@ -210,19 +210,34 @@ public class TeacherServiceImpl implements ITeacherService {
|
||||
@Transactional
|
||||
public void updateTeacher(TeacherFiledVo entity) {
|
||||
|
||||
// Teacher teacher = dao.get(entity.getId());
|
||||
// teacher.setPhoto(entity.getPhoto());
|
||||
// teacher.setWorkExperience(entity.getWorkExperience());
|
||||
// teacher.setCourses(entity.getCourses());
|
||||
// teacher.setExpertise(entity.getExpertise());
|
||||
// dao.update(teacher);
|
||||
//修改为以下方式,不影响其它字段的
|
||||
dao.updateMultiFieldById(entity.getId(),
|
||||
UpdateBuilder.create("photo", entity.getPhoto()),
|
||||
UpdateBuilder.create("workExperience", entity.getWorkExperience()),
|
||||
UpdateBuilder.create("courses", entity.getCourses()),
|
||||
UpdateBuilder.create("expertise", entity.getExpertise())
|
||||
);
|
||||
Teacher teacher = dao.get(entity.getId());
|
||||
if(teacher==null) {
|
||||
teacher=new Teacher();
|
||||
teacher.setId(entity.getId());
|
||||
teacher.setPhoto(entity.getPhoto());
|
||||
teacher.setWorkExperience(entity.getWorkExperience());
|
||||
teacher.setCourses(entity.getCourses());
|
||||
teacher.setExpertise(entity.getExpertise());
|
||||
teacher.setWaitStatus(0);
|
||||
teacher.setCertStatus(0);
|
||||
teacher.setStatus(1);
|
||||
teacher.setDeleted(false);
|
||||
//提取用户信息
|
||||
User u= userService.get(entity.getId());
|
||||
if(u!=null) {
|
||||
teacher.setName(u.getName());
|
||||
teacher.setDepartId(u.getDepartId());
|
||||
teacher.setGender(u.getGender());
|
||||
}
|
||||
dao.save(teacher);
|
||||
}else {
|
||||
dao.updateMultiFieldById(entity.getId(),
|
||||
UpdateBuilder.create("photo", entity.getPhoto()),
|
||||
UpdateBuilder.create("workExperience", entity.getWorkExperience()),
|
||||
UpdateBuilder.create("courses", entity.getCourses()),
|
||||
UpdateBuilder.create("expertise", entity.getExpertise())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user