|
|
@@ -9,7 +9,6 @@ import com.fs.common.exception.base.BaseException;
|
|
|
import com.fs.common.utils.PubFun;
|
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
-import com.fs.company.service.impl.CompanyServiceImpl;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsUserCourse;
|
|
|
@@ -30,16 +29,16 @@ import com.fs.sop.mapper.QwSopTempMapper;
|
|
|
import com.fs.sop.params.QwSopShareTempParam;
|
|
|
import com.fs.sop.service.*;
|
|
|
import com.fs.sop.vo.QwSopTempRedPackageVo;
|
|
|
-import com.fs.sop.vo.VoiceVo;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.beanutils.ConvertUtils;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -47,6 +46,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -59,8 +59,8 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
-public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
-{
|
|
|
+@Slf4j
|
|
|
+public class QwSopTempServiceImpl implements IQwSopTempService {
|
|
|
|
|
|
@Autowired
|
|
|
private CloudHostProper cloudHostProper;
|
|
|
@@ -79,6 +79,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
private final IQwSopService qwSopService;
|
|
|
private final IQwUserService qwUserService;
|
|
|
private final ICompanyService companyService;
|
|
|
+ private final ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
|
|
|
/**
|
|
|
* 查询sop模板
|
|
|
@@ -87,7 +88,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
* @return sop模板
|
|
|
*/
|
|
|
@Override
|
|
|
- public QwSopTemp selectQwSopTempById(String id){
|
|
|
+ public QwSopTemp selectQwSopTempById(String id) {
|
|
|
// QwSopTemp qwSopTemp = qwSopTempMapper.selectQwSopTempById(id);
|
|
|
QwSopTemp qwSopTemp = qwSopTempMapper.selectQwSopTempById(id);
|
|
|
List<QwSopTempDay> qwSopTempDays = qwSopTempDayService.listByTempId(id);
|
|
|
@@ -117,8 +118,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
* @return sop模板
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<QwSopTemp> selectQwSopTempList(QwSopTemp qwSopTemp)
|
|
|
- {
|
|
|
+ public List<QwSopTemp> selectQwSopTempList(QwSopTemp qwSopTemp) {
|
|
|
return qwSopTempMapper.selectQwSopTempList(qwSopTemp);
|
|
|
}
|
|
|
|
|
|
@@ -129,7 +129,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertQwSopTemp(QwSopTemp qwSopTemp){
|
|
|
+ public int insertQwSopTemp(QwSopTemp qwSopTemp) {
|
|
|
qwSopTemp.setId(UUID.randomUUID().toString());
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
qwSopTemp.setCreateTime(sdf.format(new Date()));
|
|
|
@@ -155,7 +155,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateQwSopTemp(QwSopTemp qwSopTemp){
|
|
|
+ public int updateQwSopTemp(QwSopTemp qwSopTemp) {
|
|
|
return qwSopTempMapper.updateQwSopTemp(qwSopTemp);
|
|
|
}
|
|
|
|
|
|
@@ -166,8 +166,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteQwSopTempByIds(String[] ids)
|
|
|
- {
|
|
|
+ public int deleteQwSopTempByIds(String[] ids) {
|
|
|
return qwSopTempMapper.deleteQwSopTempByIds(ids);
|
|
|
}
|
|
|
|
|
|
@@ -196,8 +195,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteQwSopTempById(String id)
|
|
|
- {
|
|
|
+ public int deleteQwSopTempById(String id) {
|
|
|
return qwSopTempMapper.deleteQwSopTempById(id);
|
|
|
}
|
|
|
|
|
|
@@ -214,7 +212,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
public int update(QwSopTemp qwSopTemp) {
|
|
|
QwSopTemp temp = qwSopTempMapper.selectById(qwSopTemp.getId());
|
|
|
int i = qwSopTempMapper.updateById(qwSopTemp);
|
|
|
- if(!Objects.equals(temp.getGap(), qwSopTemp.getGap())){
|
|
|
+ if (!Objects.equals(temp.getGap(), qwSopTemp.getGap())) {
|
|
|
// 重新排序
|
|
|
reorder(qwSopTemp.getId());
|
|
|
}
|
|
|
@@ -233,7 +231,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
qwSopTempRulesService.removeByDayId(day.getId());
|
|
|
qwSopTempContentService.removeByDayId(day.getId());
|
|
|
|
|
|
- list.forEach(item-> item.setDayId(day.getId()));
|
|
|
+ list.forEach(item -> item.setDayId(day.getId()));
|
|
|
processAndReplaceContent(list);
|
|
|
QwSopTempRules rules = list.get(0);
|
|
|
String tempId = rules.getTempId();
|
|
|
@@ -251,29 +249,29 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
reorder(day.getTempId());
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("id", day.getId());
|
|
|
- if(!voiceList.isEmpty()){
|
|
|
+ if (!voiceList.isEmpty()) {
|
|
|
for (QwSopTempContent qwSopTempContent : voiceList) {
|
|
|
String content = qwSopTempContent.getContent();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
String text = jsonObject.getString("value");
|
|
|
List<QwSop> qwSopList = qwSopService.selectQwSopByTempId(tempId);//通过tempId查询出所有sop
|
|
|
- if(qwSopList != null && !qwSopList.isEmpty()){
|
|
|
+ if (qwSopList != null && !qwSopList.isEmpty()) {
|
|
|
for (QwSop qwSop : qwSopList) {
|
|
|
- if(qwSop != null && qwSop.getQwUserIds() != null){
|
|
|
+ if (qwSop != null && qwSop.getQwUserIds() != null) {
|
|
|
//查询出所有的tempContent来筛选文字
|
|
|
List<QwSopTempContent> qwSopTempContentList = qwSopTempContentService.selectQwSopTempContentByTempId(tempId);
|
|
|
- if(qwSopTempContentList != null && !qwSopTempContentList.isEmpty()){
|
|
|
+ if (qwSopTempContentList != null && !qwSopTempContentList.isEmpty()) {
|
|
|
for (QwSopTempContent qwSopTemp : qwSopTempContentList) {
|
|
|
- if(qwSopTemp != null && qwSopTemp.getContentType() == 7){
|
|
|
+ if (qwSopTemp != null && qwSopTemp.getContentType() == 7) {
|
|
|
String[] split = qwSop.getQwUserIds().split(",");
|
|
|
Long[] qwUserIds = (Long[]) ConvertUtils.convert(split, Long.class);
|
|
|
List<QwUserVO> qwUserVOS = qwUserService.selectQwUserVOByIds(qwUserIds);
|
|
|
- if(qwUserVOS != null){
|
|
|
+ if (qwUserVOS != null) {
|
|
|
for (QwUserVO qwUserVO : qwUserVOS) {
|
|
|
Long companyUserId = qwUserVO.getCompanyUserId();
|
|
|
- QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId,text);
|
|
|
- if(qwSopTempVoice == null){
|
|
|
- if(companyUserId != null && text != null){
|
|
|
+ QwSopTempVoice qwSopTempVoice = qwSopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(companyUserId, text);
|
|
|
+ if (qwSopTempVoice == null) {
|
|
|
+ if (companyUserId != null && text != null) {
|
|
|
QwSopTempVoice sopTempVoice = new QwSopTempVoice();
|
|
|
sopTempVoice.setCompanyUserId(companyUserId);
|
|
|
sopTempVoice.setVoiceTxt(text);
|
|
|
@@ -298,12 +296,12 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private void processAndReplaceContent(List<QwSopTempRules> tempSettings){
|
|
|
+ private void processAndReplaceContent(List<QwSopTempRules> tempSettings) {
|
|
|
List<FastGptChatReplaceWords> words = fastGptChatReplaceWordsMapper.selectAllFastGptChatReplaceWords();
|
|
|
//循环天
|
|
|
- tempSettings.forEach(settingList->{
|
|
|
+ tempSettings.forEach(settingList -> {
|
|
|
//循环单日
|
|
|
- settingList.getSettingList().forEach(item->{
|
|
|
+ settingList.getSettingList().forEach(item -> {
|
|
|
JSONObject obj = JSON.parseObject(item.getContent());
|
|
|
List<String> list = Arrays.asList("linkTitle", "linkDescribe", "desc", "nickname", "value");
|
|
|
list.stream().filter(obj::containsKey).forEach(key -> {
|
|
|
@@ -316,23 +314,24 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
|
|
|
@Override
|
|
|
public void delRules(Long id) {
|
|
|
- if(id == null) return;
|
|
|
+ if (id == null) return;
|
|
|
QwSopTempDay day = qwSopTempDayService.info(id);
|
|
|
- if(day == null) return;
|
|
|
+ if (day == null) return;
|
|
|
qwSopTempDayService.removeById(day.getId());
|
|
|
qwSopTempContentService.removeByDayId(day.getId());
|
|
|
reorder(day.getTempId());
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public QwSopTempDay selectRulesInfo(Long id) {
|
|
|
QwSopTempDay day = qwSopTempDayService.info(id);
|
|
|
List<QwSopTempRules> rulesList = qwSopTempRulesService.listByDayId(id);
|
|
|
- if(!rulesList.isEmpty()){
|
|
|
+ if (!rulesList.isEmpty()) {
|
|
|
List<QwSopTempContent> contentList = qwSopTempContentService.listByRulesIds(PubFun.listToNewList(rulesList, QwSopTempRules::getId));
|
|
|
Map<Long, List<QwSopTempContent>> contentMap = PubFun.listToMapByGroupList(contentList, QwSopTempContent::getRulesId);
|
|
|
rulesList.forEach(e -> {
|
|
|
List<QwSopTempContent> contents = contentMap.get(e.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(contents)){
|
|
|
+ if (CollectionUtils.isNotEmpty(contents)) {
|
|
|
e.setSetting(contents.stream().map(c -> JSON.parseObject(c.getContent())).collect(Collectors.toList()));
|
|
|
}
|
|
|
});
|
|
|
@@ -353,14 +352,14 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
qwSopTemp.setId(newId);
|
|
|
qwSopTempMapper.insertQwSopTemp(qwSopTemp);
|
|
|
List<QwSopTempDay> dayList = qwSopTempRulesService.listByTempIdAll(oldId);
|
|
|
- if(dayList.isEmpty()) return;
|
|
|
+ if (dayList.isEmpty()) return;
|
|
|
// List<QwSopTempRules> rulesList = qwSopTempRulesService.listByTempId(oldId);
|
|
|
dayList.forEach(day -> {
|
|
|
day.setTempId(newId);
|
|
|
- if(day.getList() != null && !day.getList().isEmpty()){
|
|
|
+ if (day.getList() != null && !day.getList().isEmpty()) {
|
|
|
day.getList().forEach(e -> {
|
|
|
e.setTempId(newId);
|
|
|
- if(e.getSettingList() != null && !e.getSettingList().isEmpty()){
|
|
|
+ if (e.getSettingList() != null && !e.getSettingList().isEmpty()) {
|
|
|
e.getSettingList().forEach(item -> {
|
|
|
item.setTempId(newId);
|
|
|
});
|
|
|
@@ -376,7 +375,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
item.setRulesId(e.getId());
|
|
|
item.setDayId(e.getDayId());
|
|
|
}));
|
|
|
- qwSopTempContentService.insertBatch(collect.stream().flatMap(e ->e.getSettingList().stream()).collect(Collectors.toList()));
|
|
|
+ qwSopTempContentService.insertBatch(collect.stream().flatMap(e -> e.getSettingList().stream()).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -390,7 +389,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
public void sortDay(List<SortDayVo> list) {
|
|
|
Collection<QwSopTempDay> days = qwSopTempDayService.listByIds(PubFun.listToNewList(list, SortDayVo::getId));
|
|
|
Map<Long, Integer> dayMap = list.stream().collect(Collectors.toMap(SortDayVo::getId, SortDayVo::getDayNum));
|
|
|
- if(days.stream().anyMatch(e -> !dayMap.containsKey(e.getId()))){
|
|
|
+ if (days.stream().anyMatch(e -> !dayMap.containsKey(e.getId()))) {
|
|
|
throw new BaseException("数据错误!");
|
|
|
}
|
|
|
days.forEach(day -> day.setDayNum(dayMap.get(day.getId())));
|
|
|
@@ -404,10 +403,10 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
|
|
|
|
|
|
@DataSource(DataSourceType.SOP)
|
|
|
- private void reorder(String tempId){
|
|
|
+ private void reorder(String tempId) {
|
|
|
QwSopTemp qwSopTemp = qwSopTempMapper.selectQwSopTempById(tempId);
|
|
|
List<QwSopTempDay> days = qwSopTempDayService.listByTempId(tempId);
|
|
|
- if(days.isEmpty()) return;
|
|
|
+ if (days.isEmpty()) return;
|
|
|
for (int i = 0; i < days.size(); i++) {
|
|
|
QwSopTempDay entity = days.get(i);
|
|
|
entity.setSorts(i);
|
|
|
@@ -418,7 +417,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
|
|
|
@Override
|
|
|
public void createSopTempRules(QwSopTemp temp) {
|
|
|
- if(temp.getTime() == null){
|
|
|
+ if (temp.getTime() == null) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -436,11 +435,11 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
day.setSorts(day.getDayNum());
|
|
|
day.setList(new ArrayList<>());
|
|
|
List<String> timeList = new ArrayList<>();
|
|
|
- if(temp.getTimeList() != null){
|
|
|
+ if (temp.getTimeList() != null) {
|
|
|
timeList = JSON.parseArray(JSON.toJSONString(temp.getTimeList()), String.class);
|
|
|
}
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
- if(temp.getTime() != null){
|
|
|
+ if (temp.getTime() != null) {
|
|
|
timeList.add(0, temp.getTime().format(formatter));
|
|
|
}
|
|
|
AtomicInteger sorts = new AtomicInteger(0);
|
|
|
@@ -448,15 +447,15 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
QwSopTempRules rules = new QwSopTempRules();
|
|
|
rules.setTempId(temp.getId());
|
|
|
rules.setName(day.getName());
|
|
|
- if (temp.getOpenOfficial().equals("1")){
|
|
|
+ if (temp.getOpenOfficial().equals("1")) {
|
|
|
rules.setIsOfficial(sorts.get() == 0 ? "1" : "0");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
rules.setIsOfficial("0");
|
|
|
}
|
|
|
|
|
|
- if (day.getDayNum()==1 && sorts.get() == 0 && temp.getOpenOfficial().equals("1")){
|
|
|
+ if (day.getDayNum() == 1 && sorts.get() == 0 && temp.getOpenOfficial().equals("1")) {
|
|
|
rules.setTime("01:05");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
rules.setTime(time);
|
|
|
}
|
|
|
|
|
|
@@ -475,10 +474,10 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
setting.setMiniprogramTitle(e.getTitle());
|
|
|
|
|
|
//用课节图片做封面
|
|
|
- if("今正科技".equals(cloudHostProper.getCompanyName())){
|
|
|
- setting.setMiniprogramPicUrl(!StringUtil.isNullOrEmpty(e.getThumbnail())?e.getThumbnail():fsUserCourse.getImgUrl());
|
|
|
- setting.setLinkImageUrl(!StringUtil.isNullOrEmpty(e.getThumbnail())?e.getThumbnail():fsUserCourse.getImgUrl());
|
|
|
- }else {
|
|
|
+ if ("今正科技".equals(cloudHostProper.getCompanyName())) {
|
|
|
+ setting.setMiniprogramPicUrl(!StringUtil.isNullOrEmpty(e.getThumbnail()) ? e.getThumbnail() : fsUserCourse.getImgUrl());
|
|
|
+ setting.setLinkImageUrl(!StringUtil.isNullOrEmpty(e.getThumbnail()) ? e.getThumbnail() : fsUserCourse.getImgUrl());
|
|
|
+ } else {
|
|
|
setting.setMiniprogramPicUrl(fsUserCourse.getImgUrl());
|
|
|
setting.setLinkImageUrl(fsUserCourse.getImgUrl());
|
|
|
|
|
|
@@ -489,7 +488,7 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
setting.setContentType("4");
|
|
|
content.setContent(JSON.toJSONString(setting));
|
|
|
content.setIsBindUrl(1);
|
|
|
- List<QwSopTempContent> qwSopTempContents = new ArrayList<>() ;
|
|
|
+ List<QwSopTempContent> qwSopTempContents = new ArrayList<>();
|
|
|
qwSopTempContents.add(content);
|
|
|
if (sorts.get() == 0 && !StringUtil.isNullOrEmpty(temp.getModeContent())) {
|
|
|
QwSopTempContent content2 = new QwSopTempContent();
|
|
|
@@ -501,13 +500,13 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
content2.setContent(JSON.toJSONString(setting2));
|
|
|
qwSopTempContents.add(content2);
|
|
|
}
|
|
|
- if (sorts.get() > 0){
|
|
|
+ if (sorts.get() > 0) {
|
|
|
|
|
|
QwSopTempContent content3 = new QwSopTempContent();
|
|
|
content3.setTempId(temp.getId());
|
|
|
content3.setContentType(3);
|
|
|
QwSopTempSetting2.Content.Setting setting3 = new QwSopTempSetting2.Content.Setting();
|
|
|
- setting3.setValue(temp.getTimeDesc().get(sorts.get()-1));
|
|
|
+ setting3.setValue(temp.getTimeDesc().get(sorts.get() - 1));
|
|
|
setting3.setContentType("1");
|
|
|
content3.setContent(JSON.toJSONString(setting3));
|
|
|
qwSopTempContents.add(content3);
|
|
|
@@ -515,11 +514,11 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
}
|
|
|
|
|
|
rules.setSorts(sorts.getAndIncrement());
|
|
|
- if(rules.getSorts() == 0){
|
|
|
+ if (rules.getSorts() == 0) {
|
|
|
rules.setCourseType(0);
|
|
|
- }else if(rules.getSorts() == 1){
|
|
|
+ } else if (rules.getSorts() == 1) {
|
|
|
rules.setCourseType(1);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
rules.setCourseType(4);
|
|
|
}
|
|
|
rules.setList(qwSopTempContents);
|
|
|
@@ -540,10 +539,10 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
CourseConfig courseConfig = JSON.parseObject(sysConfig.getConfigValue(), CourseConfig.class);
|
|
|
List<Long> videoIdList = PubFun.listToNewList(ruleList, QwSopTempRules::getVideoId);
|
|
|
Map<Long, Optional<BigDecimal>> redMap;
|
|
|
- if(!videoIdList.isEmpty()){
|
|
|
+ if (!videoIdList.isEmpty()) {
|
|
|
List<FsUserCourseVideoRedPackage> redPackageList = fsUserCourseVideoRedPackageService.listByCompanyIdAndVideoIds(temp.getCompanyId(), videoIdList);
|
|
|
redMap = redPackageList.stream().collect(Collectors.groupingBy(FsUserCourseVideoRedPackage::getVideoId, Collectors.mapping(FsUserCourseVideoRedPackage::getRedPacketMoney, Collectors.reducing((e1, e2) -> e1))));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
redMap = new HashMap<>();
|
|
|
}
|
|
|
|
|
|
@@ -562,15 +561,15 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
@Override
|
|
|
public List<QwSopTempRedPackageVo> redList(String id) {
|
|
|
List<QwSopTempDay> dayList = qwSopTempRulesService.listByTempIdAll(id);
|
|
|
- if(CollectionUtils.isEmpty(dayList)){
|
|
|
+ if (CollectionUtils.isEmpty(dayList)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
List<QwSopTempRules> rules = dayList.stream()
|
|
|
- .filter(e->e!= null && e.getList()!=null)
|
|
|
+ .filter(e -> e != null && e.getList() != null)
|
|
|
.flatMap(e -> e.getList().stream())
|
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
|
- if(rules.isEmpty()){
|
|
|
+ if (rules.isEmpty()) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
List<FsUserCourseVideoRedPackage> redPackageList = fsUserCourseVideoRedPackageService.listByRuleIds(PubFun.listToNewList(rules, QwSopTempRules::getId));
|
|
|
@@ -608,14 +607,93 @@ public class QwSopTempServiceImpl implements IQwSopTempService
|
|
|
}).collect(Collectors.toList());
|
|
|
fsUserCourseVideoRedPackageService.batchSaveFsUserCourseVideoRedPackage(redPackage);
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public List<String> getSelectableRange() {
|
|
|
SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("course.config");
|
|
|
CourseConfig courseConfig = JSON.parseObject(sysConfig.getConfigValue(), CourseConfig.class);
|
|
|
List<CourseConfig.DisabledTimeVo> disabledTimeList = courseConfig.getDisabledTimeList();
|
|
|
- if(disabledTimeList == null){
|
|
|
+ if (disabledTimeList == null) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
return TimeCalculator.calculateAvailableTimes(disabledTimeList);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncTemplate(Long courseId) {
|
|
|
+ // 根据courseId查询所有相关的sop模板规则
|
|
|
+ List<QwSopTempRules> rulesList = qwSopTempRulesService.listByCourseId(courseId);
|
|
|
+ if (CollectionUtils.isEmpty(rulesList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取这些规则关联的模板ID集合
|
|
|
+ Set<String> tempIds = rulesList.stream()
|
|
|
+ .map(QwSopTempRules::getTempId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ // 查询相关联的sop模板
|
|
|
+ if (CollectionUtils.isEmpty(tempIds)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<QwSopTemp> tempList = qwSopTempMapper.selectListByIds(tempIds);
|
|
|
+ tempList = tempList.stream().filter(f -> Objects.equals(f.getStatus(), "1")).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(tempList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<QwSopTempContent> contentList = qwSopTempContentService.listByTempIds(tempIds);
|
|
|
+
|
|
|
+ CountDownLatch latch = new CountDownLatch(tempList.size());
|
|
|
+ // 对每个模板执行同步操作
|
|
|
+ for (QwSopTemp temp : tempList) {
|
|
|
+ // 构造timeList timeDesc time
|
|
|
+ rulesList.stream().filter(e -> e.getTempId().equals(temp.getId())).findFirst()
|
|
|
+ .ifPresent(first -> temp.setTime(LocalTime.parse(first.getTime() + ":00")));
|
|
|
+
|
|
|
+ temp.setTimeList(rulesList.stream()
|
|
|
+ .filter(e -> e.getTempId().equals(temp.getId()) && Objects.equals(e.getIsOfficial(), "0")
|
|
|
+ && Objects.equals(e.getName(), "第1天")).map(QwSopTempRules::getTime)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ // 过滤并找到 dayId 最小的元素
|
|
|
+ Optional<QwSopTempContent> minDayEntity = contentList.stream()
|
|
|
+ // 1. 过滤条件:tempId匹配 + isBindUrl为null
|
|
|
+ .filter(e -> e.getTempId().equals(temp.getId())
|
|
|
+ && Objects.isNull(e.getIsBindUrl()))
|
|
|
+ // 2. 按 dayId 升序排序,取第一个(最小)
|
|
|
+ .min(Comparator.comparingLong(QwSopTempContent::getDayId)); // 若dayId是Long,用comparingLong
|
|
|
+
|
|
|
+ if (minDayEntity.isPresent()) {
|
|
|
+ QwSopTempContent qwSopTempContent = minDayEntity.get();
|
|
|
+ temp.setTimeDesc(contentList.stream().filter(e -> e.getTempId().equals(temp.getId())
|
|
|
+ && Objects.isNull(e.getIsBindUrl())
|
|
|
+ && Objects.equals(qwSopTempContent.getDayId(), e.getDayId())
|
|
|
+ )
|
|
|
+ .map(m -> JSONObject.parseObject(m.getContent()).getString("value")).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 插入课程id
|
|
|
+ temp.setCourseId(courseId);
|
|
|
+ temp.setOpenOfficial("1");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ temp.setCreateTime(sdf.format(new Date()));
|
|
|
+ temp.setId(UUID.randomUUID().toString());
|
|
|
+ qwSopTempMapper.insertQwSopTemp(temp);
|
|
|
+ // 重新生成该模板的规则和内容
|
|
|
+ threadPoolTaskExecutor.execute(() -> createSopTempRules(temp));
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ latch.await();
|
|
|
+ qwSopTempMapper.deleteQwSopTempByIds(tempIds.toArray(new String[0]));
|
|
|
+ qwSopTempDayService.removeByTempIds(tempIds);
|
|
|
+ qwSopTempRulesService.removeByTempIds(tempIds);
|
|
|
+ qwSopTempContentService.removeByTempIds(tempIds);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("等待线程执行完成时被中断", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|