Commit e6cb3890 authored by zhengyi's avatar zhengyi

强制到仓业务调整

parent a77a583d
package cn.iocoder.yudao.framework.apollo.core.event.box;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Date;
/**
* 审批校验 Event
*
* @author zhengYi
*/
@Data
@AllArgsConstructor
public class BoxOrderForceWarehouseCheckEvent {
/**
* 订单ID
*/
private Long orderId;
/**
* 自编号
*/
private String selfNo;
/**
* 自编号
*/
private Date unloadTime;
/**
* 运输方式id
*/
private Integer transportId;
}
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.order.service.orderWarehouseCheck;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseCheck.OrderWarehouseCheckDO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderForceCheck;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderWarehouseCheckUpdateItemVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderWarehouseCheckUpdateReqVO;
......@@ -30,11 +31,11 @@ public interface OrderWarehouseCheckService extends IService<OrderWarehouseCheck
void check(long orderId);
/**
* 强制到仓. 箱数=入仓箱数
* 强制到仓. 订单修改为已卸柜/到仓 箱数=入仓箱数(注意:这里对/卸柜到仓箱标号不做处理)
*
* @param orderId 订单编号
* @param orderForceCheck 强制到仓信息
*/
void force(long orderId);
void force(OrderForceCheck orderForceCheck);
/**
* 撤销到仓. 修改订单状态为已清关,清空到仓时间箱数以及详情
......
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.order.service.orderWarehouseCheck;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxOrderForceWarehouseCheckEvent;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
......@@ -11,6 +12,7 @@ import cn.iocoder.yudao.module.depository.dal.dataobject.warehouse.WarehouseArea
import cn.iocoder.yudao.module.depository.dal.dataobject.warehouse.WarehouseAreaPositionDO;
import cn.iocoder.yudao.module.depository.dal.mysql.warehouse.WarehouseAreaMapper;
import cn.iocoder.yudao.module.depository.dal.mysql.warehouse.WarehouseAreaPositionMapper;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseCheck.OrderWarehouseCheckDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseIn.OrderWarehouseInDO;
......@@ -29,6 +31,7 @@ import cn.iocoder.yudao.module.order.vo.orderItem.OrderItemCheckWarehouseVO;
import cn.iocoder.yudao.module.order.vo.orderLocation.OrderLocationBackVO;
import cn.iocoder.yudao.module.order.vo.orderLocation.OrderLocationMergeVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.CheckItemSumVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderForceCheck;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderWarehouseCheckUpdateItemVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderWarehouseCheckUpdateReqVO;
import com.alibaba.fastjson.JSON;
......@@ -41,6 +44,7 @@ import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
......@@ -51,6 +55,8 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@Slf4j
@Service
@Validated
......@@ -62,7 +68,8 @@ public class OrderWarehouseCheckServiceImpl
@Autowired
private OrderMapper orderMapper;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private OrderWarehouseInService orderWarehouseInService;
@Autowired
......@@ -172,8 +179,15 @@ public class OrderWarehouseCheckServiceImpl
}
@Override
public void force(long orderId) {
check(orderId);
public void force(OrderForceCheck orderForceCheck) {
// 修改订单卸柜/到仓状态
OrderDO orderDO = orderMapper.selectById(orderForceCheck.getOrderId());
if (Objects.isNull(orderDO)) {
throw exception(ErrorCodeConstants.ORDER_NOT_EXISTS);
}
applicationContext.publishEvent(new BoxOrderForceWarehouseCheckEvent(orderDO.getOrderId(), orderDO.getContainerNumber(), orderForceCheck.getUnloadTime(), orderDO.getTransportId()));
// 同步到仓数据
check(orderForceCheck.getOrderId());
}
@Override
......@@ -196,7 +210,7 @@ public class OrderWarehouseCheckServiceImpl
public void update(OrderWarehouseCheckUpdateReqVO checkUpdateReqVO) {
Map<Long, OrderWarehouseCheckDO> mappings = listByOrderItemId(checkUpdateReqVO.getOrderItemId()).stream()
.collect(Collectors.toMap(OrderWarehouseCheckDO::getId, Function.identity()));
ServiceException exception = ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_WAREHOUSE_CHECK_NOT_EXISTS);
ServiceException exception = exception(ErrorCodeConstants.ORDER_WAREHOUSE_CHECK_NOT_EXISTS);
List<OrderWarehouseCheckDO> newWarehouseCheckDOList = new ArrayList<>();
Date now = DateUtil.date();
Long userId = SecurityFrameworkUtils.getLoginUserId();
......@@ -275,11 +289,11 @@ public class OrderWarehouseCheckServiceImpl
checkTime = orderWarehouseCheckDOListExist.stream().map(OrderWarehouseCheckDO::getCheckTime).filter(Objects::nonNull).sorted().findFirst().orElse(null);
boxGauge = orderWarehouseCheckDOListExist.stream().map(OrderWarehouseCheckDO::getBoxGauge).filter(Objects::nonNull).sorted().findFirst().orElse(null);
if (StringUtils.isBlank(boxGauge)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.BOX_GAUGE_FORMAT_ERROR);
throw exception(ErrorCodeConstants.BOX_GAUGE_FORMAT_ERROR);
}
String[] gauge = boxGauge.split("\\*");
if (gauge.length != 3) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.BOX_GAUGE_FORMAT_ERROR);
throw exception(ErrorCodeConstants.BOX_GAUGE_FORMAT_ERROR);
}
mixStatus = orderWarehouseCheckDOListExist.stream().anyMatch(t -> CollectionUtil.isNotEmpty(t.getOrderWarehouseInDetailsVOList())) ? 1 : 0;
}
......
package cn.iocoder.yudao.module.order.vo.orderWarehouseCheck;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
public class OrderForceCheck {
@ApiModelProperty("订单ID")
@NotNull(message = "请选择订单")
private Long orderId ;
@ApiModelProperty("卸柜/到仓时间")
@NotNull(message = "请输入卸柜/到仓时间")
private Date unloadTime;
}
......@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseCheck.OrderWar
import cn.iocoder.yudao.module.order.service.order.OrderQueryService;
import cn.iocoder.yudao.module.order.service.orderWarehouseCheck.OrderWarehouseCheckService;
import cn.iocoder.yudao.module.order.vo.order.OrderQueryVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderForceCheck;
import cn.iocoder.yudao.module.order.vo.orderWarehouseCheck.OrderWarehouseCheckUpdateReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -38,11 +39,11 @@ public class OrderWarehouseCheckController {
return success(service.listByOrderItemId(orderItemId));
}
@PostMapping("/force/{orderId}")
@PostMapping("/force")
@ApiOperation("强制到仓")
@ApiImplicitParam(name = "orderId", value = "订单id", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<Boolean> force(@PathVariable("orderId") Long orderId) {
service.force(orderId);
public CommonResult<Boolean> force(@Valid @RequestBody OrderForceCheck orderForceCheck) {
service.force(orderForceCheck);
return success(true);
}
......
package cn.iocoder.yudao.module.shipment.listener;
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxCheckOrderApprovalEvent;
import cn.iocoder.yudao.framework.apollo.core.event.box.BoxOrderForceWarehouseCheckEvent;
import cn.iocoder.yudao.module.shipment.dal.dataobject.BoxApprovalDO;
import cn.iocoder.yudao.module.shipment.dal.dataobject.BoxDO;
import cn.iocoder.yudao.module.shipment.enums.BoxApprovalTypeEnum;
import cn.iocoder.yudao.module.shipment.service.box.BoxService;
import cn.iocoder.yudao.module.shipment.service.boxApproval.BoxApprovalService;
import cn.iocoder.yudao.module.shipment.service.boxLoadInfo.BoxLoadInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.WAREHOUSE_IN_BOX_EXCEPTION;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeResultEnum.*;
import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.BOX_NOT_EXISTS;
/**
* 订单强制到仓业务执行
*
* @author zhengYi
*/
@Component("BoxOrderForceWarehouseCheckListener")
@AllArgsConstructor
@Slf4j
public class BoxOrderForceWarehouseCheckListener {
private final BoxLoadInfoService boxLoadInfoService;
private final BoxService boxService;
/**
* 订单强制到仓业务执行
*
* @param event 订单信息
*/
@EventListener(BoxOrderForceWarehouseCheckEvent.class)
public void orderForceWarehouseCheck(BoxOrderForceWarehouseCheckEvent event) {
BoxDO boxDO = boxService.getOne(new LambdaQueryWrapper<BoxDO>().eq(BoxDO::getSelfNo, event.getSelfNo()));
if (boxDO == null) {
throw exception(BOX_NOT_EXISTS);
}
if (event.getTransportId() == 1){
// 海运
boxLoadInfoService.updateOrderStatus(Arrays.asList(event.getOrderId()), event.getUnloadTime(), boxDO);
}else {
// 空运
boxLoadInfoService.updateOrderStatusAir(Arrays.asList(event.getOrderId()), event.getUnloadTime(), boxDO);
}
}
}
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