Commit 4251365e by wangli

修改

1 parent 636de92d
package com.dituhui.pea.order.common; package com.dituhui.pea.order.common;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import lombok.Data; import lombok.Data;
...@@ -21,11 +22,6 @@ import java.util.stream.Collectors; ...@@ -21,11 +22,6 @@ import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
public class OrderAssignCheck { public class OrderAssignCheck {
@Autowired
OrderRequestMPDao orderRequestMPDao;
@Autowired
OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
SkillInfoMPDao skillInfoMPDao; SkillInfoMPDao skillInfoMPDao;
...@@ -39,6 +35,9 @@ public class OrderAssignCheck { ...@@ -39,6 +35,9 @@ public class OrderAssignCheck {
@Autowired @Autowired
OrgGroupMPDao orgGroupMPDao; OrgGroupMPDao orgGroupMPDao;
@Autowired
OrderInfoMPDao orderInfoMPDao;
@Data @Data
public class Result { public class Result {
private Boolean canAssign; private Boolean canAssign;
...@@ -63,7 +62,7 @@ public class OrderAssignCheck { ...@@ -63,7 +62,7 @@ public class OrderAssignCheck {
public Result orderAssignCheck(String orderId, String engineerCode) { public Result orderAssignCheck(String orderId, String engineerCode) {
log.info("begin orderAssignCheck:orderId={}, engineerCode={}", orderId, engineerCode); log.info("begin orderAssignCheck:orderId={}, engineerCode={}", orderId, engineerCode);
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
double curX = Double.parseDouble(order.getX()); double curX = Double.parseDouble(order.getX());
double curY = Double.parseDouble(order.getY()); double curY = Double.parseDouble(order.getY());
...@@ -142,33 +141,22 @@ public class OrderAssignCheck { ...@@ -142,33 +141,22 @@ public class OrderAssignCheck {
private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) { private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) {
List<OrderSegment> orderSegments = new ArrayList<>(); List<OrderSegment> orderSegments = new ArrayList<>();
List<OrderAppointment> appointments = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineerCode, dt); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
List<String> orderIds = new ArrayList<>(); lqw.eq(OrderInfo::getDt, dt);
for (OrderAppointment o: appointments) { lqw.eq(OrderInfo::getEngineerCode, engineerCode);
// 过滤掉已经取消的订单 lqw.eq(OrderInfo::getOrderStatus, "NORMAL");
if(o.getStatus().equals("NOT_ASSIGNED") || o.getStatus().equals("CANCELED")) { lqw.in(OrderInfo::getAppointmentStatus, List.of("PRE", "CONFIRM"));
continue; List<OrderInfo> appointments = orderInfoMPDao.selectList(lqw);
} if(appointments.isEmpty()){
orderIds.add(o.getOrderId());
}
if(orderIds.isEmpty()){
return orderSegments; return orderSegments;
} }
for(OrderInfo o: appointments) {
Map<String, List<OrderAppointment>> m = appointments.stream().collect(Collectors.groupingBy(OrderAppointment::getOrderId));
List<OrderRequest> orderRequests = orderRequestMPDao.selectByOrderIds(orderIds);
for(OrderRequest o: orderRequests) {
List<OrderAppointment> tmp = m.getOrDefault(o.getOrderId(), new ArrayList<>());
if(tmp.isEmpty()) {
continue;
}
OrderAppointment oa = tmp.get(0);
OrderSegment seg = new OrderSegment(); OrderSegment seg = new OrderSegment();
seg.setOrderId(o.getOrderId()); seg.setOrderId(o.getOrderId());
seg.setX(Double.parseDouble(o.getX())); seg.setX(Double.parseDouble(o.getX()));
seg.setY(Double.parseDouble(o.getY())); seg.setY(Double.parseDouble(o.getY()));
seg.setStart(this.timestamp2Point(oa.getExpectStartTime())); seg.setStart(this.timestamp2Point(o.getPlanStartTime()));
seg.setEnd(this.timestamp2Point(oa.getExpectEndTime())); seg.setEnd(this.timestamp2Point(o.getPlanEndTime()));
orderSegments.add(seg); orderSegments.add(seg);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!