|
|
|
|
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.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;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "采购需求预测相关 PRO_GYQDGL,MODULE_CGXQYC")
|
|
|
|
|
@RequestMapping("api/cgxqyc")
|
|
|
|
|
@RestController
|
|
|
|
|
public class CgxqycController {
|
|
|
|
|
@Autowired
|
|
|
|
|
CgxqycStuAnswerMapper cgxqycStuAnswerMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
CgxqycAnswerMapper cgxqycAnswerMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
StuGradeMapper stuGradeMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
CompareListsUtil compareListsUtil;
|
|
|
|
|
@Autowired
|
|
|
|
|
ScoreService scoreService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/selectCgxqycStuAnswer")
|
|
|
|
|
@ApiOperation("采购需求预测-回显")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity<CgxqycStuAnswer> selectCgxqycAnswer(@RequestParam String userId) {
|
|
|
|
|
CgxqycStuAnswerExample example = new CgxqycStuAnswerExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId);
|
|
|
|
|
List<CgxqycStuAnswer> list = cgxqycStuAnswerMapper.selectByExample(example);
|
|
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "未提交");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "采购需求预测-回显", list.get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/commitCgxqycAnswer")
|
|
|
|
|
@ApiOperation("采购需求预测-提交")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity commitCgxqycAnswer(@RequestBody CgxqycStuAnswer stuAnswer, @RequestParam String userId) {
|
|
|
|
|
//先查询是否提交过
|
|
|
|
|
StuGradeExample stuGradeExample = new StuGradeExample();
|
|
|
|
|
stuGradeExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(Constant.PRO_GYQDGL).andModuleEqualTo(Constant.MODULE_CGXQYC);
|
|
|
|
|
List<StuGrade> stuGradeList = stuGradeMapper.selectByExample(stuGradeExample);
|
|
|
|
|
if(stuGradeList.isEmpty() || stuGradeList == null){
|
|
|
|
|
CgxqycAnswer answer = cgxqycAnswerMapper.selectByExample(new CgxqycAnswerExample()).get(0);
|
|
|
|
|
String monthlyDataStu = stuAnswer.getMonthlyData();
|
|
|
|
|
String monthlyData = answer.getMonthlyData();
|
|
|
|
|
int monthlyDataErrorCount =compareListsUtil.compareLists(monthlyDataStu, monthlyData).getErrorCount();
|
|
|
|
|
String seasonalIndexStu = stuAnswer.getSeasonalIndex();
|
|
|
|
|
String seasonalIndex = answer.getSeasonalIndex();
|
|
|
|
|
int seasonalIndexErrorCount = compareListsUtil.compareLists(seasonalIndexStu, seasonalIndex).getErrorCount();
|
|
|
|
|
String demandForecastStu = stuAnswer.getDemandForecast();
|
|
|
|
|
String demandForecast = answer.getDemandForecast();
|
|
|
|
|
int demandForecastErrorCount = compareListsUtil.compareLists(demandForecastStu, demandForecast).getErrorCount();
|
|
|
|
|
int errorCount = monthlyDataErrorCount + seasonalIndexErrorCount + demandForecastErrorCount;
|
|
|
|
|
Boolean aBoolean = scoreService.insertScore(userId, Constant.PRO_GYQDGL, Constant.MODULE_CGXQYC, BigDecimal.valueOf(100 - errorCount), null);
|
|
|
|
|
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_CGXQYC);
|
|
|
|
|
if(b){
|
|
|
|
|
CgxqycStuAnswerExample cgxqycStuAnswerExample = new CgxqycStuAnswerExample();
|
|
|
|
|
cgxqycStuAnswerExample.createCriteria().andUserIdEqualTo(userId);
|
|
|
|
|
cgxqycStuAnswerMapper.deleteByExample(cgxqycStuAnswerExample);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "重新实训成功");
|
|
|
|
|
}else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|