|
|
|
|
@ -1,13 +1,22 @@
|
|
|
|
|
package com.flossom.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.flossom.common.core.domain.entity.SysTag;
|
|
|
|
|
import com.flossom.common.core.domain.entity.WxScriptTag;
|
|
|
|
|
import com.flossom.common.core.domain.entity.WxScriptTemplate;
|
|
|
|
|
import com.flossom.common.core.mapper.SysTagMapper;
|
|
|
|
|
import com.flossom.common.core.mapper.WxScriptTagMapper;
|
|
|
|
|
import com.flossom.common.core.mapper.WxScriptTemplateMapper;
|
|
|
|
|
import com.flossom.common.core.utils.DateUtils;
|
|
|
|
|
import com.flossom.common.core.utils.StringUtils;
|
|
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.flossom.system.service.IWxScriptTagService;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 话术模板与标签关联Service业务层处理
|
|
|
|
|
@ -20,6 +29,10 @@ public class WxScriptTagServiceImpl implements IWxScriptTagService
|
|
|
|
|
{
|
|
|
|
|
@Autowired
|
|
|
|
|
private WxScriptTagMapper wxScriptTagMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private WxScriptTemplateMapper wxScriptTemplateMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysTagMapper sysTagMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询话术模板与标签关联
|
|
|
|
|
@ -97,6 +110,47 @@ public class WxScriptTagServiceImpl implements IWxScriptTagService
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteWxScriptTagByTagId(Long tagId) {
|
|
|
|
|
// 先找出来,符合的所有标签
|
|
|
|
|
WxScriptTag tag = new WxScriptTag();
|
|
|
|
|
tag.setTagId(tagId);
|
|
|
|
|
List<WxScriptTag> wxScriptTags = wxScriptTagMapper.selectWxScriptTagList(tag);
|
|
|
|
|
// 开始组装新的数据以及更新源数据
|
|
|
|
|
if (!CollectionUtils.isEmpty(wxScriptTags)) {
|
|
|
|
|
for (WxScriptTag wxScriptTag: wxScriptTags) {
|
|
|
|
|
Long scriptId = wxScriptTag.getScriptId();
|
|
|
|
|
// 话术模板
|
|
|
|
|
WxScriptTemplate wxScriptTemplate = wxScriptTemplateMapper.selectWxScriptTemplateById(scriptId);
|
|
|
|
|
if (Objects.nonNull(wxScriptTemplate)) {
|
|
|
|
|
WxScriptTag tagsVO = new WxScriptTag();
|
|
|
|
|
tagsVO.setScriptId(scriptId);
|
|
|
|
|
// 反查得到所有的标签
|
|
|
|
|
List<WxScriptTag> wxScriptTotalTags = wxScriptTagMapper.selectWxScriptTagList(tagsVO);
|
|
|
|
|
// 过滤删除的标签
|
|
|
|
|
if (!CollectionUtils.isEmpty(wxScriptTotalTags)) {
|
|
|
|
|
// 获取过滤后的标签的信息
|
|
|
|
|
List<WxScriptTag> collectList = wxScriptTotalTags.stream().filter(x -> !String.valueOf(x.getTagId()).equals(String.valueOf(tagId))).collect(Collectors.toList());
|
|
|
|
|
List<SysTag> createSysTagList = Lists.newArrayList();
|
|
|
|
|
if (!CollectionUtils.isEmpty(collectList)) {
|
|
|
|
|
for (WxScriptTag scriptTag : collectList) {
|
|
|
|
|
SysTag sysTag = sysTagMapper.selectDeptById(scriptTag.getTagId());
|
|
|
|
|
if (Objects.nonNull(sysTag)) {
|
|
|
|
|
createSysTagList.add(sysTag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!CollectionUtils.isEmpty(createSysTagList)) {
|
|
|
|
|
String tagNames = createSysTagList.stream().map(SysTag::getTagName).collect(Collectors.joining(","));
|
|
|
|
|
wxScriptTemplate.setTagNames(tagNames);
|
|
|
|
|
List<Long> resultList = createSysTagList.stream().map(SysTag::getId).collect(Collectors.toList());
|
|
|
|
|
String ids = StringUtils.join(resultList, ",");
|
|
|
|
|
wxScriptTemplate.setTagIds(ids);
|
|
|
|
|
wxScriptTemplateMapper.updateWxScriptTemplate(wxScriptTemplate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return wxScriptTagMapper.deleteWxScriptTagByTagId(tagId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|