You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
4.2 KiB
Java
99 lines
4.2 KiB
Java
|
1 year ago
|
package com.sztzjy.linkCommerce.controller.stu;
|
||
|
|
|
||
|
|
import com.sztzjy.linkCommerce.annotation.AnonymousAccess;
|
||
|
|
import com.sztzjy.linkCommerce.config.Constant;
|
||
|
|
import com.sztzjy.linkCommerce.entity.*;
|
||
|
|
import com.sztzjy.linkCommerce.mapper.CpbxfxAnswerMapper;
|
||
|
|
import com.sztzjy.linkCommerce.mapper.CpbxfxStuAnswerMapper;
|
||
|
|
import com.sztzjy.linkCommerce.mapper.StuGradeMapper;
|
||
|
|
import com.sztzjy.linkCommerce.service.ScoreService;
|
||
|
|
import com.sztzjy.linkCommerce.util.ResultEntity;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.http.HttpStatus;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import java.math.BigDecimal;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.UUID;
|
||
|
|
|
||
|
|
@Api(tags = "产品表现分析 PRO_CPPGYKH MODULE_CPBXFX")
|
||
|
|
@RequestMapping("api/cpbxfx")
|
||
|
|
@RestController
|
||
|
|
public class CpbxfxController {
|
||
|
|
@Autowired
|
||
|
|
CpbxfxStuAnswerMapper cpbxfxStuAnswerMapper;
|
||
|
|
@Autowired
|
||
|
|
ScoreService scoreService;
|
||
|
|
@Autowired
|
||
|
|
StuGradeMapper stuGradeMapper;
|
||
|
|
@Autowired
|
||
|
|
CpbxfxAnswerMapper cpbxfxAnswerMapper;
|
||
|
|
|
||
|
|
@PostMapping("/selectCpbxfxStuAnswer")
|
||
|
|
@ApiOperation("产品表现分析-回显")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResultEntity<CpbxfxStuAnswer> selectCpbxfxStuAnswer(@RequestParam String userId) {
|
||
|
|
CpbxfxStuAnswerExample example = new CpbxfxStuAnswerExample();
|
||
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
||
|
|
List<CpbxfxStuAnswer> list = cpbxfxStuAnswerMapper.selectByExample(example);
|
||
|
|
if (list == null || list.isEmpty()) {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "未提交");
|
||
|
|
} else {
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "产品表现分析-回显", list.get(0));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/commitCpbxfxAnswer")
|
||
|
|
@ApiOperation("产品表现分析-提交")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResultEntity commitCgcpdwAnswer(@RequestBody CpbxfxStuAnswer stuAnswer, @RequestParam String userId) {
|
||
|
|
//先查询是否提交过
|
||
|
|
StuGradeExample stuGradeExample = new StuGradeExample();
|
||
|
|
stuGradeExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(Constant.PRO_CPPGYKH).andModuleEqualTo(Constant.MODULE_CPBXFX);
|
||
|
|
List<StuGrade> stuGradeList = stuGradeMapper.selectByExample(stuGradeExample);
|
||
|
|
if(stuGradeList.isEmpty() || stuGradeList == null){
|
||
|
|
CpbxfxAnswer answer = cpbxfxAnswerMapper.selectByExample(new CpbxfxAnswerExample()).get(0);
|
||
|
|
int errorCount=0;
|
||
|
|
if(!answer.getQualifiedRate().equals(stuAnswer.getQualifiedRate())){
|
||
|
|
errorCount++;
|
||
|
|
}
|
||
|
|
if(!answer.getResponseTime().equals(stuAnswer.getResponseTime())){
|
||
|
|
errorCount++;
|
||
|
|
}
|
||
|
|
if(!answer.getUserRating().equals(stuAnswer.getUserRating())){
|
||
|
|
errorCount++;
|
||
|
|
}
|
||
|
|
if(!answer.getReturnRate().equals(stuAnswer.getReturnRate())){
|
||
|
|
errorCount++;
|
||
|
|
}
|
||
|
|
Boolean aBoolean = scoreService.insertScore(userId, Constant.PRO_CPPGYKH, Constant.MODULE_CPBXFX, BigDecimal.valueOf(100 - errorCount), null);
|
||
|
|
stuAnswer.setId(UUID.randomUUID().toString());
|
||
|
|
cpbxfxStuAnswerMapper.insert(stuAnswer);
|
||
|
|
if(aBoolean){
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "提交成功");
|
||
|
|
}else {
|
||
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败");
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@PostMapping("/restartTraining")
|
||
|
|
@ApiOperation("产品表现分析-重新实训")
|
||
|
|
@AnonymousAccess
|
||
|
|
public ResultEntity restartTraining(@RequestParam String userId) {
|
||
|
|
Boolean b=scoreService.deleteScore(userId,Constant.PRO_CPPGYKH,Constant.MODULE_CPBXFX);
|
||
|
|
if(b){
|
||
|
|
CpbxfxStuAnswerExample example = new CpbxfxStuAnswerExample();
|
||
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
||
|
|
cpbxfxStuAnswerMapper.deleteByExample(example);
|
||
|
|
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
|
||
|
|
}else {
|
||
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|