From 55e7646ebcfbb46325895a4547d37a25b75499c2 Mon Sep 17 00:00:00 2001 From: "zhangxinah@yonyou.com" Date: Wed, 26 Mar 2025 15:10:45 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0mmpub=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E9=BD=90=E5=A5=97=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .classpath | 5 ++ mmpub/META-INF/.gitkeep | 0 mmpub/METADATA/.gitkeep | 0 mmpub/component.xml | 3 + mmpub/config/billcodepredata/.gitkeep | 0 mmpub/config/doc-lucene-config/.gitkeep | 0 mmpub/config/pfxx/.gitkeep | 0 mmpub/config/tabconfig/.gitkeep | 0 mmpub/designmodel/ace/.gitkeep | 0 mmpub/designmodel/coderule/.gitkeep | 0 mmpub/designmodel/funcmodel/.gitkeep | 0 mmpub/designmodel/systemplatebase/.gitkeep | 0 mmpub/designmodel/templet/.gitkeep | 0 mmpub/doc/.gitkeep | 0 mmpub/resources/.gitkeep | 0 mmpub/script/business/.gitkeep | 0 mmpub/script/conf/.gitkeep | 0 mmpub/script/dbcreate/.gitkeep | 0 mmpub/script/dbml/.gitkeep | 0 mmpub/src/client/.gitkeep | 0 mmpub/src/private/.gitkeep | 0 .../mmpub/setanalysis/bp/SetAnalysisBP.java | 85 +++++++++++++++++++ .../bp/rule/analysisAfterCheckRule.java | 45 ++++++++++ mmpub/src/public/.gitkeep | 0 mmpub/src/test/.gitkeep | 0 25 files changed, 138 insertions(+) create mode 100644 mmpub/META-INF/.gitkeep create mode 100644 mmpub/METADATA/.gitkeep create mode 100644 mmpub/component.xml create mode 100644 mmpub/config/billcodepredata/.gitkeep create mode 100644 mmpub/config/doc-lucene-config/.gitkeep create mode 100644 mmpub/config/pfxx/.gitkeep create mode 100644 mmpub/config/tabconfig/.gitkeep create mode 100644 mmpub/designmodel/ace/.gitkeep create mode 100644 mmpub/designmodel/coderule/.gitkeep create mode 100644 mmpub/designmodel/funcmodel/.gitkeep create mode 100644 mmpub/designmodel/systemplatebase/.gitkeep create mode 100644 mmpub/designmodel/templet/.gitkeep create mode 100644 mmpub/doc/.gitkeep create mode 100644 mmpub/resources/.gitkeep create mode 100644 mmpub/script/business/.gitkeep create mode 100644 mmpub/script/conf/.gitkeep create mode 100644 mmpub/script/dbcreate/.gitkeep create mode 100644 mmpub/script/dbml/.gitkeep create mode 100644 mmpub/src/client/.gitkeep create mode 100644 mmpub/src/private/.gitkeep create mode 100644 mmpub/src/private/nc/bs/mmpub/setanalysis/bp/SetAnalysisBP.java create mode 100644 mmpub/src/private/nc/bs/mmpub/setanalysis/bp/rule/analysisAfterCheckRule.java create mode 100644 mmpub/src/public/.gitkeep create mode 100644 mmpub/src/test/.gitkeep diff --git a/.classpath b/.classpath index 8501716..74cbf75 100644 --- a/.classpath +++ b/.classpath @@ -1,5 +1,10 @@ + + + + + diff --git a/mmpub/META-INF/.gitkeep b/mmpub/META-INF/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/METADATA/.gitkeep b/mmpub/METADATA/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/component.xml b/mmpub/component.xml new file mode 100644 index 0000000..d1df635 --- /dev/null +++ b/mmpub/component.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/mmpub/config/billcodepredata/.gitkeep b/mmpub/config/billcodepredata/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/config/doc-lucene-config/.gitkeep b/mmpub/config/doc-lucene-config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/config/pfxx/.gitkeep b/mmpub/config/pfxx/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/config/tabconfig/.gitkeep b/mmpub/config/tabconfig/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/designmodel/ace/.gitkeep b/mmpub/designmodel/ace/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/designmodel/coderule/.gitkeep b/mmpub/designmodel/coderule/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/designmodel/funcmodel/.gitkeep b/mmpub/designmodel/funcmodel/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/designmodel/systemplatebase/.gitkeep b/mmpub/designmodel/systemplatebase/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/designmodel/templet/.gitkeep b/mmpub/designmodel/templet/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/doc/.gitkeep b/mmpub/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/resources/.gitkeep b/mmpub/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/script/business/.gitkeep b/mmpub/script/business/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/script/conf/.gitkeep b/mmpub/script/conf/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/script/dbcreate/.gitkeep b/mmpub/script/dbcreate/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/script/dbml/.gitkeep b/mmpub/script/dbml/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/src/client/.gitkeep b/mmpub/src/client/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/src/private/.gitkeep b/mmpub/src/private/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/src/private/nc/bs/mmpub/setanalysis/bp/SetAnalysisBP.java b/mmpub/src/private/nc/bs/mmpub/setanalysis/bp/SetAnalysisBP.java new file mode 100644 index 0000000..8d989d1 --- /dev/null +++ b/mmpub/src/private/nc/bs/mmpub/setanalysis/bp/SetAnalysisBP.java @@ -0,0 +1,85 @@ +package nc.bs.mmpub.setanalysis.bp; + +import nc.bs.mmpub.setanalysis.bp.log.SaMemoryBP; +import nc.bs.mmpub.setanalysis.bp.utils.SaLogger; +import nc.bs.mmpub.setanalysis.proxy.SaServiceProxy; +import nc.vo.mmpub.setanalysis.entity.AggAnalysisVO; +import nc.vo.mmpub.setanalysis.entity.SaContext; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDateTime; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.bs.mmpub.setanalysis.bp.rule.analysisAfterCheckRule; +import nc.vo.mmpub.setanalysis.entity.SaAnalysisVO; +import nc.vo.mmpub.setanalysis.utils.SaMeasureUtil; +import nc.bs.mmpub.setanalysis.bp.utils.SaScaleUtil; +import nc.bs.mmpub.setanalysis.bp.utils.SaVOUtils; + +public class SetAnalysisBP { + private SaContext context; + + public SetAnalysisBP(SaContext context) { + this.context = context; + } + + public AggAnalysisVO[] doSetAnalysis() { + try { + addBeforeRule(); + SaLogger.init(); + UFDateTime tstarttime1 = new UFDateTime(); + SaLogger.debug("0.分析开始^^^^^^^^^^^^^^^^^^^^^^^^^^"); + + createMd5Function(); + + UFDateTime tstarttime2 = new UFDateTime(); + SaLogger.debug("1.收集数据"); + SaMemoryBP.printMemory(); + SaServiceProxy.getAnalysisService().gather_RequiresNew(this.context); + SaLogger.debug("数据收集共耗时:" + SaLogger.getRunTime(tstarttime2)); + + UFDateTime tstarttime3 = new UFDateTime(); + SaLogger.debug("2.执行匹配开始"); + SaServiceProxy.getAnalysisService().match_RequiresNew(this.context); + SaLogger.debug("匹配共耗时:" + SaLogger.getRunTime(tstarttime3)); + + UFDateTime tstarttime4 = new UFDateTime(); + SaLogger.debug("3.反算齐套开始"); + SaServiceProxy.getAnalysisService().multiStorey_RequiresNew(this.context); + SaLogger.debug("反算齐套结束,共耗时:" + SaLogger.getRunTime(tstarttime4)); + SaMemoryBP.printMemory(); + this.result(this.context.getAggs()); + this.analysisAfterCheckRule();// 分析后调用回写 + SaLogger.debug("齐套分析算法结束,共耗时:" + SaLogger.getRunTime(tstarttime1)); + return this.context.getAggs(); + } catch (BusinessException e) { + ExceptionUtils.wrappException(e); + SaLogger.error(e.getMessage()); + + return null; + } + } + + private void result(AggAnalysisVO[] aggs) { + SaScaleUtil scale = new SaScaleUtil(); + SaAnalysisVO[] savos = SaVOUtils.construcVOs(aggs); + scale.setScaleSuperVOs(savos, "cmeasureid", new String[] { "nsetsnum" }); + SaMeasureUtil.setAnalysisAssNum(aggs); + } + + private void printMemory(String operation) { + long totalMemory = Runtime.getRuntime().totalMemory() / 1024L / 1024L; + long freeMemory = Runtime.getRuntime().freeMemory() / 1024L / 1024L; + SaLogger.debug(operation + ":totalMemory->" + operation + "MB,freeMemory->" + totalMemory + "MB"); + } + + private void createMd5Function() { + (new SaFunctionBP()).createMD5(); + } + + private void addBeforeRule() { + + } + + private void analysisAfterCheckRule() { + (new analysisAfterCheckRule()).process(this.context.getAggs()); + } +} diff --git a/mmpub/src/private/nc/bs/mmpub/setanalysis/bp/rule/analysisAfterCheckRule.java b/mmpub/src/private/nc/bs/mmpub/setanalysis/bp/rule/analysisAfterCheckRule.java new file mode 100644 index 0000000..e898745 --- /dev/null +++ b/mmpub/src/private/nc/bs/mmpub/setanalysis/bp/rule/analysisAfterCheckRule.java @@ -0,0 +1,45 @@ +package nc.bs.mmpub.setanalysis.bp.rule; + +import nc.bs.dao.BaseDAO; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.vo.mmpub.setanalysis.entity.AggAnalysisVO; +import nc.vo.mmpub.setanalysis.entity.SaAnalysisVO; +import nc.vo.pub.BusinessException; + +public class analysisAfterCheckRule implements IRule { + + @Override + public void process(AggAnalysisVO[] aggAnalysisVOS) { + try { + for (AggAnalysisVO vo : aggAnalysisVOS) { + SaAnalysisVO saAnalysisVO = vo.getParentVO(); + String cdemandbillbid = saAnalysisVO.getCdemandbillbid();//需求单据明细nsetsnum + Object ntotaloutnumsObj = saAnalysisVO.getNsetsnum();//齐套主数量ndemandnum + String ntotaloutnums = (ntotaloutnumsObj != null) ? ntotaloutnumsObj.toString() : ""; + double ntotaloutnum = + (ntotaloutnums.isEmpty()) ? 0 : Double.parseDouble(ntotaloutnums);//齐套主数量 + Object ndemandnumObj = saAnalysisVO.getNdemandnum();//分析主数量 + String ndemandnums = (ndemandnumObj != null) ? ndemandnumObj.toString() : ""; + double ndemandnum = + (ndemandnums.isEmpty()) ? 0 : Double.parseDouble(ndemandnums);//分析数量 + double vdef4 = 0; + if (ndemandnum != 0) { + vdef4 = ntotaloutnum / ndemandnum; + } + String update = + " update mm_mo set vdef6=" + ntotaloutnum + ",vdef4=" + vdef4 + " where cmoid='" + + cdemandbillbid + "' "; + updateSaleBSQty(update); + } + } catch (BusinessException e) { + throw new RuntimeException(e); + } + } + + private int updateSaleBSQty(String sql) throws BusinessException { + BaseDAO baseDAO = new BaseDAO(); + int succInt = baseDAO.executeUpdate(sql); + return succInt; + } + +} diff --git a/mmpub/src/public/.gitkeep b/mmpub/src/public/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mmpub/src/test/.gitkeep b/mmpub/src/test/.gitkeep new file mode 100644 index 0000000..e69de29 From 0eb4e5a01baf8b5391212660f1cafacea22f31a9 Mon Sep 17 00:00:00 2001 From: "zhangxinah@yonyou.com" Date: Wed, 26 Mar 2025 15:11:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8A=95=E6=94=BE=E6=A0=A1=E9=AA=8C=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bs/mmpac/pmo/pac0002/bp/PMOInsertBP.java | 382 ++++++++++++++++++ .../nc/bs/mmpac/pmo/pac0002/bp/PMOPutBP.java | 105 +++++ .../bs/mmpac/pmo/pac0002/bp/PMORowPutBP.java | 122 ++++++ .../pac0002/bp/rule/putBeforeCheckRule.java | 111 +++++ 4 files changed, 720 insertions(+) create mode 100644 mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOInsertBP.java create mode 100644 mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOPutBP.java create mode 100644 mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMORowPutBP.java create mode 100644 mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/putBeforeCheckRule.java diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOInsertBP.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOInsertBP.java new file mode 100644 index 0000000..82d3690 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOInsertBP.java @@ -0,0 +1,382 @@ +package nc.bs.mmpac.pmo.pac0002.bp; + +import java.util.ArrayList; +import java.util.List; +import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint; +import nc.bs.mmpac.pmo.pac0002.rule.PMOATOCheckRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOATPUpdateRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOCffileidInserAndUpdatetRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOCreatePickmWhenInsertRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOInsertSaveApproveRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOMarkWrSNWhenInsertRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOSNDupCheckRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOSaveSNWhenInsertRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOSplitByTaskDetailsRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOSyncSNWhenInsertRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.CheckMaterialIsEnableRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckCinwarehouseidRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDMODuplicateRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDateLogicRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckMaterialPermissionRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckNrwxisLogicRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckParentStatusRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedureDateLogicRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedureDupRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedurePSCRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProcedureratioRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckProdurepointRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSCDuplicateRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSNNumAndUnitRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckSaveNotNullRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOProcedureChkPntRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillBatchCodeRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillFirstMOInfoRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillInsertBatchValueRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillInsertDefaultValueRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillInsertPlanTimeByProcedureRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillMaterialRelationRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillPushDefaultValueRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillPushVersionRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillSNPkAndCodeRule; +import nc.bs.mmpac.pmo.pac0002.rule.grand.PMOCreatePlanOutputRule; +import nc.bs.mmpac.pmo.pac0002.rule.grand.PMOCreateProcedureRule; +import nc.bs.mmpac.pmo.pac0002.rule.grand.PMOSyncPlanmmNumRule; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4MPS; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4PMO; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4PSCRecive; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4PSM; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4Renovate; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4SFC; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4SO; +import nc.bs.mmpac.pmo.pac0002.rule.rewrite.RewriteInsertNum4TO; +import nc.bs.mmpac.pmo.pac0002.bp.rule.saveBeforeCheckRule; +import nc.bs.mmpub.rule.MMATOMaterialCheckRule; +import nc.bs.mmpub.rule.MMAutoMaterialAssignRule; +import nc.bs.mmpub.rule.MMBillTypeIsLockCheckRule; +import nc.bs.pubapp.pub.rule.FieldLengthCheckRule; +import nc.bs.pubapp.pub.rule.FillInsertDataRule; +import nc.bs.pubapp.pub.rule.OrgDisabledCheckRule; +import nc.impl.pubapp.bd.userdef.UserDefSaveRule; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +import nc.pubitf.sn.doc.param.SnDocParam; +import nc.util.mmf.busi.rule.MMBillCodeCheckAndTrantypeRule; +import nc.util.mmf.busi.rule.MMCheckMaterialProdModeRule; +import nc.util.mmf.busi.rule.MMCheckMaterialVirtualRule; +import nc.util.mmf.busi.rule.MMCreateBillcodeAndTrantypecodeRule; +import nc.util.mmf.busi.rule.MMRowNoCheckRule; +import nc.util.mmf.framework.gc.GCBillCloneUtil; +import nc.util.mmf.framework.gc.GCBillInsert; +import nc.util.mmf.framework.gc.GCInsertBPTemplate; +import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; +import nc.vo.mmpac.pmo.pac0002.util.PmoSagaUtil; + +public class PMOInsertBP { + public PMOAggVO[] insert(PMOAggVO[] bills, boolean issub, boolean isPush) { + AroundProcesser processer = new AroundProcesser(PMOPluginPoint.INSERT); + List updateParams = new ArrayList(); + List saveParams = new ArrayList(); + + addBeforeRule(processer, issub, isPush, updateParams, saveParams); + + addAfterRule(processer, issub, isPush, updateParams, saveParams); + GCBillInsert bo = new GCBillInsert(); + PMOAggVO[] aggvos = (PMOAggVO[]) processer.before(bills); + PMOAggVO[] newvos = (PMOAggVO[]) bo.insert(aggvos); + + PmoSagaUtil.addSagaAndCompensate4Insert(newvos); + return (PMOAggVO[]) processer.after(newvos); + } + + public void insertSagasCheck(PMOAggVO[] bills, boolean issub, boolean isPush) { + GCInsertBPTemplate bp = new GCInsertBPTemplate(PMOPluginPoint.INSERT); + + addBeforeRuleSagasCheck(bp.getAroundProcesser(), issub, isPush); + bp.getAroundProcesser().before(bills); + } + + private void addBeforeRule(AroundProcesser processer, boolean issub, boolean isPush, + List updateParams, List saveParams) { + IRule materialIsEnableRule = new CheckMaterialIsEnableRule(); + processer.addBeforeRule(materialIsEnableRule); + + OrgDisabledCheckRule orgDisabledCheckRule = new OrgDisabledCheckRule("pk_org", "FACTORYTYPE000000000"); + processer.addBeforeRule(orgDisabledCheckRule); + + FillInsertDataRule fillInsertDataRule = new FillInsertDataRule(); + processer.addBeforeRule(fillInsertDataRule); + + MMBillTypeIsLockCheckRule mMBillTypeIsLockCheckRule = new MMBillTypeIsLockCheckRule("vtrantypecode"); + processer.addBeforeRule(mMBillTypeIsLockCheckRule); + + MMAutoMaterialAssignRule mMAutoMaterialAssignRule = new MMAutoMaterialAssignRule(null, "cmaterialvid", + new String[] { "pk_org", "cplanfactoryid" }, null); + + processer.addBeforeFinalRule(mMAutoMaterialAssignRule); + + MMATOMaterialCheckRule mMATOMaterialCheckRule = new MMATOMaterialCheckRule(null, "cmaterialvid", "cffileid"); + + processer.addBeforeRule(mMATOMaterialCheckRule); + + IRule marperrule = new PMOCheckMaterialPermissionRule(); + processer.addBeforeRule(marperrule); + + MMCheckMaterialVirtualRule mMCheckMaterialVirtualRule = new MMCheckMaterialVirtualRule(); + processer.addBeforeRule(mMCheckMaterialVirtualRule); + + IRule chkrwxisrule = new PMOCheckNrwxisLogicRule(); + processer.addBeforeRule(chkrwxisrule); + + IRule chkrule = new PMOCheckSaveNotNullRule(issub); + processer.addBeforeRule(chkrule); + + IRule fillvaluerule = new PMOFillInsertDefaultValueRule(); + processer.addBeforeRule(fillvaluerule); + + processer.addBeforeRule(new PMOSyncPlanmmNumRule()); + + MMRowNoCheckRule mMRowNoCheckRule = new MMRowNoCheckRule(); + processer.addBeforeRule(mMRowNoCheckRule); + + IRule scrapAddrule = new PMOCheckParentStatusRule(); + processer.addBeforeRule(scrapAddrule); + + IRule snDuprule = new PMOSNDupCheckRule(); + processer.addBeforeRule(snDuprule); + + IRule outputrule = new PMOCreatePlanOutputRule(); + processer.addBeforeRule(outputrule); + + IRule procedurerule = new PMOCreateProcedureRule(isPush); + processer.addBeforeRule(procedurerule); + + IRule filltimeprocedurerule = new PMOFillInsertPlanTimeByProcedureRule(); + processer.addBeforeRule(filltimeprocedurerule); + + IRule daterule = new PMOCheckDateLogicRule(); + processer.addBeforeRule(daterule); + + IRule chkPntRule = new PMOProcedureChkPntRule(); + processer.addBeforeRule(chkPntRule); + + processer.addBeforeRule(new PMOCheckProdurepointRule()); + + IRule procdatelogicrule = new PMOCheckProcedureDateLogicRule(true); + processer.addBeforeRule(procdatelogicrule); + + IRule proccoderule = new PMOCheckProcedureDupRule(); + processer.addBeforeRule(proccoderule); + + IRule procPscCheckRule = new PMOCheckProcedurePSCRule(); + processer.addBeforeRule(procPscCheckRule); + + FieldLengthCheckRule fieldLengthCheckRule = new FieldLengthCheckRule(); + processer.addBeforeRule(fieldLengthCheckRule); + + UserDefSaveRule defRule = new UserDefSaveRule( + new Class[] { nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO.class }); + processer.addBeforeRule(defRule); + + MMCheckMaterialProdModeRule prodModeRule = new MMCheckMaterialProdModeRule(1, + nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO.class); + + processer.addBeforeRule(prodModeRule); + + IRule rewriteReviceRule = new RewriteInsertNum4PSCRecive(); + processer.addBeforeRule(rewriteReviceRule); + + IRule wrMarkRule = new PMOMarkWrSNWhenInsertRule(); + processer.addBeforeRule(wrMarkRule); + + IRule atprule = new PMOATPUpdateRule(true, "55A2"); + processer.addBeforeRule(atprule); + + IRule rewritewr = new RewriteInsertNum4Renovate(); + processer.addBeforeRule(rewritewr); + + IRule rewritesfc = new RewriteInsertNum4SFC(); + processer.addBeforeRule(rewritesfc); + + MMCreateBillcodeAndTrantypecodeRule mMCreateBillcodeAndTrantypecodeRule = new MMCreateBillcodeAndTrantypecodeRule( + "55A2", "vbillcode", "pk_group", "pk_org", "vtrantypecode"); + + processer.addBeforeRule(mMCreateBillcodeAndTrantypecodeRule); + + IRule fillfirstInfo = new PMOFillFirstMOInfoRule(); + processer.addBeforeRule(fillfirstInfo); + + IRule fillbatchvaluerule = new PMOFillInsertBatchValueRule(); + processer.addBeforeRule(fillbatchvaluerule); + + IRule batchcodeRule = new PMOFillBatchCodeRule(); + processer.addBeforeRule(batchcodeRule); + + PMOCffileidInserAndUpdatetRule cffileidRule = new PMOCffileidInserAndUpdatetRule(); + processer.addBeforeRule(cffileidRule); + + IRule snCheckRule = new PMOCheckSNNumAndUnitRule(); + processer.addBeforeRule(snCheckRule); + + IRule snRule = new PMOFillSNPkAndCodeRule(); + processer.addBeforeRule(snRule); + + IRule snSyncRule = new PMOSyncSNWhenInsertRule(updateParams, saveParams); + processer.addBeforeRule(snSyncRule); + + IRule checkCinwarehouseidRule = new PMOCheckCinwarehouseidRule(); + processer.addBeforeRule(checkCinwarehouseidRule); + + IRule atoCheck = new PMOATOCheckRule(); + processer.addBeforeRule(atoCheck); + + IRule procedureIRule = new PMOCheckProcedureratioRule(); + processer.addBeforeRule(procedureIRule); + + IRule saveBeforeCheckRule = new saveBeforeCheckRule(); + processer.addBeforeRule(saveBeforeCheckRule); + } + + private void addBeforeRuleSagasCheck(AroundProcesser processer, boolean issub, boolean isPush) { + OrgDisabledCheckRule orgDisabledCheckRule = new OrgDisabledCheckRule("pk_org", "FACTORYTYPE000000000"); + processer.addBeforeRule(orgDisabledCheckRule); + + FillInsertDataRule fillInsertDataRule = new FillInsertDataRule(); + processer.addBeforeRule(fillInsertDataRule); + + MMBillTypeIsLockCheckRule mMBillTypeIsLockCheckRule = new MMBillTypeIsLockCheckRule("vtrantypecode"); + processer.addBeforeRule(mMBillTypeIsLockCheckRule); + + MMATOMaterialCheckRule mMATOMaterialCheckRule = new MMATOMaterialCheckRule(null, "cmaterialvid", "cffileid"); + + processer.addBeforeRule(mMATOMaterialCheckRule); + + IRule marperrule = new PMOCheckMaterialPermissionRule(); + processer.addBeforeRule(marperrule); + + MMCheckMaterialVirtualRule mMCheckMaterialVirtualRule = new MMCheckMaterialVirtualRule(); + processer.addBeforeRule(mMCheckMaterialVirtualRule); + + IRule chkrwxisrule = new PMOCheckNrwxisLogicRule(); + processer.addBeforeRule(chkrwxisrule); + + IRule chkrule = new PMOCheckSaveNotNullRule(issub); + processer.addBeforeRule(chkrule); + + IRule fillvaluerule = new PMOFillInsertDefaultValueRule(); + processer.addBeforeRule(fillvaluerule); + + processer.addBeforeRule(new PMOSyncPlanmmNumRule()); + + MMRowNoCheckRule mMRowNoCheckRule = new MMRowNoCheckRule(); + processer.addBeforeRule(mMRowNoCheckRule); + + IRule daterule = new PMOCheckDateLogicRule(); + processer.addBeforeRule(daterule); + + IRule chkPntRule = new PMOProcedureChkPntRule(); + processer.addBeforeRule(chkPntRule); + + processer.addBeforeRule(new PMOCheckProdurepointRule()); + + IRule procdatelogicrule = new PMOCheckProcedureDateLogicRule(true); + processer.addBeforeRule(procdatelogicrule); + + IRule proccoderule = new PMOCheckProcedureDupRule(); + processer.addBeforeRule(proccoderule); + + FieldLengthCheckRule fieldLengthCheckRule = new FieldLengthCheckRule(); + processer.addBeforeRule(fieldLengthCheckRule); + + UserDefSaveRule defRule = new UserDefSaveRule( + new Class[] { nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO.class }); + processer.addBeforeRule(defRule); + + MMCheckMaterialProdModeRule prodModeRule = new MMCheckMaterialProdModeRule(1, + nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO.class); + + processer.addBeforeRule(prodModeRule); + + IRule snCheckRule = new PMOCheckSNNumAndUnitRule(); + processer.addBeforeRule(snCheckRule); + + IRule atoCheck = new PMOATOCheckRule(); + processer.addBeforeRule(atoCheck); + } + + private void addAfterRule(AroundProcesser processer, boolean issub, boolean isPush, + List updateParams, List saveParams) { + MMBillCodeCheckAndTrantypeRule mMBillCodeCheckAndTrantypeRule = new MMBillCodeCheckAndTrantypeRule("55A2", + "vbillcode", "pk_group", "pk_org", "vtrantypecode"); + + processer.addAfterRule(mMBillCodeCheckAndTrantypeRule); + + IRule duprule = new PMOCheckSCDuplicateRule(); + processer.addAfterRule(duprule); + + IRule dmoduprule = new PMOCheckDMODuplicateRule(); + processer.addAfterRule(dmoduprule); + + IRule pmorule = new RewriteInsertNum4PMO(); + processer.addAfterRule(pmorule); + + IRule rewriteso = new RewriteInsertNum4SO(); + processer.addAfterRule(rewriteso); + + IRule rewritepsm = new RewriteInsertNum4PSM(); + processer.addAfterRule(rewritepsm); + + IRule rewritepo = new RewriteInsertNum4MPS(); + processer.addAfterRule(rewritepo); + + IRule rewriteto = new RewriteInsertNum4TO(); + processer.addAfterRule(rewriteto); + + IRule atprule = new PMOATPUpdateRule(false, "55A2"); + processer.addAfterRule(atprule); + + IRule snsaverule = new PMOSaveSNWhenInsertRule(updateParams, saveParams); + processer.addAfterRule(snsaverule); + + IRule createPickmRule = new PMOCreatePickmWhenInsertRule(); + processer.addAfterRule(createPickmRule); + + IRule saveapproverule = new PMOInsertSaveApproveRule(); + processer.addAfterRule(saveapproverule); + } + + public PMOAggVO[] pushInsert(PMOAggVO[] vos, boolean issub, String pushtype) { + AroundProcesser processer = new AroundProcesser(PMOPluginPoint.PUSHINSERT); + + addPushInsertBeforeRules(processer, pushtype); + processer.before(vos); + + PMOAggVO[] aggvos = insert(vos, issub, true); + if ("PSM".equals(pushtype)) { + PMOAggVO[] cloneVos = (PMOAggVO[]) (new GCBillCloneUtil()).cloneBills(aggvos); + + PMOSplitByTaskDetailsRule createPutPlan = new PMOSplitByTaskDetailsRule(false); + createPutPlan.process(cloneVos); + } + return aggvos; + } + + public void pushInsertSagasCheck(PMOAggVO[] vos, boolean issub, String pushtype) { + AroundProcesser processer = new AroundProcesser(PMOPluginPoint.PUSHINSERT); + + addPushInsertBeforeRules(processer, pushtype); + processer.before(vos); + + insertSagasCheck(vos, issub, true); + } + + private void addPushInsertBeforeRules(AroundProcesser processer, String pushtype) { + IRule versionrule = new PMOFillPushVersionRule(); + processer.addBeforeRule(versionrule); + + IRule defaultrule = new PMOFillPushDefaultValueRule(); + processer.addBeforeRule(defaultrule); + + IRule relationrule = new PMOFillMaterialRelationRule(pushtype); + processer.addBeforeRule(relationrule); + } +} diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOPutBP.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOPutBP.java new file mode 100644 index 0000000..39b9819 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMOPutBP.java @@ -0,0 +1,105 @@ +package nc.bs.mmpac.pmo.pac0002.bp; + +import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint; +import nc.bs.mmpac.pmo.pac0002.rule.PMOFilterBillStatusRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOPutAutoAuditPickmRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDeptNotNullRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutCancelActApplyRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutCancelBatchBindRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutCancelDispatchNumRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutCancelHoldNumRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutCancelOperationRepRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckPutCancelWrNumRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOPutCancelCheckPutPlanStatusRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillBatchCodeRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillPutValueRule; +import nc.bs.mmpac.pmo.pac0002.bp.rule.putBeforeCheckRule; +import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.rule.IFilterRule; +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.mmpac.pmo.pac0002.constant.PMOConstLang; +import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; +import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFBillstatusEnum; + +public class PMOPutBP { + public PMOAggVO[] put(PMOAggVO[] fullBills, PMOAggVO[] originBills) { + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PMOPluginPoint.PUT); + + addPutBeforeRule(bp.getAroundProcesser()); + + addPutAfterRule(bp.getAroundProcesser()); + + return (PMOAggVO[]) bp.update(fullBills, originBills); + } + + private void addPutBeforeRule(CompareAroundProcesser processer) { + MMVOSagaFrozenValidateRule mMVOSagaFrozenValidateRule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(mMVOSagaFrozenValidateRule); + + IFilterRule filterStatusRule = new PMOFilterBillStatusRule(PMOConstLang.getMSG_ACTION_NO_AUDIT(), + PMOFBillstatusEnum.AUDIT); + processer.addBeforeRule(filterStatusRule); + + IRule checkDeptRule = new PMOCheckDeptNotNullRule(); + processer.addBeforeRule(checkDeptRule); + + IFilterRule pickmRule = new PMOPutAutoAuditPickmRule(); + processer.addBeforeRule(pickmRule); + + IRule fillValueRule = new PMOFillPutValueRule(false); + processer.addBeforeRule(fillValueRule); + + IRule batchcodeRule = new PMOFillBatchCodeRule(); + processer.addBeforeRule(batchcodeRule); + IRule putBeforeCheckRule = new putBeforeCheckRule(); + processer.addBeforeRule(putBeforeCheckRule); + } + + private void addPutAfterRule(CompareAroundProcesser processer) { + } + + public PMOAggVO[] putCancel(PMOAggVO[] fullBills, PMOAggVO[] originBills) { + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PMOPluginPoint.UNPUT); + + addPutCancelBeforeRule(bp.getAroundProcesser()); + + addPutCancelAfterRule(bp.getAroundProcesser()); + + return (PMOAggVO[]) bp.update(fullBills, originBills); + } + + private void addPutCancelBeforeRule(CompareAroundProcesser processer) { + IFilterRule filterStatusRule = new PMOFilterBillStatusRule(PMOConstLang.getMSG_ACTION_NO_AUDIT(), + PMOFBillstatusEnum.AUDIT); + processer.addBeforeRule(filterStatusRule); + + IRule checkWRNumRule = new PMOCheckPutCancelWrNumRule(); + processer.addBeforeRule(checkWRNumRule); + + IRule checkActApplyRule = new PMOCheckPutCancelActApplyRule(); + processer.addBeforeRule(checkActApplyRule); + + IRule checkHoldNumRule = new PMOCheckPutCancelHoldNumRule(); + processer.addBeforeRule(checkHoldNumRule); + + IRule checkBatchBindRule = new PMOCheckPutCancelBatchBindRule(); + processer.addBeforeRule(checkBatchBindRule); + + IRule fillValueRule = new PMOFillPutValueRule(true); + processer.addBeforeRule(fillValueRule); + + IRule checkDispatchNumRule = new PMOCheckPutCancelDispatchNumRule(); + processer.addBeforeRule(checkDispatchNumRule); + + IRule checkOperationRepRule = new PMOCheckPutCancelOperationRepRule(); + processer.addBeforeRule(checkOperationRepRule); + + IRule putCancelCheckPutPlanStatusRule = new PMOPutCancelCheckPutPlanStatusRule(); + processer.addBeforeRule(putCancelCheckPutPlanStatusRule); + } + + private void addPutCancelAfterRule(CompareAroundProcesser processer) { + } +} diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMORowPutBP.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMORowPutBP.java new file mode 100644 index 0000000..b613ad0 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/PMORowPutBP.java @@ -0,0 +1,122 @@ +package nc.bs.mmpac.pmo.pac0002.bp; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import nc.bs.mmpac.pmo.pac0002.bp.service.PMOBPService; +import nc.bs.mmpac.pmo.pac0002.bp.util.PMOBPUtil; +import nc.bs.mmpac.pmo.pac0002.pluginpoint.PMOPluginPoint; +import nc.bs.mmpac.pmo.pac0002.rule.PMOFilterBillStatusRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOFilterRowStatusRule; +import nc.bs.mmpac.pmo.pac0002.rule.PMOPutAutoAuditPickmRule; +import nc.bs.mmpac.pmo.pac0002.rule.check.PMOCheckDeptNotNullRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillBatchCodeRule; +import nc.bs.mmpac.pmo.pac0002.rule.fill.PMOFillPutValueRule; +import nc.bs.mmpac.pmo.pac0002.bp.rule.putBeforeCheckRule; +import nc.bs.mmpub.rule.MMVOSagaFrozenValidateRule; +import nc.impl.pubapp.pattern.data.vo.tool.VOConcurrentTool; +import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser; +import nc.util.mmf.framework.gc.GCBillConcurrentTool; +import nc.util.mmf.framework.gc.GCBillTransferTool; +import nc.util.mmf.framework.gc.GCBillUpdate; +import nc.util.mmf.framework.gc.GCUpdateBPTemplate; +import nc.vo.mmpac.pmo.pac0002.constant.PMOConstLang; +import nc.vo.mmpac.pmo.pac0002.entity.PMOAggVO; +import nc.vo.mmpac.pmo.pac0002.entity.PMOItemVO; +import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFBillstatusEnum; +import nc.vo.mmpac.pmo.pac0002.enumeration.PMOFItemStatusEnum; +import nc.vo.pub.CircularlyAccessibleValueObject; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; + +public class PMORowPutBP { + public PMOAggVO[] rowput(PMOAggVO[] vos) { + try { + GCBillConcurrentTool lockTool = new GCBillConcurrentTool(); + lockTool.lockBill(vos); + + (new VOConcurrentTool()).checkTSWithDB(vos[0].getChildrenVO()); + + GCUpdateBPTemplate bp = new GCUpdateBPTemplate(PMOPluginPoint.ROWPUT); + CompareAroundProcesser processer = bp.getAroundProcesser(); + + addRowPutBeforeRule(processer); + + addRowPutAfterRule(processer); + + PMOAggVO[] returnvos = (PMOAggVO[]) processer.before(vos, vos); + + List upditemList = new ArrayList(); + Map upditemMap = new HashMap(); + for (PMOAggVO aggvo : returnvos) { + PMOItemVO[] items = aggvo.getChildrenVO(); + for (PMOItemVO item : items) { + upditemList.add(item); + upditemMap.put(item.getCmoid(), item); + } + } + PMOAggVO aggvo = PMOBPService.getIPMOQueryService().queryByPk(vos[0].getParentVO().getCpmohid()); + + PMOItemVO[] olditems = aggvo.getChildrenVO(); + List tempitems = new ArrayList(); + for (PMOItemVO item : olditems) { + if (!upditemMap.containsKey(item.getCmoid())) { + tempitems.add(item); + } else { + + ((PMOItemVO) upditemMap.get(item.getCmoid())).setStatus(1); + PMOBPUtil.setGrandVOStatusUpdate((PMOItemVO) upditemMap.get(item.getCmoid())); + tempitems.add((PMOItemVO) upditemMap.get(item.getCmoid())); + } + } + aggvo.setChildrenVO((CircularlyAccessibleValueObject[]) tempitems.toArray(new PMOItemVO[tempitems.size()])); + + PMOAggVO[] aggvos = { aggvo }; + + GCBillTransferTool transferTool = new GCBillTransferTool(aggvos); + PMOAggVO[] originBills = (PMOAggVO[]) transferTool.getOriginBills(); + GCBillUpdate billupdate = new GCBillUpdate(); + PMOAggVO[] newaggvos = (PMOAggVO[]) billupdate.update(aggvos, originBills); + + PMOItemVO[] totalitems = newaggvos[0].getChildrenVO(); + Map newitemMap = new HashMap(); + for (PMOItemVO item : totalitems) { + if (upditemMap.containsKey(item.getCmoid())) { + newitemMap.put(item.getCmoid(), item); + } + } + returnvos[0] + .setChildrenVO((CircularlyAccessibleValueObject[]) newitemMap.values().toArray(new PMOItemVO[0])); + + processer.after(returnvos, returnvos); + + PMOAggVO newaggvo = PMOBPService.getIPMOQueryService().queryByPk(vos[0].getParentVO().getCpmohid()); + + return new PMOAggVO[] { newaggvo }; + + } catch (Exception e) { + ExceptionUtils.wrappException(e); + + return null; + } + } + + private void addRowPutBeforeRule(CompareAroundProcesser processer) { + MMVOSagaFrozenValidateRule mMVOSagaFrozenValidateRule = new MMVOSagaFrozenValidateRule(true); + processer.addBeforeRule(mMVOSagaFrozenValidateRule); + processer.addBeforeRule( + new PMOFilterBillStatusRule(PMOConstLang.getMSG_ACTION_NO_AUDIT(), PMOFBillstatusEnum.AUDIT)); + + processer.addBeforeRule( + new PMOFilterRowStatusRule(PMOConstLang.getMSG_RULE_NO_ROWDATA(), PMOFItemStatusEnum.AUDIT)); + + processer.addBeforeRule(new PMOCheckDeptNotNullRule()); + processer.addBeforeRule(new PMOPutAutoAuditPickmRule()); + processer.addBeforeRule(new PMOFillPutValueRule(false)); + processer.addBeforeRule(new PMOFillBatchCodeRule()); + processer.addBeforeRule(new putBeforeCheckRule()); + } + + private void addRowPutAfterRule(CompareAroundProcesser processer) { + } +} diff --git a/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/putBeforeCheckRule.java b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/putBeforeCheckRule.java new file mode 100644 index 0000000..d1f1f11 --- /dev/null +++ b/mmpac/src/private/nc/bs/mmpac/pmo/pac0002/bp/rule/putBeforeCheckRule.java @@ -0,0 +1,111 @@ +package nc.bs.mmpac.pmo.pac0002.bp.rule; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import nc.bs.framework.common.NCLocator; +import nc.impl.pubapp.pattern.rule.IRule; +import nc.itf.uap.IUAPQueryBS; +import nc.itf.uif.pub.IUifService; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.jdbc.framework.processor.MapProcessor; +import nc.vo.ic.m4c.entity.SaleOutHeadVO; +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.so.m30.entity.SaleOrderBVO; +//import nc.bs.rbac.bizlistener.BaseDocDataPermChangeEventListener; +//import nc.impl.mmpac.pmo.pac0002.PMOTransTypeQueryServiceImpl; +//import nc.impl.mmpac.bcrule.predata.BarCodeDataInitListener; +//import nc.ui.mmpub.setanalysis.action.SaAnalysisAction.actionPerformed;//流程生产订单齐套分析-分析 + +//import nc.impl.mmpub.setanalysis.SetAnalysisServiceImpl; +import nc.bs.mmpac.pmo.pac0002.bp.PMORowPutBP; +import nccloud.web.mmpac.pmo.action.PmoCardPutAction; + + +public class putBeforeCheckRule implements IRule { + + private static IUifService service = (IUifService) NCLocator.getInstance() + .lookup(IUifService.class.getName()); + + @Override + public void process(PMOAggVO[] vos) { + try { + // TODO Auto-generated method stub + List list = new ArrayList(); + for (PMOAggVO vo : vos) { + //判断是否是需要控制的业务单元 + PMOHeadVO pmoHeadVO = vo.getParentVO(); + String pkstockorgStr = getPk_stockorg(pmoHeadVO.getPk_org()); + if (pkstockorgStr == null || pkstockorgStr.equals("")) { + return; + } + PMOItemVO[] iSuperVOs = vo.getChildrenVO(); + for (int i = 0; i < iSuperVOs.length; i++) { + PMOItemVO itemvo = iSuperVOs[i]; + //判断是否类型是否为30 + if (itemvo.getVsrctype() == null || !itemvo.getVsrctype().equals("30")) { + return; + } + Map valMap = getVbdef6(itemvo.getVsrcbid()); + //销售发票表头pk_billtypecode=30-Cxx-12 + if (valMap.get("pk_billtypecode").equals("30-Cxx-12")||valMap.get("pk_billtypecode").equals("30-Cxx-02")||valMap.get("pk_billtypecode").equals("30-Cxx-08")||valMap.get("pk_billtypecode").equals("30-Cxx-13")) { + return; + } + //历史数据不考虑 + String storedDateStr = (String) valMap.get("creationtime"); + String targetDateStr = "2024-12-31 00:00:00"; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime storedDate = LocalDateTime.parse(storedDateStr, formatter); + LocalDateTime targetDate = LocalDateTime.parse(targetDateStr, formatter); + if (storedDate.isBefore(targetDate)) { + return; + } + String vdef4Str = itemvo.getVdef4();//齐套率 + String vdef4 = (vdef4Str != null) ? vdef4Str.toString() : ""; + double vdef4qty = (vdef4.isEmpty()) ? 0 : Double.parseDouble(vdef4);//齐套率 + String vdef10Str = itemvo.getVdef10();//齐套率标准 + String vdef10 = (vdef10Str != null) ? vdef10Str.toString() : ""; + double vdef10qty = (vdef10.isEmpty()) ? 0 : Double.parseDouble(vdef10);//齐套率标准 + if (vdef4qty < vdef10qty) { + throw new BusinessException( + "齐套率" + vdef4qty + "小于齐套率标准'" + vdef10qty + "',无法保存!"); + } + + } + } + } catch (BusinessException e) { + throw new RuntimeException(e); + } + } + + private Map getVbdef6(String vsrcbidStr) throws BusinessException { + IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); + String sql = " SELECT bt.pk_billtypecode,s.creationtime,b.vbdef12,d.nastnum FROM so_saleorder_b b\n" + + "INNER JOIN so_saleorder s ON s.csaleorderid = b.csaleorderid\n" + + "left join (select mm_mo.Vsrcbid,sum(nastnum) as nastnum \n" + + "from mm_mo\n" + + "where mm_mo.dr=0\n" + + "group by mm_mo.Vsrcbid) d on b.csaleorderbid=d.Vsrcbid\n" + + "INNER JOIN bd_billtype bt on bt.pk_billtypeid=s.ctrantypeid\n" + + "where b.csaleorderbid='" + vsrcbidStr + "' "; + Map valList = (Map) queryBS.executeQuery(sql, new MapProcessor()); + return valList; + } + + private String getPk_stockorg(String pk_stockorg) throws BusinessException { + String sql = + " select pk_stockorg from org_stockorg where code in ('C018','C029','C033','C039','C020','C019') and pk_stockorg='" + + pk_stockorg + "' "; + String saleorderPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor()); + return saleorderPK; + } + + public IUAPQueryBS getQueryService() { + return NCLocator.getInstance().lookup(IUAPQueryBS.class); + } +} From 7e2a1464ac176df8be391ef25a8c94720d341363 Mon Sep 17 00:00:00 2001 From: "zhangxinah@yonyou.com" Date: Thu, 27 Mar 2025 09:42:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/nc/bd/itf/tools/BFPubTools.java | 233 ++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 mmpac/src/public/nc/bd/itf/tools/BFPubTools.java diff --git a/mmpac/src/public/nc/bd/itf/tools/BFPubTools.java b/mmpac/src/public/nc/bd/itf/tools/BFPubTools.java new file mode 100644 index 0000000..a5daf91 --- /dev/null +++ b/mmpac/src/public/nc/bd/itf/tools/BFPubTools.java @@ -0,0 +1,233 @@ +package nc.bd.itf.tools; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDateTime; +import nc.vo.pub.lang.UFDouble; + +public class BFPubTools +{ + public static UFDouble ZERO = UFDouble.ZERO_DBL; + + public static boolean isEmpty(String value) + { + return (value == null) || (value.trim().length() == 0); + } + + public static UFBoolean getUFBoolean_NullAs(Object value, UFBoolean bDefautValue) + { + if ((value == null) || (value.toString().trim().equals(""))) + return bDefautValue; + if ((value instanceof UFBoolean)) { + return (UFBoolean)value; + } + return new UFBoolean(value.toString().trim()); + } + + public static UFDate getUFDate(Object value) + { + if ((value == null) || (value.toString().trim().equals(""))) + return null; + if ((value instanceof UFDate)) { + return (UFDate)value; + } + return new UFDate(value.toString().trim()); + } + + public static UFDateTime getUFDateTime(Object value) + { + if ((value == null) || (value.toString().trim().equals(""))) + return null; + if ((value instanceof UFDateTime)) { + return (UFDateTime)value; + } + return new UFDateTime(value.toString().trim()); + } + + public static UFDouble getUFDouble_NullAsZero(Object value) + { + if ((value == null) || (value.toString().trim().equals("")) || (value.toString().trim().equals("~"))) + return ZERO; + if ((value instanceof UFDouble)) + return (UFDouble)value; + if ((value instanceof BigDecimal)) { + return new UFDouble((BigDecimal)value); + } + return new UFDouble(value.toString().trim()); + } + + public static UFDouble getUFDouble_ValueAsValue(double dValue) + { + if (dValue == 0.0D) { + return ZERO; + } + return new UFDouble(dValue); + } + + public static UFDouble getUFDouble_ValueAsValue(Object value) + { + if ((value == null) || (value.toString().trim().equals(""))) + return null; + if ((value instanceof UFDouble)) + return (UFDouble)value; + if ((value instanceof BigDecimal)) { + return new UFDouble((BigDecimal)value); + } + return new UFDouble(value.toString().trim()); + } + + public static UFDouble getUFDouble_ZeroAsNull(double dValue) + { + if (dValue == 0.0D) { + return null; + } + return new UFDouble(dValue); + } + + public static UFDouble getUFDouble_ZeroAsNull(Object value) + { + UFDouble dValue = getUFDouble_NullAsZero(value); + if (dValue.compareTo(ZERO) == 0) { + return null; + } + return dValue; + } + + public static String getString_TrimZeroLenAsNull(Object value) + { + if ((value == null) || (value.toString().trim().length() == 0)) { + return null; + } + return value.toString().trim(); + } + + public static String getString_TrimZeroLenAs(Object value, String str) + { + if ((value == null) || (value.toString().trim().length() == 0)) { + return str; + } + return value.toString().trim(); + } + + public static String getString_TrimAsNull(Object value) { + if ((value == null) || (value.toString().trim().length() == 0)) { + return ""; + } + return value.toString().trim(); + } + + public static String getInStr(Collection coll) + { + String intStr = null; + if ((coll != null) && (coll.size() > 0)) { + StringBuilder sb = new StringBuilder(); + String[] values = (String[])coll.toArray(new String[0]); + for (int i = 0; i < values.length; i++) { + sb.append("'").append(values[i]).append("'"); + if (i < values.length - 1) + sb.append(","); + } + intStr = sb.toString(); + } + return intStr; + } + + public static String getInSqlWithOutAnd(String sFieldName, ArrayList alValue, int start, int num) + { + if ((sFieldName == null) || (sFieldName.trim().length() == 0) || + (alValue == null) || (start < 0) || (num < 0)) + return null; + StringBuffer sbSQL = new StringBuffer(200); + sbSQL.append(" (").append(sFieldName).append(" IN ("); + int end = start + num; + for (int i = start; i < end; i++) { + if ((alValue.get(i) != null) && + (alValue.get(i).toString().trim().length() > 0)) { + sbSQL.append("'").append(alValue.get(i)).append("'"); + if ((i != alValue.size() - 1) && ((i <= 0) || (i % 200 != 0))) + sbSQL.append(","); + } else { + return null; + } + if ((i > 0) && (i % 200 == 0)) + sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( "); + } + sbSQL.append(" ) )"); + return sbSQL.toString(); + } + public static String getInSqlWithOutAnd(String sFieldName, List alValue, int start, int num) + { + if ((sFieldName == null) || (sFieldName.trim().length() == 0) || + (alValue == null) || (start < 0) || (num < 0)) + return null; + StringBuffer sbSQL = new StringBuffer(200); + sbSQL.append(" (").append(sFieldName).append(" IN ("); + int end = start + num; + for (int i = start; i < end; i++) { + if ((alValue.get(i) != null) && + (alValue.get(i).toString().trim().length() > 0)) { + sbSQL.append("'").append(alValue.get(i)).append("'"); + if ((i != alValue.size() - 1) && ((i <= 0) || (i % 200 != 0))) + sbSQL.append(","); + } else { + return null; + } + if ((i > 0) && (i % 200 == 0)) + sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( "); + } + sbSQL.append(" ) )"); + return sbSQL.toString(); + } + public static String getInSqlWithOutAnd(String sFieldName, String[] saValue, int start, int num) + { + if ((sFieldName == null) || (sFieldName.trim().length() == 0) || + (saValue == null) || (start < 0) || (num < 0) || + (saValue.length < start + num)) + return null; + StringBuffer sbSQL = new StringBuffer(200); + sbSQL.append(" (").append(sFieldName).append(" IN ( "); + int end = start + num; + for (int i = start; i < end; i++) { + if ((saValue[i] != null) && (saValue[i].trim().length() > 0)) { + sbSQL.append("'").append(saValue[i]).append("'"); + if ((i != saValue.length - 1) && ((i <= 0) || (i % 200 != 0))) + sbSQL.append(","); + } else { + return null; + } + if ((i > 0) && (i % 200 == 0)) + sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( "); + } + sbSQL.append(" ) )"); + return sbSQL.toString(); + } + + public static String getInSqlWithOutAnd(String sFieldName, Object[] oValue, int start, int num) { + if ((sFieldName == null) || (sFieldName.trim().length() == 0) || + (oValue == null) || (start < 0) || (num < 0) || + (oValue.length < start + num)) + return null; + StringBuffer sbSQL = new StringBuffer(200); + sbSQL.append(" (").append(sFieldName).append(" IN ( "); + int end = start + num; + for (int i = start; i < end; i++) { + String sValue = getString_TrimZeroLenAsNull(oValue); + if (oValue[i] != null) { + sbSQL.append("'").append(sValue).append("'"); + if ((i != oValue.length - 1) && ((i <= 0) || (i % 200 != 0))) + sbSQL.append(","); + } else { + return null; + } + if ((i > 0) && (i % 200 == 0)) + sbSQL.append(" ) OR ").append(sFieldName).append(" IN ( "); + } + sbSQL.append(" ) )"); + return sbSQL.toString(); + } +} \ No newline at end of file From 0cda105fe0380cbb6e65d0d5b226035ef2532fab Mon Sep 17 00:00:00 2001 From: "zhangxinah@yonyou.com" Date: Thu, 27 Mar 2025 11:36:50 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=89=A9=E6=96=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=80=82=E9=85=8D2312?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/MaterialManageMaterial.java | 547 ++++++++++++++++++ 1 file changed, 547 insertions(+) create mode 100644 uapbd/src/public/nccloud/api/uapbd/materialmanage/material/MaterialManageMaterial.java diff --git a/uapbd/src/public/nccloud/api/uapbd/materialmanage/material/MaterialManageMaterial.java b/uapbd/src/public/nccloud/api/uapbd/materialmanage/material/MaterialManageMaterial.java new file mode 100644 index 0000000..e8b4178 --- /dev/null +++ b/uapbd/src/public/nccloud/api/uapbd/materialmanage/material/MaterialManageMaterial.java @@ -0,0 +1,547 @@ +package nccloud.api.uapbd.materialmanage.material; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import nc.bs.dao.BaseDAO; +import nc.ws.opm.pub.utils.result.APIErrCodeEnum; +import nc.bs.dao.DAOException; +import nc.bs.framework.common.NCLocator; +import nc.bs.framework.core.util.ObjectCreator; +import nc.impl.pubapp.pattern.database.SqlBuilderUtil; +import nc.itf.bd.material.assign.IMaterialAssignService; +import nc.jdbc.framework.processor.ColumnListProcessor; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.prod.MaterialProdVO; +import nc.vo.bd.material.sale.MaterialSaleVO; +import nc.vo.bd.material.stock.MaterialStockVO; +import nccloud.api.baseapp.exchange.convert.IOpenApiJsonConvertToExChangeXmlService; +import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataObject; +import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataResult; +import nccloud.api.rest.utils.ApiResourceParamUtils; +import nccloud.api.rest.utils.IParamTranslator; +import nccloud.api.rest.utils.OpenApiPageInfo; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.api.uapbd.common.utils.OpenApiPagenationUtils; +import nccloud.commons.lang.StringUtils; +import nc.jdbc.framework.processor.MapListProcessor; +import nccloud.ws.rest.resource.AbstractNCCRestResource; +import org.json.JSONString; + +/** + * 物料接口适配2312 + */ + +@Path("uapbd/material/material") +public class MaterialManageMaterial extends AbstractNCCRestResource { + private static final String defbilltype = "material"; + + @POST + @Path("add") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString addMaterial(JSONString json) { + return process(json); + } + + /** + * + * @param json {"code":"COM24111300019","version":"1","pk_org":"PLM"} + * @return + */ + @POST + @Path("queryMaterialIsExist") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + + public JSONString queryMaterialIsExist(JSONString json) { + + boolean bool = false;// false 不存在 true 存在 + + JSONObject jObject = JSONObject.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + + if (StringUtils.isEmpty(jObject.getString("code"))) { + return ResultMessageUtil.exceptionToJSON("code 不能为空", APIErrCodeEnum.UNKNOWEXCCODE.getCode()); + } + String code = jObject.getString("code"); + String version = jObject.getString("version"); + String pk_org = jObject.getString("pk_org");// 所属组织编码 + + String sql = "select bd_material.code,bd_material.version,org_orgs.code From bd_material , org_orgs where bd_material.pk_org=org_orgs.pk_org and bd_material.code='" + + code + "'"; + + if (!StringUtils.isEmpty(version)) { + sql += " and bd_material.version ='" + jObject.get("version") + "'"; + } + + if (!StringUtils.isEmpty(pk_org)) { + sql += " and org_orgs.code ='" + jObject.get("pk_org") + "'"; + } + + try { + ArrayList> lists = (ArrayList>) new BaseDAO() + .executeQuery(sql, new MapListProcessor()); + if (lists != null && lists.size() > 0) { + bool = true; + return ResultMessageUtil.toJSONUnTranslate(bool); + } else { + bool = false; + return ResultMessageUtil.toJSONUnTranslate(bool, "没有符合条件的数据"); + } + } catch (DAOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return ResultMessageUtil.toJSONUnTranslate(bool); + + } + + @POST + @Path("update") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString updateMaterial(JSONString json) { + return process(json); + } + + @POST + @Path("queryMaterial") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString queryMaterial(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jObject.getJSONObject("ufinterface"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } + + JSONObject data = bject.getJSONObject("data"); + String pk_group = data.getString("pk_group"); + JSONArray pk_orgs = data.getJSONArray("pk_org"); + JSONArray code = data.getJSONArray("code"); + JSONArray name = data.getJSONArray("name"); + JSONArray marbaseclass = data.getJSONArray("marbaseclass"); + String enablestate = data.getString("enablestate"); + String ts = data.getString("ts"); + JSONObject pageInfo = data.getJSONObject("pageInfo"); + Map param = new HashMap(); + + if (StringUtils.isNotBlank(pk_group)) { + param.put("pk_group", pk_group); + } + if (StringUtils.isNotBlank(enablestate)) { + param.put("enablestate", enablestate); + } + if (StringUtils.isNotBlank(ts)) { + param.put("ts", ts); + } + if (pk_orgs != null && pk_orgs.size() > 0) { + param.put("pk_org", pk_orgs.toArray(new String[0])); + } + if (code != null && code.size() > 0) { + param.put("code", code.toArray(new String[0])); + } + if (name != null && name.size() > 0) { + param.put("name", name.toArray(new String[0])); + } + if (marbaseclass != null && marbaseclass.size() > 0) { + param.put("marbaseclass", marbaseclass.toArray(new String[0])); + } + try { + ApiResourceParamUtils ApiResourceParamUtils = new ApiResourceParamUtils(); + IParamTranslator IParamTranslator = (IParamTranslator) ObjectCreator.newInstance("uapbd", + nccloud.api.uapbd.translator.OrgParamTranslator.class.getName()); + ApiResourceParamUtils.addTranslatorMap("pk_org", IParamTranslator); + String condition = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + + String sql = "select pk_material from bd_material where " + condition; + List allPks = (List) (new BaseDAO()).executeQuery(sql, new ColumnListProcessor()); + OpenApiPageInfo openApiPageInfo = new OpenApiPageInfo(); + String[] currPks = OpenApiPagenationUtils.getCurrentPagePksAndPageInfo(allPks, pageInfo, openApiPageInfo); + if (currPks == null || currPks.length == 0) { + return ResultMessageUtil.toJSON(null); + } + + SqlBuilderUtil SqlBuilderUtil = new SqlBuilderUtil(); + String wherepart = SqlBuilderUtil.buildSQL("pk_material", currPks, null); + + MaterialVO[] vos = (MaterialVO[]) (new BaseDAO()).retrieveByClause(MaterialVO.class, wherepart) + .toArray(new MaterialVO[0]); + ResultMessageUtil.toJSONByPage(vos, openApiPageInfo, false); + return ResultMessageUtil.toJSONByPage(vos, openApiPageInfo, false); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + @POST + @Path("assignMaterial") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString assignMaterial(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jObject.getJSONObject("ufinterface"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } + + JSONObject data = bject.getJSONObject("data"); + String pk_org = data.getString("pk_org"); + String code = data.getString("code"); + String version = data.getString("version"); + JSONArray assignorgs = data.getJSONArray("assignorgs"); + + JSONObject pageInfo = data.getJSONObject("pageInfo"); + Map param = new HashMap(); + + if (StringUtils.isBlank(pk_org) && StringUtils.isBlank(code) && StringUtils.isBlank(version)) { + return ResultMessageUtil.exceptionToJSON(new Exception("所属组织、物料编码、版本号,不能同时为空")); + } + if (assignorgs == null || (assignorgs != null && assignorgs.size() <= 0)) { + return ResultMessageUtil.exceptionToJSON(new Exception("分配组织不能为空")); + } + if (StringUtils.isNotBlank(pk_org)) { + param.put("pk_org", pk_org); + } + if (StringUtils.isNotBlank(code)) { + param.put("code", code); + } + if (StringUtils.isNotBlank(version)) { + param.put("version", version); + } + try { + ApiResourceParamUtils ApiResourceParamUtils = new ApiResourceParamUtils(); + IParamTranslator IParamTranslator = (IParamTranslator) ObjectCreator.newInstance("uapbd", + nccloud.api.uapbd.translator.OrgParamTranslator.class.getName()); + ApiResourceParamUtils.addTranslatorMap("pk_org", IParamTranslator); + String condition = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + + MaterialVO[] vos = (MaterialVO[]) (new BaseDAO()).retrieveByClause(MaterialVO.class, condition) + .toArray(new MaterialVO[0]); + if (vos == null || (vos != null && vos.length <= 0)) { + return ResultMessageUtil.exceptionToJSON(new Exception("未查询到物料信息")); + } + IMaterialAssignService IMaterialAssignService = (IMaterialAssignService) NCLocator.getInstance() + .lookup(IMaterialAssignService.class); + if (vos != null && vos.length > 0) { + List pk_materials = new ArrayList(); + for (MaterialVO vo : vos) { + pk_materials.add(vo.getPk_material()); + } + if (assignorgs != null && assignorgs.size() > 0) { + List pk_orgs = IParamTranslator.translateByCode(null, + (String[]) assignorgs.toArray(new String[0])); + IMaterialAssignService.assignMaterialByPks((String[]) pk_materials.toArray(new String[0]), + (String[]) pk_orgs.toArray(new String[0]), null); + } + } + return ResultMessageUtil.toJSON(null, "分配成功!"); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + @POST + @Path("queryMaterialsale") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString queryMaterialsale(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jObject.getJSONObject("ufinterface"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } + + JSONObject data = bject.getJSONObject("data"); + String pk_org = data.getString("pk_org"); + String code = data.getString("code"); + String version = data.getString("version"); + JSONArray saleorgs = data.getJSONArray("saleorgs"); + JSONObject pageInfo = data.getJSONObject("pageInfo"); + Map param = new HashMap(); + + if (StringUtils.isNotBlank(pk_org)) { + param.put("pk_org", pk_org); + } + if (StringUtils.isNotBlank(code)) { + param.put("code", code); + } + if (StringUtils.isNotBlank(version)) { + param.put("version", version); + } + + if (StringUtils.isBlank(pk_org) && StringUtils.isBlank(code)) { + return ResultMessageUtil.exceptionToJSON(new Exception("所属组织和编码 pk_org、code不能同时为空")); + } + + if (saleorgs == null || saleorgs.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("saleorgs:" + saleorgs + ",不能为空")); + } + try { + ApiResourceParamUtils ApiResourceParamUtils = new ApiResourceParamUtils(); + IParamTranslator IParamTranslator = (IParamTranslator) ObjectCreator.newInstance("uapbd", + nccloud.api.uapbd.translator.OrgParamTranslator.class.getName()); + ApiResourceParamUtils.addTranslatorMap("pk_org", IParamTranslator); + String condition = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + MaterialVO[] vos = (MaterialVO[]) (new BaseDAO()).retrieveByClause(MaterialVO.class, condition) + .toArray(new MaterialVO[0]); + + if (vos != null && vos.length > 0) { + List materialpks = new ArrayList(); + for (MaterialVO vo : vos) { + materialpks.add(vo.getPk_material()); + } + param.clear(); + param.put("pk_material", materialpks.toArray(new String[0])); + if (saleorgs != null && saleorgs.size() > 0) { + param.put("pk_org", saleorgs.toArray(new String[0])); + } + String condition1 = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + + String sql = "select pk_materialsale from bd_materialsale where " + condition1; + List allPks = (List) (new BaseDAO()).executeQuery(sql, new ColumnListProcessor()); + OpenApiPageInfo openApiPageInfo = new OpenApiPageInfo(); + String[] currPks = OpenApiPagenationUtils.getCurrentPagePksAndPageInfo(allPks, pageInfo, + openApiPageInfo); + if (currPks == null || currPks.length == 0) { + return ResultMessageUtil.toJSON(null); + } + + SqlBuilderUtil SqlBuilderUtil = new SqlBuilderUtil(); + String wherepart = SqlBuilderUtil.buildSQL("pk_materialsale", currPks, null); + + MaterialSaleVO[] salevos = (MaterialSaleVO[]) (new BaseDAO()) + .retrieveByClause(MaterialSaleVO.class, wherepart).toArray(new MaterialSaleVO[0]); + return ResultMessageUtil.toJSONByPage(salevos, openApiPageInfo, false); + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return null; + } + + @POST + @Path("queryMaterialprod") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString queryMaterialprod(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jObject.getJSONObject("ufinterface"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } + + JSONObject data = bject.getJSONObject("data"); + String pk_org = data.getString("pk_org"); + String code = data.getString("code"); + String version = data.getString("version"); + JSONArray prodorgs = data.getJSONArray("prodorgs"); + JSONObject pageInfo = data.getJSONObject("pageInfo"); + Map param = new HashMap(); + + if (StringUtils.isNotBlank(pk_org)) { + param.put("pk_org", pk_org); + } + if (StringUtils.isNotBlank(code)) { + param.put("code", code); + } + if (StringUtils.isNotBlank(version)) { + param.put("version", version); + } + if (StringUtils.isBlank(pk_org) && StringUtils.isBlank(code)) { + return ResultMessageUtil.exceptionToJSON(new Exception("所属组织和编码 pk_org、code不能同时为空")); + } + if (prodorgs == null || prodorgs.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new Exception("prodorgs:" + prodorgs + ",不能为空")); + } + try { + ApiResourceParamUtils ApiResourceParamUtils = new ApiResourceParamUtils(); + IParamTranslator IParamTranslator = (IParamTranslator) ObjectCreator.newInstance("uapbd", + nccloud.api.uapbd.translator.OrgParamTranslator.class.getName()); + ApiResourceParamUtils.addTranslatorMap("pk_org", IParamTranslator); + String condition = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + MaterialVO[] vos = (MaterialVO[]) (new BaseDAO()).retrieveByClause(MaterialVO.class, condition) + .toArray(new MaterialVO[0]); + + if (vos != null && vos.length > 0) { + List materialpks = new ArrayList(); + for (MaterialVO vo : vos) { + materialpks.add(vo.getPk_material()); + } + param.clear(); + param.put("pk_material", materialpks.toArray(new String[0])); + if (prodorgs != null && prodorgs.size() > 0) { + param.put("pk_org", prodorgs.toArray(new String[0])); + } + String condition1 = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + + String sql = "select pk_materialprod from bd_materialprod where " + condition1; + List allPks = (List) (new BaseDAO()).executeQuery(sql, new ColumnListProcessor()); + OpenApiPageInfo openApiPageInfo = new OpenApiPageInfo(); + String[] currPks = OpenApiPagenationUtils.getCurrentPagePksAndPageInfo(allPks, pageInfo, + openApiPageInfo); + if (currPks == null || currPks.length == 0) { + return ResultMessageUtil.toJSON(null); + } + + SqlBuilderUtil SqlBuilderUtil = new SqlBuilderUtil(); + String wherepart = SqlBuilderUtil.buildSQL("pk_materialprod", currPks, null); + MaterialProdVO[] prodvos = (MaterialProdVO[]) (new BaseDAO()) + .retrieveByClause(MaterialProdVO.class, wherepart).toArray(new MaterialProdVO[0]); + return ResultMessageUtil.toJSONByPage(prodvos, openApiPageInfo, false); + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return null; + } + + @POST + @Path("queryMaterialstock") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString queryMaterialstock(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jObject.getJSONObject("ufinterface"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } + + JSONObject data = bject.getJSONObject("data"); + String pk_org = data.getString("pk_org"); + String code = data.getString("code"); + String version = data.getString("version"); + JSONArray stockorgs = data.getJSONArray("stockorgs"); + JSONObject pageInfo = data.getJSONObject("pageInfo"); + Map param = new HashMap(); + + if (StringUtils.isNotBlank(pk_org)) { + param.put("pk_org", pk_org); + } + if (StringUtils.isNotBlank(code)) { + param.put("code", code); + } + if (StringUtils.isNotBlank(version)) { + param.put("version", version); + } + + if (StringUtils.isBlank(pk_org) && StringUtils.isBlank(code)) { + return ResultMessageUtil.exceptionToJSON(new Exception("所属组织和编码 pk_org、code不能同时为空")); + } + + if (stockorgs == null || stockorgs.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new Exception("stockorgs:" + stockorgs + ",不能为空")); + } + try { + ApiResourceParamUtils ApiResourceParamUtils = new ApiResourceParamUtils(); + IParamTranslator IParamTranslator = (IParamTranslator) ObjectCreator.newInstance("uapbd", + nccloud.api.uapbd.translator.OrgParamTranslator.class.getName()); + ApiResourceParamUtils.addTranslatorMap("pk_org", IParamTranslator); + String condition = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + MaterialVO[] vos = (MaterialVO[]) (new BaseDAO()).retrieveByClause(MaterialVO.class, condition) + .toArray(new MaterialVO[0]); + + if (vos != null && vos.length > 0) { + List materialpks = new ArrayList(); + for (MaterialVO vo : vos) { + materialpks.add(vo.getPk_material()); + } + param.clear(); + param.put("pk_material", materialpks.toArray(new String[0])); + if (stockorgs != null && stockorgs.size() > 0) { + param.put("pk_org", stockorgs.toArray(new String[0])); + } + String condition1 = ApiResourceParamUtils.parseParmToSqlByCode(new MaterialVO(), param); + + String sql = "select pk_materialstock from bd_materialstock where " + condition1; + List allPks = (List) (new BaseDAO()).executeQuery(sql, new ColumnListProcessor()); + OpenApiPageInfo openApiPageInfo = new OpenApiPageInfo(); + String[] currPks = OpenApiPagenationUtils.getCurrentPagePksAndPageInfo(allPks, pageInfo, + openApiPageInfo); + if (currPks == null || currPks.length == 0) { + return ResultMessageUtil.toJSON(null); + } + + SqlBuilderUtil SqlBuilderUtil = new SqlBuilderUtil(); + String wherepart = SqlBuilderUtil.buildSQL("pk_materialstock", currPks, null); + MaterialStockVO[] stockvos = (MaterialStockVO[]) (new BaseDAO()) + .retrieveByClause(MaterialStockVO.class, wherepart).toArray(new MaterialStockVO[0]); + return ResultMessageUtil.toJSONByPage(stockvos, openApiPageInfo, false); + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return null; + } + + private JSONString process(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jObject.getJSONObject("ufinterface"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } + String billtype = bject.getString("billtype"); + String account = bject.getString("account"); + String groupcode = bject.getString("groupcode"); + if (!"material".equals(billtype)) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException( + "billtype:" + billtype + ",account:" + account + ",groupcode:" + groupcode)); + } + + OpenApiConvertDataObject openApiConvertDataObject = new OpenApiConvertDataObject(); + openApiConvertDataObject.setAccount(account); + openApiConvertDataObject.setBilltype(billtype); + openApiConvertDataObject.setGroupcode(groupcode); + openApiConvertDataObject.setOpenApiJsonData(jObject); + + try { + OpenApiConvertDataResult r = getIOpenApiJsonConvertToExChangeXmlService() + .changeToExchangeData(openApiConvertDataObject); + if (r != null) { + return ResultMessageUtil.toJSON(r.getDesc()); + } + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + return ResultMessageUtil.exceptionToJSON(new Exception("未知异常")); + } + + public String getModule() { + return "uapbd"; + } + + private IOpenApiJsonConvertToExChangeXmlService getIOpenApiJsonConvertToExChangeXmlService() { + return (IOpenApiJsonConvertToExChangeXmlService) NCLocator.getInstance() + .lookup(IOpenApiJsonConvertToExChangeXmlService.class); + } +}