答题记录

pull/1/head
unclekh 5 years ago
parent 88214ff93c
commit 9e6f60dca8
  1. 16
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java
  2. 2
      blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml
  3. 27
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/ExamPaperDto.java
  4. 14
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java
  5. 36
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java
  6. 39
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java
  7. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java
  8. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java
  9. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  10. 18
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  11. 19
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  12. 17
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/IdGenerator.java

@ -3,6 +3,8 @@ package com.blockchain.common.base.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;
/**
* @author huan.xu
@ -15,14 +17,22 @@ import java.io.Serializable;
public class YyyfUserDto implements Serializable {
private static final long serialVersionUID = -6752296227958588252L;
/**传过来的用户id*/
private Integer id;
private Integer userId;
/**用户名称*/
private String name;
private String userName;
/**用户类型:0学生,1老师,2管理员*/
private Integer type;
private Integer userType;
/**班级id*/
private Integer classId;
/**学校id,为以后logo修改预留参数*/
private Integer schoolId;
/**
* 课程id
*/
private String courseId;
/**
* 请求类型0 考试 1 练习 2 不计分 3 教师管理员的案例管理
*/
private Integer reqType;
}

@ -1,5 +1,7 @@
server:
port: 8101
servlet:
context-path: /user
#注册中心
eureka:
client:

@ -1,5 +1,6 @@
package com.blockchain.server.train.dto;
import lombok.Data;
import java.io.Serializable;
@ -12,31 +13,25 @@ public class ExamPaperDto implements Serializable {
* id
*/
private String id;
/**
* 指标名称
* 案例名称
*/
private String name;
/**
* 任务目标运算符1大于2小于
* 实训用途1考核 2练习
*/
private Integer taskOperate;
/**
* 任务目标比率
*/
private Double taskRate;
/**
* 任务分数
*/
private Double taskScore;
private Integer type;
/**
* 指标代码
* 指标
*/
private String code;
List<TrainCaseTargetDto> trainCaseTargeList;
/**
* 指标id
* 案例内容描述
*/
private String targeId;
// private String content;
}

@ -13,9 +13,8 @@ import java.io.Serializable;
@Data
public class TrainCaseTargetDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 指标id
* id
*/
private String id;
@ -25,7 +24,7 @@ public class TrainCaseTargetDto implements Serializable {
private String name;
/**
* 任务目标运算符1大于2小于
* 任务目标运算符1大于2小于3等于
*/
private Integer taskOperate;
/**
@ -36,4 +35,13 @@ public class TrainCaseTargetDto implements Serializable {
* 任务分数
*/
private Double taskScore;
/**
* 指标代码
*/
private String code;
/**
* 指标id
*/
private String targeId;
}

@ -7,7 +7,9 @@ import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.RSACoderUtils;
import com.blockchain.server.yyyf.controller.api.LoginApi;
import com.blockchain.server.yyyf.dto.*;
import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.utils.IdGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -69,10 +71,13 @@ public class LoginController {
Integer schoolId = yyyfLoginRequestVo.getSchoolId();
yyyfUserDto.setClassId(classId);
yyyfUserDto.setId(userId);
yyyfUserDto.setName(userName);
yyyfUserDto.setUserId(userId);
yyyfUserDto.setUserName(userName);
yyyfUserDto.setSchoolId(schoolId);
yyyfUserDto.setType(userType);
yyyfUserDto.setUserType(userType);
yyyfUserDto.setClassId(classId);
yyyfUserDto.setCourseId(yyyfLoginRequestVo.getCourserId());
//以渔有方考核id
String examId = yyyfLoginRequestVo.getReqId();
@ -80,6 +85,23 @@ public class LoginController {
String examPaperId = yyyfLoginRequestVo.getCaseId();
//做考试和练习
if (0 == reqType || 1 == reqType) {
AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId);
if(assessUser==null){
assessUser=new AssessUser();
assessUser.setId(IdGenerator.uuid());
assessUser.setAchieveMentType(reqType==0?1:0);
assessUser.setCaseId(yyyfLoginRequestVo.getCaseId());
assessUser.setClassId(String.valueOf(classId));
assessUser.setCourseId(yyyfLoginRequestVo.getCourserId());
assessUser.setIssueId(examId);
assessUser.setSsPractiseId(yyyfLoginRequestVo.getCaseId());
assessUser.setStartTime(new Date());
assessUser.setUserId(userId);
this.assessUserService.insert(assessUser);
}
HashOperations<String, String, ExamDto> examDtoOpsForHash = redisTemplate.opsForHash();
//将参加考试的人员缓存
@ -168,7 +190,7 @@ public class LoginController {
//删除强制提醒的缓存
redisTemplate.delete(YyyfConstant.ANSER_KEY + userId);
ValueOperations<String, Object> studentAnsweValueOperations = redisTemplate.opsForValue();
/* ValueOperations<String, Object> studentAnsweValueOperations = redisTemplate.opsForValue();
String studentAnswerDtoKey = YyyfConstant.ANSER_KEY + userId + examPaperId;
StudentAnswerDto studentAnswerDto = new StudentAnswerDto();
studentAnswerDto.setUserId(userId);
@ -181,7 +203,7 @@ public class LoginController {
studentAnswerDto.setClassId(classId);
studentAnswerDto.setCourseId(yyyfLoginRequestVo.getCourserId());
studentAnsweValueOperations.set(studentAnswerDtoKey, studentAnswerDto);
studentAnsweValueOperations.set(studentAnswerDtoKey, studentAnswerDto);*/
Map<String, String> map = new HashMap<String, String>();
@ -189,7 +211,7 @@ public class LoginController {
map.put("examId", examId);
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
// redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
}
} catch (IOException e) {
@ -204,7 +226,7 @@ public class LoginController {
*/
private ResultDTO handleAfterLogin(YyyfLoginDto yyyfLoginDto, YyyfUserDto yyyfUserDto) {
int status = yyyfLoginDto.getStatus();
String token = generateToken(String.valueOf(yyyfUserDto.getId()), System.currentTimeMillis(),
String token = generateToken(String.valueOf(yyyfUserDto.getUserId()), System.currentTimeMillis(),
YyyfConstant.YYYF_ZHIXINLIAN_USER_KEY);
yyyfLoginDto.setYyyfUserToken(token);
if (status != 2) {

@ -2,6 +2,9 @@ package com.blockchain.server.yyyf.controller;
import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.controller.api.StudentAnswerApi;
import com.blockchain.server.yyyf.dto.AssessUserTargetDto;
import com.blockchain.server.yyyf.entity.AssessUserTarget;
@ -9,20 +12,26 @@ import com.blockchain.server.yyyf.enums.UserEnums;
import com.blockchain.server.yyyf.exceprion.UserException;
import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.service.AssessUserTargetService;
import com.blockchain.server.yyyf.utils.IdGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/**
* @author huangxl
@ -47,26 +56,42 @@ public class StudentAnswerController {
@PostMapping("/saveAnswer")
@ApiOperation(value = StudentAnswerApi.SaveAnswer.METHOD_NAME,
notes = StudentAnswerApi.SaveAnswer.METHOD_NOTE)
public ResultDTO saveAnswer(@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_YYYF_USER_ID) @RequestParam(name = "yyyfUserId")Integer yyyfUserId,
public ResultDTO saveAnswer(@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_YYYF_USER_DTO) @RequestParam(name = "yyyfUserDto") YyyfUserDto yyyfUserDto,
@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STUDENT_TASK_RATE) @RequestParam(name = "taskRate")String taskRate,
@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STARGE_ID) @RequestParam(name = "targeId")String targeId) {
String caseKey = YyyfConstant.CASE_KEY + yyyfUserId;
String studentAnswerDtoKey = null;
Integer yyyfUserId=yyyfUserDto.getUserId();
String caseKey = YyyfConstant.CASE_KEY + yyyfUserId ;
if (redisTemplate.hasKey(caseKey)) {
Map<String,String> map = (Map<String,String>) redisTemplate.opsForValue().get(caseKey);
String caseId=map.get("examPaperId");
String examId=map.get("examId");
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash();
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, caseId);
TrainCaseTargetDto trainCaseTargetDto =null;
AssessUserTargetDto assessUserTargetDto= assessUserTargetService.selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(yyyfUserId,examId,caseId);
List<TrainCaseTargetDto> trainCaseTargeList = examPaperDto.getTrainCaseTargeList();
for(TrainCaseTargetDto targetDto:trainCaseTargeList){
if(targetDto.getTargeId().equals(targeId)){
trainCaseTargetDto=targetDto;
break;
}
}
if(assessUserTargetDto==null){
AssessUserTargetDto assessUserTargetDto= assessUserTargetService.selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(yyyfUserId,examId,caseId);
String assessUserId=assessUserTargetDto.getAssessUserId();
if(StringUtils.isBlank(assessUserTargetDto.getId())){
AssessUserTarget assessUserTarget =new AssessUserTarget();
BeanUtils.copyProperties(trainCaseTargetDto,assessUserTarget);
assessUserTarget.setAssessUserId(assessUserId);
//学生答题的结果
// assessUserTarget.set
}
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
// redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
}else{

@ -10,7 +10,7 @@ public class StudentAnswerApi {
public static class SaveAnswer {
public static final String METHOD_NAME = "学生答题";
public static final String METHOD_NOTE = "学生答题统一调用";
public static final String METHOD_YYYF_USER_ID = "以渔有方用户id";
public static final String METHOD_YYYF_USER_DTO = "以渔有方用户";
public static final String METHOD_STUDENT_TASK_RATE="学生任务目标比率";
public static final String METHOD_STARGE_ID="指标id";
}

@ -24,7 +24,7 @@ public class AssessUser implements Serializable {
* 子系统id
*/
@Column(name = "train_id")
private String trainId;
private String trainId="0001";
/**
* 已发布id

@ -12,9 +12,9 @@ import java.util.Map;
@Repository
public interface AssessUserMapper extends Mapper<AssessUserMapper> {
public interface AssessUserMapper extends Mapper<AssessUser> {
void insert(AssessUser assessUser);
int insert(AssessUser assessUser);
void batchInsert(List<AssessUser> assessUserList);

@ -72,4 +72,22 @@ public interface AssessUserService {
**/
void delAssessUserByIssueId(String examId);
/**
* @description 查找未结束的记录
* @author Mr.Xu
* @date 2020-05-13 22:26:38
* @param []
* @return com.blockchain.server.yyyf.entity.AssessUser
**/
AssessUser selectAssessUserByUserIdAndissueIdForNotEnd(Integer userId,String examId);
/**
* @description 插入
* @author Mr.Xu
* @date 2020-05-13 22:37:12
* @param [assessUser]
* @return void
**/
void insert(AssessUser assessUser);
}

@ -6,11 +6,13 @@ import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTaskMapper;
import com.blockchain.server.yyyf.service.AssessUserService;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@ -21,6 +23,7 @@ import java.util.List;
* @description 学生用户考核信息表 服务实现类
* @date 2019-10-31 14:34
*/
@Transactional(rollbackFor = Exception.class)
@Service
public class AssessUserServiceImpl implements AssessUserService {
private static Logger LOG = LoggerFactory.getLogger(AssessUserServiceImpl.class);
@ -70,5 +73,21 @@ public class AssessUserServiceImpl implements AssessUserService {
this.assessUserMapper.delAssessUserByIssueId(examId);
}
@Override
public AssessUser selectAssessUserByUserIdAndissueIdForNotEnd(Integer userId, String issueId) {
Example example=new Example(AssessUser.class);
Example.Criteria criteria = example.createCriteria();
criteria.andCondition(" user_id =",userId)
.andCondition(" issue_id = ",issueId)
.andCondition(" end_time is null ");
return this.assessUserMapper.selectOneByExample(example);
}
@Override
public void insert(AssessUser assessUser) {
this.assessUserMapper.insertSelective(assessUser);
}
}

@ -0,0 +1,17 @@
package com.blockchain.server.yyyf.utils;
import java.util.UUID;
/**
* @author Mr.Xu
* @version 1.0
* @className IdGenerator
* @description
* @date 2020-05-13 22:17
*/
public class IdGenerator {
public static String uuid(){
return UUID.randomUUID().toString().replaceAll("-","");
}
}
Loading…
Cancel
Save