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