Commit 6bfb64f6 by 丁伟峰

Merge branch 'feat-dingwf-mvp616' into develop

2 parents fbc19f0f 72c9a5b2
......@@ -9,5 +9,5 @@ import java.util.List;
public interface OrderAppointmentDao extends JpaRepository<OrderAppointmentEntity, Integer> {
@Query("from OrderAppointmentEntity a where DATE_FORMAT(a.expectStartTime, '%Y-%m-%d') = :date and a.engineerCode in :engineerCodes")
List<?> findByDateAndEngineerCodeIn(String date, List<?> engineerCodes);
List<OrderAppointmentEntity> findByDateAndEngineerCodeIn(String date, List<?> engineerCodes);
}
......@@ -4,8 +4,12 @@ import com.alibaba.cloud.integration.order.entity.OrderRequestEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrderRequestDao extends JpaRepository <OrderRequestEntity, Long> {
OrderRequestEntity getByOrderId(String orderId);
List<OrderRequestEntity> findAllByOrderId(List<String> orderIds);
}
......@@ -15,6 +15,8 @@ import org.springframework.data.domain.Pageable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -73,25 +75,26 @@ public class WorkbenchServiceImpl implements WorkbenchService {
public Result<?> getEngineersGanttList(WorkbenchEngineersGanttReqDTO reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log.info("getEngineersGanttList: {}", reqDTO);
List<?> orderAppointments = orderAppointmentDao.findByDateAndEngineerCodeIn(reqDTO.getDate(), reqDTO.getEngineerCodes());
List<OrderAppointmentEntity> orderAppointments = orderAppointmentDao.findByDateAndEngineerCodeIn(reqDTO.getDate(), reqDTO.getEngineerCodes());
List<String> orderIds = orderAppointments.stream().map(OrderAppointmentEntity::getOrderId).collect(Collectors.toList());
Map<String, OrderRequestEntity> mapOrderRequest = getOrdersByOrderIds(orderIds);
HashMap<String, List<WorkbenchEngineersGanttRespDTO.Order>> mapEngineers = new HashMap<>();
for (Object e : orderAppointments) {
OrderAppointmentEntity entity = (OrderAppointmentEntity) e;
log.info("===== order_id: [{}]", entity.getOrderId());
for (OrderAppointmentEntity e : orderAppointments) {
log.info("===== order_id: [{}]", e.getOrderId());
WorkbenchEngineersGanttRespDTO.Order order = new WorkbenchEngineersGanttRespDTO.Order();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order.setStartTime(entity.getExpectStartTime()).setEndTime(entity.getExpectEndTime());
order.setOrderId(entity.getOrderId()).setOrderStatus(entity.getStatus());
order.setTips(getOrderTips(entity.getOrderId()));
//todo 查询order-request表,获取 appointment_status字段
order.setStartTime(e.getExpectStartTime()).setEndTime(e.getExpectEndTime());
order.setOrderId(e.getOrderId()).setOrderStatus(e.getStatus());
order.setTips(getOrderTips(e.getOrderId()));
order.setAppointmentStatus(mapOrderRequest.get(e.getOrderId()).getAppointmentStatus());
List<WorkbenchEngineersGanttRespDTO.Order> orders = null;
if (mapEngineers.containsKey(entity.getEngineerCode())) {
orders = mapEngineers.get(entity.getEngineerCode());
if (mapEngineers.containsKey(e.getEngineerCode())) {
orders = mapEngineers.get(e.getEngineerCode());
} else {
orders = new ArrayList<>();
}
orders.add(order);
mapEngineers.put(entity.getEngineerCode(), orders);
mapEngineers.put(e.getEngineerCode(), orders);
}
List<WorkbenchEngineersGanttRespDTO.GanttChart> engineers = new ArrayList<>();
......@@ -119,6 +122,13 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return Result.success(data);
}
public Map<String, OrderRequestEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderRequestEntity> orders = orderRequestDao.findAllByOrderId(orderIds);
return orders.stream()
.collect(Collectors.toMap(OrderRequestEntity::getOrderId, order -> order));
}
private List<?> getOrderTips(String orderId) {
log.info("==> getOrdertips: orderId[{}]", orderId);
OrderRequestEntity order = orderRequestDao.getByOrderId(orderId);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!