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 88309812..f900d414 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 @@ -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 statItems = stat.getStatItems(); + + if(statItems != null && statItems.size() > 0) { + + Comparator comparator = getStatItemComparator(statItems.get(0)); + + statItems = statItems.stream().sorted(comparator).collect(Collectors.toList()); + + stat.setStatItems(statItems); + } + } + + public Comparator getStatItemComparator(StatItem sample){ + + String[] itemIds = sample.getItemId(); + + int level = itemIds.length; + + Comparator chainComparator = getStatItemNLevelComparator(1); + if(level > 1) { + for(int i=2; i <= level; i++) { + chainComparator = chainComparator.thenComparing(getStatItemNLevelComparator(i)); + } + } + + return chainComparator; + } + public Comparator getStatItemNLevelComparator(int level){ + Comparator nLevelComparator = (statItemA, statItemB) -> { + + String[] statItemAIds = statItemA.getItemId(); + String[] statItemBIds = statItemB.getItemId(); + + Comparator tempComparator = getIndexOfStringArrayComparator(level-1); + + return tempComparator.compare(statItemAIds, statItemBIds); + }; + + return nLevelComparator; + } + + + public Comparator getStringArrayChainComparator(int lastIndex){ + + Comparator chainComparator = getIndexOfStringArrayComparator(0); + + if(lastIndex > 0) { + for(int i=1; i <= lastIndex; i++) { + chainComparator = chainComparator.thenComparing(getIndexOfStringArrayComparator(i)); + } + } + + return chainComparator; + } + + public Comparator getIndexOfStringArrayComparator(int index) { + + Comparator onlyNComparator = (arr1, arr2) -> { + String str1 = arr1[index]; + String str2 = arr2[index]; + return str1.compareTo(str2); + }; + + return onlyNComparator; + } } 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 18535a6c..74118721 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 @@ -220,6 +220,9 @@ public class StatServiceBean extends AbstractServiceBean implements StatService stat.setNumberValueLabel(numberValueLabel); } + //정렬 + statBean.sort(stat); + stat.setAggregateYn("Y"); } diff --git a/src/main/webapp/WEB-INF/jsp/fims/stat/stat01010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stat/stat01010-main.jsp index 4de16cc3..b9522b7e 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stat/stat01010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stat/stat01010-main.jsp @@ -388,7 +388,14 @@ $(document).ready(function(){ var tr = ""; for(var j=0; j < itemNames.length; j++){ - tr += "" + itemNames[j] + ""; + + if($P.statQuery.groupInfoList[j].ctgrType == "date"){ + tr += ""; + } else { + tr += ""; + } + tr += itemNames[j]; + tr += ""; } for(var k=0; k < numberValues.length; k++){ tr += ""; diff --git a/src/main/webapp/WEB-INF/jsp/fims/stat/stat02010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stat/stat02010-main.jsp index 02a54f12..bd88ed62 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stat/stat02010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stat/stat02010-main.jsp @@ -74,7 +74,7 @@ data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="DAY_OF_WEEK" >단속요일 diff --git a/src/main/webapp/WEB-INF/jsp/fims/stat/stat05010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/stat/stat05010-main.jsp index 8d79d17b..a3308c28 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/stat/stat05010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/stat/stat05010-main.jsp @@ -74,7 +74,7 @@ data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="DAY_OF_WEEK" >단속요일