@ -19,6 +19,7 @@ package com.epmet.datareport.service.evaluationindex.index.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource ;
import com.epmet.commons.dynamic.datasource.annotation.DataSource ;
import com.epmet.commons.tools.constant.NumConstant ;
import com.epmet.commons.tools.constant.NumConstant ;
import com.epmet.commons.tools.constant.StrConstant ;
import com.epmet.commons.tools.enums.OrgLevelEnum ;
import com.epmet.commons.tools.enums.OrgLevelEnum ;
import com.epmet.commons.tools.utils.DateUtils ;
import com.epmet.commons.tools.utils.DateUtils ;
import com.epmet.constant.DataSourceConstant ;
import com.epmet.constant.DataSourceConstant ;
@ -67,13 +68,19 @@ public class IndexExplainServiceImpl implements IndexExplainService {
@Autowired
@Autowired
private FactIndexGridSubScoreDao gridSubScoreDao ;
private FactIndexGridSubScoreDao gridSubScoreDao ;
@Autowired
@Autowired
private FactIndexGridScoreDao gridScoreDao ;
@Autowired
private FactIndexCpcSubScoreDao factIndexCpcSubScoreDao ;
private FactIndexCpcSubScoreDao factIndexCpcSubScoreDao ;
@Autowired
@Autowired
private FactIndexCommunitySubScoreDao communitySubScoreDao ;
private FactIndexCommunitySubScoreDao communitySubScoreDao ;
@Autowired
@Autowired
private FactIndexCommunityScoreDao communityScoreDao ;
@Autowired
private FactIndexAgencySubScoreDao agencySubScoreDao ;
private FactIndexAgencySubScoreDao agencySubScoreDao ;
@Autowired
@Autowired
private FactIndexDeptSubScoreDao deptSubScoreDao ;
private FactIndexDeptSubScoreDao deptSubScoreDao ;
@Autowired
private FactIndexAgencyScoreDao agencyScoreDao ;
@Override
@Override
@ -83,6 +90,7 @@ public class IndexExplainServiceImpl implements IndexExplainService {
first . setTitle ( IndexConstant . INDEX_SCORE_TITLE ) ;
first . setTitle ( IndexConstant . INDEX_SCORE_TITLE ) ;
first . setMeaning ( IndexConstant . INDEX_SCORE_DESC ) ;
first . setMeaning ( IndexConstant . INDEX_SCORE_DESC ) ;
results . add ( first ) ;
results . add ( first ) ;
List < IndexExplainTreeDTO > explainDTOList = indexExplainDao . getIndexExplainTreeByOrgType ( formDTO . getOrgLevel ( ) ) ;
List < IndexExplainTreeDTO > explainDTOList = indexExplainDao . getIndexExplainTreeByOrgType ( formDTO . getOrgLevel ( ) ) ;
if ( CollectionUtils . isEmpty ( explainDTOList ) ) {
if ( CollectionUtils . isEmpty ( explainDTOList ) ) {
return null ;
return null ;
@ -100,20 +108,33 @@ public class IndexExplainServiceImpl implements IndexExplainService {
results . add ( result ) ;
results . add ( result ) ;
result . setTitle ( explainDTO . getTitle ( ) ) ;
result . setTitle ( explainDTO . getTitle ( ) ) ;
result . setMeaning ( explainDTO . getMeaning ( ) ) ;
result . setMeaning ( explainDTO . getMeaning ( ) ) ;
result . setIndexCode ( explainDTO . getIndexCode ( ) ) ;
//全区相关的服务能力的含义中 有权重 所以特殊处理下
//全区相关的服务能力的含义中 有权重 所以特殊处理下
if ( explainDTO . getOrgLevel ( ) . equals ( OrgLevelEnum . DISTRICT . getCode ( ) ) & & IndexConstant . ZLZS_CN . equals ( explainDTO . getTitle ( ) ) ) {
if ( explainDTO . getOrgLevel ( ) . equals ( OrgLevelEnum . DISTRICT . getCode ( ) ) & & IndexConstant . ZLZS_CN . equals ( explainDTO . getTitle ( ) ) ) {
List < IndexGroupDetailResult > detailResults = detailEntityMap . get ( IndexConstant . QUAN_QU_ZHI_LI_INDEX_CODE ) ;
detailResults . forEach ( index - > {
//获取分数 补充下
String newMeaning = result . getMeaning ( ) . replaceFirst ( IndexConstant . PATTERN_D ,
IndexScoreFormDTO ablityListFormDTO = new IndexScoreFormDTO ( ) ;
index . getWeight ( ) . multiply ( new BigDecimal ( NumConstant . ONE_HUNDRED ) ) . setScale ( NumConstant . ZERO , BigDecimal . ROUND_HALF_UP ) . toString ( ) ) ;
ablityListFormDTO . setCustomerId ( formDTO . getCustomerId ( ) ) ;
ablityListFormDTO . setOrgId ( formDTO . getOrgId ( ) ) ;
ablityListFormDTO . setAllParentIndexCode ( explainDTO . getIndexCode ( ) ) ;
ablityListFormDTO . setMonthId ( StringUtils . isBlank ( formDTO . getMonthId ( ) ) ? DateUtils . getCurrentTimeBeforeMonthId ( ) : formDTO . getMonthId ( ) ) ;
List < IndexScoreResult > scoreResults = agencySubScoreDao . selectSubScore ( ablityListFormDTO ) ;
scoreResults . forEach ( e - > {
String newMeaning = result . getMeaning ( ) . replaceFirst ( e . getIndexCode ( ) , e . getScore ( ) . toString ( ) )
. replaceFirst ( IndexConstant . PATTERN_D ,
e . getWeight ( ) . multiply ( new BigDecimal ( NumConstant . ONE_HUNDRED ) ) . setScale ( NumConstant . ZERO , BigDecimal . ROUND_HALF_UP ) . toString ( ) ) ;
result . setMeaning ( newMeaning ) ;
result . setMeaning ( newMeaning ) ;
} ) ;
} ) ;
}
}
//设置表格数据
//设置表格数据
setTableData ( formDTO , detailEntityMap , explainDTO , result ) ;
setTableData ( formDTO , detailEntityMap , explainDTO , result ) ;
//子节点
//子节点
setChildren ( formDTO , detailEntityMap , result , explainDTO , explainDTO . getChildren ( ) ) ;
setChildren ( formDTO , detailEntityMap , result , explainDTO , explainDTO . getChildren ( ) ) ;
//设置 新的含义 带分数的
setCurrentMonthScore ( formDTO , first , result ) ;
}
}
return results ;
return results ;
@ -124,6 +145,72 @@ public class IndexExplainServiceImpl implements IndexExplainService {
return indexDictDao . selectIndexDict ( formDTO . getIndexCode ( ) ) ;
return indexDictDao . selectIndexDict ( formDTO . getIndexCode ( ) ) ;
}
}
private void setCurrentMonthScore ( IndexExplainFormDTO formDTO , IndexExplainResult first , IndexExplainResult second ) {
String orgLevel = formDTO . getOrgLevel ( ) ;
OrgLevelEnum anEnum = OrgLevelEnum . getEnum ( orgLevel ) ;
List < IndexScoreResult > list = null ;
switch ( anEnum ) {
case GRID :
list = gridScoreDao . selectGridScoreList ( formDTO . getCustomerId ( ) , formDTO . getOrgId ( ) , formDTO . getMonthId ( ) ) ;
break ;
case COMMUNITY :
list = communityScoreDao . selectComunityScoreList ( formDTO . getCustomerId ( ) , formDTO . getOrgId ( ) , formDTO . getMonthId ( ) ) ;
break ;
case STREET :
list = agencyScoreDao . selectAgencyScoreList ( formDTO . getCustomerId ( ) , formDTO . getOrgId ( ) , formDTO . getMonthId ( ) ) ;
break ;
case DISTRICT :
list = agencyScoreDao . selectAgencyScoreList ( formDTO . getCustomerId ( ) , formDTO . getOrgId ( ) , formDTO . getMonthId ( ) ) ;
break ;
default :
log . error ( "暂不支持更高级别的查询,level:{}" , orgLevel ) ;
}
setNewMeaningWithScore ( list , first , second ) ;
}
private void setNewMeaningWithScore ( List < IndexScoreResult > list , IndexExplainResult first , IndexExplainResult second ) {
String firstMeaning = first . getMeaning ( ) ;
String secondMeaning = second . getMeaning ( ) ;
for ( IndexScoreResult score : list ) {
String indexCode = score . getIndexCode ( ) ;
if ( score . getIsTotal ( ) ) {
firstMeaning = firstMeaning . replaceFirst ( IndexConstant . PATTERN_TOTAL , score . getScore ( ) . toString ( ) ) ;
continue ;
}
firstMeaning = firstMeaning . replaceFirst ( indexCode , score . getScore ( ) . toString ( ) ) . replace ( indexCode . concat ( IndexConstant . PATTERN_WEIGHT ) , score . getWeight ( ) . multiply ( new BigDecimal ( NumConstant . ONE_HUNDRED ) ) . setScale ( NumConstant . ZERO , BigDecimal . ROUND_HALF_UP ) . toString ( ) + "%" ) ;
if ( second . getIndexCode ( ) . contains ( score . getIndexCode ( ) ) ) {
secondMeaning = secondMeaning . replaceFirst ( IndexConstant . PATTERN_TOTAL , score . getScore ( ) . toString ( ) )
. replaceFirst ( IndexConstant . BEN_JI_EN , score . getSelfScore ( ) . toString ( ) )
. replaceFirst ( IndexConstant . XIA_JI_EN , score . getSubScore ( ) . toString ( ) ) ;
}
}
if ( CollectionUtils . isEmpty ( list ) ) {
firstMeaning = firstMeaning . replaceAll ( IndexConstant . PATTERN_ALL , StrConstant . EPMETY_STR ) ;
secondMeaning = secondMeaning . replaceAll ( IndexConstant . PATTERN_ALL , StrConstant . EPMETY_STR ) ;
}
first . setMeaning ( firstMeaning . replaceAll ( IndexConstant . PATTERN_FIX , StrConstant . EPMETY_STR ) ) ;
second . setMeaning ( secondMeaning . replaceAll ( IndexConstant . PATTERN_FIX , StrConstant . EPMETY_STR ) ) ;
}
public static void main ( String [ ] args ) {
String patern = "(?<=\\{).*?(?=(\\}|$))" ;
patern = "[#][^#]+[#]" ;
String str = "1234#qwert#134" ;
System . out . println ( str . replaceAll ( patern , "" ) ) ;
String str2 = "自然月周期内,当月指数得分P(totalScore)P=党建指数得分#(65.7)#*相关权重#(40%)#+治理指数得分#(68.2)#*相关权重#(40%)#+服务指数得分#(77.5)#*相关权重#(20%)#" ;
String totalP = "P" . concat ( IndexConstant . PATTERN_TOTAL ) . concat ( "P" ) ;
System . out . println ( str2 . replaceFirst ( totalP , "" ) ) ;
}
private void setTableData ( IndexExplainFormDTO formDTO , Map < String , List < IndexGroupDetailResult > > detailEntityMap , IndexExplainTreeDTO explainDTO , IndexExplainResult result ) {
private void setTableData ( IndexExplainFormDTO formDTO , Map < String , List < IndexGroupDetailResult > > detailEntityMap , IndexExplainTreeDTO explainDTO , IndexExplainResult result ) {
if ( NumConstant . ONE = = explainDTO . getIsSearch ( ) ) {
if ( NumConstant . ONE = = explainDTO . getIsSearch ( ) ) {
List < IndexScoreResult > realScoreList = null ;
List < IndexScoreResult > realScoreList = null ;
@ -174,6 +261,9 @@ public class IndexExplainServiceImpl implements IndexExplainService {
List < IndexGroupDetailResult > indexGroupDetailEntities = new ArrayList < > ( ) ;
List < IndexGroupDetailResult > indexGroupDetailEntities = new ArrayList < > ( ) ;
for ( IndexGroupDetailResult index : detailResults ) {
for ( IndexGroupDetailResult index : detailResults ) {
if ( IndexConstant . INDEX_DISTRINCT_TABLE1_INDEX_CODE . equals ( index . getIndexCode ( ) ) ) {
if ( IndexConstant . INDEX_DISTRINCT_TABLE1_INDEX_CODE . equals ( index . getIndexCode ( ) ) ) {
String newMeaning = result . getMeaning ( ) . replaceFirst ( IndexConstant . PATTERN_D ,
index . getWeight ( ) . multiply ( new BigDecimal ( NumConstant . ONE_HUNDRED ) ) . setScale ( NumConstant . ZERO , BigDecimal . ROUND_HALF_UP ) . toString ( ) ) ;
result . setMeaning ( newMeaning ) ;
indexGroupDetailEntities . add ( index ) ;
indexGroupDetailEntities . add ( index ) ;
setDefaultTableData ( orgLevel , type , detailEntityMap , result , allIndexCodePath , indexGroupDetailEntities ) ;
setDefaultTableData ( orgLevel , type , detailEntityMap , result , allIndexCodePath , indexGroupDetailEntities ) ;
//不下钻
//不下钻
@ -251,14 +341,14 @@ public class IndexExplainServiceImpl implements IndexExplainService {
}
}
}
}
private List < IndexScoreDetailResult > setDefaultTableData ( String orgLevel , String type , Map < String , List < IndexGroupDetailResult > > detailEntityMap ,
private void setDefaultTableData ( String orgLevel , String type , Map < String , List < IndexGroupDetailResult > > detailEntityMap ,
IndexExplainResult result , String allIndexCodePath , List < IndexGroupDetailResult > indexGroupDetailEntities ) {
IndexExplainResult result , String allIndexCodePath , List < IndexGroupDetailResult > indexGroupDetailEntities ) {
if ( indexGroupDetailEntities = = null ) {
if ( indexGroupDetailEntities = = null ) {
indexGroupDetailEntities = detailEntityMap . get ( allIndexCodePath ) ;
indexGroupDetailEntities = detailEntityMap . get ( allIndexCodePath ) ;
}
}
if ( CollectionUtils . isEmpty ( indexGroupDetailEntities ) ) {
if ( CollectionUtils . isEmpty ( indexGroupDetailEntities ) ) {
log . warn ( "setDefaultTableData allINdexCodePath:{} is config error" , allIndexCodePath ) ;
log . warn ( "setDefaultTableData allINdexCodePath:{} is config error" , allIndexCodePath ) ;
return null ;
return ;
}
}
List < IndexScoreDetailResult > tableList = new ArrayList < > ( ) ;
List < IndexScoreDetailResult > tableList = new ArrayList < > ( ) ;
List < String > threlodList = new ArrayList < > ( ) ;
List < String > threlodList = new ArrayList < > ( ) ;
@ -287,7 +377,6 @@ public class IndexExplainServiceImpl implements IndexExplainService {
result . setTableDataList ( tableList ) ;
result . setTableDataList ( tableList ) ;
result . setThresholdList ( threlodList ) ;
result . setThresholdList ( threlodList ) ;
result . setTableDesc ( IndexConstant . TABLE_DESC ) ;
result . setTableDesc ( IndexConstant . TABLE_DESC ) ;
return tableList ;
}
}
private void setChildren ( IndexExplainFormDTO formDTO , Map < String , List < IndexGroupDetailResult > > detailEntityMap , IndexExplainResult result , IndexExplainTreeDTO parentNode , List < IndexExplainTreeDTO > children ) {
private void setChildren ( IndexExplainFormDTO formDTO , Map < String , List < IndexGroupDetailResult > > detailEntityMap , IndexExplainResult result , IndexExplainTreeDTO parentNode , List < IndexExplainTreeDTO > children ) {
@ -305,10 +394,6 @@ public class IndexExplainServiceImpl implements IndexExplainService {
result . setChildren ( childrenList ) ;
result . setChildren ( childrenList ) ;
}
}
public static void main ( String [ ] args ) {
}
private List < String > getTableHeaders ( String type , String allIndexCode , String orgLevel ) {
private List < String > getTableHeaders ( String type , String allIndexCode , String orgLevel ) {
List < String > headers = new ArrayList < > ( ) ;
List < String > headers = new ArrayList < > ( ) ;
OrgLevelEnum anEnum = OrgLevelEnum . getEnum ( orgLevel ) ;
OrgLevelEnum anEnum = OrgLevelEnum . getEnum ( orgLevel ) ;