diff --git a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java index 9bc0659..53973ed 100644 --- a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java +++ b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java @@ -16,23 +16,22 @@ import java.util.Map; @Data public class YyyfUserDto implements Serializable { private static final long serialVersionUID = -6752296227958588252L; - /**传过来的用户id*/ + /** + * 传过来的用户id + */ private Integer userId; - /**用户名称*/ + /** + * 用户名称 + */ 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; } \ No newline at end of file diff --git a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java new file mode 100644 index 0000000..098ee51 --- /dev/null +++ b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/util/YyyfUserDtoUtils.java @@ -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; + } +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java index e57d7d6..18dceff 100644 --- a/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java +++ b/blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java @@ -9,6 +9,7 @@ import com.blockchain.common.base.dto.YyyfUserDto; import com.blockchain.common.base.util.HttpRequestUtil; import com.blockchain.common.base.util.RSACoderUtils; 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.enums.SmsCountEnum; import com.blockchain.server.user.common.enums.UserEnums; @@ -273,9 +274,9 @@ public class LoginController { */ private ResultDTO handleAfterLogin(UserMain userMain, String tokenType, HttpServletRequest request) { - String userId=userMain.getId(); + String userId = userMain.getId(); 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); UserBaseDTO userBaseDTO = userMainService.selectUserInfoById(userMain.getId()); userBaseDTO.setToken(token); @@ -317,32 +318,29 @@ public class LoginController { } /** - * @description 处理yyyf账号绑定 * @param [userId, tel, request] * @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; String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER); - + YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate); //如果有token,拿到用户信息,与以渔有方进行绑定 - if (redisTemplate.hasKey(yyyfTtoken)) { - YyyfUserDto yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(yyyfTtoken); - yyyfUserId = yyyfUserDto.getId(); + if (yyyfUserDto != null) { + yyyfUserId = yyyfUserDto.getUserId(); YyyfUser yyyfUser = this.yyyfUserService.selectByYyyfUserIdAndTel(yyyfUserId, tel); if (yyyfUser == null) { - this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getName()); + this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getUserName()); this.redisTemplate.delete(yyyfTtoken); - }else{ - if(!yyyfUser.getUserId().equals(userId)){ + } else { + if (!yyyfUser.getUserId().equals(userId)) { throw new UserException(UserEnums.USER_NOT_FORBID_OTHER_USER); } } - }else{ + } else { throw new UserException(UserEnums.USER_NOT_BIND_YYYF); } - return yyyfUserId; } } diff --git a/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml b/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml index edf2f92..2ce250b 100644 --- a/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml +++ b/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml @@ -1,7 +1,5 @@ server: port: 8101 - servlet: - context-path: /user #注册中心 eureka: client: diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java index b70c4a3..a2e143e 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java @@ -24,7 +24,7 @@ public class TrainCaseTargetDto implements Serializable { private String name; /** - * 任务目标运算符:1大于2小于3等于 + * 任务目标运算符:-1小于0等于1大于 */ private Integer taskOperate; /** @@ -43,5 +43,5 @@ public class TrainCaseTargetDto implements Serializable { /** * 指标id */ - private String targeId; + private String targetId; } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java index d17774e..1de143c 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java @@ -5,10 +5,13 @@ import com.blockchain.common.base.dto.ResultDTO; import com.blockchain.common.base.dto.TokenDTO; import com.blockchain.common.base.dto.YyyfUserDto; 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.dto.*; import com.blockchain.server.yyyf.entity.AssessUser; 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; @@ -18,7 +21,6 @@ import org.slf4j.LoggerFactory; 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.ValueOperations; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -54,169 +56,134 @@ public class LoginController { //存到redis中用于以渔有方用户与智信链用户进行绑定 - YyyfUserDto yyyfUserDto = new YyyfUserDto(); //登录返回的Data YyyfLoginDto yyyfLoginDto = new YyyfLoginDto(); yyyfLoginDto.setStatus(0); String userName = null; try { userName = new String(new BASE64Decoder().decodeBuffer(yyyfLoginRequestVo.getUserName().replaceAll(" ", "+")), "UTF-8"); - //根据案例id,考核id封装相关信息。 - //1、从缓存中取案列相关 - //0 考试 1 练习 2 不计分 3 教师、管理员的案例管理 - int reqType = yyyfLoginRequestVo.getReqType().intValue(); - int userType = yyyfLoginRequestVo.getUserType().intValue(); - Integer classId = yyyfLoginRequestVo.getClassId(); - Integer userId = yyyfLoginRequestVo.getUserId(); - Integer schoolId = yyyfLoginRequestVo.getSchoolId(); - - yyyfUserDto.setClassId(classId); - yyyfUserDto.setUserId(userId); - yyyfUserDto.setUserName(userName); - yyyfUserDto.setSchoolId(schoolId); - yyyfUserDto.setUserType(userType); - yyyfUserDto.setClassId(classId); - yyyfUserDto.setCourseId(yyyfLoginRequestVo.getCourserId()); - - - //以渔有方考核id - String examId = yyyfLoginRequestVo.getReqId(); - //试卷id(项目id) - 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); + } catch (IOException e) { + LOG.error(e.getMessage(), e); + } + //根据案例id,考核id封装相关信息。 + //1、从缓存中取案列相关 + //0 考试 1 练习 2 不计分 3 教师、管理员的案例管理 + int reqType = yyyfLoginRequestVo.getReqType().intValue(); + Integer classId = yyyfLoginRequestVo.getClassId(); + Integer userId = yyyfLoginRequestVo.getUserId(); + + + //以渔有方考核id + String examId = yyyfLoginRequestVo.getReqId(); + //试卷id(项目id) + String examPaperId = yyyfLoginRequestVo.getCaseId(); + + YyyfUserDto yyyfUserDto = new YyyfUserDto(); + yyyfUserDto.setUserName(userName); + yyyfUserDto.setUserId(userId); + yyyfUserDto.setUserType(yyyfLoginRequestVo.getUserType()); + + //做考试和练习 + if (0 == reqType || 1 == reqType) { + + AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); + if (assessUser == null) { + String assessUserId = IdGenerator.uuid(); + assessUser = new AssessUser(); + assessUser.setId(assessUserId); + 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); + assessUser.setUserName(userName); + + //获取案例信息 + HashOperations examPaperOpsForHash = redisTemplate.opsForHash(); + ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId); + List trainCaseTargeList = examPaperDto.getTrainCaseTargeList(); + this.assessUserService.initAssessUser(assessUser, trainCaseTargeList); + } + + + yyyfUserDto.setAssessUserId(assessUser.getId()); + + + HashOperations examDtoOpsForHash = redisTemplate.opsForHash(); + + //将参加考试的人员缓存 + HashOperations> studentOpsForHash = redisTemplate.opsForHash(); + //参加考试的人员id + List 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 examDtoOpsForHash = redisTemplate.opsForHash(); - - //将参加考试的人员缓存 - HashOperations> studentOpsForHash = redisTemplate.opsForHash(); - //参加考试的人员id - List 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); - } - - ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId); - if (examDto == null) { - 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(); - } - //如果等于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); - } + + ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId); + if (examDto == null) { + 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(); + } + //如果等于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 { - if (redisTemplate.hasKey(caseKey)) { - Map examMsgMap = (Map) redisTemplate.opsForValue().get(caseKey); - joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId")); - } - //缓存是考试,要进入练习,则不让进入 - if (joinStuIds != null && joinStuIds.stream() - .filter(stuIds -> (stuIds.equals(userId))).count() != 0) { - yyyfLoginDto.setStatus(1); - yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); - return handleAfterLogin(yyyfLoginDto, yyyfUserDto); - } - - ValueOperations studentAnsweValueOperations = redisTemplate.opsForValue(); - String studentAnswerDtoKey = YyyfConstant.ANSER_KEY + userId + examPaperId; - StudentAnswerDto studentAnswerDto = (StudentAnswerDto) studentAnsweValueOperations.get(studentAnswerDtoKey); - if (studentAnswerDto != null) { - //答题结果、且未提交 - Map 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 map = new HashMap(); - 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); - } - } + if (redisTemplate.hasKey(caseKey)) { + Map examMsgMap = (Map) redisTemplate.opsForValue().get(caseKey); + joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId")); + } + //缓存是考试,要进入练习,则不让进入 + if (joinStuIds != null && joinStuIds.stream() + .filter(stuIds -> (stuIds.equals(userId))).count() != 0) { + yyyfLoginDto.setStatus(1); + yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); + return handleAfterLogin(yyyfLoginDto, yyyfUserDto); } - //删除强制提醒的缓存 - redisTemplate.delete(YyyfConstant.ANSER_KEY + userId); - - /* ValueOperations 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 map = new HashMap(); - 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 map = new HashMap(); + map.put("examPaperId", examPaperId); + map.put("examId", examId); + + redisTemplate.opsForValue().set(caseKey, map); + redisTemplate.expire(caseKey, 2, TimeUnit.HOURS); } + return handleAfterLogin(yyyfLoginDto, yyyfUserDto); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java index 8d27238..49ff1aa 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java @@ -3,35 +3,33 @@ 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.common.base.util.YyyfUserDtoUtils; 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.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 lombok.SneakyThrows; 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 javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; /** * @author huangxl @@ -43,12 +41,10 @@ import java.util.concurrent.atomic.AtomicReference; @RequestMapping("/studentAnswer") public class StudentAnswerController { - private static final Logger LOG = LoggerFactory.getLogger(StudentAnswerController.class); - - @Autowired - private AssessUserService assessUserService; @Autowired private AssessUserTargetService assessUserTargetService; + @Autowired + private AssessUserService assessUserService; @Autowired private RedisTemplate redisTemplate; @@ -56,50 +52,64 @@ 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_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) { - - - - Integer yyyfUserId=yyyfUserDto.getUserId(); - String caseKey = YyyfConstant.CASE_KEY + yyyfUserId ; + public ResultDTO saveAnswer(@ApiParam(StudentAnswerApi.SaveAnswer.METHOD_YYYF_USER_ID) @RequestParam(name = "yyyfUserId") Integer yyyfUserId, + @ApiParam(StudentAnswerApi.SaveAnswer.METHOD_ASSESS_USER_ID) @RequestParam(name = "assessUserId") String assessUserId, + @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; if (redisTemplate.hasKey(caseKey)) { - Map map = (Map) redisTemplate.opsForValue().get(caseKey); - String caseId=map.get("examPaperId"); - String examId=map.get("examId"); - - HashOperations examPaperOpsForHash = redisTemplate.opsForHash(); - ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, caseId); - TrainCaseTargetDto trainCaseTargetDto =null; - - List 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 assessUserTarget = this.assessUserTargetService.selectByAssessUserAndCode(assessUserId, code); + assessUserTarget.setStudentRate(taskRate); + int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate()); + //最终指标结果一致 + if (assessUserTarget.getTaskOperate().intValue() == compareAnswer) { + answer = 0; + } else { + answer = 1; } + assessUserTarget.setAnswer(answer); + this.assessUserTargetService.update(assessUserTarget); redisTemplate.expire(caseKey, 2, TimeUnit.HOURS); - // redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS); - - - }else{ + } else { 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 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 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(); + } } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java index 463cf06..6625f57 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java @@ -9,8 +9,9 @@ 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_DTO = "以渔有方用户"; + public static final String METHOD_NOTE = "学生答题统一调用,调用成功,返回结果:0答案正确,1答案错误,-1系统错误"; + 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_STARGE_ID="指标id"; } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java deleted file mode 100644 index 7374cb8..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/AssessUserTargetDto.java +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java index 3d51d61..c50f9bc 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java @@ -48,7 +48,7 @@ public class AssessUser implements Serializable { * 得分 */ @Column(name = "total_score") - private BigDecimal totalScore; + private Double totalScore; /** * 时长 */ @@ -58,7 +58,7 @@ public class AssessUser implements Serializable { * 时长单位 */ @Column(name = "duration_unit") - private String durationUnit; + private String durationUnit="m"; /** * 开始时间 */ @@ -92,6 +92,10 @@ public class AssessUser implements Serializable { */ @Column(name = "course_id") private String courseId; - + /** + * 绑定的课程id + */ + @Column(name = "user_name") + private String userName; } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java index a6d6a40..efac4de 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTarget.java @@ -27,8 +27,8 @@ public class AssessUserTarget implements Serializable { /** * 指标id */ - @Column(name = "targe_id") - private String targeId; + @Column(name = "target_id") + private String targetId; /** * 指标名称 @@ -37,7 +37,7 @@ public class AssessUserTarget implements Serializable { private String targetName; /** - * 任务目标运算符:1大于2等于3小于 + * 任务目标运算符:-1小于0等于1大于 */ @Column(name = "task_operate") private Integer taskOperate; @@ -62,4 +62,14 @@ public class AssessUserTarget implements Serializable { */ @Column(name = "sort") private Integer sort; + /** + * 学生答题计算的指标 + */ + @Column(name = "student_rate") + private Double studentRate; + /** + * 学生是否完成指标,0完成,1未 + */ + @Column(name = "answer") + private Integer answer; } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java index 8173370..f6159a6 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/enums/UserEnums.java @@ -5,6 +5,7 @@ package com.blockchain.server.yyyf.enums; * @data 2019/2/21 20:53 */ 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_BIND_YYYF(1099, "该用户未绑定以渔有方或者以渔有方登录已失效", "The user does not bind yyyf", "該用戶未綁定以漁有方或者以漁有方登錄已失效"), USER_EXISTS(1100, "该用户已存在", "The user already exists", "該用戶已存在"), diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java index 7961d31..4f064eb 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java @@ -34,7 +34,7 @@ public interface AssessUserMapper extends Mapper { List selectAssessUserListByIssuerIdAndUserId(@Param("issueId") String issueId, @Param("userId") Integer userId); - AssessUser selectAssessUserById(@Param("assessUserId") String assessUserId); + List selectAssessUserListByIssueId(@Param("issueId") String issueId); diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java index 9637eea..3cd809c 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTargetMapper.java @@ -1,6 +1,5 @@ package com.blockchain.server.yyyf.mapper; -import com.blockchain.server.yyyf.dto.AssessUserTargetDto; import com.blockchain.server.yyyf.entity.AssessUserTarget; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -12,5 +11,6 @@ import java.util.List; public interface AssessUserTargetMapper extends Mapper { - AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(@Param("userId") Integer userId, @Param("issueId") String issueId,@Param("caseId") String caseId); + + void batchInsert(@Param("list")List list); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java index 781df51..b6eadfe 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java @@ -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.entity.AssessUser; @@ -90,4 +91,6 @@ public interface AssessUserService { * @return void **/ void insert(AssessUser assessUser); + + void initAssessUser(AssessUser assessUser, List trainCaseTargeList ); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java index 939b87b..7fc8a3f 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java @@ -1,13 +1,29 @@ package com.blockchain.server.yyyf.service; -import com.blockchain.server.yyyf.dto.AssessUserTargetDto; import com.blockchain.server.yyyf.entity.AssessUserTarget; +import java.util.List; + 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 获取指标情况 - * @param [yyyfUserId, examId, caseId] - * @return com.blockchain.server.yyyf.dto.AssessUserTargetDto + * @description 通过assessUserId 获取指标答题情况 + * @param [assessUserId] + * @return java.util.List **/ - AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(Integer yyyfUserId, String examId, String caseId); + List selectAssessUserTargetByAssessUserId(String assessUserId); } diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java index d9eff8d..0012358 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -1,7 +1,11 @@ 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.entity.AssessUser; +import com.blockchain.server.yyyf.entity.AssessUserTarget; import com.blockchain.server.yyyf.mapper.AssessUserMapper; import com.blockchain.server.yyyf.mapper.AssessUserTargetMapper; 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 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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import tk.mybatis.mapper.entity.Example; +import java.util.ArrayList; import java.util.List; /** @@ -59,7 +66,8 @@ public class AssessUserServiceImpl implements AssessUserService { @Override public AssessUser selectAssessUserById(String assessUserId) { - return this.assessUserMapper.selectAssessUserById(assessUserId); + + return this.assessUserMapper.selectByPrimaryKey(assessUserId); } @Override @@ -89,5 +97,23 @@ public class AssessUserServiceImpl implements AssessUserService { this.assessUserMapper.insertSelective(assessUser); } + @Override + public void initAssessUser(AssessUser assessUser, List trainCaseTargeList ) { + + List 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); + } + } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java index 443dbd8..5bde63d 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java @@ -1,23 +1,46 @@ 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.mapper.AssessUserTargetMapper; import com.blockchain.server.yyyf.service.AssessUserTargetService; 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; /** * @version 1.0 * @className AssessUserProjectServiceImpl * @description */ +@Transactional(rollbackFor = Exception.class) @Service public class AssessUserTargetServiceImpl implements AssessUserTargetService { @Autowired 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 - public AssessUserTargetDto selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(Integer yyyfUserId, String examId, String caseId) { - return this.assessUserTargetMapper.selectAssessUserTargetDtoByUserIdAndIssueIdAndCaseId(yyyfUserId,examId,caseId); + public void update(AssessUserTarget assessUserTarget) { + this.assessUserTargetMapper.updateByPrimaryKeySelective(assessUserTarget); } + + @Override + public List 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); + } + } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml index 7faf516..7a4767b 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml @@ -105,13 +105,14 @@ - 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( #{id}, #{trainId}, #{issueId}, #{ssPractiseId}, #{userId}, + #{userName}, #{totalScore}, #{duration}, #{durationUnit}, @@ -194,9 +195,6 @@ where achieve_ment_type=0 and issue_id=#{issueId} and user_id=#{userId} ORDER BY start_time desc - - SELECT - u.id AS assessUserId, - t.id AS id, - t.targe_id AS targeId, - 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} ) - + + insert into yyyf_server_assess_user_target + (id,assess_user_id, target_name, target_id, code, task_operate, task_rate,task_score, sort) + values + + ( #{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} + ) + + + \ No newline at end of file