통계 수정

main
이범준 1 year ago
parent 541a3abc5c
commit 9c640066a6

@ -0,0 +1,31 @@
package cokr.xit.fims.stat;
public class NumberValueInfo {
/**
*
*/
private String numberValueSeperator;
/**
* (count , sum , ratio )
*/
private String aggregateType;
public String getNumberValueSeperator(){
return this.numberValueSeperator;
}
public void setNumberValueSeperator(String numberValueSeperator){
this.numberValueSeperator = numberValueSeperator;
}
public String getAggregateType(){
return this.aggregateType;
}
public void setAggregateType(String aggregateType){
this.aggregateType = aggregateType;
}
}

@ -34,19 +34,9 @@ public class StatQuery extends CmmnQuery {
private List<GroupInfo> groupInfoList; private List<GroupInfo> groupInfoList;
/** /**
* () *
*/ */
//private String[] groupColName; private List<NumberValueInfo> numberValueInfoList;
/**
*
*/
//private String[] categorizationAddOption;
/**
* (ID)
*/
//private String[] categoryNameConverter;
/** /**
* ID ( ) * ID ( )
@ -59,14 +49,9 @@ public class StatQuery extends CmmnQuery {
private String namedNumberValueSeperator; private String namedNumberValueSeperator;
/** /**
* *
*/ */
private String[] compositeNumberValueSeperator; private String globalAggregate;
/**
* (count , sum , ratio )
*/
private String[] aggregateType;
/** /**
* 릿 * 릿
@ -115,6 +100,16 @@ public class StatQuery extends CmmnQuery {
return self(); return self();
} }
public List<NumberValueInfo> getNumberValueInfoList() {
return this.numberValueInfoList;
}
public <T extends StatQuery> T setNumberValueInfoList(List<NumberValueInfo> numberValueInfoList) {
this.numberValueInfoList = numberValueInfoList;
return self();
}
public String getNamedNumberValueSeperator() { public String getNamedNumberValueSeperator() {
return ifEmpty(namedNumberValueSeperator, () -> null); return ifEmpty(namedNumberValueSeperator, () -> null);
} }
@ -124,39 +119,12 @@ public class StatQuery extends CmmnQuery {
return self(); return self();
} }
//public String[] getGroupColName() { public String getGlobalAggregate() {
//return ifEmpty(groupColName, () -> null); return ifEmpty(globalAggregate, () -> null);
//}
//public <T extends StatQuery> T setGroupColName(String... groupColName) {
//this.groupColName = groupColName;
//return self();
//}
//public String[] getCategorizationAddOption() {
//return ifEmpty(categorizationAddOption, () -> null);
//}
//public <T extends StatQuery> T setCategorizationAddOption(String... categorizationAddOption) {
//this.categorizationAddOption = categorizationAddOption;
//return self();
//}
//public String[] getCategoryNameConverter() {
//return ifEmpty(categoryNameConverter, () -> null);
//}
//public <T extends StatQuery> T setCategoryNameConverter(String... categoryNameConverter) {
//this.categoryNameConverter = categoryNameConverter;
//return self();
//}
public String[] getAggregateType() {
return ifEmpty(aggregateType, () -> null);
} }
public <T extends StatQuery> T setAggregateType(String... aggregateType) { public <T extends StatQuery> T setGlobalAggregate(String globalAggregate) {
this.aggregateType = aggregateType; this.globalAggregate = globalAggregate;
return self(); return self();
} }
@ -169,15 +137,6 @@ public class StatQuery extends CmmnQuery {
return self(); return self();
} }
public String[] getCompositeNumberValueSeperator() {
return ifEmpty(compositeNumberValueSeperator, () -> null);
}
public <T extends StatQuery> T setCompositeNumberValueSeperator(String... compositeNumberValueSeperator) {
this.compositeNumberValueSeperator = compositeNumberValueSeperator;
return self();
}
public String[] getFixedItemId() { public String[] getFixedItemId() {
return ifEmpty(fixedItemId, () -> null); return ifEmpty(fixedItemId, () -> null);
} }

@ -20,6 +20,7 @@ import cokr.xit.fims.cmmn.CmmnQuery;
import cokr.xit.fims.cmmn.CodeConverter; import cokr.xit.fims.cmmn.CodeConverter;
import cokr.xit.fims.stat.CodeSubsetInfo; import cokr.xit.fims.stat.CodeSubsetInfo;
import cokr.xit.fims.stat.GroupInfo; import cokr.xit.fims.stat.GroupInfo;
import cokr.xit.fims.stat.NumberValueInfo;
import cokr.xit.fims.stat.Stat; import cokr.xit.fims.stat.Stat;
import cokr.xit.fims.stat.StatItem; import cokr.xit.fims.stat.StatItem;
import cokr.xit.fims.stat.StatQuery; import cokr.xit.fims.stat.StatQuery;
@ -67,41 +68,6 @@ public class StatBean extends AbstractComponent {
Stat stat = new Stat(); Stat stat = new Stat();
//통계 요청 설정
int compositeSize = 0;
String[] compositeNumberValueSeperator = statQuery.getCompositeNumberValueSeperator();
String[] aggregateType = statQuery.getAggregateType();
if(compositeNumberValueSeperator == null && aggregateType == null) {
compositeSize = 1;
compositeNumberValueSeperator = new String[] {""};
aggregateType = new String[] {"count"};
} else if(compositeNumberValueSeperator != null && aggregateType == null) {
compositeSize = compositeNumberValueSeperator.length;
aggregateType = new String[compositeSize];
} else if(compositeNumberValueSeperator == null && aggregateType != null) {
compositeSize = aggregateType.length;
compositeNumberValueSeperator = new String[compositeSize];
} else {
if(compositeNumberValueSeperator.length > aggregateType.length) {
compositeSize = compositeNumberValueSeperator.length;
} else {
compositeSize = aggregateType.length;
}
}
for(int i=0; i < compositeSize; i++) {
if(compositeNumberValueSeperator[i] == null) {
compositeNumberValueSeperator[i] = "";
}
if(aggregateType[i] == null || aggregateType[i].equals("")) {
aggregateType[i] = "count";
}
}
statQuery.setAggregateType(aggregateType);
statQuery.setCompositeNumberValueSeperator(compositeNumberValueSeperator);
//통계 항목별 그룹핑 //통계 항목별 그룹핑
Map<String, List<DataObject>> group = this.grouping(queryResult, statQuery); Map<String, List<DataObject>> group = this.grouping(queryResult, statQuery);
@ -149,13 +115,6 @@ public class StatBean extends AbstractComponent {
List<GroupInfo> groupInfoList = statQuery.getGroupInfoList(); List<GroupInfo> groupInfoList = statQuery.getGroupInfoList();
//String[] categorizations = statQuery.getGroupColName();
//String[] addOptions = statQuery.getCategorizationAddOption();
//String[] categoryNameConverters = statQuery.getCategoryNameConverter();
List<CodeSubsetInfo> subsetInfoList = statQuery.getCodeSubsetInfoList(); List<CodeSubsetInfo> subsetInfoList = statQuery.getCodeSubsetInfoList();
Map<String, List<DataObject>> group = queryResult.stream() Map<String, List<DataObject>> group = queryResult.stream()
@ -258,11 +217,10 @@ public class StatBean extends AbstractComponent {
*/ */
public int[] extractNumberValue(List<DataObject> listByKey, StatQuery statQuery) { public int[] extractNumberValue(List<DataObject> listByKey, StatQuery statQuery) {
String[] compositeNumberValueSeperator = statQuery.getCompositeNumberValueSeperator(); List<NumberValueInfo> numberValueInfoList = statQuery.getNumberValueInfoList();
String[] aggregateType = statQuery.getAggregateType();
int[] aggregateArr = new int[compositeNumberValueSeperator.length]; int[] aggregateArr = new int[numberValueInfoList.size()];
for(int i=0; i < compositeNumberValueSeperator.length; i++) { for(int i=0; i < numberValueInfoList.size(); i++) {
aggregateArr[i] = 0; aggregateArr[i] = 0;
} }
@ -273,7 +231,10 @@ public class StatBean extends AbstractComponent {
for(int j=0; j < aggregateArr.length; j++) { for(int j=0; j < aggregateArr.length; j++) {
String condition = compositeNumberValueSeperator[j]; String condition = numberValueInfoList.get(j).getNumberValueSeperator();
String aggregateType = numberValueInfoList.get(j).getAggregateType();
if(!condition.equals("")) {
if(condition.contains("=")) { if(condition.contains("=")) {
@ -281,10 +242,6 @@ public class StatBean extends AbstractComponent {
String conditionColumnValue = dataObject.string(conditionColumn); String conditionColumnValue = dataObject.string(conditionColumn);
String conditionValue = condition.split("=")[1]; String conditionValue = condition.split("=")[1];
if(conditionColumnValue.equals("")) {
continue;
}
if(conditionColumn.endsWith("_DT") && conditionValue.length() == 8) { if(conditionColumn.endsWith("_DT") && conditionValue.length() == 8) {
conditionColumnValue = conditionColumnValue.substring(0,8); conditionColumnValue = conditionColumnValue.substring(0,8);
} }
@ -294,8 +251,11 @@ public class StatBean extends AbstractComponent {
} }
} }
if(aggregateType[j].startsWith("sum=")) { }
aggregateArr[j] += dataObject.number(aggregateType[j].split("=")[1]).intValue();
if(aggregateType.startsWith("sum=")) {
aggregateArr[j] += dataObject.number(aggregateType.split("=")[1]).intValue();
} else { } else {
aggregateArr[j] += 1; aggregateArr[j] += 1;
} }
@ -396,15 +356,18 @@ public class StatBean extends AbstractComponent {
int decimalPoint = statQuery.getDecimalPoint(); int decimalPoint = statQuery.getDecimalPoint();
String[] aggregateTypes = statQuery.getAggregateType(); List<NumberValueInfo> numberValueInfoList = statQuery.getNumberValueInfoList();
for(StatItem statItem : statItems) { for(StatItem statItem : statItems) {
for(int i = 0; i < aggregateTypes.length ; i++) { for(int i = 0; i < numberValueInfoList.size(); i++) {
NumberValueInfo numberValueInfo = numberValueInfoList.get(i);
String aggregateType = numberValueInfo.getAggregateType();
if(aggregateTypes[i].startsWith("ratio=")) { if(aggregateType.startsWith("ratio=")) {
int refIndex = Integer.parseInt(aggregateTypes[i].split("=")[1]); int refIndex = Integer.parseInt(aggregateType.split("=")[1]);
int totValue = statItem.getNumberValue()[refIndex]; int totValue = statItem.getNumberValue()[refIndex];
if(totValue == 0) { if(totValue == 0) {

@ -2,7 +2,6 @@ package cokr.xit.fims.stat.service.bean;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -20,6 +19,7 @@ import cokr.xit.fims.excl.service.OpnnSbmsnService;
import cokr.xit.fims.sndb.SndbQuery; import cokr.xit.fims.sndb.SndbQuery;
import cokr.xit.fims.sndb.service.SndngService; import cokr.xit.fims.sndb.service.SndngService;
import cokr.xit.fims.stat.GroupInfo; import cokr.xit.fims.stat.GroupInfo;
import cokr.xit.fims.stat.NumberValueInfo;
import cokr.xit.fims.stat.Stat; import cokr.xit.fims.stat.Stat;
import cokr.xit.fims.stat.StatQuery; import cokr.xit.fims.stat.StatQuery;
import cokr.xit.fims.stat.service.StatService; import cokr.xit.fims.stat.service.StatService;
@ -66,49 +66,42 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
if(statQuery.getNamedNumberValueSeperator().equals("completeAndTotal")) { //완료자료 및 전체자료 if(statQuery.getNamedNumberValueSeperator().equals("completeAndTotal")) { //완료자료 및 전체자료
String[] compositeNumberValueSeperator = new String[] {"COMPLETE_YN=Y", ""}; String seperator1 = "COMPLETE_YN=Y";
statQuery.setCompositeNumberValueSeperator(compositeNumberValueSeperator); String seperator2 = "";
if(statQuery.getAggregateType() == null) { String globalAggregate = statQuery.getGlobalAggregate();
String[] aggregateType = new String[] {"count", "count"}; String aggregate1 = globalAggregate;
statQuery.setAggregateType(aggregateType); String aggregate2 = globalAggregate;
}
daySetting = true;
numberValueLabel = new String[] {"처리건수","전체건수"}; List<NumberValueInfo> numberValueInfoList = new ArrayList<NumberValueInfo>();
NumberValueInfo col1 = new NumberValueInfo();
col1.setNumberValueSeperator(seperator1);
col1.setAggregateType(aggregate1);
numberValueInfoList.add(col1);
NumberValueInfo col2 = new NumberValueInfo();
col2.setNumberValueSeperator(seperator2);
col2.setAggregateType(aggregate2);
numberValueInfoList.add(col2);
statQuery.setNumberValueInfoList(numberValueInfoList);
} else if(statQuery.getNamedNumberValueSeperator().equals("lastFewDays")) { numberValueLabel = new String[] {"처리","전체"};
String[] compositeNumberValueSeperator = new String[dayRange];
for(int i=0; i<compositeNumberValueSeperator.length; i++) {
compositeNumberValueSeperator[i] = dayColumn+"="+CmmnUtil.addDay(firstDay,i);
}
statQuery.setCompositeNumberValueSeperator(compositeNumberValueSeperator);
daySetting = true; daySetting = true;
if(statQuery.getAggregateType() == null) { } else if(statQuery.getNamedNumberValueSeperator().equals("lastFewDays")) {
String[] aggregateType = new String[compositeNumberValueSeperator.length];
for(int i=0; i<compositeNumberValueSeperator.length; i++) {
aggregateType[i] = "count";
}
statQuery.setAggregateType(aggregateType);
} else if(statQuery.getAggregateType().length != statQuery.getCompositeNumberValueSeperator().length) { String globalAggregate = statQuery.getGlobalAggregate();
String[] aggregateType = new String[compositeNumberValueSeperator.length];
String defaultType = statQuery.getAggregateType()[0]; List<NumberValueInfo> numberValueInfoList = new ArrayList<NumberValueInfo>();
if(ifEmpty(defaultType,()->"").equals("")) {
defaultType = "count";
}
for(int i=0; i<compositeNumberValueSeperator.length; i++) { for(int i=0; i<dayRange; i++) {
aggregateType[i] = defaultType; NumberValueInfo numberValueInfo = new NumberValueInfo();
numberValueInfo.setNumberValueSeperator(dayColumn+"="+CmmnUtil.addDay(firstDay,i));
numberValueInfo.setAggregateType(globalAggregate);
numberValueInfoList.add(numberValueInfo);
} }
statQuery.setNumberValueInfoList(numberValueInfoList);
statQuery.setAggregateType(aggregateType);
}
numberValueLabel = new String[dayRange]; numberValueLabel = new String[dayRange];
for(int i=0; i < dayRange; i++) { for(int i=0; i < dayRange; i++) {
@ -119,6 +112,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
} }
} }
daySetting = true;
} }
String domain = ""; String domain = "";
@ -202,8 +196,8 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
//비율 값 계산 //비율 값 계산
boolean exsistRatioValue = false; boolean exsistRatioValue = false;
for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) { for(NumberValueInfo numberValueInfo : statQuery.getNumberValueInfoList()) {
if(aggregateType.startsWith("ratio=")) { if(numberValueInfo.getAggregateType().startsWith("ratio=")) {
exsistRatioValue = true; exsistRatioValue = true;
} }
} }

@ -199,6 +199,7 @@ function fnLoadStatisticsDatas(){
var mergedQuery = {}; var mergedQuery = {};
var groupInfoList = []; var groupInfoList = [];
var numberValueInfoList = [];
var codeSubsetInfoList = []; var codeSubsetInfoList = [];
var defaultQuery = {}; var defaultQuery = {};
@ -210,7 +211,8 @@ function fnLoadStatisticsDatas(){
defaultQuery = { defaultQuery = {
structureType : "aggregate", structureType : "aggregate",
fixedItemId : ["01","02","minwon","dobo"], fixedItemId : ["01","02","minwon","dobo"],
namedNumberValueSeperator : "completeAndTotal" namedNumberValueSeperator : "completeAndTotal",
globalAggregate : "count"
}; };
groupInfoList = [ groupInfoList = [
@ -247,12 +249,15 @@ function fnLoadStatisticsDatas(){
defaultQuery = { defaultQuery = {
structureType : "aggregate", structureType : "aggregate",
fixedItemId : ["등록대상","이첩대상"], fixedItemId : ["등록대상","이첩대상"],
namedNumberValueSeperator : "completeAndTotal" namedNumberValueSeperator : "completeAndTotal",
globalAggregate : "count"
}; };
groupInfoList = [ groupInfoList = [
{
groupColName : "등록대상이첩대상구분", groupColName : "등록대상이첩대상구분",
categoryNameConverter : "code=FIM999" categoryNameConverter : "code=FIM999"
}
]; ];
queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList"); queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList");
@ -265,12 +270,15 @@ function fnLoadStatisticsDatas(){
defaultQuery = { defaultQuery = {
structureType : "aggregate", structureType : "aggregate",
fixedItemId : ["01", "02", "03"], fixedItemId : ["01", "02", "03"],
namedNumberValueSeperator : "completeAndTotal" namedNumberValueSeperator : "completeAndTotal",
globalAggregate : "count"
}; };
groupInfoList = [ groupInfoList = [
{
groupColName : "SNDNG_SE_CD", groupColName : "SNDNG_SE_CD",
categoryNameConverter : "code=FIM047" categoryNameConverter : "code=FIM047"
}
]; ];
queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList"); queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList");
@ -283,12 +291,15 @@ function fnLoadStatisticsDatas(){
defaultQuery = { defaultQuery = {
structureType : "aggregate", structureType : "aggregate",
fixedItemId : ["00", "acceptOrNonAccept", "03"], fixedItemId : ["00", "acceptOrNonAccept", "03"],
namedNumberValueSeperator : "completeAndTotal" namedNumberValueSeperator : "completeAndTotal",
globalAggregate : "count"
}; };
groupInfoList = [ groupInfoList = [
{
groupColName : "OPNN_SBMSN_STTS_CD", groupColName : "OPNN_SBMSN_STTS_CD",
categoryNameConverter : "code=FIM031" categoryNameConverter : "code=FIM031"
}
]; ];
queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList"); queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList");
@ -313,6 +324,7 @@ function fnLoadStatisticsDatas(){
structureType : "aggregate", structureType : "aggregate",
fixedItemId : ["01","02","dobo","minwon"], fixedItemId : ["01","02","dobo","minwon"],
namedNumberValueSeperator : "lastFewDays", namedNumberValueSeperator : "lastFewDays",
globalAggregate : "count",
dayRange : 15, dayRange : 15,
dayColumn : "CRDN_YMD" dayColumn : "CRDN_YMD"
}; };
@ -350,19 +362,29 @@ function fnLoadStatisticsDatas(){
//초기자료처리별 건수 차트 //초기자료처리별 건수 차트
defaultQuery = { defaultQuery = {
structureType : "aggregate", structureType : "aggregate",
groupColName : ["초기자료처리"],
categoryNameConverter : ["code=FIM999"],
fixedItemId : ["단속","계고","서손"] fixedItemId : ["단속","계고","서손"]
}; };
groupInfoList = [ groupInfoList = [
{
groupColName : "초기자료처리", groupColName : "초기자료처리",
categoryNameConverter : "code=FIM999" categoryNameConverter : "code=FIM999"
}
]; ];
queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList"); queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList");
mergedQuery = {...defaultQuery, ...queryInQuery1 };
numberValueInfoList = [
{
numberValueSeperator : "",
aggregateType : "count"
}
];
queryInQuery2 = fnJsonArrayToFormData(numberValueInfoList, "numberValueInfoList");
mergedQuery = {...defaultQuery, ...queryInQuery1, ...queryInQuery2 };
//fnLoadStatisticsData(mergedQuery, "doughnutChart1", "doughnut"); //fnLoadStatisticsData(mergedQuery, "doughnutChart1", "doughnut");
@ -373,13 +395,24 @@ function fnLoadStatisticsDatas(){
}; };
groupInfoList = [ groupInfoList = [
{
groupColName : "SNDNG_SE_CD", groupColName : "SNDNG_SE_CD",
categoryNameConverter : "code=FIM047" categoryNameConverter : "code=FIM047"
}
]; ];
queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList"); queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList");
mergedQuery = {...defaultQuery, ...queryInQuery1 }; numberValueInfoList = [
{
numberValueSeperator : "",
aggregateType : "count"
}
];
queryInQuery2 = fnJsonArrayToFormData(numberValueInfoList, "numberValueInfoList");
mergedQuery = {...defaultQuery, ...queryInQuery1, ... queryInQuery2};
//fnLoadStatisticsData(mergedQuery, "doughnutChart2", "doughnut"); //fnLoadStatisticsData(mergedQuery, "doughnutChart2", "doughnut");
@ -390,13 +423,24 @@ function fnLoadStatisticsDatas(){
}; };
groupInfoList = [ groupInfoList = [
{
groupColName : "OPNN_SBMSN_STTS_CD", groupColName : "OPNN_SBMSN_STTS_CD",
categoryNameConverter : "code=FIM031" categoryNameConverter : "code=FIM031"
}
]; ];
queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList"); queryInQuery1 = fnJsonArrayToFormData(groupInfoList, "groupInfoList");
mergedQuery = {...defaultQuery, ...queryInQuery1 }; numberValueInfoList = [
{
numberValueSeperator : "",
aggregateType : "count"
}
];
queryInQuery2 = fnJsonArrayToFormData(numberValueInfoList, "numberValueInfoList");
mergedQuery = {...defaultQuery, ...queryInQuery1, ...queryInQuery2 };
//fnLoadStatisticsData(mergedQuery, "doughnutChart3", "doughnut"); //fnLoadStatisticsData(mergedQuery, "doughnutChart3", "doughnut");
} }

Loading…
Cancel
Save