Commit 99401af3 by huangjinxin

fix:消息通知bean,插单优化

1 parent 16743816
......@@ -15,11 +15,13 @@ public interface OrderEventDao extends JpaRepository<OrderEventEntity, Integer>
List<OrderEventEntity> findByOrderId(String orderId);
List<OrderEventEntity> findByOrderIdAndEvent(String orderId, String event);
@Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByClusterId(String clusterId, Date date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId and DATE(a.createTime) = :date")
Page<OrderEventEntity> findAllByBranchId(String branchId, Date date, Pageable pageable);
Page<OrderEventEntity> findAllByBranchId(String branchId, Date date, Pageable pageable);
@Query("select a from OrderEventEntity a join OrderInfoEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId and DATE(a.createTime) = :date")
......
......@@ -75,12 +75,12 @@ public interface OrderInfoService {
/**
* 派工消息通知bean
*
* @param source 原订单
* @param target 改动后订单
* @param rescheduled 工单计划时间
* @param reason 改约原因
* @param operator 操作人
* @param source 原订单
* @param target 改动后订单
* @param isRescheduled 是否改约
* @param reason 改约原因
* @param operator 操作人
* @return
*/
Boolean rescheduled(OrderInfoEntity source, OrderInfoEntity target, Date rescheduled, String reason, String operator);
Boolean rescheduled(OrderInfoEntity source, OrderInfoEntity target, Boolean isRescheduled, String reason, String operator);
}
......@@ -398,7 +398,7 @@ public class DispatchServiceImpl implements DispatchService {
}
//回调改约
Boolean boo = orderInfoService.rescheduled(sourceOrder, entity, new Date(), "", "PEA");
Boolean boo = orderInfoService.rescheduled(sourceOrder, entity, false, "", "PEA");
log.info("[orderReschedule] orderId:{}, 通知bean结果: {}", sourceOrder.getOrderId(), boo);
if (!boo) {
throw new BusinessException("服务工单变更结果通知BEAN失败");
......
......@@ -226,7 +226,7 @@ public class OrderAssignImpl implements OrderAssign {
entity.setOrgClusterId(byTeamId.getClusterId());
}
//回调改约
Boolean boo = orderInfoService.rescheduled(sourceOrder, entity, new Date(), "", "PEA");
Boolean boo = orderInfoService.rescheduled(sourceOrder, entity, false, "", "PEA");
log.info("[orderReschedule] orderId:{}, 通知bean结果: {}", sourceOrder.getOrderId(), boo);
if (!boo) {
throw new BusinessException("服务工单变更结果通知BEAN失败");
......@@ -275,7 +275,7 @@ public class OrderAssignImpl implements OrderAssign {
}
orderInfoDao.save(order);
//回调改约
Boolean boo = orderInfoService.rescheduled(sourceOrder, order, new Date(), "", "PEA");
Boolean boo = orderInfoService.rescheduled(sourceOrder, order, false, "", "PEA");
log.info("[orderReschedule] orderId:{}, 通知bean结果: {}", sourceOrder.getOrderId(), boo);
if (!boo) {
throw new BusinessException("服务工单变更结果通知BEAN失败");
......
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.service.impl;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.dituhui.pea.bean.AllotResultParam;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum;
......@@ -45,6 +46,7 @@ import java.math.RoundingMode;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
......@@ -92,6 +94,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Autowired
private OrderEventDao OrderEventDao;
private final BeanRemoteServiceImpl beanRemoteService;
private final EngineerInfoDao engineerInfoDao;
......@@ -476,7 +481,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
orderInfoDao.save(order);
log.info("[orderReschedule] orderId:{}, order: {}", order.getOrderId(), JSONObject.toJSONString(order));
//回调改约
Boolean boo = this.rescheduled(sourceOrder, order, req.getHappendDate(), req.getReschedulingReason(), StringUtils.isNotBlank(req.getOperator()) ? req.getOperator() : "PEA");
Boolean boo = this.rescheduled(sourceOrder, order, true, req.getReschedulingReason(), StringUtils.isNotBlank(req.getOperator()) ? req.getOperator() : "PEA");
log.info("[orderReschedule] orderId:{}, 通知bean结果: {}", order.getOrderId(), boo);
if (!boo) {
throw new BusinessException("服务工单变更结果通知BEAN失败");
......@@ -490,30 +495,50 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Override
public Boolean rescheduled(OrderInfoEntity source, OrderInfoEntity target, Date rescheduledDate, String reason, String operator) {
public Boolean rescheduled(OrderInfoEntity source, OrderInfoEntity target, Boolean isRescheduled, String reason, String operator) {
if (source.getOrderId().startsWith("peatest") || Objects.equals(operator, "BEAN")) {
return true;
}
Rescheduled rescheduled = new Rescheduled();
rescheduled.setRisId(source.getOrderId());
rescheduled.setInitiatorOfRescheduling(operator);
rescheduled.setReasonForRescheduling(OrderReschedulingReason.getReason(reason));
rescheduled.setRescheduledDate(DateUtil.toMilliseconds(target.getPlanStartTime()));
rescheduled.setRequireApprove(Boolean.FALSE);
AllotResultParam allotResultParam = new AllotResultParam();
if (StringUtils.isNotBlank(target.getEngineerCode())) {
String engineerCode = target.getEngineerCode();
EngineerInfoEntity byEngineerCode = engineerInfoDao.getByEngineerCode(engineerCode);
rescheduled.setExecutorWorkNo(byEngineerCode.getCosmosId());
rescheduled.setOrgUnitId(byEngineerCode.getGroupId());
allotResultParam.setExecutorWorkNo(byEngineerCode.getCosmosId());
}
if (StringUtils.isNotBlank(target.getEngineerCodeSub())) {
EngineerInfoEntity code = engineerInfoDao.getByEngineerCode(target.getEngineerCodeSub());
rescheduled.setAssistantWorkNo(code.getCosmosId());
rescheduled.setAssOrgUnitId(code.getGroupId());
allotResultParam.setAssistantWorkNo(code.getCosmosId());
}
// 不是改约需要判断是否初次派单
if (!isRescheduled) {
List<OrderEventEntity> orderIdAndEvent = OrderEventDao.findByOrderIdAndEvent(target.getOrderId(), OrderEventEnum.reassignment.getEvent());
if (CollectionUtils.isEmpty(orderIdAndEvent)) {
allotResultParam.setRisId(target.getOrderId());
allotResultParam.setReason("自动派单");
allotResultParam.setAppointmentStartTime(target.getPlanStartTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
allotResultParam.setAppointmentEndTime(target.getPlanEndTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
boolean result = beanRemoteService.allotResultUpdate(allotResultParam);
log.info("【rescheduled服务工单派单结果更新allotResultUpdate】请求参数:{}, 响应结果:{}", JSONObject.toJSON(allotResultParam), result);
return result;
}
}
rescheduled.setRisId(source.getOrderId());
rescheduled.setInitiatorOfRescheduling(operator);
rescheduled.setReasonForRescheduling(OrderReschedulingReason.getReason(reason));
rescheduled.setRescheduledDate(DateUtil.toMilliseconds(target.getPlanStartTime()));
rescheduled.setRequireApprove(Boolean.FALSE);
//判断是否是改派
if ((StringUtils.isNotBlank(target.getEngineerCode()) && !Objects.equals(target.getEngineerCode(), source.getEngineerCode())) ||
(StringUtils.isNotBlank(target.getEngineerCodeSub()) && !Objects.equals(target.getEngineerCodeSub(), source.getEngineerCodeSub()))) {
......@@ -522,7 +547,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
rescheduled.setReassignment(Boolean.FALSE);
}
return beanRemoteService.orderRescheduled(rescheduled);
boolean result = beanRemoteService.orderRescheduled(rescheduled);
log.info("【rescheduled服务工单派单结果更新orderRescheduled】请求参数:{}, 响应结果:{}", JSONObject.toJSON(rescheduled), result);
return result;
}
......@@ -605,7 +632,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
// 没有单直接返回
if (CollectionUtils.isEmpty(orderSegments)) {
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, beginStart, beginEnd, takeTime, true, insertOrder);
if (!handleLeaveTimeResult.getCode().equals(ResultEnum.SUCCESS)) {
if (!handleLeaveTimeResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
......@@ -658,7 +685,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(moveTime));
}
//回调改约
Boolean boo = this.rescheduled(sourceOrder, nestOrder, new Date(), "", "PEA");
Boolean boo = this.rescheduled(sourceOrder, nestOrder, false, "", "PEA");
log.info("[insterEngineerOrders] orderId:{}, 通知bean结果: {}", nestOrder.getOrderId(), boo);
if (!boo) {
log.info("[insterEngineerOrders] orderId:{}, 服务工单变更结果通知BEAN失败", nestOrder.getOrderId());
......@@ -716,7 +743,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
continue;
}
//回调改约
Boolean boo = this.rescheduled(sourceOrder, nestOrder, new Date(), "", "PEA");
Boolean boo = this.rescheduled(sourceOrder, nestOrder, false, "", "PEA");
log.info("[insterEngineerOrders] orderId:{}, 通知bean结果: {}", nestOrder.getOrderId(), boo);
if (!boo) {
log.info("[insterEngineerOrders] orderId:{}, 服务工单变更结果通知BEAN失败", nestOrder.getOrderId());
......@@ -798,7 +825,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(minutes));
}
//回调改约
Boolean boo = this.rescheduled(sourceOrder, nestOrder, new Date(), "", "PEA");
Boolean boo = this.rescheduled(sourceOrder, nestOrder, false, "", "PEA");
log.info("[insterEngineerOrders] orderId:{}, 通知bean结果: {}", nestOrder.getOrderId(), boo);
if (!boo) {
log.info("[insterEngineerOrders] orderId:{}, 服务工单变更结果通知BEAN失败", nestOrder.getOrderId());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!