Commit 25fb7a90 by wangli

新增接口

1 parent 8bac2140
......@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -40,15 +41,13 @@ public class EngineerServiceImpl implements EngineerService {
@Override
public Result<?> getEngineerInfoList(long page, long size) {
// 查询工程师信息
IPage<EngineerInfo> pg = this.queryEngineerInfo(page, size);
IPage<EngineerInfo> pg = this.queryEngineerInfoIPage(page, size);
List<EngineerInfo> records = pg.getRecords();
// 获取groupIds
List<String> groupIds = new ArrayList<>();
for(EngineerInfo e: records){
groupIds.add(e.getGroupId());
}
List<String> groupIds = records.stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
// 获取Map<groupId, groupName>
HashMap<String, String> groupNames = this.queryGroupNames(groupIds);
......@@ -63,12 +62,34 @@ public class EngineerServiceImpl implements EngineerService {
return Result.success(res);
}
@Override
public Result<?> getEngineerInfoDetail(String engineerCode) {
// 获取技术员基础信息详情
HashMap<String, String> map = new HashMap<>();
// 获取技术员列表
List<EngineerInfo> records = this.queryEngineerInfos(engineerCode);
if (records.isEmpty()){
return Result.success(map);
}
List<String> groupIds = records.stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, String> groupNames = this.queryGroupNames(groupIds);
List<EngineerInfoListResp.EngineerInfo> items = this.packEngineerInfo(records, groupNames);
if (items.isEmpty()) {
return Result.success(map);
}
return Result.success(items.get(0));
}
@Transactional
@Override
public Result<?> getEngineerSkillList(long page, long size) {
// 获取技术员技能列表
IPage<EngineerInfo> pg = this.queryEngineerInfo(page, size);
IPage<EngineerInfo> pg = this.queryEngineerInfoIPage(page, size);
List<EngineerInfo> engineers = pg.getRecords();
......@@ -106,6 +127,12 @@ public class EngineerServiceImpl implements EngineerService {
return Result.success(res);
}
@Override
public Result<?> getEngineerSkillDetail(String engineerCode) {
// 获取工程师技能详情
return null;
}
@Transactional
@Override
public Result<?> engineerSkillUpdate(String engineerCode, List<String> categoryIds) {
......@@ -153,7 +180,7 @@ public class EngineerServiceImpl implements EngineerService {
// 技术员业务属性配置列表
// 查询技术员列表
IPage<EngineerInfo> pg = this.queryEngineerInfo(page, size);
IPage<EngineerInfo> pg = this.queryEngineerInfoIPage(page, size);
List<EngineerInfo> records = pg.getRecords();
......@@ -209,6 +236,12 @@ public class EngineerServiceImpl implements EngineerService {
return Result.success(res);
}
@Override
public Result<?> getEngineerBusinessDetail(String engineerCode) {
// 获取技术员业务熟悉详情
return null;
}
@Transactional
@Override
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, String departure, String priority) {
......@@ -238,7 +271,7 @@ public class EngineerServiceImpl implements EngineerService {
return Result.success(null);
}
private IPage<EngineerInfo> queryEngineerInfo(long page, long size) {
private IPage<EngineerInfo> queryEngineerInfoIPage(long page, long size) {
// 分页查询工程师基础信息
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.orderByAsc(EngineerInfo::getGroupId);
......@@ -249,6 +282,13 @@ public class EngineerServiceImpl implements EngineerService {
return pg;
}
private List<EngineerInfo> queryEngineerInfos(String engineerCode) {
// 分页查询工程师基础信息
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.eq(EngineerInfo::getEngineerCode, engineerCode);
return engineerInfoMPDao.selectList(lqw);
}
private HashMap<String, String> queryGroupNames(List<String> groupIds) {
//查询小组名称映射关系
HashMap<String, String> map = new HashMap<>();
......@@ -308,7 +348,7 @@ public class EngineerServiceImpl implements EngineerService {
private List<EngineerInfoListResp.EngineerInfo> packEngineerInfo(List<EngineerInfo> engineers, HashMap<String, String> groups) {
String groupName, age, workType;
String groupName, age, kind;
List<EngineerInfoListResp.EngineerInfo> items = new ArrayList<>();
for(EngineerInfo e: engineers) {
......@@ -319,15 +359,39 @@ public class EngineerServiceImpl implements EngineerService {
item.setSex(e.getGender());
item.setPhone(e.getPhone());
item.setAddress(e.getAddress());
item.setGrade(e.getGrade());
// group name
groupName = groups.getOrDefault(e.getGroupId(), "");
item.setGroupName(groupName);
// 年龄
age = this.getEngineerAge(e.getBirth());
item.setAge(age);
workType = (e.getKind() == 1) ? "fullJob": "partJob";
item.setKind(workType);
// 工作类型:全职/兼职
kind = (e.getKind() == 1) ? "fullJob": "partJob";
item.setKind(kind);
if(e.getCredentials() != null){
item.setCredentials(Arrays.asList(e.getCredentials().split("、")));
} else{
item.setCredentials(new ArrayList<String>());
}
// 标签
List<String> tags = new ArrayList<>();
if (e.getTags() != null) {
Iterator<Map.Entry<String, JsonNode>> it = e.getTags().fields();
while(it.hasNext()){
Map.Entry<String, JsonNode> field = it.next();
String name = field.getKey();
JsonNode value = field.getValue();
tags.add(String.format("%s+%d",field.getKey(), field.getValue().intValue()));
}
} else {
item.setTags(tags);
}
items.add(item);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!