diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/IndexConstant.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/IndexConstant.java index 27facb34f2..3f174a32b2 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/IndexConstant.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/IndexConstant.java @@ -32,14 +32,17 @@ public class IndexConstant { public static final String THRESHOLD_TEXT = "给定阈值%d%%,超过阈值不加分"; public static final String TABLE_DESC = "详见下表:"; public static final String INDEX_SCORE_TITLE = "当月指数"; - public static final String INDEX_SCORE_DESC = "自然月周期内,当月指数得分(totalScore)=党建指数得分(dangjiannengli)*相关权重(dangjiannengliweight)+治理指数得分(zhilinengli)*相关权重(zhilinengliweight)+服务指数得分(fuwunengli)*相关权重(fuwunengliweight)"; + public static final String INDEX_SCORE_DESC = "自然月周期内,当月指数得分#(totalScore)#=党建指数得分#(dangjiannengli)#*相关权重#(dangjiannengliweight)#" + + "+治理指数得分#(zhilinengli)#*相关权重#(zhilinengliweight)#+服务指数得分#(fuwunengli)#*相关权重#(fuwunengliweight)#"; public static final String INDEX_DISTRINCT_TABLE1_INDEX_CODE = "suoyoujiedaozlnlpjz"; public static final String INDEX_DISTRINCT_TABLE2_INDEX_CODE = "suoyouzhishubmzlnlpjz"; public static final String ZHI_LI_NENG_LI = "zhilinengli"; + public static final String PATTERN_FIX = "#"; public static final String PATTERN_D = "d"; public static final String PATTERN_WEIGHT = "weight"; public static final String PATTERN_TOTAL = "totalScore"; public static final String QUAN_QU_ZHI_LI_INDEX_CODE = "quanquxiangguan:zhilinengli"; + public static final String PATTERN_ALL = "[#][^#]+[#]"; /** diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/index/impl/IndexExplainServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/index/impl/IndexExplainServiceImpl.java index cdde8c050d..ae40c88329 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/index/impl/IndexExplainServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/index/impl/IndexExplainServiceImpl.java @@ -19,6 +19,7 @@ package com.epmet.datareport.service.evaluationindex.index.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; 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.utils.DateUtils; import com.epmet.constant.DataSourceConstant; @@ -89,7 +90,6 @@ public class IndexExplainServiceImpl implements IndexExplainService { first.setTitle(IndexConstant.INDEX_SCORE_TITLE); first.setMeaning(IndexConstant.INDEX_SCORE_DESC); results.add(first); - //获取该等级的分数及权重 List explainDTOList = indexExplainDao.getIndexExplainTreeByOrgType(formDTO.getOrgLevel()); if (CollectionUtils.isEmpty(explainDTOList)) { @@ -120,19 +120,21 @@ public class IndexExplainServiceImpl implements IndexExplainService { ablityListFormDTO.setAllParentIndexCode(explainDTO.getIndexCode()); ablityListFormDTO.setMonthId(StringUtils.isBlank(formDTO.getMonthId()) ? DateUtils.getCurrentTimeBeforeMonthId() : formDTO.getMonthId()); List scoreResults = agencySubScoreDao.selectSubScore(ablityListFormDTO); - scoreResults.forEach(e->{ - String newMeaning = result.getMeaning().replaceFirst(e.getIndexCode(),e.getScore().toString()) + 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());; + e.getWeight().multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.ZERO, BigDecimal.ROUND_HALF_UP).toString()); result.setMeaning(newMeaning); }); } + + //设置表格数据 setTableData(formDTO, detailEntityMap, explainDTO, result); //子节点 setChildren(formDTO, detailEntityMap, result, explainDTO, explainDTO.getChildren()); - //设置 新的含义 带分数的 - setCurrentMonthScore(formDTO, first,result); + //设置 新的含义 带分数的 + setCurrentMonthScore(formDTO, first, result); } return results; @@ -166,9 +168,10 @@ public class IndexExplainServiceImpl implements IndexExplainService { default: log.error("暂不支持更高级别的查询,level:{}", orgLevel); } - if (CollectionUtils.isNotEmpty(list)) { - setNewMeaningWithScore(list, first,second); - } + + setNewMeaningWithScore(list, first, second); + + } private void setNewMeaningWithScore(List list, IndexExplainResult first, IndexExplainResult second) { @@ -181,15 +184,31 @@ public class IndexExplainServiceImpl implements IndexExplainService { continue; } - firstMeaning = firstMeaning.replaceFirst(indexCode, score.getScore().toString()).replaceFirst(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())){ + 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()); } } - first.setMeaning(firstMeaning); - second.setMeaning(secondMeaning); + 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> detailEntityMap, IndexExplainTreeDTO explainDTO, IndexExplainResult result) { @@ -375,10 +394,6 @@ public class IndexExplainServiceImpl implements IndexExplainService { result.setChildren(childrenList); } - public static void main(String[] args) { - - } - private List getTableHeaders(String type, String allIndexCode, String orgLevel) { List headers = new ArrayList<>(); OrgLevelEnum anEnum = OrgLevelEnum.getEnum(orgLevel);