diff --git a/src/main/java/cokr/xit/fims/stat/StatQuery.java b/src/main/java/cokr/xit/fims/stat/StatQuery.java index 7bf79a1f..a4d7e784 100644 --- a/src/main/java/cokr/xit/fims/stat/StatQuery.java +++ b/src/main/java/cokr/xit/fims/stat/StatQuery.java @@ -62,10 +62,15 @@ public class StatQuery extends CmmnQuery { private String[] compositeNumberValueSeperator; /** - * 수치값 집계 유형(count,sum) + * 수치값 집계 유형(count 건수, sum 합계, ratio 비율) */ private String[] aggregateType; + /** + * 표기할 소수점 자릿수 + */ + private int decimalPoint; + /** * 날짜 컬럼 */ @@ -148,6 +153,15 @@ public class StatQuery extends CmmnQuery { return self(); } + public int getDecimalPoint() { + return ifEmpty(decimalPoint, () -> null); + } + + public T setDecimalPoint(int decimalPoint) { + this.decimalPoint = decimalPoint; + return self(); + } + public String[] getCompositeNumberValueSeperator() { return ifEmpty(compositeNumberValueSeperator, () -> null); } diff --git a/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java b/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java index 582e8dc1..303648dd 100644 --- a/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java +++ b/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java @@ -414,13 +414,15 @@ public class StatBean extends AbstractComponent { */ public void attachRatioValue(List statItems, StatQuery statQuery) { + int decimalPoint = statQuery.getDecimalPoint(); + String[] aggregateTypes = statQuery.getAggregateType(); for(StatItem statItem : statItems) { for(int i = 0; i < aggregateTypes.length ; i++) { - if(aggregateTypes[i].startsWith("ratioRef=")) { + if(aggregateTypes[i].startsWith("ratio=")) { int refIndex = Integer.parseInt(aggregateTypes[i].split("=")[1]); @@ -428,7 +430,10 @@ public class StatBean extends AbstractComponent { if(totValue == 0) { statItem.getNumberValue()[i] = 0; } else { - statItem.getNumberValue()[i] = statItem.getNumberValue()[i] * 100 / totValue; + int originalValue = statItem.getNumberValue()[i]; + double ratioValue = originalValue / totValue; + double percent = ratioValue * 100 * (decimalPoint+1); + statItem.getNumberValue()[i] = (int) Math.floor(percent); } } diff --git a/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java b/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java index 86b799e0..8e4f69ff 100644 --- a/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java +++ b/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java @@ -203,7 +203,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService //비율 계산 boolean exsistRatioValue = false; for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) { - if(aggregateType.startsWith("ratioRef=")) { + if(aggregateType.startsWith("ratio=")) { exsistRatioValue = true; } }