|
@@ -7,8 +7,13 @@ import com.fs.common.annotation.DataSource;
|
|
|
import com.fs.common.enums.DataSourceType;
|
|
|
import com.fs.common.exception.base.BaseException;
|
|
|
import com.fs.common.utils.PubFun;
|
|
|
+import com.fs.course.domain.FsUserCourse;
|
|
|
+import com.fs.course.domain.FsUserCourseVideo;
|
|
|
+import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
+import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.fastGpt.domain.FastGptChatReplaceWords;
|
|
|
import com.fs.fastGpt.mapper.FastGptChatReplaceWordsMapper;
|
|
|
+import com.fs.qw.vo.QwSopTempSetting2;
|
|
|
import com.fs.qw.vo.SortDayVo;
|
|
|
import com.fs.sop.domain.QwSopTemp;
|
|
|
import com.fs.sop.domain.QwSopTempContent;
|
|
@@ -21,10 +26,13 @@ import com.fs.sop.vo.VoiceVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -45,6 +53,8 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
private final IQwSopTempContentService qwSopTempContentService;
|
|
|
private final IQwSopTempVoiceService qwSopTempVoiceService;
|
|
|
private final RocketMQTemplate rocketMQTemplate;
|
|
|
+ private final FsUserCourseMapper fsUserCourseMapper;
|
|
|
+ private final FsUserCourseVideoMapper fsUserCourseVideoMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询sop模板
|
|
@@ -56,6 +66,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
public QwSopTemp selectQwSopTempById(String id){
|
|
|
// QwSopTemp qwSopTemp = qwSopTempMapper.selectQwSopTempById(id);
|
|
|
QwSopTemp qwSopTemp = qwSopTempMapper.selectQwSopTempById(id);
|
|
|
+ if(qwSopTemp == null) return null;
|
|
|
List<QwSopTempDay> qwSopTempDays = qwSopTempDayService.listByTempId(id);
|
|
|
qwSopTemp.setList(qwSopTempDays);
|
|
|
// List<QwSopTempRules> rulesList = qwSopTempRulesService.listByTempId(id);
|
|
@@ -164,6 +175,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
return qwSopTempMapper.deleteQwSopTempById(id);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public int addNew(QwSopTemp qwSopTemp) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -172,6 +184,82 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
return qwSopTempMapper.insertQwSopTemp(qwSopTemp);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void createSopTempRules(QwSopTemp temp) {
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(temp.getCourseId());
|
|
|
+ temp.setProject(fsUserCourse.getProject());
|
|
|
+ qwSopTempMapper.updateQwSopTemp(temp);
|
|
|
+ List<FsUserCourseVideo> videoList = fsUserCourseVideoMapper.selectVideoByCourseId(fsUserCourse.getCourseId());
|
|
|
+ AtomicInteger i = new AtomicInteger(1);
|
|
|
+ Integer gap = temp.getGap();
|
|
|
+ List<QwSopTempDay> collect = videoList.stream().map(e -> {
|
|
|
+ QwSopTempDay day = new QwSopTempDay();
|
|
|
+ day.setTempId(temp.getId());
|
|
|
+ day.setDayNum(i.getAndIncrement() * gap);
|
|
|
+ day.setName("第" + day.getDayNum() + "天");
|
|
|
+ day.setSorts(day.getDayNum());
|
|
|
+ day.setList(new ArrayList<>());
|
|
|
+ QwSopTempRules rules = new QwSopTempRules();
|
|
|
+ rules.setTempId(temp.getId());
|
|
|
+ rules.setName(day.getName());
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
+ rules.setTime(e.getViewStartTime().format(formatter));
|
|
|
+ rules.setContentType(2);
|
|
|
+ rules.setType(2);
|
|
|
+ rules.setCourseType(0);
|
|
|
+ rules.setCourseId(e.getCourseId());
|
|
|
+ rules.setVideoId(e.getVideoId());
|
|
|
+ rules.setSorts(0);
|
|
|
+ day.getList().add(rules);
|
|
|
+ QwSopTempContent content = new QwSopTempContent();
|
|
|
+ content.setTempId(temp.getId());
|
|
|
+ content.setContentType(3);
|
|
|
+ QwSopTempSetting2.Content.Setting setting = new QwSopTempSetting2.Content.Setting();
|
|
|
+ setting.setLinkTitle(fsUserCourse.getCourseName());
|
|
|
+ setting.setIsBindUrl(1);
|
|
|
+ setting.setLinkDescribe(e.getTitle());
|
|
|
+ setting.setLinkImageUrl(fsUserCourse.getImgUrl());
|
|
|
+ setting.setContentType("3");
|
|
|
+ content.setContent(JSON.toJSONString(setting));
|
|
|
+ content.setIsBindUrl(1);
|
|
|
+ rules.setList(Collections.singletonList(content));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(temp.getTimeList() != null && !temp.getTimeList().isEmpty()){
|
|
|
+ AtomicInteger sorts = new AtomicInteger(1);
|
|
|
+ List<QwSopTempRules> rulesList = temp.getTimeList().stream().map(time -> {
|
|
|
+ QwSopTempRules rulesSub = new QwSopTempRules();
|
|
|
+ rulesSub.setTempId(temp.getId());
|
|
|
+ rulesSub.setName(day.getName());
|
|
|
+ rulesSub.setTime(time);
|
|
|
+ rulesSub.setContentType(1);
|
|
|
+ rulesSub.setType(1);
|
|
|
+ rulesSub.setSorts(sorts.getAndIncrement());
|
|
|
+ QwSopTempContent contentSbu = new QwSopTempContent();
|
|
|
+ contentSbu.setTempId(temp.getId());
|
|
|
+ contentSbu.setContentType(1);
|
|
|
+ QwSopTempSetting2.Content.Setting settingSub = new QwSopTempSetting2.Content.Setting();
|
|
|
+ settingSub.setContentType("1");
|
|
|
+ settingSub.setValue("");
|
|
|
+ contentSbu.setContent(JSON.toJSONString(settingSub));
|
|
|
+ rulesSub.setList(Collections.singletonList(contentSbu));
|
|
|
+ return rulesSub;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ day.getList().addAll(rulesList);
|
|
|
+ }
|
|
|
+ return day;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ qwSopTempDayService.addOrUpdateBatch(collect);
|
|
|
+ List<QwSopTempRules> ruleList = collect.stream().flatMap(e -> e.getList().stream().peek(r -> r.setDayId(e.getId()))).collect(Collectors.toList());
|
|
|
+ qwSopTempRulesService.saveList(ruleList);
|
|
|
+ List<QwSopTempContent> contentList = ruleList.stream().flatMap(e -> e.getList().stream().peek(r -> {
|
|
|
+ r.setDayId(e.getDayId());
|
|
|
+ r.setRulesId(e.getId());
|
|
|
+ })).collect(Collectors.toList());
|
|
|
+ qwSopTempContentService.saveList(contentList);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@DataSource(DataSourceType.SOP)
|
|
|
public int update(QwSopTemp qwSopTemp) {
|