Commit 40064b6c by 刘鑫

fix(改派推荐工程师): 改派推荐工程师距离为不限制时不做距离过滤

1 parent 822072a4
...@@ -14,7 +14,7 @@ public class RecommendEngineersReq { ...@@ -14,7 +14,7 @@ public class RecommendEngineersReq {
*/ */
private String key; private String key;
/** /**
* 距离范围(单位:KM), 不传默认10.0 KM * 距离范围(单位:KM), 不传改值为:不限
*/ */
private Double distance; private Double distance;
/** /**
......
...@@ -64,6 +64,7 @@ import java.math.BigDecimal; ...@@ -64,6 +64,7 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -321,13 +322,13 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -321,13 +322,13 @@ public class OrderAssignImpl implements OrderAssign {
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill()); SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(order.getBrand(), order.getType(), order.getSkill());
if (skill == null) { if (skill == null) {
log.info("skill_info表没有匹配到技能配置:{}-{}-{}", order.getBrand(), order.getY(), order.getSkill()); log.info("skill_info表没有匹配到技能配置:{}-{}-{}", order.getBrand(), order.getY(), order.getSkill());
return new ArrayList<>(); return Collections.emptyList();
} }
Set<String> engineerCodes3 = engineerSkillGroupDao.findBySkillGroupCode(skill.getSkillGroupCode()).stream().map( Set<String> engineerCodes3 = engineerSkillGroupDao.findBySkillGroupCode(skill.getSkillGroupCode()).stream().map(
EngineerSkillGroupEntity::getEngineerCode).collect(Collectors.toSet()); EngineerSkillGroupEntity::getEngineerCode).collect(Collectors.toSet());
if (engineerCodes3.isEmpty()) { if (engineerCodes3.isEmpty()) {
log.info("没有匹配到技能相匹配的技术员:{}-{}-{}", order.getBrand(), order.getType(), order.getSkill()); log.info("没有匹配到技能相匹配的技术员:{}-{}-{}", order.getBrand(), order.getType(), order.getSkill());
return new ArrayList<>(); return Collections.emptyList();
} }
engineerCodes1.retainAll(engineerCodes3); engineerCodes1.retainAll(engineerCodes3);
if (engineerCodes1.isEmpty()) { if (engineerCodes1.isEmpty()) {
...@@ -338,20 +339,20 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -338,20 +339,20 @@ public class OrderAssignImpl implements OrderAssign {
// 获取工程师位置(准实时位置)并进行距离判定, distance如果为空值 默认10KM // 获取工程师位置(准实时位置)并进行距离判定, distance如果为空值 默认10KM
double orderLongitude = Double.parseDouble(order.getX()); double orderLongitude = Double.parseDouble(order.getX());
double orderLatitude = Double.parseDouble(order.getY()); double orderLatitude = Double.parseDouble(order.getY());
if (Objects.isNull(distance)) { if (Objects.nonNull(distance)) {
distance = 10.0D; final BigDecimal finalDistance = BigDecimal.valueOf(distance);
return engineerCodes1.stream()
.filter(engineerCode -> {
Location location = engineerDateLocation(engineerCode);
BigDecimal orderAndEngineerDistance = BigDecimal.valueOf(Stapial4jUtil.getDistance(location.getLongitude(), location.getLatitude(),
orderLongitude, orderLatitude));
return orderAndEngineerDistance.compareTo(finalDistance) <= 0;
}).collect(Collectors.toList());
} }
final BigDecimal finalDistance = BigDecimal.valueOf(distance);
return engineerCodes1.stream()
.filter(engineerCode -> {
Location location = engineerDateLocation(engineerCode);
BigDecimal orderAndEngineerDistance = BigDecimal.valueOf(Stapial4jUtil.getDistance(location.getLongitude(), location.getLatitude(),
orderLongitude, orderLatitude));
return orderAndEngineerDistance.compareTo(finalDistance) <= 0;
}).collect(Collectors.toList());
return new ArrayList<>(engineerCodes1);
} }
private Location engineerDateLocation(String engineerCode) { private Location engineerDateLocation(String engineerCode) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!