Commit e02be106 authored by Administrator's avatar Administrator

Merge branch 'release' into 'jd_dev'

Release分支合并到jd分支20250104

See merge request !67
parents 616b53a5 80868350
package cn.iocoder.yudao.framework.apollo.core.event.warehouseIn;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 入仓订单检查订单入仓异常 Event
*
* @author zhengYi
*/
@Data
@AllArgsConstructor
public class WarehouseInOrderCheckExceptionEvent {
/**
* 订单id
*/
private Long orderId;
}
package cn.iocoder.yudao.module.order.listener;
import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderCheckExceptionEvent;
import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
/**
* 入仓订单检查订单入仓异常监听
*
* @author zhengYi
*/
@Component("WarehouseInOrderCheckExceptionListener")
@AllArgsConstructor
public class WarehouseInOrderCheckExceptionListener {
private final OrderWarehouseInService orderWarehouseInService;
/**
* 入仓订单检查订单入仓异常更新业务
*
* @param event 订单id
*/
@EventListener(WarehouseInOrderCheckExceptionEvent.class)
public void warehouseInOrderCheckExceptionEvent(WarehouseInOrderCheckExceptionEvent event) {
orderWarehouseInService.finishWarehouseInWhenCheckException(event.getOrderId());
}
}
...@@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderRemoveLadin ...@@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderRemoveLadin
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxOrderDynamicEstTimeEvent; import cn.iocoder.yudao.framework.apollo.core.event.box.BoxOrderDynamicEstTimeEvent;
import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderChangeChannelEvent; import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderChangeChannelEvent;
import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderChangeTransportEvent; import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderChangeTransportEvent;
import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderCheckExceptionEvent;
import cn.iocoder.yudao.framework.common.util.spring.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.util.spring.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.bigDecimal.BigDecimalUtils; import cn.iocoder.yudao.framework.common.util.bigDecimal.BigDecimalUtils;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO; import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
...@@ -2198,12 +2199,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -2198,12 +2199,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
throw exception(ORDER_UPDATE_APPROVAL_MUST_BE_WAREHOUSE_IN); throw exception(ORDER_UPDATE_APPROVAL_MUST_BE_WAREHOUSE_IN);
} }
} }
if (isShipment) { // if (isShipment) {
// 出货阶段的修改,需要将当前订单状态值标出,放首位 // // 出货阶段的修改,需要将当前订单状态值标出,放首位
ApplyInfoVO applyInfoVO = new ApplyInfoVO(); // ApplyInfoVO applyInfoVO = new ApplyInfoVO();
applyInfoVO.setName(statusName); // applyInfoVO.setName(statusName);
applyInfoList.addFirst(applyInfoVO); // applyInfoList.addFirst(applyInfoVO);
} // }
// 订单有修改则执行修改审批任务 // 订单有修改则执行修改审批任务
vo.setApplyInfoList(applyInfoList); vo.setApplyInfoList(applyInfoList);
orderApprovalDO = new OrderApprovalDO(); orderApprovalDO = new OrderApprovalDO();
...@@ -4408,7 +4409,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -4408,7 +4409,12 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
currentOrderDO.setAuditResult(auditResult); currentOrderDO.setAuditResult(auditResult);
if (StringUtils.isNotBlank(auditResult)) { if (StringUtils.isNotBlank(auditResult)) {
// 获取固定中文说明描述 // 获取固定中文说明描述
msg = I18nMessage.getZhMessage(auditResult); // 这里针对订单修改审批业务需要补充,当订单在出货阶段进行编辑审批时,需要
msg = (((Objects.equals(auditResult,order_update_processing.getDesc())
|| Objects.equals(auditResult,order_update_pass.getDesc())
|| Objects.equals(auditResult,order_update_reject.getDesc())
|| Objects.equals(auditResult,order_update_cancel.getDesc()))
&& currentOrderDO.getShipmentState() > 0) ? OrderStatusEnum.valueOf(currentOrderDO.getStatus()).getNameZh().concat("-"): "").concat(I18nMessage.getZhMessage(auditResult));
} }
if (auditType == 0) { if (auditType == 0) {
this.checkOrderProcessingApprovalType(currentOrderDO, auditType, auditResult); this.checkOrderProcessingApprovalType(currentOrderDO, auditType, auditResult);
...@@ -6016,8 +6022,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl ...@@ -6016,8 +6022,10 @@ public class OrderServiceImpl extends AbstractService<OrderMapper, OrderDO> impl
orderDO.setContainerNumber(null); orderDO.setContainerNumber(null);
orderDO.setTidanNo(null); orderDO.setTidanNo(null);
orderMapper.updateById(orderDO); orderMapper.updateById(orderDO);
// TODO 这里修改完订单后需要对订单当前待处理的相关异常进行判断,是否需要重置 // 检查入仓异常信息自动处理
// TODO 注意:重泡货异常如果需要重置,需要调用计价接口,重新计算价格(这里计算的价格是应收总额价格) applicationContext.publishEvent(
new WarehouseInOrderCheckExceptionEvent(orderDO.getOrderId()));
// 处理控货信息 // 处理控货信息
handleOrderCargoControl(consignorDO, orderDO); handleOrderCargoControl(consignorDO, orderDO);
// 重新计价 // 重新计价
......
...@@ -64,6 +64,14 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> { ...@@ -64,6 +64,14 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> {
*/ */
boolean finishWarehouseInWhenChangeTransportType(Long orderId); boolean finishWarehouseInWhenChangeTransportType(Long orderId);
/**
* 订单信息修改后需要检查订单入仓异常情况
*
* @param orderId
*/
void finishWarehouseInWhenCheckException(Long orderId);
/** /**
* 订单储位接口 * 订单储位接口
* *
...@@ -150,7 +158,6 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> { ...@@ -150,7 +158,6 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> {
String updateOrUpdateApply(@Valid OrderWarehouseInUpdateApplyReqVO updateReqVO); String updateOrUpdateApply(@Valid OrderWarehouseInUpdateApplyReqVO updateReqVO);
/** /**
* 出货阶段-追加申请 * 出货阶段-追加申请
* *
...@@ -264,11 +271,9 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> { ...@@ -264,11 +271,9 @@ public interface OrderWarehouseInService extends IService<OrderWarehouseInDO> {
WarehouseInInfoVO getStatisticsFirstFinishedAfterPacked(Long orderId); WarehouseInInfoVO getStatisticsFirstFinishedAfterPacked(Long orderId);
List<OrderWarehouseInWithAttrVO> getOrderWarehouseInCommonAttrList(Long orderId, Long excludeOrderWarehouseInId); List<OrderWarehouseInWithAttrVO> getOrderWarehouseInCommonAttrList(Long orderId, Long excludeOrderWarehouseInId);
/** /**
* 有订单,但客户类型不正确。故这里通过客户订单来修改客户状态 * 有订单,但客户类型不正确。故这里通过客户订单来修改客户状态
*/ */
......
...@@ -6,6 +6,8 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -6,6 +6,8 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderRemoveLadingBillEvent;
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderSchedulingEvent;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent; import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.framework.apollo.core.event.QueryChannelInfoEvent; import cn.iocoder.yudao.framework.apollo.core.event.QueryChannelInfoEvent;
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderSchedulingEvent; import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderSchedulingEvent;
...@@ -1097,6 +1099,27 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1097,6 +1099,27 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
return this.finishWarehouseIn(finishReqVO); return this.finishWarehouseIn(finishReqVO);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void finishWarehouseInWhenCheckException(Long orderId) {
OrderWarehouseInFinishReqVO finishReqVO = new OrderWarehouseInFinishReqVO();
finishReqVO.setOrderId(orderId);
//不需要更新影像
finishReqVO.setUpdateWarehouseInUrl(false);
//不需要更新标签
finishReqVO.setUpdateLabel(false);
//不需要更新用户的 状态 和下一次掉入公海时间
finishReqVO.setUpdateCustomer(false);
//不需要给客户发送入仓短信
finishReqVO.setSendMsg(false);
//不需要纪录操作日志
finishReqVO.setIsAddOrderOperateLog(false);
// 仅重置入仓异常信息
finishReqVO.setIsOnlyResetException(true);
this.finishWarehouseIn(finishReqVO);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean finishWarehouseIn(OrderWarehouseInFinishReqVO finishReqVO) { public boolean finishWarehouseIn(OrderWarehouseInFinishReqVO finishReqVO) {
...@@ -1139,7 +1162,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1139,7 +1162,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
// 退场入仓不校验这些、拆单入仓不校验 // 退场入仓不校验这些、拆单入仓不校验
boolean isNotRollbackIn = boolean isNotRollbackIn =
Boolean.FALSE.equals(finishReqVO.getIsRollbackIn()); Boolean.FALSE.equals(finishReqVO.getIsRollbackIn());
if (isNotRollbackIn && !finishReqVO.getIsSplitIn()) { if (isNotRollbackIn && !finishReqVO.getIsSplitIn() && !finishReqVO.getIsOnlyResetException()) {
// 订单排单校验 // 订单排单校验
applicationContext.publishEvent( applicationContext.publishEvent(
new BoxCheckOrderSchedulingEvent(orderId)); new BoxCheckOrderSchedulingEvent(orderId));
...@@ -1318,19 +1341,20 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1318,19 +1341,20 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
// 处理发货人异常 // 处理发货人异常
//需要到仓确认,需要自动生成发货人异常信息 //需要到仓确认,需要自动生成发货人异常信息
processConsignorException(finishReqVO, orderId, orderDO); processConsignorException(finishReqVO.getIsUpdateCallback(), orderId, orderDO);
// 重新调用计算订单价格, 订单信息和订单项信息需要重新查询, // 重新调用计算订单价格, 订单信息和订单项信息需要重新查询,
// 可能创建异常和修改订单已经对订单信息造成改变 // 可能创建异常和修改订单已经对订单信息造成改变
boolean firstRucang = orderDO.getRucangTime() == null; boolean firstRucang = orderDO.getRucangTime() == null;
if (!finishReqVO.getIsOnlyResetException()) {
// 默认执行计价业务,可以手动确认不执行计价业务
if (firstRucang) { if (firstRucang) {
//在下面的函数中完成费用计算 //在下面的函数中完成费用计算
orderService.finishOrderWarehouseIn(orderDO.getOrderId()); orderService.finishOrderWarehouseIn(orderDO.getOrderId());
} else { } else {
orderService.finishOrderWarehouseInUpdate(orderDO.getOrderId()); orderService.finishOrderWarehouseInUpdate(orderDO.getOrderId());
} }
}
} }
// 更新订单状态 // 更新订单状态
...@@ -1688,9 +1712,9 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1688,9 +1712,9 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
return false; return false;
} }
private void processConsignorException(OrderWarehouseInFinishReqVO finishReqVO, Long orderId, OrderDO orderDO) { private void processConsignorException(Boolean isUpdateCallback, Long orderId, OrderDO orderDO) {
//入仓修改回调的入仓不需要生成单证异常和发货人异常 //入仓修改回调的入仓不需要生成单证异常和发货人异常
if (!Boolean.TRUE.equals(finishReqVO.getIsUpdateCallback())) { if (!Boolean.TRUE.equals(isUpdateCallback)) {
// 海运要发货人异常,空运不要发货人异常 // 海运要发货人异常,空运不要发货人异常
if (orderDO.getTransportId() != 3 && orderDO.getTransportId() != 4) { if (orderDO.getTransportId() != 3 && orderDO.getTransportId() != 4) {
// 1.12.发货人异常(客户档案设置了到仓确认,此类客户的货是通知装柜才可装) // 1.12.发货人异常(客户档案设置了到仓确认,此类客户的货是通知装柜才可装)
...@@ -1725,6 +1749,9 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1725,6 +1749,9 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
if (CollectionUtil.isEmpty(listOrderException)) { if (CollectionUtil.isEmpty(listOrderException)) {
orderExceptionService.createOrderException(orderExceptionCreateReqVO); orderExceptionService.createOrderException(orderExceptionCreateReqVO);
} }
} else {
orderExceptionService.autoProcessException(orderId, null, OrderExceptionEnum.ORDER_CONSIGNOR_EXCEPTION,
"系统自动处理为已处理", OrderExceptionResult.ORDER_CONSIGNOR_EXCEPTION_RESULT.CONFIRM_CHECK);
} }
} }
} }
...@@ -1771,7 +1798,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -1771,7 +1798,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
} else { } else {
if (isUpdateCallback) { if (isUpdateCallback) {
// v2.2 当入仓纪录修改审批后,订单非重货且当前存在重货异常未处理,系统自动处理异常,处理结果设置为普货 // v2.2 当入仓纪录修改审批后,订单非重货且当前存在重货异常未处理,系统自动处理异常,处理结果设置为普货
orderExceptionService.autoProcessException(orderId, null, OrderExceptionEnum.ORDER_HEAVY_CARGO_EXCEPTION, "订单入仓纪录修改,订单非重货,系统自动处理为已处理", OrderExceptionResult.ORDER_HEAVY_CARGO_EXCEPTION_RESULT.GENERAL_CARGO); orderExceptionService.autoProcessException(orderId, null, OrderExceptionEnum.ORDER_HEAVY_CARGO_EXCEPTION, "订单入仓纪录修改,订单非重货,系统自动处理为已处理", OrderExceptionResult.ORDER_HEAVY_CARGO_EXCEPTION_RESULT.GENERAL_CARGO);
// 更新订单为普货 // 更新订单为普货
orderService.updateOrderType(orderId, 1); orderService.updateOrderType(orderId, 1);
} else { } else {
...@@ -4408,7 +4435,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -4408,7 +4435,7 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderService.shipmentOrderInWarehouse(orderWarehouseInVO); orderService.shipmentOrderInWarehouse(orderWarehouseInVO);
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "航运中-入仓修改审批已通过", updateReqVO.getApplyInfoVOList()); orderBusinessService.addOrderOperateLog(orderId, "仓库操作", OrderStatusEnum.valueOf(orderDO.getStatus()).getNameZh().concat("-入仓修改审批已通过"), updateReqVO.getApplyInfoVOList());
// 预装、理货、装柜 // 预装、理货、装柜
applicationContext.publishEvent(new BoxOrderShipmentWarehouseInEvent(orderId)); applicationContext.publishEvent(new BoxOrderShipmentWarehouseInEvent(orderId));
...@@ -4457,12 +4484,14 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -4457,12 +4484,14 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderItemService.updateById(orderItemDO); orderItemService.updateById(orderItemDO);
} }
orderBusinessService.addOrderOperateLog(orderId, "仓库操作", "航运中-入仓追加审批已通过", updateReqVO.getApplyInfoVOList()); orderBusinessService.addOrderOperateLog(orderId, "仓库操作", OrderStatusEnum.valueOf(orderDO.getStatus()).getNameZh().concat("-入仓追加审批已通过"), updateReqVO.getApplyInfoVOList());
// 预装、理货、装柜 // 预装、理货、装柜
applicationContext.publishEvent(new BoxOrderShipmentWarehouseInEvent(orderId)); applicationContext.publishEvent(new BoxOrderShipmentWarehouseInEvent(orderId));
} }
// 入仓修改或入仓追加审批通过后,需要重置可能存在的提单(当订单已经开始出货了就可能已制作提单)
applicationContext.publishEvent(new BoxCheckOrderRemoveLadingBillEvent(orderId));
} }
...@@ -6027,6 +6056,64 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI ...@@ -6027,6 +6056,64 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
} }
public void processExceptionWhenOrderUpdate(Long orderId) {
OrderDO orderDO = orderService.getById(orderId);
if (orderDO == null) {
throw ServiceExceptionUtil.exception(
ErrorCodeConstants.ORDER_NOT_EXISTS);
}
// 重置重泡货优惠
resetSpecialVWeightAndWeightUnit(orderId, orderDO,
false, // finishReqVO.getIsSumWeightNoChange(),
false //finishReqVO.getIsSumVolumeNoChange()
);
List<OrderWarehouseInDO> orderWarehouseInDOList =
orderWarehouseInMapper.selectList(OrderWarehouseInDO::getOrderId,
orderDO.getOrderId());
if (CollUtil.isNotEmpty(orderWarehouseInDOList)) {
processChannelPackagingOverWeightException(orderDO);
}
// 重泡货配置
ZhongPaoBestVO zhongPaoBest = getZhongPaoBest(orderDO);
BigDecimal weightSum =
orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getWeight).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal volumeSum =
orderWarehouseInDOList.stream().map(OrderWarehouseInDO::getVolume).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
// 处理重泡货异常
processZhongPaoException(orderId, orderDO, zhongPaoBest, weightSum, volumeSum,
true, // finishReqVO.getIsUpdateCallback(),
false, // finishReqVO.getIsSumVolumeNoChange(),
false, // finishReqVO.getIsSumWeightNoChange(),
orderDO.getAirShipment() == 4 //finishStocked
);
// 处理发货人异常
processConsignorException(false, orderId, orderDO);
// 查询订单异常数量
List<OrderExceptionDO> orderUnProcessExceptionList =
orderExceptionService.getPendingOrderExceptionByOrderIdAndOrderItemIdAndExceptionKey(orderId, null, null);
// 重置异常状态
int exceptionNum = orderUnProcessExceptionList.size();
if (exceptionNum == 0) {
orderService.updateStatus(orderId, orderDO.getOrderNo(), null, 0, null, null, null, null, false);
} else if (exceptionNum == 1) {
// 由多个异常变成1个异常时,需要更新
OrderExceptionDO orderExceptionDO = orderUnProcessExceptionList.get(0);
orderService.updateStatus(orderId, orderDO.getOrderNo(),
null, OrderAbnormalStateEnum.keyOf(orderExceptionDO.getOrderExceptionType()).getValue(), null, null, null, null, false);
}
}
private OrderDO updateOrderSumPrevPacked(Long orderId) { private OrderDO updateOrderSumPrevPacked(Long orderId) {
orderService.updateSumDataPrevPacked(orderId); orderService.updateSumDataPrevPacked(orderId);
return orderService.getById(orderId); return orderService.getById(orderId);
......
...@@ -106,4 +106,9 @@ public class OrderWarehouseInFinishReqVO { ...@@ -106,4 +106,9 @@ public class OrderWarehouseInFinishReqVO {
@Transient @Transient
private Boolean isAddOrderOperateLog = true; private Boolean isAddOrderOperateLog = true;
//是否只单独重置异常
@Transient
private Boolean isOnlyResetException = false;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment