Commit bb94843d by 刘鑫

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

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