Commit c707d5a6 by 刘鑫

fix(ID1003988): 增加工程师各类型位置

1 parent 83887b88
package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.dto.param.TLocation;
import com.dituhui.pea.order.enums.TestimonialsEngineerTag;
import lombok.Data;
......@@ -19,6 +20,10 @@ public class OrderAssignRecommendResp {
* 工程师标签
*/
private TestimonialsEngineerTag distanceDesc;
/**
* 不同类型的坐标点
*/
private List<TLocation> locations;
private String timeDesc;
private String desc;
private String startTime;
......
......@@ -12,11 +12,11 @@ public class BaseLocation {
* 地址纬度
*/
@NotNull(message = "地址纬度必填")
private Double latitude;
protected Double latitude;
/**
* 地址经度
*/
@NotNull(message = "地址经度必填")
private Double longitude;
protected Double longitude;
}
package com.dituhui.pea.order.dto.param;
import com.dituhui.pea.order.enums.LocationType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* 带类型的坐标
*/
@Setter
@Getter
@EqualsAndHashCode(callSuper = false)
public class TLocation extends BaseLocation {
/**
* 坐标类型--绑定工程师使用
*/
protected LocationType locationType;
/**
* 详细地址, xx路xx号等信息
*/
protected String address;
}
package com.dituhui.pea.order.enums;
/**
* 工程师坐标类型
*/
public enum LocationType {
/**
* 准实时
*/
QUASI_REALTIME,
/**
* 常规
*/
GENERAL,
/**
* 上一单
*/
PREVIOUS_ORDER,
/**
* 下一单
*/
NEXT_ORDER;
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.order.dto.EngineerBusinessDTO;
import com.dituhui.pea.order.dto.param.TLocation;
import java.util.List;
......@@ -14,4 +15,11 @@ public interface EngineerBusinessService {
void updateEngineerCenter(EngineerBusinessDTO.EngineerCenterUpdateReqDTO centerReq );
List<EngineerBusinessDTO.Blocks> getBlocks(EngineerBusinessDTO.Request engineerReq);
/**
* 获取工程师出发位置
* @param engineerCode 工程师编号
* @return 工程师出发位置
*/
TLocation engineerDepartLocation(String engineerCode);
}
......@@ -2,7 +2,9 @@ package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.EngineerBusinessDTO;
import com.dituhui.pea.order.dto.param.TLocation;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.LocationType;
import com.dituhui.pea.order.service.EngineerBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -128,4 +130,15 @@ public class EngineerBusinessServiceImpl implements EngineerBusinessService {
return block;
}).collect(Collectors.toList());
}
@Override
public TLocation engineerDepartLocation(String engineerCode) {
EngineerBusinessEntity byEngineerCode = engineerBusinessDao.getByEngineerCode(engineerCode);
TLocation location = new TLocation();
location.setAddress(byEngineerCode.getAddress());
location.setLongitude(StringUtils.isNotBlank(byEngineerCode.getX()) ? Double.parseDouble(byEngineerCode.getX()) : 0.0);
location.setLatitude(StringUtils.isNotBlank(byEngineerCode.getY()) ? Double.parseDouble(byEngineerCode.getY()) : 0.0);
location.setLocationType(LocationType.GENERAL);
return location;
}
}
......@@ -10,7 +10,6 @@ import com.dituhui.pea.order.common.OrderAssignCheck;
import com.dituhui.pea.order.common.Stapial4jUtil;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.dao.EngineerBusinessDao;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillGroupDao;
import com.dituhui.pea.order.dao.OrderInfoDao;
......@@ -23,9 +22,8 @@ import com.dituhui.pea.order.dto.OrderAssignRecommendResp;
import com.dituhui.pea.order.dto.OrderAssignReq;
import com.dituhui.pea.order.dto.OrderReschedule;
import com.dituhui.pea.order.dto.TimeLineDTO;
import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.RecommendEngineersReq;
import com.dituhui.pea.order.entity.EngineerBusinessEntity;
import com.dituhui.pea.order.dto.param.TLocation;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.EngineerSkillGroupEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity;
......@@ -33,12 +31,14 @@ import com.dituhui.pea.order.entity.OrgTeamEngineerEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.LocationType;
import com.dituhui.pea.order.enums.OrderEventEnum;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum;
import com.dituhui.pea.order.enums.ServiceStatusEnum;
import com.dituhui.pea.order.enums.TestimonialsEngineerTag;
import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.EngineerBusinessService;
import com.dituhui.pea.order.service.EngineerCalendarService;
import com.dituhui.pea.order.service.MsgService;
import com.dituhui.pea.order.service.OrderAssign;
......@@ -117,9 +117,8 @@ public class OrderAssignImpl implements OrderAssign {
@Autowired
private IUser userService;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
private EngineerBusinessService engineerBusinessService;
@Autowired
private EngineerCalendarService engineerCalendarService;
......@@ -179,6 +178,7 @@ public class OrderAssignImpl implements OrderAssign {
//标签判定
//判定当前工程师是否在队内, 否则判定是否在10KM内, 否则
TempEngineer tempEngineer = engineerDistanceMap.get(engineerCode);
item.setLocations(tempEngineer.getLocations());
if (Objects.nonNull(orgTeamEngineerDao.findByTeamIdAndEngineerCode(orgTeamId, engineerCode))) {
engineerTag = TestimonialsEngineerTag.TEAM;
} else if (tempEngineer.getDistance().compareTo(judgeDistance) <= 0) {
......@@ -370,11 +370,13 @@ public class OrderAssignImpl implements OrderAssign {
//均计算距离
List<TempEngineer> result = engineerCodes1.stream()
.map(engineerCode -> {
Location location = engineerDateLocation(engineerCode);
List<TLocation> tLocations = engineerDateLocation(engineerCode);
TLocation location = tLocations.stream().filter(t -> Objects.equals(t.getLocationType(), LocationType.QUASI_REALTIME))
.findFirst().get();
BigDecimal orderAndEngineerDistance = BigDecimal.valueOf(Stapial4jUtil.getDistance(location.getLongitude(), location.getLatitude(),
orderLongitude, orderLatitude));
return new TempEngineer(engineerCode, orderAndEngineerDistance);
return new TempEngineer(engineerCode, orderAndEngineerDistance, tLocations);
}).collect(Collectors.toList());
// 距离过滤
if (Objects.nonNull(distance)) {
......@@ -397,28 +399,36 @@ public class OrderAssignImpl implements OrderAssign {
* 距离 (KM)
*/
private BigDecimal distance;
/**
* 不同类型坐标
*/
private List<TLocation> locations;
}
private Location engineerDateLocation(String engineerCode) {
private List<TLocation> engineerDateLocation(String engineerCode) {
final LocalDate currentDate = LocalDate.now();
List<OrderInfoEntity> engineerDateOrderList = orderInfoDao.getEngineerDateOrder(engineerCode, DateUtils.formatDate(currentDate));
Set<String> ss = Set.of("CANCELED", "RESCHEDULED");
engineerDateOrderList = engineerDateOrderList.stream()
.filter(e -> !ss.contains(e.getOrderStatus()))
.sorted(Comparator.comparing(OrderInfoEntity::getPlanStartTime))
.collect(Collectors.toList());
Location location = new Location();
TLocation quasiRealTimeLocation = new TLocation();
quasiRealTimeLocation.setLocationType(LocationType.QUASI_REALTIME);
//查询工程师已开始的工单
Optional<OrderInfoEntity> startedOrder = engineerDateOrderList.stream()
.filter(e -> Objects.equals("STARTED", e.getServiceStatus()))
.max(Comparator.comparing(OrderInfoEntity::getPlanStartTime));
OrderInfoEntity currentOrder = null;
if (startedOrder.isPresent()) {
OrderInfoEntity startedOrderInfo = startedOrder.get();
location.setAddress(startedOrderInfo.getAddress());
location.setLongitude(Double.parseDouble(startedOrderInfo.getX()));
location.setLatitude(Double.parseDouble(startedOrderInfo.getY()));
return location;
quasiRealTimeLocation.setAddress(startedOrderInfo.getAddress());
quasiRealTimeLocation.setLongitude(Double.parseDouble(startedOrderInfo.getX()));
quasiRealTimeLocation.setLatitude(Double.parseDouble(startedOrderInfo.getY()));
currentOrder = startedOrderInfo;
}
//如果没有已开始的工单 查询 最后一个已完成工单
......@@ -426,20 +436,50 @@ public class OrderAssignImpl implements OrderAssign {
.filter(e -> Objects.equals("FINISHED", e.getServiceStatus()))
.max(Comparator.comparing(OrderInfoEntity::getActualEndTime));
ArrayList<TLocation> resultLocationList = new ArrayList<>();
TLocation generalLocation = engineerBusinessService.engineerDepartLocation(engineerCode);
//常规位置, 出发地
resultLocationList.add(generalLocation);
if (finishedOrder.isPresent()) {
OrderInfoEntity finishedOrderInfo = finishedOrder.get();
location.setAddress(finishedOrderInfo.getAddress());
location.setLongitude(Double.parseDouble(finishedOrderInfo.getX()));
location.setLatitude(Double.parseDouble(finishedOrderInfo.getY()));
quasiRealTimeLocation.setAddress(finishedOrderInfo.getAddress());
quasiRealTimeLocation.setLongitude(Double.parseDouble(finishedOrderInfo.getX()));
quasiRealTimeLocation.setLatitude(Double.parseDouble(finishedOrderInfo.getY()));
currentOrder = finishedOrderInfo;
} else {
// 如果都没有, 则获取工程师出发地址
EngineerBusinessEntity byEngineerCode = engineerBusinessDao.getByEngineerCode(engineerCode);
location.setAddress(byEngineerCode.getAddress());
location.setLongitude(StringUtils.isNotBlank(byEngineerCode.getX()) ? Double.parseDouble(byEngineerCode.getX()) : 0.0);
location.setLatitude(StringUtils.isNotBlank(byEngineerCode.getY()) ? Double.parseDouble(byEngineerCode.getY()) : 0.0);
quasiRealTimeLocation.setAddress(generalLocation.getAddress());
quasiRealTimeLocation.setLongitude(generalLocation.getLongitude());
quasiRealTimeLocation.setLatitude(generalLocation.getLatitude());
}
//准实时位置
resultLocationList.add(quasiRealTimeLocation);
//
if (Objects.nonNull(currentOrder)) {
int i = engineerDateOrderList.indexOf(currentOrder);
//上一单
if (i > 0) {
OrderInfoEntity order = engineerDateOrderList.get(i - 1);
TLocation pre = new TLocation();
pre.setLocationType(LocationType.PREVIOUS_ORDER);
pre.setAddress(order.getAddress());
pre.setLongitude(Double.parseDouble(order.getX()));
pre.setLatitude(Double.parseDouble(order.getY()));
resultLocationList.add(pre);
}
//下一单
if (i < engineerDateOrderList.size() - 1) {
OrderInfoEntity order = engineerDateOrderList.get(i + 1);
TLocation next = new TLocation();
next.setLocationType(LocationType.NEXT_ORDER);
next.setAddress(order.getAddress());
next.setLongitude(Double.parseDouble(order.getX()));
next.setLatitude(Double.parseDouble(order.getY()));
resultLocationList.add(next);
}
}
return location;
return resultLocationList;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!