통계 수정

main
이범준 1 year ago
parent b4b50ae852
commit 7be1fa704c

@ -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;
}
}

@ -1,5 +1,7 @@
package cokr.xit.fims.stat; package cokr.xit.fims.stat;
import java.util.List;
import cokr.xit.fims.cmmn.CmmnQuery; import cokr.xit.fims.cmmn.CmmnQuery;
/** /**
@ -46,11 +48,6 @@ public class StatQuery extends CmmnQuery {
*/ */
private String[] fixedItemId; private String[] fixedItemId;
/**
* ( )
*/
private String[] regroupInfos;
/** /**
* *
*/ */
@ -81,6 +78,11 @@ public class StatQuery extends CmmnQuery {
*/ */
private int dayRange; private int dayRange;
/**
*
*/
List<CodeSubsetInfo> codeSubsetInfoList;
public String getStructureType() { public String getStructureType() {
return ifEmpty(structureType, () -> null); return ifEmpty(structureType, () -> null);
} }
@ -135,15 +137,6 @@ public class StatQuery extends CmmnQuery {
return self(); return self();
} }
public String[] getRegroupInfos() {
return ifEmpty(regroupInfos, () -> null);
}
public <T extends StatQuery> T setRegroupInfos(String... regroupInfos) {
this.regroupInfos = regroupInfos;
return self();
}
public String[] getAggregateType() { public String[] getAggregateType() {
return ifEmpty(aggregateType, () -> null); return ifEmpty(aggregateType, () -> null);
} }
@ -197,4 +190,14 @@ public class StatQuery extends CmmnQuery {
this.dayColumn = dayColumn; this.dayColumn = dayColumn;
return self(); return self();
} }
public List<CodeSubsetInfo> getCodeSubsetInfoList() {
return this.codeSubsetInfoList;
}
public <T extends StatQuery> T setCodeSubsetInfoList(List<CodeSubsetInfo> codeSubsetInfoList) {
this.codeSubsetInfoList = codeSubsetInfoList;
return self();
}
} }

@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import cokr.xit.base.code.CommonCode; import cokr.xit.base.code.CommonCode;
import cokr.xit.fims.cmmn.CmmnQuery; 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.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;
@ -148,6 +149,9 @@ public class StatBean extends AbstractComponent {
String[] addOptions = statQuery.getCategorizationAddOption(); String[] addOptions = statQuery.getCategorizationAddOption();
String[] categoryNameConverters = statQuery.getCategoryNameConverter();
List<CodeSubsetInfo> subsetInfoList = statQuery.getCodeSubsetInfoList();
Map<String, List<DataObject>> group = queryResult.stream() Map<String, List<DataObject>> group = queryResult.stream()
.collect( .collect(
@ -183,6 +187,21 @@ public class StatBean extends AbstractComponent {
result += colValue; result += colValue;
} }
} else { } 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; result += colValue;
} }
} }
@ -352,61 +371,6 @@ public class StatBean extends AbstractComponent {
} }
} }
/** .
* @param statItems , statQuery
* @return
*/
public void regroupItem(List<StatItem> 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<DataObject> refList = new ArrayList<DataObject>();
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 * @param statItems , statQuery

@ -195,12 +195,7 @@ public class StatServiceBean extends AbstractServiceBean implements StatService
//통계 항목명 변환 //통계 항목명 변환
statBean.attachItemName(stat.getStatItems(), statQuery, commonCodes); statBean.attachItemName(stat.getStatItems(), statQuery, commonCodes);
//통계 항목 재그룹화 //비율 값 계산
if(statQuery.getRegroupInfos() != null){
statBean.regroupItem(stat.getStatItems(), statQuery);
}
//비율 계산
boolean exsistRatioValue = false; boolean exsistRatioValue = false;
for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) { for(String aggregateType : Arrays.asList(statQuery.getAggregateType())) {
if(aggregateType.startsWith("ratio=")) { if(aggregateType.startsWith("ratio=")) {

@ -14,6 +14,7 @@ import cokr.xit.base.user.ManagedUser;
import cokr.xit.base.user.dao.UserMapper; import cokr.xit.base.user.dao.UserMapper;
import cokr.xit.base.web.ApplicationController; import cokr.xit.base.web.ApplicationController;
import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.crdn.dao.GlobalStngMapper;
import cokr.xit.fims.stat.CodeSubsetInfo;
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;
@ -48,6 +49,9 @@ public class Stat01Controller extends ApplicationController {
return mav; return mav;
} }
/**
* @return
*/
public ModelAndView getStatistics(StatQuery statQuery) { public ModelAndView getStatistics(StatQuery statQuery) {
ModelAndView mav = new ModelAndView("jsonView"); ModelAndView mav = new ModelAndView("jsonView");
@ -81,6 +85,16 @@ public class Stat01Controller extends ApplicationController {
commonCodes = getCodesOf(codeGroup.toArray(new String[codeGroup.size()])); 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); Stat stat = statService.getStatistics(statQuery, commonCodes);
mav.addObject("stat", stat); mav.addObject("stat", stat);

@ -197,16 +197,36 @@ function fnMakeSkeleton(){
function fnLoadStatisticsDatas(){ function fnLoadStatisticsDatas(){
var queryParam = {}; var queryParam = {};
var codeSubsetInfoList = [];
var queryInQuery = {};
//단속구분별 전체/완료 건수 //단속구분별 전체/완료 건수
queryParam = { queryParam = {
structureType : "aggregate", structureType : "aggregate",
categorization : ["CRDN_SE_CD"], categorization : ["CRDN_SE_CD"],
categoryNameConverter : ["code=FIM002"], categoryNameConverter : ["code=FIM002"],
fixedItemId : ["01","02","06","13","08","09","10","11"], fixedItemId : ["01","02","minwon","dobo"],
regroupInfos : ["08,09,10,11=민원","06,13=도보"],
namedNumberValueSeperator : "completeAndTotal" 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"); fnLoadStatisticsData(queryParam, "card1", "progressAndTotal");
//초기자료처리별 전체/완료건수 //초기자료처리별 전체/완료건수
@ -234,10 +254,23 @@ function fnLoadStatisticsDatas(){
structureType : "aggregate", structureType : "aggregate",
categorization : ["OPNN_SBMSN_STTS_CD"], categorization : ["OPNN_SBMSN_STTS_CD"],
categoryNameConverter : ["code=FIM031"], categoryNameConverter : ["code=FIM031"],
fixedItemId : ["00", "01", "02", "03"], fixedItemId : ["00", "acceptOrNonAccept", "03"],
regroupInfo : ["01,02=수용/미수용"],
namedNumberValueSeperator : "completeAndTotal" namedNumberValueSeperator : "completeAndTotal"
}; };
codeSubsetInfoList = [
{
sourceGroup : "FIM031",
sourceCodes : ["01","02"],
targetCode : "acceptOrNonAccept",
targetCodeVal : "수용/미수용"
}
];
queryInQuery = fnJsonArrayToFormData(codeSubsetInfoList, "codeSubsetInfoList");
queryParam = {...queryParam, ...queryInQuery};
//fnLoadStatisticsData(queryParam, "card4" , "progressAndTotal"); //fnLoadStatisticsData(queryParam, "card4" , "progressAndTotal");
//단속구분별 최근n일 건수 //단속구분별 최근n일 건수
@ -245,12 +278,31 @@ function fnLoadStatisticsDatas(){
structureType : "aggregate", structureType : "aggregate",
categorization : ["CRDN_SE_CD"], categorization : ["CRDN_SE_CD"],
categoryNameConverter : ["code=FIM002"], categoryNameConverter : ["code=FIM002"],
fixedItemId : ["01","02","06","13","08","09","10","11"], fixedItemId : ["01","02","dobo","minwon"],
regroupInfos : ["08,09,10,11=민원","06,13=도보"],
namedNumberValueSeperator : "lastFewDays", namedNumberValueSeperator : "lastFewDays",
dayRange : 15, dayRange : 15,
dayColumn : "CRDN_YMD" 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"); fnLoadStatisticsData(queryParam, "lineChart", "line");
//초기자료처리별 건수 차트 //초기자료처리별 건수 차트

@ -291,3 +291,23 @@ function snakeToCamel(text){
function camelToKebab(text){ function camelToKebab(text){
return text.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); 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<array.length; i++){
var json = array[i];
var keys = Object.keys(json);
for(var j=0; j<keys.length; j++){
var key = keys[j];
newObj[name+"["+i+"]."+key] = json[key];
}
}
return newObj;
}

Loading…
Cancel
Save