Commit 7f7199a4 by wangli

新增订单改约实现

1 parent 4bc4b847
......@@ -2,12 +2,17 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dto.OrderAssignReq;
import com.dituhui.pea.order.dto.OrderReschedule;
import com.dituhui.pea.order.dto.OrderRevokeAssign;
import com.dituhui.pea.order.service.OrderAssign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/pea-order")
public class OrderAssignController {
......@@ -53,4 +58,18 @@ public class OrderAssignController {
}
return res;
}
@PostMapping("/order/rescheduling")
public Result<?> orderRescheduling(@RequestBody OrderReschedule req){
// 订单改约
Result<?> res = null;
LocalDateTime expectBegin = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectBegin());
LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd());
try{
res = orderAssign.orderReschedule(req.getOrderId(), expectBegin, expectEnd, req.getExpectDesc());
} catch (BusinessException e){
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import org.bouncycastle.asn1.cms.TimeStampAndCRL;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
public interface OrderAssign {
......@@ -11,4 +16,6 @@ public interface OrderAssign {
Result<?> orderAssign(String orderId, String engineerCode);
Result<?> orderRevokeAssign(String orderId);
Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc);
}
......@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
......@@ -212,6 +213,51 @@ public class OrderAssignImpl implements OrderAssign {
return Result.success(null);
}
@Override
public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException{
// 工单改约接口(当前同放回工单池处理)
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
if (order == null){
throw new BusinessException("订单不存在");
}
if(order.getDt() == expectBegin.toLocalDate()) {
throw new BusinessException("改约日期不能与之前日期相同");
}
if (LocalDate.now().isAfter(expectBegin.toLocalDate())){
throw new BusinessException("改约日期不能小于今日");
}
// 更新order_request表为未指派
order.setAppointmentStatus("NOT_ASSIGNED");
order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(Timestamp.valueOf(expectBegin));
order.setExpectTimeEnd(Timestamp.valueOf(expectEnd));
order.setExpectTimeDesc(expectDesc);
orderRequestMPDao.updateById(order);
// 更新order_appointment表为未指派
LambdaUpdateWrapper<OrderAppointment> appWrapper = new LambdaUpdateWrapper<>();
appWrapper.set(OrderAppointment::getStatus, "RESCHEDULED")
.eq(OrderAppointment::getOrderId, orderId).eq(OrderAppointment::getDt, order.getDt());
orderAppointmentMPDao.update(null, appWrapper);
// 登记事件
OrderEvent oe = new OrderEvent();
oe.setOrderId(orderId);
oe.setSuborderId("");
oe.setHappen(new Timestamp(System.currentTimeMillis()));
oe.setEvent("已改约");
oe.setOperator("123"); // 操作员ID TODO-用户系统
oe.setOperatorName("测试用户"); // 操作员姓名 TODO-用户系统
oe.setSource("PEA");
oe.setDescription("已改约");
oe.setMemo("");
oe.setCreateTime(new Timestamp(System.currentTimeMillis()));
orderEventMPDao.insert(oe);
return Result.success(null);
}
private List<String> searchEngineerCodes(Integer distance, String key, String recommend){
return null;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!