|
@@ -55,7 +55,8 @@ public class SmartEvaluateTeacherController implements SmartEvaluateTeacherContr
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult addScoreManage(addScoreManageRequest asmr, BindingResult bindingResult) {
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public CommonResult addScoreManage(addScoreManageRequest asmr, BindingResult bindingResult) throws Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
|
return CommonResult.fail(st);
|
|
return CommonResult.fail(st);
|
|
@@ -74,31 +75,40 @@ public class SmartEvaluateTeacherController implements SmartEvaluateTeacherContr
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- SmartScoreManage parentData = new SmartScoreManage();
|
|
|
|
|
- parentData.setTermId(asmr.getTermId());
|
|
|
|
|
- parentData.setTerm(semester.getName());
|
|
|
|
|
- parentData.setScoreItem(asmr.getScoreItem());
|
|
|
|
|
- parentData.setParentId(0);
|
|
|
|
|
- parentData.setScoreNum(asmr.getScoreNum());
|
|
|
|
|
- int insertResult = smartScoreManageService.insertSmartScoreManage(parentData);
|
|
|
|
|
- if (insertResult <= 0) {
|
|
|
|
|
- return CommonResult.fail("添加项失败");
|
|
|
|
|
- }
|
|
|
|
|
- SmartScoreManage childData = new SmartScoreManage();
|
|
|
|
|
- childData.setTermId(asmr.getTermId());
|
|
|
|
|
- childData.setTerm(semester.getName());
|
|
|
|
|
- childData.setScoreItem(asmr.getScoreChildItem());
|
|
|
|
|
- childData.setParentId(insertResult);
|
|
|
|
|
- childData.setScoreNum(asmr.getScoreNum());
|
|
|
|
|
- int insertChildResult = smartScoreManageService.insertSmartScoreManage(childData);
|
|
|
|
|
- if (insertChildResult <= 0) {
|
|
|
|
|
- return CommonResult.fail("添加子项失败");
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ SmartScoreManage parentData = new SmartScoreManage();
|
|
|
|
|
+ parentData.setTermId(asmr.getTermId());
|
|
|
|
|
+ parentData.setTerm(semester.getName());
|
|
|
|
|
+ parentData.setScoreItem(asmr.getScoreItem());
|
|
|
|
|
+ parentData.setParentId(0);
|
|
|
|
|
+ parentData.setScoreNum(asmr.getScoreNum());
|
|
|
|
|
+ int insertResult = smartScoreManageService.insertSmartScoreManage(parentData);
|
|
|
|
|
+ if (insertResult <= 0) {
|
|
|
|
|
+ //return CommonResult.fail("添加项失败");
|
|
|
|
|
+ throw new Exception("添加项失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ SmartScoreManage childData = new SmartScoreManage();
|
|
|
|
|
+ childData.setTermId(asmr.getTermId());
|
|
|
|
|
+ childData.setTerm(semester.getName());
|
|
|
|
|
+ childData.setScoreItem(asmr.getScoreChildItem());
|
|
|
|
|
+ childData.setParentId(insertResult);
|
|
|
|
|
+ childData.setScoreNum(asmr.getScoreNum());
|
|
|
|
|
+ int insertChildResult = smartScoreManageService.insertSmartScoreManage(childData);
|
|
|
|
|
+ if (insertChildResult <= 0) {
|
|
|
|
|
+ //return CommonResult.fail("添加子项失败");
|
|
|
|
|
+ throw new Exception("添加子项失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new Exception("添加失败!");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
return CommonResult.ok("添加成功");
|
|
return CommonResult.ok("添加成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult addChildScoreManage(addChildScoreManageRequest acsmr, BindingResult bindingResult) {
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public CommonResult addChildScoreManage(addChildScoreManageRequest acsmr, BindingResult bindingResult) throws Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
|
return CommonResult.fail(st);
|
|
return CommonResult.fail(st);
|
|
@@ -110,77 +120,140 @@ public class SmartEvaluateTeacherController implements SmartEvaluateTeacherContr
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//根据父级ID获取父级下所有子级数据
|
|
//根据父级ID获取父级下所有子级数据
|
|
|
- List<SmartScoreManage> childDatas = smartScoreManageService.queryDatasByParentId(acsmr.getId());
|
|
|
|
|
- if(childDatas != null && childDatas.size() > 0){
|
|
|
|
|
|
|
+ List<SmartScoreManage> childDatas = smartScoreManageService.queryAllDatasByParentId(acsmr.getId());
|
|
|
|
|
+ if (childDatas != null && childDatas.size() > 0) {
|
|
|
long exist = childDatas.stream().filter(e -> e.getScoreItem().equals(acsmr.getScoreItem())).count();
|
|
long exist = childDatas.stream().filter(e -> e.getScoreItem().equals(acsmr.getScoreItem())).count();
|
|
|
- if(exist > 0){
|
|
|
|
|
|
|
+ if (exist > 0) {
|
|
|
return CommonResult.fail("存在重复子项");
|
|
return CommonResult.fail("存在重复子项");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- SmartScoreManage parentData = new SmartScoreManage();
|
|
|
|
|
- parentData.setTermId(acsmr.getTermId());
|
|
|
|
|
- parentData.setTerm(semester.getName());
|
|
|
|
|
- parentData.setScoreItem(acsmr.getScoreItem());
|
|
|
|
|
- parentData.setParentId(acsmr.getId());
|
|
|
|
|
- parentData.setScoreNum(acsmr.getScoreNum());
|
|
|
|
|
- int insertResult = smartScoreManageService.insertSmartScoreManage(parentData);
|
|
|
|
|
- if (insertResult <= 0) {
|
|
|
|
|
- return CommonResult.fail("添加子项失败");
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ SmartScoreManage parentData = new SmartScoreManage();
|
|
|
|
|
+ parentData.setTermId(acsmr.getTermId());
|
|
|
|
|
+ parentData.setTerm(semester.getName());
|
|
|
|
|
+ parentData.setScoreItem(acsmr.getScoreItem());
|
|
|
|
|
+ parentData.setParentId(acsmr.getId());
|
|
|
|
|
+ parentData.setScoreNum(acsmr.getScoreNum());
|
|
|
|
|
+ int insertResult = smartScoreManageService.insertSmartScoreManage(parentData);
|
|
|
|
|
+ if (insertResult <= 0) {
|
|
|
|
|
+ //return CommonResult.fail("添加子项失败");
|
|
|
|
|
+ throw new Exception("添加子项失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Optional<SmartScoreManage> oScoreManage = childDatas.stream().filter(e -> e.getParentId().intValue() == 0).findFirst();
|
|
|
|
|
+ if (oScoreManage != null && oScoreManage.isPresent()) {
|
|
|
|
|
+ BigDecimal totalNum = new BigDecimal(0.0);
|
|
|
|
|
+ for (SmartScoreManage child : childDatas) {
|
|
|
|
|
+ if (child.getParentId().intValue() != 0) {
|
|
|
|
|
+ totalNum.add(new BigDecimal(child.getScoreNum()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ totalNum = totalNum.add(new BigDecimal(acsmr.getScoreNum()));
|
|
|
|
|
+ oScoreManage.get().setScoreNum(totalNum.doubleValue());
|
|
|
|
|
+
|
|
|
|
|
+ int updateData = smartScoreManageService.updateSmartScoreManage(oScoreManage.get());
|
|
|
|
|
+ if (updateData <= 0) {
|
|
|
|
|
+ //return CommonResult.ok("添加失败");
|
|
|
|
|
+ throw new Exception("添加失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new Exception("添加子项失败!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return CommonResult.ok("添加成功");
|
|
return CommonResult.ok("添加成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult updateScoreManage(updateScoreManageRequest usmr, BindingResult bindingResult) {
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public CommonResult updateScoreManage(updateScoreManageRequest usmr, BindingResult bindingResult) throws Exception {
|
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
String st = paramUtils.getParamError(bindingResult);
|
|
|
return CommonResult.fail(st);
|
|
return CommonResult.fail(st);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SmartScoreManage data = smartScoreManageService.getSmartScoreManageById(usmr.getId());
|
|
SmartScoreManage data = smartScoreManageService.getSmartScoreManageById(usmr.getId());
|
|
|
- if(data == null){
|
|
|
|
|
|
|
+ if (data == null) {
|
|
|
return CommonResult.fail("数据已失效,编辑失败");
|
|
return CommonResult.fail("数据已失效,编辑失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//根据父级ID获取父级下所有子级数据
|
|
//根据父级ID获取父级下所有子级数据
|
|
|
- List<SmartScoreManage> childDatas = smartScoreManageService.queryDatasByParentId(data.getParentId());
|
|
|
|
|
- if(childDatas != null && childDatas.size() > 0){
|
|
|
|
|
|
|
+ List<SmartScoreManage> childDatas = smartScoreManageService.queryAllDatasByParentId(data.getParentId());
|
|
|
|
|
+ if (childDatas != null && childDatas.size() > 0) {
|
|
|
long exist = childDatas.stream().filter(e -> e.getScoreItem().equals(usmr.getScoreItem()) && e.getId().intValue() != usmr.getId().intValue()).count();
|
|
long exist = childDatas.stream().filter(e -> e.getScoreItem().equals(usmr.getScoreItem()) && e.getId().intValue() != usmr.getId().intValue()).count();
|
|
|
- if(exist > 0){
|
|
|
|
|
|
|
+ if (exist > 0) {
|
|
|
return CommonResult.fail("存在重复子项");
|
|
return CommonResult.fail("存在重复子项");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- data.setScoreItem(usmr.getScoreItem());
|
|
|
|
|
- data.setScoreNum(usmr.getScoreNum());
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<SmartScoreManage> updateDatas = new ArrayList<>();
|
|
|
|
|
+ Optional<SmartScoreManage> oScoreManage = childDatas.stream().filter(e -> e.getParentId().intValue() == 0).findFirst();
|
|
|
|
|
+ if (oScoreManage != null && oScoreManage.isPresent()) {
|
|
|
|
|
+ BigDecimal totalNum = new BigDecimal(0.0);
|
|
|
|
|
+ for (SmartScoreManage child : childDatas) {
|
|
|
|
|
+ if (child.getParentId().intValue() != 0 && child.getId().intValue() != usmr.getId().intValue()) {
|
|
|
|
|
+ totalNum.add(new BigDecimal(child.getScoreNum()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ totalNum = totalNum.add(new BigDecimal(usmr.getScoreNum()));
|
|
|
|
|
+ oScoreManage.get().setScoreNum(totalNum.doubleValue());
|
|
|
|
|
+
|
|
|
|
|
+ updateDatas.add(oScoreManage.get());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- int updateData = smartScoreManageService.updateSmartScoreManage(data);
|
|
|
|
|
- if(updateData <= 0){
|
|
|
|
|
- return CommonResult.fail("编辑失败");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ data.setScoreItem(usmr.getScoreItem());
|
|
|
|
|
+ data.setScoreNum(usmr.getScoreNum());
|
|
|
|
|
+ updateDatas.add(data);
|
|
|
|
|
+
|
|
|
|
|
+ boolean updateData = smartScoreManageService.updateBatchById(updateDatas);
|
|
|
|
|
+ if (!updateData) {
|
|
|
|
|
+ //return CommonResult.fail("编辑失败");
|
|
|
|
|
+ throw new Exception("编辑失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new Exception("编辑失败!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return CommonResult.ok("编辑成功");
|
|
return CommonResult.ok("编辑成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public CommonResult deleteScoreManage(int id) {
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
|
|
+ public CommonResult deleteScoreManage(int id) throws Exception {
|
|
|
|
|
+
|
|
|
SmartScoreManage data = smartScoreManageService.getSmartScoreManageById(id);
|
|
SmartScoreManage data = smartScoreManageService.getSmartScoreManageById(id);
|
|
|
- if(data == null){
|
|
|
|
|
|
|
+ if (data == null) {
|
|
|
return CommonResult.fail("数据已失效,删除失败");
|
|
return CommonResult.fail("数据已失效,删除失败");
|
|
|
}
|
|
}
|
|
|
- int result = smartScoreManageService.deleteSmartScoreManageById(id);
|
|
|
|
|
- if(result <= 0){
|
|
|
|
|
- return CommonResult.fail("删除失败");
|
|
|
|
|
|
|
+ SmartScoreManage parent = smartScoreManageService.getSmartScoreManageById(data.getParentId());
|
|
|
|
|
+ if (parent == null) {
|
|
|
|
|
+ return CommonResult.fail("父级数据为空删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ int result = smartScoreManageService.deleteSmartScoreManageById(id);
|
|
|
|
|
+ if (result <= 0) {
|
|
|
|
|
+ //return CommonResult.fail("删除失败");
|
|
|
|
|
+ throw new Exception("删除失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal scoreNum = new BigDecimal(parent.getScoreNum()).subtract(new BigDecimal(data.getScoreNum()));
|
|
|
|
|
+ parent.setScoreNum(scoreNum.doubleValue());
|
|
|
|
|
+
|
|
|
|
|
+ int update = smartScoreManageService.updateSmartScoreManage(parent);
|
|
|
|
|
+ if (update <= 0) {
|
|
|
|
|
+ //return CommonResult.fail("删除失败");
|
|
|
|
|
+ throw new Exception("删除失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new Exception("删除失败!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return CommonResult.ok("删除成功");
|
|
return CommonResult.ok("删除成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@PassToken
|
|
@PassToken
|
|
|
public CommonResult operateSmartScoreManage(JSONObject jsonObject) {
|
|
public CommonResult operateSmartScoreManage(JSONObject jsonObject) {
|
|
|
SimpleScore simpleScoreLists = null;
|
|
SimpleScore simpleScoreLists = null;
|