Commit d055e92a by 丁伟峰

增加了按某一个级别,返回下面所有的技术员的接口

1 parent 31282576
...@@ -3,7 +3,8 @@ package com.dituhui.pea.order.controller; ...@@ -3,7 +3,8 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.LevelReqDTO; import com.dituhui.pea.order.dto.LevelReqDTO;
import com.dituhui.pea.order.dto.OrganizationEngineersReqDTO; import com.dituhui.pea.order.dto.OrganizationEngineersDTO;
import com.dituhui.pea.order.dto.OrganizationEngineersByTeamsDTO;
import com.dituhui.pea.order.service.OrganizationService; import com.dituhui.pea.order.service.OrganizationService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -42,7 +43,7 @@ public class OrganizationController { ...@@ -42,7 +43,7 @@ public class OrganizationController {
} }
@GetMapping("/organization/engineer/list") @GetMapping("/organization/engineer/list")
public Result<?> getTeamsEngineers(OrganizationEngineersReqDTO reqDTO) { public Result<?> getEngineersByTeams(OrganizationEngineersByTeamsDTO.Request reqDTO) {
Result<?> res = null; Result<?> res = null;
try { try {
res = organizationService.getEngineersByTeams(reqDTO.getTeamIds()); res = organizationService.getEngineersByTeams(reqDTO.getTeamIds());
...@@ -51,4 +52,15 @@ public class OrganizationController { ...@@ -51,4 +52,15 @@ public class OrganizationController {
} }
return res; return res;
} }
@GetMapping("/organization/engineer/all")
public Result<?> getEngineersByOrganization(OrganizationEngineersDTO.Request reqDTO) {
Result<?> res = null;
try {
res = organizationService.getEngineersByLevel(reqDTO.getLevelType(), reqDTO.getLevelValue());
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
} }
...@@ -5,7 +5,13 @@ import com.dituhui.pea.order.entity.EngineerInfoEntity; ...@@ -5,7 +5,13 @@ import com.dituhui.pea.order.entity.EngineerInfoEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integer> { public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integer> {
EngineerInfoEntity getByEngineerCode(String engineerCode); EngineerInfoEntity getByEngineerCode(String engineerCode);
List<EngineerInfoEntity> findByGroupId(String groupId);
List<EngineerInfoEntity> findByGroupIdIn(List<String> groupIds);
} }
...@@ -13,5 +13,7 @@ public interface OrgGroupDao extends JpaRepository<OrgGroupEntity, Integer> { ...@@ -13,5 +13,7 @@ public interface OrgGroupDao extends JpaRepository<OrgGroupEntity, Integer> {
List<OrgGroupEntity> findAllByBranchId(String branchId); List<OrgGroupEntity> findAllByBranchId(String branchId);
List<OrgGroupEntity> findAllByClusterId(String clusterId);
OrgGroupEntity getByGroupId(String groupId); OrgGroupEntity getByGroupId(String groupId);
} }
...@@ -6,10 +6,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; ...@@ -6,10 +6,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
@lombok.Data @lombok.Data
public class OrderChangeListReqDTO { public class OrderChangeListReqDTO {
......
package com.dituhui.pea.order.dto; package com.dituhui.pea.order.dto;
import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.checkerframework.checker.units.qual.Acceleration;
import java.util.List; import java.util.List;
@lombok.Data public class OrganizationEngineersByTeamsDTO {
@Accessors(chain = true)
public class OrganizationEngineersRespDTO { @Data
public static class Request {
private List<String> teamIds;
}
@Data
@Accessors(chain = true)
public static class Result {
private List<?> engineers; private List<?> engineers;
}
@lombok.Data @Data
public static class Engineer { public static class Engineer {
/** /**
* 技术员id * 技术员id
......
package com.dituhui.pea.order.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
public class OrganizationEngineersDTO {
@Data
@Accessors(chain = true)
public static class Request {
private String levelType;
private String levelValue;
}
@Data
@Accessors(chain = true)
public static class Result {
private List<Engineer> engineers;
private String levelType;
private String levelValue;
}
@Data
@Accessors(chain = true)
public static class Engineer {
private String engineerCode;
private String engineerName;
private String phone;
}
}
package com.dituhui.pea.order.dto;
import lombok.experimental.Accessors;
import java.util.List;
@lombok.Data
public class OrganizationEngineersReqDTO {
private List<String> teamIds;
}
...@@ -10,4 +10,6 @@ public interface OrganizationService { ...@@ -10,4 +10,6 @@ public interface OrganizationService {
Result<?> getEngineersByTeams(List<String> teamIds); Result<?> getEngineersByTeams(List<String> teamIds);
Result<?> getTeamsByLevel(String levelType, String levelValue); Result<?> getTeamsByLevel(String levelType, String levelValue);
Result<?> getEngineersByLevel(String levelType, String levelValue);
} }
...@@ -2,9 +2,7 @@ package com.dituhui.pea.order.service.impl; ...@@ -2,9 +2,7 @@ package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.OrganizationEngineersRespDTO; import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.dto.OrganizationTeamsRespDTO;
import com.dituhui.pea.order.dto.OrganizationTreeRespDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.OrganizationService; import com.dituhui.pea.order.service.OrganizationService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -14,6 +12,7 @@ import org.springframework.stereotype.Service; ...@@ -14,6 +12,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
...@@ -71,16 +70,16 @@ public class OrganizationServiceImpl implements OrganizationService { ...@@ -71,16 +70,16 @@ public class OrganizationServiceImpl implements OrganizationService {
@Override @Override
public Result<?> getEngineersByTeams(List<String> teamIds) { public Result<?> getEngineersByTeams(List<String> teamIds) {
List<OrganizationEngineersRespDTO.Engineer> engineers = new ArrayList<>(); List<OrganizationEngineersByTeamsDTO.Engineer> engineers = new ArrayList<>();
for (OrgTeamEngineerEntity e : orgTeamEngineerDao.findAllByTeamIdIn(teamIds)) { for (OrgTeamEngineerEntity e : orgTeamEngineerDao.findAllByTeamIdIn(teamIds)) {
EngineerInfoEntity engineerInfoEntity = engineerInfoDao.getByEngineerCode(e.getEngineerCode()); EngineerInfoEntity engineerInfoEntity = engineerInfoDao.getByEngineerCode(e.getEngineerCode());
if (engineerInfoEntity == null) { if (engineerInfoEntity == null) {
log.error("技术员信息不存在!engineer_code: {}", e.getEngineerCode()); log.error("技术员信息不存在!engineer_code: {}", e.getEngineerCode());
continue; continue;
} }
engineers.add(new OrganizationEngineersRespDTO.Engineer(e.getTeamId(), e.getEngineerCode(), engineerInfoEntity.getName())); engineers.add(new OrganizationEngineersByTeamsDTO.Engineer(e.getTeamId(), e.getEngineerCode(), engineerInfoEntity.getName()));
} }
return Result.success(new OrganizationEngineersRespDTO().setEngineers(engineers)); return Result.success(new OrganizationEngineersByTeamsDTO.Result().setEngineers(engineers));
} }
@Override @Override
...@@ -110,6 +109,33 @@ public class OrganizationServiceImpl implements OrganizationService { ...@@ -110,6 +109,33 @@ public class OrganizationServiceImpl implements OrganizationService {
return Result.success(new OrganizationTeamsRespDTO().setTeams(teams)); return Result.success(new OrganizationTeamsRespDTO().setTeams(teams));
} }
@Override
public Result<?> getEngineersByLevel(String levelType, String levelValue) {
List<EngineerInfoEntity> engineers = null;
assert "group".equals(levelType) || "branch".equals(levelType) || "cluster".equals(levelType);
if ("group".equals(levelType)) {
engineers = engineerInfoDao.findByGroupId(levelType);
} else if ("branch".equals(levelType)) {
List<String> groupIds = orgGroupDao.findAllByBranchId(levelValue).stream()
.map(OrgGroupEntity::getGroupId).collect(Collectors.toList());
engineers = engineerInfoDao.findByGroupIdIn(groupIds);
} else {
// "cluster".equals(levelType)
List<String> groupIds = orgGroupDao.findAllByClusterId(levelValue).stream()
.map(OrgGroupEntity::getGroupId).collect(Collectors.toList());
engineers = engineerInfoDao.findByGroupIdIn(groupIds);
}
List<OrganizationEngineersDTO.Engineer> engineers1 = engineers.stream().map(entity -> {
return new OrganizationEngineersDTO.Engineer()
.setEngineerCode(entity.getEngineerCode())
.setEngineerName(entity.getName())
.setPhone(entity.getPhone());
}).collect(Collectors.toList());
OrganizationEngineersDTO.Result rs = new OrganizationEngineersDTO.Result();
rs.setLevelType(levelType).setLevelValue(levelValue).setEngineers(engineers1);
return Result.success(rs);
}
private List<?> getTreeByRoot() { private List<?> getTreeByRoot() {
List<OrganizationTreeRespDTO.Cluster> clusters = new ArrayList<>(); List<OrganizationTreeRespDTO.Cluster> clusters = new ArrayList<>();
for (OrgClusterEntity c : orgClusterDao.findAll()) { for (OrgClusterEntity c : orgClusterDao.findAll()) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!