feat(mmpac): 优化流程生产订单赋值生产BOM字段逻辑
- 增加配置参数检查,只处理指定的组织 - 查询并赋值生产BOM版本号和ID - 添加异常处理和日志记录
This commit is contained in:
parent
9bb3a751d8
commit
071394bf64
|
@ -3,11 +3,16 @@ package nc.bs.mmpac.pmo.pac0002.bp.rule;
|
|||
import nc.bs.logging.Logger;
|
||||
import nc.bs.uapbd.util.MyHelper;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.vo.bd.bom.bom0202.entity.BomVO;
|
||||
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.am.common.util.StringUtils;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程生产订单赋值生产BOM字段
|
||||
|
@ -20,29 +25,55 @@ public class BeforePmoBomRule implements IRule<PMOAggVO> {
|
|||
@Override
|
||||
public void process(PMOAggVO[] vos) {
|
||||
try {
|
||||
Map<String, String> configParams = MyHelper.getConfigParams("xb-config", null);
|
||||
if (configParams.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (PMOAggVO vo : vos) {
|
||||
PMOHeadVO headVO = vo.getParentVO();
|
||||
String pkOrg = headVO.getPk_org();
|
||||
|
||||
MyHelper.getStrValByCondition(FactoryVO.getDefaultTableName(), FactoryVO.CODE,
|
||||
String orgCode = MyHelper.getStrValByCondition(FactoryVO.getDefaultTableName(), FactoryVO.CODE,
|
||||
FactoryVO.PK_FACTORY + " = '" + pkOrg + "'");
|
||||
// 只有箱变公司才赋值生产BOM字段
|
||||
if (!"C030".equals(pkOrg)) {
|
||||
if (checkIfOrg(orgCode, configParams)) {
|
||||
continue;
|
||||
}
|
||||
// 箱变公司赋值生产BOM的相关字段 cbomversionid vbomversion
|
||||
// 箱变公司赋值生产BOM的相关字段
|
||||
PMOItemVO[] pmoItemVOS = vo.getChildrenVO();
|
||||
for (PMOItemVO pmoItemVO : pmoItemVOS) {
|
||||
// vsrctype 来源单据类型 来源销售订单的需要赋值
|
||||
if ("30".equals(pmoItemVO.getVsrctype())) {
|
||||
pmoItemVO.setVbomversion(""); // 生产BOM版本号
|
||||
pmoItemVO.setCbomversionid(""); // 生产BOM版本
|
||||
// BOM状态 (FBomBillstatusEnum) 是否需要判断BOM的状态
|
||||
// 根据bom版本号查询BOM(销售订单号+行号)
|
||||
String bomVersion = pmoItemVO.getVsrccode() + pmoItemVO.getVsrcrowno();
|
||||
String whereSql = BomVO.PK_ORG + " = '" + pkOrg + "' AND " + BomVO.HVERSION + " = '" + bomVersion + "'";
|
||||
String bomId = MyHelper.getStrValByCondition(BomVO.TABLE_NAME, BomVO.CBOMID, whereSql);
|
||||
if (StringUtils.isEmpty(bomId)) {
|
||||
throw new BusinessException("未找到对应的BOM");
|
||||
}
|
||||
pmoItemVO.setVbomversion(bomVersion); // 生产BOM版本号
|
||||
pmoItemVO.setCbomversionid(bomId); // 生产BOM版本
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
Logger.error("BeforePmoBomRule-exp:" + e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
ExceptionUtils.wrappException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIfOrg(String code, Map<String, String> configParams) throws BusinessException {
|
||||
String targetCode = configParams.get("xbOrg");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue