|
@@ -0,0 +1,121 @@
|
|
|
+package nc.bs.mmpac.pmo.pac0002.rule;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import nc.bs.framework.common.NCLocator;
|
|
|
+import nc.bs.mmpac.pmo.pac0002.bp.service.PMOBPService;
|
|
|
+import nc.bs.mmpac.pmo.pac0002.bp.util.PMOBPUtil;
|
|
|
+import nc.impl.pubapp.pattern.rule.IRule;
|
|
|
+import nc.itf.uap.busibean.SysinitAccessor;
|
|
|
+import nc.itf.uap.pf.IPfExchangeService;
|
|
|
+import nc.itf.uap.pf.busiflow.PfButtonClickContext;
|
|
|
+import nc.util.mmf.framework.base.MMArrayUtil;
|
|
|
+import nc.util.mmf.framework.base.MMCollectionUtil;
|
|
|
+import nc.util.mmf.framework.base.MMValueCheck;
|
|
|
+import nc.vo.mmpac.pickm.entity.AggPickmVO;
|
|
|
+import nc.vo.mmpac.pickm.param.PickmTransParam;
|
|
|
+import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO;
|
|
|
+import nc.vo.mmpac.pmo.pac0002.entity.PMOHeadVO;
|
|
|
+import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pub.lang.UFBoolean;
|
|
|
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 只在审核时使用,审核时生产备料计划
|
|
|
+ *
|
|
|
+ * @since 6.5
|
|
|
+ */
|
|
|
+public class PMOInsertPickmRule implements IRule<PMOAggVO> {
|
|
|
+ @Override
|
|
|
+ public void process(PMOAggVO[] aggvos) {
|
|
|
+ PMOAggVO[] vos = PMOBPUtil.getApprovedVOs(aggvos);
|
|
|
+ if (MMValueCheck.isEmpty(vos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /************add by ZTH 2022-11-16 外部交换平台生产订单不允许自动生成备料计划**************************/
|
|
|
+ PMOItemVO bodyvo=vos[0].getChildrenVO()[0];
|
|
|
+ String vnote =bodyvo.getVdef10();// Y审批不自动生成备料计划
|
|
|
+ if("Y".equals(vnote)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ /****************************************************************************************************/
|
|
|
+
|
|
|
+
|
|
|
+ this.createPickms(vos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createPickms(PMOAggVO[] vos) {
|
|
|
+ if (MMArrayUtil.isEmpty(vos)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PMOAggVO> aggVOList = new ArrayList<PMOAggVO>();
|
|
|
+ PMOAggVO newAggVO = null;
|
|
|
+ // 取备料计划信息
|
|
|
+ List<PickmTransParam> paraList = new ArrayList<PickmTransParam>();
|
|
|
+ for (PMOAggVO aggVO : vos) {
|
|
|
+ PMOItemVO[] itemVOs = (PMOItemVO[]) aggVO.getChildren(PMOItemVO.class);
|
|
|
+ if (MMArrayUtil.isEmpty(itemVOs)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (PMOItemVO itemVO : itemVOs) {
|
|
|
+ // 组装参数查询是否存在备料计划
|
|
|
+ PickmTransParam para = new PickmTransParam();
|
|
|
+ // para.setSourceBillID(head.getCpmohid());
|
|
|
+ para.setSourceBillRowID(itemVO.getCmoid());
|
|
|
+ paraList.add(para);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (paraList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ // 查询是否存在备料计划
|
|
|
+ Map<String, UFBoolean> havepickmMap =
|
|
|
+ PMOBPService.getIPpickmQueryServiceForPmo().queryHavePickmByMO(
|
|
|
+ paraList.toArray(new PickmTransParam[paraList.size()]));
|
|
|
+
|
|
|
+ for (PMOAggVO aggVO : vos) {
|
|
|
+ PMOItemVO[] itemVOs = (PMOItemVO[]) aggVO.getChildren(PMOItemVO.class);
|
|
|
+ if (MMArrayUtil.isEmpty(itemVOs)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (PMOItemVO itemVO : itemVOs) {
|
|
|
+ // 取出不存在备料计划的产品行进行进行生成
|
|
|
+ if (havepickmMap.containsKey(itemVO.getCmoid())
|
|
|
+ && UFBoolean.FALSE.equals(havepickmMap.get(itemVO.getCmoid()))) {
|
|
|
+ newAggVO = new PMOAggVO();
|
|
|
+ newAggVO.setParent(aggVO.getParent());
|
|
|
+ newAggVO.setChildren(PMOItemVO.class, new PMOItemVO[] {
|
|
|
+ itemVO
|
|
|
+ });
|
|
|
+ aggVOList.add(newAggVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (BusinessException e1) {
|
|
|
+ ExceptionUtils.wrappException(e1);
|
|
|
+ }
|
|
|
+ if (MMCollectionUtil.isEmpty(aggVOList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ nc.itf.uap.pf.IPfExchangeService ef = NCLocator.getInstance().lookup(IPfExchangeService.class);
|
|
|
+ try {
|
|
|
+ AggPickmVO[] pickms =
|
|
|
+ (AggPickmVO[]) ef.runChangeDataAryNeedClassify("55A2", "55A3", aggVOList.toArray(new PMOAggVO[0]),
|
|
|
+ null, PfButtonClickContext.ClassifyByItfdef);
|
|
|
+ PMOBPService.getIPpickmBusinessServiceForPmo().insertPickmForMO(pickms);
|
|
|
+ }
|
|
|
+ catch (BusinessException e) {
|
|
|
+ ExceptionUtils.wrappException(e);
|
|
|
+ // ExceptionUtils.wrappBusinessException(PMOConstLang.getMSG_RULE_INSERTPICKM_ERROR() + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|