修改公共接口

main
yz 1 year ago
parent 412dd0a4a7
commit b8b300ad1c

@ -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, "已提交过");
}
}

@ -11,8 +11,7 @@ import java.math.BigDecimal;
*/
public interface ScoreService {
void submitScoreCalculation(StuGrade stuGrade);
//查询学生信息
void selectByUserId(String userId, @ApiParam("大模块")String project,@ApiParam("小模块") String module, BigDecimal score,@ApiParam("主观内容") String context);
//新增学生成绩信息
Boolean insertScore(String userId, @ApiParam("大模块")String project,@ApiParam("小模块") String module, BigDecimal score,@ApiParam("主观内容") String context);
}

@ -26,8 +26,7 @@ public class ScoreServiceImpl implements ScoreService {
private StuGradeMapper stuGradeMapper;
@Override
public void submitScoreCalculation(StuGrade stuGrade) {
public Boolean submitScoreCalculation(StuGrade stuGrade) {
StuGradeExample stuGradeExample = new StuGradeExample();
stuGradeExample.createCriteria()
@ -45,20 +44,11 @@ public class ScoreServiceImpl implements ScoreService {
stuGrade = scoreCalculation(stuGrade);
stuGradeMapper.insertSelective(stuGrade);
int i = stuGradeMapper.insertSelective(stuGrade);
return i==1;
}else {
//更新成绩
String id = stuGradeList.get(0).getId();
stuGrade.setId(id);
stuGrade = scoreCalculation(stuGrade);
stuGradeMapper.updateByPrimaryKeyWithBLOBs(stuGrade);
return false;
}
}
@Autowired
@ -71,7 +61,7 @@ public class ScoreServiceImpl implements ScoreService {
//根据用户ID查询数据
@Override
public void selectByUserId(String userId,String project,String module,BigDecimal score,String context) {
public Boolean insertScore(String userId,String project,String module,BigDecimal score,String context) {
UserinfoExample userinfoExample = new UserinfoExample();
userinfoExample.createCriteria().andUserIdEqualTo(userId);
List<Userinfo> userinfoList = userinfoMapper.selectByExample(userinfoExample);
@ -92,7 +82,8 @@ public class ScoreServiceImpl implements ScoreService {
userinfo.getSchoolClassId(),
schoolClassInfo.getClassName()
,context);
submitScoreCalculation(stuGrade);
Boolean aBoolean = submitScoreCalculation(stuGrade);
return aBoolean;
}else {
throw new ServiceException(HttpStatus.BAD_REQUEST,"用户数据不存在!");
}

Loading…
Cancel
Save