Commit f66f8cf9 by 丁伟峰

技术员日历、技术员甘特图剥离到独立的service实现中

1 parent 5706bb32
......@@ -477,81 +477,4 @@ public class EngineerServiceImpl implements EngineerService {
return (age <= 0) ? "" : Integer.toString(age);
}
@Override
public Result<?> getEngineersGanttList(EngineersGanttReqDTO reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log.info("getEngineersGanttList: {}", reqDTO);
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<EngineersGanttRespDTO.Order>> mapEngineers = new HashMap<>();
for (OrderAppointmentEntity e : orderAppointments) {
log.info("===== order_id: [{}]", e.getOrderId());
EngineersGanttRespDTO.Order order = new EngineersGanttRespDTO.Order();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order.setStartTime(e.getExpectStartTime()).setEndTime(e.getExpectEndTime());
order.setOrderId(e.getOrderId()).setPreStatus(e.getPreStatus());
order.setTips(getOrderTips(e.getOrderId()));
order.setAppointmentStatus(mapOrderRequest.get(e.getOrderId()).getAppointmentStatus());
List<EngineersGanttRespDTO.Order> orders = null;
if (mapEngineers.containsKey(e.getEngineerCode())) {
orders = mapEngineers.get(e.getEngineerCode());
} else {
orders = new ArrayList<>();
}
orders.add(order);
mapEngineers.put(e.getEngineerCode(), orders);
}
List<EngineersGanttRespDTO.GanttChart> engineers = new ArrayList<>();
for (String engineerCode : reqDTO.getEngineerCodes()) {
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(engineerCode);
EngineersGanttRespDTO.GanttChart engineer = new EngineersGanttRespDTO.GanttChart();
engineer.setEngineerCode(engineerCode)
.setStartTime(String.format("%s 08:00", reqDTO.getDate()))
.setEndTime(String.format("%s 18:00", reqDTO.getDate()))
.setHoliday(false) // todo
.setEngineerName(engineerInfo.getName())
.setGrade(engineerInfo.getGrade());
CapacityEngineerStatEntity capacityEngineerStat = capacityEngineerStatDao.getByEngineerCodeAndWorkday(engineerCode, reqDTO.getDate());
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
}
if (mapEngineers.containsKey(engineerCode)) {
engineer.setOrders(mapEngineers.get(engineerCode));
}
// engineer.setErrorTip(); todo
engineers.add(engineer);
}
EngineersGanttRespDTO data = new EngineersGanttRespDTO().setDate(reqDTO.getDate()).setEngineers(engineers);
return Result.success(data);
}
public Map<String, OrderRequestEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderRequestEntity> orders = orderRequestDao.findAllByOrderIdIn(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);
if (order == null) {
log.error("对应的订单不存在!{}", orderId);
return null;
}
List<LabelValueDTO> tips = new ArrayList<>();
tips.add(new LabelValueDTO().setLabel("工单号码").setValue(orderId));
tips.add(new LabelValueDTO().setLabel("类型/品牌").setValue(String.format("%s %s", order.getBrand(), order.getType())));
tips.add(new LabelValueDTO().setLabel("电话/地址").setValue(String.format("%s %s\n %s", order.getName(), order.getPhone(), order.getAddress())));
if (StringUtils.isNotBlank(order.getApplyNote())) {
tips.add(new LabelValueDTO().setLabel("备注").setValue(order.getApplyNote()));
}
tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags()));
return tips;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!