重构 MES同步规则中的组织检查逻辑- 移除各规则中重复的组织代码检查逻辑
- 新增通用的 checkIfIncludeOrg 方法用于组织检查 - 更新相关规则调用新的组织检查方法 - 优化 BatchTransferToPurchaseOrder 中的错误处理和状态更新逻辑
This commit is contained in:
parent
a6bac28c63
commit
3e622e7141
|
@ -5,6 +5,7 @@ import nc.bs.dao.BaseDAO;
|
|||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.bd.psn.PsndocVO;
|
||||
|
@ -26,6 +27,8 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl.checkIfIncludeOrg;
|
||||
|
||||
/**
|
||||
* ²É¹ºÈë¿âÇ©×Öºóͬ²½µ½MES
|
||||
*/
|
||||
|
@ -135,15 +138,9 @@ public class AfterSigningSynchronizeRuleMES implements IRule<PurchaseInVO> {
|
|||
private List<PurchaseInVO> checkAndFilterBills(PurchaseInVO[] purchaseInVOS) {
|
||||
List<PurchaseInVO> result = new ArrayList<>();
|
||||
for (PurchaseInVO vo : purchaseInVOS) {
|
||||
// 检查组织是否为电缆组织
|
||||
// if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) {
|
||||
// result.add(vo);
|
||||
// }
|
||||
|
||||
try {
|
||||
String targetCode = "C034";
|
||||
String code = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, vo.getParentVO().getPk_org());
|
||||
if (code != null && code.equals(targetCode)) {
|
||||
if (checkIfIncludeOrg(code)) {
|
||||
result.add(vo);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import nc.bs.dao.BaseDAO;
|
|||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
import nc.vo.bd.material.measdoc.MeasdocVO;
|
||||
|
@ -30,6 +31,8 @@ import java.math.RoundingMode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl.checkIfIncludeOrg;
|
||||
|
||||
/**
|
||||
* (前置)采购收货单推送MES系统,后续调用采购入库
|
||||
*/
|
||||
|
@ -128,15 +131,9 @@ public class PurchaseReceiptRuleMES implements IRule<PurchaseInVO> {
|
|||
private List<PurchaseInVO> checkAndFilterBills(PurchaseInVO[] purchaseInVOS) {
|
||||
List<PurchaseInVO> result = new ArrayList<>();
|
||||
for (PurchaseInVO vo : purchaseInVOS) {
|
||||
// 检查组织是否为电缆组织
|
||||
// if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) {
|
||||
// result.add(vo);
|
||||
// }
|
||||
|
||||
try {
|
||||
String targetCode = "C034";
|
||||
String code = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, vo.getParentVO().getPk_org());
|
||||
if (code != null && code.equals(targetCode)) {
|
||||
if (checkIfIncludeOrg(code)) {
|
||||
result.add(vo);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import nc.bs.dao.BaseDAO;
|
|||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.vo.bd.currtype.CurrtypeVO;
|
||||
import nc.vo.bd.cust.CustomerVO;
|
||||
|
@ -37,6 +38,8 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl.checkIfIncludeOrg;
|
||||
|
||||
|
||||
/**
|
||||
* 销售出库(签字后传MES金思维系统)
|
||||
|
@ -191,14 +194,9 @@ public class AfterSigningSynchronizeRuleMES implements IRule<SaleOutVO> {
|
|||
private List<SaleOutVO> checkAndFilterBills(SaleOutVO[] saleOutVOS) {
|
||||
List<SaleOutVO> result = new ArrayList<>();
|
||||
for (SaleOutVO vo : saleOutVOS) {
|
||||
// 检查组织是否为电缆组织
|
||||
// if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) {
|
||||
// result.add(vo);
|
||||
// }
|
||||
try {
|
||||
String targetCode = "C034";
|
||||
String code = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, vo.getParentVO().getPk_org());
|
||||
if (code != null && code.equals(targetCode)) {
|
||||
if (checkIfIncludeOrg(code)) {
|
||||
result.add(vo);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import nc.bs.dao.BaseDAO;
|
|||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.vo.bd.currtype.CurrtypeVO;
|
||||
import nc.vo.bd.cust.CustomerVO;
|
||||
|
@ -29,6 +30,8 @@ import java.math.RoundingMode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl.checkIfIncludeOrg;
|
||||
|
||||
|
||||
/**
|
||||
* (품零)饋簡슥새데(BIP轟) 股箇逞MES
|
||||
|
@ -235,14 +238,9 @@ public class SalesDeliveryOrderRuleMES implements IRule<SaleOutVO> {
|
|||
private List<SaleOutVO> checkAndFilterBills(SaleOutVO[] saleOutVOS) {
|
||||
List<SaleOutVO> result = new ArrayList<>();
|
||||
for (SaleOutVO vo : saleOutVOS) {
|
||||
// 检查组织是否为电缆组织
|
||||
// if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) {
|
||||
// result.add(vo);
|
||||
// }
|
||||
try {
|
||||
String targetCode = "C034";
|
||||
String code = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, vo.getParentVO().getPk_org());
|
||||
if (code != null && code.equals(targetCode)) {
|
||||
if (checkIfIncludeOrg(code)) {
|
||||
result.add(vo);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import nc.bs.dao.BaseDAO;
|
|||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.impl.pubapp.pattern.rule.IRule;
|
||||
import nc.itf.arap.goldentax.SysParaInitQuery;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.vo.bd.cust.CustomerVO;
|
||||
import nc.vo.bd.material.MaterialVO;
|
||||
|
@ -28,6 +29,8 @@ import nccloud.pubift.commen.itf.utils.IHttpPostOtherSys;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl.checkIfIncludeOrg;
|
||||
|
||||
|
||||
/**
|
||||
* Å̵㣨ÉóÅúºó´«MES£©
|
||||
|
@ -77,14 +80,9 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<InvCountBillVO> {
|
|||
private List<InvCountBillVO> checkAndFilterBills(InvCountBillVO[] invCountBillVOS) {
|
||||
List<InvCountBillVO> result = new ArrayList<>();
|
||||
for (InvCountBillVO vo : invCountBillVOS) {
|
||||
// 检查组织是否为电缆组织
|
||||
// if (vo.getHead() != null && "0001A110000000000677".equals(vo.getHead().getPk_org())) {
|
||||
// result.add(vo);
|
||||
// }
|
||||
try {
|
||||
String targetCode = "C034";
|
||||
String code = transferCodeByPk(StockOrgVO.getDefaultTableName(), StockOrgVO.CODE, StockOrgVO.PK_STOCKORG, vo.getParentVO().getPk_org());
|
||||
if (code != null && code.equals(targetCode)) {
|
||||
if (checkIfIncludeOrg(code)) {
|
||||
result.add(vo);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
|
|
|
@ -128,6 +128,25 @@ public class HttpPostOtherSysImpl implements IHttpPostOtherSys {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前组织是否为电缆
|
||||
*/
|
||||
public static boolean checkIfIncludeOrg(String code) throws BusinessException {
|
||||
//当当前操作人员是BIP的时候 直接return 不走同步MES的业务逻辑
|
||||
String targetCode = SysParaInitQuery.getParaString("GLOBLE00000000000000", "INCLUDEORG");
|
||||
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
|
||||
throw new BusinessException("未配置组织参数,请前往 [业务参数设置-全局] 配置INCLUDEORG参数");
|
||||
}
|
||||
String[] orgItem = targetCode.split(";");
|
||||
for (String orgCode : orgItem) {
|
||||
if (!orgCode.isEmpty() && orgCode.equals(code)) {
|
||||
obmlog.debug("当前处理组织校验为电缆:" + code);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务请求post方法
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,8 @@ import nc.vo.pu.m21.entity.OrderHeaderVO;
|
|||
import nc.vo.pu.m21.entity.OrderItemVO;
|
||||
import nc.vo.pu.m21.entity.OrderVO;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.CircularlyAccessibleValueObject;
|
||||
import nc.vo.pub.ISuperVO;
|
||||
import nc.vo.pub.VOStatus;
|
||||
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
|
||||
|
@ -173,10 +175,8 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
|||
/**
|
||||
* 批量转换请购单到采购订单
|
||||
*/
|
||||
private void processBatchTransfer(PraybillVO[] vos, BgWorkingContext bgWorkingContext) throws BusinessException {
|
||||
private void processBatchTransfer(PraybillVO[] vos, BgWorkingContext bgWorkingContext) {
|
||||
logger.info("开始批量转换请购单到采购订单,请购单数量: " + vos.length, this.getClass(), "processBatchTransfer");
|
||||
|
||||
try {
|
||||
// 调用单据转换规则生成采购订单(20->21)
|
||||
OrderVO[] orderVOs = PfServiceScmUtil.exeVOChangeByBillItfDef("20", "21", vos);
|
||||
if (orderVOs == null || orderVOs.length == 0) {
|
||||
|
@ -196,26 +196,27 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
|||
}
|
||||
// 批量处理
|
||||
processBatch(vos, orderVOs);
|
||||
} catch (Exception e) {
|
||||
logger.error("批量转换请购单到采购订单失败", e, this.getClass(), "processBatchTransfer");
|
||||
}
|
||||
}
|
||||
|
||||
private void processBatch(PraybillVO[] vos, OrderVO[] orderVOs) {
|
||||
CloudPFlowContext cloudContext = this.getCloudPFlowContext(orderVOs);
|
||||
// 每次检查之前全部设置为成功
|
||||
Arrays.stream(vos).forEach(currentVO -> {
|
||||
PraybillHeaderVO hvo = currentVO.getHVO();
|
||||
hvo.setVdef30("success");
|
||||
hvo.setVdef31("N");
|
||||
hvo.setStatus(VOStatus.UPDATED);
|
||||
});
|
||||
if (orderVOs.length == 1) {
|
||||
PraybillVO singleVO = vos[0];
|
||||
PraybillHeaderVO singleHVO = singleVO.getHVO();
|
||||
SCMScriptResultDTO scriptResult = null;
|
||||
try {
|
||||
scriptResult = ((IBatchRunScriptService) NCLocator.getInstance().lookup(IBatchRunScriptService.class)).runBacth(cloudContext, OrderVO.class);
|
||||
if (scriptResult.getErrorMessageMap().isEmpty() && scriptResult.getSucessNum() > 0) {
|
||||
singleHVO.setStatus(VOStatus.UPDATED);
|
||||
}
|
||||
(NCLocator.getInstance().lookup(IBatchRunScriptService.class)).runBacth(cloudContext, OrderVO.class);
|
||||
} catch (Exception e) {
|
||||
// TODO 后面需要确定的字段
|
||||
singleHVO.setVdef30(e.getMessage().substring(0, 300));
|
||||
singleHVO.setVdef30(e.getMessage().substring(0, !e.getMessage().isEmpty() && e.getMessage().length() < 300 ? e.getMessage().length() : 300));
|
||||
singleHVO.setVdef31("N");
|
||||
singleHVO.setStatus(VOStatus.UPDATED);
|
||||
logger.error("单个处理时失败", e, this.getClass(), "processBatch");
|
||||
}
|
||||
updatePrayBillVOs(List.of(singleVO));
|
||||
|
@ -224,25 +225,24 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
|||
SCMScriptResultDTO scriptResult = ((IBatchRunScriptService) NCLocator.getInstance().lookup(IBatchRunScriptService.class)).runBacth(cloudContext, OrderVO.class);
|
||||
AbstractBill[] sucessVOs = scriptResult.getSucessVOs();
|
||||
// 要进行批量更新的数组
|
||||
List<PraybillVO> hvoList = new ArrayList<>(vos.length - sucessVOs.length);
|
||||
List<PraybillVO> failedHVOList = new ArrayList<>(vos.length - sucessVOs.length);
|
||||
Map<Integer, String> errorMessageMap = scriptResult.getErrorMessageMap();
|
||||
// 记录失败信息
|
||||
if (!errorMessageMap.isEmpty()) {
|
||||
errorMessageMap.keySet().forEach(key -> {
|
||||
String errMsg = errorMessageMap.get(key);
|
||||
if (errMsg.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String errMsg = errorMessageMap.get(key) == null ? "" : errorMessageMap.get(key);
|
||||
PraybillVO vo = vos[key];
|
||||
PraybillHeaderVO hvo = vo.getHVO();
|
||||
// TODO 后面需要确定的字段
|
||||
hvo.setVdef30(errMsg.substring(0, 300));
|
||||
hvo.setVdef30(errMsg.substring(0, Math.min(errMsg.length(), 300)));
|
||||
hvo.setVdef31("N");
|
||||
hvoList.add(vo);
|
||||
hvo.setStatus(VOStatus.UPDATED);
|
||||
failedHVOList.add(vo);
|
||||
logger.warn("单据转换生成采购订单时发生错误: " + scriptResult.getErrorMessage(), this.getClass(), "processBatchTransfer");
|
||||
});
|
||||
}
|
||||
// 进行批量更新 目的是为了记录信息
|
||||
updatePrayBillVOs(hvoList);
|
||||
if (!failedHVOList.isEmpty()) {
|
||||
updatePrayBillVOs(failedHVOList);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePrayBillVOs(List<PraybillVO> hvoList) {
|
||||
|
@ -259,7 +259,7 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
|||
logger.warn("批量更新请购单表头失败,需要更新的数组为0", this.getClass(), "processBatchTransfer");
|
||||
return;
|
||||
}
|
||||
String[] headupname = new String[]{"fbillstatus"};
|
||||
String[] headupname = new String[]{"vdef30", "vdef31"};
|
||||
VOUpdate<PraybillHeaderVO> headupsrv = new VOUpdate<>();
|
||||
headupsrv.update(hvoBatchUpdatedList, headupname);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.math.RoundingMode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static nccloud.pubift.commen.impl.utils.HttpPostOtherSysImpl.checkIfIncludeOrg;
|
||||
|
||||
/**
|
||||
* 销售订单审批后推送MES金思维系统
|
||||
*/
|
||||
|
@ -99,13 +101,11 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> {
|
|||
// 生成方式
|
||||
data.put("generation", "Z");
|
||||
// 客户编码(必填,最大长度8)
|
||||
String customerCode = transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE,
|
||||
CustomerVO.PK_CUSTOMER, head.getCcustomerid());
|
||||
String customerCode = transferCodeByPk(CustomerVO.getDefaultTableName(), CustomerVO.CODE, CustomerVO.PK_CUSTOMER, head.getCcustomerid());
|
||||
data.put("customId", customerCode);
|
||||
data.put("seller", transferCodeByPk(PsndocVO.getDefaultTableName(), PsndocVO.NAME, PsndocVO.PK_PSNDOC, head.getCemployeeid()));
|
||||
// 销售部门编码(必填,最大长度8)
|
||||
String deptCode = transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE,
|
||||
DeptVersionVO.PK_VID, head.getCdeptvid());
|
||||
String deptCode = transferCodeByPk(DeptVersionVO.getDefaultTableName(), DeptVersionVO.CODE, DeptVersionVO.PK_VID, head.getCdeptvid());
|
||||
data.put("departmentId", deptCode);
|
||||
// 联系人(非必填)
|
||||
data.put("contacts", null);
|
||||
|
@ -160,8 +160,7 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> {
|
|||
// 合同序号
|
||||
detailItem.put("contractNum", null);
|
||||
// 物料编码
|
||||
String materialCode = transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE,
|
||||
MaterialVO.PK_MATERIAL, body.getCmaterialvid());
|
||||
String materialCode = transferCodeByPk(MaterialVO.getDefaultTableName(), MaterialVO.CODE, MaterialVO.PK_MATERIAL, body.getCmaterialvid());
|
||||
detailItem.put("materialId", materialCode);
|
||||
// 计量单位
|
||||
detailItem.put("unit", transferCodeByPk(MeasdocVO.getDefaultTableName(), MeasdocVO.CODE, MeasdocVO.PK_MEASDOC, body.getCunitid()));
|
||||
|
@ -237,14 +236,9 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> {
|
|||
private List<SaleOrderVO> checkAndFilterBills(SaleOrderVO[] saleOutVOS) {
|
||||
List<SaleOrderVO> result = new ArrayList<>();
|
||||
for (SaleOrderVO vo : saleOutVOS) {
|
||||
// 检查组织是否为电缆组织
|
||||
// if (vo.getParentVO().getPk_org() != null && "0001A110000000000677".equals(vo.getParentVO().getPk_org())) {
|
||||
// result.add(vo);
|
||||
// }
|
||||
try {
|
||||
String targetCode = "C034";
|
||||
String code = transferCodeByPk(SalesOrgVO.getDefaultTableName(), SalesOrgVO.CODE, SalesOrgVO.PK_SALESORG, vo.getParentVO().getPk_org());
|
||||
if (code != null && code.equals(targetCode)) {
|
||||
if (checkIfIncludeOrg(code)) {
|
||||
result.add(vo);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
|
|
Loading…
Reference in New Issue