|
|
|
|
@ -6,6 +6,7 @@ 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;
|
|
|
|
|
@ -14,6 +15,7 @@ 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.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@ -29,6 +31,8 @@ public class CgxqycController {
|
|
|
|
|
StuGradeMapper stuGradeMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
CompareListsUtil compareListsUtil;
|
|
|
|
|
@Autowired
|
|
|
|
|
ScoreService scoreService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/selectCgxqycAnswer")
|
|
|
|
|
@ApiOperation("采购需求预测-回显")
|
|
|
|
|
@ -44,33 +48,38 @@ public class CgxqycController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @PostMapping("/commitCgxqycAnswer")
|
|
|
|
|
// @ApiOperation("采购需求预测-提交")
|
|
|
|
|
// @AnonymousAccess
|
|
|
|
|
// public ResultEntity commitCgxqycAnswer(@RequestBody CgxqycStuAnswer cgxqycStuAnswer, @RequestParam String userId) {
|
|
|
|
|
// CgxqycAnswer cgxqycAnswer = cgxqycAnswerMapper.selectByExample(new CgxqycAnswerExample()).get(0);
|
|
|
|
|
// String monthlyDataStu = cgxqycStuAnswer.getMonthlyData();
|
|
|
|
|
// String monthlyData = cgxqycAnswer.getMonthlyData();
|
|
|
|
|
// int monthlyDataErrorCount =compareListsUtil.compareLists(monthlyDataStu, monthlyData).getErrorCount();
|
|
|
|
|
// String seasonalIndexStu = cgxqycStuAnswer.getSeasonalIndex();
|
|
|
|
|
// String seasonalIndex = cgxqycAnswer.getSeasonalIndex();
|
|
|
|
|
// int seasonalIndexErrorCount = compareListsUtil.compareLists(seasonalIndexStu, seasonalIndex).getErrorCount();
|
|
|
|
|
// String demandForecastStu = cgxqycStuAnswer.getDemandForecast();
|
|
|
|
|
// String demandForecast = cgxqycAnswer.getDemandForecast();
|
|
|
|
|
// int demandForecastErrorCount = compareListsUtil.compareLists(demandForecastStu, demandForecast).getErrorCount();
|
|
|
|
|
// int errorCount = monthlyDataErrorCount + seasonalIndexErrorCount + demandForecastErrorCount;
|
|
|
|
|
// //先查询是否提交过
|
|
|
|
|
// 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) {
|
|
|
|
|
// //新建学生成绩
|
|
|
|
|
//// stuGradeMapper.insert()
|
|
|
|
|
// } else {
|
|
|
|
|
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
@PostMapping("/commitCgxqycAnswer")
|
|
|
|
|
@ApiOperation("采购需求预测-提交")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity commitCgxqycAnswer(@RequestBody CgxqycStuAnswer cgxqycStuAnswer, @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 cgxqycAnswer = cgxqycAnswerMapper.selectByExample(new CgxqycAnswerExample()).get(0);
|
|
|
|
|
String monthlyDataStu = cgxqycStuAnswer.getMonthlyData();
|
|
|
|
|
String monthlyData = cgxqycAnswer.getMonthlyData();
|
|
|
|
|
int monthlyDataErrorCount =compareListsUtil.compareLists(monthlyDataStu, monthlyData).getErrorCount();
|
|
|
|
|
String seasonalIndexStu = cgxqycStuAnswer.getSeasonalIndex();
|
|
|
|
|
String seasonalIndex = cgxqycAnswer.getSeasonalIndex();
|
|
|
|
|
int seasonalIndexErrorCount = compareListsUtil.compareLists(seasonalIndexStu, seasonalIndex).getErrorCount();
|
|
|
|
|
String demandForecastStu = cgxqycStuAnswer.getDemandForecast();
|
|
|
|
|
String demandForecast = cgxqycAnswer.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, "提交失败");
|
|
|
|
|
}
|
|
|
|
|
//新建学生成绩
|
|
|
|
|
// stuGradeMapper.insert()
|
|
|
|
|
}else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|