增加mmpub模块,增加齐套算法
This commit is contained in:
		
							parent
							
								
									3deeda5d52
								
							
						
					
					
						commit
						55e7646ebc
					
				|  | @ -1,5 +1,10 @@ | ||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <classpath> | <classpath> | ||||||
|  | 	<classpathentry kind="src" output="bin" path="mmpub/src/public"/> | ||||||
|  | 	<classpathentry kind="src" output="bin" path="mmpub/src/client"/> | ||||||
|  | 	<classpathentry kind="src" output="bin" path="mmpub/src/private"/> | ||||||
|  | 	<classpathentry kind="src" output="bin" path="mmpub/src/test"/> | ||||||
|  | 	<classpathentry kind="src" output="bin" path="mmpub/resources"/> | ||||||
| 	<classpathentry kind="src" output="bin" path="sscivm/src/public"/> | 	<classpathentry kind="src" output="bin" path="sscivm/src/public"/> | ||||||
| 	<classpathentry kind="src" output="bin" path="sscivm/src/client"/> | 	<classpathentry kind="src" output="bin" path="sscivm/src/client"/> | ||||||
| 	<classpathentry kind="src" output="bin" path="sscivm/src/private"/> | 	<classpathentry kind="src" output="bin" path="sscivm/src/private"/> | ||||||
|  |  | ||||||
|  | @ -0,0 +1,3 @@ | ||||||
|  | <component name="mmpub" displayname="mmpub"> | ||||||
|  |   <dependencies/> | ||||||
|  | </component> | ||||||
|  | @ -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()); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | @ -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<AggAnalysisVO> { | ||||||
|  | 
 | ||||||
|  |     @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; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue