|
|
|
@ -20,6 +20,7 @@ import cokr.xit.fims.cmmn.CmmnUtil;
|
|
|
|
|
import cokr.xit.fims.cmmn.CodeConverter;
|
|
|
|
|
import cokr.xit.fims.crdn.service.bean.CrdnStngBean;
|
|
|
|
|
import cokr.xit.fims.stat.CodeSubsetInfo;
|
|
|
|
|
import cokr.xit.fims.stat.CompositeKey;
|
|
|
|
|
import cokr.xit.fims.stat.GroupInfo;
|
|
|
|
|
import cokr.xit.fims.stat.NumberValueInfo;
|
|
|
|
|
import cokr.xit.fims.stat.Stat;
|
|
|
|
@ -104,7 +105,7 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//통계 항목별 그룹핑
|
|
|
|
|
Map<String, List<DataObject>> group = this.grouping(queryResult, statQuery);
|
|
|
|
|
Map<CompositeKey, List<DataObject>> group = this.grouping(queryResult, statQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//고정 항목 설정
|
|
|
|
@ -113,17 +114,17 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//수치 값 추출
|
|
|
|
|
Set<String> keySet = group.keySet();
|
|
|
|
|
Iterator<String> it = keySet.iterator();
|
|
|
|
|
Set<CompositeKey> keySet = group.keySet();
|
|
|
|
|
Iterator<CompositeKey> it = keySet.iterator();
|
|
|
|
|
|
|
|
|
|
List<StatItem> statItems = new ArrayList<>();
|
|
|
|
|
while(it.hasNext()){
|
|
|
|
|
String key = it.next();
|
|
|
|
|
CompositeKey compositeKey = it.next();
|
|
|
|
|
StatItem statItem = new StatItem();
|
|
|
|
|
|
|
|
|
|
statItem.setItemId(key.split(",", -1));
|
|
|
|
|
statItem.setItemId(compositeKey.toArray());
|
|
|
|
|
|
|
|
|
|
List<DataObject> listByKey = group.get(key);
|
|
|
|
|
List<DataObject> listByKey = group.get(compositeKey);
|
|
|
|
|
|
|
|
|
|
int[] numberValues = this.extractNumberValue(listByKey, statQuery);
|
|
|
|
|
|
|
|
|
@ -145,29 +146,41 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
* @param queryResult SQL쿼리 처리 결과, statQuery 통계 요청
|
|
|
|
|
* @return 통계 항목별로 그룹핑된 목록
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, List<DataObject>> grouping(List<DataObject> queryResult, StatQuery statQuery){
|
|
|
|
|
public Map<CompositeKey, List<DataObject>> grouping(List<DataObject> queryResult, StatQuery statQuery){
|
|
|
|
|
|
|
|
|
|
List<GroupInfo> groupInfoList = statQuery.getGroupInfoList();
|
|
|
|
|
|
|
|
|
|
List<CodeSubsetInfo> subsetInfoList = statQuery.getCodeSubsetInfoList();
|
|
|
|
|
|
|
|
|
|
Map<String, List<DataObject>> group = queryResult.stream()
|
|
|
|
|
Map<CompositeKey, List<DataObject>> group = queryResult.stream()
|
|
|
|
|
.collect(
|
|
|
|
|
Collectors.groupingBy(
|
|
|
|
|
(item) -> {
|
|
|
|
|
String result = "";
|
|
|
|
|
|
|
|
|
|
CompositeKey compositeKey = new CompositeKey();
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < groupInfoList.size(); i++) {
|
|
|
|
|
String key = "";
|
|
|
|
|
GroupInfo groupInfo = groupInfoList.get(i);
|
|
|
|
|
|
|
|
|
|
if(i != 0) {
|
|
|
|
|
result += ",";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String refCol = groupInfo.getRefCol();
|
|
|
|
|
String colValue = item.string(refCol);
|
|
|
|
|
|
|
|
|
|
if(ifEmpty(groupInfo.getCtgrType(), ()-> "").equals("")) {
|
|
|
|
|
result += colValue;
|
|
|
|
|
key = colValue;
|
|
|
|
|
if(i == 0) {
|
|
|
|
|
compositeKey.setLevel1(key);
|
|
|
|
|
}
|
|
|
|
|
if(i == 1) {
|
|
|
|
|
compositeKey.setLevel2(key);
|
|
|
|
|
}
|
|
|
|
|
if(i == 2) {
|
|
|
|
|
compositeKey.setLevel3(key);
|
|
|
|
|
}
|
|
|
|
|
if(i == 3) {
|
|
|
|
|
compositeKey.setLevel4(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -177,21 +190,21 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
if(ctgrType.equals("date")) {
|
|
|
|
|
|
|
|
|
|
if(addOption.equals("YYYY")) { //연도별
|
|
|
|
|
result += colValue.substring(0,4);
|
|
|
|
|
key = colValue.substring(0,4);
|
|
|
|
|
} else if(addOption.equals("YYYYMM")) { //연월별
|
|
|
|
|
result += colValue.substring(0,6);
|
|
|
|
|
key = colValue.substring(0,6);
|
|
|
|
|
} else if(addOption.equals("YYYYMMDD")) { //일자별
|
|
|
|
|
result += colValue.substring(0,8);
|
|
|
|
|
key = colValue.substring(0,8);
|
|
|
|
|
} else if(addOption.equals("DAY_OF_WEEK")) { //요일별
|
|
|
|
|
result += CmmnUtil.getDayOfWeek(colValue);
|
|
|
|
|
key = CmmnUtil.getDayOfWeek(colValue);
|
|
|
|
|
} else if(addOption.equals("HH")) { //시간대별
|
|
|
|
|
if(colValue.length() == 14) {
|
|
|
|
|
result += colValue.substring(8,10);
|
|
|
|
|
key = colValue.substring(8,10);
|
|
|
|
|
} else {
|
|
|
|
|
result += colValue.substring(0,2);
|
|
|
|
|
key = colValue.substring(0,2);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result += colValue;
|
|
|
|
|
key = colValue;
|
|
|
|
|
}
|
|
|
|
|
} else if(ctgrType.equals("code") || ctgrType.equals("otherCode")) {
|
|
|
|
|
|
|
|
|
@ -209,7 +222,7 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += colValue;
|
|
|
|
|
key = colValue;
|
|
|
|
|
|
|
|
|
|
} else if(ctgrType.equals("method")) {
|
|
|
|
|
|
|
|
|
@ -217,19 +230,31 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
String ffnlgCarmdlCd = item.string("FFNLG_CARMDL_CD");
|
|
|
|
|
String vhrno = item.string("VHRNO");
|
|
|
|
|
result += crdnStngBean.getBusinessYnOfCar(ffnlgCarmdlCd, vhrno);
|
|
|
|
|
key = crdnStngBean.getBusinessYnOfCar(ffnlgCarmdlCd, vhrno);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
result += colValue;
|
|
|
|
|
key = colValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
result += colValue;
|
|
|
|
|
key = colValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(i == 0) {
|
|
|
|
|
compositeKey.setLevel1(key);
|
|
|
|
|
}
|
|
|
|
|
if(i == 1) {
|
|
|
|
|
compositeKey.setLevel2(key);
|
|
|
|
|
}
|
|
|
|
|
if(i == 2) {
|
|
|
|
|
compositeKey.setLevel3(key);
|
|
|
|
|
}
|
|
|
|
|
if(i == 3) {
|
|
|
|
|
compositeKey.setLevel4(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
return compositeKey;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
@ -241,29 +266,37 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
* @param group 그룹핑한 데이터 목록, statQuery 통계 요청;
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void itemFix(Map<String, List<DataObject>> group, StatQuery statQuery) {
|
|
|
|
|
public void itemFix(Map<CompositeKey, List<DataObject>> group, StatQuery statQuery) {
|
|
|
|
|
|
|
|
|
|
String[] fixedItemId = statQuery.getFixedItemId();
|
|
|
|
|
|
|
|
|
|
CompositeKey[] fixedItemKey = new CompositeKey[fixedItemId.length];
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < fixedItemId.length; i++) {
|
|
|
|
|
if(!group.containsKey(fixedItemId[i])) {
|
|
|
|
|
group.put(fixedItemId[i], null);
|
|
|
|
|
CompositeKey newObj = new CompositeKey();
|
|
|
|
|
newObj.setLevel1(fixedItemId[i]);
|
|
|
|
|
fixedItemKey[i] = newObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < fixedItemKey.length; i++) {
|
|
|
|
|
if(!group.containsKey(fixedItemKey[i])) {
|
|
|
|
|
group.put(fixedItemKey[i], null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Set<String> keySet = group.keySet();
|
|
|
|
|
Iterator<String> it = keySet.iterator();
|
|
|
|
|
Set<CompositeKey> keySet = group.keySet();
|
|
|
|
|
Iterator<CompositeKey> it = keySet.iterator();
|
|
|
|
|
|
|
|
|
|
List<String> deleteTargets = new ArrayList<>();
|
|
|
|
|
List<CompositeKey> deleteTargets = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
while(it.hasNext()) {
|
|
|
|
|
String key = it.next();
|
|
|
|
|
if(!Arrays.asList(fixedItemId).contains(key)) {
|
|
|
|
|
deleteTargets.add(key);
|
|
|
|
|
CompositeKey compositekey = it.next();
|
|
|
|
|
if(!Arrays.asList(fixedItemKey).contains(compositekey)) {
|
|
|
|
|
deleteTargets.add(compositekey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(String deleteTarget : deleteTargets) {
|
|
|
|
|
for(CompositeKey deleteTarget : deleteTargets) {
|
|
|
|
|
group.remove(deleteTarget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|