修改公共接口

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.CgxqycAnswerMapper;
import com.sztzjy.linkCommerce.mapper.CgxqycStuAnswerMapper; import com.sztzjy.linkCommerce.mapper.CgxqycStuAnswerMapper;
import com.sztzjy.linkCommerce.mapper.StuGradeMapper; import com.sztzjy.linkCommerce.mapper.StuGradeMapper;
import com.sztzjy.linkCommerce.service.ScoreService;
import com.sztzjy.linkCommerce.util.CompareListsUtil; import com.sztzjy.linkCommerce.util.CompareListsUtil;
import com.sztzjy.linkCommerce.util.ResultEntity; import com.sztzjy.linkCommerce.util.ResultEntity;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,6 +31,8 @@ public class CgxqycController {
StuGradeMapper stuGradeMapper; StuGradeMapper stuGradeMapper;
@Autowired @Autowired
CompareListsUtil compareListsUtil; CompareListsUtil compareListsUtil;
@Autowired
ScoreService scoreService;
@PostMapping("/selectCgxqycAnswer") @PostMapping("/selectCgxqycAnswer")
@ApiOperation("采购需求预测-回显") @ApiOperation("采购需求预测-回显")
@ -44,33 +48,38 @@ public class CgxqycController {
} }
} }
// @PostMapping("/commitCgxqycAnswer") @PostMapping("/commitCgxqycAnswer")
// @ApiOperation("采购需求预测-提交") @ApiOperation("采购需求预测-提交")
// @AnonymousAccess @AnonymousAccess
// public ResultEntity commitCgxqycAnswer(@RequestBody CgxqycStuAnswer cgxqycStuAnswer, @RequestParam String userId) { public ResultEntity commitCgxqycAnswer(@RequestBody CgxqycStuAnswer cgxqycStuAnswer, @RequestParam String userId) {
// CgxqycAnswer cgxqycAnswer = cgxqycAnswerMapper.selectByExample(new CgxqycAnswerExample()).get(0); //先查询是否提交过
// String monthlyDataStu = cgxqycStuAnswer.getMonthlyData(); StuGradeExample stuGradeExample = new StuGradeExample();
// String monthlyData = cgxqycAnswer.getMonthlyData(); stuGradeExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(Constant.PRO_GYQDGL).andModuleEqualTo(Constant.MODULE_CGXQYC);
// int monthlyDataErrorCount =compareListsUtil.compareLists(monthlyDataStu, monthlyData).getErrorCount(); List<StuGrade> stuGradeList = stuGradeMapper.selectByExample(stuGradeExample);
// String seasonalIndexStu = cgxqycStuAnswer.getSeasonalIndex(); if(stuGradeList.isEmpty() || stuGradeList == null){
// String seasonalIndex = cgxqycAnswer.getSeasonalIndex(); CgxqycAnswer cgxqycAnswer = cgxqycAnswerMapper.selectByExample(new CgxqycAnswerExample()).get(0);
// int seasonalIndexErrorCount = compareListsUtil.compareLists(seasonalIndexStu, seasonalIndex).getErrorCount(); String monthlyDataStu = cgxqycStuAnswer.getMonthlyData();
// String demandForecastStu = cgxqycStuAnswer.getDemandForecast(); String monthlyData = cgxqycAnswer.getMonthlyData();
// String demandForecast = cgxqycAnswer.getDemandForecast(); int monthlyDataErrorCount =compareListsUtil.compareLists(monthlyDataStu, monthlyData).getErrorCount();
// int demandForecastErrorCount = compareListsUtil.compareLists(demandForecastStu, demandForecast).getErrorCount(); String seasonalIndexStu = cgxqycStuAnswer.getSeasonalIndex();
// int errorCount = monthlyDataErrorCount + seasonalIndexErrorCount + demandForecastErrorCount; String seasonalIndex = cgxqycAnswer.getSeasonalIndex();
// //先查询是否提交过 int seasonalIndexErrorCount = compareListsUtil.compareLists(seasonalIndexStu, seasonalIndex).getErrorCount();
// StuGradeExample stuGradeExample = new StuGradeExample(); String demandForecastStu = cgxqycStuAnswer.getDemandForecast();
// stuGradeExample.createCriteria().andUserIdEqualTo(userId).andProjectEqualTo(Constant.PRO_GYQDGL).andModuleEqualTo(Constant.MODULE_CGXQYC); String demandForecast = cgxqycAnswer.getDemandForecast();
// List<StuGrade> stuGradeList = stuGradeMapper.selectByExample(stuGradeExample); int demandForecastErrorCount = compareListsUtil.compareLists(demandForecastStu, demandForecast).getErrorCount();
// if (stuGradeList.isEmpty() || stuGradeList == null) { int errorCount = monthlyDataErrorCount + seasonalIndexErrorCount + demandForecastErrorCount;
// //新建学生成绩 Boolean aBoolean = scoreService.insertScore(userId, Constant.PRO_GYQDGL, Constant.MODULE_CGXQYC, BigDecimal.valueOf(100 - errorCount), null);
//// stuGradeMapper.insert() if(aBoolean){
// } else { return new ResultEntity<>(HttpStatus.OK, "提交成功");
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "已提交过"); }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 { 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; private StuGradeMapper stuGradeMapper;
@Override public Boolean submitScoreCalculation(StuGrade stuGrade) {
public void submitScoreCalculation(StuGrade stuGrade) {
StuGradeExample stuGradeExample = new StuGradeExample(); StuGradeExample stuGradeExample = new StuGradeExample();
stuGradeExample.createCriteria() stuGradeExample.createCriteria()
@ -45,20 +44,11 @@ public class ScoreServiceImpl implements ScoreService {
stuGrade = scoreCalculation(stuGrade); stuGrade = scoreCalculation(stuGrade);
stuGradeMapper.insertSelective(stuGrade); int i = stuGradeMapper.insertSelective(stuGrade);
return i==1;
}else { }else {
//更新成绩 return false;
String id = stuGradeList.get(0).getId();
stuGrade.setId(id);
stuGrade = scoreCalculation(stuGrade);
stuGradeMapper.updateByPrimaryKeyWithBLOBs(stuGrade);
} }
} }
@Autowired @Autowired
@ -71,7 +61,7 @@ public class ScoreServiceImpl implements ScoreService {
//根据用户ID查询数据 //根据用户ID查询数据
@Override @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 userinfoExample = new UserinfoExample();
userinfoExample.createCriteria().andUserIdEqualTo(userId); userinfoExample.createCriteria().andUserIdEqualTo(userId);
List<Userinfo> userinfoList = userinfoMapper.selectByExample(userinfoExample); List<Userinfo> userinfoList = userinfoMapper.selectByExample(userinfoExample);
@ -92,7 +82,8 @@ public class ScoreServiceImpl implements ScoreService {
userinfo.getSchoolClassId(), userinfo.getSchoolClassId(),
schoolClassInfo.getClassName() schoolClassInfo.getClassName()
,context); ,context);
submitScoreCalculation(stuGrade); Boolean aBoolean = submitScoreCalculation(stuGrade);
return aBoolean;
}else { }else {
throw new ServiceException(HttpStatus.BAD_REQUEST,"用户数据不存在!"); throw new ServiceException(HttpStatus.BAD_REQUEST,"用户数据不存在!");
} }

Loading…
Cancel
Save