통계 결과 정렬 기능 추가

main
이범준 1 year ago
parent 59c2ad5671
commit bc3105ac5a

@ -3,6 +3,7 @@ package cokr.xit.fims.stat.service.bean;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -369,11 +370,11 @@ public class StatBean extends AbstractComponent {
GroupInfo groupInfo = groupInfoList.get(i); GroupInfo groupInfo = groupInfoList.get(i);
String ctgrType = groupInfo.getCtgrType(); String ctgrType = ifEmpty(groupInfo.getCtgrType(), ()-> "");
String dtlCtgr = groupInfo.getDtlCtgr(); String dtlCtgr = ifEmpty(groupInfo.getDtlCtgr(), ()-> "");
if(ctgrType.equals("") || ctgrType.equals("plain")) { //일반텍스트 if(ctgrType.equals("") || ctgrType.equals("plain") || ctgrType.equals("date")) { //일반텍스트
compositeItemName[i] = compositeItemId[i]; compositeItemName[i] = compositeItemId[i];
continue; 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;
}
} }

@ -220,6 +220,9 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
stat.setNumberValueLabel(numberValueLabel); stat.setNumberValueLabel(numberValueLabel);
} }
//정렬
statBean.sort(stat);
stat.setAggregateYn("Y"); stat.setAggregateYn("Y");
} }

@ -388,7 +388,14 @@ $(document).ready(function(){
var tr = "<tr>"; var tr = "<tr>";
for(var j=0; j < itemNames.length; j++){ for(var j=0; j < itemNames.length; j++){
tr += "<td>" + itemNames[j] + "</td>";
if($P.statQuery.groupInfoList[j].ctgrType == "date"){
tr += "<td class='text-center' >";
} else {
tr += "<td>";
}
tr += itemNames[j];
tr += "</td>";
} }
for(var k=0; k < numberValues.length; k++){ for(var k=0; k < numberValues.length; k++){
tr += "<td class='text-end' >"; tr += "<td class='text-end' >";

@ -74,7 +74,7 @@
data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="DAY_OF_WEEK" data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="DAY_OF_WEEK"
>단속요일</option> >단속요일</option>
<option value="crdnHour" <option value="crdnHour"
data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="HH" data-ref-col="CRDN_TM" data-ctgr-type="date" data-dtl-ctgr="HH"
>단속시간대</option> >단속시간대</option>
<option value="crdnLine" <option value="crdnLine"
data-ref-col="" data-ctgr-type="" data-dtl-ctgr="" data-ref-col="" data-ctgr-type="" data-dtl-ctgr=""
@ -113,7 +113,7 @@
<datalist id="presetDatalist--${pageName}"> <datalist id="presetDatalist--${pageName}">
<option value="crdnPreset1" data-stat-domain="crdn" <option value="crdnPreset1" data-stat-domain="crdn"
>단속건수,부과필요건수,부과유예건수,의견수용건수,경찰서이첩건수,서손건수,면제차량건수,부과건수,서손율,의견진술접수건수,의견진술수용율 >전체단속건수,부과필요건수,부과유예건수,의견수용건수,경찰서이첩건수,서손건수,면제차량건수,부과건수,서손율,의견진술접수건수,의견진술수용율
</option> </option>
</datalist> </datalist>

@ -74,7 +74,7 @@
data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="DAY_OF_WEEK" data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="DAY_OF_WEEK"
>단속요일</option> >단속요일</option>
<option value="crdnHour" <option value="crdnHour"
data-ref-col="CRDN_YMD" data-ctgr-type="date" data-dtl-ctgr="HH" data-ref-col="CRDN_TM" data-ctgr-type="date" data-dtl-ctgr="HH"
>단속시간대</option> >단속시간대</option>
<option value="crdnLine" <option value="crdnLine"
data-ref-col="" data-ctgr-type="" data-dtl-ctgr="" data-ref-col="" data-ctgr-type="" data-dtl-ctgr=""
@ -113,9 +113,9 @@
<datalist id="presetDatalist--${pageName}"> <datalist id="presetDatalist--${pageName}">
<option value="preset1" <option value="preset1"
>전체건수,총금액,단속건수,단속금액,자납부과건수,자납부과금액,의견진술접수건수,의견진술수용건수,경찰서이첩건수,서손건수,면제건수,부과건수,부과금액,가산금액대납건수,대납금액,징수건수,징수금액,체납건수,체납금액,감액건수,감액금액,부분감액,합계건수,합계금액 >전체건수,총금액,단속상태건수,단속상태금액,자납부과건수,자납부과금액,의견진술접수건수,의견진술수용건수,경찰서이첩건수,서손건수,면제건수,부과건수,부과금액,가산금액대납건수,대납금액,징수건수,징수금액,체납건수,체납금액,감액건수,감액금액,부분감액,합계건수,합계금액
</option> </option>
<option value="preset2" <option value="preset2"
>단속건수,단속금액,부과필요건수,부과유예건수,의견진술수용건수,경찰서이첩건수,서손건수,면제차량건수,부과건수,부과금액,징수건수,징수금액,감액건수,감액금액,미납건수,미납금액 >전체건수,총금액,부과필요건수,부과유예건수,의견진술수용건수,경찰서이첩건수,서손건수,면제차량건수,부과건수,부과금액,징수건수,징수금액,감액건수,감액금액,미납건수,미납금액
</option> </option>
</datalist> </datalist>

Loading…
Cancel
Save