|
@@ -1,105 +0,0 @@
|
|
-package com.ssj.service.rabbitmq;
|
|
|
|
-
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import com.ssj.bean.sys.homework.domain.HomeworkPicture;
|
|
|
|
-import com.ssj.bean.sys.template.CommentTemplate;
|
|
|
|
-import com.ssj.framework.core.rabbitmq.TopicRabbitConfig;
|
|
|
|
-import com.ssj.framework.core.util.SystemResourceLocator;
|
|
|
|
-import com.ssj.service.ai.model.HomeworkFeedbackPushmqModel;
|
|
|
|
-import com.ssj.service.ai.model.HomeworkPicturePreDeal;
|
|
|
|
-import com.ssj.service.kmt.dto.CompositionCommentDto;
|
|
|
|
-import com.ssj.service.sys.homework.request.CorrectionRequest;
|
|
|
|
-import com.ssj.service.sys.homework.service.HomeworkPictureService;
|
|
|
|
-import com.ssj.service.sys.homework.service.HomeworkService;
|
|
|
|
-import com.ssj.service.sys.picturepredeal.service.PicturePreDealService;
|
|
|
|
-import com.ssj.service.sys.template.CommentTemplateMapperService;
|
|
|
|
-import com.ssj.service.weixin.library.service.IBookManagerService;
|
|
|
|
-import com.ssj.sys.util.xunfei.XunFeiTTSUtils;
|
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
-import org.springframework.amqp.core.Message;
|
|
|
|
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
|
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
-
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
-@Component
|
|
|
|
-public class TopicRabbitHomeworkFeedbackPushConsumer {
|
|
|
|
-
|
|
|
|
- private static Logger logger = LoggerFactory.getLogger(TopicRabbitHomeworkFeedbackPushConsumer.class);
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private HomeworkPictureService homeworkPictureService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private HomeworkService homeworkService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private IBookManagerService bookManagerService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private CommentTemplateMapperService commentTemplateMapperService;
|
|
|
|
-
|
|
|
|
- private static Long num=0L;
|
|
|
|
-
|
|
|
|
- @RabbitListener(queues = {TopicRabbitConfig.topic_homeworkfeedback_push})
|
|
|
|
- @RabbitHandler
|
|
|
|
- public void handleMessage(Message message){
|
|
|
|
- try {
|
|
|
|
- num = num + 1;
|
|
|
|
- logger.info("作业批改结果消息队列开始消费...");
|
|
|
|
- HomeworkFeedbackPushmqModel model = JSONObject.parseObject(message.getBody(), HomeworkFeedbackPushmqModel.class);
|
|
|
|
- logger.error("开始消费推送信息队列数据:"+JSONObject.toJSONString(model));
|
|
|
|
- //推送报告
|
|
|
|
- try {
|
|
|
|
- Thread.sleep(3000);
|
|
|
|
- logger.error("作业批改结果推送报告处理任务开始---------------");
|
|
|
|
- CorrectionRequest request = model.getRequest();
|
|
|
|
- HomeworkPicture homeworkPicture = model.getHomeworkPicture();
|
|
|
|
- //待批改数累计减一
|
|
|
|
- bookManagerService.updateCorrectHomeworkNum(homeworkPicture.getVipId(), homeworkPicture.getTeacherId(), -1);
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isNotEmpty(request.getCompositionCommentList())) {
|
|
|
|
- List<String> selectedCompositionCommentIdList = request.getCompositionCommentList().stream()
|
|
|
|
- .map(CompositionCommentDto::getCompositionCommentId)
|
|
|
|
- .distinct()
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- List<CommentTemplate> commentList = commentTemplateMapperService.findCompositionByIds(selectedCompositionCommentIdList);
|
|
|
|
- StringBuilder compositionComments = new StringBuilder();
|
|
|
|
- if (commentList != null) {
|
|
|
|
- for (int i = 0; i < commentList.size(); i++) {
|
|
|
|
- compositionComments.append(i + 1).append(" ").append(commentList.get(i).getComment());
|
|
|
|
- }
|
|
|
|
- if (!compositionComments.toString().equals(homeworkPicture.getCompositionComment())) {
|
|
|
|
- homeworkPicture.setCompositionComment(compositionComments.toString());
|
|
|
|
- try {
|
|
|
|
- String videoPath = XunFeiTTSUtils.textToVoice(compositionComments.toString(), homeworkPicture.getVipId());
|
|
|
|
- homeworkPicture.setCompositionCommentPath(videoPath);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- logger.error("讯飞转语音异常", e);
|
|
|
|
- }
|
|
|
|
- homeworkPictureService.save(homeworkPicture);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- homeworkService.findWrongQuestionAndSetRedis(homeworkPicture.getHomeworkId());
|
|
|
|
- homeworkService.findWrongHowDetailAndSetRedis(homeworkPicture.getHomeworkId());
|
|
|
|
- //批改后删除单科批改详情的缓存
|
|
|
|
- homeworkService.removeRedisCorrectDetailDto4(homeworkPicture.getVipId(), homeworkPicture.getSubject(), homeworkPicture.getCreateTime());
|
|
|
|
- homeworkPictureService.pushTodayFinishHomework(homeworkPicture, 2);
|
|
|
|
- logger.error("作业批改结果推送报告处理任务结束---------------");
|
|
|
|
- }catch (Exception e){
|
|
|
|
- logger.error("异常", e);
|
|
|
|
- }
|
|
|
|
- logger.info("作业批改结果消息队列完成消费..." + num);
|
|
|
|
- } catch (Exception e){
|
|
|
|
- logger.error("消费队列消费异常" + e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|