Commit afc69207 by 刘鑫

DOC: 预约单统计数据返回示例

1 parent 07aa01cf
package com.dituhui.pea.order.controller;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.dto.OrganizationTreeDTO;
import com.dituhui.pea.order.dto.param.*;
......@@ -247,9 +249,9 @@ public class PeaApiController {
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@NotNull @RequestParam("date") Date date) {
OrderDTO.AppointResult appointResult = peaOuterAPIService.engineerCode(engineerCode, DateUtil.fromDate(date).toLocalDate());
return Result.success(new OrderDTO.AppointResult());
return Result.success(appointResult);
}
......
......@@ -22,4 +22,6 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByDtAndOrgTeamIdAndAppointmentStatusIn(LocalDate dt, String orgTeamId, List<String> appointmentStatus);
OrderInfoEntity findTopBySkillAndAppointmentStatus(String skill, String status);
List<OrderInfoEntity> findByServiceStatusAndEngineerCode(String serviceStatus, String engineerCode);
}
......@@ -3,7 +3,9 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.order.dto.param.EstimateDTO;
import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderDTO;
import java.time.LocalDate;
import java.util.List;
/**
......@@ -32,4 +34,7 @@ public interface PeaOuterAPIService {
* @return 不需要的备件且符合条件的多个未分配工单
*/
List<Order> orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration);
OrderDTO.AppointResult engineerCode(String engineerCode, LocalDate localDate);
}
......@@ -6,6 +6,7 @@ import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dto.param.EstimateDTO;
import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.service.PeaOuterAPIService;
......@@ -13,7 +14,12 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 对外接口实现
......@@ -66,6 +72,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
order.setFaultDescribe(sss.getFaultDescribe());
order.setExpectTimeBegin(DateUtil.toDate(sss.getExpectTimeBegin()));
order.setExpectTimeEnd(DateUtil.toDate(sss.getExpectTimeEnd()));
order.setApplyNote(sss.getApplyNote());
Location orderLocation = new Location();
......@@ -76,4 +83,36 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
return List.of(order);
}
@Override
public OrderDTO.AppointResult engineerCode(String engineerCode, LocalDate localDate) {
OrderDTO.AppointResult result = new OrderDTO.AppointResult();
result.setEngineerCode(engineerCode);
result.setDate(DateUtil.toDate(localDate));
List<OrderInfoEntity> finishedOrder = orderInfoDao.findByServiceStatusAndEngineerCode("INIT", engineerCode);
List<OrderDTO.AppointmentOrderResult> collect = Optional.ofNullable(finishedOrder).orElse(Collections.emptyList())
.stream()
.map(this::order2AppointmentOrderResult)
.collect(Collectors.toList());
result.setOrders(collect);
return result;
}
private OrderDTO.AppointmentOrderResult order2AppointmentOrderResult(OrderInfoEntity orderInfo) {
OrderDTO.AppointmentOrderResult result = new OrderDTO.AppointmentOrderResult();
result.setOrderId(orderInfo.getOrderId());
result.setOrderStatus(orderInfo.getServiceStatus());
result.setPlanBeginTime(DateUtil.toDate(orderInfo.getPlanStartTime()));
// result.setPlanDistance();
result.setPlanDuration(orderInfo.getTakeTime() * 60);
if (Objects.nonNull(orderInfo.getActualStartTime())) {
result.setActualBeginTime(DateUtil.toDate(orderInfo.getActualStartTime()));
result.setActualDuration(orderInfo.getArriveElapsed() * 60);
result.setActualDistance(orderInfo.getArriveDistance());
}
return result;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!