|
|
|
@ -1,14 +1,10 @@
|
|
|
|
|
package cokr.xit.fims.stat.service.bean;
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.time.DayOfWeek;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.TextStyle;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -17,6 +13,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.base.code.CommonCode;
|
|
|
|
|
import cokr.xit.fims.cmmn.CmmnQuery;
|
|
|
|
|
import cokr.xit.fims.cmmn.CmmnUtil;
|
|
|
|
|
import cokr.xit.fims.cmmn.CodeConverter;
|
|
|
|
|
import cokr.xit.fims.stat.CodeSubsetInfo;
|
|
|
|
|
import cokr.xit.fims.stat.GroupInfo;
|
|
|
|
@ -128,23 +125,28 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
if(i != 0) {
|
|
|
|
|
result += ",";
|
|
|
|
|
}
|
|
|
|
|
String colValue = item.string(groupInfo.getGroupColName());
|
|
|
|
|
|
|
|
|
|
if(!ifEmpty(groupInfo.getCategorizationAddOption(), ()-> "").equals("")) {
|
|
|
|
|
String addOption = groupInfo.getCategorizationAddOption();
|
|
|
|
|
String refCol = groupInfo.getRefCol();
|
|
|
|
|
String colValue = item.string(refCol);
|
|
|
|
|
|
|
|
|
|
if(ifEmpty(groupInfo.getCtgrType(), ()-> "").equals("")) {
|
|
|
|
|
result += colValue;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String ctgrType = groupInfo.getCtgrType();
|
|
|
|
|
String addOption = groupInfo.getDtlCtgr();
|
|
|
|
|
|
|
|
|
|
if(ctgrType.equals("date")) {
|
|
|
|
|
|
|
|
|
|
if(addOption.equals("YYYY")) { //연도별
|
|
|
|
|
result += colValue.substring(0,4);
|
|
|
|
|
} else if(addOption.equals("YYYYMM")) { //연월별
|
|
|
|
|
result += colValue.substring(0,6);
|
|
|
|
|
} else if(addOption.equals("YYYYMMDD")) { //일자별
|
|
|
|
|
result += colValue.substring(0,8);
|
|
|
|
|
} else if(addOption.equals("DAY_OF_WEEK")) { //요일별
|
|
|
|
|
int y = Integer.parseInt(colValue.substring(0,4));
|
|
|
|
|
int m = Integer.parseInt(colValue.substring(4,6));
|
|
|
|
|
int d = Integer.parseInt(colValue.substring(6,8));
|
|
|
|
|
LocalDate date = LocalDate.of(y, m, d);
|
|
|
|
|
DayOfWeek dayOfWeek = date.getDayOfWeek();
|
|
|
|
|
String dow = dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN);
|
|
|
|
|
result += dow;
|
|
|
|
|
result += CmmnUtil.getDayOfWeek(colValue);
|
|
|
|
|
} else if(addOption.equals("HH")) { //시간대별
|
|
|
|
|
if(colValue.length() == 14) {
|
|
|
|
|
result += colValue.substring(8,10);
|
|
|
|
@ -154,16 +156,15 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
} else {
|
|
|
|
|
result += colValue;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
} else if(ctgrType.equals("code") || ctgrType.equals("otherCode")) {
|
|
|
|
|
|
|
|
|
|
if(groupInfo.getGroupColName().endsWith("_CD")
|
|
|
|
|
&& groupInfo.getCategoryNameConverter() != null
|
|
|
|
|
&& groupInfo.getCategoryNameConverter().startsWith("code=")
|
|
|
|
|
&& subsetInfoList != null && !subsetInfoList.isEmpty()
|
|
|
|
|
if(ctgrType.equals("code")
|
|
|
|
|
&& subsetInfoList != null
|
|
|
|
|
&& !subsetInfoList.isEmpty()
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
for(CodeSubsetInfo subsetInfo : subsetInfoList) {
|
|
|
|
|
if(subsetInfo.getSourceGroup().equals(groupInfo.getCategoryNameConverter().split("=")[1])) {
|
|
|
|
|
if(subsetInfo.getSourceGroup().equals(addOption)) {
|
|
|
|
|
if(Arrays.asList(subsetInfo.getSourceCodes()).contains(colValue)) {
|
|
|
|
|
colValue = subsetInfo.getTargetCode();
|
|
|
|
|
}
|
|
|
|
@ -171,8 +172,11 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += colValue;
|
|
|
|
|
} else {
|
|
|
|
|
result += colValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
@ -219,6 +223,8 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
List<NumberValueInfo> numberValueInfoList = statQuery.getNumberValueInfoList();
|
|
|
|
|
|
|
|
|
|
List<CodeSubsetInfo> subsetInfoList = statQuery.getCodeSubsetInfoList();
|
|
|
|
|
|
|
|
|
|
int[] aggregateArr = new int[numberValueInfoList.size()];
|
|
|
|
|
for(int i=0; i < numberValueInfoList.size(); i++) {
|
|
|
|
|
aggregateArr[i] = 0;
|
|
|
|
@ -230,32 +236,65 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
DataObject dataObject = listByKey.get(i);
|
|
|
|
|
|
|
|
|
|
for(int j=0; j < aggregateArr.length; j++) {
|
|
|
|
|
NumberValueInfo numverValueInfo = numberValueInfoList.get(j);
|
|
|
|
|
|
|
|
|
|
String condition = numberValueInfoList.get(j).getNumberValueSeperator();
|
|
|
|
|
String aggregateType = numberValueInfoList.get(j).getAggregateType();
|
|
|
|
|
String seperatorRefCol = ifEmpty(numverValueInfo.getSeperatorRefCol(), ()-> "");
|
|
|
|
|
String conditionValue = ifEmpty(numverValueInfo.getConditionValue(), ()-> "");
|
|
|
|
|
|
|
|
|
|
if(!condition.equals("")) {
|
|
|
|
|
String seperatorCtgrType = ifEmpty(numverValueInfo.getSeperatorCtgrType(), ()-> "");
|
|
|
|
|
String seperatorDtlCtgr = ifEmpty(numverValueInfo.getSeperatorDtlCtgr(), ()-> "");
|
|
|
|
|
|
|
|
|
|
if(condition.contains("=")) {
|
|
|
|
|
String aggregateType = ifEmpty(numverValueInfo.getAggregateType(), ()-> "");
|
|
|
|
|
String sumRefCol = ifEmpty(numverValueInfo.getSumRefCol(), ()-> "");
|
|
|
|
|
|
|
|
|
|
String conditionColumn = condition.split("=")[0];
|
|
|
|
|
String conditionColumnValue = dataObject.string(conditionColumn);
|
|
|
|
|
String conditionValue = condition.split("=")[1];
|
|
|
|
|
if(!seperatorRefCol.equals("")) {
|
|
|
|
|
|
|
|
|
|
if(conditionColumn.endsWith("_DT") && conditionValue.length() == 8) {
|
|
|
|
|
conditionColumnValue = conditionColumnValue.substring(0,8);
|
|
|
|
|
String dataColumnValue = dataObject.string(seperatorRefCol);
|
|
|
|
|
|
|
|
|
|
if(seperatorCtgrType.equals("date")) {
|
|
|
|
|
if(seperatorDtlCtgr.equals("YYYY")) { //연도별
|
|
|
|
|
dataColumnValue = dataColumnValue.substring(0,4);
|
|
|
|
|
} else if(seperatorDtlCtgr.equals("YYYYMM")) { //연월별
|
|
|
|
|
dataColumnValue = dataColumnValue.substring(0,6);
|
|
|
|
|
} else if(seperatorDtlCtgr.equals("YYYYMMDD")) { //일자별
|
|
|
|
|
dataColumnValue = dataColumnValue.substring(0,8);
|
|
|
|
|
} else if(seperatorDtlCtgr.equals("DAY_OF_WEEK")) { //요일별
|
|
|
|
|
dataColumnValue = CmmnUtil.getDayOfWeek(dataColumnValue);
|
|
|
|
|
} else if(seperatorDtlCtgr.equals("HH")) { //시간대별
|
|
|
|
|
if(dataColumnValue.length() == 14) {
|
|
|
|
|
dataColumnValue = dataColumnValue.substring(8,10);
|
|
|
|
|
} else {
|
|
|
|
|
dataColumnValue = dataColumnValue.substring(0,2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!conditionColumnValue.equals(conditionValue)) {
|
|
|
|
|
continue;
|
|
|
|
|
} else if(seperatorCtgrType.equals("code") || seperatorCtgrType.equals("otherCode")) {
|
|
|
|
|
|
|
|
|
|
if(seperatorCtgrType.equals("code")
|
|
|
|
|
&& subsetInfoList != null
|
|
|
|
|
&& !subsetInfoList.isEmpty()
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
for(CodeSubsetInfo subsetInfo : subsetInfoList) {
|
|
|
|
|
if(subsetInfo.getSourceGroup().equals(seperatorDtlCtgr)) {
|
|
|
|
|
if(Arrays.asList(subsetInfo.getSourceCodes()).contains(dataColumnValue)) {
|
|
|
|
|
dataColumnValue = subsetInfo.getTargetCode();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!dataColumnValue.equals(conditionValue)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(aggregateType.startsWith("sum=")) {
|
|
|
|
|
aggregateArr[j] += dataObject.number(aggregateType.split("=")[1]).intValue();
|
|
|
|
|
|
|
|
|
|
if(aggregateType.equals("sum")) {
|
|
|
|
|
aggregateArr[j] += dataObject.number(sumRefCol).intValue();
|
|
|
|
|
} else {
|
|
|
|
|
aggregateArr[j] += 1;
|
|
|
|
|
}
|
|
|
|
@ -281,7 +320,8 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
int taskSeCdIndex = -1;
|
|
|
|
|
for(int i=0; i < groupInfoList.size(); i++) {
|
|
|
|
|
if(groupInfoList.get(i).getCategoryNameConverter().equals("code=FIM054")) {
|
|
|
|
|
if(groupInfoList.get(i).getCtgrType().equals("code")
|
|
|
|
|
&& groupInfoList.get(i).getDtlCtgr().equals("FIM054")) {
|
|
|
|
|
taskSeCdIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -294,9 +334,12 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
for(int i=0; i < compositeItemId.length ;i++) {
|
|
|
|
|
|
|
|
|
|
GroupInfo groupInfo = groupInfoList.get(i);
|
|
|
|
|
String converter = groupInfo.getCategoryNameConverter();
|
|
|
|
|
|
|
|
|
|
if(converter.equals("") || converter.equals("plain")) { //일반텍스트
|
|
|
|
|
String ctgrType = groupInfo.getCtgrType();
|
|
|
|
|
String dtlCtgr = groupInfo.getDtlCtgr();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ctgrType.equals("") || ctgrType.equals("plain")) { //일반텍스트
|
|
|
|
|
compositeItemName[i] = compositeItemId[i];
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -304,13 +347,13 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
String itemName = "";
|
|
|
|
|
|
|
|
|
|
if(converter.startsWith("code=")){ //공통코드
|
|
|
|
|
if(ctgrType.equals("code")){ //공통코드
|
|
|
|
|
|
|
|
|
|
itemName = codeConverter.codeToValue(converter.split("=")[1], compositeItemId[i]);
|
|
|
|
|
itemName = codeConverter.codeToValue(dtlCtgr, compositeItemId[i]);
|
|
|
|
|
|
|
|
|
|
} else if(converter.startsWith("otherCode=")) { //비공통코드
|
|
|
|
|
} else if(ctgrType.equals("otherCode")) { //비공통코드
|
|
|
|
|
|
|
|
|
|
if(converter.equals("otherCode=VLTN_CD")) {
|
|
|
|
|
if(dtlCtgr.equals("VLTN_CD")) {
|
|
|
|
|
|
|
|
|
|
String taskSeCd = "";
|
|
|
|
|
if(taskSeCdIndex != -1) {
|
|
|
|
@ -324,13 +367,13 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemName = codeConverter.vltnCdToValue(taskSeCd, compositeItemId[i]);
|
|
|
|
|
} else if(converter.equals("otherCode=VLTN_ID")) {
|
|
|
|
|
} else if(dtlCtgr.equals("VLTN_ID")) {
|
|
|
|
|
itemName = codeConverter.vltnIdToValue(compositeItemId[i]);
|
|
|
|
|
} else if(converter.equals("otherCode=SGG_CD")) {
|
|
|
|
|
} else if(dtlCtgr.equals("SGG_CD")) {
|
|
|
|
|
itemName = codeConverter.sggCodeToValue(compositeItemId[i]);
|
|
|
|
|
} else if(converter.equals("otherCode=DEPT_CD")) {
|
|
|
|
|
} else if(dtlCtgr.equals("DEPT_CD")) {
|
|
|
|
|
itemName = codeConverter.deptCodeToValue(compositeItemId[i]);
|
|
|
|
|
} else if(converter.equals("otherCode=USER_ID")) {
|
|
|
|
|
} else if(dtlCtgr.equals("USER_ID")) {
|
|
|
|
|
itemName = codeConverter.userIdToUserName(compositeItemId[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -365,9 +408,9 @@ public class StatBean extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
String aggregateType = numberValueInfo.getAggregateType();
|
|
|
|
|
|
|
|
|
|
if(aggregateType.startsWith("ratio=")) {
|
|
|
|
|
if(aggregateType.equals("ratio")) {
|
|
|
|
|
|
|
|
|
|
int refIndex = Integer.parseInt(aggregateType.split("=")[1]);
|
|
|
|
|
int refIndex = numberValueInfo.getRatioRefIndex();
|
|
|
|
|
|
|
|
|
|
int totValue = statItem.getNumberValue()[refIndex];
|
|
|
|
|
if(totValue == 0) {
|
|
|
|
|