提交 4df52796 authored 作者: zjm's avatar zjm

fix(培训模块): 修改了查看个人考卷的接口,返回值多加了两个用户信息,批阅人,试卷所属人

修改了查看个人考卷的接口,返回值多加了两个用户信息,批阅人,试卷所属人
上级 058aeafc
......@@ -433,17 +433,18 @@ public class TrainJobController {
@ApiOperation(value = "批阅试卷", notes = "批阅试卷")
@PostMapping("/readOverTestPaper")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity readOverTestPaper(@RequestBody ReadOverTestPaper readOverTestPaper){
public ResponseEntity readOverTestPaper(@RequestBody ReadOverTestPaper readOverTestPaper,@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser){
AtomicReference<Float> shortAnswerScore = new AtomicReference<>();
shortAnswerScore.set(0f);
readOverTestPaper.getProblemVos().forEach(
problemVo -> shortAnswerScore.set(shortAnswerScore.get() + problemVo.getScore())
);
TestPaper testPaper= testPaperService.findByUserIdAndTrainId(readOverTestPaper.getUserId(),readOverTestPaper.getTrainId());
TestPaper testPaper= testPaperService.findByUserIdAndTrainId1(readOverTestPaper.getUserId(),readOverTestPaper.getTrainId());
testPaper.setShortAnswerScore(shortAnswerScore.get());
testPaper.setShortAnswerProblem(JacksonUtil.toJSon(readOverTestPaper.getProblemVos()));
testPaper.setCountScore(testPaper.getChooseScore()+testPaper.getJudgeScore()+testPaper.getMultipleScore()+testPaper.getShortAnswerScore());
testPaper.setStatus(1);
testPaper.setMarkingId(securityUser.getCurrentUserInfo().getUserId());
TrainUser trainUser= trainUserDao.findByUserIdAndTrainId(testPaper.getUserId(),testPaper.getTrainId());
trainUser.setScore(testPaper.getCountScore().toString());
trainUser.setOnlineStatus(3);
......
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.train.entity;
import com.tykj.dev.device.train.entity.vo.ProblemVo;
import com.tykj.dev.device.train.entity.vo.TestPaperListVo;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.misc.base.BaseEntity;
import com.tykj.dev.misc.base.BeanHelper;
import io.swagger.annotations.ApiModel;
......@@ -37,7 +38,7 @@ public class TestPaper extends BaseEntity {
* 阅卷人
*/
@ApiModelProperty(value = "阅卷人(不)", example = "bmxx", name = "taskId")
private String markingName;
private Integer markingId;
/**
* 总分
......@@ -117,6 +118,12 @@ public class TestPaper extends BaseEntity {
@ApiModelProperty(value = "简答题", example = "bmxx", name = "chooseScore")
private List<ProblemVo> shortAnswerProblemList;
@Transient
private User markingUser;
@Transient
private User user;
/**
* 0。待批阅 1。批阅完成
*/
......
......@@ -26,6 +26,11 @@ public interface TestPaperService {
TestPaper findByUserIdAndTrainId(Integer userId,Integer trainId);
/**
* 根据id查询试卷
*/
TestPaper findByUserIdAndTrainId1(Integer userId,Integer trainId);
/**
* 根据培训id以及状态查询试卷
*/
......
......@@ -12,6 +12,8 @@ import com.tykj.dev.device.train.entity.vo.TestPaperListVo;
import com.tykj.dev.device.train.entity.vo.TestPaperManagementListVo;
import com.tykj.dev.device.train.service.TestPaperService;
import com.tykj.dev.device.train.service.TrainThemeService;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil;
......@@ -48,6 +50,12 @@ public class TestPaperServiceImpl implements TestPaperService {
@Autowired
TrainThemeService trainThemeService;
@Autowired
UnitsCache unitsCache;
@Autowired
UserCache userCache;
@Override
public TestPaper saveProble(TestPaper testPaper) {
return testPaperDao.save(testPaper);
......@@ -86,6 +94,23 @@ public class TestPaperServiceImpl implements TestPaperService {
TrainTheme trainTheme= trainThemeService.findById(trainId);
testPaper.setGenerateTestPaper(JacksonUtil.readValue(trainTheme.getGenerateTestPaperString(), new TypeReference<GenerateTestPaper>() {
}));
testPaper.setUser(userCache.findById(testPaper.getUserId()));
testPaper.setMarkingUser(userCache.findById(testPaper.getMarkingId()));
return testPaper;
}
@Override
public TestPaper findByUserIdAndTrainId1(Integer userId, Integer trainId) {
TestPaper testPaper= testPaperDao.findByTrainIdAndUserId(trainId,userId);
testPaper.setJudgeProblemList(JacksonUtil.readValue(testPaper.getJudgeProblem(), new TypeReference<List<ProblemVo>>() {
}));
testPaper.setChooseProblemList(JacksonUtil.readValue(testPaper.getChooseProblem(), new TypeReference<List<ProblemVo>>() {
}));
testPaper.setMultipleChoiceProblemList(JacksonUtil.readValue(testPaper.getMultipleChoiceProblem(), new TypeReference<List<ProblemVo>>() {
}));
testPaper.setShortAnswerProblemList(JacksonUtil.readValue(testPaper.getShortAnswerProblem(), new TypeReference<List<ProblemVo>>() {
}));
TrainTheme trainTheme= trainThemeService.findById(trainId);
return testPaper;
}
......
package com.tykj.dev.device.user.cache;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.UnitsService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
......@@ -14,12 +17,17 @@ public class UserCache {
private Map<Integer, User> idMap;
@Autowired
UnitsService unitsService;
public UserCache(List<User> userList){
this.idMap = userList.stream().collect(Collectors.toMap(User::getUserId, Function.identity()));
}
public User findById(Integer id) {
return idMap.get(id);
User user=idMap.get(id);
user.setUnits(unitsService.findById(user.getUnitsId()));
return user;
}
public Map<Integer, User> getIdMap() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论