|
|
|
@@ -19,10 +19,13 @@ package org.dubhe.admin.service.impl; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Maps; |
|
|
|
import org.dubhe.admin.dao.DictDetailMapper; |
|
|
|
import org.dubhe.admin.dao.DictMapper; |
|
|
|
import org.dubhe.admin.domain.dto.*; |
|
|
|
import org.dubhe.admin.domain.entity.Dict; |
|
|
|
import org.dubhe.admin.domain.entity.DictDetail; |
|
|
|
import org.dubhe.admin.service.DictService; |
|
|
|
import org.dubhe.admin.service.convert.DictConvert; |
|
|
|
import org.dubhe.biz.base.exception.BusinessException; |
|
|
|
@@ -33,10 +36,14 @@ import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description 字典服务 实现类 |
|
|
|
@@ -97,14 +104,38 @@ public class DictServiceImpl implements DictService { |
|
|
|
* 通过Name查询字典详情 |
|
|
|
* |
|
|
|
* @param name 字典名称 |
|
|
|
* @param filter 过滤类型: algorithmUsage:异常检测 |
|
|
|
* @return org.dubhe.domain.dto.DictDTO 字典实例 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public DictDTO findByName(String name) { |
|
|
|
public DictDTO findByName(String name, String filter) { |
|
|
|
Dict dict = dictMapper.selectCollByName(name); |
|
|
|
if (!StringUtils.isEmpty(filter) && !ObjectUtils.isEmpty(dict) && !CollectionUtils.isEmpty(dict.getDictDetails())) { |
|
|
|
// algorithmUsage:异常检测 |
|
|
|
String[] split = filter.split(":"); |
|
|
|
String s = split[1]; |
|
|
|
List<String> algorithmLimit = configAlgorithmLimit(s); |
|
|
|
List<DictDetail> collect = dict.getDictDetails().stream().filter(item -> CollectionUtils.isEmpty(algorithmLimit) || algorithmLimit.contains(item.getValue())).collect(Collectors.toList()); |
|
|
|
dict.setDictDetails(collect); |
|
|
|
} |
|
|
|
return dictConvert.toDto(dict); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* - 算法(异常检测、安全预警和健康状态)对应数据集的(车端和桩端) |
|
|
|
* - 算法(其他)对应数据集的(实验、其他) |
|
|
|
* @param name |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<String> configAlgorithmLimit(String name){ |
|
|
|
HashMap<String, List<String>> hashMap = Maps.newHashMap(); |
|
|
|
hashMap.put("异常检测", Lists.newArrayList("101", "102")); |
|
|
|
hashMap.put("安全预警", Lists.newArrayList("101", "102")); |
|
|
|
hashMap.put("健康状态", Lists.newArrayList("101", "102")); |
|
|
|
hashMap.put("其他", Lists.newArrayList("105", "106")); |
|
|
|
return hashMap.get(name); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增字典 |
|
|
|
* |
|
|
|
|