修复请购单转采购订单功能
- 修改了 AfterApprovingSynchronizeRuleMES 中的产品编号字段 - 优化了 BatchTransferToPurchaseOrder 中的错误处理和批量更新逻辑 -调整了订单状态设置和错误信息记录的方式
This commit is contained in:
parent
dd2003a1e2
commit
cd417c2c5f
|
@ -1,6 +1,7 @@
|
||||||
package nc.bs.pu.m21.plugin;
|
package nc.bs.pu.m21.plugin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import nc.bs.framework.common.NCLocator;
|
import nc.bs.framework.common.NCLocator;
|
||||||
import nc.bs.logging.Log;
|
import nc.bs.logging.Log;
|
||||||
|
@ -11,6 +12,7 @@ import nc.bs.pub.taskcenter.BgWorkingContext;
|
||||||
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
|
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
|
||||||
import nc.bs.pubapp.AppBsContext;
|
import nc.bs.pubapp.AppBsContext;
|
||||||
import nc.impl.pubapp.pattern.data.vo.VOQuery;
|
import nc.impl.pubapp.pattern.data.vo.VOQuery;
|
||||||
|
import nc.impl.pubapp.pattern.data.vo.VOUpdate;
|
||||||
import nc.impl.pubapp.pattern.page.db.IDDBPage;
|
import nc.impl.pubapp.pattern.page.db.IDDBPage;
|
||||||
import nc.itf.uap.pf.IPfExchangeService;
|
import nc.itf.uap.pf.IPfExchangeService;
|
||||||
import nc.util.mmf.framework.base.MMArrayUtil;
|
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||||
|
@ -26,6 +28,7 @@ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
||||||
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
|
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
|
||||||
import nc.vo.scmpub.res.billtype.POBillType;
|
import nc.vo.scmpub.res.billtype.POBillType;
|
||||||
import nc.vo.scmpub.util.AppInfoContext;
|
import nc.vo.scmpub.util.AppInfoContext;
|
||||||
|
import nccloud.commons.lang.ArrayUtils;
|
||||||
import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO;
|
import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO;
|
||||||
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
|
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
|
||||||
import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService;
|
import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService;
|
||||||
|
@ -42,7 +45,7 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
||||||
// 1. 查询满足条件的请购单聚合VO
|
// 1. 查询满足条件的请购单聚合VO
|
||||||
PraybillVO[] purchaseRequestVOs = getQualifiedPurchaseRequests(bgWorkingContext);
|
PraybillVO[] purchaseRequestVOs = getQualifiedPurchaseRequests(bgWorkingContext);
|
||||||
logger.info("查询到满足条件的请购单数量: " + purchaseRequestVOs.length, this.getClass(), "executeTask");
|
logger.info("查询到满足条件的请购单数量: " + purchaseRequestVOs.length, this.getClass(), "executeTask");
|
||||||
if (purchaseRequestVOs.length <= 0) {
|
if (purchaseRequestVOs.length == 0) {
|
||||||
logger.info("未找到满足条件的请购单,任务结束", this.getClass(), "executeTask");
|
logger.info("未找到满足条件的请购单,任务结束", this.getClass(), "executeTask");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -186,35 +189,52 @@ public class BatchTransferToPurchaseOrder implements IBackgroundWorkPlugin {
|
||||||
for (OrderVO orderVO : orderVOs) {
|
for (OrderVO orderVO : orderVOs) {
|
||||||
// 对采购订单赋值行号
|
// 对采购订单赋值行号
|
||||||
OrderHeaderVO hvo = orderVO.getHVO();
|
OrderHeaderVO hvo = orderVO.getHVO();
|
||||||
|
hvo.setStatus(2);
|
||||||
OrderItemVO[] bvo = orderVO.getBVO();
|
OrderItemVO[] bvo = orderVO.getBVO();
|
||||||
for (int j = 0; j < bvo.length; j++) {
|
for (int j = 0; j < bvo.length; j++) {
|
||||||
int rowNum = (j + 1) * 10;
|
int rowNum = (j + 1) * 10;
|
||||||
// 设置pk_order
|
bvo[j].setStatus(2);
|
||||||
bvo[j].setPk_order(hvo.getPk_order());
|
|
||||||
bvo[j].setCrowno(String.valueOf(rowNum));
|
bvo[j].setCrowno(String.valueOf(rowNum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloudPFlowContext cloudContext = this.getCloudPFlowContext(orderVOs);
|
CloudPFlowContext cloudContext = this.getCloudPFlowContext(orderVOs);
|
||||||
AppInfoContext.setBtnCode("Save");
|
|
||||||
SCMScriptResultDTO scriptResult = ((IBatchRunScriptService) NCLocator.getInstance().lookup(IBatchRunScriptService.class)).runBacth(cloudContext, OrderVO.class);
|
SCMScriptResultDTO scriptResult = ((IBatchRunScriptService) NCLocator.getInstance().lookup(IBatchRunScriptService.class)).runBacth(cloudContext, OrderVO.class);
|
||||||
AbstractBill[] sucessVOs = scriptResult.getSucessVOs();
|
AbstractBill[] sucessVOs = scriptResult.getSucessVOs();
|
||||||
// TODO sucessVOs 获取成功保存的采购订单 但是无法保存 无法获取 暂时无法测试
|
// 要进行批量更新的数组
|
||||||
|
List<PraybillVO> hvoList = new ArrayList<>(vos.length - sucessVOs.length);
|
||||||
Map<Integer, String> errorMessageMap = scriptResult.getErrorMessageMap();
|
Map<Integer, String> errorMessageMap = scriptResult.getErrorMessageMap();
|
||||||
if (!errorMessageMap.isEmpty()) {
|
if (!errorMessageMap.isEmpty()) {
|
||||||
errorMessageMap.keySet().forEach(key -> {
|
errorMessageMap.keySet().forEach(key -> {
|
||||||
String errMsg = errorMessageMap.get(key);
|
String errMsg = errorMessageMap.get(key);
|
||||||
if (errMsg.isEmpty()) return;
|
if (errMsg.isEmpty()) {
|
||||||
// TODO 此处逻辑有问题 采购订单转换 不成功的需要和错误信息一一对应后 才能设置错误信息
|
return;
|
||||||
OrderVO orderVO = orderVOs[key];
|
}
|
||||||
// 给单据设置错误信息
|
PraybillVO vo = vos[key];
|
||||||
orderVO.getHVO().setVdef30(errMsg);
|
// TODO 后面需要把确定的字段长度扩充一下 errMsg也需要截取一下
|
||||||
orderVO.getHVO().setVdef31("N");
|
vo.getHVO().setVdef30(errMsg);
|
||||||
|
vo.getHVO().setVdef31("N");
|
||||||
|
hvoList.add(vo);
|
||||||
logger.warn("单据转换生成采购订单时发生错误: " + scriptResult.getErrorMessage(), this.getClass(), "processBatchTransfer");
|
logger.warn("单据转换生成采购订单时发生错误: " + scriptResult.getErrorMessage(), this.getClass(), "processBatchTransfer");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 进行批量更新
|
||||||
|
PraybillHeaderVO[] hvoBatchUpdatedList = {};
|
||||||
|
if (hvoList.isEmpty()) {
|
||||||
|
logger.warn("批量更新请购单表头失败,获取表头数组长度为0", this.getClass(), "processBatchTransfer");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (PraybillVO hvo : hvoList) {
|
||||||
|
hvoBatchUpdatedList = ArrayUtils.add(hvoBatchUpdatedList, hvo.getHVO());
|
||||||
|
logger.info("循环更新请购单表头: " + hvo.getHVO().getPk_praybill(), this.getClass(), "processBatchTransfer");
|
||||||
|
}
|
||||||
|
if (hvoBatchUpdatedList.length == 0) {
|
||||||
|
logger.warn("批量更新请购单表头失败,需要更新的数组为0", this.getClass(), "processBatchTransfer");
|
||||||
|
}
|
||||||
|
String[] headupname = new String[]{"fbillstatus"};
|
||||||
|
VOUpdate<PraybillHeaderVO> headupsrv = new VOUpdate<>();
|
||||||
|
headupsrv.update(hvoBatchUpdatedList, headupname);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("批量转换请购单到采购订单失败", e, this.getClass(), "processBatchTransfer");
|
logger.error("批量转换请购单到采购订单失败", e, this.getClass(), "processBatchTransfer");
|
||||||
ExceptionUtils.marsh(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class AfterApprovingSynchronizeRuleMES implements IRule<SaleOrderVO> {
|
||||||
if (bodys != null) {
|
if (bodys != null) {
|
||||||
for (SaleOrderBVO body : bodys) {
|
for (SaleOrderBVO body : bodys) {
|
||||||
JSONObject detailItem = new JSONObject();
|
JSONObject detailItem = new JSONObject();
|
||||||
detailItem.put("productNum", head.getVbillcode());
|
detailItem.put("productNum", head.getVdef6());
|
||||||
// 以下字段需要表体的字段
|
// 以下字段需要表体的字段
|
||||||
// 需求日期 表体dreceivedate
|
// 需求日期 表体dreceivedate
|
||||||
UFDate dreceivedate = body.getDreceivedate();
|
UFDate dreceivedate = body.getDreceivedate();
|
||||||
|
|
Loading…
Reference in New Issue