|
@@ -9,6 +9,7 @@ import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.common.entity.ImPrivateMessage;
|
|
@@ -22,17 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleComplaintsDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleReviewDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
|
|
|
-import com.ym.mec.biz.dal.dao.OrganizationDao;
|
|
|
-import com.ym.mec.biz.dal.dao.PracticeGroupDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
-import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
import com.ym.mec.biz.dal.entity.ClassGroup;
|
|
|
import com.ym.mec.biz.dal.entity.CourseHomework;
|
|
|
import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
@@ -104,6 +94,9 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
|
|
|
private TeacherDao teacherDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private CourseScheduleComplaintsDao courseScheduleComplaintsDao;
|
|
|
|
|
|
@Autowired
|
|
@@ -182,93 +175,79 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
|
|
|
throw new BizException("课程不存在");
|
|
|
}
|
|
|
|
|
|
- String lockKey = "course_review_" + courseSchedule.getId();
|
|
|
- long lockVal = Thread.currentThread().getId();
|
|
|
- if (!redisCache.getLocked(lockKey, lockVal, 20)) {
|
|
|
- throw new BizException("评论提交中,请稍等");
|
|
|
- }
|
|
|
- PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(courseSchedule.getMusicGroupId()));
|
|
|
+ studentDao.lockUser(courseScheduleReview.getTeacherId());
|
|
|
|
|
|
- try {
|
|
|
- CourseScheduleReview hasReview = courseScheduleReviewDao.findByCourseScheduleAndStudent(courseScheduleId.longValue(), practiceGroup.getStudentId());
|
|
|
- if (hasReview != null) {
|
|
|
- throw new BizException("评论已提交,请勿重复提交");
|
|
|
- }
|
|
|
- courseScheduleReview.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
- courseScheduleReview.setEducationalTeacherId(practiceGroup.getEducationalTeacherId());
|
|
|
- courseScheduleReview.setStudentId(practiceGroup.getStudentId());
|
|
|
- courseScheduleReview.setCreateTime(date);
|
|
|
- courseScheduleReview.setUpdateTime(date);
|
|
|
- long num = courseScheduleReviewDao.insert(courseScheduleReview);
|
|
|
- if (num <= 0) {
|
|
|
- throw new BizException("评论提交失败,请重试");
|
|
|
- }
|
|
|
+ PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(courseSchedule.getMusicGroupId()));
|
|
|
|
|
|
- CourseHomework existHomework = courseHomeworkDao.findByCourseSchedule(courseScheduleId.longValue());
|
|
|
+ CourseScheduleReview hasReview = courseScheduleReviewDao.findByCourseScheduleAndStudent(courseScheduleId.longValue(), practiceGroup.getStudentId());
|
|
|
+ if (hasReview != null) {
|
|
|
+ throw new BizException("评论已提交,请勿重复提交");
|
|
|
+ }
|
|
|
+ courseScheduleReview.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ courseScheduleReview.setEducationalTeacherId(practiceGroup.getEducationalTeacherId());
|
|
|
+ courseScheduleReview.setStudentId(practiceGroup.getStudentId());
|
|
|
+ courseScheduleReview.setCreateTime(date);
|
|
|
+ courseScheduleReview.setUpdateTime(date);
|
|
|
+ long num = courseScheduleReviewDao.insert(courseScheduleReview);
|
|
|
+ if (num <= 0) {
|
|
|
+ throw new BizException("评论提交失败,请重试");
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isNotBlank(courseScheduleReview.getHomeWork())) {
|
|
|
- //新增课堂作业
|
|
|
- CourseHomework courseHomework = new CourseHomework();
|
|
|
- List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseSchedule.getId());
|
|
|
+ CourseHomework existHomework = courseHomeworkDao.findByCourseSchedule(courseScheduleId.longValue());
|
|
|
|
|
|
- if(Objects.nonNull(existHomework)){
|
|
|
- courseHomework.setId(existHomework.getId());
|
|
|
- courseHomework.setContent(courseScheduleReview.getHomeWork());
|
|
|
- courseHomework.setExpiryDate(DateUtil.addDays(date, 7));
|
|
|
- courseHomeworkService.update(courseHomework);
|
|
|
- }else{
|
|
|
- courseHomework.setContent(courseScheduleReview.getHomeWork());
|
|
|
- courseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
|
- courseHomework.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
- courseHomework.setGroupType(courseSchedule.getGroupType());
|
|
|
- courseHomework.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
- courseHomework.setExpiryDate(DateUtil.addDays(date, 7));
|
|
|
- courseHomework.setExpectNum(CollectionUtils.isEmpty(courseScheduleStudentPayments) ? 0 : courseScheduleStudentPayments.size());
|
|
|
- courseHomeworkService.insert(courseHomework);
|
|
|
- }
|
|
|
+ if (StringUtils.isNotBlank(courseScheduleReview.getHomeWork())) {
|
|
|
+ //新增课堂作业
|
|
|
+ CourseHomework courseHomework = new CourseHomework();
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseSchedule.getId());
|
|
|
+
|
|
|
+ if(Objects.nonNull(existHomework)){
|
|
|
+ courseHomework.setId(existHomework.getId());
|
|
|
+ courseHomework.setContent(courseScheduleReview.getHomeWork());
|
|
|
+ courseHomework.setExpiryDate(DateUtil.addDays(date, 7));
|
|
|
+ courseHomeworkService.update(courseHomework);
|
|
|
+ }else{
|
|
|
+ courseHomework.setContent(courseScheduleReview.getHomeWork());
|
|
|
+ courseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseHomework.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ courseHomework.setGroupType(courseSchedule.getGroupType());
|
|
|
+ courseHomework.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ courseHomework.setExpiryDate(DateUtil.addDays(date, 7));
|
|
|
+ courseHomework.setExpectNum(CollectionUtils.isEmpty(courseScheduleStudentPayments) ? 0 : courseScheduleStudentPayments.size());
|
|
|
+ courseHomeworkService.insert(courseHomework);
|
|
|
+ }
|
|
|
|
|
|
- if (!CollectionUtils.isEmpty(courseScheduleStudentPayments)) {
|
|
|
+ if (!CollectionUtils.isEmpty(courseScheduleStudentPayments)) {
|
|
|
// List<StudentCourseHomework> studentCourseHomeworks = new ArrayList<>();
|
|
|
- Teacher teacher = teacherDao.get(courseScheduleReview.getTeacherId());
|
|
|
- String dateStr = DateUtil.dateToString(DateUtil.addDays(date, 1), "MM月dd日");
|
|
|
- for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
|
|
|
- StudentCourseHomework studentCourseHomework = new StudentCourseHomework();
|
|
|
- if(Objects.isNull(existHomework)){
|
|
|
- studentCourseHomework.setCourseHomeworkId(courseHomework.getId());
|
|
|
- studentCourseHomework.setUserId(courseScheduleStudentPayment.getUserId());
|
|
|
- studentCourseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
|
- studentCourseHomework.setCreateTime(date);
|
|
|
- studentCourseHomework.setUpdateTime(date);
|
|
|
- studentCourseHomework.setStatus(YesOrNoEnum.NO);
|
|
|
- studentCourseHomework.setIsView(YesOrNoEnum.NO);
|
|
|
- studentCourseHomework.setIsReplied(YesOrNoEnum.NO);
|
|
|
- studentCourseHomeworkDao.insert(studentCourseHomework);
|
|
|
- }else{
|
|
|
- studentCourseHomework = studentCourseHomeworkDao.findByStudentAndCourseHomewok(existHomework.getId(), courseScheduleStudentPayment.getUserId());
|
|
|
- }
|
|
|
-
|
|
|
- Map<Integer, String> userMap = new HashMap<>();
|
|
|
- userMap.put(courseScheduleStudentPayment.getUserId(), courseScheduleStudentPayment.getUserId().toString());
|
|
|
- String notifyUrl = "3?courseScheduleID=" + courseSchedule.getId() + "&studentCourseHomeworkId=" + studentCourseHomework.getId() + "&extra=0";
|
|
|
- sysMessageService.batchSendImMessage(MessageTypeEnum.IM_HOMEWORK_REMIND,courseScheduleReview.getTeacherId().toString(),
|
|
|
- new String[]{courseScheduleStudentPayment.getUserId().toString()},
|
|
|
- null,courseSchedule.getName(), dateStr,courseHomework.getContent());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.HOMEWORK_REMIND,
|
|
|
- userMap, null, 0, notifyUrl, "STUDENT", teacher.getRealName(), courseSchedule.getName(), dateStr);
|
|
|
+ Teacher teacher = teacherDao.get(courseScheduleReview.getTeacherId());
|
|
|
+ String dateStr = DateUtil.dateToString(DateUtil.addDays(date, 1), "MM月dd日");
|
|
|
+ for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
|
|
|
+ StudentCourseHomework studentCourseHomework = new StudentCourseHomework();
|
|
|
+ if(Objects.isNull(existHomework)){
|
|
|
+ studentCourseHomework.setCourseHomeworkId(courseHomework.getId());
|
|
|
+ studentCourseHomework.setUserId(courseScheduleStudentPayment.getUserId());
|
|
|
+ studentCourseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ studentCourseHomework.setCreateTime(date);
|
|
|
+ studentCourseHomework.setUpdateTime(date);
|
|
|
+ studentCourseHomework.setStatus(YesOrNoEnum.NO);
|
|
|
+ studentCourseHomework.setIsView(YesOrNoEnum.NO);
|
|
|
+ studentCourseHomework.setIsReplied(YesOrNoEnum.NO);
|
|
|
+ studentCourseHomeworkDao.insert(studentCourseHomework);
|
|
|
+ }else{
|
|
|
+ studentCourseHomework = studentCourseHomeworkDao.findByStudentAndCourseHomewok(existHomework.getId(), courseScheduleStudentPayment.getUserId());
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- } finally {
|
|
|
- redisCache.releaseLocked(lockKey, lockVal);
|
|
|
- try {
|
|
|
- Thread.sleep(150);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ Map<Integer, String> userMap = new HashMap<>();
|
|
|
+ userMap.put(courseScheduleStudentPayment.getUserId(), courseScheduleStudentPayment.getUserId().toString());
|
|
|
+ String notifyUrl = "3?courseScheduleID=" + courseSchedule.getId() + "&studentCourseHomeworkId=" + studentCourseHomework.getId() + "&extra=0";
|
|
|
+ sysMessageService.batchSendImMessage(MessageTypeEnum.IM_HOMEWORK_REMIND,courseScheduleReview.getTeacherId().toString(),
|
|
|
+ new String[]{courseScheduleStudentPayment.getUserId().toString()},
|
|
|
+ null,courseSchedule.getName(), dateStr,courseHomework.getContent());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.HOMEWORK_REMIND,
|
|
|
+ userMap, null, 0, notifyUrl, "STUDENT", teacher.getRealName(), courseSchedule.getName(), dateStr);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return courseScheduleReview;
|
|
|
}
|
|
|
|