Переглянути джерело

备料计划审批+生产订单审批不生成备料计划

yaoyu 2 роки тому
батько
коміт
8947b3a7e6

+ 71 - 0
xh/so/src/private/nc/bs/mmpac/pickm/pfxx/plugin/MMPacPickmPfxxPlugin.java

@@ -0,0 +1,71 @@
+package nc.bs.mmpac.pickm.pfxx.plugin;
+
+import nc.bs.framework.common.NCLocator;
+import nc.bs.pfxx.ISwapContext;
+import nc.bs.pfxx.plugin.AbstractPfxxPlugin;
+import nc.itf.mmpac.pickm.IPickmMaintainService;
+import nc.vo.mmpac.pickm.entity.AggPickmVO;
+import nc.vo.pfxx.auxiliary.AggxsysregisterVO;
+import nc.vo.pfxx.util.PfxxPluginUtils;
+import nc.vo.pub.AggregatedValueObject;
+import nc.vo.pub.BusinessException;
+import nc.vo.pub.CircularlyAccessibleValueObject;
+import nc.vo.pub.VOStatus;
+import nc.vo.pubapp.pattern.pub.PubAppTool;
+
+/**
+ * 备料计划外部系统交换插件实现类
+ * 
+ * @since 6.0
+ * @version 2013-10-29 下午04:29:08
+ * @author lijbe
+ */
+public class MMPacPickmPfxxPlugin extends AbstractPfxxPlugin {
+    private IPickmMaintainService maintainService = null;
+
+    @Override
+    protected Object processBill(Object vo, ISwapContext swapContext, AggxsysregisterVO aggvo) throws BusinessException {
+        // 1.得到转换后的VO数据,取决于向导第一步注册的VO信息
+    	
+        AggregatedValueObject resvo = (AggregatedValueObject) vo;
+
+        String vopk = PfxxPluginUtils.queryBillPKBeforeSaveOrUpdate(swapContext.getBilltype(), swapContext.getDocID());
+
+        // 2.如果此单据没有导入过,那么准备保存新单据,保存单据前请进行必要的数据检查,并给出明确的业务异常...
+        AggregatedValueObject returnVO = null;
+
+        if (PubAppTool.isNull(vopk)) {
+            resvo.getParentVO().setStatus(VOStatus.NEW);
+            for (CircularlyAccessibleValueObject bvo : resvo.getChildrenVO()) {
+                bvo.setStatus(VOStatus.NEW);
+            }
+            returnVO = this.getMaintainService().insert(new AggPickmVO[] {
+                (AggPickmVO) resvo
+            })[0];
+            /***************add by ZTH 2022-11-16 备料计划自动审批*******************************/
+            returnVO = this.getMaintainService().auditPickm(new AggPickmVO[] {
+                    (AggPickmVO) returnVO
+                })[0];
+           /************************************************************************************/ 
+        }
+        else {
+
+            returnVO = this.getMaintainService().update(new AggPickmVO[] {
+                (AggPickmVO) resvo
+            })[0];
+        }
+        vopk = returnVO.getParentVO().getPrimaryKey();
+
+        PfxxPluginUtils.addDocIDVsPKContrast(swapContext.getBilltype(), swapContext.getDocID(), vopk);
+
+        return vopk;
+    }
+
+    public IPickmMaintainService getMaintainService() {
+        if (this.maintainService == null) {
+            this.maintainService = NCLocator.getInstance().lookup(IPickmMaintainService.class);
+        }
+        return this.maintainService;
+    }
+   
+}

+ 121 - 0
xh/so/src/private/nc/bs/mmpac/pmo/pac0002/rule/PMOInsertPickmRule.java

@@ -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());
+        }
+    }
+}