Commit c9f83922 by 王力

Merge branch 'dev_order_assign0717' into 'develop'

优化获取技术员发出位置,若从bussiness表没有配置,从小组/分站中去获取

See merge request !222
2 parents f83368b1 64b5e191
package com.dituhui.pea.order.common; package com.dituhui.pea.order.common;
import com.dituhui.pea.order.dao.EngineerBusinessMPDao; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dao.OrderAppointmentMPDao; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.dao.OrderRequestMPDao;
import com.dituhui.pea.order.dao.SkillInfoMPDao;
import com.dituhui.pea.order.entity.EngineerBusiness;
import com.dituhui.pea.order.entity.OrderAppointment;
import com.dituhui.pea.order.entity.OrderRequest;
import com.dituhui.pea.order.entity.SkillInfo;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -38,6 +33,12 @@ public class OrderAssignCheck { ...@@ -38,6 +33,12 @@ public class OrderAssignCheck {
@Autowired @Autowired
EngineerBusinessMPDao engineerBusinessMPDao; EngineerBusinessMPDao engineerBusinessMPDao;
@Autowired
EngineerInfoMPDao engineerInfoMPDao;
@Autowired
OrgGroupMPDao orgGroupMPDao;
@Data @Data
public class Result { public class Result {
private Boolean canAssign; private Boolean canAssign;
...@@ -89,8 +90,11 @@ public class OrderAssignCheck { ...@@ -89,8 +90,11 @@ public class OrderAssignCheck {
// 计算距离 & 时间 // 计算距离 & 时间
if(index == 0 && orderSegments.isEmpty()) { if(index == 0 && orderSegments.isEmpty()) {
// 第一订单为出发地, 没有其他订单 // 第一订单为出发地, 没有其他订单
EngineerBusiness b = engineerBusinessMPDao.getByEngineerCode(engineerCode); double[] location = this.getEngineerDepartureLocation(engineerCode);
OrderSegment pre = new OrderSegment(480, 480, Double.parseDouble(b.getX()), Double.parseDouble(b.getY())); double preX = location[0];
double preY = location[1];
OrderSegment pre = new OrderSegment(480, 480, preX, preY);
Pair p = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY); Pair p = this.getDistanceAndDuration(pre.getX(), pre.getY(), curX, curY);
// 最早可插入位置为技术员出发时间+行程时间 // 最早可插入位置为技术员出发时间+行程时间
...@@ -105,9 +109,12 @@ public class OrderAssignCheck { ...@@ -105,9 +109,12 @@ public class OrderAssignCheck {
} }
else if(index == 0 && !orderSegments.isEmpty()) { else if(index == 0 && !orderSegments.isEmpty()) {
// 第一订单为出发地, 且有其他订单 // 第一订单为出发地, 且有其他订单
EngineerBusiness b = engineerBusinessMPDao.getByEngineerCode(engineerCode); double[] location = this.getEngineerDepartureLocation(engineerCode);
double preX = location[0];
double preY = location[1];
OrderSegment post = orderSegments.get(0); OrderSegment post = orderSegments.get(0);
OrderSegment pre = new OrderSegment(480, 480, Double.parseDouble(b.getX()), Double.parseDouble(b.getY())); OrderSegment pre = new OrderSegment(480, 480, preX, preY);
return this.getResult(curX, curY, pre, post, takeTime, order.getDt()); return this.getResult(curX, curY, pre, post, takeTime, order.getDt());
} }
else if(index == orderSegments.size()) { else if(index == orderSegments.size()) {
...@@ -196,6 +203,20 @@ public class OrderAssignCheck { ...@@ -196,6 +203,20 @@ public class OrderAssignCheck {
return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime); return new Result(true, "success", minuteAddition, distanceAddition, startDateTime, endDateTime);
} }
private double[] getEngineerDepartureLocation(String engineerCode){
// 获取技术员出发坐标
// 从技术员配置中获取
EngineerBusiness b = engineerBusinessMPDao.getByEngineerCode(engineerCode);
if( b != null && StringUtils.isNotEmpty(b.getX()) && StringUtils.isNotEmpty(b.getY())){
return new double[]{Double.parseDouble(b.getX()), Double.parseDouble(b.getY())};
}
//从org_group中获取
EngineerInfo e = engineerInfoMPDao.getByEngineerCode(engineerCode);
OrgGroup g = orgGroupMPDao.getByGroupId(e.getGroupId());
return new double[]{Double.parseDouble(g.getX()), Double.parseDouble(g.getY())};
}
private int timestamp2Point(Timestamp t) { private int timestamp2Point(Timestamp t) {
LocalDateTime dt = t.toLocalDateTime(); LocalDateTime dt = t.toLocalDateTime();
return dt.getHour() * 60 + dt.getMinute(); return dt.getHour() * 60 + dt.getMinute();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!