통계 수정

main
이범준 1 year ago
parent 3c2fb33e45
commit bfe8b98c1a

@ -62,10 +62,15 @@ public class StatQuery extends CmmnQuery {
private String[] compositeNumberValueSeperator; private String[] compositeNumberValueSeperator;
/** /**
* (count,sum) * (count , sum , ratio )
*/ */
private String[] aggregateType; private String[] aggregateType;
/**
* 릿
*/
private int decimalPoint;
/** /**
* *
*/ */
@ -148,6 +153,15 @@ public class StatQuery extends CmmnQuery {
return self(); return self();
} }
public int getDecimalPoint() {
return ifEmpty(decimalPoint, () -> null);
}
public <T extends StatQuery> T setDecimalPoint(int decimalPoint) {
this.decimalPoint = decimalPoint;
return self();
}
public String[] getCompositeNumberValueSeperator() { public String[] getCompositeNumberValueSeperator() {
return ifEmpty(compositeNumberValueSeperator, () -> null); return ifEmpty(compositeNumberValueSeperator, () -> null);
} }

@ -414,13 +414,15 @@ public class StatBean extends AbstractComponent {
*/ */
public void attachRatioValue(List<StatItem> statItems, StatQuery statQuery) { public void attachRatioValue(List<StatItem> statItems, StatQuery statQuery) {
int decimalPoint = statQuery.getDecimalPoint();
String[] aggregateTypes = statQuery.getAggregateType(); String[] aggregateTypes = statQuery.getAggregateType();
for(StatItem statItem : statItems) { for(StatItem statItem : statItems) {
for(int i = 0; i < aggregateTypes.length ; i++) { 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]); int refIndex = Integer.parseInt(aggregateTypes[i].split("=")[1]);
@ -428,7 +430,10 @@ public class StatBean extends AbstractComponent {
if(totValue == 0) { if(totValue == 0) {
statItem.getNumberValue()[i] = 0; statItem.getNumberValue()[i] = 0;
} else { } 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);
} }
} }

@ -203,7 +203,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
//비율 계산 //비율 계산
boolean exsistRatioValue = false; boolean exsistRatioValue = false;
for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) { for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) {
if(aggregateType.startsWith("ratioRef=")) { if(aggregateType.startsWith("ratio=")) {
exsistRatioValue = true; exsistRatioValue = true;
} }
} }

Loading…
Cancel
Save