Commit 9636c482 by wangli

新增工程师技能列表实现

1 parent 1c2432dd
package com.alibaba.cloud.integration.order.dto;
import lombok.Data;
import java.util.HashMap;
import java.util.List;
@Data
public class EngineerSkillListResp {
private long total;
private long pages;
private long pageCurrent;
private long pageSize;
private List<EngineerSkill> content;
@Data
public static class EngineerSkill{
private String engineerCode;
private String engineerName;
private String groupName;
private HashMap<String, Integer> skills;
}
}
package com.alibaba.cloud.integration.order.service.impl; package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.EngineerBusinessDao; import com.alibaba.cloud.integration.order.dao.*;
import com.alibaba.cloud.integration.order.dao.EngineerInfoDao;
import com.alibaba.cloud.integration.order.dao.EngineerSkillDao;
import com.alibaba.cloud.integration.order.dao.OrgGroupDao;
import com.alibaba.cloud.integration.order.dto.EngineerBusinessListResp; import com.alibaba.cloud.integration.order.dto.EngineerBusinessListResp;
import com.alibaba.cloud.integration.order.dto.EngineerInfoListResp; import com.alibaba.cloud.integration.order.dto.EngineerInfoListResp;
import com.alibaba.cloud.integration.order.entity.EngineerBusiness; import com.alibaba.cloud.integration.order.dto.EngineerSkillListResp;
import com.alibaba.cloud.integration.order.entity.EngineerInfo; import com.alibaba.cloud.integration.order.entity.*;
import com.alibaba.cloud.integration.order.entity.OrgGroup;
import com.alibaba.cloud.integration.order.service.EngineerService; import com.alibaba.cloud.integration.order.service.EngineerService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
...@@ -38,6 +34,9 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -38,6 +34,9 @@ public class EngineerServiceImpl implements EngineerService {
@Autowired @Autowired
private EngineerBusinessDao engineerBusinessDao; private EngineerBusinessDao engineerBusinessDao;
@Autowired
private ProductCategory2Dao productCategory2Dao;
@Transactional @Transactional
@Override @Override
public Result<?> getEngineerInfoList(long page, long size) { public Result<?> getEngineerInfoList(long page, long size) {
...@@ -69,7 +68,44 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -69,7 +68,44 @@ public class EngineerServiceImpl implements EngineerService {
@Override @Override
public Result<?> getEngineerSkillList(long page, long size) { public Result<?> getEngineerSkillList(long page, long size) {
// 获取技术员技能列表 // 获取技术员技能列表
return null;
IPage<EngineerInfo> pg = this.queryEngineerInfo(page, size);
List<EngineerInfo> engineers = pg.getRecords();
// 获取groupId类表
List<String> groupIds = engineers.stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, String> groupNames = this.queryGroupNames(groupIds);
// 获取技术员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);
List<EngineerSkillListResp.EngineerSkill> items = new ArrayList<>();
for(EngineerInfo e: engineers) {
EngineerSkillListResp.EngineerSkill skill = new EngineerSkillListResp.EngineerSkill();
skill.setEngineerCode(e.getEngineerCode());
skill.setEngineerName(e.getName());
skill.setGroupName(groupNames.getOrDefault(e.getGroupId(), ""));
// 获取一个工程师的技能列表
HashMap<String, Integer> engineerSkill = engineerSkills.get(e.getEngineerCode());
skill.setSkills(this.getEngineerSkillIds(skillIds, engineerSkill));
items.add(skill);
}
EngineerSkillListResp res = new EngineerSkillListResp();
res.setTotal(pg.getTotal());
res.setPages(pg.getPages());
res.setPageCurrent(pg.getCurrent());
res.setPageSize(pg.getSize());
res.setContent(items);
return Result.success(res);
} }
@Transactional @Transactional
...@@ -147,7 +183,7 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -147,7 +183,7 @@ public class EngineerServiceImpl implements EngineerService {
Integer dep = (departure.equals("配件仓")) ? 1 : 2; Integer dep = (departure.equals("配件仓")) ? 1 : 2;
wrapper.set(EngineerBusiness::getDeparture, dep); wrapper.set(EngineerBusiness::getDeparture, dep);
Integer pri; int pri;
if (priority.equals("高")) { if (priority.equals("高")) {
pri = 3; pri = 3;
} else if (priority.equals("中")) { } else if (priority.equals("中")) {
...@@ -191,6 +227,33 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -191,6 +227,33 @@ public class EngineerServiceImpl implements EngineerService {
return map; return map;
} }
private HashMap<String, HashMap<String, Integer>> queryEngineerSkills(List<String> engineerCodes) {
// 获取engineerCode对应的技能表, HashMap<engineerCode, HashMap<categoryId, status>>
HashMap<String, HashMap<String, Integer>> map = new HashMap<>();
if (engineerCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerSkill> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerSkill::getEngineerCode, engineerCodes);
List<EngineerSkill> records = engineerSkillDao.selectList(lqw);
Comparator<EngineerSkill> ec = Comparator.comparing(EngineerSkill::getEngineerCode, String.CASE_INSENSITIVE_ORDER);
List<EngineerSkill> results = records.stream().sorted(ec).collect(Collectors.toList());
// 根据engineerCode分组
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);
}
return map;
}
private HashMap<String, EngineerBusiness> queryEngineerBusiness(List<String> engineerCodes) { private HashMap<String, EngineerBusiness> queryEngineerBusiness(List<String> engineerCodes) {
HashMap<String, EngineerBusiness> map = new HashMap<>(); HashMap<String, EngineerBusiness> map = new HashMap<>();
if (engineerCodes.isEmpty()) { if (engineerCodes.isEmpty()) {
...@@ -205,6 +268,14 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -205,6 +268,14 @@ public class EngineerServiceImpl implements EngineerService {
return map; 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) { private List<EngineerInfoListResp.EngineerInfo> packEngineerInfo(List<EngineerInfo> engineers, HashMap<String, String> groups) {
String groupName, age, workType; String groupName, age, workType;
...@@ -233,6 +304,14 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -233,6 +304,14 @@ public class EngineerServiceImpl implements EngineerService {
return items; return items;
} }
private HashMap<String, Integer> getEngineerSkillIds(List<String> skillIds, HashMap<String, Integer> engineerSkillIds) {
HashMap<String, Integer> map = new HashMap<>();
for(String skillId: skillIds) {
map.put(skillId, engineerSkillIds.getOrDefault(skillId, 0));
}
return map;
}
private String getEngineerAge(String birth) { private String getEngineerAge(String birth) {
// 获取工程师年龄 // 获取工程师年龄
if (birth.isEmpty()) { if (birth.isEmpty()) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!