箱变负计划备料重算关闭最终需求数量为0请购单

This commit is contained in:
lihao 2025-11-11 15:51:18 +08:00
parent 2896878eae
commit dbf94989a3
1 changed files with 97 additions and 46 deletions

View File

@ -2,18 +2,26 @@ package nc.bs.mmpac.pmo.pac0002.bp.rule;
import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.NCLocator;
import nc.bs.uapbd.util.MyHelper;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.itf.pu.m20.IPraybillMaintain;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.vo.bd.material.stock.MaterialStockVO;
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
import nc.vo.org.OrgVO;
import nc.vo.pu.m20.entity.PraybillItemVO;
import nc.vo.pu.m20.entity.PraybillVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.model.transfer.bill.ClientBillToServer;
import nccloud.framework.service.ServiceLocator;
import nccloud.pubitf.pu.buyingreq.service.IBuyingReqQueryCardInfoService;
import nccloud.web.pu.buyingreq.util.PublicUtil;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -39,26 +47,38 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
if (checkIfOrg(orgCode, configParams)) {
continue;
}
String material= pmoItemVO.getCmaterialvid();
if(!checkProdect(material,pkOrg)){
continue;
}
try {
String pmoid = pmoItemVO.getCmoid();
UFDouble nastnum = pmoItemVO.getNastnum();
// 查询备料计划
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";
String pickmsql = "select cpickm_bid,cbmaterialvid,nplanoutnum from mm_pickm_b where cpickmid in ( select cpickmid from mm_pickm where csourcebillrowid='" + pmoid + "' and dr=0) and dr = 0";
List<Map<String, Object>> hmateral = (List<Map<String, Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
List<String> pmobids = new ArrayList<String>();
List<String> pmoids = new ArrayList<String>();
// 根据 生产订单-备料计划-计划订单-请购单-采购订单-到货单-采购入库 依次更新下游单据
for (Map<String, Object> map : hmateral) {
if (null == map.get("cbmaterialvid")) {
continue;
}
String material = map.get("cbmaterialvid").toString();
if (!checkProdect(material, pkOrg)) {
continue;
}
// 查询计划订单
String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0";
List<Map<String, Object>> ploList = (List<Map<String, Object>>) dao.executeQuery(plosql, new MapListProcessor());
for (Map<String, Object> plo : ploList) {
// 查询请购单
String buyingreqsql = "select pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
List<Map<String, Object>> buyingreq = (List<Map<String, Object>>) dao.executeQuery(buyingreqsql, new MapListProcessor());
for (Map<String, Object> map2 : buyingreq) {
if (UFDouble.ZERO_DBL.compareTo(new UFDouble(map.get("nplanoutnum").toString())) == 0) {
pmobids.add(map2.get("pk_praybill_b").toString());
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='"
@ -83,19 +103,19 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
// 已经采购入库的数据不处理
}
}
}
}
}
if (pmobids.size() > 0) {
buyingreqRowClose(pmobids,pmoids);
}
} catch (DAOException e) {
throw new RuntimeException(e);
}
} catch (DAOException ex) {
throw new RuntimeException(ex);
} catch (BusinessException ex) {
throw new RuntimeException(ex);
}
}
}
@ -103,6 +123,37 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
throw new RuntimeException(e);
}
}
private void buyingreqRowClose(List<String> pmobids, List<String> pmoids) throws BusinessException {
String reason = "¸º¼Æ»®";
IBuyingReqQueryCardInfoService query = NCLocator.getInstance().lookup(IBuyingReqQueryCardInfoService.class);
PraybillVO[] rvo = query.queryVOs(pmoids.toArray(new String[0]));
if (null == rvo || rvo.length == 0) {
PublicUtil util = new PublicUtil();
util.afterError();
}
for (PraybillVO vo : rvo) {
ClientBillToServer<PraybillVO> tool = new ClientBillToServer<PraybillVO>();
PraybillVO[] lightVOs = (PraybillVO[])tool.construct(new PraybillVO[]{vo}, new PraybillVO[]{vo});
for(PraybillVO storeReqAppVO : lightVOs) {
PraybillItemVO[] bvos = storeReqAppVO.getBVO();
if (bvos != null && bvos.length > 0) {
for(PraybillItemVO bvo : bvos) {
bvo.setAttributeValue("vclosereason", reason);
}
}
}
IPraybillMaintain orderCloseService =NCLocator.getInstance().lookup(IPraybillMaintain.class);
// lightVOs[0].getParent().setAttributeValue("ts", info.getTs());
// lightVOs[0].getBVO()[0].setAttributeValue("ts", info.getBts());
PraybillVO[] returnVos = orderCloseService.closeBillRow(lightVOs);
}
}
/**
* 根据物料查询物料库存信息页签-是否项目专用料进行判断
*