齐套率计算调整

This commit is contained in:
mzr 2025-03-14 10:33:27 +08:00
parent 0eb0cd5c3c
commit c1aa00cbcb
2 changed files with 112 additions and 18 deletions

View File

@ -0,0 +1,88 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package nc.bs.mmpub.setanalysis.bp;
import nc.bs.mmpub.setanalysis.bp.log.SaMemoryBP;
import nc.bs.mmpub.setanalysis.bp.rule.analysisAfterCheckRule;
import nc.bs.mmpub.setanalysis.bp.utils.SaLogger;
import nc.bs.mmpub.setanalysis.bp.utils.SaScaleUtil;
import nc.bs.mmpub.setanalysis.bp.utils.SaVOUtils;
import nc.bs.mmpub.setanalysis.proxy.SaServiceProxy;
import nc.bs.mmpub.setanalysis.rule.SaCheckTsRule;
import nc.vo.mmpub.setanalysis.entity.AggAnalysisVO;
import nc.vo.mmpub.setanalysis.entity.SaAnalysisVO;
import nc.vo.mmpub.setanalysis.entity.SaContext;
import nc.vo.mmpub.setanalysis.utils.SaMeasureUtil;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
public class SetAnalysisBP {
private SaContext context;
public SetAnalysisBP(SaContext context) {
this.context = context;
}
public AggAnalysisVO[] doSetAnalysis() {
try {
this.addBeforeRule();
SaLogger.init();
UFDateTime tstarttime1 = new UFDateTime();
SaLogger.debug("0.分析开始^^^^^^^^^^^^^^^^^^^^^^^^^^");
this.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());
//分析后调用回写齐套率计算方式已调整此处不用注释analysisAfterCheckRule
// this.analysisAfterCheckRule();
SaLogger.debug("齐套分析算法结束,共耗时:" + SaLogger.getRunTime(tstarttime1));
return this.context.getAggs();
} catch (BusinessException var5) {
ExceptionUtils.wrappException(var5);
SaLogger.error(var5.getMessage());
return null;
}
}
private void printMemory(String operation) {
long totalMemory = Runtime.getRuntime().totalMemory() / 1024L / 1024L;
long freeMemory = Runtime.getRuntime().freeMemory() / 1024L / 1024L;
SaLogger.debug(operation + ":totalMemory->" + totalMemory + "MB,freeMemory->" + freeMemory + "MB");
}
private void createMd5Function() {
(new SaFunctionBP()).createMD5();
}
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 addBeforeRule() {
(new SaCheckTsRule()).process(this.context.getAggs());
}
private void analysisAfterCheckRule() {
(new analysisAfterCheckRule()).process(this.context.getAggs());
}
}

View File

@ -182,24 +182,19 @@ public class SaMultiStoreyBP {
if (agg != null) {
SaAnalysisVO analysis = agg.getParentVO();
analysis.setNsetsnum(nsetsnum.getNsetsnum());
// 流程生产订单表体主键
String cdemandbillbid = analysis.getCdemandbillbid();
// 物料的总行数
UFDouble goodsnum = nsetsnum.getGoodsnum().setScale(2, UFDouble.ROUND_HALF_UP);
// 满足齐套的物料的行数
UFDouble pass_goodsnum = nsetsnum.getPass_goodsnum().setScale(2, UFDouble.ROUND_HALF_UP);
// 齐套率计算=满足的/总数量
UFDouble rate = pass_goodsnum.div(goodsnum, 4, UFDouble.ROUND_HALF_UP);
// 修改流程生产订单的齐套率物料的总行数满足齐套的物料的行数
String sql = String.format("update mm_mo set vdef12 = '%s',vdef11 = '%s',vdef4 = '%s' where cmoid = '%s'",
goodsnum, pass_goodsnum, rate, cdemandbillbid);
try {
NCCForUAPLogger.debug("sql = " + sql);
BaseDAO bd = new BaseDAO();
bd.executeUpdate(sql);
} catch (DAOException e) {
NCCForUAPLogger.debug("setRewriteNmaterialnum-exp:" + e.getMessage());
throw new RuntimeException(e);
if (isUpdateMatch) {
// 流程生产订单表体主键
String cdemandbillbid = analysis.getCdemandbillbid();
// 物料的总行数
UFDouble goodsnum = nsetsnum.getGoodsnum().setScale(2, UFDouble.ROUND_HALF_UP);
// 满足齐套的物料的行数
UFDouble pass_goodsnum = nsetsnum.getPass_goodsnum().setScale(2, UFDouble.ROUND_HALF_UP);
// 齐套率计算=满足的/总数量
UFDouble rate = pass_goodsnum.div(goodsnum, 2, UFDouble.ROUND_HALF_UP);
// 修改流程生产订单的齐套率物料的总行数满足齐套的物料的行数
String sql = String.format("update mm_mo set vdef12 = '%s',vdef11 = '%s',vdef4 = '%s' where cmoid = '%s'",
goodsnum, pass_goodsnum, rate.toString(), cdemandbillbid);
updateDef4(sql);
}
}
@ -218,6 +213,17 @@ public class SaMultiStoreyBP {
}
}
private int updateDef4(String sql) {
try {
NCCForUAPLogger.debug("sql = " + sql);
BaseDAO baseDAO = new BaseDAO();
return baseDAO.executeUpdate(sql);
} catch (DAOException e) {
NCCForUAPLogger.debug("setRewriteNmaterialnum-exp:" + e.getMessage());
throw new RuntimeException(e);
}
}
private int getLevel(String key) {
return key.length() == 0 ? 0 : Integer.parseInt(key) - 1;
}