From e785338212ff7468a12da093136c2986b6a97fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Mon, 16 Jun 2025 16:48:36 +0800 Subject: [PATCH] =?UTF-8?q?patch=5Fdev=5Fmmpsc=5F=E5=8D=8A=E6=88=90?= =?UTF-8?q?=E5=93=81=E6=94=B6=E8=B4=A7=E5=8D=95=E5=AE=A1=E6=89=B9=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=8A=A0=E5=B7=A5=E8=B4=B9=5Fsdlizheng=5F20250616=5F?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0mmpsc=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .classpath | 5 + mmpsc/src/client/.gitkeep | 0 mmpsc/src/private/.gitkeep | 0 .../pscrecive/bp/PscreciveApproveBP.java | 75 +++++++++ .../pscrecive/bp/PscreciveAutoApproveBP.java | 144 ++++++++++++++++++ .../bs/mmpsc/pscrecive/rule/Push55E6Rule.java | 126 +++++++++++++++ mmpsc/src/public/.gitkeep | 0 mmpsc/src/test/.gitkeep | 0 8 files changed, 350 insertions(+) create mode 100644 mmpsc/src/client/.gitkeep create mode 100644 mmpsc/src/private/.gitkeep create mode 100644 mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveApproveBP.java create mode 100644 mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveAutoApproveBP.java create mode 100644 mmpsc/src/private/nc/bs/mmpsc/pscrecive/rule/Push55E6Rule.java create mode 100644 mmpsc/src/public/.gitkeep create mode 100644 mmpsc/src/test/.gitkeep diff --git a/.classpath b/.classpath index 2a23253..48135db 100644 --- a/.classpath +++ b/.classpath @@ -100,6 +100,11 @@ + + + + + diff --git a/mmpsc/src/client/.gitkeep b/mmpsc/src/client/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpsc/src/private/.gitkeep b/mmpsc/src/private/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveApproveBP.java b/mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveApproveBP.java new file mode 100644 index 0000000..312ee09 --- /dev/null +++ b/mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveApproveBP.java @@ -0,0 +1,75 @@ +package nc.bs.mmpsc.pscrecive.bp; + +import nc.bs.mmpsc.pscrecive.plugin.bpplugin.PscrecivePluginPoint; +import nc.bs.mmpsc.pscrecive.rule.*; +import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser; +import nc.util.mmf.framework.gc.GCUpdateBPTemplate; +import nc.vo.mmpsc.pscrecive.entity.AggPscreciveVO; + +/** + * 单据审核的BP + * + * @since 6.0 + * @version 2014-01-27 15:02:41 + * @author computer + */ +public class PscreciveApproveBP { + /** + * 单据的持久化 + * + * @param clientBills 单据VO + * @param originBills 原始单据VO + * @return 保存后的单据VO + */ + public AggPscreciveVO[] approve(AggPscreciveVO[] clientBills, AggPscreciveVO[] originBills) { + // 调用修改模板 + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PscrecivePluginPoint.APPROVE); + + // 执行前规则 + this.addBeforeRule(bp.getAroundProcesser()); + + // 执行后规则 + this.addAfterRule(bp.getAroundProcesser(), originBills); + + return bp.update(clientBills, originBills); + } + + /** + * @param processer + * @param originBills + */ + private void addAfterRule(CompareAroundProcesser processer, AggPscreciveVO[] originBills) { + // 自动业务关闭工序委外订单 + IRule closerule = new CloseOrderRule(); + processer.addAfterRule(closerule); + //添加审批推送加工费结算单逻辑 + IRule pushrule = new Push55E6Rule(); + processer.addAfterFinalRule(pushrule); + } + + /** + * @param processer + */ + private void addBeforeRule(CompareAroundProcesser processer) { + // 校验冻结状态 added by zhanghr + IRule checkFrozenRule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(checkFrozenRule); + // 检查状态 + IRule irule = new ApproveBillStatusRule(); + processer.addBeforeRule(irule); + // 工序委外订单状态检查规则 + IRule orderCheckRule = new CheckPscOrderStatusRule(); + processer.addBeforeRule(orderCheckRule); + // 补充核销状态 + IRule vrule = new ApproveVerifyStatusRule(); + processer.addBeforeRule(vrule); + // 修改审核信息 + IRule frule = new FillApprovePsnRule(); + processer.addBeforeRule(frule); + // 更新审核状态 + IRule updaterule = new ApproveStatusUpdateRule(); + processer.addBeforeRule(updaterule); + } +} diff --git a/mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveAutoApproveBP.java b/mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveAutoApproveBP.java new file mode 100644 index 0000000..614dcd9 --- /dev/null +++ b/mmpsc/src/private/nc/bs/mmpsc/pscrecive/bp/PscreciveAutoApproveBP.java @@ -0,0 +1,144 @@ +package nc.bs.mmpsc.pscrecive.bp; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import nc.bs.mmpsc.pscrecive.plugin.bpplugin.PscrecivePluginPoint; +import nc.bs.mmpsc.pscrecive.rule.*; +import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser; +import nc.util.mmf.framework.base.MMArrayUtil; +import nc.util.mmf.framework.base.MMVOUtil; +import nc.util.mmf.framework.gc.GCUpdateBPTemplate; +import nc.vo.mmpsc.pscrecive.entity.AggPscreciveVO; +import nc.vo.mmpsc.pscrecive.entity.PscReciveTransTypeVO; +import nc.vo.mmpsc.pscrecive.util.QueryUtil; +import nc.vo.mmpsc.pscrecive.util.VOChangUtil; + +/** + * 收货单自动审核的BP + * + * @since 6.0 + * @version 2014-01-27 15:02:41 + * @author computer + */ +public class PscreciveAutoApproveBP { + /** + * 单据的持久化 + * + * @param clientBills 单据VO + * @param originBills 原始单据VO + * @return 保存后的单据VO + */ + public AggPscreciveVO[] approve(AggPscreciveVO[] clientBills) { + AggPscreciveVO[] approveVOs = this.filterAutoApprove(clientBills); + if (MMArrayUtil.isEmpty(approveVOs)) { + return clientBills; + } + AggPscreciveVO[] originBills = VOChangUtil.clone(approveVOs); + // 调用修改模板 + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PscrecivePluginPoint.APPROVE); + + // 执行前规则 + this.addBeforeRule(bp.getAroundProcesser()); + + // 执行后规则 + this.addAfterRule(bp.getAroundProcesser(), originBills); + + AggPscreciveVO[] returnBills = bp.update(clientBills, originBills); + return new QueryUtil().queryAfterUpdate(returnBills); + } + + /** + * @param processer + * @param originBills + */ + private void addAfterRule(CompareAroundProcesser processer, AggPscreciveVO[] originBills) { + //暂时没有规则 + //添加审批推送加工费结算单逻辑 + IRule pushrule = new Push55E6Rule(); + processer.addAfterFinalRule(pushrule); + } + + /** + * @param processer + */ + private void addBeforeRule(CompareAroundProcesser processer) { + // 校验冻结状态 added by zhanghr + IRule checkFrozenRule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(checkFrozenRule); + // 检查状态 + IRule irule = new ApproveBillStatusRule(); + processer.addBeforeRule(irule); + // 补充核销状态 + IRule vrule = new ApproveVerifyStatusRule(); + processer.addBeforeRule(vrule); + // 修改审核信息 + IRule frule = new FillApprovePsnRule(); + processer.addBeforeRule(frule); + // 更新审核状态 + IRule updaterule = new ApproveStatusUpdateRule(); + processer.addBeforeRule(updaterule); + // 自动业务关闭工序委外订单 + IRule closerule = new CloseOrderRule(); + processer.addBeforeRule(closerule); + } + + /** + * 过滤出需要自动审核 + * + * @param nowBills + * @return + */ + private AggPscreciveVO[] filterAutoApprove(AggPscreciveVO[] nowBills) { + if (nowBills == null || nowBills.length == 0) { + return null; + } + List typeid = new ArrayList(); + for (AggPscreciveVO bill : nowBills) { + typeid.add(bill.getHeadVO().getCtrantype()); + } + // 查询哪些交易类型需要自动审核 + Map autoMap = this.isAutoApprove(typeid.toArray(new String[0])); + // 过滤 + List reList = new ArrayList(); + for (AggPscreciveVO bill : nowBills) { + Boolean is = autoMap.get(bill.getHeadVO().getCtrantype()); + if (is != null && is.booleanValue()) { + reList.add(bill); + } + } + if (reList.size() > 0) { + return reList.toArray(new AggPscreciveVO[0]); + } + return null; + } + + /** + * 是否自动审核 + * + * @param ids + * @return + */ + private Map isAutoApprove(String[] ids) { + // 查询 + PscReciveTransTypeVO[] types = MMVOUtil.query(PscReciveTransTypeVO.class, PscReciveTransTypeVO.CTRANTYPEID, ids); + Map map = new HashMap(); + if (MMArrayUtil.isEmpty(types)) { + return map; + } + // 构造结果 + for (PscReciveTransTypeVO type : types) { + if (type.getBautoapprove() != null && type.getBautoapprove().booleanValue()) { + map.put(type.getCtrantypeid(), Boolean.TRUE); + } + else { + map.put(type.getCtrantypeid(), Boolean.FALSE); + } + } + return map; + } +} diff --git a/mmpsc/src/private/nc/bs/mmpsc/pscrecive/rule/Push55E6Rule.java b/mmpsc/src/private/nc/bs/mmpsc/pscrecive/rule/Push55E6Rule.java new file mode 100644 index 0000000..bacab7a --- /dev/null +++ b/mmpsc/src/private/nc/bs/mmpsc/pscrecive/rule/Push55E6Rule.java @@ -0,0 +1,126 @@ +package nc.bs.mmpsc.pscrecive.rule; + +import nc.bs.framework.common.NCLocator; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.itf.mmpsc.pscsettle.ISettleMaintain; +import nc.itf.uap.pf.IPfExchangeService; +import nc.util.mmf.framework.base.MMArrayUtil; +import nc.util.mmf.framework.base.MMNumberUtil; +import nc.vo.mmpsc.pscrecive.entity.AggPscreciveVO; +import nc.vo.mmpsc.pscrecive.entity.PscreciveItemVO; +import nc.vo.mmpsc.pscrecive.entity.PscreciveQcVO; +import nc.vo.mmpsc.pscrecive.enumeration.PscReciveProcessMethodEnum; +import nc.vo.mmpsc.pscrecive.enumeration.PscReciveStatusEnum; +import nc.vo.mmpsc.pscsettle.entity.AggSettleVO; +import nc.vo.mmpsc.pscsettle.entity.SettleHeadVO; +import nc.vo.mmpsc.pscsettle.entity.SettleItemVO; +import nc.vo.pub.compiler.PfParameterVO; +import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Classname Push55E6Rule + * @Description TODO + * @Version 1.0.0 + * @Date 2025/6/16 14:40 + * @Created by ame + */ +public class Push55E6Rule implements IRule { + + @Override + public void process(AggPscreciveVO[] aggvos) { + if(aggvos==null || aggvos.length<1){ + return; + } + ISettleMaintain service = NCLocator.getInstance().lookup(ISettleMaintain.class); + try { + AggPscreciveVO[] newAggvos = this.fiterData(aggvos); + if(newAggvos!=null && newAggvos.length>0){ + IPfExchangeService ef = NCLocator.getInstance().lookup(IPfExchangeService.class); + AggSettleVO[] aggSettleVOs = (AggSettleVO[])ef.runChangeDataAryNeedClassify("55E5", "55E6", newAggvos, (PfParameterVO)null, 1); + if (aggSettleVOs != null && aggSettleVOs.length > 0) { + this.fillData(aggSettleVOs); + service.insertSettle(aggSettleVOs); + } + } + } catch (Exception e) { + ExceptionUtils.wrappBusinessException(e.getMessage()); + } + } + + private void fillData(AggSettleVO[] aggSettleVOs) { + for (AggSettleVO aggSettleVO : aggSettleVOs) { + SettleHeadVO headVO = aggSettleVO.getHeadVO(); + SettleItemVO[] itemVO = aggSettleVO.getItemVO(); + headVO.setStatus(2); + headVO.setFstatusflag(1); + //itemVO的vrowno根据序号设置值:i*10 + for (int i = 0; i < itemVO.length; i++) { + itemVO[i].setStatus(2); + itemVO[i].setVrowno(String.valueOf((i+1) * 10)); + } + } + } + + private AggPscreciveVO[] fiterData(AggPscreciveVO[] aggPscreciveVOs) { + AggPscreciveVO[] statusvos = this.fiterDataStatus(aggPscreciveVOs); + AggPscreciveVO[] qcvos = this.fiterDataQc(statusvos); + return qcvos; + } + + private AggPscreciveVO[] fiterDataStatus(AggPscreciveVO[] vos) { + List aggPscreciveVOs = new ArrayList(); + for (AggPscreciveVO aggPscreciveVO : vos) { + if (PscReciveStatusEnum.APPROVED.equalsValue(aggPscreciveVO.getHeadVO().getFstatusflag())) { + aggPscreciveVOs.add(aggPscreciveVO); + } + } + return aggPscreciveVOs.toArray(new AggPscreciveVO[aggPscreciveVOs.size()]); + } + + private AggPscreciveVO[] fiterDataQc(AggPscreciveVO[] vos) { + if (MMArrayUtil.isEmpty(vos)) { + return null; + } + List aggPscreciveVOs = new ArrayList(); + for (AggPscreciveVO aggPscreciveVO : vos) { + List pscreciveItemVOs = new ArrayList(); + for (PscreciveItemVO pscreciveItemVO : aggPscreciveVO.getItemVO()) { + PscreciveQcVO[] pscreciveQcVOs = pscreciveItemVO.getCpscrecive_qcid(); + if (MMArrayUtil.isNotEmpty(pscreciveQcVOs)) { + UFDouble sumNum = UFDouble.ZERO_DBL; + UFDouble sumAstNum = UFDouble.ZERO_DBL; + for (PscreciveQcVO pscreciveQcVO : pscreciveQcVOs) { + if (PscReciveProcessMethodEnum.PRODIN.equalsValue(pscreciveQcVO.getFqprocessmethod()) + || PscReciveProcessMethodEnum.MATERREJECT + .equalsValue(pscreciveQcVO.getFqprocessmethod()) + || PscReciveProcessMethodEnum.REWORK.equalsValue(pscreciveQcVO.getFqprocessmethod())) { + sumNum = MMNumberUtil.add(sumNum, pscreciveQcVO.getNqnum()); + sumAstNum = MMNumberUtil.add(sumAstNum, pscreciveQcVO.getNqastnum()); + } + } + if (MMNumberUtil.isGtZero(sumNum) && MMNumberUtil.isGtZero(sumAstNum)) { + pscreciveItemVO.setProcessastnum(sumAstNum); + pscreciveItemVO.setProcessnum(sumNum); + pscreciveItemVOs.add(pscreciveItemVO); + } + } else if (aggPscreciveVO.getHeadVO().getBreturn() != null + && aggPscreciveVO.getHeadVO().getBreturn().booleanValue()) { + pscreciveItemVO.setProcessastnum(MMNumberUtil.toNegValue(pscreciveItemVO.getNbastrecivenum())); + pscreciveItemVO.setProcessnum(MMNumberUtil.toNegValue(pscreciveItemVO.getNbrecivenum())); + pscreciveItemVOs.add(pscreciveItemVO); + } + } + if (pscreciveItemVOs.size() > 0) { + aggPscreciveVO.setChildrenVO(pscreciveItemVOs.toArray(new PscreciveItemVO[0])); + aggPscreciveVOs.add(aggPscreciveVO); + } + } + return aggPscreciveVOs.toArray(new AggPscreciveVO[aggPscreciveVOs.size()]); + } + + +} diff --git a/mmpsc/src/public/.gitkeep b/mmpsc/src/public/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpsc/src/test/.gitkeep b/mmpsc/src/test/.gitkeep new file mode 100644 index 0000000..e69de29