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 99a2bd8b..ca85399b 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 @@ -30,18 +30,31 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule { // 查询备料计划 String pickmsql = "select cpickm_bid,nplanoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + pmoid + "' and dr=0) and dr = 0"; List> hmateral = (List>) dao.executeQuery(pickmsql, new MapListProcessor()); - + // 根据 生产订单-备料计划-计划订单-请购单-采购订单-到货单-采购入库 依次更新下游单据 for (Map map : hmateral) { - String buyingreqsql = "select pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + map.get("cpickm_bid") + "' and dr = 0"; - List> buyingreq = (List>) dao.executeQuery(buyingreqsql, new MapListProcessor()); - for (Map map2 : buyingreq) { - if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal)map.get("nplanoutnum"))) >0) { - String sql = "update po_praybill_b set vbdef15='" +map.get("nplanoutnum") + "' where pk_praybill_b='" - +map2.get("pk_praybill_b") + "'"; - dao.executeUpdate(sql); + // 查询计划订单 + String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0"; + List> ploList = (List>) dao.executeQuery(plosql, new MapListProcessor()); + for (Map plo : ploList) { + // 查询请购单 + String buyingreqsql = "select pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0"; + List> buyingreq = (List>) dao.executeQuery(buyingreqsql, new MapListProcessor()); + for (Map map2 : buyingreq) { + if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal)map.get("nplanoutnum"))) >0) { + // 更新请购单 + String sql = "update po_praybill_b set vbdef15='" +map.get("nplanoutnum") + "' where pk_praybill_b='" + +map2.get("pk_praybill_b") + "'"; + dao.executeUpdate(sql); + + + } } } + + + + } } catch (DAOException e) { throw new RuntimeException(e);