Commit 227dd733 by wangli

修改,更改表为order_info表

1 parent 3c9980d8
...@@ -30,10 +30,7 @@ import java.util.stream.Collectors; ...@@ -30,10 +30,7 @@ import java.util.stream.Collectors;
public class OrderAssignImpl implements OrderAssign { public class OrderAssignImpl implements OrderAssign {
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
...@@ -63,7 +60,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -63,7 +60,7 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) { public Result<?> getOrderAssignRecommendEngineers(String orderId, String key, String distance, String recommend) {
// 服务单指派-推荐技术员列表 // 服务单指派-推荐技术员列表
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -84,13 +81,13 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -84,13 +81,13 @@ public class OrderAssignImpl implements OrderAssign {
} }
// 获取已技术员已指派订单列表 // 获取已技术员已指派订单列表
List<OrderAppointment> orderAppointments = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineer.getEngineerCode(), order.getDt()); List<OrderInfo> orderAppointments = orderInfoMPDao.selectByEngineerCodeAndDtAndAppointmentStatus(engineer.getEngineerCode(), order.getDt(), "CONFIRM");
// 获取订单tips // 获取订单tips
HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>(); HashMap<String, List<LabelValueDTO>> orderTips = new HashMap<>();
List<String> orderIds = orderAppointments.stream().map(OrderAppointment::getOrderId).collect(Collectors.toList()); List<String> orderIds = orderAppointments.stream().map(OrderInfo::getOrderId).collect(Collectors.toList());
if (!orderIds.isEmpty()) { if (!orderIds.isEmpty()) {
List<OrderRequest> orders = orderRequestMPDao.selectByOrderIds(orderIds); List<OrderInfo> orders = orderInfoMPDao.selectByDtAndOrderIds(TimeUtils.IsoDate2LocalDate(date), orderIds);
orderTips = this.packOrderTips(orders); orderTips = this.packOrderTips(orders);
} }
...@@ -126,7 +123,8 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -126,7 +123,8 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> orderAssign(String orderId, String engineerCode) throws BusinessException { public Result<?> orderAssign(String orderId, String engineerCode) throws BusinessException {
// 服务单指派-指派提交 // 服务单指派-指派提交
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -134,7 +132,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -134,7 +132,7 @@ public class OrderAssignImpl implements OrderAssign {
EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode); EngineerInfo engineer = engineerInfoMPDao.getByEngineerCode(engineerCode);
boolean record = false; boolean record = false;
OrderAppointment op = orderAppointmentMPDao.getByOrderIdAndDt(orderId, order.getDt()); OrderInfo op = orderInfoMPDao.getByOrderIdAndDt(orderId, order.getDt());
if (op != null) { if (op != null) {
record = true; record = true;
} }
...@@ -148,39 +146,17 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -148,39 +146,17 @@ public class OrderAssignImpl implements OrderAssign {
if (!result.getCanAssign()) { if (!result.getCanAssign()) {
throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员"); throw new BusinessException("指派失败, 未能找到合适的时间段, 请选择其他技术员");
} }
Timestamp expectStartTime = Timestamp.valueOf(result.getStart()); Timestamp planStartTime = Timestamp.valueOf(result.getStart());
Timestamp expectEndTime = Timestamp.valueOf(result.getEnd()); Timestamp planEndTime = Timestamp.valueOf(result.getEnd());
// 更新或插入指派单
if (!record) {
op = new OrderAppointment();
}
op.setOrderId(orderId);
op.setSuborderId(Long.toString(System.currentTimeMillis()));
op.setMainSub(1);
op.setEngineerCode(engineerCode);
op.setEngineerName(engineer.getName());
op.setEngineerAge(0);
op.setEngineerPhone(engineer.getPhone());
op.setIsWorkshop(0);
op.setDt(order.getDt());
op.setExpectStartTime(expectStartTime);
op.setExpectEndTime(expectEndTime);
op.setPreStatus("CONFIRM");
op.setStatus("ASSIGNED");
if (!record) {
orderAppointmentMPDao.insert(op);
} else {
orderAppointmentMPDao.updateById(op);
}
// 更新order_request表状态 // 更新order_request表状态
LambdaUpdateWrapper<OrderRequest> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<OrderInfo> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(OrderRequest::getAppointmentStatus, "ASSIGNED"); wrapper.set(OrderInfo::getAppointmentStatus, "CONFIRM");
wrapper.set(OrderRequest::getAppointmentMethod, "MANUAL"); wrapper.set(OrderInfo::getAppointmentMethod, "MANUAL");
wrapper.eq(OrderRequest::getOrderId, orderId); wrapper.set(OrderInfo::getPlanStartTime, planStartTime);
orderRequestMPDao.update(null, wrapper); wrapper.set(OrderInfo::getPlanEndTime, planEndTime);
wrapper.eq(OrderInfo::getOrderId, orderId);
orderInfoMPDao.update(null, wrapper);
// 工单变更登记 // 工单变更登记
commonService.addOrderEvent(orderId, "", "PEA-WEB", "API", "工单指派", "工单指派", ""); commonService.addOrderEvent(orderId, "", "PEA-WEB", "API", "工单指派", "工单指派", "");
...@@ -190,20 +166,16 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -190,20 +166,16 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> orderRevokeAssign(String orderId) throws BusinessException { public Result<?> orderRevokeAssign(String orderId) throws BusinessException {
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); // 放回工单池
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
// 更新order_request表为未指派 // 更新order_request表为未指派
order.setAppointmentStatus("NOT_ASSIGNED"); order.setAppointmentStatus("INIT");
orderRequestMPDao.updateById(order); orderInfoMPDao.updateById(order);
// 更新order_appointment表为未指派
LambdaUpdateWrapper<OrderAppointment> appWrapper = new LambdaUpdateWrapper<>();
appWrapper.set(OrderAppointment::getStatus, "NOT_ASSIGNED")
.eq(OrderAppointment::getOrderId, orderId).eq(OrderAppointment::getDt, order.getDt());
orderAppointmentMPDao.update(null, appWrapper);
// 登记事件 // 登记事件
OrderEvent oe = new OrderEvent(); OrderEvent oe = new OrderEvent();
...@@ -225,7 +197,8 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -225,7 +197,8 @@ public class OrderAssignImpl implements OrderAssign {
@Override @Override
public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException { public Result<?> orderReschedule(String orderId, LocalDateTime expectBegin, LocalDateTime expectEnd, String expectDesc) throws BusinessException {
// 工单改约接口(当前同放回工单池处理) // 工单改约接口(当前同放回工单池处理)
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
if (order == null) { if (order == null) {
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
} }
...@@ -239,18 +212,12 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -239,18 +212,12 @@ public class OrderAssignImpl implements OrderAssign {
LocalDate originDate = order.getDt(); // 改约前的日期 LocalDate originDate = order.getDt(); // 改约前的日期
// 更新order_request表为未指派 // 更新order_request表为未指派
order.setAppointmentStatus("NOT_ASSIGNED"); order.setAppointmentStatus("INIT");
order.setDt(expectBegin.toLocalDate()); order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(Timestamp.valueOf(expectBegin)); order.setExpectTimeBegin(Timestamp.valueOf(expectBegin));
order.setExpectTimeEnd(Timestamp.valueOf(expectEnd)); order.setExpectTimeEnd(Timestamp.valueOf(expectEnd));
order.setExpectTimeDesc(expectDesc); order.setExpectTimeDesc(expectDesc);
orderRequestMPDao.updateById(order); orderInfoMPDao.updateById(order);
// 更新order_appointment表为未指派
LambdaUpdateWrapper<OrderAppointment> appWrapper = new LambdaUpdateWrapper<>();
appWrapper.set(OrderAppointment::getStatus, "RESCHEDULED")
.eq(OrderAppointment::getOrderId, orderId).eq(OrderAppointment::getDt, originDate);
orderAppointmentMPDao.update(null, appWrapper);
// 登记事件 // 登记事件
OrderEvent oe = new OrderEvent(); OrderEvent oe = new OrderEvent();
...@@ -269,7 +236,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -269,7 +236,7 @@ public class OrderAssignImpl implements OrderAssign {
return Result.success(null); return Result.success(null);
} }
private List<String> searchEngineerCodes(OrderRequest order, String distance, String key, String recommend) { private List<String> searchEngineerCodes(OrderInfo order, String distance, String key, String recommend) {
Set<String> engineerCodes1 = this.searchEngineerByRecommend(order, recommend); Set<String> engineerCodes1 = this.searchEngineerByRecommend(order, recommend);
if (engineerCodes1.isEmpty()) { if (engineerCodes1.isEmpty()) {
log.info("recommend:{}筛选条件未找到技术员", recommend); log.info("recommend:{}筛选条件未找到技术员", recommend);
...@@ -316,7 +283,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -316,7 +283,7 @@ public class OrderAssignImpl implements OrderAssign {
return new ArrayList<>(engineerCodes1); return new ArrayList<>(engineerCodes1);
} }
private Set<String> searchEngineerByRecommend(OrderRequest order, String recommend) { private Set<String> searchEngineerByRecommend(OrderInfo order, String recommend) {
if (StringUtils.isNotEmpty(recommend) && recommend.equals("team")) { if (StringUtils.isNotEmpty(recommend) && recommend.equals("team")) {
return orgTeamEngineerMPDao.selectByTeamId(order.getOrgTeamId()).stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toSet()); return orgTeamEngineerMPDao.selectByTeamId(order.getOrgTeamId()).stream().map(OrgTeamEngineer::getEngineerCode).collect(Collectors.toSet());
} }
...@@ -355,18 +322,17 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -355,18 +322,17 @@ public class OrderAssignImpl implements OrderAssign {
return engineerInfoMPDao.selectList(lqw).stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toSet()); return engineerInfoMPDao.selectList(lqw).stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toSet());
} }
private List<TimeLineDTO> packTimelines(List<OrderAppointment> orders, HashMap<String, List<LabelValueDTO>> orderTips) { private List<TimeLineDTO> packTimelines(List<OrderInfo> orders, HashMap<String, List<LabelValueDTO>> orderTips) {
List<LabelValueDTO> empty = new ArrayList<>(); List<LabelValueDTO> empty = new ArrayList<>();
List<TimeLineDTO> items = new ArrayList<>(); List<TimeLineDTO> items = new ArrayList<>();
for (OrderAppointment order : orders) { for (OrderInfo order : orders) {
TimeLineDTO item = new TimeLineDTO(); TimeLineDTO item = new TimeLineDTO();
item.setOrderId(order.getOrderId()); item.setOrderId(order.getOrderId());
item.setPreStatus(order.getPreStatus()); item.setAppointmentStatus(order.getAppointmentStatus());
item.setAppointmentStatus(order.getStatus()); item.setStartTime(TimeUtils.IsoTimestamp2DateTime(order.getPlanStartTime()));
item.setStartTime(TimeUtils.IsoTimestamp2DateTime(order.getExpectStartTime())); item.setEndTime(TimeUtils.IsoTimestamp2DateTime(order.getPlanEndTime()));
item.setEndTime(TimeUtils.IsoTimestamp2DateTime(order.getExpectEndTime()));
item.setTips(orderTips.getOrDefault(order.getOrderId(), empty)); item.setTips(orderTips.getOrDefault(order.getOrderId(), empty));
items.add(item); items.add(item);
...@@ -374,12 +340,12 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -374,12 +340,12 @@ public class OrderAssignImpl implements OrderAssign {
return items; return items;
} }
private HashMap<String, List<LabelValueDTO>> packOrderTips(List<OrderRequest> orders) { private HashMap<String, List<LabelValueDTO>> packOrderTips(List<OrderInfo> orders) {
return orders.stream().collect(Collectors.toMap( return orders.stream().collect(Collectors.toMap(
OrderRequest::getOrderId, this::packOrderTip, (l1, l2) -> l1, HashMap::new)); OrderInfo::getOrderId, this::packOrderTip, (l1, l2) -> l1, HashMap::new));
} }
private List<LabelValueDTO> packOrderTip(OrderRequest order) { private List<LabelValueDTO> packOrderTip(OrderInfo order) {
// pack订单tips // pack订单tips
List<LabelValueDTO> items = new ArrayList<>(); List<LabelValueDTO> items = new ArrayList<>();
items.add(new LabelValueDTO("类型/品牌", String.format("%s %s %s", order.getSkill(), order.getType(), order.getBrand()))); items.add(new LabelValueDTO("类型/品牌", String.format("%s %s %s", order.getSkill(), order.getType(), order.getBrand())));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!