From 7be1fa704c271f78d88df755e24c3a1074d46ae6 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Fri, 3 Nov 2023 14:42:19 +0900 Subject: [PATCH] =?UTF-8?q?=ED=86=B5=EA=B3=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/fims/stat/CodeSubsetInfo.java | 45 +++++++++++ .../java/cokr/xit/fims/stat/StatQuery.java | 31 ++++---- .../xit/fims/stat/service/bean/StatBean.java | 74 +++++-------------- .../stat/service/bean/StatServiceBean.java | 7 +- .../xit/fims/stat/web/Stat01Controller.java | 14 ++++ .../webapp/WEB-INF/jsp/include/dashboard.jsp | 64 ++++++++++++++-- .../js/fims/framework/cmm/cmmUtil.js | 20 +++++ 7 files changed, 174 insertions(+), 81 deletions(-) create mode 100644 src/main/java/cokr/xit/fims/stat/CodeSubsetInfo.java diff --git a/src/main/java/cokr/xit/fims/stat/CodeSubsetInfo.java b/src/main/java/cokr/xit/fims/stat/CodeSubsetInfo.java new file mode 100644 index 00000000..ce532d6d --- /dev/null +++ b/src/main/java/cokr/xit/fims/stat/CodeSubsetInfo.java @@ -0,0 +1,45 @@ +package cokr.xit.fims.stat; + +public class CodeSubsetInfo { + + private String sourceGroup; + + private String[] sourceCodes; + + private String targetCode; + + private String targetCodeVal; + + public String getSourceGroup(){ + return this.sourceGroup; + } + + public void setSourceGroup(String sourceGroup){ + this.sourceGroup = sourceGroup; + } + + public String[] getSourceCodes(){ + return this.sourceCodes; + } + + public void setSourceCodes(String[] sourceCodes){ + this.sourceCodes = sourceCodes; + } + + public String getTargetCode(){ + return this.targetCode; + } + + public void setTargetCode(String targetCode){ + this.targetCode = targetCode; + } + + public String getTargetCodeVal(){ + return this.targetCodeVal; + } + + public void setTargetCodeVal(String targetCodeVal){ + this.targetCodeVal = targetCodeVal; + } + +} diff --git a/src/main/java/cokr/xit/fims/stat/StatQuery.java b/src/main/java/cokr/xit/fims/stat/StatQuery.java index e7b41378..301dc882 100644 --- a/src/main/java/cokr/xit/fims/stat/StatQuery.java +++ b/src/main/java/cokr/xit/fims/stat/StatQuery.java @@ -1,5 +1,7 @@ package cokr.xit.fims.stat; +import java.util.List; + import cokr.xit.fims.cmmn.CmmnQuery; /**통계 요청 @@ -46,11 +48,6 @@ public class StatQuery extends CmmnQuery { */ private String[] fixedItemId; - /** - * 항목 병합 방법 (항목이 단일키일 경우) - */ - private String[] regroupInfos; - /** * 명명된 복합 수치값 구분자 */ @@ -81,6 +78,11 @@ public class StatQuery extends CmmnQuery { */ private int dayRange; + /** + * 코드 서브셋 정보 + */ + List codeSubsetInfoList; + public String getStructureType() { return ifEmpty(structureType, () -> null); } @@ -135,15 +137,6 @@ public class StatQuery extends CmmnQuery { return self(); } - public String[] getRegroupInfos() { - return ifEmpty(regroupInfos, () -> null); - } - - public T setRegroupInfos(String... regroupInfos) { - this.regroupInfos = regroupInfos; - return self(); - } - public String[] getAggregateType() { return ifEmpty(aggregateType, () -> null); } @@ -197,4 +190,14 @@ public class StatQuery extends CmmnQuery { this.dayColumn = dayColumn; return self(); } + + public List getCodeSubsetInfoList() { + return this.codeSubsetInfoList; + } + + public T setCodeSubsetInfoList(List codeSubsetInfoList) { + this.codeSubsetInfoList = codeSubsetInfoList; + return self(); + } + } diff --git a/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java b/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java index 303648dd..1a61be8b 100644 --- a/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java +++ b/src/main/java/cokr/xit/fims/stat/service/bean/StatBean.java @@ -18,6 +18,7 @@ import org.springframework.stereotype.Component; import cokr.xit.base.code.CommonCode; import cokr.xit.fims.cmmn.CmmnQuery; import cokr.xit.fims.cmmn.CodeConverter; +import cokr.xit.fims.stat.CodeSubsetInfo; import cokr.xit.fims.stat.Stat; import cokr.xit.fims.stat.StatItem; import cokr.xit.fims.stat.StatQuery; @@ -148,6 +149,9 @@ public class StatBean extends AbstractComponent { String[] addOptions = statQuery.getCategorizationAddOption(); + String[] categoryNameConverters = statQuery.getCategoryNameConverter(); + + List subsetInfoList = statQuery.getCodeSubsetInfoList(); Map> group = queryResult.stream() .collect( @@ -183,6 +187,21 @@ public class StatBean extends AbstractComponent { result += colValue; } } else { + + if(categorizations[i].endsWith("_CD") + && categoryNameConverters != null && categoryNameConverters[i].startsWith("code=") + && subsetInfoList != null && !subsetInfoList.isEmpty() + ) { + + for(CodeSubsetInfo subsetInfo : subsetInfoList) { + if(subsetInfo.getSourceGroup().equals(categoryNameConverters[i].split("=")[1])) { + if(Arrays.asList(subsetInfo.getSourceCodes()).contains(colValue)) { + colValue = subsetInfo.getTargetCode(); + } + } + } + } + result += colValue; } } @@ -352,61 +371,6 @@ public class StatBean extends AbstractComponent { } } - /** 통계의 일부 항목을 합쳐 새 범주로 묶는다. - * @param statItems 통계 항목 목록, statQuery 통계 요청 - * @return - */ - public void regroupItem(List statItems, StatQuery statQuery) { - - String refListYn = statQuery.getRefListYn(); - - String[] regroupInfos = statQuery.getRegroupInfos(); - - for(int i=0; i < regroupInfos.length; i++) { - - String[] regroupInfo = regroupInfos[i].split("="); - String[] sourceCodes = regroupInfo[0].split(","); - String targetCodeName = regroupInfo[1]; - - StatItem newItem = new StatItem(); - newItem.setItemId(new String[]{"regroup"+i}); - newItem.setItemName(new String[]{targetCodeName}); - - int[] numberValues = null; - List refList = new ArrayList(); - - for(StatItem statItem : statItems) { - if(Arrays.asList(sourceCodes).contains(statItem.getItemId()[0])) { - - if(numberValues == null) { - numberValues = statItem.getNumberValue(); - } else { - for(int j=0; j < numberValues.length; j++) { - numberValues[j] += statItem.getNumberValue()[j]; - } - } - - if(ifEmpty(refListYn, () -> "").equals("Y") - && !ifEmpty(statItem.getRefList(), () -> "").equals("") - && !statItem.getRefList().isEmpty()) { - refList.addAll(statItem.getRefList()); - } - - } - } - - newItem.setNumberValue(numberValues); - - if(ifEmpty(refListYn, () -> "").equals("Y")) { - newItem.setRefList(refList); - } - - statItems.removeIf(item -> Arrays.asList(sourceCodes).contains(item.getItemId()[0])); - - statItems.add(newItem); - - } - } /** 통계의 수치값 중 비율(%)을 계산한다. * @param statItems 통계 항목 목록, statQuery 통계 요청 diff --git a/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java b/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java index 8e4f69ff..0454ffa8 100644 --- a/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java +++ b/src/main/java/cokr/xit/fims/stat/service/bean/StatServiceBean.java @@ -195,12 +195,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService //통계 항목명 변환 statBean.attachItemName(stat.getStatItems(), statQuery, commonCodes); - //통계 항목 재그룹화 - if(statQuery.getRegroupInfos() != null){ - statBean.regroupItem(stat.getStatItems(), statQuery); - } - - //비율 계산 + //비율 값 계산 boolean exsistRatioValue = false; for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) { if(aggregateType.startsWith("ratio=")) { diff --git a/src/main/java/cokr/xit/fims/stat/web/Stat01Controller.java b/src/main/java/cokr/xit/fims/stat/web/Stat01Controller.java index ca63f1b8..d3aacbcf 100644 --- a/src/main/java/cokr/xit/fims/stat/web/Stat01Controller.java +++ b/src/main/java/cokr/xit/fims/stat/web/Stat01Controller.java @@ -14,6 +14,7 @@ import cokr.xit.base.user.ManagedUser; import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.crdn.dao.GlobalStngMapper; +import cokr.xit.fims.stat.CodeSubsetInfo; import cokr.xit.fims.stat.Stat; import cokr.xit.fims.stat.StatQuery; import cokr.xit.fims.stat.service.StatService; @@ -48,6 +49,9 @@ public class Stat01Controller extends ApplicationController { return mav; } + /** + * @return + */ public ModelAndView getStatistics(StatQuery statQuery) { ModelAndView mav = new ModelAndView("jsonView"); @@ -81,6 +85,16 @@ public class Stat01Controller extends ApplicationController { commonCodes = getCodesOf(codeGroup.toArray(new String[codeGroup.size()])); } + if(statQuery.getCodeSubsetInfoList() != null && !statQuery.getCodeSubsetInfoList().isEmpty()) { + for(CodeSubsetInfo subsetInfo : statQuery.getCodeSubsetInfoList()) { + CommonCode newCode = new CommonCode(); + newCode.setGroupID(subsetInfo.getSourceGroup()); + newCode.setCode(subsetInfo.getTargetCode()); + newCode.setValue(subsetInfo.getTargetCodeVal()); + commonCodes.get(subsetInfo.getSourceGroup()).add(newCode); + } + } + Stat stat = statService.getStatistics(statQuery, commonCodes); mav.addObject("stat", stat); diff --git a/src/main/webapp/WEB-INF/jsp/include/dashboard.jsp b/src/main/webapp/WEB-INF/jsp/include/dashboard.jsp index 755d9184..c8ab85bd 100644 --- a/src/main/webapp/WEB-INF/jsp/include/dashboard.jsp +++ b/src/main/webapp/WEB-INF/jsp/include/dashboard.jsp @@ -197,16 +197,36 @@ function fnMakeSkeleton(){ function fnLoadStatisticsDatas(){ var queryParam = {}; + var codeSubsetInfoList = []; + var queryInQuery = {}; //단속구분별 전체/완료 건수 queryParam = { structureType : "aggregate", categorization : ["CRDN_SE_CD"], categoryNameConverter : ["code=FIM002"], - fixedItemId : ["01","02","06","13","08","09","10","11"], - regroupInfos : ["08,09,10,11=민원","06,13=도보"], + fixedItemId : ["01","02","minwon","dobo"], namedNumberValueSeperator : "completeAndTotal" }; + codeSubsetInfoList = [ + { + sourceGroup : "FIM002", + sourceCodes : ["08","09","10","11"], + targetCode : "minwon", + targetCodeVal : "민원" + }, + { + sourceGroup : "FIM002", + sourceCodes : ["06","13"], + targetCode : "dobo", + targetCodeVal : "도보" + } + ]; + + queryInQuery = fnJsonArrayToFormData(codeSubsetInfoList, "codeSubsetInfoList"); + + queryParam = {...queryParam, ...queryInQuery}; + fnLoadStatisticsData(queryParam, "card1", "progressAndTotal"); //초기자료처리별 전체/완료건수 @@ -234,10 +254,23 @@ function fnLoadStatisticsDatas(){ structureType : "aggregate", categorization : ["OPNN_SBMSN_STTS_CD"], categoryNameConverter : ["code=FIM031"], - fixedItemId : ["00", "01", "02", "03"], - regroupInfo : ["01,02=수용/미수용"], + fixedItemId : ["00", "acceptOrNonAccept", "03"], namedNumberValueSeperator : "completeAndTotal" }; + + codeSubsetInfoList = [ + { + sourceGroup : "FIM031", + sourceCodes : ["01","02"], + targetCode : "acceptOrNonAccept", + targetCodeVal : "수용/미수용" + } + ]; + + queryInQuery = fnJsonArrayToFormData(codeSubsetInfoList, "codeSubsetInfoList"); + + queryParam = {...queryParam, ...queryInQuery}; + //fnLoadStatisticsData(queryParam, "card4" , "progressAndTotal"); //단속구분별 최근n일 건수 @@ -245,12 +278,31 @@ function fnLoadStatisticsDatas(){ structureType : "aggregate", categorization : ["CRDN_SE_CD"], categoryNameConverter : ["code=FIM002"], - fixedItemId : ["01","02","06","13","08","09","10","11"], - regroupInfos : ["08,09,10,11=민원","06,13=도보"], + fixedItemId : ["01","02","dobo","minwon"], namedNumberValueSeperator : "lastFewDays", dayRange : 15, dayColumn : "CRDN_YMD" }; + + codeSubsetInfoList = [ + { + sourceGroup : "FIM002", + sourceCodes : ["08","09","10","11"], + targetCode : "minwon", + targetCodeVal : "민원" + }, + { + sourceGroup : "FIM002", + sourceCodes : ["06","13"], + targetCode : "dobo", + targetCodeVal : "도보" + } + ]; + + queryInQuery = fnJsonArrayToFormData(codeSubsetInfoList, "codeSubsetInfoList"); + + queryParam = {...queryParam, ...queryInQuery}; + fnLoadStatisticsData(queryParam, "lineChart", "line"); //초기자료처리별 건수 차트 diff --git a/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js b/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js index ea4bc1e7..ccd7c50b 100644 --- a/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js +++ b/src/main/webapp/resources/js/fims/framework/cmm/cmmUtil.js @@ -291,3 +291,23 @@ function snakeToCamel(text){ function camelToKebab(text){ return text.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); } + +/** + * jsonArray를 FormData형식의 키를 갖는 json으로 치환한다. + * @return FormData형식의 키를 갖는 json + */ +function fnJsonArrayToFormData(array, name){ + newObj = {}; + + for(var i=0; i