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.
155 lines
6.5 KiB
Java
155 lines
6.5 KiB
Java
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.CgxqycAnswerMapper;
|
|
import com.sztzjy.linkCommerce.mapper.CgxqycStuAnswerMapper;
|
|
import com.sztzjy.linkCommerce.mapper.GyspgyxzStuAnswerMapper;
|
|
import com.sztzjy.linkCommerce.mapper.StuGradeMapper;
|
|
import com.sztzjy.linkCommerce.service.ScoreService;
|
|
import com.sztzjy.linkCommerce.util.CompareListsUtil;
|
|
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_GYQDGL,MODULE_GYSPGYXZ")
|
|
@RequestMapping("api/gyspgyxz")
|
|
@RestController
|
|
public class GyspgyxzController {
|
|
@Autowired
|
|
GyspgyxzStuAnswerMapper gyspgyxzStuAnswerMapper;
|
|
@Autowired
|
|
StuGradeMapper stuGradeMapper;
|
|
@Autowired
|
|
CompareListsUtil compareListsUtil;
|
|
@Autowired
|
|
ScoreService scoreService;
|
|
|
|
@PostMapping("/selectGyspgyxzStuAnswer")
|
|
@ApiOperation("供应商评估与选择-回显")
|
|
@AnonymousAccess
|
|
public ResultEntity<GyspgyxzStuAnswer> selectGyspgyxzAnswer(@RequestParam String userId) {
|
|
GyspgyxzStuAnswerExample example = new GyspgyxzStuAnswerExample();
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
List<GyspgyxzStuAnswer> list = gyspgyxzStuAnswerMapper.selectByExample(example);
|
|
if (list == null || list.isEmpty()) {
|
|
return new ResultEntity<>(HttpStatus.OK, "未提交");
|
|
} else {
|
|
return new ResultEntity<>(HttpStatus.OK, "供应商评估与选择-回显", list.get(0));
|
|
}
|
|
}
|
|
|
|
@PostMapping("/commitGyspgyxzAnswer")
|
|
@ApiOperation("供应商评估与选择-提交")
|
|
@AnonymousAccess
|
|
public ResultEntity commitGyspgyxzAnswer(@RequestBody GyspgyxzStuAnswer stuAnswer, @RequestParam String userId) {
|
|
//先查询是否提交过
|
|
StuGradeExample stuGradeExample = new StuGradeExample();
|
|
stuGradeExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(Constant.PRO_GYQDGL).andModuleEqualTo(Constant.MODULE_GYSPGYXZ);
|
|
List<StuGrade> stuGradeList = stuGradeMapper.selectByExample(stuGradeExample);
|
|
if(stuGradeList.isEmpty() || stuGradeList == null){
|
|
int errorCount=0;
|
|
if(stuAnswer.getQualityWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getQualityWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.15))<0 || weight.compareTo(BigDecimal.valueOf(0.25))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getPriceWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getPriceWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.1))<0 || weight.compareTo(BigDecimal.valueOf(0.2))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getStabilityWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getStabilityWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.1))<0 || weight.compareTo(BigDecimal.valueOf(0.2))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getReputationWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getReputationWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.1))<0 || weight.compareTo(BigDecimal.valueOf(0.2))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getSupportWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getSupportWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.05))<0 || weight.compareTo(BigDecimal.valueOf(0.15))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getMoqWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getMoqWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.05))<0 || weight.compareTo(BigDecimal.valueOf(0.15))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getVarietyWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getVarietyWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.05))<0 || weight.compareTo(BigDecimal.valueOf(0.15))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
if(stuAnswer.getLogisticsWeight()!=null){
|
|
BigDecimal weight = stuAnswer.getLogisticsWeight();
|
|
if(weight.compareTo(BigDecimal.valueOf(0.05))<0 || weight.compareTo(BigDecimal.valueOf(0.15))>0){
|
|
errorCount++;
|
|
}
|
|
}else {
|
|
errorCount++;
|
|
}
|
|
Boolean aBoolean = scoreService.insertScore(userId, Constant.PRO_GYQDGL, Constant.MODULE_GYSPGYXZ, BigDecimal.valueOf(100 - errorCount), null);
|
|
stuAnswer.setId(UUID.randomUUID().toString());
|
|
gyspgyxzStuAnswerMapper.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_GYQDGL,Constant.MODULE_GYSPGYXZ);
|
|
if(b){
|
|
GyspgyxzStuAnswerExample example = new GyspgyxzStuAnswerExample();
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
gyspgyxzStuAnswerMapper.deleteByExample(example);
|
|
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
|
|
}else {
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|