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("是否包含工序") @ApiModelProperty("是否包含工序")
private Boolean needProcess; 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.deleted == null "> and bo.deleted = false</if>
<if test="query.status != null and query.status != ''"> and bo.status = #{query.status}</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.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"> <if test="query.statusList != null and query.statusList.size() > 0">
and bo.status in and bo.status in
<foreach item="item" collection="query.statusList" open="(" separator="," close=")"> <foreach item="item" collection="query.statusList" open="(" separator="," close=")">

View File

@ -1,14 +1,18 @@
package com.ruoyi.bst.order.service.impl; package com.ruoyi.bst.order.service.impl;
import com.ruoyi.bst.order.domain.OrderBO; 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.OrderVO;
import com.ruoyi.bst.order.domain.enums.OrderStatus; 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.order.service.OrderValidator;
import com.ruoyi.bst.orderProd.domain.OrderProdBO; import com.ruoyi.bst.orderProd.domain.OrderProdBO;
import com.ruoyi.bst.orderProd.domain.enums.OrderProdWorkType; import com.ruoyi.bst.orderProd.domain.enums.OrderProdWorkType;
import com.ruoyi.bst.prodProcess.domain.ProdProcessBO; import com.ruoyi.bst.prodProcess.domain.ProdProcessBO;
import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.collection.CollectionUtils; 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 org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -20,6 +24,8 @@ import java.util.List;
@Service @Service
public class OrderValidatorImpl implements OrderValidator { public class OrderValidatorImpl implements OrderValidator {
@Autowired
private OrderService orderService;
@Override @Override
public void checkBefore(OrderBO data) { 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()); boolean singleEndProd = this.hasSingleEndProd(data.getProdList());
ServiceUtil.assertion(!singleEndProd, "订单中必须有且仅有一个产品为成品"); 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) { private boolean hasSingleEndProcess(List<ProdProcessBO> processList) {
if (CollectionUtils.isEmptyElement(processList)) { if (CollectionUtils.isEmptyElement(processList)) {
return false; return false;
@ -87,5 +108,7 @@ public class OrderValidatorImpl implements OrderValidator {
@Override @Override
public void checkAfter(OrderVO vo) { public void checkAfter(OrderVO vo) {
// 校验订单编号
this.checkOrderNo(vo.getId(), vo.getOrderNo());
} }
} }