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 cc55c8a..cd484a8 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 @@ -250,11 +250,12 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { if (mesSaleOrderRelatesBySale != null && !mesSaleOrderRelatesBySale.isEmpty()) { throw new ServiceException("选择的销售订单已经合并过,不能绑定"); } - } + }else{ + if (orderBind.getSaleOrderId() != null) { + throw new ServiceException("安全库存标识为是的不需要选择销售订单"); + } - if (orderBind.getSafeFlag().equals(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES) - && orderBind.getSaleOrderId() != null) { - throw new ServiceException("安全库存标识为是的不需要选择销售订单"); + orderBind.setSaleOrderId(0L); } BigDecimal bindAmount = orderBind.getBindAmount() == null ? @@ -348,15 +349,15 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { MesPurchaseOrder dbMesPurchaseOrder = mesPurchaseOrderMapper. unbindPurchaseOrderListByPurchaseAndSaleOrderId(purchaseOrderId, mesSaleOrder.getSaleOrderId()); if (!mesPurchaseOrder.equals(dbMesPurchaseOrder)) { - throw new ServiceException("数据有变化,请重新更新"); + throw new ServiceException("序号: " + mesPurchaseOrder.getSerialNumber() +",数据有变化,请重新更新"); } if (dbMesPurchaseOrder.getOrderStatus().equals(MesConstants.MES_PURCHASE_ORDER_STATUS_PURCHASE_COMPLETE)) { - throw new ServiceException("此采购订单已经采购完成,无需再绑定"); + throw new ServiceException("序号: " + mesPurchaseOrder.getSerialNumber() +",此采购订单已经采购完成,无需再绑定"); } if (dbMesPurchaseOrder.getOrderStatus().equals(MesConstants.MES_PURCHASE_ORDER_STATUS_AUTO_OUTSTOCK_COMPLETE)) { - throw new ServiceException("此采购订单已经自动出库完成,无需再绑定"); + throw new ServiceException("序号: " + mesPurchaseOrder.getSerialNumber() +",此采购订单已经自动出库完成,无需再绑定"); } @@ -426,10 +427,15 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService { mesOrderBindMapper.insertMesOrderBind(orderBind); } else { MesOrderBind bind = bindList.get(0); - bind.setBindAmount(purchaseOrder.getUpdateAmount()); - bind.setUpdateBy(SecurityUtils.getUsername()); - bind.setUpdateTime(DateUtils.getNowDate()); - mesOrderBindMapper.updateMesOrderBind(bind); + if(purchaseOrder.getUpdateAmount().compareTo(BigDecimal.ZERO)>0){ + bind.setBindAmount(purchaseOrder.getUpdateAmount()); + bind.setUpdateBy(SecurityUtils.getUsername()); + bind.setUpdateTime(DateUtils.getNowDate()); + mesOrderBindMapper.updateMesOrderBind(bind); + }else{ + mesOrderBindMapper.deleteMesOrderBindByOrderBindId(bind.getOrderBindId()); + } + } } diff --git a/hw-ui/src/views/mes/saleOrder/bindingPurchase.vue b/hw-ui/src/views/mes/saleOrder/bindingPurchase.vue index bb5dc99..afb9f89 100644 --- a/hw-ui/src/views/mes/saleOrder/bindingPurchase.vue +++ b/hw-ui/src/views/mes/saleOrder/bindingPurchase.vue @@ -423,9 +423,9 @@ export default { const updateAmount = obj.updateAmount ? parseInt(obj.updateAmount) : 0;//更新绑定数 - if (!this.isPositiveInteger(updateAmount) || updateAmount <= 0) { + if (!this.isPositiveInteger(updateAmount) || updateAmount < 0) { this.submitLoading = false; - this.$modal.msgError("序号为" + (obj.serialNumber) + ",绑定数量须为大于0的正整数!"); + this.$modal.msgError("序号为" + (obj.serialNumber) + ",绑定数量须为大于等于0!"); return; }