|
|
@@ -106,6 +106,9 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
@Autowired
|
|
|
private PersonalProductService personalProductService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PurchaseOrderItemDao orderItemDao;
|
|
|
+
|
|
|
/**
|
|
|
* 最多数量
|
|
|
*/
|
|
|
@@ -372,6 +375,8 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
if (endQty > notice.getQty()) {
|
|
|
throw new IllegalOperatorException("累计发货数量将超出本次送货提醒的需求数!");
|
|
|
}
|
|
|
+ // 检验采购单需求数量
|
|
|
+ checkOrderQty(notice, thisQty);
|
|
|
PurchaseOrder order = notice.getOrderItem().getOrder();
|
|
|
send.setCurrency(order.getCurrency());
|
|
|
send.setBackStatus((short) Status.NOT_UPLOAD.value());
|
|
|
@@ -411,6 +416,31 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验发货提醒与采购单需求数量对比
|
|
|
+ *
|
|
|
+ * @param notice 发货提醒
|
|
|
+ * @param thisQty 本次发货数量
|
|
|
+ */
|
|
|
+ private void checkOrderQty(PurchaseNotice notice, double thisQty) {
|
|
|
+ List<PurchaseNotice> notices = purchaseNoticeDao.findByOrderItemId(notice.getOrderItemId());
|
|
|
+ PurchaseOrderItem item = orderItemDao.findOne(notice.getOrderItemId());
|
|
|
+ // 查询所有已发货数量
|
|
|
+ Double sendQty = 0.0;
|
|
|
+ for (PurchaseNotice purchaseNotice : notices) {
|
|
|
+ if (purchaseNotice.getEnd() != null) {
|
|
|
+ if (purchaseNotice.getEnd() != 1) {
|
|
|
+ sendQty += purchaseNotice.getEndQty();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sendQty += purchaseNotice.getEndQty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sendQty + thisQty > item.getQty()) {
|
|
|
+ throw new IllegalOperatorException("该采购单已发货数量[" + sendQty + "]本次发货数量["
|
|
|
+ + thisQty + "]总数超过订单需求数量[" + item.getQty() + "],请核对数量后重新发货");
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public int getOnhandCount() {
|
|
|
return purchaseNoticeDao.getCountByVendUUAndStatus(SystemSession.getUser().getEnterprise().getUu(),
|