|
@@ -24,6 +24,7 @@ import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -215,62 +216,70 @@ public class SmartEvaluateTeacherController implements SmartEvaluateTeacherContr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PassToken
|
|
@PassToken
|
|
|
- public CommonResult evaluateScore(JSONObject jsonObject) {
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public CommonResult evaluateScore(JSONObject jsonObject) throws Exception {
|
|
|
SimpleEvaluateScore simpleEvaluateScore = null;
|
|
SimpleEvaluateScore simpleEvaluateScore = null;
|
|
|
try {
|
|
try {
|
|
|
simpleEvaluateScore = JSONObject.parseObject(jsonObject.toString(), SimpleEvaluateScore.class);
|
|
simpleEvaluateScore = JSONObject.parseObject(jsonObject.toString(), SimpleEvaluateScore.class);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- return CommonResult.errorMsg("参数格式错误");
|
|
|
|
|
|
|
+ //return CommonResult.errorMsg("参数格式错误");
|
|
|
|
|
+ throw new Exception("参数格式错误!");
|
|
|
}
|
|
}
|
|
|
- SmartEvaluateTeacher teacher = smartEvaluateTeacherService.getSmartEvaluateTeacherById(simpleEvaluateScore.getId());
|
|
|
|
|
- teacher.setLowingScore(simpleEvaluateScore.getLowingScore());
|
|
|
|
|
- teacher.setTotalScore(simpleEvaluateScore.getTotalScore());
|
|
|
|
|
- JSONObject desScore = new JSONObject();
|
|
|
|
|
- List<SmartEvaluateTdetailList> mainList = simpleEvaluateScore.getSimpleScoreList();
|
|
|
|
|
- List<SmartEvaluateTdetail> lse = new ArrayList<>();
|
|
|
|
|
- for (int i = 0; i < mainList.size(); i++) {
|
|
|
|
|
- if (mainList.get(i).getDeleted() == 0) {
|
|
|
|
|
- desScore.put(mainList.get(i).getScoreItem(), mainList.get(i).getOwnNum());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ SmartEvaluateTeacher teacher = smartEvaluateTeacherService.getSmartEvaluateTeacherById(simpleEvaluateScore.getId());
|
|
|
|
|
+ if (teacher == null) {
|
|
|
|
|
+ //return CommonResult.fail("教师评分数据为空");
|
|
|
|
|
+ throw new Exception("教师评分数据为空!");
|
|
|
}
|
|
}
|
|
|
- SmartEvaluateTdetail mainLse = new SmartEvaluateTdetail();
|
|
|
|
|
- mainLse.setId(mainList.get(i).getId() == null ? (int) UUIDUtil.generateID() : mainList.get(i).getId());
|
|
|
|
|
-// mainLse.setCardNo(teacher.getCardNo());
|
|
|
|
|
-// mainLse.setTerm(teacher.getTerm());
|
|
|
|
|
-// mainLse.setScoreItem(mainList.get(i).getScoreItem());
|
|
|
|
|
-// mainLse.setParentId(mainList.get(i).getParentId());
|
|
|
|
|
-// mainLse.setScoreNum(mainList.get(i).getScoreNum());
|
|
|
|
|
- mainLse.setOwnNum(mainList.get(i).getOwnNum());
|
|
|
|
|
- mainLse.setDeleted(mainList.get(i).getDeleted());
|
|
|
|
|
- lse.add(mainLse);
|
|
|
|
|
- List<SmartEvaluateTdetailList> childScoreList = mainList.get(i).getEvaluateList();
|
|
|
|
|
- for (int j = 0; j < childScoreList.size(); j++) {
|
|
|
|
|
- SmartEvaluateTdetailList childScore = childScoreList.get(j);
|
|
|
|
|
- SmartEvaluateTdetail childLse = new SmartEvaluateTdetail();
|
|
|
|
|
- childLse.setId(childScore.getId() == null ? (int) UUIDUtil.generateID() : childScore.getId());
|
|
|
|
|
-// childLse.setCardNo(teacher.getCardNo());
|
|
|
|
|
-// childLse.setTerm(teacher.getTerm());
|
|
|
|
|
-// childLse.setScoreItem(childScore.getScoreItem());
|
|
|
|
|
-// childLse.setParentId(mainLse.getId());
|
|
|
|
|
-// childLse.setScoreNum(childScore.getScoreNum());
|
|
|
|
|
- childLse.setOwnNum(childScore.getOwnNum());
|
|
|
|
|
- childLse.setDeleted(childScore.getDeleted());
|
|
|
|
|
- lse.add(childLse);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ List<SmartEvaluateTdetail> newDetails = new ArrayList<>();
|
|
|
|
|
+ List<SmartEvaluateTdetail> updateDetails = new ArrayList<>();
|
|
|
|
|
+ //查找明细smart_evaluate_tdetail
|
|
|
|
|
+ List<SmartEvaluateTdetail> tdetails = smartEvaluateTdetailService.queryTdetailsByTermUserId(teacher.getTermId(), teacher.getUserId());
|
|
|
|
|
+ for (SmartEvaluateTdetailList ssl:simpleEvaluateScore.getSimpleScoreList()) {
|
|
|
|
|
+ for (SmartEvaluateTdetailList sc:ssl.getEvaluateList()) {
|
|
|
|
|
+ Optional<SmartEvaluateTdetail> oStdetail = tdetails.stream().filter(e -> e.getScoreManageId().equals(sc.getId())).findFirst();
|
|
|
|
|
+ if(oStdetail != null && oStdetail.isPresent()){
|
|
|
|
|
+ oStdetail.get().setOwnNum(sc.getOwnNum());
|
|
|
|
|
+ updateDetails.add(oStdetail.get());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ SmartEvaluateTdetail nDetail = new SmartEvaluateTdetail();
|
|
|
|
|
+ nDetail.setScoreManageId(sc.getId());
|
|
|
|
|
+ nDetail.setTermId(teacher.getTermId());
|
|
|
|
|
+ nDetail.setUserId(teacher.getUserId());
|
|
|
|
|
+ nDetail.setOwnNum(sc.getOwnNum());
|
|
|
|
|
+ newDetails.add(nDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- for (int i = 0; i < lse.size(); i++) {
|
|
|
|
|
- SmartEvaluateTdetail scoreDetail = lse.get(i);
|
|
|
|
|
- SmartEvaluateTdetail listc = smartEvaluateTdetailService.getSmartEvaluateTdetailById(scoreDetail.getId());
|
|
|
|
|
- if (listc == null) {
|
|
|
|
|
- smartEvaluateTdetailService.insertSmartEvaluateTdetail(scoreDetail);
|
|
|
|
|
- } else {
|
|
|
|
|
- smartEvaluateTdetailService.updateSmartEvaluateTdetail(scoreDetail);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ teacher.setTotalScore(simpleEvaluateScore.getTotalScore());
|
|
|
|
|
+ teacher.setLowingScore(simpleEvaluateScore.getLowingScore());
|
|
|
|
|
+
|
|
|
|
|
+ int updateEvaluate = smartEvaluateTeacherService.updateSmartEvaluateTeacher(teacher);
|
|
|
|
|
+ if (updateEvaluate <= 0) {
|
|
|
|
|
+ throw new Exception("教师评分数据更新失败!");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if(newDetails != null && newDetails.size() > 0){
|
|
|
|
|
+ boolean insertDetail = smartEvaluateTdetailService.saveBatch(newDetails);
|
|
|
|
|
+ if(!insertDetail){
|
|
|
|
|
+ return CommonResult.fail("评价明细数据添加失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(updateDetails != null && updateDetails.size() > 0){
|
|
|
|
|
+ boolean updateDetail = smartEvaluateTdetailService.updateBatchById(updateDetails);
|
|
|
|
|
+ if(!updateDetail){
|
|
|
|
|
+ return CommonResult.fail("评价明细数据更新失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new Exception("评分失败!");
|
|
|
}
|
|
}
|
|
|
- teacher.setTotalScore(simpleEvaluateScore.getTotalScore());
|
|
|
|
|
- teacher.setLowingScore(simpleEvaluateScore.getLowingScore());
|
|
|
|
|
- teacher.setEvaluateDetail(desScore.toString());
|
|
|
|
|
- smartEvaluateTeacherService.updateSmartEvaluateTeacher(teacher);
|
|
|
|
|
- return CommonResult.ok();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return CommonResult.ok("评分成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PassToken
|
|
@PassToken
|
|
@@ -312,7 +321,7 @@ public class SmartEvaluateTeacherController implements SmartEvaluateTeacherContr
|
|
|
child.setScoreItem(detail.getScoreItem());
|
|
child.setScoreItem(detail.getScoreItem());
|
|
|
child.setScoreNum(detail.getScoreNum());
|
|
child.setScoreNum(detail.getScoreNum());
|
|
|
Optional<SmartEvaluateTdetail> oset = sets.stream().filter(e -> e.getScoreManageId().equals(detail.getId())).findFirst();
|
|
Optional<SmartEvaluateTdetail> oset = sets.stream().filter(e -> e.getScoreManageId().equals(detail.getId())).findFirst();
|
|
|
- if(oset != null && oset.isPresent()){
|
|
|
|
|
|
|
+ if (oset != null && oset.isPresent()) {
|
|
|
child.setOwnNum(oset.get().getOwnNum());
|
|
child.setOwnNum(oset.get().getOwnNum());
|
|
|
ownerTotal.add(new BigDecimal(oset.get().getOwnNum()));
|
|
ownerTotal.add(new BigDecimal(oset.get().getOwnNum()));
|
|
|
}
|
|
}
|