Commit bb94843d by 刘鑫

fix(改约回调): 改约回调

1 parent 9f854f07
......@@ -3,7 +3,7 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.dto.param.Location;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
@Data
......@@ -12,6 +12,10 @@ public class OrderReschedule {
private String expectBegin;
private String expectEnd;
private String expectDesc;
/**
* 操作发生时间
*/
private Date happendDate = new Date();
/**
* 操作员
......
......@@ -8,6 +8,7 @@ import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.List;
......
......@@ -25,6 +25,7 @@ import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.*;
import com.dituhui.pea.order.feign.bean.OrderCancel;
import com.dituhui.pea.order.feign.bean.Reason;
import com.dituhui.pea.order.feign.bean.Rescheduled;
import com.dituhui.pea.order.service.*;
import com.dituhui.pea.order.utils.CommonUtil;
import com.dituhui.pea.order.utils.OrderUtil;
......@@ -37,6 +38,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -46,10 +48,7 @@ import java.math.RoundingMode;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -97,6 +96,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
private EngineerBusinessDao engineerBusinessDao;
private final BeanRemoteServiceImpl beanRemoteService;
private final EngineerInfoDao engineerInfoDao;
/**
......@@ -117,14 +117,12 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.success(null);
}
//排除自己
List<String> multipleOrdersList = infoList.stream().filter(e -> !e.getOrderId().equals(orderId))
.map(OrderInfoEntity::getMultipleOrders).distinct().collect(Collectors.toList());
List<String> multipleOrdersList = infoList.stream().filter(e -> !e.getOrderId().equals(orderId)).map(OrderInfoEntity::getMultipleOrders).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(multipleOrdersList)) {
return Result.success(null);
}
//查看是否已存在一家多单id存在则返回
List<String> multipleOrdersFilterList = infoList.stream().filter(e -> StringUtils.isNotEmpty(e.getMultipleOrders()))
.map(OrderInfoEntity::getMultipleOrders).distinct().collect(Collectors.toList());
List<String> multipleOrdersFilterList = infoList.stream().filter(e -> StringUtils.isNotEmpty(e.getMultipleOrders())).map(OrderInfoEntity::getMultipleOrders).distinct().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(multipleOrdersFilterList)) {
return Result.success(multipleOrdersFilterList.get(0));
}
......@@ -229,9 +227,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
orderCancelParam.setCancellationReason(reason);
beanRemoteService.orderCancel(orderCancelParam);
//记录流程
commonService.addOrderEvent(orderId, "", "BEAN", "BEAN", OrderEventEnum.cancel.getEvent(),
String.format(OrderEventEnum.cancel.getMsg(), engineerName + "-" + (ObjectUtil.isNotNull(orgTeamEntity) ? orgTeamEntity.getTeamName() : "")),
"", actualStartTime);
commonService.addOrderEvent(orderId, "", "BEAN", "BEAN", OrderEventEnum.cancel.getEvent(), String.format(OrderEventEnum.cancel.getMsg(), engineerName + "-" + (ObjectUtil.isNotNull(orgTeamEntity) ? orgTeamEntity.getTeamName() : "")), "", actualStartTime);
} else if (request.getOrderStatus().equalsIgnoreCase(OrderStatusEnum.RESCHEDULED.getCode())) {
//组装改约接口
OrderReschedule reschedule = new OrderReschedule();
......@@ -245,6 +241,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
reschedule.setOrderTags(request.getOrderTags());
reschedule.setExpectBegin(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeBegin()));
reschedule.setExpectEnd(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeEnd()));
reschedule.setHappendDate(happenDate);
if (StringUtils.isNotBlank(request.getDescription())) {
reschedule.setDescription(request.getDescription());
}
......@@ -273,6 +270,8 @@ public class OrderInfoServiceImpl implements OrderInfoService {
}
LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd());
OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId());
final OrderInfoEntity sourceOrder = new OrderInfoEntity();
BeanUtils.copyProperties(order, sourceOrder);
if (ObjectUtil.isNull(order)) {
throw new BusinessException("订单不存在");
}
......@@ -383,8 +382,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
}
}
}
log.info("[orderReschedule] orderId:{} orderstatus: isToday:{},isBelong:{},isNetwork:{},isAssign:{},skillUpdate:{}",
order.getOrderId(), isToday, isBelong, isNetwork, isAssign, skillUpdate);
log.info("[orderReschedule] orderId:{} orderstatus: isToday:{},isBelong:{},isNetwork:{},isAssign:{},skillUpdate:{}", order.getOrderId(), isToday, isBelong, isNetwork, isAssign, skillUpdate);
// 当天单变更技能直接人工指派
if (isToday && skillUpdate) {
if (isAssign) {
......@@ -460,8 +458,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
OrgTeamEntity teamInfo = null;
if (StringUtils.isNotBlank(teamId)) {
teamInfo = orgTeamDao.getByTeamId(teamId);
special = CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
special = CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(), order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), teamInfo.getWorkOff());
} else {
cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), null);
......@@ -479,15 +476,52 @@ public class OrderInfoServiceImpl implements OrderInfoService {
order.setPlanEndTime(order.getExpectTimeEnd());
orderInfoDao.save(order);
log.info("[orderReschedule] orderId:{}, order: {}", order.getOrderId(), JSONObject.toJSONString(order));
//
if (!Objects.equals(req.getOperator(), "BEAN")) {
//回调改约
Rescheduled pea = rescheduled(sourceOrder, order, req.getHappendDate(), req.getReschedulingReason(), "PEA");
beanRemoteService.orderRescheduled(pea);
}
// 登记事件
commonService.addOrderEvent(req.getOrderId(), "", req.getOperator(), req.getOperator(), OrderEventEnum.recontracting.getEvent(),
String.format(OrderEventEnum.recontracting.getMsg(), engineerName + "-" + (ObjectUtil.isNotNull(orgTeamEntity) ? orgTeamEntity.getTeamName() : ""),
ObjectUtil.isNotNull(orgGroupEntity) ? orgGroupEntity.getGroupName() : "", req.getExpectBegin(), req.getReschedulingReason()),
StringUtils.isNotBlank(req.getReschedulingReason()) ? "改约原因:" + req.getReschedulingReason() : "");
commonService.addOrderEvent(req.getOrderId(), "", req.getOperator(), req.getOperator(), OrderEventEnum.recontracting.getEvent(), String.format(OrderEventEnum.recontracting.getMsg(), engineerName + "-" + (ObjectUtil.isNotNull(orgTeamEntity) ? orgTeamEntity.getTeamName() : ""), ObjectUtil.isNotNull(orgGroupEntity) ? orgGroupEntity.getGroupName() : "", req.getExpectBegin(), req.getReschedulingReason()), StringUtils.isNotBlank(req.getReschedulingReason()) ? "改约原因:" + req.getReschedulingReason() : "");
return Result.success(null);
}
public Rescheduled rescheduled(OrderInfoEntity source, OrderInfoEntity target, Date happened, String reason, String operator) {
Rescheduled rescheduled = new Rescheduled();
rescheduled.setRisId(source.getOrderId());
rescheduled.setInitiatorOfRescheduling(operator);
Reason reasons = new Reason();
reasons.setOneLevel(reason);
rescheduled.setReasonForRescheduling(reasons);
rescheduled.setRescheduledDate(happened.getTime());
rescheduled.setRequireApprove(Boolean.FALSE);
String engineerCode = target.getEngineerCode();
if ((StringUtils.isNotBlank(target.getEngineerCode()) && !Objects.equals(engineerCode, source.getEngineerCode())) ||
(StringUtils.isNotBlank(target.getEngineerCodeSub()) && !Objects.equals(target.getEngineerCodeSub(), source.getEngineerCodeSub()))) {
rescheduled.setReassignment(Boolean.TRUE);
} else {
rescheduled.setReassignment(Boolean.FALSE);
EngineerInfoEntity byEngineerCode = engineerInfoDao.getByEngineerCode(engineerCode);
rescheduled.setExecutorWorkNo(engineerCode);
rescheduled.setOrgUnitId(byEngineerCode.getGroupId());
if (StringUtils.isNotBlank(target.getEngineerCodeSub())) {
rescheduled.setAssistantWorkNo(target.getEngineerCodeSub());
EngineerInfoEntity code = engineerInfoDao.getByEngineerCode(target.getEngineerCodeSub());
rescheduled.setAssOrgUnitId(code.getGroupId());
}
}
return rescheduled;
}
/**
* 改约原因
*
......@@ -781,8 +815,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
for (int i = 0; i < engineerLeaveTimeSlice.size(); i++) {
OccupyInfoDetail occupyInfoDetail = engineerLeaveTimeSlice.get(i);
// 请假之中
if (isLeave && (expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) >= 0 || expectTimeBegin.plusMinutes(takeTime + rodeTime).compareTo(occupyInfoDetail.getBeginTime()) >= 0) &&
(expectTimeEnd.compareTo(occupyInfoDetail.getEndTime()) <= 0 || expectTimeEnd.plusMinutes(takeTime + rodeTime).compareTo(occupyInfoDetail.getEndTime()) <= 0)) {
if (isLeave && (expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) >= 0 || expectTimeBegin.plusMinutes(takeTime + rodeTime).compareTo(occupyInfoDetail.getBeginTime()) >= 0) && (expectTimeEnd.compareTo(occupyInfoDetail.getEndTime()) <= 0 || expectTimeEnd.plusMinutes(takeTime + rodeTime).compareTo(occupyInfoDetail.getEndTime()) <= 0)) {
return null;
}
// 请假开始之前能插入
......@@ -815,8 +848,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
for (int i = 0; i < engineerLeaveTimeSlice.size(); i++) {
OccupyInfoDetail occupyInfoDetail = engineerLeaveTimeSlice.get(i);
// 请假之中
if (isLeave && (expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) >= 0 || expectTimeBegin.plusMinutes(takeTime).compareTo(occupyInfoDetail.getBeginTime()) >= 0) &&
(expectTimeEnd.compareTo(occupyInfoDetail.getEndTime()) <= 0 || expectTimeEnd.plusMinutes(takeTime).compareTo(occupyInfoDetail.getEndTime()) <= 0)) {
if (isLeave && (expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) >= 0 || expectTimeBegin.plusMinutes(takeTime).compareTo(occupyInfoDetail.getBeginTime()) >= 0) && (expectTimeEnd.compareTo(occupyInfoDetail.getEndTime()) <= 0 || expectTimeEnd.plusMinutes(takeTime).compareTo(occupyInfoDetail.getEndTime()) <= 0)) {
return Result.failed(StatusCodeEnum.ENGINEER_IS_LEAVE_TIME);
}
// 请假开始之前能插入
......@@ -912,8 +944,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
// order.setIsSpecialTime(CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
// order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff()));
//特殊时间段
Integer special = CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
Integer special = CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(), order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
Integer cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), teamInfo.getWorkOff());
// 处理cutoff 动态排班结束后创建的当日单和次日单
boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(order.getExpectTimeBegin());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!