|
|
@@ -26,6 +26,7 @@ import com.xjrsoft.module.student.service.IStudentReportRecordService;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
|
|
|
import com.xjrsoft.module.student.vo.StudentReportPlanPageVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import me.zhyd.oauth.log.Log;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -137,57 +138,61 @@ public class StudentReportPlanServiceImpl extends MPJBaseServiceImpl<StudentRepo
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean release(StudentReportPlan studentReportPlan) {
|
|
|
- List<Long> classIds = studentReportPlan.getStudentReportPlanClassRelationList().stream().map(StudentReportPlanClassRelation::getClassId).collect(Collectors.toList());
|
|
|
- //1、查询选择的学生
|
|
|
- List<BaseStudentUserPageVo> studentList = studentService.getStudentList(new BaseStudentUserPageDto() {{
|
|
|
- setClassIds(classIds);
|
|
|
- }});
|
|
|
- if(studentList.isEmpty()){
|
|
|
- throw new MyException("未能查询到学生,请联系管理员");
|
|
|
- }
|
|
|
-
|
|
|
- Date createDate = new Date();
|
|
|
- List<StudentReportRecord> insertList = new ArrayList<>();
|
|
|
- for (BaseStudentUserPageVo student : studentList) {
|
|
|
- insertList.add(
|
|
|
- new StudentReportRecord(){{
|
|
|
- setCreateDate(createDate);
|
|
|
- setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- setUserId(Long.parseLong(student.getId()));
|
|
|
- setBaseSemesterId(studentReportPlan.getSemesterId());
|
|
|
- setStudentReportPlanId(studentReportPlan.getId());
|
|
|
- }}
|
|
|
- );
|
|
|
- }
|
|
|
+ try {
|
|
|
+ List<Long> classIds = studentReportPlan.getStudentReportPlanClassRelationList().stream().map(StudentReportPlanClassRelation::getClassId).collect(Collectors.toList());
|
|
|
+ //1、查询选择的学生
|
|
|
+ List<BaseStudentUserPageVo> studentList = studentService.getStudentList(new BaseStudentUserPageDto() {{
|
|
|
+ setClassIds(classIds);
|
|
|
+ }});
|
|
|
+ if(studentList.isEmpty()){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- if(!insertList.isEmpty()){
|
|
|
- reportRecordService.remove(
|
|
|
- new QueryWrapper<StudentReportRecord>().lambda()
|
|
|
- .eq(StudentReportRecord::getStudentReportPlanId, studentReportPlan.getId())
|
|
|
- );
|
|
|
-
|
|
|
- reportRecordService.saveBatch(insertList);
|
|
|
- Set<String> studentUserIds = studentList.stream().map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
- //发布后,将学生的状态改为不正常
|
|
|
- List<BaseStudent> baseStudents = studentService.list(
|
|
|
- new QueryWrapper<BaseStudent>().lambda()
|
|
|
- .in(BaseStudent::getUserId, studentUserIds)
|
|
|
- );
|
|
|
-
|
|
|
- for (BaseStudent baseStudent : baseStudents) {
|
|
|
- baseStudent.setIsNormal(0);
|
|
|
+ Date createDate = new Date();
|
|
|
+ List<StudentReportRecord> insertList = new ArrayList<>();
|
|
|
+ for (BaseStudentUserPageVo student : studentList) {
|
|
|
+ insertList.add(
|
|
|
+ new StudentReportRecord(){{
|
|
|
+ setCreateDate(createDate);
|
|
|
+ setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ setUserId(Long.parseLong(student.getId()));
|
|
|
+ setBaseSemesterId(studentReportPlan.getSemesterId());
|
|
|
+ setStudentReportPlanId(studentReportPlan.getId());
|
|
|
+ }}
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
- studentService.updateBatchById(baseStudents);
|
|
|
+ if(!insertList.isEmpty()){
|
|
|
+ reportRecordService.remove(
|
|
|
+ new QueryWrapper<StudentReportRecord>().lambda()
|
|
|
+ .eq(StudentReportRecord::getStudentReportPlanId, studentReportPlan.getId())
|
|
|
+ );
|
|
|
+
|
|
|
+ reportRecordService.saveBatch(insertList);
|
|
|
+ Set<String> studentUserIds = studentList.stream().map(BaseStudentUserPageVo::getId).collect(Collectors.toSet());
|
|
|
+ //发布后,将学生的状态改为不正常
|
|
|
+ List<BaseStudent> baseStudents = studentService.list(
|
|
|
+ new QueryWrapper<BaseStudent>().lambda()
|
|
|
+ .in(BaseStudent::getUserId, studentUserIds)
|
|
|
+ );
|
|
|
+
|
|
|
+ for (BaseStudent baseStudent : baseStudents) {
|
|
|
+ baseStudent.setIsNormal(0);
|
|
|
+ }
|
|
|
|
|
|
- //修改用户的状态
|
|
|
- List<User> userList = userService.listByIds(studentUserIds);
|
|
|
+ studentService.updateBatchById(baseStudents);
|
|
|
|
|
|
- for (User user : userList) {
|
|
|
- user.setEnabledMark(EnabledMark.DISABLED.getCode());
|
|
|
- }
|
|
|
+ //修改用户的状态
|
|
|
+ List<User> userList = userService.listByIds(studentUserIds);
|
|
|
|
|
|
- userService.updateBatchById(userList);
|
|
|
+ for (User user : userList) {
|
|
|
+ user.setEnabledMark(EnabledMark.DISABLED.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ userService.updateBatchById(userList);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ Log.error(e.getMessage(), e);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -218,4 +223,9 @@ public class StudentReportPlanServiceImpl extends MPJBaseServiceImpl<StudentRepo
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StudentReportPlan> getWillBeginData() {
|
|
|
+ return baseMapper.getWillBeginData();
|
|
|
+ }
|
|
|
}
|