ic_采购入库新增接口转换结算财务组织并修改序列号翻译强控
This commit is contained in:
parent
e689e35df5
commit
2746f49940
|
@ -0,0 +1,284 @@
|
||||||
|
package nccloud.api.impl.ic.m45;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import nc.vo.ic.org.OrgInfoQuery;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import nc.bs.scmpub.query.SCMBillQuery;
|
||||||
|
import nc.itf.scmpub.reference.uap.pf.PfServiceScmUtil;
|
||||||
|
import nc.pubimpl.ic.api.maintain.BillMaintainTool;
|
||||||
|
import nc.vo.ic.general.define.ICBillFlag;
|
||||||
|
import nc.vo.ic.general.define.ICBillHeadVO;
|
||||||
|
import nc.vo.ic.general.util.ICLocationUtil;
|
||||||
|
import nc.vo.ic.location.ICLocationVO;
|
||||||
|
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
|
||||||
|
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
|
||||||
|
import nc.vo.ic.m45.entity.PurchaseInVO;
|
||||||
|
import nc.vo.ic.pub.define.ICPubMetaNameConst;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pub.VOStatus;
|
||||||
|
import nc.vo.scmpub.check.billvalidate.BillVOsCheckRule;
|
||||||
|
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||||
|
import nccloud.api.ic.m45.IAPIPurchaseInMaitain;
|
||||||
|
import nccloud.api.impl.ic.m45.check.CheckPurchaseInSaveValidator;
|
||||||
|
import nccloud.api.impl.ic.m45.fill.PurchaseInSaveFillValue;
|
||||||
|
import nccloud.api.impl.ic.m45.fill.PurchaseInUpdateFillValue;
|
||||||
|
import nccloud.api.impl.ic.pub.check.CheckProhibitUpdateFields;
|
||||||
|
import nccloud.openapi.ic.util.ICAPILocationVOUtils;
|
||||||
|
import nccloud.openapi.scmpub.pub.TransferCodeToPKTool;
|
||||||
|
import nccloud.openapi.scmpub.pub.TransferMapToVOTool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Description: 库存采购入库单维护接口实现类
|
||||||
|
*
|
||||||
|
* @author: 刘伟
|
||||||
|
* @date: 2019-5-7 下午3:22:00
|
||||||
|
* @version NCC1909
|
||||||
|
*/
|
||||||
|
public class APIPurchaseInMaitainImpl implements IAPIPurchaseInMaitain {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PurchaseInVO[] save(List<Map<String, Object>> paramList)
|
||||||
|
throws BusinessException {
|
||||||
|
// MapList转聚合VOList
|
||||||
|
List<PurchaseInVO> aggVOList =
|
||||||
|
TransferMapToVOTool.transferMapToAggVO(paramList, PurchaseInVO.class);
|
||||||
|
PurchaseInVO[] vos = aggVOList.toArray(new PurchaseInVO[aggVOList.size()]);
|
||||||
|
// 设置货位序列号VO
|
||||||
|
ICAPILocationVOUtils.setLocationVO(ICBillType.PurchaseIn.getCode(), vos);
|
||||||
|
// 1、传入数据基本非空校验
|
||||||
|
BillVOsCheckRule checker =
|
||||||
|
new BillVOsCheckRule(new CheckPurchaseInSaveValidator());
|
||||||
|
checker.check(vos);
|
||||||
|
// 2、编码翻译成pk
|
||||||
|
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||||
|
// 翻译货位
|
||||||
|
ICAPILocationVOUtils.translate(vos);
|
||||||
|
|
||||||
|
//begin没取到财务组织导致的报错,在这里给财务组织赋值为库存组织
|
||||||
|
for(PurchaseInVO vo : vos ) {
|
||||||
|
if(vo.getHead().getCfanaceorgoid()!=null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String cfinanceoid = (new OrgInfoQuery()).getFinanceOrgIDByCalBodyID(vo.getHead().getPk_org());
|
||||||
|
String cfinancevid = (new OrgInfoQuery()).getFinanceOrgVIDByCalBodyID(vo.getHead().getPk_org());
|
||||||
|
vo.getHead().setCfanaceorgoid(cfinanceoid);
|
||||||
|
vo.getHead().setCfanaceorgvid(cfinancevid);
|
||||||
|
}
|
||||||
|
//end
|
||||||
|
|
||||||
|
// 3、其他数据填充
|
||||||
|
new PurchaseInSaveFillValue().setDefaultValue(vos);
|
||||||
|
|
||||||
|
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>(
|
||||||
|
PurchaseInVO.class, ICBillType.PurchaseIn.getCode());
|
||||||
|
return tool.insert(vos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PurchaseInVO[] update(List<Map<String, Object>> paramList)
|
||||||
|
throws BusinessException {
|
||||||
|
// MapList转聚合VOList
|
||||||
|
List<PurchaseInVO> aggVOList =
|
||||||
|
TransferMapToVOTool.transferMapToAggVO(paramList, PurchaseInVO.class);
|
||||||
|
PurchaseInVO[] vos = aggVOList.toArray(new PurchaseInVO[aggVOList.size()]);
|
||||||
|
// 2、编码翻译成pk
|
||||||
|
aggVOList = TransferCodeToPKTool.transferAggVO(aggVOList);
|
||||||
|
Set<String> bfields = new HashSet<String>();
|
||||||
|
PurchaseInHeadVO newVO = vos[0].getHead();
|
||||||
|
String cgeneralhid = newVO.getCgeneralhid();
|
||||||
|
if (StringUtils.isEmpty(cgeneralhid)) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||||
|
"04008027-0380")/* @res "修改采购入库单请指定表头主键cgeneralhid值。" */);
|
||||||
|
}
|
||||||
|
SCMBillQuery<PurchaseInVO> queryTool =
|
||||||
|
new SCMBillQuery<PurchaseInVO>(PurchaseInVO.class);
|
||||||
|
PurchaseInVO[] purInVOs = queryTool.queryVOByIDs(new String[] {
|
||||||
|
cgeneralhid
|
||||||
|
});
|
||||||
|
Map<String, ICLocationVO[]> deleteLoc =
|
||||||
|
new HashMap<String, ICLocationVO[]>();
|
||||||
|
// 加载原始单据和货位信息
|
||||||
|
PurchaseInVO[] originBills = queryTool.queryVOByIDs(new String[] {
|
||||||
|
cgeneralhid
|
||||||
|
});
|
||||||
|
ICLocationUtil.loadLocationVOs(originBills);
|
||||||
|
if (ArrayUtils.isEmpty(purInVOs)) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||||
|
"04008027-0381")/* @res "没找到要修改的入库单信息,请检查数据的表头主键cgeneralhid。" */);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> headProFields =
|
||||||
|
CheckProhibitUpdateFields.getHeadProhibitFields("45");
|
||||||
|
List<String> bodyProFields =
|
||||||
|
CheckProhibitUpdateFields.getBodyProhibitFields("45");
|
||||||
|
PurchaseInHeadVO origVO = purInVOs[0].getHead();
|
||||||
|
if (origVO.getFbillflag() == null
|
||||||
|
|| 0 != ((Integer) ICBillFlag.FREE.value())
|
||||||
|
.compareTo((Integer) origVO.getFbillflag())) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0",
|
||||||
|
"04008027-0329")/* @res "当前入库单编号:" */ + origVO.getVbillcode()
|
||||||
|
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0362")/* @res "不是自由状态,不能修改" */);
|
||||||
|
}
|
||||||
|
origVO.setStatus(VOStatus.UPDATED);
|
||||||
|
for (String attr : newVO.getAttributeNames()) {
|
||||||
|
if (newVO.getAttributeValue(attr) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (headProFields.contains(attr) && !newVO.getAttributeValue(attr)
|
||||||
|
.equals(origVO.getAttributeValue(attr))) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0363")/* @res "表头字段:" */ + attr
|
||||||
|
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0364")/* @res "不允许修改。" */ );
|
||||||
|
}
|
||||||
|
origVO.setAttributeValue(attr, newVO.getAttributeValue(attr));
|
||||||
|
}
|
||||||
|
for (PurchaseInVO orivo : originBills) {
|
||||||
|
PurchaseInBodyVO[] oribodys = orivo.getBodys();
|
||||||
|
for (PurchaseInBodyVO oribody : oribodys) {
|
||||||
|
ICLocationVO[] locationVOs = oribody.getLocationVOs();
|
||||||
|
if (null != locationVOs) {
|
||||||
|
deleteLoc.put(oribody.getCgeneralbid(), locationVOs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vos[0].getBodys() != null) {
|
||||||
|
Map<String, PurchaseInBodyVO> pkbs =
|
||||||
|
new HashMap<String, PurchaseInBodyVO>();
|
||||||
|
for (PurchaseInBodyVO origBvo : purInVOs[0].getBodys()) {
|
||||||
|
origBvo.setStatus(VOStatus.UPDATED);
|
||||||
|
pkbs.put(origBvo.getCgeneralbid(), origBvo);
|
||||||
|
}
|
||||||
|
for (PurchaseInBodyVO newBvo : vos[0].getBodys()) {
|
||||||
|
PurchaseInBodyVO roigBvo = pkbs.get(newBvo.getCgeneralbid());
|
||||||
|
if (newBvo.getCgeneralbid() == null || roigBvo == null) {
|
||||||
|
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||||
|
.getNCLangRes().getStrByID("4008027_0", "04008027-0382")/*
|
||||||
|
* @res
|
||||||
|
* "没有匹配到原始入库单表体信息,请检查数据的表体主键cgeneralbid。"
|
||||||
|
*/);
|
||||||
|
}
|
||||||
|
for (String battr : newBvo.getAttributeNames()) {
|
||||||
|
if (newBvo.getAttributeValue(battr) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (bodyProFields.contains(battr)
|
||||||
|
&& !newBvo.getAttributeValue(battr)
|
||||||
|
.equals(roigBvo.getAttributeValue(battr))) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0366")/* @res "表体字段:" */ + battr
|
||||||
|
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0364")/* @res "不允许修改。" */ );
|
||||||
|
}
|
||||||
|
roigBvo.setAttributeValue(battr, newBvo.getAttributeValue(battr));
|
||||||
|
bfields.add(battr);
|
||||||
|
}
|
||||||
|
//设置货位序列号孙表,把原来的孙表删除,修改的货位置为新增
|
||||||
|
if(null != newBvo.getLocationVOs()) {
|
||||||
|
List<ICLocationVO> allloc = new ArrayList<ICLocationVO>();
|
||||||
|
if(null != deleteLoc && null != deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||||
|
for(ICLocationVO delloc : deleteLoc.get(roigBvo.getCgeneralbid())) {
|
||||||
|
delloc.setStatus(VOStatus.DELETED);
|
||||||
|
allloc.add(delloc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(ICLocationVO loc : newBvo.getLocationVOs()) {
|
||||||
|
loc.setStatus(VOStatus.NEW);
|
||||||
|
allloc.add(loc);
|
||||||
|
}
|
||||||
|
roigBvo.setLocationVOs(allloc.toArray(new ICLocationVO[allloc.size()]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 翻译货位
|
||||||
|
ICAPILocationVOUtils.translate(purInVOs);
|
||||||
|
// 其他数据填充
|
||||||
|
new PurchaseInUpdateFillValue().setDefaultValue(purInVOs);
|
||||||
|
BillMaintainTool<PurchaseInVO> tool = new BillMaintainTool<PurchaseInVO>(
|
||||||
|
PurchaseInVO.class, ICBillType.PurchaseIn.getCode());
|
||||||
|
tool.doBeforeInsert(purInVOs);
|
||||||
|
return nc.bs.framework.common.NCLocator.getInstance()
|
||||||
|
.lookup(nc.itf.ic.m45.self.IPurchaseInMaintain.class)
|
||||||
|
.update(purInVOs, originBills);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(PurchaseInVO[] vos) throws BusinessException {
|
||||||
|
nc.bs.framework.common.NCLocator.getInstance()
|
||||||
|
.lookup(nc.itf.ic.m45.self.IPurchaseInMaintain.class).delete(vos);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PurchaseInVO[] sign(PurchaseInVO[] vos) throws BusinessException {
|
||||||
|
if (ArrayUtils.isEmpty(vos)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (PurchaseInVO aggvo : vos) {
|
||||||
|
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||||
|
if (parentVO.getFbillflag() == null
|
||||||
|
|| 0 != ((Integer) ICBillFlag.FREE.value())
|
||||||
|
.compareTo((Integer) parentVO.getFbillflag())) {
|
||||||
|
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
|
||||||
|
.getStrByID("4008027_0", "04008027-0329")
|
||||||
|
/* @res "当前入库单编号:" */ + parentVO.getVbillcode()
|
||||||
|
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0330")/* @res "不是自由状态,不能签字" */);
|
||||||
|
}
|
||||||
|
if (aggvo.getChildrenVO() != null && aggvo.getChildrenVO().length > 0) {
|
||||||
|
if (aggvo.getChildrenVO()[0]
|
||||||
|
.getAttributeValue(ICPubMetaNameConst.NNUM) == null) {
|
||||||
|
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl
|
||||||
|
.getNCLangRes().getStrByID("4008027_0", "04008027-0329")
|
||||||
|
/* @res "当前入库单编号:" */ + parentVO.getVbillcode()
|
||||||
|
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0331")/* @res "主数量为空,不能签字" */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 加载货位单品明细
|
||||||
|
ICLocationUtil.loadLocationVOs(vos);
|
||||||
|
|
||||||
|
return (PurchaseInVO[]) PfServiceScmUtil.processBatch("SIGN", "45", vos,
|
||||||
|
null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PurchaseInVO[] unSign(PurchaseInVO[] vos) throws BusinessException {
|
||||||
|
if (ArrayUtils.isEmpty(vos)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (PurchaseInVO aggvo : vos) {
|
||||||
|
ICBillHeadVO parentVO = aggvo.getParentVO();
|
||||||
|
if (parentVO.getFbillflag() == null
|
||||||
|
|| 0 != ((Integer) ICBillFlag.SIGN.value())
|
||||||
|
.compareTo((Integer) parentVO.getFbillflag())) {
|
||||||
|
throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes()
|
||||||
|
.getStrByID("4008027_0", "04008027-0329")
|
||||||
|
/* @res "当前入库单编号:" */ + parentVO.getVbillcode()
|
||||||
|
+ nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008027_0", "04008027-0332")/* @res "不是签字状态,不能取消签字" */);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (PurchaseInVO[]) PfServiceScmUtil.processBatch("CANCELSIGN", "45",
|
||||||
|
vos, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
package nccloud.openapi.ic.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import nc.bs.framework.common.NCLocator;
|
||||||
|
import nc.itf.urmex.pub.IRMGlobalCache;
|
||||||
|
import nc.pubitf.sn.doc.param.SnDocQueryParam;
|
||||||
|
import nc.vo.bd.rack.RackVO;
|
||||||
|
import nc.vo.ic.general.define.ICBillBodyVO;
|
||||||
|
import nc.vo.ic.general.define.ICBillVO;
|
||||||
|
import nc.vo.ic.location.ICLocationVO;
|
||||||
|
import nc.vo.ic.pub.define.ICBillTableInfo;
|
||||||
|
import nc.vo.ic.pub.iadapter.sn.SnInterfaceAdapter;
|
||||||
|
import nc.vo.ic.pub.util.ValueCheckUtil;
|
||||||
|
import nc.vo.ml.NCLangRes4VoTransl;
|
||||||
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pub.VOStatus;
|
||||||
|
import nc.vo.pub.lang.UFDouble;
|
||||||
|
import nc.vo.pubapp.pattern.pub.MathTool;
|
||||||
|
import nc.vo.pubapp.pattern.pub.PubAppTool;
|
||||||
|
import nc.vo.scmpub.res.billtype.ICBillType;
|
||||||
|
import nc.vo.sn.doc.entity.SerialNoVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @@description
|
||||||
|
* @author lanli6
|
||||||
|
* @date 2023年2月15日
|
||||||
|
* @version ncc1.0
|
||||||
|
*/
|
||||||
|
public class ICAPILocationVOUtils {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* json格式实例:
|
||||||
|
* [{"ic_material_h":{"pk_org":"001","cwarehouseid":"ck03","cdptvid":"bm002",
|
||||||
|
* "vtrantypecode":"4D-01"},
|
||||||
|
* "ic_material_b":[{"cmaterialvid":"物料001","castunitid":"BOX",
|
||||||
|
* "nshouldassistnum":2,"vchangerate":"1/1",
|
||||||
|
* "ic_loc":[{"clocationid":"00","vserialcode":"122001","csnunitid": "BOX"
|
||||||
|
* ,"nnum":"1","nassistnum":"1"},
|
||||||
|
* {"clocationid":"00","vserialcode":"122001","csnunitid":"BOX","nnum":"1",
|
||||||
|
* "nassistnum":"1"}]}]}]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 货位明细表数据,json标识
|
||||||
|
*/
|
||||||
|
public static String ic_loc = "ic_loc";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把json转换为货位VO
|
||||||
|
*
|
||||||
|
* @param billtype 单据类型
|
||||||
|
* @param bodyvo 表体VO
|
||||||
|
* @param bodyInfo 表体json数据
|
||||||
|
*/
|
||||||
|
public static void setLocationVO(String billtype, ICBillVO[] aggVOList) {
|
||||||
|
for (ICBillVO aggvo : aggVOList) {
|
||||||
|
ICBillBodyVO[] bodys = aggvo.getBodys();
|
||||||
|
for (ICBillBodyVO body : bodys) {
|
||||||
|
setbodyLocationVO(billtype, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static void setbodyLocationVO(String billtype, ICBillBodyVO body) {
|
||||||
|
// 获取货位明细map
|
||||||
|
List<Map<String, String>> locationMap = (List<Map<String, String>>) body
|
||||||
|
.getAttributeValue(ICAPILocationVOUtils.ic_loc);
|
||||||
|
if (locationMap == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICBillType type = ICBillType.getICBillType(billtype);
|
||||||
|
// 创建货位VO数组
|
||||||
|
ICLocationVO[] loc = new ICLocationVO[locationMap.size()];
|
||||||
|
|
||||||
|
// 一个map表示一行货位,遍历每一行货位
|
||||||
|
int i = 0;
|
||||||
|
for (Map<String, String> row : locationMap) {
|
||||||
|
if (row == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 获取相应单据类型对应的货位VO
|
||||||
|
loc[i] = ICBillTableInfo.getICBillTableInfo(type).createLocationVO();
|
||||||
|
// 给货位VO的字段赋值
|
||||||
|
for (Map.Entry<String, String> location : row.entrySet()) {
|
||||||
|
if (location.getKey() != null) {
|
||||||
|
loc[i].setAttributeValue(location.getKey().trim(),
|
||||||
|
location.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
// 给表体设置货位VO
|
||||||
|
body.setLocationVOs(loc);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译货位和序列号
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public static void translate(ICBillVO[] billvos) throws BusinessException {
|
||||||
|
Set<String> wareSet = new HashSet<String>();
|
||||||
|
Set<String> locSet = new HashSet<String>();
|
||||||
|
List<SnDocQueryParam> paramlist = new ArrayList<SnDocQueryParam>();
|
||||||
|
// 获取单据的组织、仓库、物料、货位号、序列号
|
||||||
|
for (ICBillVO billvo : billvos) {
|
||||||
|
String pk_stordoc = billvo.getHead().getCwarehouseid();
|
||||||
|
if (!PubAppTool.isNull(pk_stordoc)) {
|
||||||
|
wareSet.add(pk_stordoc);
|
||||||
|
}
|
||||||
|
for (ICBillBodyVO bodyvo : billvo.getChildrenVO()) {
|
||||||
|
ICLocationVO[] locs = bodyvo.getLocationVOs();
|
||||||
|
if (ValueCheckUtil.isNullORZeroLength(locs)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ICLocationVO lvo : locs) {
|
||||||
|
if(VOStatus.DELETED == lvo.getStatus()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SnDocQueryParam param = new SnDocQueryParam();
|
||||||
|
param.setCmaterialvid(bodyvo.getCmaterialvid());
|
||||||
|
if (!PubAppTool.isNull(lvo.getClocationid())) {
|
||||||
|
locSet.add(lvo.getClocationid());
|
||||||
|
}
|
||||||
|
if (!PubAppTool.isNull(lvo.getVserialcode())) {
|
||||||
|
param.setSncode(lvo.getVserialcode());
|
||||||
|
paramlist.add(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 如果没有传序列号不处理孙表转换
|
||||||
|
// if (ValueCheckUtil.isNullORZeroLength(paramlist)) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// 查询货位
|
||||||
|
Map<String, RackVO> rackMap = getRack(wareSet, locSet);
|
||||||
|
// 查询序列号
|
||||||
|
Map<String, SerialNoVO> snMap =new HashMap<>();
|
||||||
|
if (!ValueCheckUtil.isNullORZeroLength(paramlist)) {
|
||||||
|
snMap =getSerialNoVO(paramlist.toArray(new SnDocQueryParam[paramlist.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置翻译好的货位和序列号主键
|
||||||
|
for (ICBillVO billvo : billvos) {
|
||||||
|
String pk_stordoc = billvo.getHead().getCwarehouseid();
|
||||||
|
|
||||||
|
for (ICBillBodyVO bodyvo : billvo.getChildrenVO()) {
|
||||||
|
String cmaterialvid = bodyvo.getCmaterialvid();
|
||||||
|
|
||||||
|
ICLocationVO[] locs = bodyvo.getLocationVOs();
|
||||||
|
if (locs == null || locs.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (ICLocationVO lvo : locs) {
|
||||||
|
if(VOStatus.DELETED == lvo.getStatus()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 设置货位主键
|
||||||
|
String clcode = lvo.getClocationid();
|
||||||
|
if (!PubAppTool.isNull(clcode)) {
|
||||||
|
RackVO rackvo = rackMap.get(clcode + pk_stordoc);
|
||||||
|
if (null == rackvo) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008003_0", "04008001-0961", null, new String[] {
|
||||||
|
clcode
|
||||||
|
})/* @res "货位[{0}]不存在!" */);
|
||||||
|
}
|
||||||
|
|
||||||
|
lvo.setClocationid(rackvo.getPk_rack());
|
||||||
|
}
|
||||||
|
// 设置序列号主键
|
||||||
|
String vserialcode = lvo.getVserialcode();
|
||||||
|
if (!PubAppTool.isNull(vserialcode)) {
|
||||||
|
SerialNoVO snVO = snMap.get(vserialcode + cmaterialvid);
|
||||||
|
if (snVO == null) {
|
||||||
|
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes()
|
||||||
|
.getStrByID("4008001_0", "04008001-0962", null, new String[] {
|
||||||
|
vserialcode
|
||||||
|
})/* @res "序列号[{0}]不存在!" */);
|
||||||
|
}
|
||||||
|
if (MathTool.greaterThan(lvo.getNnum(), new UFDouble(1))) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008001_0", "04008001-0963")/* @res "序列号数量不能大于1" */);
|
||||||
|
}
|
||||||
|
if (MathTool.isZero(lvo.getNnum())
|
||||||
|
|| MathTool.isZero(lvo.getNassistnum())) {
|
||||||
|
throw new BusinessException(
|
||||||
|
nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
|
||||||
|
"4008001_0", "04008001-0964")/* @res "序列号数量不能为0" */);
|
||||||
|
}
|
||||||
|
|
||||||
|
lvo.setPk_serialcode(snVO.getPk_serialno());
|
||||||
|
}
|
||||||
|
// 补充货位序列号孙表的组织信息
|
||||||
|
lvo.setCorpoid(bodyvo.getPk_org());
|
||||||
|
lvo.setCorpvid(bodyvo.getPk_org_v());
|
||||||
|
lvo.setPk_group(bodyvo.getPk_group());
|
||||||
|
lvo.setPk_group(bodyvo.getPk_group());
|
||||||
|
lvo.setStatus(VOStatus.NEW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译货位
|
||||||
|
* @param orgSet
|
||||||
|
* @param wareSet
|
||||||
|
* @param locSet
|
||||||
|
* @return rackMap
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
private static Map<String, RackVO> getRack(Set<String> wareSet,
|
||||||
|
Set<String> locSet) throws BusinessException {
|
||||||
|
Map<String, RackVO> rackMap = new HashMap<>();
|
||||||
|
// 如果没有传货位不处理主键转换
|
||||||
|
if (ValueCheckUtil.isNullORZeroLength(locSet)) {
|
||||||
|
return rackMap;
|
||||||
|
}
|
||||||
|
// 根据code查询货位信息
|
||||||
|
IRMGlobalCache cacheSvr =
|
||||||
|
NCLocator.getInstance().lookup(IRMGlobalCache.class);
|
||||||
|
rackMap = cacheSvr.getRackVO(locSet.toArray(new String[locSet.size()]),
|
||||||
|
wareSet.toArray(new String[wareSet.size()]));
|
||||||
|
// key:code+pk_stordoc
|
||||||
|
return rackMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译序列号
|
||||||
|
* @param marSet
|
||||||
|
* @param serialSet
|
||||||
|
* @return snMap
|
||||||
|
*/
|
||||||
|
private static Map<String, SerialNoVO> getSerialNoVO(
|
||||||
|
SnDocQueryParam[] snDoc) {
|
||||||
|
|
||||||
|
Map<String, SerialNoVO> snMap = new HashMap<String, SerialNoVO>();
|
||||||
|
SerialNoVO[] serialnovos = SnInterfaceAdapter.querySerialnos(snDoc);
|
||||||
|
for (SerialNoVO serialnovo : serialnovos) {
|
||||||
|
// key:code+cmaterialvid
|
||||||
|
String key = serialnovo.getVcode() + serialnovo.getCmaterialvid();
|
||||||
|
snMap.put(key, serialnovo);
|
||||||
|
}
|
||||||
|
return snMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue