| | |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.smartor.common.PinYinUtil; |
| | | import com.smartor.domain.IvrLibaTargetAssort; |
| | | import com.smartor.domain.SvyLibScriptCategory; |
| | | import com.smartor.domain.SvyLibScriptCategoryVO; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<SvyLibScriptCategoryVO> selectSvyLibScriptCategoryList(SvyLibScriptCategory svyLibScriptCategory) { |
| | | List<SvyLibScriptCategory> svyLibScriptCategories = svyLibScriptCategoryMapper.selectSvyLibScriptCategoryList(svyLibScriptCategory); |
| | | //将pid为空的,过滤掉 |
| | | svyLibScriptCategories = svyLibScriptCategories.stream().filter(assort -> assort.getPid() == null).collect(Collectors.toList()); |
| | | List<SvyLibScriptCategoryVO> svyLibScriptCategoryVOS = DtoConversionUtils.sourceToTarget(svyLibScriptCategories, SvyLibScriptCategoryVO.class); |
| | | |
| | | List<SvyLibScriptCategoryVO> SvyLibScriptCategoryVO = DtoConversionUtils.sourceToTarget(svyLibScriptCategories, SvyLibScriptCategoryVO.class); |
| | | //遍历查出来的数据,通过 id=pid 获取他们的子数据 |
| | | for (SvyLibScriptCategoryVO svyLibScriptCategoryVO : SvyLibScriptCategoryVO) { |
| | | if (svyLibScriptCategoryVO.getPid() != null) { |
| | | continue; |
| | | } |
| | | SvyLibScriptCategory svyLibScriptCategory1 = new SvyLibScriptCategory(); |
| | | svyLibScriptCategory1.setPid(svyLibScriptCategoryVO.getId()); |
| | | List<SvyLibScriptCategory> svyLibScriptCategories1 = svyLibScriptCategoryMapper.selectSvyLibScriptCategoryList(svyLibScriptCategory1); |
| | | if (!Collections.isEmpty(svyLibScriptCategories1)) { |
| | | svyLibScriptCategoryVO.setSvyLibScriptCategoryList(svyLibScriptCategories1); |
| | | List<SvyLibScriptCategoryVO> rootList = new ArrayList<>(); |
| | | Map<Long, SvyLibScriptCategoryVO> categoryMap = new HashMap<>(); |
| | | |
| | | // 建立id->对象的映射 |
| | | for (SvyLibScriptCategoryVO category : svyLibScriptCategoryVOS) { |
| | | categoryMap.put(category.getId(), category); |
| | | } |
| | | |
| | | for (SvyLibScriptCategoryVO category : svyLibScriptCategoryVOS) { |
| | | if (category.getPid() == null || category.getPid() == -1) { |
| | | // 顶层节点 |
| | | rootList.add(category); |
| | | } else { |
| | | // 找到父节点,并添加到其子节点列表 |
| | | SvyLibScriptCategoryVO parent = categoryMap.get(category.getPid()); |
| | | if (parent != null) { |
| | | SvyLibScriptCategory sc = DtoConversionUtils.sourceToTarget(category, SvyLibScriptCategory.class); |
| | | parent.getSvyLibScriptCategoryList().add(sc); |
| | | } |
| | | } |
| | | } |
| | | return SvyLibScriptCategoryVO; |
| | | return rootList; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public int updateSvyLibScriptCategory(SvyLibScriptCategory svyLibScriptCategory) { |
| | | svyLibScriptCategory.setUpdateTime(DateUtils.getNowDate()); |
| | | if (svyLibScriptCategory.getName() != null && svyLibScriptCategory.getName().contains("满意度") && svyLibScriptCategory.getPid() != -1) { |
| | | svyLibScriptCategory.setType(PinYinUtil.getpy(svyLibScriptCategory.getName())); |
| | | } |
| | | return svyLibScriptCategoryMapper.updateSvyLibScriptCategory(svyLibScriptCategory); |
| | | } |
| | | |
| | |
| | | svyLibScriptCategory.setUpdateTime(new Date()); |
| | | svyLibScriptCategory.setCreateTime(new Date()); |
| | | if (svyLibScriptCategory.getPid() == null) svyLibScriptCategory.setPid((long) -1); |
| | | if (svyLibScriptCategory.getName() != null && svyLibScriptCategory.getName().contains("满意度") && svyLibScriptCategory.getPid() != -1) { |
| | | svyLibScriptCategory.setType(PinYinUtil.getpy(svyLibScriptCategory.getName())); |
| | | } |
| | | i = svyLibScriptCategoryMapper.insertSvyLibScriptCategory(svyLibScriptCategory); |
| | | log.info("问题话术分类库一级树的主键:{}", svyLibScriptCategory.getId()); |
| | | |
| | |
| | | if (seqMax1 != null) { |
| | | svyLibScriptCategory1.setSeqno(seqMax1 + 1); |
| | | } |
| | | if (svyLibScriptCategory1.getName() != null && svyLibScriptCategory1.getName().contains("满意度")) { |
| | | svyLibScriptCategory1.setType(PinYinUtil.getpy(svyLibScriptCategory1.getName())); |
| | | } |
| | | |
| | | svyLibScriptCategory1.setGuid(svyLibScriptCategoryVO.getGuid()); |
| | | svyLibScriptCategory1.setOrgid(svyLibScriptCategoryVO.getOrgid()); |
| | | svyLibScriptCategoryMapper.insertSvyLibScriptCategory(svyLibScriptCategory1); |