采购入库保存接口-调用费用领料逻辑+wms代码同步

This commit is contained in:
mzr 2025-11-01 20:11:42 +08:00
parent 075a6948ff
commit 91da40edf2
2 changed files with 149 additions and 114 deletions

View File

@ -51,8 +51,6 @@ public class InsertBP implements IInsertBP<PurchaseInVO>,
processor.addAfterRule(new InsertOrSignRewritePayPlanInvoiceRule(IPaymentUtil.STORE_RECEIPT_DATE)); processor.addAfterRule(new InsertOrSignRewritePayPlanInvoiceRule(IPaymentUtil.STORE_RECEIPT_DATE));
// 흙욋데괏닸쀼畇꽃뭔북谿마운셕뺍 // 흙욋데괏닸쀼畇꽃뭔북谿마운셕뺍
processor.addAfterRule(new M45SaveAndRewriteCTPayPlan()); processor.addAfterRule(new M45SaveAndRewriteCTPayPlan());
// žŤĂÜÖýÔě-ÁěÁĎ
processor.addAfterRule(new ManualMaterialPickupRule());
// processor.addAfterRule(new InsertRewritePORule()); // processor.addAfterRule(new InsertRewritePORule());
} }

View File

@ -1,21 +1,16 @@
package nccloud.api.impl.ic.m45; package nccloud.api.impl.ic.m45;
import java.util.ArrayList; import nc.bs.framework.common.InvocationInfoProxy;
import java.util.HashMap; import nc.bs.framework.common.NCLocator;
import java.util.HashSet; import nc.bs.framework.server.ISecurityTokenCallback;
import java.util.List; import nc.bs.ic.m45.insert.rule.ManualMaterialPickupRule;
import java.util.Map;
import java.util.Set;
import nc.impl.pubapp.pattern.data.vo.VOQuery;
import nc.vo.ic.org.OrgInfoQuery;
import nc.vo.pu.m23.entity.ArriveHeaderVO;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import nc.bs.scmpub.query.SCMBillQuery; import nc.bs.scmpub.query.SCMBillQuery;
import nc.impl.pubapp.pattern.data.vo.VOQuery;
import nc.itf.ic.m45.self.IPurchaseInMaintain;
import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil; import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil;
import nc.pubimpl.ic.api.maintain.BillMaintainTool; import nc.pubimpl.ic.api.maintain.BillMaintainTool;
import nc.pubimpl.ic.api.maintain.BillManuInsertTool;
import nc.vo.bc.pub.util.SysParaInitQuery;
import nc.vo.ic.general.define.ICBillFlag; import nc.vo.ic.general.define.ICBillFlag;
import nc.vo.ic.general.define.ICBillHeadVO; import nc.vo.ic.general.define.ICBillHeadVO;
import nc.vo.ic.general.util.ICLocationUtil; import nc.vo.ic.general.util.ICLocationUtil;
@ -23,9 +18,13 @@ import nc.vo.ic.location.ICLocationVO;
import nc.vo.ic.m45.entity.PurchaseInBodyVO; import nc.vo.ic.m45.entity.PurchaseInBodyVO;
import nc.vo.ic.m45.entity.PurchaseInHeadVO; import nc.vo.ic.m45.entity.PurchaseInHeadVO;
import nc.vo.ic.m45.entity.PurchaseInVO; import nc.vo.ic.m45.entity.PurchaseInVO;
import nc.vo.ic.org.OrgInfoQuery;
import nc.vo.ic.pub.define.ICPubMetaNameConst; import nc.vo.ic.pub.define.ICPubMetaNameConst;
import nc.vo.pu.m23.entity.ArriveHeaderVO;
import nc.vo.pub.BusinessException; import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus; import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pubapp.pattern.data.ValueUtils;
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule; import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
import nc.vo.scmpub.res.billtype.ICBillType; import nc.vo.scmpub.res.billtype.ICBillType;
import nccloud.api.ic.m45.IAPIPurchaseInMaitain; import nccloud.api.ic.m45.IAPIPurchaseInMaitain;
@ -33,9 +32,14 @@ import nccloud.api.impl.ic.m45.check.CheckPurchaseInSaveValidator;
import nccloud.api.impl.ic.m45.fill.PurchaseInSaveFillValue; import nccloud.api.impl.ic.m45.fill.PurchaseInSaveFillValue;
import nccloud.api.impl.ic.m45.fill.PurchaseInUpdateFillValue; import nccloud.api.impl.ic.m45.fill.PurchaseInUpdateFillValue;
import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields; import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields;
import nccloud.api.uapbd.wms.utils.IWmsSyncUtils;
import nccloud.openapi.ic.util.ICAPILocationVOUtils; import nccloud.openapi.ic.util.ICAPILocationVOUtils;
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool; import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
import nccloud.openapi.scmpub.pub.TransferMapToVOTool; import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
/** /**
* @version NCC1909 * @version NCC1909
@ -46,18 +50,18 @@ import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain { public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
@Override @Override
public PurchaseInVO[] save(List<Map<String, Object>> paramList) public PurchaseInVO[] save(List<Map<String, Object>> paramList) throws BusinessException {
throws BusinessException {
// MapList转聚合VOList // MapList转聚合VOList
List<PurchaseInVO> aggVOList = List<PurchaseInVO> aggVOList = TransferMapToVOTool.transferMapToAggVO(paramList, PurchaseInVO.class);
TransferMapToVOTool.transferMapToAggVO(paramList, PurchaseInVO.class); //检查是否满足wms组织条件
UFBoolean isWmsOrg = checkWmsOrg(aggVOList);
String creatorCode = aggVOList.get(0).getHead().getCreator();
PurchaseInVO[] vos = aggVOList.toArray(new PurchaseInVO[aggVOList.size()]); PurchaseInVO[] vos = aggVOList.toArray(new PurchaseInVO[aggVOList.size()]);
// 设置货位序列号VO // 设置货位序列号VO
ICAPILocationVOUtils.setLocationVO(ICBillType.PurchaseIn.getCode(), vos); ICAPILocationVOUtils.setLocationVO(ICBillType.PurchaseIn.getCode(), vos);
// 1传入数据基本非空校验 // 1传入数据基本非空校验
BillVOsCheckRule checker = BillVOsCheckRule checker = new BillVOsCheckRule(new CheckPurchaseInSaveValidator());
new BillVOsCheckRule(new CheckPurchaseInSaveValidator()); // 2025年4月23日15点10分 采购入库单接口项目字段为波浪则清空 sdlizheng --start
//2025年4月23日15点10分 采购入库单接口项目字段为波浪则清空 sdlizheng --start
for (PurchaseInVO vo : vos) { for (PurchaseInVO vo : vos) {
PurchaseInBodyVO[] bodys = vo.getBodys(); PurchaseInBodyVO[] bodys = vo.getBodys();
if (bodys != null && bodys.length > 0) { if (bodys != null && bodys.length > 0) {
@ -72,16 +76,27 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
} }
} }
//2025年4月23日15点10分 采购入库单接口项目字段为波浪则清空 sdlizheng --end // 2025年4月23日15点10分 采购入库单接口项目字段为波浪则清空 sdlizheng --end
//添加供应商和交易类型为空赋值 // 添加供应商和交易类型为空赋值
fillHeadDataBeforeCheck(vos); fillHeadDataBeforeCheck(vos);
checker.check(vos); checker.check(vos);
// 2编码翻译成pk // 2编码翻译成pk
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList); aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
if (aggVOList == null || aggVOList.size() < 1) {
throw new BusinessException("翻译采购入库对象失败,检查数据格式");
}
String creatorPK = aggVOList.get(0).getHead().getCreator();
if (isWmsOrg.booleanValue()) {
if (!nc.vo.cmp.util.StringUtils.isEmpty(creatorCode)) {
InvocationInfoProxy.getInstance().setUserCode(creatorCode);
InvocationInfoProxy.getInstance().setUserId(creatorPK);
NCLocator.getInstance().lookup(ISecurityTokenCallback.class).token("NCSystem".getBytes(), "pfxx".getBytes());
}
}
// 翻译货位 // 翻译货位
ICAPILocationVOUtils.translate(vos); ICAPILocationVOUtils.translate(vos);
//begin没取到财务组织导致的报错在这里给财务组织赋值为库存组织 // begin没取到财务组织导致的报错在这里给财务组织赋值为库存组织
for (PurchaseInVO vo : vos) { for (PurchaseInVO vo : vos) {
if (vo.getHead().getCfanaceorgoid() != null) { if (vo.getHead().getCfanaceorgoid() != null) {
continue; continue;
@ -91,30 +106,60 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
vo.getHead().setCfanaceorgoid(cfinanceoid); vo.getHead().setCfanaceorgoid(cfinanceoid);
vo.getHead().setCfanaceorgvid(cfinancevid); vo.getHead().setCfanaceorgvid(cfinancevid);
} }
//end // end
// 3其他数据填充 // 3其他数据填充
new PurchaseInSaveFillValue().setDefaultValue(vos); new PurchaseInSaveFillValue().setDefaultValue(vos);
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>( BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>(PurchaseInVO.class,
PurchaseInVO.class, ICBillType.PurchaseIn.getCode()); ICBillType.PurchaseIn.getCode());
return tool.insert(vos); PurchaseInVO[] insert = tool.insert(vos);
IWmsSyncUtils wmsSyncUtils = NCLocator.getInstance().lookup(IWmsSyncUtils.class);
if (wmsSyncUtils.isWMS()) {
return this.signOnWMS(insert);
}
ManualMaterialPickupRule rule = new ManualMaterialPickupRule();
rule.process(insert);
return insert;
}
private UFBoolean checkWmsOrg(List<PurchaseInVO> paramList) throws BusinessException {
if (paramList == null || paramList.size() < 1) {
throw new BusinessException("转换采购入库对象失败,检查报文结构及数据格式");
}
String targetCode = SysParaInitQuery.getParaString("GLOBLE00000000000000", "WMSORG");
if (targetCode == null || StringUtils.isEmpty(targetCode)) {
throw new BusinessException("未配置组织参数,请前往 [业务参数设置-全局] 配置WMSORG 参数");
}
String[] orgItem = targetCode.split(";");
if (orgItem == null || orgItem.length < 1) {
throw new BusinessException("WMSORG全局参数解析失败请检查");
}
//使用Stream将orgItem转成list
List<String> orgList = Arrays.asList(orgItem);
String pkOrg = paramList.get(0).getHead().getPk_org();
if (orgList.contains(pkOrg)) {
return UFBoolean.TRUE;
} else {
return UFBoolean.FALSE;
}
} }
private void fillHeadDataBeforeCheck(PurchaseInVO[] vos) { private void fillHeadDataBeforeCheck(PurchaseInVO[] vos) {
for (PurchaseInVO vo : vos) { for (PurchaseInVO vo : vos) {
if (StringUtils.isEmpty(vo.getHead().getVtrantypecode())) { if (StringUtils.isEmpty(vo.getHead().getVtrantypecode())) {
//设置默认交易类型 // 设置默认交易类型
vo.getHead().setVtrantypecode("45-01"); vo.getHead().setVtrantypecode("45-01");
} }
if (StringUtils.isEmpty(vo.getHead().getCvendorid())) { if (StringUtils.isEmpty(vo.getHead().getCvendorid())) {
//根据上游获取数据 // 根据上游获取数据
PurchaseInBodyVO[] bodys = vo.getBodys(); PurchaseInBodyVO[] bodys = vo.getBodys();
String csourcetype = bodys[0].getCsourcetype(); String csourcetype = bodys[0].getCsourcetype();
String csourcebillhid = bodys[0].getCsourcebillhid(); String csourcebillhid = bodys[0].getCsourcebillhid();
if ("23".equals(csourcetype) && StringUtils.isNotEmpty(csourcebillhid)) { if ("23".equals(csourcetype) && StringUtils.isNotEmpty(csourcebillhid)) {
//上游到货单 // 上游到货单
ArriveHeaderVO[] srcHVOs = new VOQuery<>(ArriveHeaderVO.class).query(new String[]{csourcebillhid}); ArriveHeaderVO[] srcHVOs = new VOQuery<>(ArriveHeaderVO.class)
.query(new String[]{csourcebillhid});
if (ArrayUtils.isNotEmpty(srcHVOs)) { if (ArrayUtils.isNotEmpty(srcHVOs)) {
vo.getHead().setCvendorid(srcHVOs[0].getPk_supplier()); vo.getHead().setCvendorid(srcHVOs[0].getPk_supplier());
} }
@ -124,11 +169,9 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
} }
@Override @Override
public PurchaseInVO[] update(List<Map<String, Object>> paramList) public PurchaseInVO[] update(List<Map<String, Object>> paramList) throws BusinessException {
throws BusinessException {
// MapList转聚合VOList // MapList转聚合VOList
List<PurchaseInVO> aggVOList = List<PurchaseInVO> aggVOList = TransferMapToVOTool.transferMapToAggVO(paramList, PurchaseInVO.class);
TransferMapToVOTool.transferMapToAggVO(paramList, PurchaseInVO.class);
PurchaseInVO[] vos = aggVOList.toArray(new PurchaseInVO[aggVOList.size()]); PurchaseInVO[] vos = aggVOList.toArray(new PurchaseInVO[aggVOList.size()]);
// 2编码翻译成pk // 2编码翻译成pk
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList); aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
@ -136,53 +179,41 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
PurchaseInHeadVO newVO = vos[0].getHead(); PurchaseInHeadVO newVO = vos[0].getHead();
String cgeneralhid = newVO.getCgeneralhid(); String cgeneralhid = newVO.getCgeneralhid();
if (StringUtils.isEmpty(cgeneralhid)) { if (StringUtils.isEmpty(cgeneralhid)) {
throw new BusinessException( throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0380")/* @res "修改采购入库单请指定表头主键cgeneralhid值。" */);
"04008027-0380")/* @res "修改采购入库单请指定表头主键cgeneralhid值。" */);
} }
SCMBillQuery<PurchaseInVO> queryTool = SCMBillQuery<PurchaseInVO> queryTool = new SCMBillQuery<PurchaseInVO>(PurchaseInVO.class);
new SCMBillQuery<PurchaseInVO>(PurchaseInVO.class); PurchaseInVO[] purInVOs = queryTool.queryVOByIDs(new String[]{cgeneralhid});
PurchaseInVO[] purInVOs = queryTool.queryVOByIDs(new String[]{ Map<String, ICLocationVO[]> deleteLoc = new HashMap<String, ICLocationVO[]>();
cgeneralhid
});
Map<String, ICLocationVO[]> deleteLoc =
new HashMap<String, ICLocationVO[]>();
// 加载原始单据和货位信息 // 加载原始单据和货位信息
PurchaseInVO[] originBills = queryTool.queryVOByIDs(new String[]{ PurchaseInVO[] originBills = queryTool.queryVOByIDs(new String[]{cgeneralhid});
cgeneralhid
});
ICLocationUtil.loadLocationVOs(originBills); ICLocationUtil.loadLocationVOs(originBills);
if (ArrayUtils.isEmpty(purInVOs)) { if (ArrayUtils.isEmpty(purInVOs)) {
throw new BusinessException( throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0381")/* @res "没找到要修改的入库单信息请检查数据的表头主键cgeneralhid。" */);
"04008027-0381")/* @res "没找到要修改的入库单信息请检查数据的表头主键cgeneralhid。" */);
} else { } else {
List<String> headProFields = List<String> headProFields = CheckProhibitUpdateFields.getHeadProhibitFields("45");
CheckProhibitUpdateFields.getHeadProhibitFields("45"); List<String> bodyProFields = CheckProhibitUpdateFields.getBodyProhibitFields("45");
List<String> bodyProFields =
CheckProhibitUpdateFields.getBodyProhibitFields("45");
PurchaseInHeadVO origVO = purInVOs[0].getHead(); PurchaseInHeadVO origVO = purInVOs[0].getHead();
if (origVO.getFbillflag() == null if (origVO.getFbillflag() == null
|| 0 != ((Integer) ICBillFlag.FREE.value()) || 0 != ((Integer) ICBillFlag.FREE.value()).compareTo((Integer) origVO.getFbillflag())) {
.compareTo((Integer) origVO.getFbillflag())) {
throw new BusinessException( throw new BusinessException(
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0329")
"04008027-0329")/* @res "当前入库单编号:" */ + origVO.getVbillcode() /* @res "当前入库单编号:" */ + origVO.getVbillcode()
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
"4008027_0", "04008027-0362")/* @res "不是自由状态,不能修改" */); "04008027-0362")/* @res "不是自由状态,不能修改" */);
} }
origVO.setStatus(VOStatus.UPDATED); origVO.setStatus(VOStatus.UPDATED);
for (String attr : newVO.getAttributeNames()) { for (String attr : newVO.getAttributeNames()) {
if (newVO.getAttributeValue(attr) == null) { if (newVO.getAttributeValue(attr) == null) {
continue; continue;
} }
if (headProFields.contains(attr) && !newVO.getAttributeValue(attr) if (headProFields.contains(attr)
.equals(origVO.getAttributeValue(attr))) { && !newVO.getAttributeValue(attr).equals(origVO.getAttributeValue(attr))) {
throw new BusinessException( throw new BusinessException(
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0363")
"4008027_0", "04008027-0363")/* @res "表头字段:" */ + attr /* @res "表头字段:" */ + attr + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( .getStrByID("4008027_0", "04008027-0364")/* @res "不允许修改。" */);
"4008027_0", "04008027-0364")/* @res "不允许修改。" */);
} }
origVO.setAttributeValue(attr, newVO.getAttributeValue(attr)); origVO.setAttributeValue(attr, newVO.getAttributeValue(attr));
} }
@ -196,8 +227,7 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
} }
} }
if (vos[0].getBodys() != null) { if (vos[0].getBodys() != null) {
Map<String, PurchaseInBodyVO> pkbs = Map<String, PurchaseInBodyVO> pkbs = new HashMap<String, PurchaseInBodyVO>();
new HashMap<String, PurchaseInBodyVO>();
for (PurchaseInBodyVO origBvo : purInVOs[0].getBodys()) { for (PurchaseInBodyVO origBvo : purInVOs[0].getBodys()) {
origBvo.setStatus(VOStatus.UPDATED); origBvo.setStatus(VOStatus.UPDATED);
pkbs.put(origBvo.getCgeneralbid(), origBvo); pkbs.put(origBvo.getCgeneralbid(), origBvo);
@ -205,10 +235,9 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
for (PurchaseInBodyVO newBvo : vos[0].getBodys()) { for (PurchaseInBodyVO newBvo : vos[0].getBodys()) {
PurchaseInBodyVO roigBvo = pkbs.get(newBvo.getCgeneralbid()); PurchaseInBodyVO roigBvo = pkbs.get(newBvo.getCgeneralbid());
if (newBvo.getCgeneralbid() == null || roigBvo == null) { if (newBvo.getCgeneralbid() == null || roigBvo == null) {
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
.getNCLangRes().getStrByID("4008027_0", "04008027-0382")/* "04008027-0382")/*
* @res * @res "没有匹配到原始入库单表体信息请检查数据的表体主键cgeneralbid。"
* "没有匹配到原始入库单表体信息请检查数据的表体主键cgeneralbid。"
*/); */);
} }
for (String battr : newBvo.getAttributeNames()) { for (String battr : newBvo.getAttributeNames()) {
@ -216,18 +245,16 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
continue; continue;
} }
if (bodyProFields.contains(battr) if (bodyProFields.contains(battr)
&& !newBvo.getAttributeValue(battr) && !newBvo.getAttributeValue(battr).equals(roigBvo.getAttributeValue(battr))) {
.equals(roigBvo.getAttributeValue(battr))) {
throw new BusinessException( throw new BusinessException(
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0366")
"4008027_0", "04008027-0366")/* @res "表体字段:" */ + battr /* @res "表体字段:" */ + battr + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( .getStrByID("4008027_0", "04008027-0364")/* @res "不允许修改。" */);
"4008027_0", "04008027-0364")/* @res "不允许修改。" */);
} }
roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr)); roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr));
bfields.add(battr); bfields.add(battr);
} }
//设置货位序列号孙表,把原来的孙表删除修改的货位置为新增 // 设置货位序列号孙表,把原来的孙表删除修改的货位置为新增
if (null != newBvo.getLocationVOs()) { if (null != newBvo.getLocationVOs()) {
List<ICLocationVO> allloc = new ArrayList<ICLocationVO>(); List<ICLocationVO> allloc = new ArrayList<ICLocationVO>();
if (null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) { if (null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) {
@ -250,18 +277,27 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
ICAPILocationVOUtils.translate(purInVOs); ICAPILocationVOUtils.translate(purInVOs);
// 其他数据填充 // 其他数据填充
new PurchaseInUpdateFillValue().setDefaultValue(purInVOs); new PurchaseInUpdateFillValue().setDefaultValue(purInVOs);
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>( // 如果是退回则直接调用新增自制补值
PurchaseInVO.class, ICBillType.PurchaseIn.getCode()); if (ValueUtils.getBoolean(purInVOs[0].getHead().getFreplenishflag())) {
tool.doBeforeInsert(purInVOs); BillManuInsertTool<PurchaseInVO> tool = new BillManuInsertTool<PurchaseInVO>();
return nc.bs.framework.common.NCLocator.getInstance() tool.doBeforeInsert(purInVOs, ICBillType.PurchaseIn.getCode());
.lookup(nc.itf.ic.m45.self.IPurchaseInMaintain.class) } else {
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>(PurchaseInVO.class,
ICBillType.PurchaseIn.getCode());
tool.doBeforeInsert(purInVOs);
}
PurchaseInVO[] updateVO = NCLocator.getInstance().lookup(IPurchaseInMaintain.class)
.update(purInVOs, originBills); .update(purInVOs, originBills);
IWmsSyncUtils wmsSyncUtils = NCLocator.getInstance().lookup(IWmsSyncUtils.class);
if (wmsSyncUtils.isWMS()) {
return this.signOnWMS(updateVO);
}
return updateVO;
} }
@Override @Override
public void delete(PurchaseInVO[] vos) throws BusinessException { public void delete(PurchaseInVO[] vos) throws BusinessException {
nc.bs.framework.common.NCLocator.getInstance() nc.bs.framework.common.NCLocator.getInstance().lookup(nc.itf.ic.m45.self.IPurchaseInMaintain.class).delete(vos);
.lookup(nc.itf.ic.m45.self.IPurchaseInMaintain.class).delete(vos);
} }
@ -273,30 +309,27 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
for (PurchaseInVO aggvo : vos) { for (PurchaseInVO aggvo : vos) {
ICBillHeadVO parentVO = aggvo.getParentVO(); ICBillHeadVO parentVO = aggvo.getParentVO();
if (parentVO.getFbillflag() == null if (parentVO.getFbillflag() == null
|| 0 != ((Integer) ICBillFlag.FREE.value()) || 0 != ((Integer) ICBillFlag.FREE.value()).compareTo((Integer) parentVO.getFbillflag())) {
.compareTo((Integer) parentVO.getFbillflag())) { throw new BusinessException(
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0329")
.getStrByID("4008027_0", "04008027-0329") /* @res "当前入库单编号:" */ + parentVO.getVbillcode()
/* @res "当前入库单编号:" */ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( "04008027-0330")/* @res "不是自由状态,不能签字" */);
"4008027_0", "04008027-0330")/* @res "不是自由状态,不能签字" */);
} }
if (aggvo.getChildrenVO() != null && aggvo.getChildrenVO().length > 0) { if (aggvo.getChildrenVO() != null && aggvo.getChildrenVO().length > 0) {
if (aggvo.getChildrenVO()[0] if (aggvo.getChildrenVO()[0].getAttributeValue(ICPubMetaNameConst.NNUM) == null) {
.getAttributeValue(ICPubMetaNameConst.NNUM) == null) { throw new BusinessException(
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0329")
.getNCLangRes().getStrByID("4008027_0", "04008027-0329") /* @res "当前入库单编号:" */ + parentVO.getVbillcode()
/* @res "当前入库单编号:" */ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( "04008027-0331")/* @res "主数量为空,不能签字" */);
"4008027_0", "04008027-0331")/* @res "主数量为空,不能签字" */);
} }
} }
} }
// 加载货位单品明细 // 加载货位单品明细
ICLocationUtil.loadLocationVOs(vos); ICLocationUtil.loadLocationVOs(vos);
return (PurchaseInVO[]) PfServiceScmUtil.processBatch("SIGN", "45", vos, return (PurchaseInVO[]) PfServiceScmUtil.processBatch("SIGN", "45", vos, null, null);
null, null);
} }
@Override @Override
@ -307,17 +340,21 @@ public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
for (PurchaseInVO aggvo : vos) { for (PurchaseInVO aggvo : vos) {
ICBillHeadVO parentVO = aggvo.getParentVO(); ICBillHeadVO parentVO = aggvo.getParentVO();
if (parentVO.getFbillflag() == null if (parentVO.getFbillflag() == null
|| 0 != ((Integer) ICBillFlag.SIGN.value()) || 0 != ((Integer) ICBillFlag.SIGN.value()).compareTo((Integer) parentVO.getFbillflag())) {
.compareTo((Integer) parentVO.getFbillflag())) { throw new BusinessException(
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0329")
.getStrByID("4008027_0", "04008027-0329") /* @res "当前入库单编号:" */ + parentVO.getVbillcode()
/* @res "当前入库单编号:" */ + parentVO.getVbillcode() + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID( "04008027-0332")/* @res "不是签字状态,不能取消签字" */);
"4008027_0", "04008027-0332")/* @res "不是签字状态,不能取消签字" */);
} }
} }
return (PurchaseInVO[]) PfServiceScmUtil.processBatch("CANCELSIGN", "45", return (PurchaseInVO[]) PfServiceScmUtil.processBatch("CANCELSIGN", "45", vos, null, null);
vos, null, null); }
private PurchaseInVO[] signOnWMS(PurchaseInVO[] updateVO) throws BusinessException {
List<PurchaseInVO> purchaseInVOList = new ArrayList<>();
Arrays.stream(updateVO).filter(vo -> vo.getHead().getFbillflag() == 2).forEach(purchaseInVOList::add);
return NCLocator.getInstance().lookup(IAPIPurchaseInMaitain.class).sign(purchaseInVOList.toArray(new PurchaseInVO[]{}));
} }
} }