diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseOrder.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseOrder.java index 7b29b4c..3e9c20e 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseOrder.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseOrder.java @@ -158,6 +158,28 @@ public class MesPurchaseOrder extends BaseEntity { /** 条码数 */ private BigDecimal barcodeAmount; + /** 更新绑定数量 */ + private BigDecimal updateAmount; + + /** 序号 */ + private Long serialNumber; + + public Long getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(Long serialNumber) { + this.serialNumber = serialNumber; + } + + public BigDecimal getUpdateAmount() { + return updateAmount; + } + + public void setUpdateAmount(BigDecimal updateAmount) { + this.updateAmount = updateAmount; + } + public BigDecimal getBoundAmount() { return boundAmount; } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java index 4ba207e..e2b4003 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseOrderServiceImpl.java @@ -246,6 +246,8 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { if (StringUtils.isNull(saleOrderId)){ return 0; } + //校验数据 + checkSaveSalesBindPurchase(purchaseOrderList); MesSaleOrder mesSaleOrder = mesSaleOrderMapper.selectMesSaleOrderBySaleOrderId(saleOrderId); String saleorderCode = mesSaleOrder.getSaleorderCode(); Long productId = mesSaleOrder.getMaterialId(); @@ -267,7 +269,6 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { String materialCode = mesPurchaseOrder.getMaterialCode(); String materialName = mesPurchaseOrder.getMaterialName(); String poNo = mesPurchaseOrder.getPoNo(); - BigDecimal orderAmount = mesPurchaseOrder.getOrderAmount(); orderBind.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO); orderBind.setSaleOrderId(saleOrderId); orderBind.setSaleOrderCode(saleorderCode); @@ -278,14 +279,14 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { orderBind.setMaterialId(materialId); orderBind.setMaterialCode(materialCode); orderBind.setMaterialName(materialName); - orderBind.setBindAmount(purchaseOrder.getSaleBindAmount()); + orderBind.setBindAmount(purchaseOrder.getUpdateAmount()); orderBind.setPoNo(poNo); orderBind.setCreateTime(currentDate); orderBind.setCreateBy(userName); mesOrderBindMapper.insertMesOrderBind(orderBind); } else { MesOrderBind bind = bindList.get(0); - bind.setBindAmount(purchaseOrder.getSaleBindAmount()); + bind.setBindAmount(purchaseOrder.getUpdateAmount()); bind.setUpdateBy(SecurityUtils.getUsername()); bind.setUpdateTime(DateUtils.getNowDate()); mesOrderBindMapper.updateMesOrderBind(bind); @@ -294,6 +295,23 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { return 1; } + private void checkSaveSalesBindPurchase(List purchaseOrderList) { + for (MesPurchaseOrder purchaseOrder : purchaseOrderList) { + BigDecimal boundAmount = purchaseOrder.getBoundAmount();//已绑定总数 + BigDecimal saleBindAmount = purchaseOrder.getSaleBindAmount();//销售订单已绑定数 + BigDecimal updateAmount = purchaseOrder.getUpdateAmount();//更新绑定数量 + BigDecimal orderAmount = purchaseOrder.getOrderAmount();//采购订单数量 + BigDecimal safeAmount = purchaseOrder.getSafeAmount();//安全库存数 + BigDecimal barcodeAmount = purchaseOrder.getBarcodeAmount();//条码数 + BigDecimal totalBindAmount = boundAmount.subtract(saleBindAmount).add(updateAmount); + // (已绑定总数 - 销售订单已绑定数 + 更新绑定数量) 需要小于等于 采购订单数量 + if (totalBindAmount.compareTo(orderAmount) > 0) { + throw new ServiceException("序号: " + purchaseOrder.getSerialNumber() + " 总绑定数大于订单数!"); + } + + } + } + /** * 删除销售订单绑定采购订单 * diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml index 248d35f..cd591fb 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseOrderMapper.xml @@ -256,12 +256,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from mes_purchase_order mpo left join mes_base_material_info mbmi on mbmi.material_id = mpo.material_id - and mpo.po_no = #{poNo} - and mpo.material_code = #{materialCode} + and mpo.po_no like concat('%', #{poNo}, '%') + and mpo.material_code like concat('%', #{materialCode}, '%') and mpo.material_name like concat('%', #{materialName}, '%') and mpo.specification_parameter like concat('%', #{specificationParameter}, '%') + and mbmi.material_spec like concat('%', #{materialSpec}, '%') - order by sale_bind_amount desc + order by mpo.po_no ,mpo.material_code