This commit is contained in:
磷叶 2024-12-27 11:16:01 +08:00
parent f0fd164daa
commit 67b047ec5b
3 changed files with 31 additions and 0 deletions

View File

@ -33,4 +33,10 @@ public class OrderQuery extends OrderVO{
@ApiModelProperty("是否包含工序")
private Boolean needProcess;
@ApiModelProperty("精准订单号")
private String eqOrderNo;
@ApiModelProperty("排除的ID")
private Long excludeId;
}

View File

@ -34,6 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.deleted == null "> and bo.deleted = false</if>
<if test="query.status != null and query.status != ''"> and bo.status = #{query.status}</if>
<if test="query.material != null and query.material != ''"> and bo.material like concat('%', #{query.material}, '%')</if>
<if test="query.excludeId != null">and bo.id != #{query.excludeId}</if>
<if test="query.eqOrderNo != null and query.eqOrderNo != ''">and bo.order_no = #{query.eqOrderNo}</if>
<if test="query.statusList != null and query.statusList.size() > 0">
and bo.status in
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">

View File

@ -1,14 +1,18 @@
package com.ruoyi.bst.order.service.impl;
import com.ruoyi.bst.order.domain.OrderBO;
import com.ruoyi.bst.order.domain.OrderQuery;
import com.ruoyi.bst.order.domain.OrderVO;
import com.ruoyi.bst.order.domain.enums.OrderStatus;
import com.ruoyi.bst.order.service.OrderService;
import com.ruoyi.bst.order.service.OrderValidator;
import com.ruoyi.bst.orderProd.domain.OrderProdBO;
import com.ruoyi.bst.orderProd.domain.enums.OrderProdWorkType;
import com.ruoyi.bst.prodProcess.domain.ProdProcessBO;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.collection.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@ -20,6 +24,8 @@ import java.util.List;
@Service
public class OrderValidatorImpl implements OrderValidator {
@Autowired
private OrderService orderService;
@Override
public void checkBefore(OrderBO data) {
@ -36,6 +42,9 @@ public class OrderValidatorImpl implements OrderValidator {
}
}
// 校验订单编号
this.checkOrderNo(data.getId(), data.getOrderNo());
// 有且仅有一个结束的产品
boolean singleEndProd = this.hasSingleEndProd(data.getProdList());
ServiceUtil.assertion(!singleEndProd, "订单中必须有且仅有一个产品为成品");
@ -54,6 +63,18 @@ public class OrderValidatorImpl implements OrderValidator {
}
}
private void checkOrderNo(Long id, String orderNo) {
if (StringUtils.isBlank(orderNo)) {
return;
}
OrderQuery query = new OrderQuery();
query.setEqOrderNo(orderNo);
query.setExcludeId(id);
int unique = orderService.selectCount(query);
ServiceUtil.assertion(unique > 0, "订单编号%s已存在", orderNo);
}
private boolean hasSingleEndProcess(List<ProdProcessBO> processList) {
if (CollectionUtils.isEmptyElement(processList)) {
return false;
@ -87,5 +108,7 @@ public class OrderValidatorImpl implements OrderValidator {
@Override
public void checkAfter(OrderVO vo) {
// 校验订单编号
this.checkOrderNo(vo.getId(), vo.getOrderNo());
}
}