|
|
|
@ -3,6 +3,7 @@ package cokr.xit.fims.stat.service.bean;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -369,11 +370,11 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
GroupInfo groupInfo = groupInfoList.get(i);
|
|
|
|
|
|
|
|
|
|
String ctgrType = groupInfo.getCtgrType();
|
|
|
|
|
String dtlCtgr = groupInfo.getDtlCtgr();
|
|
|
|
|
String ctgrType = ifEmpty(groupInfo.getCtgrType(), ()-> "");
|
|
|
|
|
String dtlCtgr = ifEmpty(groupInfo.getDtlCtgr(), ()-> "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ctgrType.equals("") || ctgrType.equals("plain")) { //일반텍스트
|
|
|
|
|
if(ctgrType.equals("") || ctgrType.equals("plain") || ctgrType.equals("date")) { //일반텍스트
|
|
|
|
|
compositeItemName[i] = compositeItemId[i];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -504,6 +505,77 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 통계결과를 정렬한다.
|
|
|
|
|
* @param stat 통계
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void sort(Stat stat) {
|
|
|
|
|
|
|
|
|
|
List<StatItem> statItems = stat.getStatItems();
|
|
|
|
|
|
|
|
|
|
if(statItems != null && statItems.size() > 0) {
|
|
|
|
|
|
|
|
|
|
Comparator<StatItem> comparator = getStatItemComparator(statItems.get(0));
|
|
|
|
|
|
|
|
|
|
statItems = statItems.stream().sorted(comparator).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
stat.setStatItems(statItems);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Comparator<StatItem> getStatItemComparator(StatItem sample){
|
|
|
|
|
|
|
|
|
|
String[] itemIds = sample.getItemId();
|
|
|
|
|
|
|
|
|
|
int level = itemIds.length;
|
|
|
|
|
|
|
|
|
|
Comparator<StatItem> chainComparator = getStatItemNLevelComparator(1);
|
|
|
|
|
if(level > 1) {
|
|
|
|
|
for(int i=2; i <= level; i++) {
|
|
|
|
|
chainComparator = chainComparator.thenComparing(getStatItemNLevelComparator(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return chainComparator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Comparator<StatItem> getStatItemNLevelComparator(int level){
|
|
|
|
|
|
|
|
|
|
Comparator<StatItem> nLevelComparator = (statItemA, statItemB) -> {
|
|
|
|
|
|
|
|
|
|
String[] statItemAIds = statItemA.getItemId();
|
|
|
|
|
String[] statItemBIds = statItemB.getItemId();
|
|
|
|
|
|
|
|
|
|
Comparator<String[]> tempComparator = getIndexOfStringArrayComparator(level-1);
|
|
|
|
|
|
|
|
|
|
return tempComparator.compare(statItemAIds, statItemBIds);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return nLevelComparator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Comparator<String[]> getStringArrayChainComparator(int lastIndex){
|
|
|
|
|
|
|
|
|
|
Comparator<String[]> chainComparator = getIndexOfStringArrayComparator(0);
|
|
|
|
|
|
|
|
|
|
if(lastIndex > 0) {
|
|
|
|
|
for(int i=1; i <= lastIndex; i++) {
|
|
|
|
|
chainComparator = chainComparator.thenComparing(getIndexOfStringArrayComparator(i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return chainComparator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Comparator<String[]> getIndexOfStringArrayComparator(int index) {
|
|
|
|
|
|
|
|
|
|
Comparator<String[]> onlyNComparator = (arr1, arr2) -> {
|
|
|
|
|
String str1 = arr1[index];
|
|
|
|
|
String str2 = arr2[index];
|
|
|
|
|
return str1.compareTo(str2);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return onlyNComparator;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|