箱变负计划备料重算关闭最终需求数量为0请购单
This commit is contained in:
parent
2896878eae
commit
dbf94989a3
|
|
@ -2,18 +2,26 @@ package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
||||||
|
|
||||||
import nc.bs.dao.BaseDAO;
|
import nc.bs.dao.BaseDAO;
|
||||||
import nc.bs.dao.DAOException;
|
import nc.bs.dao.DAOException;
|
||||||
|
import nc.bs.framework.common.NCLocator;
|
||||||
import nc.bs.uapbd.util.MyHelper;
|
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.jdbc.framework.processor.MapListProcessor;
|
||||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
import nc.vo.bd.material.stock.MaterialStockVO;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||||
import nc.impl.pubapp.pattern.rule.IRule;
|
import nc.impl.pubapp.pattern.rule.IRule;
|
||||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||||
import nc.vo.org.OrgVO;
|
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.BusinessException;
|
||||||
import nc.vo.pub.lang.UFDouble;
|
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.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -29,73 +37,85 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
BaseDAO dao = new BaseDAO();
|
BaseDAO dao = new BaseDAO();
|
||||||
try {
|
try {
|
||||||
for (PMOAggVO pmoAggVO : pmoAggVOS) {
|
for (PMOAggVO pmoAggVO : pmoAggVOS) {
|
||||||
for (PMOItemVO pmoItemVO:pmoAggVO.getChildrenVO()){
|
for (PMOItemVO pmoItemVO : pmoAggVO.getChildrenVO()) {
|
||||||
configParams = MyHelper.getConfigParams("xb-config", null);
|
configParams = MyHelper.getConfigParams("xb-config", null);
|
||||||
if (configParams.isEmpty()) {
|
if (configParams.isEmpty()) {
|
||||||
throw new BusinessException("箱变的QMS接口缺少配置");
|
throw new BusinessException("箱变的QMS接口缺少配置");
|
||||||
}
|
}
|
||||||
String pkOrg = pmoAggVO.getParentVO().getPk_org();
|
String pkOrg = pmoAggVO.getParentVO().getPk_org();
|
||||||
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
String orgCode = MyHelper.transferField(OrgVO.getDefaultTableName(), OrgVO.CODE, OrgVO.PK_ORG, pkOrg);
|
||||||
if (checkIfOrg(orgCode, configParams)) {
|
if (checkIfOrg(orgCode, configParams)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String material= pmoItemVO.getCmaterialvid();
|
|
||||||
if(!checkProdect(material,pkOrg)){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
String pmoid=pmoItemVO.getCmoid();
|
String pmoid = pmoItemVO.getCmoid();
|
||||||
UFDouble nastnum=pmoItemVO.getNastnum();
|
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<Map<String, Object>> hmateral = (List<Map<String, Object>>) dao.executeQuery(pickmsql, new MapListProcessor());
|
||||||
// 根据 生产订单-备料计划-计划订单-请购单-采购订单-到货单-采购入库 依次更新下游单据
|
|
||||||
for (Map<String,Object> map : hmateral) {
|
List<String> pmobids = new ArrayList<String>();
|
||||||
// 查询计划订单
|
List<String> pmoids = new ArrayList<String>();
|
||||||
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> map : hmateral) {
|
||||||
for (Map<String,Object> plo : ploList) {
|
if (null == map.get("cbmaterialvid")) {
|
||||||
// 查询请购单
|
continue;
|
||||||
String buyingreqsql = "select 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());
|
String material = map.get("cbmaterialvid").toString();
|
||||||
for (Map<String,Object> map2 : buyingreq) {
|
if (!checkProdect(material, pkOrg)) {
|
||||||
if (new UFDouble((BigDecimal) map2.get("nnum")).compareTo(new UFDouble((BigDecimal)map.get("nplanoutnum"))) >0) {
|
continue;
|
||||||
// 更新请购单
|
}
|
||||||
String sql = "update po_praybill_b set vbdef33='" +map.get("nplanoutnum") + "' where pk_praybill_b='"
|
// 查询计划订单
|
||||||
+map2.get("pk_praybill_b") + "'";
|
String plosql = "select cpoid from mm_plo where vsrcbid ='" + map.get("cpickm_bid") + "' and dr = 0";
|
||||||
dao.executeUpdate(sql);
|
List<Map<String, Object>> ploList = (List<Map<String, Object>>) dao.executeQuery(plosql, new MapListProcessor());
|
||||||
// 查询采购订单
|
for (Map<String, Object> plo : ploList) {
|
||||||
String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0";
|
// 查询请购单
|
||||||
List<Map<String,Object>> orders = (List<Map<String,Object>>) dao.executeQuery(ordersql, new MapListProcessor());
|
String buyingreqsql = "select pk_praybill,pk_praybill_b,nnum from po_praybill_b where csourcebid ='" + plo.get("cpoid") + "' and dr = 0";
|
||||||
for (Map<String,Object> order : orders) {
|
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='"
|
||||||
|
+ map2.get("pk_praybill_b") + "'";
|
||||||
|
dao.executeUpdate(sql);
|
||||||
|
// 查询采购订单
|
||||||
|
String ordersql = "select pk_order_b from po_order_b where csourcebid ='" + map2.get("pk_praybill_b") + "' and dr = 0";
|
||||||
|
List<Map<String, Object>> orders = (List<Map<String, Object>>) dao.executeQuery(ordersql, new MapListProcessor());
|
||||||
|
for (Map<String, Object> order : orders) {
|
||||||
// 更新采购订单
|
// 更新采购订单
|
||||||
String updateOrderSql = "update po_order_b set vbdef33='" +map.get("nplanoutnum") + "' where pk_order_b='"
|
String updateOrderSql = "update po_order_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_order_b='"
|
||||||
+order.get("pk_order_b") + "'";
|
+ order.get("pk_order_b") + "'";
|
||||||
dao.executeUpdate(updateOrderSql);
|
dao.executeUpdate(updateOrderSql);
|
||||||
// 查询到货单
|
// 查询到货单
|
||||||
String arriveordersql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + order.get("pk_order_b") + "' and dr = 0";
|
String arriveordersql = "select pk_arriveorder_b from po_arriveorder_b where csourcebid ='" + order.get("pk_order_b") + "' and dr = 0";
|
||||||
List<Map<String,Object>> arriveorders = (List<Map<String,Object>>) dao.executeQuery(arriveordersql, new MapListProcessor());
|
List<Map<String, Object>> arriveorders = (List<Map<String, Object>>) dao.executeQuery(arriveordersql, new MapListProcessor());
|
||||||
for (Map<String,Object> arriveorder : arriveorders) {
|
for (Map<String, Object> arriveorder : arriveorders) {
|
||||||
// 更新到货单
|
// 更新到货单
|
||||||
String updatearriveorderSql = "update po_arriveorder_b set vbdef33='" +map.get("nplanoutnum") + "' where pk_arriveorder_b='"
|
String updatearriveorderSql = "update po_arriveorder_b set vbdef33='" + map.get("nplanoutnum") + "' where pk_arriveorder_b='"
|
||||||
+arriveorder.get("pk_arriveorder_b") + "'";
|
+ arriveorder.get("pk_arriveorder_b") + "'";
|
||||||
dao.executeUpdate(updatearriveorderSql);
|
dao.executeUpdate(updatearriveorderSql);
|
||||||
// 已经采购入库的数据不处理
|
// 已经采购入库的数据不处理
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pmobids.size() > 0) {
|
||||||
|
buyingreqRowClose(pmobids,pmoids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (DAOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
} catch (BusinessException ex) {
|
||||||
}
|
throw new RuntimeException(ex);
|
||||||
} catch (DAOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +123,37 @@ public class AfterPickmRecalUpdateBuyingreqRule implements IRule<PMOAggVO> {
|
||||||
throw new RuntimeException(e);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据物料查询物料库存信息页签-是否项目专用料进行判断
|
* 根据物料查询物料库存信息页签-是否项目专用料进行判断
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue