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.*; 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 = "产品问题诊断-Kano模型 PRO_CPPGYKH MODULE_CPWTZD_KANOMX") @RequestMapping("api/cpwtzdkanomx") @RestController public class CpwtzdKanomxController { @Autowired CpwtzdKanomxStuAnswerMapper cpwtzdKanomxStuAnswerMapper; @Autowired ScoreService scoreService; @Autowired StuGradeMapper stuGradeMapper; @Autowired CpwtzdKanomxAnswerMapper cpwtzdKanomxAnswerMapper; @PostMapping("/selectCpwtzdKanomxStuAnswer") @ApiOperation("产品问题诊断-KANO模型-回显") @AnonymousAccess public ResultEntity selectCpwtzdKanomxStuAnswer(@RequestParam String userId) { CpwtzdKanomxStuAnswerExample example = new CpwtzdKanomxStuAnswerExample(); example.createCriteria().andUserIdEqualTo(userId); List list = cpwtzdKanomxStuAnswerMapper.selectByExample(example); if (list == null || list.isEmpty()) { return new ResultEntity<>(HttpStatus.OK, "未提交"); } else { return new ResultEntity<>(HttpStatus.OK, "产品问题诊断-KANO模型-回显", list.get(0)); } } @PostMapping("/commitCpwtzdKanomxAnswer") @ApiOperation("产品问题诊断-KANO模型-提交") @AnonymousAccess public ResultEntity commitCpwtzdKanomxAnswer(@RequestBody CpwtzdKanomxStuAnswer stuAnswer, @RequestParam String userId) { //先查询是否提交过 StuGradeExample stuGradeExample = new StuGradeExample(); stuGradeExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(Constant.PRO_CPPGYKH).andModuleEqualTo(Constant.MODULE_CPWTZD_KANOMX); List stuGradeList = stuGradeMapper.selectByExample(stuGradeExample); if(stuGradeList.isEmpty() || stuGradeList == null){ CpwtzdKanomxAnswer answer = cpwtzdKanomxAnswerMapper.selectByExample(new CpwtzdKanomxAnswerExample()).get(0); int errorCount=0; if(!answer.getRw4One().equals(stuAnswer.getRw4One())){ errorCount++; } if(!answer.getRw4Two().equals(stuAnswer.getRw4Two())){ errorCount++; } if(!answer.getRw4Three().equals(stuAnswer.getRw4Three())){ errorCount++; } if(!answer.getRw5One().equals(stuAnswer.getRw5One())){ errorCount++; } if(!answer.getRw5Two().equals(stuAnswer.getRw5Two())){ errorCount++; } if(!answer.getRw5Three().equals(stuAnswer.getRw5Three())){ errorCount++; } Boolean aBoolean = scoreService.insertScore(userId, Constant.PRO_CPPGYKH, Constant.MODULE_CPWTZD_KANOMX, BigDecimal.valueOf(100 - errorCount), null); stuAnswer.setId(UUID.randomUUID().toString()); cpwtzdKanomxStuAnswerMapper.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("产品问题诊断-Kano模型-重新实训") @AnonymousAccess public ResultEntity restartTraining(@RequestParam String userId) { Boolean b=scoreService.deleteScore(userId,Constant.PRO_CPPGYKH,Constant.MODULE_CPWTZD_KANOMX); if(b){ CpwtzdKanomxStuAnswerExample example = new CpwtzdKanomxStuAnswerExample(); example.createCriteria().andUserIdEqualTo(userId); cpwtzdKanomxStuAnswerMapper.deleteByExample(example); return new ResultEntity<>(HttpStatus.OK, "重新实训成功"); }else { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败"); } } }