流程生产订单保存前校验物料类型是否一致-精密铸造
This commit is contained in:
parent
0a7b8779d1
commit
eeaf3c30e2
|
|
@ -2,6 +2,7 @@ package nc.bs.mmpac.pmo.pac0002.bp;
|
|||
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterApproveSyncPLMRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.BeforePmoBomRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.BeforePmoWlbzJMRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.saveBeforeCheckRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint;
|
||||
import nc.bs.mmpac.pmo.pac0002.rule.*;
|
||||
|
|
@ -195,6 +196,7 @@ public class PMOInsertBP {
|
|||
IRule<PMOAggVO> saveBeforeCheckRule = new saveBeforeCheckRule();
|
||||
processer.addBeforeRule(saveBeforeCheckRule);
|
||||
|
||||
processer.addBeforeRule(new BeforePmoWlbzJMRule());
|
||||
processer.addBeforeRule(new BeforePmoBomRule());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
package nc.bs.mmpac.pmo.pac0002.bp;
|
||||
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.AfterPlanStartTimeChangeRule;
|
||||
import nc.bs.mmpac.pmo.pac0002.bp.rule.BeforePmoWlbzJMRule;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -249,6 +250,7 @@ public class PMOUpdateBP {
|
|||
processer.addBeforeRule(procedureIRule);
|
||||
IRule<PMOAggVO> atoCheck = new PMOATOCheckRule();
|
||||
processer.addBeforeRule(atoCheck);
|
||||
processer.addBeforeRule(new BeforePmoWlbzJMRule());
|
||||
}
|
||||
|
||||
private void addAfterRule(CompareAroundProcesser<PMOAggVO> processer) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
||||
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.trade.business.HYSuperDMO;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.am.common.util.StringUtils;
|
||||
import nc.vo.bd.defdoc.DefdocVO;
|
||||
import nc.vo.bd.material.stock.MaterialStockVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
||||
import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
||||
import nc.vo.org.FactoryVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 流程生产订单保存前校验物料类型是否一致-精密铸造
|
||||
*
|
||||
* @author mzr
|
||||
* @date 2025/10/20
|
||||
*/
|
||||
public class BeforePmoWlbzJMRule implements IRule<PMOAggVO> {
|
||||
private static final String LOG_INFO_NAME = "qyMesLog";
|
||||
private static final Log logger = Log.getInstance(LOG_INFO_NAME);
|
||||
|
||||
@Override
|
||||
public void process(PMOAggVO[] vos) {
|
||||
try {
|
||||
Map<String, String> configParams = MyHelper.getConfigParams("jm-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (PMOAggVO vo : vos) {
|
||||
PMOHeadVO headVO = vo.getParentVO();
|
||||
String pkOrg = headVO.getPk_org();
|
||||
|
||||
String orgCode = MyHelper.getStrValByCondition(FactoryVO.getDefaultTableName(), FactoryVO.CODE,
|
||||
FactoryVO.PK_FACTORY + " = '" + pkOrg + "'");
|
||||
// 只有精密公司才校验
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
PMOItemVO[] pmoItemVOS = vo.getChildrenVO();
|
||||
if (pmoItemVOS != null && pmoItemVOS.length > 1) {
|
||||
// 如果明细超过1行,根据物料档案库存信息自定义项3 精密物料标志字段进行区分,同一个生产订单明细中不能存在不同的类型
|
||||
Set<String> materialTypeSet = new HashSet<>();
|
||||
for (PMOItemVO pmoItemVO : pmoItemVOS) {
|
||||
// 物料ID
|
||||
String cmaterialvid = pmoItemVO.getCmaterialvid();
|
||||
String wlbzId = MyHelper.getStrValByCondition(MaterialStockVO.getDefaultTableName(), MaterialStockVO.DEF3,
|
||||
MaterialStockVO.PK_MATERIAL + " = '" + cmaterialvid + "' and pk_org = '" + pkOrg + "'");
|
||||
String defName = getDefName("zdy-jmzz001", wlbzId);
|
||||
if (MMValueCheck.isNotEmpty(defName)) {
|
||||
materialTypeSet.add(defName);
|
||||
}
|
||||
}
|
||||
if (materialTypeSet.size() > 1) {
|
||||
ExceptionUtils.wrappBusinessException("生产订单明细中存在不同类型物料,请检查");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
logger.error("BeforePmoMaterialTypeJMRule-exp:" + e.getMessage(), e);
|
||||
ExceptionUtils.wrappException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("jmOrg");
|
||||
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(",");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义项信息
|
||||
*/
|
||||
private String getDefName(String code, String pk_defdoc) {
|
||||
String res = "";
|
||||
String strWhere = " pk_defdoclist in (select pk_defdoclist from bd_defdoclist where code='" + code + "' and dr=0 ) and dr = 0 and pk_defdoc = '" + pk_defdoc + "'";
|
||||
try {
|
||||
DefdocVO[] defdocVOs = (DefdocVO[]) new HYSuperDMO().queryByWhereClause(DefdocVO.class, strWhere);
|
||||
if (defdocVOs != null && defdocVOs.length > 0) {
|
||||
res = defdocVOs[0].getName().trim();
|
||||
}
|
||||
} catch (DAOException e) {
|
||||
logger.error("BeforePmoMaterialTypeJMRule-error,getDefName[" + e.getMessage() + "]");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue