加入表体拆单逻辑

This commit is contained in:
hefengkai 2024-10-18 16:33:06 +08:00
parent 91be5b859d
commit 186bb370c2
1 changed files with 34 additions and 2 deletions

View File

@ -1,10 +1,13 @@
package nc.impl.pu.m23.approve.rule;
import java.util.ArrayList;
import java.util.Map;
import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.itf.pu.dhjyd.dhjydmaster.IArriveToDhjyd;
import nc.vo.pu.m23.entity.ArriveHeaderVO;
import nc.vo.pu.m23.entity.ArriveItemVO;
import nc.vo.pu.m23.entity.ArriveVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nccloud.commons.lang.ArrayUtils;
@ -24,12 +27,41 @@ public class ApproveAndSaveDhjyRule extends Object implements IRule<ArriveVO>
try {
IArriveToDhjyd service = (IArriveToDhjyd)NCLocator.getInstance().lookup(IArriveToDhjyd.class);
if (vos != null && vos.length > 0) {
for(int i = 0; i < vos.length; i++) {
service.createDhjyd_RequiresNew(vos[i]);
ArriveVO[] _vos = separateBill(vos);//到货单依据表体拆单处理
for(int i = 0; i < _vos.length; i++) {
service.createDhjyd_RequiresNew(_vos[i]);
}
}
} catch (Exception e) {
ExceptionUtils.wrappException(e);
}
}
/***
* 到货单按照表体拆单
* @author hefk
*
*/
private ArriveVO[] separateBill(ArriveVO[] vos) throws Exception {
ArriveVO _vo = null;//拆分后子到货单定义
ArrayList<ArriveVO> list = new ArrayList<ArriveVO>();//拆分后到货单集合
for(int i = 0; i < vos.length; i++) {
ArriveVO vo = vos[i];
ArriveHeaderVO arriveHeadVo = vo.getHVO();//获取到货单表头信息
ArriveItemVO[] arriveItems = vo.getBVO();//获取到货单表体信息
if(arriveItems != null && arriveItems.length > 0) {
for(int j = 0; j < arriveItems.length; j++) {
_vo = new ArriveVO();//实例生成
_vo.setHVO(arriveHeadVo);//表头设置
_vo.setBVO(new ArriveItemVO[] {arriveItems[j]});//表体设置
list.add(_vo);
}
}
}
return list.toArray(new ArriveVO[0]);
}
}