答题提交处理

pull/1/head
huan.xu 5 years ago
parent 9e6f60dca8
commit d286a3b57c
  1. 23
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java
  2. 32
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java
  3. 26
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java
  4. 2
      blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml
  5. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java
  6. 269
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java
  7. 110
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java
  8. 5
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java
  9. 16
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java
  10. 10
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java
  11. 16
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java
  12. 1
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java
  13. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  14. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java
  15. 3
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  16. 26
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java
  17. 28
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  18. 29
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java
  19. 6
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml
  20. 32
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml

@ -16,23 +16,22 @@ import java.util.Map;
@Data @Data
public class YyyfUserDto implements Serializable { public class YyyfUserDto implements Serializable {
private static final long serialVersionUID = -6752296227958588252L; private static final long serialVersionUID = -6752296227958588252L;
/**传过来的用户id*/ /**
* 传过来的用户id
*/
private Integer userId; private Integer userId;
/**用户名称*/ /**
* 用户名称
*/
private String userName; private String userName;
/**用户类型:0学生,1老师,2管理员*/
private Integer userType;
/**班级id*/
private Integer classId;
/**学校id,为以后logo修改预留参数*/
private Integer schoolId;
/** /**
* 课程id * 成绩主表id
*/ */
private String courseId; private String assessUserId;
/** /**
* 请求类型0 考试 1 练习 2 不计分 3 教师管理员的案例管理 * 用户类型:0学生1老师2管理员
*/ */
private Integer reqType; private Integer userType;
} }

@ -0,0 +1,32 @@
package com.blockchain.common.base.util;
import com.blockchain.common.base.constant.BaseConstant;
import com.blockchain.common.base.dto.YyyfUserDto;
import org.springframework.data.redis.core.RedisTemplate;
import javax.servlet.http.HttpServletRequest;
/**
* @author huan.xu
* @version 1.0
* @className YyyfUserDto
* @description
* @date 2020-05-14 14:09
*/
public class YyyfUserDtoUtils {
/**
* @description 从cookies 获取以渔有方用户信息
* @param [request, redisTemplate]
* @return com.blockchain.common.base.dto.YyyfUserDto
**/
public static YyyfUserDto getYyyfUserDto(HttpServletRequest request, RedisTemplate redisTemplate) {
YyyfUserDto yyyfUserDto = null;
String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER);
//如果有token,拿到用户信息,与以渔有方进行绑定
if (redisTemplate.hasKey(yyyfTtoken)) {
yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(yyyfTtoken);
}
return yyyfUserDto;
}
}

@ -9,6 +9,7 @@ import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.HttpRequestUtil; import com.blockchain.common.base.util.HttpRequestUtil;
import com.blockchain.common.base.util.RSACoderUtils; import com.blockchain.common.base.util.RSACoderUtils;
import com.blockchain.common.base.util.SSOHelper; import com.blockchain.common.base.util.SSOHelper;
import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.user.common.constants.other.InternationalConstant; import com.blockchain.server.user.common.constants.other.InternationalConstant;
import com.blockchain.server.user.common.enums.SmsCountEnum; import com.blockchain.server.user.common.enums.SmsCountEnum;
import com.blockchain.server.user.common.enums.UserEnums; import com.blockchain.server.user.common.enums.UserEnums;
@ -273,9 +274,9 @@ public class LoginController {
*/ */
private ResultDTO handleAfterLogin(UserMain userMain, String tokenType, HttpServletRequest request) { private ResultDTO handleAfterLogin(UserMain userMain, String tokenType, HttpServletRequest request) {
String userId=userMain.getId(); String userId = userMain.getId();
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType, dealBindYyyfAccount(userId,userMain.getMobilePhone(),request)); setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType, dealBindYyyfAccount(userId, userMain.getMobilePhone(), request));
String token = generateToken(userMain.getMobilePhone(), timestamp, tokenType); String token = generateToken(userMain.getMobilePhone(), timestamp, tokenType);
UserBaseDTO userBaseDTO = userMainService.selectUserInfoById(userMain.getId()); UserBaseDTO userBaseDTO = userMainService.selectUserInfoById(userMain.getId());
userBaseDTO.setToken(token); userBaseDTO.setToken(token);
@ -317,32 +318,29 @@ public class LoginController {
} }
/** /**
* @description 处理yyyf账号绑定
* @param [userId, tel, request] * @param [userId, tel, request]
* @return java.lang.String * @return java.lang.String
* @description 处理yyyf账号绑定
**/ **/
private Integer dealBindYyyfAccount(String userId, String tel, HttpServletRequest request){ private Integer dealBindYyyfAccount(String userId, String tel, HttpServletRequest request) {
Integer yyyfUserId = null; Integer yyyfUserId = null;
String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER); String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER);
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
//如果有token,拿到用户信息,与以渔有方进行绑定 //如果有token,拿到用户信息,与以渔有方进行绑定
if (redisTemplate.hasKey(yyyfTtoken)) { if (yyyfUserDto != null) {
YyyfUserDto yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(yyyfTtoken); yyyfUserId = yyyfUserDto.getUserId();
yyyfUserId = yyyfUserDto.getId();
YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, tel); YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, tel);
if (yyyfUser == null) { if (yyyfUser == null) {
this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getName()); this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getUserName());
this.redisTemplate.delete(yyyfTtoken); this.redisTemplate.delete(yyyfTtoken);
}else{ } else {
if(!yyyfUser.getUserId().equals(userId)){ if (!yyyfUser.getUserId().equals(userId)) {
throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER); throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER);
} }
} }
}else{ } else {
throw new UserException(UserEnums.USER_NOT_BIND_YYYF); throw new UserException(UserEnums.USER_NOT_BIND_YYYF);
} }
return yyyfUserId; return yyyfUserId;
} }
} }

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

@ -24,7 +24,7 @@ public class TrainCaseTargetDto implements Serializable {
private String name; private String name;
/** /**
* 任务目标运算符1大于2小于3等 * 任务目标运算符-1小于0等于1大
*/ */
private Integer taskOperate; private Integer taskOperate;
/** /**
@ -43,5 +43,5 @@ public class TrainCaseTargetDto implements Serializable {
/** /**
* 指标id * 指标id
*/ */
private String targeId; private String targetId;
} }

@ -5,10 +5,13 @@ import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.TokenDTO; import com.blockchain.common.base.dto.TokenDTO;
import com.blockchain.common.base.dto.YyyfUserDto; import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.RSACoderUtils; import com.blockchain.common.base.util.RSACoderUtils;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.controller.api.LoginApi; import com.blockchain.server.yyyf.controller.api.LoginApi;
import com.blockchain.server.yyyf.dto.*; import com.blockchain.server.yyyf.dto.*;
import com.blockchain.server.yyyf.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.service.AssessUserService; import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.service.AssessUserTargetService;
import com.blockchain.server.yyyf.utils.IdGenerator; import com.blockchain.server.yyyf.utils.IdGenerator;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -18,7 +21,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -54,169 +56,134 @@ public class LoginController {
//存到redis中用于以渔有方用户与智信链用户进行绑定 //存到redis中用于以渔有方用户与智信链用户进行绑定
YyyfUserDto yyyfUserDto = new YyyfUserDto();
//登录返回的Data //登录返回的Data
YyyfLoginDto yyyfLoginDto = new YyyfLoginDto(); YyyfLoginDto yyyfLoginDto = new YyyfLoginDto();
yyyfLoginDto.setStatus(0); yyyfLoginDto.setStatus(0);
String userName = null; String userName = null;
try { try {
userName = new String(new BASE64Decoder().decodeBuffer(yyyfLoginRequestVo.getUserName().replaceAll(" ", "+")), "UTF-8"); userName = new String(new BASE64Decoder().decodeBuffer(yyyfLoginRequestVo.getUserName().replaceAll(" ", "+")), "UTF-8");
//根据案例id,考核id封装相关信息。 } catch (IOException e) {
//1、从缓存中取案列相关 LOG.error(e.getMessage(), e);
//0 考试 1 练习 2 不计分 3 教师、管理员的案例管理 }
int reqType = yyyfLoginRequestVo.getReqType().intValue(); //根据案例id,考核id封装相关信息。
int userType = yyyfLoginRequestVo.getUserType().intValue(); //1、从缓存中取案列相关
Integer classId = yyyfLoginRequestVo.getClassId(); //0 考试 1 练习 2 不计分 3 教师、管理员的案例管理
Integer userId = yyyfLoginRequestVo.getUserId(); int reqType = yyyfLoginRequestVo.getReqType().intValue();
Integer schoolId = yyyfLoginRequestVo.getSchoolId(); Integer classId = yyyfLoginRequestVo.getClassId();
Integer userId = yyyfLoginRequestVo.getUserId();
yyyfUserDto.setClassId(classId);
yyyfUserDto.setUserId(userId);
yyyfUserDto.setUserName(userName); //以渔有方考核id
yyyfUserDto.setSchoolId(schoolId); String examId = yyyfLoginRequestVo.getReqId();
yyyfUserDto.setUserType(userType); //试卷id(项目id)
yyyfUserDto.setClassId(classId); String examPaperId = yyyfLoginRequestVo.getCaseId();
yyyfUserDto.setCourseId(yyyfLoginRequestVo.getCourserId());
YyyfUserDto yyyfUserDto = new YyyfUserDto();
yyyfUserDto.setUserName(userName);
//以渔有方考核id yyyfUserDto.setUserId(userId);
String examId = yyyfLoginRequestVo.getReqId(); yyyfUserDto.setUserType(yyyfLoginRequestVo.getUserType());
//试卷id(项目id)
String examPaperId = yyyfLoginRequestVo.getCaseId(); //做考试和练习
//做考试和练习 if (0 == reqType || 1 == reqType) {
if (0 == reqType || 1 == reqType) {
AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId);
if (assessUser == null) {
AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); String assessUserId = IdGenerator.uuid();
if(assessUser==null){ assessUser = new AssessUser();
assessUser=new AssessUser(); assessUser.setId(assessUserId);
assessUser.setId(IdGenerator.uuid()); assessUser.setAchieveMentType(reqType == 0 ? 1 : 0);
assessUser.setAchieveMentType(reqType==0?1:0); assessUser.setCaseId(yyyfLoginRequestVo.getCaseId());
assessUser.setCaseId(yyyfLoginRequestVo.getCaseId()); assessUser.setClassId(String.valueOf(classId));
assessUser.setClassId(String.valueOf(classId)); assessUser.setCourseId(yyyfLoginRequestVo.getCourserId());
assessUser.setCourseId(yyyfLoginRequestVo.getCourserId()); assessUser.setIssueId(examId);
assessUser.setIssueId(examId); assessUser.setSsPractiseId(yyyfLoginRequestVo.getCaseId());
assessUser.setSsPractiseId(yyyfLoginRequestVo.getCaseId()); assessUser.setStartTime(new Date());
assessUser.setStartTime(new Date()); assessUser.setUserId(userId);
assessUser.setUserId(userId); assessUser.setUserName(userName);
this.assessUserService.insert(assessUser);
//获取案例信息
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash();
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId);
List<TrainCaseTargetDto> trainCaseTargeList = examPaperDto.getTrainCaseTargeList();
this.assessUserService.initAssessUser(assessUser, trainCaseTargeList);
}
yyyfUserDto.setAssessUserId(assessUser.getId());
HashOperations<String, String, ExamDto> examDtoOpsForHash = redisTemplate.opsForHash();
//将参加考试的人员缓存
HashOperations<String, String, List<Integer>> studentOpsForHash = redisTemplate.opsForHash();
//参加考试的人员id
List<Integer> joinStuIds = null;
//考试id和案列id缓存
String caseKey = YyyfConstant.CASE_KEY + userId;
//判断考试缓存中是否存在这张卷子
if (0 == reqType) {
//如果他提交了,库里有信息了,不允许他再次进入了。
if (this.assessUserService.selectScore(examId, userId) != null) {
yyyfLoginDto.setStatus(2);
yyyfLoginDto.setMsg(YyyfConstant.SUBMITTED);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
} }
HashOperations<String, String, ExamDto> examDtoOpsForHash = redisTemplate.opsForHash();
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId);
//将参加考试的人员缓存 if (examDto == null) {
HashOperations<String, String, List<Integer>> studentOpsForHash = redisTemplate.opsForHash(); examDto = new ExamDto();
//参加考试的人员id examDto.setExamId(yyyfLoginRequestVo.getReqId());
List<Integer> joinStuIds = null; examDto.setBeginTime(yyyfLoginRequestVo.getBeginTime());
examDto.setEndTime(yyyfLoginRequestVo.getEndTime());
//考试id和案列id缓存 examDto.setType(reqType);
String caseKey = YyyfConstant.CASE_KEY + userId; examDto.setExamPaperId(examPaperId);
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto);
//判断考试缓存中是否存在这张卷子 }
if (0 == reqType) {
//如果他提交了,库里有信息了,不允许他再次进入了。 joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
if (this.assessUserService.selectScore(examId, userId) != null) { if (joinStuIds == null) {
yyyfLoginDto.setStatus(2); joinStuIds = new ArrayList<Integer>();
yyyfLoginDto.setMsg(YyyfConstant.SUBMITTED); }
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); //如果等于0
} if (joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() == 0) {
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId); joinStuIds.add(userId);
if (examDto == null) { studentOpsForHash.put(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId, joinStuIds);
examDto = new ExamDto();
examDto.setExamId(yyyfLoginRequestVo.getReqId());
examDto.setBeginTime(yyyfLoginRequestVo.getBeginTime());
examDto.setEndTime(yyyfLoginRequestVo.getEndTime());
examDto.setType(reqType);
examDto.setExamPaperId(examPaperId);
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto);
}
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
if (joinStuIds == null) {
joinStuIds = new ArrayList<Integer>();
}
//如果等于0
if (joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() == 0) {
joinStuIds.add(userId);
studentOpsForHash.put(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId, joinStuIds);
} else {
yyyfLoginDto.setStatus(1);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
} else { } else {
yyyfLoginDto.setStatus(1);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
} else {
if (redisTemplate.hasKey(caseKey)) { if (redisTemplate.hasKey(caseKey)) {
Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey); Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey);
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId")); joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId"));
} }
//缓存是考试,要进入练习,则不让进入 //缓存是考试,要进入练习,则不让进入
if (joinStuIds != null && joinStuIds.stream() if (joinStuIds != null && joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) { .filter(stuIds -> (stuIds.equals(userId))).count() != 0) {
yyyfLoginDto.setStatus(1); yyyfLoginDto.setStatus(1);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
ValueOperations<String, Object> studentAnsweValueOperations = redisTemplate.opsForValue();
String studentAnswerDtoKey = YyyfConstant.ANSER_KEY + userId + examPaperId;
StudentAnswerDto studentAnswerDto = (StudentAnswerDto) studentAnsweValueOperations.get(studentAnswerDtoKey);
if (studentAnswerDto != null) {
//答题结果、且未提交
Map<String, Double> result = studentAnswerDto.getResult();
if (result != null && result.size() > 0 && result.get("isSubmit") == null) {
yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.INCOMPLETE_PRACTICE);
PractiseTipDto practiseTipDto = new PractiseTipDto();
practiseTipDto.setExamId(examId);
practiseTipDto.setExamPaperId(examPaperId);
practiseTipDto.setYyyfUserId(userId);
yyyfLoginDto.setPractiseTipDto(practiseTipDto);
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examPaperId);
map.put("examId", examId);
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
}
} }
//删除强制提醒的缓存
redisTemplate.delete(YyyfConstant.ANSER_KEY + userId);
/* ValueOperations<String, Object> studentAnsweValueOperations = redisTemplate.opsForValue();
String studentAnswerDtoKey = YyyfConstant.ANSER_KEY + userId + examPaperId;
StudentAnswerDto studentAnswerDto = new StudentAnswerDto();
studentAnswerDto.setUserId(userId);
studentAnswerDto.setUserType(userType);
studentAnswerDto.setBeginTime(new Date());
studentAnswerDto.setExamId(examId);
studentAnswerDto.setType(reqType);
studentAnswerDto.setExamPaperId(examPaperId);
studentAnswerDto.setUserName(userName);
studentAnswerDto.setClassId(classId);
studentAnswerDto.setCourseId(yyyfLoginRequestVo.getCourserId());
studentAnsweValueOperations.set(studentAnswerDtoKey, studentAnswerDto);*/
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examPaperId);
map.put("examId", examId);
redisTemplate.opsForValue().set(caseKey, map);
// redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
} }
} catch (IOException e) { //删除强制提醒的缓存
LOG.error(e.getMessage(), e); // redisTemplate.delete(YyyfConstant.ANSER_KEY + userId);
Map<String, String> map = new HashMap<String, String>();
map.put("examPaperId", examPaperId);
map.put("examId", examId);
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
} }
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
} }

@ -3,35 +3,33 @@ package com.blockchain.server.yyyf.controller;
import com.blockchain.common.base.constant.YyyfConstant; import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.YyyfUserDto; import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.server.train.dto.ExamPaperDto; import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.controller.api.StudentAnswerApi; import com.blockchain.server.yyyf.controller.api.StudentAnswerApi;
import com.blockchain.server.yyyf.dto.AssessUserTargetDto; import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.enums.UserEnums; import com.blockchain.server.yyyf.enums.UserEnums;
import com.blockchain.server.yyyf.exceprion.UserException; import com.blockchain.server.yyyf.exceprion.UserException;
import com.blockchain.server.yyyf.service.AssessUserService; import com.blockchain.server.yyyf.service.AssessUserService;
import com.blockchain.server.yyyf.service.AssessUserTargetService; import com.blockchain.server.yyyf.service.AssessUserTargetService;
import com.blockchain.server.yyyf.utils.IdGenerator;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils; import lombok.SneakyThrows;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @author huangxl * @author huangxl
@ -43,12 +41,10 @@ import java.util.concurrent.atomic.AtomicReference;
@RequestMapping("/studentAnswer") @RequestMapping("/studentAnswer")
public class StudentAnswerController { public class StudentAnswerController {
private static final Logger LOG = LoggerFactory.getLogger(StudentAnswerController.class);
@Autowired
private AssessUserService assessUserService;
@Autowired @Autowired
private AssessUserTargetService assessUserTargetService; private AssessUserTargetService assessUserTargetService;
@Autowired
private AssessUserService assessUserService;
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@ -56,50 +52,64 @@ public class StudentAnswerController {
@PostMapping("/saveAnswer") @PostMapping("/saveAnswer")
@ApiOperation(value = StudentAnswerApi.SaveAnswer.METHOD_NAME, @ApiOperation(value = StudentAnswerApi.SaveAnswer.METHOD_NAME,
notes = StudentAnswerApi.SaveAnswer.METHOD_NOTE) notes = StudentAnswerApi.SaveAnswer.METHOD_NOTE)
public ResultDTO saveAnswer(@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_YYYF_USER_DTO) @RequestParam(name = "yyyfUserDto") YyyfUserDto yyyfUserDto, public ResultDTO<Integer> saveAnswer(@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_YYYF_USER_ID) @RequestParam(name = "yyyfUserId") Integer yyyfUserId,
@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STUDENT_TASK_RATE) @RequestParam(name = "taskRate")String taskRate, @ApiParam(StudentAnswerApi.SaveAnswer.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId") String assessUserId,
@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STARGE_ID) @RequestParam(name = "targeId")String targeId) { @ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STUDENT_TASK_RATE) @RequestParam(name = "taskRate") Double taskRate,
@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_STARGE_ID) @RequestParam(name = "code") String code) {
String caseKey = YyyfConstant.CASE_KEY + yyyfUserId;
Integer answer = -1;
Integer yyyfUserId=yyyfUserDto.getUserId();
String caseKey = YyyfConstant.CASE_KEY + yyyfUserId ;
if (redisTemplate.hasKey(caseKey)) { if (redisTemplate.hasKey(caseKey)) {
Map<String,String> map = (Map<String,String>) redisTemplate.opsForValue().get(caseKey); AssessUserTarget assessUserTarget = this.assessUserTargetService.selectByAssessUserAndCode(assessUserId, code);
String caseId=map.get("examPaperId"); assessUserTarget.setStudentRate(taskRate);
String examId=map.get("examId"); int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate());
//最终指标结果一致
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash(); if (assessUserTarget.getTaskOperate().intValue() == compareAnswer) {
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, caseId); answer = 0;
TrainCaseTargetDto trainCaseTargetDto =null; } else {
answer = 1;
List<TrainCaseTargetDto> trainCaseTargeList = examPaperDto.getTrainCaseTargeList();
for(TrainCaseTargetDto targetDto:trainCaseTargeList){
if(targetDto.getTargeId().equals(targeId)){
trainCaseTargetDto=targetDto;
break;
}
}
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
} }
assessUserTarget.setAnswer(answer);
this.assessUserTargetService.update(assessUserTarget);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS); redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
// redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS); } else {
}else{
throw new UserException(UserEnums.USER_NOT_BIND_YYYF); throw new UserException(UserEnums.USER_NOT_BIND_YYYF);
} }
return new ResultDTO(); return ResultDTO.requstSuccess(answer);
} }
@SneakyThrows
@PostMapping("/submit")
@ApiOperation(value = StudentAnswerApi.SaveAnswer.METHOD_NAME,
notes = StudentAnswerApi.SaveAnswer.METHOD_NOTE)
public ResultDTO<Integer> submit(HttpServletRequest request) {
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
String assessUserId = yyyfUserDto.getAssessUserId();
AssessUser assessUser = this.assessUserService.selectAssessUserById(assessUserId);
if (assessUser.getEndTime() != null) {
throw new UserException(UserEnums.PROHIBIT_DUPLICATE_SUBMISSION);
}
Double totalScore = 0d;
List<AssessUserTarget> assessUserTargetList = this.assessUserTargetService.selectAssessUserTargetByAssessUserId(assessUserId);
for (AssessUserTarget assessUserTarget : assessUserTargetList) {
Integer answer = assessUserTarget.getAnswer();
Double taskScore = assessUserTarget.getTaskScore();
if (assessUserTarget.getAnswer() == 0) {
totalScore += taskScore;
}
}
Date startTime = assessUser.getStartTime();
Date now = new Date();
assessUser.setTotalScore(totalScore);
assessUser.setEndTime(now);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//考试时长
//考试时长
long duration1 = sdf.parse(sdf.format(now)).getTime() - sdf.parse(sdf.format(startTime)).getTime();
long duration = now.getTime() - startTime.getTime();
return ResultDTO.requstSuccess();
}
} }

@ -9,8 +9,9 @@ public class StudentAnswerApi {
public static class SaveAnswer { public static class SaveAnswer {
public static final String METHOD_NAME = "学生答题"; public static final String METHOD_NAME = "学生答题";
public static final String METHOD_NOTE = "学生答题统一调用"; public static final String METHOD_NOTE = "学生答题统一调用,调用成功,返回结果:0答案正确,1答案错误,-1系统错误";
public static final String METHOD_YYYF_USER_DTO = "以渔有方用户"; public static final String METHOD_YYYF_USER_ID= "以渔有方用户ID";
public static final String METHOD_ASSESS_USER_ID= "assessUser的主键ID";
public static final String METHOD_STUDENT_TASK_RATE="学生任务目标比率"; public static final String METHOD_STUDENT_TASK_RATE="学生任务目标比率";
public static final String METHOD_STARGE_ID="指标id"; public static final String METHOD_STARGE_ID="指标id";
} }

@ -1,16 +0,0 @@
package com.blockchain.server.yyyf.dto;
import com.blockchain.server.yyyf.entity.AssessUserTarget;
import lombok.Data;
/**
* @author huan.xu
* @version 1.0
* @className AssessUserTargetDto
* @description
* @date 2020-05-13 16:52
*/
@Data
public class AssessUserTargetDto extends AssessUserTarget {
private String assessUserId;
}

@ -48,7 +48,7 @@ public class AssessUser implements Serializable {
* 得分 * 得分
*/ */
@Column(name = "total_score") @Column(name = "total_score")
private BigDecimal totalScore; private Double totalScore;
/** /**
* 时长 * 时长
*/ */
@ -58,7 +58,7 @@ public class AssessUser implements Serializable {
* 时长单位 * 时长单位
*/ */
@Column(name = "duration_unit") @Column(name = "duration_unit")
private String durationUnit; private String durationUnit="m";
/** /**
* 开始时间 * 开始时间
*/ */
@ -92,6 +92,10 @@ public class AssessUser implements Serializable {
*/ */
@Column(name = "course_id") @Column(name = "course_id")
private String courseId; private String courseId;
/**
* 绑定的课程id
*/
@Column(name = "user_name")
private String userName;
} }

@ -27,8 +27,8 @@ public class AssessUserTarget implements Serializable {
/** /**
* 指标id * 指标id
*/ */
@Column(name = "targe_id") @Column(name = "target_id")
private String targeId; private String targetId;
/** /**
* 指标名称 * 指标名称
@ -37,7 +37,7 @@ public class AssessUserTarget implements Serializable {
private String targetName; private String targetName;
/** /**
* 任务目标运算符1大于2等于3小 * 任务目标运算符-1小于0等于1大
*/ */
@Column(name = "task_operate") @Column(name = "task_operate")
private Integer taskOperate; private Integer taskOperate;
@ -62,4 +62,14 @@ public class AssessUserTarget implements Serializable {
*/ */
@Column(name = "sort") @Column(name = "sort")
private Integer sort; private Integer sort;
/**
* 学生答题计算的指标
*/
@Column(name = "student_rate")
private Double studentRate;
/**
* 学生是否完成指标0完成1未
*/
@Column(name = "answer")
private Integer answer;
} }

@ -5,6 +5,7 @@ package com.blockchain.server.yyyf.enums;
* @data 2019/2/21 20:53 * @data 2019/2/21 20:53
*/ */
public enum UserEnums { public enum UserEnums {
PROHIBIT_DUPLICATE_SUBMISSION(1097,"禁止重复提交","Prohibit duplicate submission","禁止重複提交"),
USER_NOT_FORBID_OTHER_USER(1098, "禁止登录他人账号", "The user does not allow login other user's accout", "禁止登錄他人賬號"), USER_NOT_FORBID_OTHER_USER(1098, "禁止登录他人账号", "The user does not allow login other user's accout", "禁止登錄他人賬號"),
USER_NOT_BIND_YYYF(1099, "该用户未绑定以渔有方或者以渔有方登录已失效", "The user does not bind yyyf", "該用戶未綁定以漁有方或者以漁有方登錄已失效"), USER_NOT_BIND_YYYF(1099, "该用户未绑定以渔有方或者以渔有方登录已失效", "The user does not bind yyyf", "該用戶未綁定以漁有方或者以漁有方登錄已失效"),
USER_EXISTS(1100, "该用户已存在", "The user already exists", "該用戶已存在"), USER_EXISTS(1100, "该用户已存在", "The user already exists", "該用戶已存在"),

@ -34,7 +34,7 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
List<AssessUser> selectAssessUserListByIssuerIdAndUserId(@Param("issueId") String issueId, @Param("userId") Integer userId); List<AssessUser> selectAssessUserListByIssuerIdAndUserId(@Param("issueId") String issueId, @Param("userId") Integer userId);
AssessUser selectAssessUserById(@Param("assessUserId") String assessUserId);
List<AssessUser> selectAssessUserListByIssueId(@Param("issueId") String issueId); List<AssessUser> selectAssessUserListByIssueId(@Param("issueId") String issueId);

@ -1,6 +1,5 @@
package com.blockchain.server.yyyf.mapper; package com.blockchain.server.yyyf.mapper;
import com.blockchain.server.yyyf.dto.AssessUserTargetDto;
import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.entity.AssessUserTarget;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -12,5 +11,6 @@ import java.util.List;
public interface AssessUserTargetMapper extends Mapper<AssessUserTarget> { public interface AssessUserTargetMapper extends Mapper<AssessUserTarget> {
AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(@Param("userId") Integer userId, @Param("issueId") String issueId,@Param("caseId") String caseId);
void batchInsert(@Param("list")List<AssessUserTarget> list);
} }

@ -2,6 +2,7 @@ package com.blockchain.server.yyyf.service;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.PractiseProDto; import com.blockchain.server.yyyf.dto.PractiseProDto;
import com.blockchain.server.yyyf.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
@ -90,4 +91,6 @@ public interface AssessUserService {
* @return void * @return void
**/ **/
void insert(AssessUser assessUser); void insert(AssessUser assessUser);
void initAssessUser(AssessUser assessUser, List<TrainCaseTargetDto> trainCaseTargeList );
} }

@ -1,13 +1,29 @@
package com.blockchain.server.yyyf.service; package com.blockchain.server.yyyf.service;
import com.blockchain.server.yyyf.dto.AssessUserTargetDto;
import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.entity.AssessUserTarget;
import java.util.List;
public interface AssessUserTargetService{ public interface AssessUserTargetService{
/**
* @description 根据assessUserId和code获取指标信息
* @param [assessUserId, code]
* @return com.blockchain.server.yyyf.entity.AssessUserTarget
**/
AssessUserTarget selectByAssessUserAndCode(String assessUserId, String code);
/**
* @description 更新
* @param [assessUserTarget]
* @return void
**/
void update(AssessUserTarget assessUserTarget);
/** /**
* @description 获取指标情况 * @description 通过assessUserId 获取指标答题情况
* @param [yyyfUserId, examId, caseId] * @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.AssessUserTargetDto * @return java.util.List<com.blockchain.server.yyyf.entity.AssessUserTarget>
**/ **/
AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(Integer yyyfUserId, String examId, String caseId); List<AssessUserTarget> selectAssessUserTargetByAssessUserId(String assessUserId);
} }

@ -1,7 +1,11 @@
package com.blockchain.server.yyyf.service.impl; package com.blockchain.server.yyyf.service.impl;
import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.train.dto.TrainCaseTargetDto;
import com.blockchain.server.yyyf.dto.PractiseProDto; import com.blockchain.server.yyyf.dto.PractiseProDto;
import com.blockchain.server.yyyf.entity.AssessUser; import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.mapper.AssessUserMapper; import com.blockchain.server.yyyf.mapper.AssessUserMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.mapper.AssessUserTaskMapper; import com.blockchain.server.yyyf.mapper.AssessUserTaskMapper;
@ -9,11 +13,14 @@ import com.blockchain.server.yyyf.service.AssessUserService;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -59,7 +66,8 @@ public class AssessUserServiceImpl implements AssessUserService {
@Override @Override
public AssessUser selectAssessUserById(String assessUserId) { public AssessUser selectAssessUserById(String assessUserId) {
return this.assessUserMapper.selectAssessUserById(assessUserId);
return this.assessUserMapper.selectByPrimaryKey(assessUserId);
} }
@Override @Override
@ -89,5 +97,23 @@ public class AssessUserServiceImpl implements AssessUserService {
this.assessUserMapper.insertSelective(assessUser); this.assessUserMapper.insertSelective(assessUser);
} }
@Override
public void initAssessUser(AssessUser assessUser, List<TrainCaseTargetDto> trainCaseTargeList ) {
List<AssessUserTarget> list=new ArrayList<>(trainCaseTargeList.size());
int j=1;
for(TrainCaseTargetDto trainCaseTargetDto :trainCaseTargeList){
AssessUserTarget assessUserTarget=new AssessUserTarget();
BeanUtils.copyProperties(trainCaseTargetDto,assessUserTarget);
assessUserTarget.setAssessUserId(assessUser.getId());
assessUserTarget.setTargetId(trainCaseTargetDto.getId());
assessUserTarget.setTargetName(trainCaseTargetDto.getName());
assessUserTarget.setSort(j++);
list.add(assessUserTarget);
}
this.assessUserMapper.insert(assessUser);
this.assessUserTargetMapper.batchInsert(list);
}
} }

@ -1,23 +1,46 @@
package com.blockchain.server.yyyf.service.impl; package com.blockchain.server.yyyf.service.impl;
import com.blockchain.server.yyyf.dto.AssessUserTargetDto;
import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper;
import com.blockchain.server.yyyf.service.AssessUserTargetService; import com.blockchain.server.yyyf.service.AssessUserTargetService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/** /**
* @version 1.0 * @version 1.0
* @className AssessUserProjectServiceImpl * @className AssessUserProjectServiceImpl
* @description * @description
*/ */
@Transactional(rollbackFor = Exception.class)
@Service @Service
public class AssessUserTargetServiceImpl implements AssessUserTargetService { public class AssessUserTargetServiceImpl implements AssessUserTargetService {
@Autowired @Autowired
private AssessUserTargetMapper assessUserTargetMapper; private AssessUserTargetMapper assessUserTargetMapper;
@Override
public AssessUserTarget selectByAssessUserAndCode(String assessUserId, String code) {
Example example=new Example(AssessUserTarget.class);
Example.Criteria criteria=example.createCriteria();
criteria.andCondition(" assess_user_id= ",assessUserId);
criteria.andCondition(" code = ",code);
return this.assessUserTargetMapper.selectOneByExample(example);
}
@Override @Override
public AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(Integer yyyfUserId, String examId, String caseId) { public void update(AssessUserTarget assessUserTarget) {
return this.assessUserTargetMapper.selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(yyyfUserId,examId,caseId); this.assessUserTargetMapper.updateByPrimaryKeySelective(assessUserTarget);
} }
@Override
public List<AssessUserTarget> selectAssessUserTargetByAssessUserId(String assessUserId) {
Example example=new Example(AssessUserTarget.class);
Example.Criteria criteria = example.createCriteria();
criteria.andCondition(" assess_user_id = " ,assessUserId);
return this.assessUserTargetMapper.selectByExample(example);
}
} }

@ -105,13 +105,14 @@
</sql> </sql>
<insert id="insert" parameterType="com.blockchain.server.yyyf.entity.AssessUser"> <insert id="insert" parameterType="com.blockchain.server.yyyf.entity.AssessUser">
insert into yyyf_server_assess_user ( id, train_id, issue_id, ss_practise_id, user_id, total_score, duration, duration_unit, start_time, end_time, case_id, achieve_ment_type, class_id, course_id) insert into yyyf_server_assess_user ( id, train_id, issue_id, ss_practise_id, user_id,user_name, total_score, duration, duration_unit, start_time, end_time, case_id, achieve_ment_type, class_id, course_id)
values( values(
#{id}, #{id},
#{trainId}, #{trainId},
#{issueId}, #{issueId},
#{ssPractiseId}, #{ssPractiseId},
#{userId}, #{userId},
#{userName},
#{totalScore}, #{totalScore},
#{duration}, #{duration},
#{durationUnit}, #{durationUnit},
@ -194,9 +195,6 @@
where achieve_ment_type=0 and issue_id=#{issueId} and user_id=#{userId} where achieve_ment_type=0 and issue_id=#{issueId} and user_id=#{userId}
ORDER BY start_time desc ORDER BY start_time desc
</select> </select>
<select id="selectAssessUserById" resultMap="YfServerAssessUserResultMap">
select * from yyyf_server_assess_user where id=#{assessUserId}
</select>
<select id="selectAssessUserListByIssueId" resultMap="YfServerAssessUserResultMap"> <select id="selectAssessUserListByIssueId" resultMap="YfServerAssessUserResultMap">
select * from yyyf_server_assess_user where issue_id=#{issueId} and achieve_ment_type = 1 select * from yyyf_server_assess_user where issue_id=#{issueId} and achieve_ment_type = 1

@ -47,26 +47,20 @@
t.duration_unit, t.duration_unit,
t.project_case_desc, t.project_case_desc,
</sql> </sql>
<select id="selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId"
resultType="com.blockchain.server.yyyf.dto.AssessUserTargetDto">
SELECT <insert id="batchInsert" parameterType="java.util.List">
u.id AS assessUserId, insert into yyyf_server_assess_user_target
t.id AS id, (id,assess_user_id, target_name, target_id, code, task_operate, task_rate,task_score, sort)
t.targe_id AS targeId, values
t.target_name AS targetName,
t.task_operate AS taskOperate,
t.task_rate AS taskRate,
t.task_score AS taskScore,
t. CODE AS CODE,
t.sort AS sort
FROM
yyyf_server_assess_user u
LEFT JOIN yyyf_server_assess_user_target t ON (
u.end_time IS NULL
AND u.case_id = #{caseId} and u.id=t.assess_user_id and u.user_id=#{userId}
AND u.issue_id = #{issueId} )
</select>
<foreach collection ="list" item="item" index= "index" separator =",">
( #{item.id,jdbcType=VARCHAR},
#{item.assessUserId,jdbcType=VARCHAR}, #{item.targetName,jdbcType=VARCHAR}, #{item.targetId,jdbcType=VARCHAR},
#{item.code,jdbcType=VARCHAR}, #{item.taskOperate,jdbcType=TINYINT}, #{item.taskRate,jdbcType=DECIMAL},
#{item.taskScore,jdbcType=DECIMAL}, #{item.sort,jdbcType=INTEGER}
)
</foreach >
</insert>
</mapper> </mapper>
Loading…
Cancel
Save