From 6e5f6cae074980a5a468ec6d2f6f448a36e5fcd8 Mon Sep 17 00:00:00 2001 From: lihao Date: Thu, 15 Jan 2026 17:54:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81srm=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AfterPickmRecalUpdateBuyingreqRule.java | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) 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 b40965fb..93b3eadb 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 @@ -87,21 +87,68 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule { String ctpusql = "select pk_ct_pu_b from ct_pu_b where csrcbid ='" + map2.get("pk_praybill_b") + "' and dr = 0"; List> ctpus = (List>) dao.executeQuery(ctpusql, new MapListProcessor()); if(ctpus.isEmpty()){ - // 更新请购单 - 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); +// ========== 20260108 新增逻辑:路径2(无采购合同,请购单直接关联采购订单) ========== +// 直接查询请购单关联的采购订单(跳过采购合同) + String directOrderSql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0"; + List> directOrders = (List>) dao.executeQuery(directOrderSql, new MapListProcessor()); +// 遍历直接关联的采购订单 + if(directOrders.isEmpty()){ + // 更新请购单 + 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); + 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); + } + for (Map directOrder : directOrders) { + // 查询到货单 + String directArriveSql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + directOrder.get("pk_order_b") + "' and dr = 0"; + List> directArriveOrders = (List>) dao.executeQuery(directArriveSql, new MapListProcessor()); + int directInnum = directArriveOrders.size(); + // 同样的判断条件:C030组织且无到货单时更新 + if ("C030".equals(orgCode) && directInnum == 0) { + // 更新请购单 + String qgsql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='" + + map2.get("pk_praybill_b") + "'"; + dao.executeUpdate(qgsql); + // 更新采购订单 + String updateDirectOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='" + + directOrder.get("pk_order_b") + "'"; + dao.executeUpdate(updateDirectOrderSql); + // 同步SRM请购单(和原有逻辑一致) + 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); + } + } } for (Map ctpu : ctpus) { // 查询采购订单 String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + ctpu.get("pk_ct_pu_b") + "' and dr = 0"; List> orders = (List>) dao.executeQuery(ordersql, new MapListProcessor()); if(orders.isEmpty()){ + // 更新请购单 + String qgsql = "update po_praybill_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_praybill_b='" + + map2.get("pk_praybill_b") + "'"; + dao.executeUpdate(qgsql); // 更新采购合同 String sql = "update ct_pu_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_ct_pu_b='" + ctpu.get("pk_ct_pu_b") + "'"; int num = dao.executeUpdate(sql); + 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); } for (Map order : orders) { // 查询到货单