diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterPickmRecalUpdateBuyingreqRule.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterPickmRecalUpdateBuyingreqRule.java index 4b713bf0..55390068 100644 --- a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterPickmRecalUpdateBuyingreqRule.java +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/AfterPickmRecalUpdateBuyingreqRule.java @@ -81,35 +81,30 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule { pmoids.add(map2.get("pk_praybill").toString()); } if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal) map.get("nplanoutnum"))) > 0) { - // 更新请购单 - String sql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='" - + map2.get("pk_praybill_b") + "'"; - int num = dao.executeUpdate(sql); - if (num > 0 && "C030".equals(orgCode)) { - SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil(); - JSONObject reqData = new JSONObject(); - reqData.put("org", "C030");// 组织编码 - reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键 - reqData.put("mainNum", map.get("nplanoutnum"));// 主数量 - billUtil.reqBIPBill(reqData); - } // 查询采购订单 String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0"; List> orders = (List>) dao.executeQuery(ordersql, new MapListProcessor()); for (Map order : orders) { - // 更新采购订单 - String updateOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='" - + order.get("pk_order_b") + "'"; - dao.executeUpdate(updateOrderSql); // 查询到货单 String arriveordersql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + order.get("pk_order_b") + "' and dr = 0"; List> arriveorders = (List>) dao.executeQuery(arriveordersql, new MapListProcessor()); - for (Map arriveorder : arriveorders) { - // 更新到货单 - String updatearriveorderSql = "update po_arriveorder_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_arriveorder_b='" - + arriveorder.get("pk_arriveorder_b") + "'"; - dao.executeUpdate(updatearriveorderSql); - // 已经采购入库的数据不处理 + // 20251216 备料重算优化 如果有到货单则不更新最终需求数量 + int innum=arriveorders.size(); + if ("C030".equals(orgCode) && innum ==0) { + // 更新请购单 + String sql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='" + + map2.get("pk_praybill_b") + "'"; + int num = dao.executeUpdate(sql); + // 更新采购订单 + String updateOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='" + + order.get("pk_order_b") + "'"; + dao.executeUpdate(updateOrderSql); + SyncSrmPrayBillUtil billUtil = new SyncSrmPrayBillUtil(); + JSONObject reqData = new JSONObject(); + reqData.put("org", "C030");// 组织编码 + reqData.put("erpId", map2.get("pk_praybill_b"));// 请购单表体主键 + reqData.put("mainNum", map.get("nplanoutnum"));// 主数量 + billUtil.reqBIPBill(reqData); } } }