Commit e24f9c0f by 刘鑫

feat: 加单确认流程

1 parent dc969b13
...@@ -299,11 +299,7 @@ public class PeaApiController { ...@@ -299,11 +299,7 @@ public class PeaApiController {
@PostMapping("/order/increase/confirm") @PostMapping("/order/increase/confirm")
public Result<OrderConfirmResult> orderConfirm(@Validated @RequestBody OrderConfirmParam requestParam) { public Result<OrderConfirmResult> orderConfirm(@Validated @RequestBody OrderConfirmParam requestParam) {
OrderConfirmResult result = new OrderConfirmResult(); return Result.success(peaOuterAPIService.orderAddConfirm(requestParam));
result.setEngineerCode(requestParam.getEngineerCode());
result.setOrderId(requestParam.getOrderId());
result.setAppointmentStatus(requestParam.getAppointmentResult());
return Result.success(result);
} }
......
...@@ -74,7 +74,7 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS ...@@ -74,7 +74,7 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
* @return 满足条件的工单信息 * @return 满足条件的工单信息
*/ */
@Query(value = "SELECT oi.* FROM skill_info si LEFT JOIN order_info oi ON oi.brand = si.brand AND oi.type = si.type AND oi.skill = si.skill " + @Query(value = "SELECT oi.* FROM skill_info si LEFT JOIN order_info oi ON oi.brand = si.brand AND oi.type = si.type AND oi.skill = si.skill " +
" WHERE si.skill_group_code = :skillGroupCode AND oi.expect_time_begin >= :dateTime " + " WHERE si.skill_group_code = :skillGroupCode AND oi.expect_time_begin >= :dateTime AND oi.is_multiple = 0 " +
" AND (appointment_status = 'INIT' AND order_status != 'CANCELED') ", nativeQuery = true) " AND (appointment_status = 'INIT' AND order_status != 'CANCELED') AND oi.reason_for_failure IS NULL ", nativeQuery = true)
List<OrderInfoEntity> getSkillGroupOrder(String skillGroupCode, LocalDateTime dateTime); List<OrderInfoEntity> getSkillGroupOrder(String skillGroupCode, LocalDateTime dateTime);
} }
...@@ -3,6 +3,8 @@ package com.dituhui.pea.order.service; ...@@ -3,6 +3,8 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.order.dto.param.EstimateDTO; import com.dituhui.pea.order.dto.param.EstimateDTO;
import com.dituhui.pea.order.dto.param.Location; import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.Order; import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderConfirmParam;
import com.dituhui.pea.order.dto.param.OrderConfirmResult;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -35,6 +37,14 @@ public interface PeaOuterAPIService { ...@@ -35,6 +37,14 @@ public interface PeaOuterAPIService {
*/ */
List<Order> orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration); List<Order> orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration);
/**
* 加单确认 待上门变为已排期
*
* @param request 请求参数
* @return 加单确认结果
*/
OrderConfirmResult orderAddConfirm(OrderConfirmParam request);
OrderDTO.AppointResult engineerCode(String engineerCode, LocalDate localDate); OrderDTO.AppointResult engineerCode(String engineerCode, LocalDate localDate);
} }
...@@ -5,6 +5,7 @@ import com.dituhui.pea.enums.StatusCodeEnum; ...@@ -5,6 +5,7 @@ import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.SaasUtils; import com.dituhui.pea.order.common.SaasUtils;
import com.dituhui.pea.order.common.Stapial4jUtil; import com.dituhui.pea.order.common.Stapial4jUtil;
import com.dituhui.pea.order.common.jackson.DateUtil; import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillGroupDao; import com.dituhui.pea.order.dao.EngineerSkillGroupDao;
import com.dituhui.pea.order.dao.MapBlockInfoDao; import com.dituhui.pea.order.dao.MapBlockInfoDao;
import com.dituhui.pea.order.dao.OrderInfoDao; import com.dituhui.pea.order.dao.OrderInfoDao;
...@@ -12,11 +13,18 @@ import com.dituhui.pea.order.dao.OrgGroupDao; ...@@ -12,11 +13,18 @@ import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dto.param.EstimateDTO; import com.dituhui.pea.order.dto.param.EstimateDTO;
import com.dituhui.pea.order.dto.param.Location; import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.Order; import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderConfirmParam;
import com.dituhui.pea.order.dto.param.OrderConfirmResult;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.EngineerSkillGroupEntity; import com.dituhui.pea.order.entity.EngineerSkillGroupEntity;
import com.dituhui.pea.order.entity.MapBlockInfoEntity; import com.dituhui.pea.order.entity.MapBlockInfoEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity; import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum;
import com.dituhui.pea.order.enums.ServiceStatusEnum;
import com.dituhui.pea.order.service.PeaOuterAPIService; import com.dituhui.pea.order.service.PeaOuterAPIService;
import com.dituhui.pea.pojo.fendan.FendanDTO; import com.dituhui.pea.pojo.fendan.FendanDTO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -52,6 +60,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService { ...@@ -52,6 +60,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
private final EngineerSkillGroupDao engineerSkillGroupDao; private final EngineerSkillGroupDao engineerSkillGroupDao;
private final SaasUtils saasUtils; private final SaasUtils saasUtils;
private final MapBlockInfoDao mapBlockInfoDao; private final MapBlockInfoDao mapBlockInfoDao;
private final EngineerInfoDao engineerInfoDao;
@Override @Override
public EstimateDTO.VisitResult estimateVisitService(String brand, String productType, String serviceType, Location clientLocation) { public EstimateDTO.VisitResult estimateVisitService(String brand, String productType, String serviceType, Location clientLocation) {
...@@ -117,7 +126,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService { ...@@ -117,7 +126,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
List<OrderInfoEntity> skillGroupOrder = orderInfoDao.getSkillGroupOrder(groupCode, targetTime); List<OrderInfoEntity> skillGroupOrder = orderInfoDao.getSkillGroupOrder(groupCode, targetTime);
orderList.addAll(skillGroupOrder); orderList.addAll(skillGroupOrder);
} }
//TODO 排除一家多台、需要配件工单 //TODO需要配件工单
//每分钟0.3167 KM, 每小时19KM //每分钟0.3167 KM, 每小时19KM
//查询 地址范围内工单(过滤掉所需耗时大于空闲时长的工单), 范围根据空闲时长计算 //查询 地址范围内工单(过滤掉所需耗时大于空闲时长的工单), 范围根据空闲时长计算
double speed = 0.3167; double speed = 0.3167;
...@@ -153,6 +162,37 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService { ...@@ -153,6 +162,37 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public OrderConfirmResult orderAddConfirm(OrderConfirmParam request) {
final String orderId = request.getOrderId();
OrderInfoEntity orderInfo = orderInfoDao.getByOrderId(orderId);
EngineerInfoEntity engineerInfo = engineerInfoDao.getByEngineerCode(request.getEngineerCode());
//confirmed预约成功;other预约失败
if (Objects.equals(request.getAppointmentResult(), "CONFIRMED")) {
orderInfo.setAppointmentStatus(String.valueOf(OrderFlowEnum.CONFIRM));
orderInfo.setServiceStatus(ServiceStatusEnum.CONTACTED.getCode());
orderInfo.setOrderStatus(OrderStatusEnum.RESCHEDULED.getCode());
orderInfo.setAppointmentStatus(String.valueOf(AppointmentMethodEnum.AUTO_NOW));
orderInfo.setEngineerCode(engineerInfo.getEngineerCode());
orderInfo.setEngineerName(engineerInfo.getName());
// 更新上门时间, 结束时间
LocalDateTime planStartTime = DateUtil.fromDate(request.getAppointmentTime());
LocalDateTime planEndTime = planStartTime.plusMinutes(orderInfo.getTakeTime());
orderInfo.setPlanStartTime(planStartTime);
orderInfo.setPlanEndTime(planEndTime);
}
orderInfo.setReasonForFailure(request.getReasonForFailure());
orderInfoDao.save(orderInfo);
//TODO 回调BEAN 改约接口
OrderConfirmResult orderConfirmResult = new OrderConfirmResult();
orderConfirmResult.setOrderId(orderId);
orderConfirmResult.setEngineerCode(engineerInfo.getEngineerCode());
orderConfirmResult.setAppointmentStatus(request.getReasonForFailure());
return orderConfirmResult;
}
public List<OrderInfoEntity> nearBySearch(double distance, double userLng, double userLat, Set<OrderInfoEntity> orderList) { public List<OrderInfoEntity> nearBySearch(double distance, double userLng, double userLat, Set<OrderInfoEntity> orderList) {
//1 获取外切正方形最大最小经纬度 //1 获取外切正方形最大最小经纬度
Rectangle rectangle = Stapial4jUtil.getRectangle(distance, userLng, userLat); Rectangle rectangle = Stapial4jUtil.getRectangle(distance, userLng, userLat);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!