통계 수정

main
이범준 1 year ago
parent 9c640066a6
commit 649bce1083

@ -6,11 +6,15 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
@ -218,4 +222,14 @@ public class CmmnUtil {
return yyyyMMddFormat.format(cal.getTime());
}
public static String getDayOfWeek(String dateStr) {
int y = Integer.parseInt(dateStr.substring(0,4));
int m = Integer.parseInt(dateStr.substring(4,6));
int d = Integer.parseInt(dateStr.substring(6,8));
LocalDate date = LocalDate.of(y, m, d);
DayOfWeek dayOfWeek = date.getDayOfWeek();
String dow = dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.KOREAN);
return dow;
}
}

@ -2,33 +2,43 @@ package cokr.xit.fims.stat;
public class GroupInfo {
private String groupColName;
/**
*
*/
private String refCol;
private String categoryNameConverter;
/**
*
*/
private String ctgrType;
private String categorizationAddOption;
/**
*
*/
private String dtlCtgr;
public String getGroupColName(){
return this.groupColName;
public String getRefCol(){
return this.refCol;
}
public void setGroupColName(String groupColName){
this.groupColName = groupColName;
public void setRefCol(String refCol){
this.refCol = refCol;
}
public String getCategoryNameConverter(){
return this.categoryNameConverter;
public String getCtgrType(){
return this.ctgrType;
}
public void setCategoryNameConverter(String categoryNameConverter){
this.categoryNameConverter = categoryNameConverter;
public void setCtgrType(String ctgrType){
this.ctgrType = ctgrType;
}
public String getCategorizationAddOption(){
return this.categorizationAddOption;
public String getDtlCtgr(){
return this.dtlCtgr;
}
public void setCategorizationAddOption(String categorizationAddOption){
this.categorizationAddOption = categorizationAddOption;
public void setDtlCtgr(String dtlCtgr){
this.dtlCtgr = dtlCtgr;
}
}

@ -3,21 +3,71 @@ package cokr.xit.fims.stat;
public class NumberValueInfo {
/**
*
*
*/
private String numberValueSeperator;
private String seperatorRefCol;
/**
*
*/
private String conditionValue;
/**
*
*/
private String seperatorCtgrType;
/**
*
*/
private String seperatorDtlCtgr;
/**
* (count , sum , ratio )
*/
private String aggregateType;
public String getNumberValueSeperator(){
return this.numberValueSeperator;
/**
*
*/
private String sumRefCol;
/**
*
*/
private int ratioRefIndex;
public String getSeperatorRefCol(){
return this.seperatorRefCol;
}
public void setSeperatorRefCol(String seperatorRefCol){
this.seperatorRefCol = seperatorRefCol;
}
public void setNumberValueSeperator(String numberValueSeperator){
this.numberValueSeperator = numberValueSeperator;
public String getConditionValue(){
return this.conditionValue;
}
public void setConditionValue(String conditionValue){
this.conditionValue = conditionValue;
}
public String getSeperatorCtgrType(){
return this.seperatorCtgrType;
}
public void setSeperatorCtgrType(String seperatorCtgrType){
this.seperatorCtgrType = seperatorCtgrType;
}
public String getSeperatorDtlCtgr(){
return this.seperatorDtlCtgr;
}
public void setSeperatorDtlCtgr(String seperatorDtlCtgr){
this.seperatorDtlCtgr = seperatorDtlCtgr;
}
public String getAggregateType(){
@ -28,4 +78,19 @@ public class NumberValueInfo {
this.aggregateType = aggregateType;
}
public String getSumRefCol(){
return this.sumRefCol;
}
public void setSumRefCol(String sumRefCol){
this.sumRefCol = sumRefCol;
}
public int getRatioRefIndex(){
return this.ratioRefIndex;
}
public void setRatioRefIndex(int ratioRefIndex){
this.ratioRefIndex = ratioRefIndex;
}
}

@ -53,6 +53,11 @@ public class StatQuery extends CmmnQuery {
*/
private String globalAggregate;
/**
*
*/
private String globalSumRefCol;
/**
* 릿
*/
@ -128,6 +133,15 @@ public class StatQuery extends CmmnQuery {
return self();
}
public String getGlobalSumRefCol() {
return ifEmpty(globalSumRefCol, () -> null);
}
public <T extends StatQuery> T setGlobalSumRefCol(String globalSumRefCol) {
this.globalSumRefCol = globalSumRefCol;
return self();
}
public int getDecimalPoint() {
return ifEmpty(decimalPoint, () -> null);
}

@ -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) {

@ -66,21 +66,19 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
if(statQuery.getNamedNumberValueSeperator().equals("completeAndTotal")) { //완료자료 및 전체자료
String seperator1 = "COMPLETE_YN=Y";
String seperator2 = "";
String globalAggregate = statQuery.getGlobalAggregate();
String aggregate1 = globalAggregate;
String aggregate2 = globalAggregate;
String globalSumRefCol = ifEmpty(statQuery.getGlobalSumRefCol(), () -> "") ;
List<NumberValueInfo> numberValueInfoList = new ArrayList<NumberValueInfo>();
NumberValueInfo col1 = new NumberValueInfo();
col1.setNumberValueSeperator(seperator1);
col1.setAggregateType(aggregate1);
col1.setSeperatorRefCol("COMPLETE_YN");
col1.setConditionValue("Y");
col1.setAggregateType(globalAggregate);
col1.setSumRefCol(globalSumRefCol);
numberValueInfoList.add(col1);
NumberValueInfo col2 = new NumberValueInfo();
col2.setNumberValueSeperator(seperator2);
col2.setAggregateType(aggregate2);
col2.setAggregateType(globalAggregate);
col2.setSumRefCol(globalSumRefCol);
numberValueInfoList.add(col2);
statQuery.setNumberValueInfoList(numberValueInfoList);
@ -96,7 +94,10 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
for(int i=0; i<dayRange; i++) {
NumberValueInfo numberValueInfo = new NumberValueInfo();
numberValueInfo.setNumberValueSeperator(dayColumn+"="+CmmnUtil.addDay(firstDay,i));
numberValueInfo.setSeperatorRefCol(dayColumn);
numberValueInfo.setConditionValue(CmmnUtil.addDay(firstDay,i));
numberValueInfo.setSeperatorCtgrType("date");
numberValueInfo.setSeperatorCtgrType("YYYYMMDD");
numberValueInfo.setAggregateType(globalAggregate);
numberValueInfoList.add(numberValueInfo);
}
@ -121,7 +122,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
for(GroupInfo groupInfo : GroupInfoList) {
String categorization = groupInfo.getGroupColName();
String categorization = groupInfo.getRefCol();
switch(categorization) {
case "CRDN_SE_CD" :
@ -197,7 +198,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
//비율 값 계산
boolean exsistRatioValue = false;
for(NumberValueInfo numberValueInfo : statQuery.getNumberValueInfoList()) {
if(numberValueInfo.getAggregateType().startsWith("ratio=")) {
if(numberValueInfo.getAggregateType().equals("ratio")) {
exsistRatioValue = true;
}
}

@ -67,12 +67,13 @@ public class Stat01Controller extends ApplicationController {
for(int i=0; i < groupInfoList.size(); i++) {
GroupInfo groupInfo = groupInfoList.get(i);
String converter = groupInfo.getCategoryNameConverter();
if(converter.startsWith("code=")) {
codeGroup.add(converter.split("=")[1]);
} else if(converter.startsWith("otherCode=")) {
String ctgrType = groupInfo.getCtgrType();
String dtlCtgr = groupInfo.getDtlCtgr();
if(ctgrType.equals("code")) {
codeGroup.add(dtlCtgr);
} else if(ctgrType.equals("otherCode")) {
if(converter.equals("otherCode=VLTN_CD")) {
if(dtlCtgr.equals("VLTN_CD")) {
codeGroup.add("FIM054");
codeGroup.add("FIM004");
codeGroup.add("FIM005");

@ -217,8 +217,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "CRDN_SE_CD",
categoryNameConverter : "code=FIM002"
refCol : "CRDN_SE_CD",
ctgrType : ["code"],
dtlCtgr : ["FIM002"]
}
];
@ -255,8 +256,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "등록대상이첩대상구분",
categoryNameConverter : "code=FIM999"
refCol : "등록대상이첩대상구분",
ctgrType : ["code"],
dtlCtgr : ["FIM999"]
}
];
@ -276,8 +278,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "SNDNG_SE_CD",
categoryNameConverter : "code=FIM047"
refCol : "SNDNG_SE_CD",
ctgrType : ["code"],
dtlCtgr : ["FIM047"]
}
];
@ -297,8 +300,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "OPNN_SBMSN_STTS_CD",
categoryNameConverter : "code=FIM031"
refCol : "OPNN_SBMSN_STTS_CD",
ctgrType : ["code"],
dtlCtgr : ["FIM031"]
}
];
@ -331,8 +335,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "CRDN_SE_CD",
categoryNameConverter : "code=FIM002"
refCol : "CRDN_SE_CD",
ctgrType : ["code"],
dtlCtgr : ["FIM002"]
}
];
@ -367,8 +372,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "초기자료처리",
categoryNameConverter : "code=FIM999"
refCol : "초기자료처리",
ctgrType : ["code"],
dtlCtgr : ["FIM999"]
}
];
@ -377,7 +383,6 @@ function fnLoadStatisticsDatas(){
numberValueInfoList = [
{
numberValueSeperator : "",
aggregateType : "count"
}
];
@ -396,8 +401,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "SNDNG_SE_CD",
categoryNameConverter : "code=FIM047"
refCol : "SNDNG_SE_CD",
ctgrType : ["code"],
dtlCtgr : ["FIM047"]
}
];
@ -405,7 +411,6 @@ function fnLoadStatisticsDatas(){
numberValueInfoList = [
{
numberValueSeperator : "",
aggregateType : "count"
}
];
@ -424,8 +429,9 @@ function fnLoadStatisticsDatas(){
groupInfoList = [
{
groupColName : "OPNN_SBMSN_STTS_CD",
categoryNameConverter : "code=FIM031"
refCol : "OPNN_SBMSN_STTS_CD",
ctgrType : ["code"],
dtlCtgr : ["FIM031"]
}
];
@ -433,7 +439,6 @@ function fnLoadStatisticsDatas(){
numberValueInfoList = [
{
numberValueSeperator : "",
aggregateType : "count"
}
];

Loading…
Cancel
Save