Commit 1e3928a0 by wangli

只返回技术员支持的技能列表,不用返回所有技能的标记

1 parent 2fa3082b
......@@ -34,9 +34,6 @@ public class EngineerServiceImpl implements EngineerService {
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Autowired
private ProductCategory2Dao productCategory2Dao;
@Transactional
@Override
public Result<?> getEngineerInfoList(long page, long size) {
......@@ -80,11 +77,9 @@ public class EngineerServiceImpl implements EngineerService {
// 获取技术员code列表
List<String> engineerCodes = engineers.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList());
// 获取所有技能分类
List<String> skillIds = this.queryProductCategoryIds();
// 获取所有技术员技能列表HashMap<engineerCode, HashMap<skillId, status>>
HashMap<String, HashMap<String, Integer>> engineerSkills = this.queryEngineerSkills(engineerCodes);
// 获取技术员的可用技能列表
HashMap<String, List<String>> engineerSkills = this.queryEngineerSkills(engineerCodes);
List<String> emptySkills = Collections.emptyList();
List<EngineerSkillListResp.EngineerSkill> items = new ArrayList<>();
for(EngineerInfo e: engineers) {
......@@ -94,8 +89,7 @@ public class EngineerServiceImpl implements EngineerService {
skill.setGroupName(groupNames.getOrDefault(e.getGroupId(), ""));
// 获取一个工程师的技能列表
HashMap<String, Integer> engineerSkill = engineerSkills.get(e.getEngineerCode());
skill.setSkills(this.getEngineerSkillIds(skillIds, engineerSkill));
skill.setSkills(engineerSkills.getOrDefault(e.getEngineerCode(), emptySkills));
items.add(skill);
}
......@@ -227,15 +221,16 @@ public class EngineerServiceImpl implements EngineerService {
return map;
}
private HashMap<String, HashMap<String, Integer>> queryEngineerSkills(List<String> engineerCodes) {
// 获取engineerCode对应的技能表, HashMap<engineerCode, HashMap<categoryId, status>>
private HashMap<String, List<String>> queryEngineerSkills(List<String> engineerCodes) {
// 获取engineerCode对应的技能表, HashMap<engineerCode, List<skillId>>
HashMap<String, HashMap<String, Integer>> map = new HashMap<>();
HashMap<String, List<String>> map = new HashMap<>();
if (engineerCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerSkill> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerSkill::getEngineerCode, engineerCodes);
lqw.eq(EngineerSkill::getStatus, 1);
List<EngineerSkill> records = engineerSkillDao.selectList(lqw);
Comparator<EngineerSkill> ec = Comparator.comparing(EngineerSkill::getEngineerCode, String.CASE_INSENSITIVE_ORDER);
......@@ -245,11 +240,9 @@ public class EngineerServiceImpl implements EngineerService {
Map<String, List<EngineerSkill>> g = results.stream().collect(Collectors.groupingBy(EngineerSkill::getEngineerCode));
for(String engineerCode: g.keySet()) {
HashMap<String, Integer> skills = new HashMap<>();
for (EngineerSkill es: g.get(engineerCode)) {
skills.put(es.getCategoryId(), es.getStatus());
}
map.put(engineerCode, skills);
// 技术员技能ID列表
List<String> skillIds = g.get(engineerCode).stream().map(EngineerSkill::getCategoryId).collect(Collectors.toList());
map.put(engineerCode, skillIds);
}
return map;
}
......@@ -268,14 +261,6 @@ public class EngineerServiceImpl implements EngineerService {
return map;
}
private List<String> queryProductCategoryIds() {
// 获取所有技能分类
LambdaQueryWrapper<ProductCategory> lqw = new LambdaQueryWrapper<>();
lqw.select(ProductCategory::getProductCategoryId);
List<ProductCategory> records = productCategory2Dao.selectList(lqw);
return records.stream().map(ProductCategory::getProductCategoryId).collect(Collectors.toList());
}
private List<EngineerInfoListResp.EngineerInfo> packEngineerInfo(List<EngineerInfo> engineers, HashMap<String, String> groups) {
String groupName, age, workType;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!